diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-11-15 04:02:10 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-11-15 04:02:10 +0800 |
commit | 0b5a2eef8fa5ff4976f97883b631ec28f0553f6a (patch) | |
tree | e4410baba5cb2b077b9f7257898722fbfebf20dd /app/services/commits | |
parent | 3128641f7eb93fec0930ebfb83a93dfa5e0b343a (diff) | |
download | gitlab-ce-0b5a2eef8fa5ff4976f97883b631ec28f0553f6a.tar.gz |
Add `source_branch` option for various git operations
If `source_branch` option is passed, and target branch cannot be found,
`Repository#update_branch_with_hooks` would try to create a new branch
from `source_branch`.
This way, we could make changes in the new branch while only firing
the hooks once for the changes. Previously, we can only create a new
branch first then make changes to the new branch, firing hooks twice.
This behaviour is bad for CI.
Fixes #7237
Diffstat (limited to 'app/services/commits')
-rw-r--r-- | app/services/commits/change_service.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/app/services/commits/change_service.rb b/app/services/commits/change_service.rb index 1c82599c579..04b28cfaed8 100644 --- a/app/services/commits/change_service.rb +++ b/app/services/commits/change_service.rb @@ -29,7 +29,7 @@ module Commits tree_id = repository.public_send("check_#{action}_content", @commit, @target_branch) if tree_id - create_target_branch(into) if @create_merge_request + validate_target_branch(into) if @create_merge_request repository.public_send(action, current_user, @commit, into, tree_id) success @@ -50,12 +50,12 @@ module Commits true end - def create_target_branch(new_branch) + def validate_target_branch(new_branch) # Temporary branch exists and contains the change commit - return success if repository.find_branch(new_branch) + return if repository.find_branch(new_branch) - result = CreateBranchService.new(@project, current_user) - .execute(new_branch, @target_branch, source_project: @source_project) + result = ValidateNewBranchService.new(@project, current_user). + execute(new_branch) if result[:status] == :error raise ChangeError, "There was an error creating the source branch: #{result[:message]}" |