Commit c402aeef authored by Connor Shea's avatar Connor Shea

Allow alternative names for the CHANGELOG file.

"CHANGELOG", "NEWS", "HISTORY", and "CHANGES" are recognized as Changelog files.

Also adds relevant tests for each of these names.

Resolves #14864.
parent 88e4802d
......@@ -6,6 +6,7 @@ v 8.8.0 (unreleased)
- Add 'l' shortcut to open Label dropdown on issuables and 'i' to create new issue on a project
- Updated search UI
- Replace Devise Async with Devise ActiveJob integration. !3902 (Connor Shea)
- Allow "NEWS" and "CHANGES" as alternative names for CHANGELOG. !3768 (Connor Shea)
v 8.7.1 (unreleased)
- Throttle the update of `project.last_activity_at` to 1 minute. !3848
......
......@@ -457,7 +457,7 @@ class Repository
def changelog
cache.fetch(:changelog) do
tree(:head).blobs.find do |file|
file.name =~ /\A(changelog|history)/i
file.name =~ /\A(changelog|history|changes|news)/i
end
end
end
......
......@@ -134,7 +134,43 @@ describe Repository, models: true do
end
end
describe '#license_blob' do
describe "#changelog" do
before do
repository.send(:cache).expire(:changelog)
end
it 'accepts changelog' do
expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('changelog')])
expect(repository.changelog.name).to eq('changelog')
end
it 'accepts news instead of changelog' do
expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('news')])
expect(repository.changelog.name).to eq('news')
end
it 'accepts history instead of changelog' do
expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('history')])
expect(repository.changelog.name).to eq('history')
end
it 'accepts changes instead of changelog' do
expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('changes')])
expect(repository.changelog.name).to eq('changes')
end
it 'is case-insensitive' do
expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('CHANGELOG')])
expect(repository.changelog.name).to eq('CHANGELOG')
end
end
describe "#license_blob" do
before do
repository.send(:cache).expire(:license_blob)
repository.remove_file(user, 'LICENSE', 'Remove LICENSE', 'master')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment