summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/git_post_receive_spec.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-08-13 09:04:30 -0700
committerStan Hu <stanhu@gmail.com>2019-08-13 09:04:30 -0700
commite658f9603c99ca6a8ef4c0292b2cdab2916fb09e (patch)
tree57e0c03ea5dd676c7a53243bf3da20aefafc0ded /spec/lib/gitlab/git_post_receive_spec.rb
parent3702ab7317533896c7455357dd6643181666f22b (diff)
downloadgitlab-ce-sh-only-flush-tags-once-per-push.tar.gz
Only expire tag cache once per pushsh-only-flush-tags-once-per-push
Previously each tag in a push would invoke the Gitaly `FindAllTags` RPC since the tag cache would be invalidated with every tag. We can eliminate those extraneous calls by expiring the tag cache once in `PostReceive` and taking advantage of the cached tags. Relates to https://gitlab.com/gitlab-org/gitlab-ce/issues/65795
Diffstat (limited to 'spec/lib/gitlab/git_post_receive_spec.rb')
-rw-r--r--spec/lib/gitlab/git_post_receive_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git_post_receive_spec.rb b/spec/lib/gitlab/git_post_receive_spec.rb
index 1911e954df9..4c20d945585 100644
--- a/spec/lib/gitlab/git_post_receive_spec.rb
+++ b/spec/lib/gitlab/git_post_receive_spec.rb
@@ -49,4 +49,47 @@ describe ::Gitlab::GitPostReceive do
end
end
end
+
+ describe '#includes_tags?' do
+ context 'with no tags' do
+ let(:changes) do
+ <<~EOF
+ 654321 210987 refs/notags/tag1
+ 654322 210986 refs/heads/test1
+ 654323 210985 refs/merge-requests/mr1
+ EOF
+ end
+
+ it 'returns false' do
+ expect(subject.includes_tags?).to be_falsey
+ end
+ end
+
+ context 'with tags' do
+ let(:changes) do
+ <<~EOF
+ 654322 210986 refs/heads/test1
+ 654321 210987 refs/tags/tag1
+ 654323 210985 refs/merge-requests/mr1
+ EOF
+ end
+
+ it 'returns true' do
+ expect(subject.includes_tags?).to be_truthy
+ end
+ end
+
+ context 'with malformed changes' do
+ let(:changes) do
+ <<~EOF
+ ref/tags/1 a
+ sometag refs/tags/2
+ EOF
+ end
+
+ it 'returns false' do
+ expect(subject.includes_tags?).to be_falsey
+ end
+ end
+ end
end