File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -670,12 +670,20 @@ end
670670
671671commits = git . commits . size
672672if commits > 1
673- warn (
674- "danger check: pull request contains #{ commits } commits while most of the cases it should have only one.\n " \
675- "If it's not a special case you should squash commits into single one.\n " \
676- "You can read how to do it here: https://davidwalsh.name/squash-commits-git\n " \
677- "But be careful because **it can destroy** all your changes!"
678- )
673+ if git . commits . any? { |c | c . message =~ /^Merge branch/ || c . message =~ /^Merge remote-tracking branch/ }
674+ fail (
675+ "danger check: pull request contains merge commits! " \
676+ "Please, rebase your branch to get rid of such commits:\n " \
677+ "`git rebase master #{ branch_for_head } `"
678+ )
679+ else
680+ warn (
681+ "danger check: pull request contains #{ commits } commits while most of the cases it should have only one.\n " \
682+ "If it's not a special case you should squash commits into single one.\n " \
683+ "You can read how to do it here: https://davidwalsh.name/squash-commits-git\n " \
684+ "But be careful because **it can destroy** all your changes!"
685+ )
686+ end
679687end
680688
681689all_checks_passed = violation_report [ :errors ] . empty? && violation_report [ :warnings ] . empty? && violation_report [ :messages ] . empty?
You can’t perform that action at this time.
0 commit comments