Don't require start branch to exist if we're just creating a new branch
This commit is contained in:
parent
e7bf621ab1
commit
f2464a1321
|
@ -56,14 +56,17 @@ class GitOperationService
|
||||||
start_project: repository.project,
|
start_project: repository.project,
|
||||||
&block)
|
&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
|
update_branch_with_hooks(branch_name) do
|
||||||
repository.with_repo_branch_commit(
|
repository.with_repo_branch_commit(
|
||||||
start_project.repository,
|
start_repository,
|
||||||
start_branch_name,
|
start_branch_name || branch_name,
|
||||||
&block)
|
&block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -150,11 +153,4 @@ class GitOperationService
|
||||||
repository.raw_repository.autocrlf = :input
|
repository.raw_repository.autocrlf = :input
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue