Commit a07021fa authored by Rubén Dávila's avatar Rubén Dávila Committed by Robert Speicher
Browse files

Make more robust the test to see if a commit has been previously reverted.

parent be54ba33
......@@ -628,11 +628,11 @@ def revert(user, commit, base_branch, target_branch = nil)
args = [, source_sha]
args << { mainline: 1 } if commit.merge_commit?
return false unless diff_exists?(source_sha,
revert_index = rugged.revert_commit(*args)
tree_id = revert_index.write_tree(rugged)
return false if revert_index.conflicts?
return false unless diff_exists?(source_sha, tree_id)
commit_with_hooks(user, target_branch) do |ref|
committer = user_to_committer(user)
......@@ -640,14 +640,14 @@ def revert(user, commit, base_branch, target_branch = nil)
message: commit.revert_message,
author: committer,
committer: committer,
tree: revert_index.write_tree(rugged),
tree: tree_id,
parents: [rugged.lookup(source_sha)],
update_ref: ref)
def diff_exists?(source_sha, target_sha)
rugged.diff(source_sha, target_sha)
def diff_exists?(sha1, sha2)
rugged.diff(sha1, sha2).size > 0
def merged_to_root_ref?(branch_name)
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