save repo empty state into variable for proper result

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2015-08-17 10:24:25 +02:00
parent a608e45e6b
commit 3b93856e13
No known key found for this signature in database
GPG Key ID: 161B5D6A44D3D88A
1 changed files with 3 additions and 2 deletions

View File

@ -494,12 +494,13 @@ 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
gl_id = Gitlab::ShellEnv.gl_id(current_user) gl_id = Gitlab::ShellEnv.gl_id(current_user)
was_empty = empty?
# Create temporary ref # Create temporary ref
random_string = SecureRandom.hex random_string = SecureRandom.hex
tmp_ref = "refs/tmp/#{random_string}/head" tmp_ref = "refs/tmp/#{random_string}/head"
unless empty? unless was_empty
oldrev = find_branch(branch).target oldrev = find_branch(branch).target
rugged.references.create(tmp_ref, oldrev) rugged.references.create(tmp_ref, oldrev)
end end
@ -516,7 +517,7 @@ class Repository
status = pre_receive_hook.trigger(gl_id, oldrev, newrev, ref) status = pre_receive_hook.trigger(gl_id, oldrev, newrev, ref)
if status if status
if empty? if was_empty
# Create branch # Create branch
rugged.references.create(ref, newrev) rugged.references.create(ref, newrev)
else else