diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /danger/commit_messages/Dangerfile | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'danger/commit_messages/Dangerfile')
-rw-r--r-- | danger/commit_messages/Dangerfile | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/danger/commit_messages/Dangerfile b/danger/commit_messages/Dangerfile index 174fc10eef3..4e17db60471 100644 --- a/danger/commit_messages/Dangerfile +++ b/danger/commit_messages/Dangerfile @@ -37,7 +37,8 @@ def build_message(commit, message, more_info: true) end def squash_mr? - gitlab_danger.ci? ? gitlab.mr_json['squash'] : false + # Locally, we assume the MR is set to be squashed so that the user only sees warnings instead of errors. + gitlab_danger.ci? ? gitlab.mr_json['squash'] : true end def wip_mr? @@ -100,25 +101,27 @@ end def lint_commits(commits) commit_linters = commits.map { |commit| lint_commit(commit) } - failed_commit_linters = commit_linters.select { |commit_linter| commit_linter.failed? } - warn_or_fail_commits(failed_commit_linters, default_to_fail: !squash_mr?) - - if count_non_fixup_commits(commit_linters) > MAX_COMMITS_COUNT - self.warn(format(MAX_COMMITS_COUNT_EXCEEDED_MESSAGE, max_commits_count: MAX_COMMITS_COUNT)) - end if squash_mr? multi_line_commit_linter = commit_linters.detect { |commit_linter| !commit_linter.merge? && commit_linter.multi_line? } if multi_line_commit_linter && multi_line_commit_linter.failed? warn_or_fail_commits(multi_line_commit_linter) - else + commit_linters.delete(multi_line_commit_linter) # Don't show an error (here) and a warning (below) + elsif gitlab_danger.ci? # We don't have access to the MR title locally title_linter = lint_mr_title(gitlab.mr_json['title']) if title_linter.failed? warn_or_fail_commits(title_linter) end end + else + if count_non_fixup_commits(commit_linters) > MAX_COMMITS_COUNT + self.warn(format(MAX_COMMITS_COUNT_EXCEEDED_MESSAGE, max_commits_count: MAX_COMMITS_COUNT)) + end end + + failed_commit_linters = commit_linters.select { |commit_linter| commit_linter.failed? } + warn_or_fail_commits(failed_commit_linters, default_to_fail: !squash_mr?) end def warn_or_fail_commits(failed_linters, default_to_fail: true) @@ -127,7 +130,7 @@ def warn_or_fail_commits(failed_linters, default_to_fail: true) Array(failed_linters).each do |linter| linter.problems.each do |problem_key, problem_desc| case problem_key - when :subject_above_warning + when :subject_too_short, :subject_above_warning warn_commit(linter.commit, problem_desc) else self.__send__("#{level}_commit", linter.commit, problem_desc) # rubocop:disable GitlabSecurity/PublicSend |