diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-23 18:09:37 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-23 18:09:37 +0300 |
commit | 7e1e45d40a2312e20893ccfc6e7e5dfad6cf7b1c (patch) | |
tree | 7e0754c6a37ed9f3c13d15747cf8a5a5bce13387 /danger | |
parent | ecf1ffc19875a94c9de675b0559adc408b202515 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'danger')
-rw-r--r-- | danger/changelog/Dangerfile | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile index 9937f40f013..82ac749b531 100644 --- a/danger/changelog/Dangerfile +++ b/danger/changelog/Dangerfile @@ -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 |