summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-01-25 23:13:09 -0800
committerStan Hu <stanhu@gmail.com>2017-01-26 10:17:57 -0800
commitd09fdfd6c72e544fa3156a13cad59a791e977dce (patch)
treec52165158aff0d09789bbbf8ef7b9582371dd1ef /spec/models
parent403cb125f5e2aced8088f24966624519f6e11e29 (diff)
downloadgitlab-ce-d09fdfd6c72e544fa3156a13cad59a791e977dce.tar.gz
Fix Error 500 when repositories contain annotated tags pointing to blobssh-fix-annotated-tags-pointing-to-blob
In repositories such as https://github.com/git/git.git, annotated tags can point to blobs, not necessarily to commits. `Repository` attempts to return the tags in the order of the commit date, but if a commit is not available the previous implementation would error due to a `nil` target. This change modifies the code to use the current time if a commit is not associated with the given tag. Closes #27228
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/repository_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 99ca53938c8..b91fbc1a845 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -90,6 +90,30 @@ describe Repository, models: true do
it { is_expected.to eq(['v1.1.0', 'v1.0.0']) }
end
+
+ context 'annotated tag pointing to a blob' do
+ let(:annotated_tag_name) { 'annotated-tag' }
+
+ subject { repository.tags_sorted_by('updated_asc').map(&:name) }
+
+ before do
+ options = { message: 'test tag message\n',
+ tagger: { name: 'John Smith', email: 'john@gmail.com' } }
+ repository.rugged.tags.create(annotated_tag_name, 'a48e4fc218069f68ef2e769dd8dfea3991362175', options)
+
+ double_first = double(committed_date: Time.now - 1.second)
+ double_last = double(committed_date: Time.now)
+
+ allow(tag_a).to receive(:dereferenced_target).and_return(double_last)
+ allow(tag_b).to receive(:dereferenced_target).and_return(double_first)
+ end
+
+ it { is_expected.to eq(['v1.1.0', 'v1.0.0', annotated_tag_name]) }
+
+ after do
+ repository.rugged.tags.delete(annotated_tag_name)
+ end
+ end
end
end