prCommitsTooManyCommits.ts 667 B

12345678910111213141516171819
  1. import { DangerDSLType, DangerResults } from "danger";
  2. declare const danger: DangerDSLType;
  3. declare const message: (message: string, results?: DangerResults) => void;
  4. /**
  5. * Check if pull request has not an excessive numbers of commits (if squashed)
  6. *
  7. * @dangerjs INFO
  8. */
  9. export default function (): void {
  10. const tooManyCommitThreshold: number = 2; // above this number of commits, squash commits is suggested
  11. const prCommits: number = danger.github.commits.length;
  12. if (prCommits > tooManyCommitThreshold) {
  13. return message(
  14. `You might consider squashing your ${prCommits} commits (simplifying branch history).`
  15. );
  16. }
  17. }