Commit b844fcb7 authored by Yorick Peterse's avatar Yorick Peterse

Tweak Danger for the new changelog setup

We now only inform the user about the new setup if a changelog is
required or optional. In addition, the link to the rollout issue is now
wrapped in an inline code block. Using a regular link results in a lot
of system notes and related merge requests being created, making it
difficult to navigate the issue linked to.
parent 7adf65f7
...@@ -13,6 +13,28 @@ merge_request: %<mr_iid>s ...@@ -13,6 +13,28 @@ merge_request: %<mr_iid>s
#{SEE_DOC} #{SEE_DOC}
SUGGEST_COMMENT 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) def check_changelog_yaml(path)
raw_file = File.read(path) raw_file = File.read(path)
yaml = YAML.safe_load(raw_file) yaml = YAML.safe_load(raw_file)
...@@ -75,25 +97,38 @@ elsif changelog.optional? ...@@ -75,25 +97,38 @@ elsif changelog.optional?
message changelog.optional_text message changelog.optional_text
end end
message <<~MSG if changelog.required? || changelog.optional?
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. 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.
``` 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 my commit's subject line
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` For more information, take a look at the following resources:
- 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). - `https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1564`
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
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