2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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 &&
|
2018-04-06 08:18:58 -04:00
|
|
|
can?(current_user, :create_merge_request_from, project) &&
|
2017-10-10 10:56:04 -04:00
|
|
|
project.repository.branch_exists?(from) &&
|
|
|
|
project.repository.branch_exists?(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)
|
2017-06-29 13:06:35 -04:00
|
|
|
project_new_merge_request_path(
|
2015-05-09 16:26:25 -04:00
|
|
|
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
|