diff options
author | Yorick Peterse <yorick@yorickpeterse.com> | 2021-06-01 18:27:31 +0300 |
---|---|---|
committer | Yorick Peterse <yorick@yorickpeterse.com> | 2021-06-01 18:34:29 +0300 |
commit | 56d5110d074c897172342401299587f204511c6a (patch) | |
tree | 7ae67433b684d869d4362ea697562e4ce8aba4ed /danger | |
parent | 098c6dcdbde9824385d61b6cc56c2e10724a104b (diff) |
Ensure trailers use the right casing
Changelog trailers are processed case-sensitively by the API. This
updates Danger so it errors when using incorrect casing, such as
`changelog` instead of `Changelog`.
See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62915 for more
information.
Diffstat (limited to 'danger')
-rw-r--r-- | danger/changelog/Dangerfile | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile index 56efe44de..0aa9ff9ee 100644 --- a/danger/changelog/Dangerfile +++ b/danger/changelog/Dangerfile @@ -1,10 +1,20 @@ require 'yaml' def lint_commit(commit) - trailer = commit.message.match(/^Changelog:\s*(?<category>\w+)/) + trailer = commit.message.match(/^(?<name>Changelog):\s*(?<category>.+)$/i) return :missing if trailer.nil? || trailer[:category].nil? + name = trailer[:name] + + unless name == 'Changelog' + self.fail( + "The changelog trailer for commit #{commit.sha} must be `Changelog` (starting with a capital C), not `#{name}`" + ) + + return :invalid + end + category = trailer[:category] return :valid if CATEGORIES.include?(category) |