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

Some fixes required for conflicts on revert.

parent 91e6e32d
......@@ -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)
......
......@@ -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
......
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