Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 21:18:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 21:18:33 +0300
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/finders/repositories
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/finders/repositories')
-rw-r--r--spec/finders/repositories/changelog_commits_finder_spec.rb93
-rw-r--r--spec/finders/repositories/commits_with_trailer_finder_spec.rb38
-rw-r--r--spec/finders/repositories/previous_tag_finder_spec.rb8
3 files changed, 99 insertions, 40 deletions
diff --git a/spec/finders/repositories/changelog_commits_finder_spec.rb b/spec/finders/repositories/changelog_commits_finder_spec.rb
new file mode 100644
index 00000000000..8665d36144a
--- /dev/null
+++ b/spec/finders/repositories/changelog_commits_finder_spec.rb
@@ -0,0 +1,93 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Repositories::ChangelogCommitsFinder do
+ let_it_be(:project) { create(:project, :repository) }
+
+ describe '#each_page' do
+ it 'only yields commits with the given trailer' do
+ finder = described_class.new(
+ project: project,
+ from: '570e7b2abdd848b95f2f578043fc23bd6f6fd24d',
+ to: 'c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd'
+ )
+
+ commits = finder.each_page('Signed-off-by').to_a.flatten
+
+ expect(commits.length).to eq(1)
+ expect(commits.first.id).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e')
+ expect(commits.first.trailers).to eq(
+ 'Signed-off-by' => 'Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>'
+ )
+ end
+
+ it 'ignores commits that are reverted' do
+ # This range of commits is found on the branch
+ # https://gitlab.com/gitlab-org/gitlab-test/-/commits/trailers.
+ finder = described_class.new(
+ project: project,
+ from: 'ddd0f15ae83993f5cb66a927a28673882e99100b',
+ to: '694e6c2f08cad00d183682d9dede99615998a630'
+ )
+
+ commits = finder.each_page('Changelog').to_a.flatten
+
+ expect(commits).to be_empty
+ end
+
+ it 'includes revert commits if they have a trailer' do
+ finder = described_class.new(
+ project: project,
+ from: 'ddd0f15ae83993f5cb66a927a28673882e99100b',
+ to: 'f0a5ed60d24c98ec6d00ac010c1f3f01ee0a8373'
+ )
+
+ initial_commit = project.commit('ed2e92bf50b3da2c7cbbab053f4977a4ecbd109a')
+ revert_commit = project.commit('f0a5ed60d24c98ec6d00ac010c1f3f01ee0a8373')
+
+ commits = finder.each_page('Changelog').to_a.flatten
+
+ expect(commits).to eq([revert_commit, initial_commit])
+ end
+
+ it 'supports paginating of commits' do
+ finder = described_class.new(
+ project: project,
+ from: 'c1acaa58bbcbc3eafe538cb8274ba387047b69f8',
+ to: '5937ac0a7beb003549fc5fd26fc247adbce4a52e',
+ per_page: 1
+ )
+
+ commits = finder.each_page('Signed-off-by')
+
+ expect(commits.count).to eq(4)
+ end
+ end
+
+ describe '#revert_commit_sha' do
+ let(:finder) { described_class.new(project: project, from: 'a', to: 'b') }
+
+ it 'returns the SHA of a reverted commit' do
+ commit = double(
+ :commit,
+ description: 'This reverts commit 152c03af1b09f50fa4b567501032b106a3a81ff3.'
+ )
+
+ expect(finder.send(:revert_commit_sha, commit))
+ .to eq('152c03af1b09f50fa4b567501032b106a3a81ff3')
+ end
+
+ it 'returns nil when the commit is not a revert commit' do
+ commit = double(:commit, description: 'foo')
+
+ expect(finder.send(:revert_commit_sha, commit)).to be_nil
+ end
+
+ it 'returns nil when the commit has no description' do
+ commit = double(:commit, description: nil)
+
+ expect(finder.send(:revert_commit_sha, commit)).to be_nil
+ end
+ end
+end
diff --git a/spec/finders/repositories/commits_with_trailer_finder_spec.rb b/spec/finders/repositories/commits_with_trailer_finder_spec.rb
deleted file mode 100644
index 0c457aae340..00000000000
--- a/spec/finders/repositories/commits_with_trailer_finder_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Repositories::CommitsWithTrailerFinder do
- let(:project) { create(:project, :repository) }
-
- describe '#each_page' do
- it 'only yields commits with the given trailer' do
- finder = described_class.new(
- project: project,
- from: '570e7b2abdd848b95f2f578043fc23bd6f6fd24d',
- to: 'c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd'
- )
-
- commits = finder.each_page('Signed-off-by').to_a.flatten
-
- expect(commits.length).to eq(1)
- expect(commits.first.id).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e')
- expect(commits.first.trailers).to eq(
- 'Signed-off-by' => 'Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>'
- )
- end
-
- it 'supports paginating of commits' do
- finder = described_class.new(
- project: project,
- from: 'c1acaa58bbcbc3eafe538cb8274ba387047b69f8',
- to: '5937ac0a7beb003549fc5fd26fc247adbce4a52e',
- per_page: 1
- )
-
- commits = finder.each_page('Signed-off-by')
-
- expect(commits.count).to eq(4)
- end
- end
-end
diff --git a/spec/finders/repositories/previous_tag_finder_spec.rb b/spec/finders/repositories/previous_tag_finder_spec.rb
index 7cc33d11baf..b332dd158d1 100644
--- a/spec/finders/repositories/previous_tag_finder_spec.rb
+++ b/spec/finders/repositories/previous_tag_finder_spec.rb
@@ -12,16 +12,20 @@ RSpec.describe Repositories::PreviousTagFinder do
tag1 = double(:tag1, name: 'v1.0.0')
tag2 = double(:tag2, name: 'v1.1.0')
tag3 = double(:tag3, name: 'v2.0.0')
- tag4 = double(:tag4, name: '1.0.0')
+ tag4 = double(:tag4, name: '0.9.0')
+ tag5 = double(:tag5, name: 'v0.8.0-pre1')
+ tag6 = double(:tag6, name: 'v0.7.0')
allow(project.repository)
.to receive(:tags)
- .and_return([tag1, tag3, tag2, tag4])
+ .and_return([tag1, tag3, tag2, tag4, tag5, tag6])
expect(finder.execute('2.1.0')).to eq(tag3)
expect(finder.execute('2.0.0')).to eq(tag2)
expect(finder.execute('1.5.0')).to eq(tag2)
expect(finder.execute('1.0.1')).to eq(tag1)
+ expect(finder.execute('1.0.0')).to eq(tag4)
+ expect(finder.execute('0.9.0')).to eq(tag6)
end
end