summaryrefslogtreecommitdiff
path: root/app/helpers/compare_helper.rb
blob: 2c28dd81c87b622b0e02378b7941047a301df117 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module CompareHelper
  def create_mr_button?(from = params[:from], to = params[:to], project = @project)
    from.present? &&
      to.present? &&
      from != to &&
      can?(current_user, :create_merge_request, project) &&
      project.repository.branch_names.include?(from) &&
      project.repository.branch_names.include?(to)
  end

  def create_mr_path(from = params[:from], to = params[:to], project = @project)
    project_new_merge_request_path(
      project,
      merge_request: {
        source_branch: to,
        target_branch: from
      }
    )
  end
end