Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/changelog_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'optparse'

CHANGELOG_REGEX =
%r{^(?:\* )?changelog: (?<category>[\w -/]{2,}), (?<subcategory>[\w -]{2,}), (?<change>.+)$}
%r{^(?:\* )?[cC]hangelog: ?(?<category>[\w -/]{2,}), ?(?<subcategory>[\w -]{2,}), ?(?<change>.+)$}
CATEGORIES = [
'Improvements',
'Bug Fixes',
Expand Down
24 changes: 24 additions & 0 deletions spec/fixtures/git_log_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,27 @@ squashed_commit_invalid:
DELIMITER
title: 'LG-5629 account buttons part 2 (#5945)'
commit_messages: []
commit_changelog_capitalized:
commit_log: |
title: Improve changelog tool flexibility for commit messages (#7000)
body:Changelog: Internal, Changelog, Improve changelog tool flexibility for commit messages
DELIMITER
title: Improve changelog tool flexibility for commit messages (#7000)
category: Internal
subcategory: Changelog
change: Improve changelog tool flexibility for commit messages
pr_number: '7000'
commit_messages:
- 'Changelog: Internal, Changelog, Improve changelog tool flexibility for commit messages'
commit_changelog_whitespace:
commit_log: |
title: Improve changelog tool flexibility for commit messages (#7000)
body:changelog:Internal,Changelog,Improve changelog tool flexibility for commit messages
DELIMITER
title: Improve changelog tool flexibility for commit messages (#7000)
category: Internal
subcategory: Changelog
change: Improve changelog tool flexibility for commit messages
pr_number: '7000'
commit_messages:
- 'changelog:Internal,Changelog,Improve changelog tool flexibility for commit messages'
28 changes: 27 additions & 1 deletion spec/scripts/changelog_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
it 'builds a git log into structured changelog objects' do
git_log = git_fixtures.values.pluck('commit_log').join("\n")
changelog_entries = generate_changelog(git_log)
expect(changelog_entries.length).to eq 4
expect(changelog_entries.length).to eq 6
fixture_and_changelog = git_fixtures.values.filter do |x|
x['category'].present?
end.zip(changelog_entries)
Expand All @@ -35,6 +35,32 @@
expect(commits.first['pr_number']).to eq changelog.first.pr_number
expect(commits.first['change']).to eq changelog.first.change
end

it 'detects changelog regardless of capitalization' do
commit = git_fixtures['commit_changelog_capitalized']
git_log = commit['commit_log']

changelog = generate_changelog(git_log)

expect(changelog).not_to be_empty
expect(commit['category']).to eq changelog.first.category
expect(commit['subcategory']).to eq changelog.first.subcategory
expect(commit['pr_number']).to eq changelog.first.pr_number
expect(commit['change']).to eq changelog.first.change
end

it 'detects changelog regardless of whitespace' do
commit = git_fixtures['commit_changelog_whitespace']
git_log = commit['commit_log']

changelog = generate_changelog(git_log)

expect(changelog).not_to be_empty
expect(commit['category']).to eq changelog.first.category
expect(commit['subcategory']).to eq changelog.first.subcategory
expect(commit['pr_number']).to eq changelog.first.pr_number
expect(commit['change']).to eq changelog.first.change
end
end

describe '#build_structured_git_log' do
Expand Down