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

Create branch if it doesn't exists.

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