diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-09-10 17:03:14 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-09-10 17:03:14 -0300 |
commit | cfe77ce4a3494b9c1516fe7e915f76b21a68e763 (patch) | |
tree | cef43c4d6c2fdee57ad19ab6815e41617eace2f2 /danger/commit_messages/Dangerfile | |
parent | 934d4925d85f22c67e7ad57f607e8fe430a9ea92 (diff) | |
parent | 95d16dc007f3fe8831f2baa511bbb7bd708baff0 (diff) | |
download | gitlab-ce-cfe77ce4a3494b9c1516fe7e915f76b21a68e763.tar.gz |
Merge remote-tracking branch 'origin/master' into camilstaps/gitlab-ce-new-66023-public-private-fork-counts
Diffstat (limited to 'danger/commit_messages/Dangerfile')
-rw-r--r-- | danger/commit_messages/Dangerfile | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/danger/commit_messages/Dangerfile b/danger/commit_messages/Dangerfile index 0c675cc4c9c..d371ade4887 100644 --- a/danger/commit_messages/Dangerfile +++ b/danger/commit_messages/Dangerfile @@ -88,9 +88,36 @@ 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.mr_json['squash'] + is_wip = gitlab.mr_json['work_in_progress'] + is_fixup = commit.message.start_with?('fixup!', 'squash!') + + if is_fixup + # The MR is set to squash - Danger adds an informative notice + # The MR is not set to squash - Danger fails. if also WIP warn only, not error + if is_squash + return false + end + + if is_wip + warn_commit( + commit, + 'Squash or Fixup commits must be squashed before merge, or enable squash merge option' + ) + else + fail_commit( + commit, + 'Squash or Fixup commits must be squashed before merge, or enable squash merge option' + ) + end + + # Makes no sense to process other rules for fixup commits, they trigger just more noise + return false + end + # 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'] + if is_squash return false else fail_commit( |