Commit 11345866 authored by Rubén Dávila's avatar Rubén Dávila Committed by Robert Speicher

Don't make Repository#revert aware of MRs.

parent 328b52d5
...@@ -622,14 +622,14 @@ class Repository ...@@ -622,14 +622,14 @@ class Repository
merge_commit_sha merge_commit_sha
end 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 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 = [commit.id, source_sha]
args << { mainline: 1 } if commit.merge_commit? args << { mainline: 1 } if commit.merge_commit?
# Temporary branch exists and contains the revert 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) return false unless diff_exists?(source_sha, commit.id)
revert_index = rugged.revert_commit(*args) revert_index = rugged.revert_commit(*args)
......
...@@ -6,7 +6,7 @@ module Commits ...@@ -6,7 +6,7 @@ module Commits
@source_project = params[:source_project] || @project @source_project = params[:source_project] || @project
@target_branch = params[:target_branch] @target_branch = params[:target_branch]
@commit = params[:commit] @commit = params[:commit]
@create_merge_request = params[:create_merge_request] @create_merge_request = params[:create_merge_request].present?
# Check push permissions to branch # Check push permissions to branch
validate validate
...@@ -23,7 +23,11 @@ module Commits ...@@ -23,7 +23,11 @@ module Commits
end end
def commit 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 end
private private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment