summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-15 11:17:47 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-15 11:17:47 -0800
commitde27375d6cb2772b91459f5e706aed5b03b35a54 (patch)
tree12e1012b84a61b55954b226cfc218eac57d08fc8
parenta0d4235c04e8f47e8625a6f46d64b65df599b370 (diff)
downloadgitlab-ce-de27375d6cb2772b91459f5e706aed5b03b35a54.tar.gz
Test git builder over annotated tag
-rw-r--r--lib/gitlab/push_data_builder.rb7
-rw-r--r--spec/lib/gitlab/push_data_builder_spec.rb5
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/gitlab/push_data_builder.rb b/lib/gitlab/push_data_builder.rb
index 7f5d71376f1..faea6ae375c 100644
--- a/lib/gitlab/push_data_builder.rb
+++ b/lib/gitlab/push_data_builder.rb
@@ -66,8 +66,11 @@ module Gitlab
if newrev != Gitlab::Git::BLANK_SHA && ref.start_with?('refs/tags/')
tag_name = Gitlab::Git.extract_ref_name(ref)
tag = repository.find_tag(tag_name)
- commit = repository.commit(tag.target)
- commit.try(:sha)
+
+ if tag
+ commit = repository.commit(tag.target)
+ commit.try(:sha)
+ end
else
newrev
end
diff --git a/spec/lib/gitlab/push_data_builder_spec.rb b/spec/lib/gitlab/push_data_builder_spec.rb
index fbf767a167f..691fd133637 100644
--- a/spec/lib/gitlab/push_data_builder_spec.rb
+++ b/spec/lib/gitlab/push_data_builder_spec.rb
@@ -21,13 +21,14 @@ describe 'Gitlab::PushDataBuilder' do
Gitlab::PushDataBuilder.build(project,
user,
Gitlab::Git::BLANK_SHA,
- '5937ac0a7beb003549fc5fd26fc247adbce4a52e',
+ '8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b',
'refs/tags/v1.1.0')
end
it { data.should be_a(Hash) }
it { data[:before].should == Gitlab::Git::BLANK_SHA }
- it { data[:after].should == '5937ac0a7beb003549fc5fd26fc247adbce4a52e' }
+ it { data[:checkout_sha].should == '5937ac0a7beb003549fc5fd26fc247adbce4a52e' }
+ it { data[:after].should == '8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b' }
it { data[:ref].should == 'refs/tags/v1.1.0' }
it { data[:commits].should be_empty }
it { data[:total_commits_count].should be_zero }