68 lines
2.1 KiB
Ruby
68 lines
2.1 KiB
Ruby
# 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
|
|
end
|