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

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 Resolved
Comment thread @commitlint/cli/src/cli.test.ts Resolved
Comment thread @commitlint/cli/src/cli.test.ts Resolved
@knocte
knocte force-pushed the wip/rejectSameFromToParams branch from 0a00271 to 48964e5 Compare May 24, 2026 15:04
@escapedcat
escapedcat merged commit 121005e into conventional-changelog:master May 24, 2026
12 of 22 checks passed
sys-support pushed a commit to 3caravelle/renovate that referenced this pull request Jun 25, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@commitlint/cli](https://commitlint.js.org/) ([source](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/cli)) | [`21.0.1` → `21.1.0`](https://renovatebot.com/diffs/npm/@commitlint%2fcli/21.0.1/21.1.0) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@commitlint%2fcli/21.1.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@commitlint%2fcli/21.0.1/21.1.0?slim=true) |
| [@commitlint/config-conventional](https://commitlint.js.org/) ([source](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/config-conventional)) | [`21.0.1` → `21.1.0`](https://renovatebot.com/diffs/npm/@commitlint%2fconfig-conventional/21.0.1/21.1.0) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@commitlint%2fconfig-conventional/21.1.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@commitlint%2fconfig-conventional/21.0.1/21.1.0?slim=true) |

---

### Release Notes

<details>
<summary>conventional-changelog/commitlint (@&#8203;commitlint/cli)</summary>

### [`v21.1.0`](https://github.com/conventional-changelog/commitlint/blob/HEAD/@&#8203;commitlint/cli/CHANGELOG.md#2110-2026-06-23)

[Compare Source](conventional-changelog/commitlint@v21.0.2...v21.1.0)

##### Features

- **cli:** add --default-config flag to lint without a config file ([#&#8203;4805](conventional-changelog/commitlint#4805)) ([7af27ba](conventional-changelog/commitlint@7af27ba)), closes [#&#8203;3662](conventional-changelog/commitlint#3662)

#### [21.0.2](conventional-changelog/commitlint@v21.0.1...v21.0.2) (2026-05-29)

##### Bug Fixes

- disallow same commit hash for --from and --to ([#&#8203;4773](conventional-changelog/commitlint#4773)) ([121005e](conventional-changelog/commitlint@121005e))

#### [21.0.1](conventional-changelog/commitlint@v21.0.0...v21.0.1) (2026-05-12)

**Note:** Version bump only for package [@&#8203;commitlint/cli](https://github.com/commitlint/cli)

### [`v21.0.2`](https://github.com/conventional-changelog/commitlint/blob/HEAD/@&#8203;commitlint/cli/CHANGELOG.md#2102-2026-05-29)

[Compare Source](conventional-changelog/commitlint@v21.0.1...v21.0.2)

##### Bug Fixes

- disallow same commit hash for --from and --to ([#&#8203;4773](conventional-changelog/commitlint#4773)) ([121005e](conventional-changelog/commitlint@121005e))

</details>

<details>
<summary>conventional-changelog/commitlint (@&#8203;commitlint/config-conventional)</summary>

### [`v21.1.0`](https://github.com/conventional-changelog/commitlint/blob/HEAD/@&#8203;commitlint/config-conventional/CHANGELOG.md#2110-2026-06-23)

[Compare Source](conventional-changelog/commitlint@v21.0.2...v21.1.0)

**Note:** Version bump only for package [@&#8203;commitlint/config-conventional](https://github.com/commitlint/config-conventional)

#### [21.0.2](conventional-changelog/commitlint@v21.0.1...v21.0.2) (2026-05-29)

**Note:** Version bump only for package [@&#8203;commitlint/config-conventional](https://github.com/commitlint/config-conventional)

#### [21.0.1](conventional-changelog/commitlint@v21.0.0...v21.0.1) (2026-05-12)

**Note:** Version bump only for package [@&#8203;commitlint/config-conventional](https://github.com/commitlint/config-conventional)

### [`v21.0.2`](https://github.com/conventional-changelog/commitlint/blob/HEAD/@&#8203;commitlint/config-conventional/CHANGELOG.md#2102-2026-05-29)

[Compare Source](conventional-changelog/commitlint@v21.0.1...v21.0.2)

**Note:** Version bump only for package [@&#8203;commitlint/config-conventional](https://github.com/commitlint/config-conventional)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44MS4zIiwidXBkYXRlZEluVmVyIjoiNDIuODEuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Reviewed-on: https://git.3caravelle.net/3Caravelle/renovate/pulls/37
Co-authored-by: Renovate Bot <renovate-bot@3caravelle.com>
Co-committed-by: Renovate Bot <renovate-bot@3caravelle.com>
pat-s pushed a commit to devxygmbh/ansible-data-science-core that referenced this pull request Jul 20, 2026
…ocker tag to v21.2.1 (#95)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cr.codefloe.com/docker.io/commitlint/commitlint](https://github.com/conventional-changelog/commitlint) | minor | `21.0.1` → `21.2.1` |

---

### Release Notes

<details>
<summary>conventional-changelog/commitlint (cr.codefloe.com/docker.io/commitlint/commitlint)</summary>

### [`v21.2.1`](https://github.com/conventional-changelog/commitlint/blob/HEAD/CHANGELOG.md#2121-2026-07-08)

[Compare Source](conventional-changelog/commitlint@v21.2.0...v21.2.1)

**Note:** Version bump only for package [@&#8203;commitlint/root](https://github.com/commitlint/root)

### [`v21.2.0`](https://github.com/conventional-changelog/commitlint/blob/HEAD/CHANGELOG.md#2120-2026-06-30)

[Compare Source](conventional-changelog/commitlint@v21.1.0...v21.2.0)

##### Features

- **resolve-extends:** resolve pure-ESM presets (conventional-changelog v7/v9/v10) ([#&#8203;4859](conventional-changelog/commitlint#4859)) ([fdb566f](conventional-changelog/commitlint@fdb566f))

### [`v21.1.0`](https://github.com/conventional-changelog/commitlint/blob/HEAD/CHANGELOG.md#2110-2026-06-23)

[Compare Source](conventional-changelog/commitlint@v21.0.2...v21.1.0)

##### Bug Fixes

- remove duplicate es-toolkit\@&#8203;1.47.1 keys from lockfile ([#&#8203;4833](conventional-changelog/commitlint#4833)) ([b3323f5](conventional-changelog/commitlint@b3323f5)), closes [#&#8203;4831](conventional-changelog/commitlint#4831)

##### Features

- **cli:** add --default-config flag to lint without a config file ([#&#8203;4805](conventional-changelog/commitlint#4805)) ([7af27ba](conventional-changelog/commitlint@7af27ba)), closes [#&#8203;3662](conventional-changelog/commitlint#3662)
- **lint:** allow for custom commit parser function ([#&#8203;4829](conventional-changelog/commitlint#4829)) ([e820753](conventional-changelog/commitlint@e820753)), closes [#&#8203;4816](conventional-changelog/commitlint#4816) [#&#8203;4816](conventional-changelog/commitlint#4816)

#### [21.0.2](conventional-changelog/commitlint@v21.0.1...v21.0.2) (2026-05-29)

##### Bug Fixes

- apply oxfmt formatting to get-edit-commit.ts ([#&#8203;4768](conventional-changelog/commitlint#4768)) ([1af3138](conventional-changelog/commitlint@1af3138)), closes [#&#8203;4755](conventional-changelog/commitlint#4755)
- **config-pnpm-scopes:** adapt to read-yaml-file v3 named export ([#&#8203;4701](conventional-changelog/commitlint#4701)) ([8b55772](conventional-changelog/commitlint@8b55772))
- disallow same commit hash for --from and --to ([#&#8203;4773](conventional-changelog/commitlint#4773)) ([121005e](conventional-changelog/commitlint@121005e))
- emit actionable error when --edit cannot find COMMIT\_EDITMSG ([#&#8203;589](conventional-changelog/commitlint#589)) ([#&#8203;4755](conventional-changelog/commitlint#4755)) ([bb10907](conventional-changelog/commitlint@bb10907))
- **read:** fail when --from and --to share no merge-base [#&#8203;4555](conventional-changelog/commitlint#4555) ([#&#8203;4754](conventional-changelog/commitlint#4754)) ([e4595eb](conventional-changelog/commitlint@e4595eb))
- update dependency [@&#8203;pnpm/read-project-manifest](https://github.com/pnpm/read-project-manifest) to v6 ([#&#8203;4617](conventional-changelog/commitlint#4617)) ([ca16ec1](conventional-changelog/commitlint@ca16ec1))
- update vitest monorepo to \~4.1.0 ([#&#8203;4654](conventional-changelog/commitlint#4654)) ([f1f25d5](conventional-changelog/commitlint@f1f25d5))

#### [21.0.1](conventional-changelog/commitlint@v21.0.0...v21.0.1) (2026-05-12)

##### Bug Fixes

- **load:** only resolve relative formatter paths ([#&#8203;4761](conventional-changelog/commitlint#4761)) ([f8be069](conventional-changelog/commitlint@f8be069))
- **types:** add presetConfig to ParserPreset interface ([#&#8203;4749](conventional-changelog/commitlint#4749)) ([e402cd4](conventional-changelog/commitlint@e402cd4)), closes [#&#8203;4748](conventional-changelog/commitlint#4748)

### [`v21.0.2`](https://github.com/conventional-changelog/commitlint/blob/HEAD/CHANGELOG.md#2102-2026-05-29)

[Compare Source](conventional-changelog/commitlint@v21.0.1...v21.0.2)

##### Bug Fixes

- apply oxfmt formatting to get-edit-commit.ts ([#&#8203;4768](conventional-changelog/commitlint#4768)) ([1af3138](conventional-changelog/commitlint@1af3138)), closes [#&#8203;4755](conventional-changelog/commitlint#4755)
- **config-pnpm-scopes:** adapt to read-yaml-file v3 named export ([#&#8203;4701](conventional-changelog/commitlint#4701)) ([8b55772](conventional-changelog/commitlint@8b55772))
- disallow same commit hash for --from and --to ([#&#8203;4773](conventional-changelog/commitlint#4773)) ([121005e](conventional-changelog/commitlint@121005e))
- emit actionable error when --edit cannot find COMMIT\_EDITMSG ([#&#8203;589](conventional-changelog/commitlint#589)) ([#&#8203;4755](conventional-changelog/commitlint#4755)) ([bb10907](conventional-changelog/commitlint@bb10907))
- **read:** fail when --from and --to share no merge-base [#&#8203;4555](conventional-changelog/commitlint#4555) ([#&#8203;4754](conventional-changelog/commitlint#4754)) ([e4595eb](conventional-changelog/commitlint@e4595eb))
- update dependency [@&#8203;pnpm/read-project-manifest](https://github.com/pnpm/read-project-manifest) to v6 ([#&#8203;4617](conventional-changelog/commitlint#4617)) ([ca16ec1](conventional-changelog/commitlint@ca16ec1))
- update vitest monorepo to \~4.1.0 ([#&#8203;4654](conventional-changelog/commitlint#4654)) ([f1f25d5](conventional-changelog/commitlint@f1f25d5))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4zMS4wIiwidXBkYXRlZEluVmVyIjoiNDMuMzEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: devxy-bot <no-reply@devxy.io>
Reviewed-on: https://codefloe.com/devxy/ansible-data-science-core/pulls/95
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