File tree 1 file changed +14
-6
lines changed
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -670,12 +670,20 @@ end
670
670
671
671
commits = git . commits . size
672
672
if 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 them:\n " \
677
+ "`git rebase master #{ github . 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
679
687
end
680
688
681
689
all_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