Some fixes required for conflicts on revert.

This commit is contained in:
Rubén Dávila
2016-02-19 13:14:51 -05:00
committed by Robert Speicher
parent 91e6e32d13
commit 6b0e478353
2 changed files with 14 additions and 9 deletions
+10 -7
View File
@@ -628,18 +628,21 @@ class Repository
target_sha = find_branch(target_branch).try(:target)
# First make revert in temp branch
status = target_sha ? true : revert_commit(user, commit, target_branch, base_branch)
rm_branch(target_branch) if target_sha
success = revert_commit(user, commit, target_branch, base_branch)
# Make the revert happen in the target branch
source_sha = find_branch(target_branch).target
target_sha = find_branch(base_branch).target
has_changes = is_there_something_to_merge?(source_sha, target_sha)
if success && !create_mr
source_sha = find_branch(target_branch).target
target_sha = find_branch(base_branch).target
has_changes = is_there_something_to_merge?(source_sha, target_sha)
if has_changes && !create_mr
status = revert_commit(user, commit, base_branch, base_branch)
if has_changes
success = revert_commit(user, commit, base_branch, base_branch)
end
end
has_changes && status
has_changes && success
end
def revert_commit(user, commit, target_branch, base_branch)
+4 -2
View File
@@ -14,7 +14,9 @@ module Commits
if commit
success
else
error("Something went wrong. Your changes were not committed")
error("Sorry, we cannot revert this commit automatically.
It may have already been reverted, or a more recent commit may
have updated some of its content.")
end
rescue Repository::CommitError, Gitlab::Git::Repository::InvalidBlobName, GitHooksService::PreReceiveError, ValidationError => ex
error(ex.message)
@@ -26,7 +28,7 @@ module Commits
# Create branch with revert commit
reverted = repository.revert(current_user, @commit, @target_branch, @create_merge_request)
unless @create_merge_request
if reverted && !@create_merge_request
repository.rm_branch(current_user, @commit.revert_branch_name)
end