From d1ecda7b67e1f239fb90dd1cefaef9139ac19d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 15 Mar 2022 17:44:12 +0100 Subject: Use the changelog rule from `gitlab-dangerfiles` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rule was introduced in https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/releases/v2.9.0 Signed-off-by: Rémy Coutable --- danger/rules/changelog/Dangerfile | 91 --------------------------------------- 1 file changed, 91 deletions(-) delete mode 100644 danger/rules/changelog/Dangerfile (limited to 'danger') diff --git a/danger/rules/changelog/Dangerfile b/danger/rules/changelog/Dangerfile deleted file mode 100644 index e1079b78a..000000000 --- a/danger/rules/changelog/Dangerfile +++ /dev/null @@ -1,91 +0,0 @@ -require 'yaml' - -def lint_commit(commit) - trailer = commit.message.match(/^(?Changelog):\s*(?.+)$/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) - - self.fail( - "Commit #{commit.sha} uses an invalid changelog category: #{category}" - ) - - :invalid -end - -def presented_no_changelog_labels - NO_CHANGELOG_LABELS.map { |label| %(~"#{label}") }.join(', ') -end - -NO_CHANGELOG_LABELS = [ - 'documentation', - 'type::tooling', - 'tooling::pipelines', - 'tooling::workflow', - 'ci-build', - 'meta' -].freeze - -CATEGORIES = YAML - .load_file(File.expand_path('../../../.gitlab/changelog_config.yml', __dir__)) - .fetch('categories') - .keys - .freeze - -SEE_DOC = "See [the documentation](https://docs.gitlab.com/ee/development/changelog.html).".freeze - -CHANGELOG_MISSING = <<~MSG.freeze -**[CHANGELOG missing](https://docs.gitlab.com/ee/development/changelog.html).** - -To ceate a changelog, annotate one or more commits with the `Changelog` Git -trailer. If you want to annotate the latest commit, you can do so using `git -commit --amend`. If you want to annotate older or multiple commits, you need to -do so using `git rebase -i`. - -When adding the trailer, you can use the following values: - -- #{CATEGORIES.join("\n- ")} - -For example: - -``` -This is the subject of your commit. - -This would be the body of your commit containing some extra details. - -Changelog: added -``` - -If your merge request doesn't warrant a CHANGELOG entry, consider adding any of -the #{presented_no_changelog_labels} labels. - -#{SEE_DOC} -MSG - -changelog_needed = (gitlab.mr_labels & NO_CHANGELOG_LABELS).empty? - -if changelog_needed - checked = 0 - - git.commits.each do |commit| - case lint_commit(commit) - when :valid, :invalid - checked += 1 - end - end - - warn(CHANGELOG_MISSING) if checked.zero? -end -- cgit v1.2.3