summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-03-02 08:59:57 -0600
committerDouwe Maan <douwe@selenight.nl>2017-03-02 08:59:57 -0600
commitf2464a13210fe77e2a01b1a5ef9b6466444da426 (patch)
treeabc6ddbd605ea7b0f6bba9f782ca195dae7aaa77
parente7bf621ab1fc04d17cd7edd8ca2350cb05e7c0e0 (diff)
downloadgitlab-ce-f2464a13210fe77e2a01b1a5ef9b6466444da426.tar.gz
Don't require start branch to exist if we're just creating a new branch
-rw-r--r--app/services/git_operation_service.rb18
1 files changed, 7 insertions, 11 deletions
diff --git a/app/services/git_operation_service.rb b/app/services/git_operation_service.rb
index 82ef34a4863..ed6ea638235 100644
--- a/app/services/git_operation_service.rb
+++ b/app/services/git_operation_service.rb
@@ -56,14 +56,17 @@ class GitOperationService
start_project: repository.project,
&block)
- start_branch_name ||= branch_name
+ start_repository = start_project.repository
+ start_branch_name = nil if start_repository.empty_repo?
- verify_start_branch_exists!(start_project.repository, start_branch_name)
+ if start_branch_name && !start_repository.branch_exists?(start_branch_name)
+ raise ArgumentError, "Cannot find branch #{start_branch_name} in #{start_repository.path_with_namespace}"
+ end
update_branch_with_hooks(branch_name) do
repository.with_repo_branch_commit(
- start_project.repository,
- start_branch_name,
+ start_repository,
+ start_branch_name || branch_name,
&block)
end
end
@@ -150,11 +153,4 @@ class GitOperationService
repository.raw_repository.autocrlf = :input
end
end
-
- def verify_start_branch_exists!(start_repository, start_branch_name)
- return if start_repository.empty_repo?
- return if start_repository.branch_exists?(start_branch_name)
-
- raise ArgumentError, "Cannot find branch #{start_branch_name} in #{start_repository.path_with_namespace}"
- end
end