fix: disallow same commit hash for --from and --to#4773
Merged
escapedcat merged 2 commits intoMay 24, 2026
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes commitlint CLI behavior when --from and --to are provided with the same value by failing early with a clearer error and a non-zero exit code, addressing issue #3376.
Changes:
- Added an early-guard in the CLI to detect
--from === --toand throw aCommitlintInvalidArgumenterror. - Added a regression test ensuring the CLI fails with the expected exit code and guidance when
--fromand--toare identical.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| @commitlint/cli/src/cli.ts | Adds early validation for --from/--to equality and emits a targeted invalid-argument error. |
| @commitlint/cli/src/cli.test.ts | Adds a regression test for the new invalid-argument behavior when --from and --to match. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0a00271 to
48964e5
Compare
121005e
into
conventional-changelog:master
12 of 22 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3376
Description
Before executing anything, make commitlint-cli check the --from and --to args, and if they are the same, throw an early error (before a more cryptic one throws under the hood, or before a misleading exitCode=0 happens).
Motivation and Context
#3376
Usage examples
See #3376
How Has This Been Tested?
TDD
Types of changes
Checklist: