Skip to content

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

@knocte

Description

@knocte

Using same commit hash for --from and --to flags makes commitlint do nothing and return exit-code=0 (success).

Steps to Reproduce

  1. Do a commit that violates your commitlint policies.
  2. Grab the last commit hash from your repo, e.g. with git-log.
  3. Run npx commitlint --verbose --from <commitHash> --to <commitHash>

Current Behavior

It does nothing and returns exit-code = 0 (success). This is quite misleading because it could make anyone think that the validation was successful on the last commit (especially in CI scenarios).

Expected Behavior

If commit-hash supplied for --from and --to is the same, it should just analyze one single commit message for the supplied commit hash. Or at least return an exit-code different than 0 to denote that the supplied params were invalid (invalid in the sense that commitlint didn't validate anything).

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Context

I was trying to develop a simple GitHub actions CI workflow that checks the single last commit hash. The flag --edit didn't work in this scenario so I tried --from and --to with ${{ github.sha } but, as you can see from this bug I just filed, it didn't work.

You might want to suggest that I should use the previous commit hash for the from flag, but I believe that in order to achieve this I probably need to tweak the actions/checkout@v2 step with a fetch-depth: 0 option; which is not ideal (because it's not easy to figure out). Fixing this bug should probably be better.

Your Environment

Executable Version
commitlint --version @commitlint/[email protected]
git --version git version 2.32.0 (Apple Git-132)
node --version v18.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions