From f10c8481b3c44e955c086cb841e9391574c68308 Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Wed, 19 Jun 2019 14:17:10 +0000 Subject: When using suggestions, squash must be enabled --- danger/commit_messages/Dangerfile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/danger/commit_messages/Dangerfile b/danger/commit_messages/Dangerfile index bdb4343b1d6..ec494635f02 100644 --- a/danger/commit_messages/Dangerfile +++ b/danger/commit_messages/Dangerfile @@ -80,7 +80,7 @@ def unicode_emoji_regex ))x end -def lint_commit(commit) +def lint_commit(commit) # rubocop:disable Metrics/AbcSize # For now we'll ignore merge commits, as getting rid of those is a problem # separate from enforcing good commit messages. return false if commit.message.start_with?('Merge branch') @@ -114,6 +114,16 @@ def lint_commit(commit) ) end + # Fail if a suggestion commit is used and squash is not enabled + if commit.message.start_with?('Apply suggestion to') && !gitlab.mr_json['squash'] + fail_commit( + commit, + 'If you are applying suggestions, squash needs to be enabled in the merge request' + ) + + failures = true + end + unless subject_starts_with_capital?(subject) fail_commit(commit, 'The commit subject must start with a capital letter') failures = true -- cgit v1.2.1