Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 of 4 tasks
knocte opened this issue Sep 11, 2022 · 3 comments
Open
2 of 4 tasks
Labels

Comments

@knocte
Copy link
Contributor

knocte commented Sep 11, 2022

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
@knocte

This comment was marked as outdated.

@escapedcat
Copy link
Member

escapedcat commented Sep 12, 2022

#2568 is related

@escapedcat escapedcat added bug and removed question labels Sep 12, 2022
@knocte

This comment was marked as outdated.

Mersho added a commit to Mersho/commitlint that referenced this issue Feb 12, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 12, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 12, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 12, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 12, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 12, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 13, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 13, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 13, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 13, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 13, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 13, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 14, 2024
Mersho added a commit to Mersho/commitlint that referenced this issue Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants