diff --git a/changelogs/unreleased/0a68660b-mr-iid.yml b/changelogs/unreleased/0a68660b-mr-iid.yml new file mode 100644 index 0000000000000000000000000000000000000000..e071e3194b93a443217c9b02a64d4fe36c29da07 --- /dev/null +++ b/changelogs/unreleased/0a68660b-mr-iid.yml @@ -0,0 +1,5 @@ +--- +title: Correct merge request IID! +merge_request: 33081 +author: +type: other diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile index 7b8a096639d991a662e944bbbf831f408c5a274f..24e166e45af8bda1e6d06f9d0808749a7df19910 100644 --- a/danger/changelog/Dangerfile +++ b/danger/changelog/Dangerfile @@ -3,7 +3,7 @@ require 'yaml' -SEE_DOC = "See [the documentation](https://docs.gitlab.com/ee/development/changelog.html)." +SEE_DOC = "See the [changelog documentation](https://docs.gitlab.com/ee/development/changelog.html)." CREATE_CHANGELOG_MESSAGE = <<~MSG If you want to create a changelog entry for GitLab FOSS, run the following: @@ -20,14 +20,25 @@ bin/changelog --ee -m %s "%s" 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. MSG +SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT +```suggestion +merge_request: %s +``` + +#{SEE_DOC} +SUGGEST_COMMENT + def check_changelog_yaml(path) - yaml = YAML.safe_load(File.read(path)) + raw_file = File.read(path) + yaml = YAML.safe_load(raw_file) fail "`title` should be set, in #{gitlab.html_link(path)}! #{SEE_DOC}" if yaml["title"].nil? fail "`type` should be set, in #{gitlab.html_link(path)}! #{SEE_DOC}" if yaml["type"].nil? if yaml["merge_request"].nil? && !helper.security_mr? - message "Consider setting `merge_request` to #{gitlab.mr_json["iid"]} in #{gitlab.html_link(path)}. #{SEE_DOC}" + markdown(format(SUGGEST_MR_COMMENT, mr_iid: gitlab.mr_json["iid"]), + file: path, + line: raw_file.lines.find_index("merge_request:\n")&.succ) elsif yaml["merge_request"] != gitlab.mr_json["iid"] && !helper.security_mr? fail "Merge request ID was not set to #{gitlab.mr_json["iid"]}! #{SEE_DOC}" end