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,25 +97,38 @@ elsif changelog.optional?
message changelog.optional_text
end
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.
if changelog.required? || changelog.optional?
checked = 0
git.commits.each do |commit|
case check_changelog_trailer(commit)
when :valid, :invalid
checked += 1
end
end
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:
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.
```
This is my commit's subject line
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:
This is the optional commit body.
```
This is my commit's subject line
Changelog: added
```
This is the optional commit body.
The value of the `Changelog` trailer should be one of the following: added, fixed, changed, deprecated, removed, security, performance, other.
Changelog: added
```
For more information, take a look at the following resources:
The value of the `Changelog` trailer should be one of the following: added, fixed, changed, deprecated, removed, security, performance, other.
- `https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1564`
- https://docs.gitlab.com/ee/api/repositories.html#generate-changelog-data
For more information, take a look at the following resources:
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
- `https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1564`
- 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
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