diff --git a/scripts/changelog_check.rb b/scripts/changelog_check.rb index 5af1e51f4f6..58c7f1e1a3c 100755 --- a/scripts/changelog_check.rb +++ b/scripts/changelog_check.rb @@ -3,7 +3,7 @@ require 'optparse' CHANGELOG_REGEX = - %r{^(?:\* )?changelog: (?[\w -/]{2,}), (?[\w -]{2,}), (?.+)$} + %r{^(?:\* )?[cC]hangelog: ?(?[\w -/]{2,}), ?(?[\w -]{2,}), ?(?.+)$} CATEGORIES = [ 'Improvements', 'Bug Fixes', diff --git a/spec/fixtures/git_log_changelog.yml b/spec/fixtures/git_log_changelog.yml index 7ca04ecc86c..7921ca0c420 100644 --- a/spec/fixtures/git_log_changelog.yml +++ b/spec/fixtures/git_log_changelog.yml @@ -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' diff --git a/spec/scripts/changelog_check_spec.rb b/spec/scripts/changelog_check_spec.rb index 81dac6be249..29824a1e3fa 100644 --- a/spec/scripts/changelog_check_spec.rb +++ b/spec/scripts/changelog_check_spec.rb @@ -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) @@ -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