summaryrefslogtreecommitdiff
path: root/danger/changelog
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-23 15:09:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-23 15:09:36 +0000
commit074d013e1eb3f6e0c27f96a3be8b9361254c8a98 (patch)
treef185c474ddc8624a4793c84b0b1f4cc07349694b /danger/changelog
parent8f9beefac3774b30e911fb00a68f4c7a5244cf27 (diff)
downloadgitlab-ce-074d013e1eb3f6e0c27f96a3be8b9361254c8a98.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'danger/changelog')
-rw-r--r--danger/changelog/Dangerfile34
1 files changed, 22 insertions, 12 deletions
diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile
index 1c4647121fb..3c9030e7dbc 100644
--- a/danger/changelog/Dangerfile
+++ b/danger/changelog/Dangerfile
@@ -3,9 +3,9 @@
require 'yaml'
-SEE_DOC = "See [the documentation](https://docs.gitlab.com/ce/development/changelog.html)."
+SEE_DOC = "See [the documentation](https://docs.gitlab.com/ee/development/changelog.html)."
CREATE_CHANGELOG_MESSAGE = <<~MSG
-You can create one with:
+If you want to create a changelog entry for GitLab FOSS, run the following:
```
bin/changelog -m %<mr_iid>s "%<mr_title>s"
@@ -20,7 +20,7 @@ bin/changelog --ee -m %<mr_iid>s "%<mr_title>s"
Note: Merge requests with %<labels>s do not trigger this check.
MSG
-def check_changelog(path)
+def check_changelog_yaml(path)
yaml = YAML.safe_load(File.read(path))
fail "`title` should be set, in #{gitlab.html_link(path)}! #{SEE_DOC}" if yaml["title"].nil?
@@ -28,8 +28,6 @@ def check_changelog(path)
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}"
- 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
# YAML could not be parsed, fail the build.
@@ -38,6 +36,19 @@ rescue StandardError => e
warn "There was a problem trying to check the Changelog. Exception: #{e.name} - #{e.message}"
end
+def check_changelog_path(path)
+ ee_changes = helper.all_ee_changes.dup
+ ee_changes.delete(path)
+
+ if ee_changes.any? && !changelog.ee_changelog?
+ warn "This MR has a Changelog file outside `ee/`, but code changes in `ee/`. Consider moving the Changelog file into `ee/`."
+ end
+
+ if ee_changes.empty? && changelog.ee_changelog?
+ warn "This MR has a Changelog file in `ee/`, but no code changes in `ee/`. Consider moving the Changelog file outside `ee/`."
+ end
+end
+
def sanitized_mr_title
helper.sanitize_mr_title(gitlab.mr_json["title"])
end
@@ -49,11 +60,10 @@ end
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: sanitized_mr_title, labels: changelog.presented_no_changelog_labels)
- end
+if changelog_found
+ check_changelog_yaml(changelog_found)
+ check_changelog_path(changelog_found)
+elsif changelog.needed?
+ message "**[CHANGELOG missing](https://docs.gitlab.com/ee/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: sanitized_mr_title, labels: changelog.presented_no_changelog_labels)
end