Skip to content

fix: disallow same commit hash for --from and --to#4773

Merged
escapedcat merged 2 commits into
conventional-changelog:masterfrom
knocte:wip/rejectSameFromToParams
May 24, 2026
Merged

fix: disallow same commit hash for --from and --to#4773
escapedcat merged 2 commits into
conventional-changelog:masterfrom
knocte:wip/rejectSameFromToParams

Conversation

@knocte

@knocte knocte commented May 16, 2026

Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 === --to and throw a CommitlintInvalidArgument error.
  • Added a regression test ensuring the CLI fails with the expected exit code and guidance when --from and --to are 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.

Comment thread @commitlint/cli/src/cli.ts Outdated
Comment thread @commitlint/cli/src/cli.test.ts
Comment thread @commitlint/cli/src/cli.test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Using same commit for --from and --to does nothing and returns exit-code=0 (success)

3 participants