Don't make Repository#revert aware of MRs.

This commit is contained in:
Rubén Dávila 2016-02-09 17:16:15 -05:00 committed by Robert Speicher
parent 328b52d58a
commit 11345866d8
2 changed files with 9 additions and 5 deletions

View file

@ -622,14 +622,14 @@ class Repository
merge_commit_sha
end
def revert(user, commit, base_branch, create_mr = false)
def revert(user, commit, base_branch, target_branch = nil)
source_sha = find_branch(base_branch).target
target_branch = create_mr ? commit.revert_branch_name : base_branch
target_branch ||= base_branch
args = [commit.id, source_sha]
args << { mainline: 1 } if commit.merge_commit?
# Temporary branch exists and contains the revert commit
return true if create_mr && find_branch(target_branch)
return true if (base_branch != target_branch) && find_branch(target_branch)
return false unless diff_exists?(source_sha, commit.id)
revert_index = rugged.revert_commit(*args)

View file

@ -6,7 +6,7 @@ module Commits
@source_project = params[:source_project] || @project
@target_branch = params[:target_branch]
@commit = params[:commit]
@create_merge_request = params[:create_merge_request]
@create_merge_request = params[:create_merge_request].present?
# Check push permissions to branch
validate
@ -23,7 +23,11 @@ module Commits
end
def commit
repository.revert(current_user, @commit, @target_branch, @create_merge_request)
if @create_merge_request
repository.revert(current_user, @commit, @target_branch, @commit.revert_branch_name)
else
repository.revert(current_user, @commit, @target_branch)
end
end
private