Commit acf332a7 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'tweak-new-changelog-suggestion' into 'master'

Tweak Danger for the new changelog setup

See merge request gitlab-org/gitlab!60004
parents a69667f9 b844fcb7
......@@ -13,6 +13,28 @@ merge_request: %<mr_iid>s
#{SEE_DOC}
SUGGEST_COMMENT
CATEGORIES = YAML
.load_file(File.expand_path('../../.gitlab/changelog_config.yml', __dir__))
.fetch('categories')
.keys
.freeze
def check_changelog_trailer(commit)
trailer = commit.message.match(/^Changelog:\s*(?<category>\w+)/)
return :missing if trailer.nil? || trailer[:category].nil?
category = trailer[:category]
return :valid if CATEGORIES.include?(category)
self.fail(
"Commit #{commit.sha} uses an invalid changelog category: #{category}"
)
:invalid
end
def check_changelog_yaml(path)
raw_file = File.read(path)
yaml = YAML.safe_load(raw_file)
......@@ -75,7 +97,18 @@ elsif changelog.optional?
message changelog.optional_text
end
message <<~MSG
if changelog.required? || changelog.optional?
checked = 0
git.commits.each do |commit|
case check_changelog_trailer(commit)
when :valid, :invalid
checked += 1
end
end
if checked == 0
message <<~MSG
We are in the process of rolling out a new workflow for adding changelog entries. This new workflow uses Git commit subjects and Git trailers to generate changelogs. This new approach will soon replace the current YAML based approach.
To ease the transition process, we recommend you start using both the old and new approach in parallel. This is not required at this time, but will make it easier to transition to the new approach in the future. To do so, pick the commit that should go in the changelog and add a `Changelog` trailer to it. For example:
......@@ -96,4 +129,6 @@ message <<~MSG
- https://docs.gitlab.com/ee/api/repositories.html#generate-changelog-data
If you'd like to see the new approach in action, take a look at the commits in [the Omnibus repository](https://gitlab.com/gitlab-org/omnibus-gitlab/-/commits/master).
MSG
MSG
end
end
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