From 1eb82b65c554f21d83447f895a6208905fabe112 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 18 Sep 2019 14:14:39 +0000 Subject: Add latest changes from gitlab-org/gitlab@12-3-auto-deploy-20190916 --- danger/changelog/Dangerfile | 6 ------ danger/commit_messages/Dangerfile | 10 ++-------- danger/only_documentation/Dangerfile | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 danger/only_documentation/Dangerfile (limited to 'danger') 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 %s "%s" ``` -If you want to create a changelog entry for GitLab EE, run the following instead: - -``` -bin/changelog --ee -m %s "%s" -``` - Note: Merge requests with %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 -- cgit v1.2.1