Methods
A
B
C
D
E
I
M
N
S
U
V
Instance Public methods
automerge()
# File app/controllers/merge_requests_controller.rb, line 74
def automerge
  return access_denied! unless can?(current_user, :accept_mr, @project)
  if @merge_request.open? && @merge_request.can_be_merged?
    @merge_request.should_remove_source_branch = params[:should_remove_source_branch]
    @merge_request.automerge!(current_user)
    @status = true
  else
    @status = false
  end
end
automerge_check()
# File app/controllers/merge_requests_controller.rb, line 67
def automerge_check
  if @merge_request.unchecked?
    @merge_request.check_if_can_be_merged
  end
  render json: {state: @merge_request.human_state}
end
branch_from()
# File app/controllers/merge_requests_controller.rb, line 85
def branch_from
  @commit = project.commit(params[:ref])
  @commit = CommitDecorator.decorate(@commit)
end
branch_to()
# File app/controllers/merge_requests_controller.rb, line 90
def branch_to
  @commit = project.commit(params[:ref])
  @commit = CommitDecorator.decorate(@commit)
end
ci_status()
# File app/controllers/merge_requests_controller.rb, line 95
def ci_status
  status = project.gitlab_ci_service.commit_status(merge_request.last_commit.sha)
  response = { status: status }

  render json: response
end
create()
# File app/controllers/merge_requests_controller.rb, line 45
def create
  @merge_request = @project.merge_requests.new(params[:merge_request])
  @merge_request.author = current_user

  if @merge_request.save
    @merge_request.reload_code
    redirect_to [@project, @merge_request], notice: 'Merge request was successfully created.'
  else
    render action: "new"
  end
end
diffs()
# File app/controllers/merge_requests_controller.rb, line 30
def diffs
  @diffs = @merge_request.diffs
  @commit = @merge_request.last_commit

  @comments_allowed = true
  @line_notes = @merge_request.notes.where("line_code is not null")
end
edit()
# File app/controllers/merge_requests_controller.rb, line 42
def edit
end
index()
# File app/controllers/merge_requests_controller.rb, line 16
def index
  @merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute
end
new()
# File app/controllers/merge_requests_controller.rb, line 38
def new
  @merge_request = @project.merge_requests.new(params[:merge_request])
end
show()
# File app/controllers/merge_requests_controller.rb, line 20
def show
  respond_to do |format|
    format.html
    format.js

    format.diff  { render text: @merge_request.to_diff }
    format.patch { render text: @merge_request.to_patch }
  end
end
update()
# File app/controllers/merge_requests_controller.rb, line 57
def update
  if @merge_request.update_attributes(params[:merge_request].merge(author_id_of_changes: current_user.id))
    @merge_request.reload_code
    @merge_request.mark_as_unchecked
    redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.'
  else
    render action: "edit"
  end
end
Instance Protected methods
authorize_admin_merge_request!()
# File app/controllers/merge_requests_controller.rb, line 112
def authorize_admin_merge_request!
  return render_404 unless can?(current_user, :admin_merge_request, @merge_request)
end
authorize_modify_merge_request!()
# File app/controllers/merge_requests_controller.rb, line 108
def authorize_modify_merge_request!
  return render_404 unless can?(current_user, :modify_merge_request, @merge_request)
end
define_show_vars()
# File app/controllers/merge_requests_controller.rb, line 129
def define_show_vars
  # Build a note object for comment form
  @note = @project.notes.new(noteable: @merge_request)

  # Get commits from repository
  # or from cache if already merged
  @commits = @merge_request.commits
  @commits = CommitDecorator.decorate(@commits)
end
merge_request()
# File app/controllers/merge_requests_controller.rb, line 104
def merge_request
  @merge_request ||= @project.merge_requests.find(params[:id])
end
module_enabled()
# File app/controllers/merge_requests_controller.rb, line 116
def module_enabled
  return render_404 unless @project.merge_requests_enabled
end
validates_merge_request()
# File app/controllers/merge_requests_controller.rb, line 120
def validates_merge_request
  # Show git not found page if target branch doesnt exist
  return git_not_found! unless @project.repo.heads.map(&:name).include?(@merge_request.target_branch)

  # Show git not found page if source branch doesnt exist
  # and there is no saved commits between source & target branch
  return git_not_found! if !@project.repo.heads.map(&:name).include?(@merge_request.source_branch) && @merge_request.commits.blank?
end