summaryrefslogtreecommitdiff
path: root/danger
diff options
context:
space:
mode:
Diffstat (limited to 'danger')
-rw-r--r--danger/changelog/Dangerfile6
-rw-r--r--danger/commit_messages/Dangerfile10
-rw-r--r--danger/only_documentation/Dangerfile24
3 files changed, 26 insertions, 14 deletions
diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile
index f83dc556964..2d1ca64a9e8 100644
--- a/danger/changelog/Dangerfile
+++ b/danger/changelog/Dangerfile
@@ -12,12 +12,6 @@ You can create one with:
bin/changelog -m %<mr_iid>s "%<mr_title>s"
```
-If you want to create a changelog entry for GitLab EE, run the following instead:
-
-```
-bin/changelog --ee -m %<mr_iid>s "%<mr_title>s"
-```
-
Note: Merge requests with %<labels>s do not trigger this check.
MSG
diff --git a/danger/commit_messages/Dangerfile b/danger/commit_messages/Dangerfile
index 064b8c94805..d371ade4887 100644
--- a/danger/commit_messages/Dangerfile
+++ b/danger/commit_messages/Dangerfile
@@ -37,10 +37,6 @@ class EmojiChecker
end
end
-def gitlab_danger
- @gitlab_danger ||= GitlabDanger.new(helper.gitlab_helper)
-end
-
def fail_commit(commit, message)
fail("#{commit.sha}: #{message}")
end
@@ -60,8 +56,6 @@ def subject_starts_with_capital?(subject)
end
def ce_upstream?
- return unless gitlab_danger.ci?
-
gitlab.mr_labels.any? { |label| label == 'CE upstream' }
end
@@ -94,8 +88,8 @@ def lint_commit(commit) # rubocop:disable Metrics/AbcSize
# We ignore revert commits as they are well structured by Git already
return false if commit.message.start_with?('Revert "')
- is_squash = gitlab_danger.ci? ? gitlab.mr_json['squash'] : false
- is_wip = gitlab_danger.ci? ? gitlab.mr_json['work_in_progress'] : false
+ is_squash = gitlab.mr_json['squash']
+ is_wip = gitlab.mr_json['work_in_progress']
is_fixup = commit.message.start_with?('fixup!', 'squash!')
if is_fixup
diff --git a/danger/only_documentation/Dangerfile b/danger/only_documentation/Dangerfile
new file mode 100644
index 00000000000..ce7ede26d9a
--- /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/', '.gitlab/ci/docs.gitlab-ci.yml', '.markdownlint.json') || file.end_with?('.md') }
+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