commitizen: cz check range sometimes failed in GitLab CI

Description

Runcz check --range origin/master..HEAD to check commits in CI occasionally fails. And it worked after I retried the job.But sometimes it didn’t work after retrying multiple times. I couldn’t find out the reason ,

Steps to reproduce

lint: retry: 1 script: - cz version - cz check --rev-range origin/master…HEAD

Current behavior

cz check --rev-range origin/master..HEAD failed. Outputs attached below:

  fatal: ambiguous argument 'master..HEAD': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

Desired behavior

cz check --rev-range can run successfully in gitlab CI.

Screenshots

image

Environment

commitizen version: 2.34.0 python version: 3.7.5 operating system: Linux

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 24 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Hello, if I run cz check --rev-range origin/main..HEAD it works. I noticed that the pre-commit hook has --rev-range origin/HEAD..HEAD which is an invalid ref. Perhaps when the repo has multiple branches the reference becomes invalid? Will try to make a reprex soon.

The following fixed it for me:

git remote set-head origin -a

Eventually found a semi-good explanation at: https://learnku.com/articles/71493

(My issue is actually when I’m trying to run git push with the pre-push hook enabled, which then gives a similar error on ambiguity.)

What would be the output of git log origin/master..? Can it generate output as expected?

Oh,it didn’t show anything of git log origin/master. Maybe there’s no git fetch on some CI machines. I try git fetch origin and it works. Thanks for your help!