From 1708e1fc03439adec8e4f3aa341faaf6f378f192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Tue, 2 Feb 2016 19:48:12 -0500 Subject: [PATCH] Create branch if it doesn't exists. --- app/models/repository.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index f17d70b3dd..872066a02e 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -724,10 +724,11 @@ class Repository 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 = target_branch.target end with_tmp_ref(oldrev) do |tmp_ref| @@ -739,7 +740,7 @@ class Repository end GitHooksService.new.execute(current_user, path_to_repo, oldrev, newrev, ref) do - if was_empty + if was_empty || !target_branch # Create branch rugged.references.create(ref, newrev) else