diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2016-02-24 12:00:34 -0500 |
---|---|---|
committer | Rubén Dávila <rdavila84@gmail.com> | 2016-03-01 19:16:27 -0500 |
commit | 0c116d8ed6736de0d08ca838ae03aeca7dcaf142 (patch) | |
tree | 69eb1eb181bf63d83c81138b77141ece9303972a /app/services/commits | |
parent | 6aa50165b0acc355925e271f07ef8e87291e0232 (diff) | |
download | gitlab-ce-0c116d8ed6736de0d08ca838ae03aeca7dcaf142.tar.gz |
Check for conflicts before creating target branch.
Diffstat (limited to 'app/services/commits')
-rw-r--r-- | app/services/commits/revert_service.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/app/services/commits/revert_service.rb b/app/services/commits/revert_service.rb index 43d1c766e35..9cb918d7a2e 100644 --- a/app/services/commits/revert_service.rb +++ b/app/services/commits/revert_service.rb @@ -17,28 +17,28 @@ module Commits def commit revert_into = @create_merge_request ? @commit.revert_branch_name : @target_branch + revert_tree_id = repository.check_revert_content(@commit, @target_branch) - if @create_merge_request - # Temporary branch exists and contains the revert commit - return success if repository.find_branch(revert_into) + if revert_tree_id + create_target_branch(revert_into) if @create_merge_request - create_target_branch - end - - unless repository.revert(current_user, @commit, revert_into) + repository.revert(current_user, @commit, revert_into, revert_tree_id) + success + else error_msg = "Sorry, we cannot revert this #{params[:revert_type_title]} automatically. It may have already been reverted, or a more recent commit may have updated some of its content." raise ReversionError, error_msg end - - success end private - def create_target_branch + def create_target_branch(new_branch) + # Temporary branch exists and contains the revert commit + return success if repository.find_branch(new_branch) + result = CreateBranchService.new(@project, current_user) - .execute(@commit.revert_branch_name, @target_branch, source_project: @source_project) + .execute(new_branch, @target_branch, source_project: @source_project) if result[:status] == :error raise ReversionError, "There was an error creating the source branch: #{result[:message]}" |