Skip to content

feat(check): add --no-merge option to reject merge commits#47

Closed
gcornut wants to merge 1 commit into
masterfrom
chore/fail-on-merge-commit
Closed

feat(check): add --no-merge option to reject merge commits#47
gcornut wants to merge 1 commit into
masterfrom
chore/fail-on-merge-commit

Conversation

@gcornut

@gcornut gcornut commented Jun 26, 2026

Copy link
Copy Markdown
Member

By default, merge commits are silently skipped. This adds a --no-merge option to fail on merge commits instead, useful for enforcing a rebase workflow in CI.

Let me know if there any cases where adding this on our PR CI would be a bad idea.

Changes

  • check_message.sh: --no-merge flag (or COMMIT_VALIDATOR_NO_MERGE env var) makes merge commits fail instead of being skipped, both for MERGE_MSG path and message-based detection.
  • check.sh: when COMMIT_VALIDATOR_NO_MERGE is set, merge commits are included in the validated range and rejected.
  • action.yml: new no_merge input wired to COMMIT_VALIDATOR_NO_MERGE.
  • Tests: 5 new bats tests covering both scripts.
  • README: documented the new option in both the GitHub Action and pre-commit hook sections.

Note on GitHub Actions pull_request workflows

When a pull_request workflow runs, HEAD is not the PR's head commit — GitHub creates a synthetic merge commit (PR branch merged into base) that is never pushed to the repository. With no_merge: "true", this could cause a false positive if the validated range included HEAD.

This is safe because the action already passes an explicit range using base.sha..head.sha, so the synthetic merge commit at HEAD is never part of the validated range.

@gcornut gcornut marked this pull request as ready for review June 26, 2026 09:07
@gcornut gcornut requested review from a team and lumautomation as code owners June 26, 2026 09:07
@gcornut

gcornut commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

@gcornut

gcornut commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

We will actually have a GH repo config that does that better
https://github.com/lumapps/github-automation/pull/2525

@gcornut gcornut closed this Jun 26, 2026
@gcornut gcornut deleted the chore/fail-on-merge-commit branch June 26, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant