Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRubén Dávila <rdavila84@gmail.com>2016-02-13 05:03:07 +0300
committerRobert Speicher <rspeicher@gmail.com>2016-02-19 21:14:54 +0300
commita07021fa8e8abcf5881cece65bbe0248338d16b6 (patch)
tree34d248dd555fa9e9f76254fd79e81c1df6f8dd2b /app/models/repository.rb
parentbe54ba33ed1fed6ddef5d544c25b293a9669142f (diff)
Make more robust the test to see if a commit has been previously reverted.
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index d98277fc257..68914dc0f8f 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -628,11 +628,11 @@ class Repository
args = [commit.id, source_sha]
args << { mainline: 1 } if commit.merge_commit?
- return false unless diff_exists?(source_sha, commit.id)
-
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 @@ class Repository
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)
end
end
- def diff_exists?(source_sha, target_sha)
- rugged.diff(source_sha, target_sha).size.zero?
+ def diff_exists?(sha1, sha2)
+ rugged.diff(sha1, sha2).size > 0
end
def merged_to_root_ref?(branch_name)