diff --git a/scripts/changelog-check b/scripts/changelog-check index 71fd95fe67e..f691af9fa1e 100755 --- a/scripts/changelog-check +++ b/scripts/changelog-check @@ -3,7 +3,7 @@ require 'open3' require 'optparse' CHANGELOG_REGEX = - %r{^changelog: (?[\w -/]{2,}), (?[A-Z][\w -]{2,}), (?.+)$} + %r{^(?:\* )?changelog: (?[\w -/]{2,}), (?[A-Z][\w -]{2,}), (?.+)$} CATEGORIES = [ 'Improvements', 'Accessibility', 'Bug Fixes', 'Internal' ] @@ -18,6 +18,11 @@ def build_changelog(line) CHANGELOG_REGEX.match(line) end +def build_changelog_from_commit(commit) + commit.commit_messages.reverse.map { |message| build_changelog(message) }.compact.first || + build_changelog(commit.title) +end + # Transforms a formatted git log into structured objects. # The git format ends up printing a single commit as: # @@ -41,9 +46,10 @@ def get_git_log(base_branch, source_branch) end }.map do |title_and_commit_messages| title = title_and_commit_messages.first.first.delete_prefix('title: ') + messages = title_and_commit_messages[1] SquashedCommit.new( - title: title_and_commit_messages.first.first, - commit_messages: title_and_commit_messages[1], + title: title, + commit_messages: messages, ) end end @@ -79,7 +85,7 @@ def generate_changelog(base_branch, source_branch) log.each do |item| # Skip this commit if the skip changelog message appears next if item.commit_messages.any? { |message| message.include?(SKIP_CHANGELOG_MESSAGE) } - change = item.commit_messages.reverse.map { |message| build_changelog(message) }.compact.first + change = build_changelog_from_commit(item) next unless change pr_number = %r{\(#(?\d+)\)}.match(item[:title])