summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-06-27 14:10:46 +0000
committerNick Thomas <nick@gitlab.com>2019-06-27 14:10:46 +0000
commitd56d5f98033a76119c82257ded8d4fe6a49b5a0d (patch)
tree802f3d03118cc16714feaee3cf179fc0aee5f501
parentccf3caf4ed540c2d5da9c3bf6ea2773a1bed680a (diff)
parent068d6baa38df09c43d7364e9f87caffe73168460 (diff)
downloadgitlab-ce-d56d5f98033a76119c82257ded8d4fe6a49b5a0d.tar.gz
Merge branch 'leipert-danger-dogs' into 'master'
Add a danger rule to suggest `docs-` prefixes Closes #54490 See merge request gitlab-org/gitlab-ce!30115
-rw-r--r--Dangerfile1
-rw-r--r--danger/only_documentation/Dangerfile24
2 files changed, 25 insertions, 0 deletions
diff --git a/Dangerfile b/Dangerfile
index d0a605f8d8e..094d55e8652 100644
--- a/Dangerfile
+++ b/Dangerfile
@@ -19,4 +19,5 @@ unless helper.release_automation?
danger.import_dangerfile(path: 'danger/single_codebase')
danger.import_dangerfile(path: 'danger/gitlab_ui_wg')
danger.import_dangerfile(path: 'danger/ce_ee_vue_templates')
+ danger.import_dangerfile(path: 'danger/only_documentation')
end
diff --git a/danger/only_documentation/Dangerfile b/danger/only_documentation/Dangerfile
new file mode 100644
index 00000000000..8e4564f22b6
--- /dev/null
+++ b/danger/only_documentation/Dangerfile
@@ -0,0 +1,24 @@
+# rubocop:disable Style/SignalException
+# frozen_string_literal: true
+
+has_only_docs_changes = helper.all_changed_files.all? { |file| file.start_with?('doc/') }
+is_docs_only_branch = gitlab.branch_for_head =~ /(^docs[\/-].*|.*-docs$)/
+
+if is_docs_only_branch && !has_only_docs_changes
+ fail "It seems like your branch name has a `docs` prefix or suffix. "\
+ "The CI won't run the full pipeline, but you also have changed non-docs files. "\
+ "Please recreate this MR with a new branch name."
+end
+
+if has_only_docs_changes && !is_docs_only_branch
+ markdown(<<~MARKDOWN)
+
+ ## Documentation only changes
+
+ Hey! Seems your merge request contains only docs changes.
+ Tired of waiting 2 hours for the pipeline to finish?
+ Next time, prepend `docs-` to [your branch name](https://docs.gitlab.com/ee/development/documentation/#branch-naming)
+ and the pipeline will finish before you say GitLab (x300)!
+
+ MARKDOWN
+end