diff options
Diffstat (limited to 'danger')
-rw-r--r-- | danger/changelog/Dangerfile | 28 | ||||
-rw-r--r-- | danger/changes_size/Dangerfile | 2 | ||||
-rw-r--r-- | danger/database/Dangerfile | 2 | ||||
-rw-r--r-- | danger/plugins/changelog.rb | 10 | ||||
-rw-r--r-- | danger/prettier/Dangerfile | 2 | ||||
-rw-r--r-- | danger/roulette/Dangerfile | 4 |
6 files changed, 21 insertions, 27 deletions
diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile index f83dc556964..62b41d14bee 100644 --- a/danger/changelog/Dangerfile +++ b/danger/changelog/Dangerfile @@ -3,7 +3,6 @@ require 'yaml' -NO_CHANGELOG_LABELS = %w[backstage ci-build meta].freeze SEE_DOC = "See [the documentation](https://docs.gitlab.com/ce/development/changelog.html)." CREATE_CHANGELOG_MESSAGE = <<~MSG You can create one with: @@ -21,14 +20,6 @@ bin/changelog --ee -m %<mr_iid>s "%<mr_title>s" Note: Merge requests with %<labels>s do not trigger this check. MSG -def ee_changelog?(changelog_path) - changelog_path =~ /unreleased-ee/ -end - -def ce_port_changelog?(changelog_path) - helper.ee? && !ee_changelog?(changelog_path) -end - def check_changelog(path) yaml = YAML.safe_load(File.read(path)) @@ -37,7 +28,7 @@ def check_changelog(path) if yaml["merge_request"].nil? message "Consider setting `merge_request` to #{gitlab.mr_json["iid"]} in #{gitlab.html_link(path)}. #{SEE_DOC}" - elsif yaml["merge_request"] != gitlab.mr_json["iid"] && !ce_port_changelog?(path) + elsif yaml["merge_request"] != gitlab.mr_json["iid"] && !changelog.ce_port_changelog?(path) fail "Merge request ID was not set to #{gitlab.mr_json["iid"]}! #{SEE_DOC}" end rescue Psych::SyntaxError, Psych::DisallowedClass, Psych::BadAlias @@ -47,25 +38,18 @@ rescue StandardError => e warn "There was a problem trying to check the Changelog. Exception: #{e.name} - #{e.message}" end -def presented_no_changelog_labels - NO_CHANGELOG_LABELS.map { |label| "~#{label}" }.join(', ') -end - -changelog_needed = (gitlab.mr_labels & NO_CHANGELOG_LABELS).empty? -changelog_found = git.added_files.find { |path| path =~ %r{\A(ee/)?(changelogs/unreleased)(-ee)?/} } - -mr_title = gitlab.mr_json["title"].gsub(/^WIP: */, '') - if git.modified_files.include?("CHANGELOG.md") fail "**CHANGELOG.md was edited.** Please remove the additions and create a CHANGELOG entry.\n\n" + - format(CREATE_CHANGELOG_MESSAGE, mr_iid: gitlab.mr_json["iid"], mr_title: mr_title, labels: presented_no_changelog_labels) + format(CREATE_CHANGELOG_MESSAGE, mr_iid: gitlab.mr_json["iid"], mr_title: changelog.sanitized_mr_title, labels: changelog.presented_no_changelog_labels) end -if changelog_needed +changelog_found = changelog.found + +if changelog.needed? if changelog_found check_changelog(changelog_found) else message "**[CHANGELOG missing](https://docs.gitlab.com/ce/development/changelog.html)**: If this merge request [doesn't need a CHANGELOG entry](https://docs.gitlab.com/ee/development/changelog.html#what-warrants-a-changelog-entry), feel free to ignore this message.\n\n" + - format(CREATE_CHANGELOG_MESSAGE, mr_iid: gitlab.mr_json["iid"], mr_title: mr_title, labels: presented_no_changelog_labels) + format(CREATE_CHANGELOG_MESSAGE, mr_iid: gitlab.mr_json["iid"], mr_title: changelog.sanitized_mr_title, labels: changelog.presented_no_changelog_labels) end end diff --git a/danger/changes_size/Dangerfile b/danger/changes_size/Dangerfile index 941afeeba64..2c1d59427af 100644 --- a/danger/changes_size/Dangerfile +++ b/danger/changes_size/Dangerfile @@ -1,7 +1,7 @@ # FIXME: git.info_for_file raises the following error # /usr/local/bundle/gems/git-1.4.0/lib/git/lib.rb:956:in `command': (Danger::DSLError) # [!] Invalid `Dangerfile` file: -# [!] Invalid `Dangerfile` file: git '--git-dir=/builds/gitlab-org/gitlab-foss/.git' '--work-tree=/builds/gitlab-org/gitlab-foss' cat-file '-t' '' 2>&1:fatal: Not a valid object name +# [!] Invalid `Dangerfile` file: git '--git-dir=/builds/gitlab-org/gitlab/.git' '--work-tree=/builds/gitlab-org/gitlab' cat-file '-t' '' 2>&1:fatal: Not a valid object name # This seems to be the same as https://github.com/danger/danger/issues/535. # locale_files_updated = git.modified_files.select { |path| path.start_with?('locale') } diff --git a/danger/database/Dangerfile b/danger/database/Dangerfile index fc6c5130fdc..56624c0b897 100644 --- a/danger/database/Dangerfile +++ b/danger/database/Dangerfile @@ -20,7 +20,7 @@ changes are reviewed, take the following steps: 1. Ensure the merge request has ~database and ~"database::review pending" labels. If the merge request modifies database files, Danger will do this for you. -1. Use the [Database changes checklist](https://gitlab.com/gitlab-org/gitlab-foss/blob/master/.gitlab/merge_request_templates/Database%20changes.md) +1. Use the [Database changes checklist](https://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab/merge_request_templates/Database%20changes.md) template or add the appropriate items to the MR description. 1. Assign and mention the database reviewer suggested by Reviewer Roulette. MSG diff --git a/danger/plugins/changelog.rb b/danger/plugins/changelog.rb new file mode 100644 index 00000000000..84f399e9e97 --- /dev/null +++ b/danger/plugins/changelog.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require_relative '../../lib/gitlab/danger/changelog' + +module Danger + class Changelog < Plugin + # Put the helper code somewhere it can be tested + include Gitlab::Danger::Changelog + end +end diff --git a/danger/prettier/Dangerfile b/danger/prettier/Dangerfile index 0be75db8baa..ee27aaf9228 100644 --- a/danger/prettier/Dangerfile +++ b/danger/prettier/Dangerfile @@ -36,6 +36,6 @@ if GitlabDanger.new(helper.gitlab_helper).ci? Also consider auto-formatting [on-save]. - [on-save]: https://docs.gitlab.com/ee/development/new_fe_guide/style/prettier.html + [on-save]: https://docs.gitlab.com/ee/development/fe_guide/tooling.html#formatting-with-prettier MARKDOWN end diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index 42fc3831c14..173cf4e0ea2 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -27,7 +27,7 @@ UNKNOWN_FILES_MESSAGE = <<MARKDOWN These files couldn't be categorised, so Danger was unable to suggest a reviewer. Please consider creating a merge request to -[add support](https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/danger/helper.rb) +[add support](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/danger/helper.rb) for them. MARKDOWN @@ -46,7 +46,7 @@ def spin_for_category(team, project, category, branch_name) end # TODO: take CODEOWNERS into account? - # https://gitlab.com/gitlab-org/gitlab-foss/issues/57653 + # https://gitlab.com/gitlab-org/gitlab/issues/26723 # Make traintainers have triple the chance to be picked as a reviewer reviewer = roulette.spin_for_person(reviewers + traintainers + traintainers, random: random) |