Commit 1708e1fc authored by Rubén Dávila's avatar Rubén Dávila Committed by Robert Speicher
Browse files

Create branch if it doesn't exists.

parent df5f362c
......@@ -724,10 +724,11 @@ def commit_with_hooks(current_user, branch)
oldrev = Gitlab::Git::BLANK_SHA
ref = Gitlab::Git::BRANCH_REF_PREFIX + branch
target_branch = find_branch(branch)
was_empty = empty?
unless was_empty
oldrev = find_branch(branch).target
if !was_empty && target_branch
oldrev =
with_tmp_ref(oldrev) do |tmp_ref|
......@@ -739,7 +740,7 @@ def commit_with_hooks(current_user, branch)
end, path_to_repo, oldrev, newrev, ref) do
if was_empty
if was_empty || !target_branch
# Create branch
rugged.references.create(ref, newrev)
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