2013-09-12 13:15:10 -04:00
|
|
|
module CompareHelper
|
2015-05-09 16:26:25 -04:00
|
|
|
def create_mr_button?(from = params[:from], to = params[:to], project = @project)
|
2015-05-09 17:51:50 -04:00
|
|
|
from.present? &&
|
2015-05-09 16:26:25 -04:00
|
|
|
to.present? &&
|
|
|
|
from != to &&
|
2017-01-19 09:42:18 -05:00
|
|
|
can?(current_user, :create_merge_request, project) &&
|
2015-05-09 17:51:50 -04:00
|
|
|
project.repository.branch_names.include?(from) &&
|
|
|
|
project.repository.branch_names.include?(to)
|
2013-09-12 13:15:10 -04:00
|
|
|
end
|
|
|
|
|
2015-05-09 16:26:25 -04:00
|
|
|
def create_mr_path(from = params[:from], to = params[:to], project = @project)
|
2015-01-24 13:02:58 -05:00
|
|
|
new_namespace_project_merge_request_path(
|
2015-05-09 16:26:25 -04:00
|
|
|
project.namespace,
|
|
|
|
project,
|
2015-01-24 13:02:58 -05:00
|
|
|
merge_request: {
|
2015-05-09 16:26:25 -04:00
|
|
|
source_branch: to,
|
|
|
|
target_branch: from
|
2015-01-24 13:02:58 -05:00
|
|
|
}
|
|
|
|
)
|
2013-09-12 13:15:10 -04:00
|
|
|
end
|
|
|
|
end
|