Commit b9ec2970 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'danger-apply-suggestions-72-chars' into 'master'

Do not fail danger if suggestion commit msg > 72

See merge request gitlab-org/gitlab-ce!30090
parents 872eae04 2549d2f0
...@@ -88,6 +88,19 @@ def lint_commit(commit) # rubocop:disable Metrics/AbcSize ...@@ -88,6 +88,19 @@ def lint_commit(commit) # rubocop:disable Metrics/AbcSize
# We ignore revert commits as they are well structured by Git already # We ignore revert commits as they are well structured by Git already
return false if commit.message.start_with?('Revert "') return false if commit.message.start_with?('Revert "')
# Fail if a suggestion commit is used and squash is not enabled
if commit.message.start_with?('Apply suggestion to')
if gitlab.mr_json['squash']
return false
else
fail_commit(
commit,
'If you are applying suggestions, enable squash in the merge request and re-run the failed job'
)
return true
end
end
failures = false failures = false
subject, separator, details = commit.message.split("\n", 3) subject, separator, details = commit.message.split("\n", 3)
...@@ -114,16 +127,6 @@ def lint_commit(commit) # rubocop:disable Metrics/AbcSize ...@@ -114,16 +127,6 @@ def lint_commit(commit) # rubocop:disable Metrics/AbcSize
) )
end 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) unless subject_starts_with_capital?(subject)
fail_commit(commit, 'The commit subject must start with a capital letter') fail_commit(commit, 'The commit subject must start with a capital letter')
failures = true failures = true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment