GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cz check range sometimes failed in GitLab CI · Issue #593 · commitizen-tools/commitizen

cz check range sometimes failed in GitLab CI #593

New issue
Copy link
New issue
Copy link
Closed as not planned
Bug
Closed as not planned
cz check range sometimes failed in GitLab CI#593
Bug
Copy link
Labels
issue-status: wait-for-responsetype: bug

Description

@SsuperL
SsuperL
opened on Sep 21, 2022
Issue body actions

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

Reacted by Ross Patterson, Ackerman and gebbissimo

Activity

Next
  1. SsuperL
    added
    type: bug
    on Sep 21, 2022
  2. Lee-W commented on Sep 22, 2022

    @Lee-W
    Lee-W
    on Sep 22, 2022
    Member
    More actions

    Is it possible that the git repo doesn't setup remote 🤔

  3. SsuperL commented on Sep 23, 2022

    @SsuperL
    SsuperL
    on Sep 23, 2022
    Author
    More actions

    I run command git remote -v in the CI , and it shows that the remote has been setup.

  4. SsuperL commented on Sep 23, 2022

    @SsuperL
    SsuperL
    on Sep 23, 2022
    Author
    More actions

    image

  5. Lee-W commented on Sep 23, 2022

    @Lee-W
    Lee-W
    on Sep 23, 2022
    Member
    More actions

    Hmmm... As I'm not able to reproduce it, I don't have any clue on how we could fix it. But we can keep it open till you or someone encounter this issue again with more detail

  6. SsuperL commented on Sep 25, 2022

    @SsuperL
    SsuperL
    on Sep 25, 2022
    Author
    More actions

    Actually,this issue has come up again.

  7. SsuperL commented on Sep 26, 2022

    @SsuperL
    SsuperL
    on Sep 26, 2022
    Author
    More actions

    image
    And when I merged the branch into master,it said that there is no commit found range origin/master..HEAD.

  8. Lee-W commented on Sep 26, 2022

    @Lee-W
    Lee-W
    on Sep 26, 2022
    Member
    More actions

    Do you mean after merging back to the master branch? If that's the case, your HEAD will on on master so the result seem to be expected.

  9. SsuperL commented on Sep 27, 2022

    @SsuperL
    SsuperL
    on Sep 27, 2022
    Author
    More actions

    Do you mean after merging back to the master branch? If that's the case, your HEAD will on on master so the result seem to be expected.

    yes. Or can it skip check when there's no commit rather than make the job failed?

    image

  10. Lee-W commented on Oct 3, 2022

    @Lee-W
    Lee-W
    on Oct 3, 2022
    Member
    More actions

    @SsuperL Please try cz --no-raise 3 check --rev-range master... it's output the message with a zero return code

    https://commitizen-tools.github.io/commitizen/bump/#easy-way

  11. SsuperL commented on Oct 9, 2022

    @SsuperL
    SsuperL
    on Oct 9, 2022
    Author
    More actions

    cz --no-raise 3 check --rev-range master..

    I'll try it.Thank you!

  12. Lujeni commented on Oct 19, 2022

    @Lujeni
    Lujeni
    on Oct 19, 2022
    More actions

    @SsuperL did you try to git fetch before your command ? its seems GitLab CI dont fetch every branch

  13. SsuperL commented on Oct 24, 2022

    @SsuperL
    SsuperL
    on Oct 24, 2022
    Author
    More actions

    @SsuperL did you try to git fetch before your command ? its seems GitLab CI dont fetch every branch
    No, but it only appeared on some machines. And the command git branch -r shows branch origin/master exists.

  14. SsuperL commented on Nov 29, 2022

    @SsuperL
    SsuperL
    on Nov 29, 2022
    Author
    More actions

    image

  15. Lee-W commented on Nov 29, 2022

    @Lee-W
    Lee-W
    on Nov 29, 2022
    Member
    More actions

    do you have remote origin and branch master?

  16. 5 remaining items

  17. baggiponte commented on Mar 22, 2023

    @baggiponte
    baggiponte
    on Mar 22, 2023
    More actions

    Hi, I am having the same issue outside of CI. When I git push with the pre-push pre-commit hook, I get the following:

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

    Whereas if I skip the verification everything works fine.

    Unfortunately the repo is private and I can't share the url, but the configs are:

    default_install_hook_types:
      - pre-commit
      - pre-push
    default_language_version:
      python: python3.9
    repos:
      - repo: https://github.com/commitizen-tools/commitizen
        rev: v2.42.1
        hooks:
          - id: commitizen-branch
            stages: [ push ]

    And the hook (which should not matter) is:

    #!/usr/bin/env bash
    # File generated by pre-commit: https://pre-commit.com
    # ID: 138fd403232d2ddd5efb44317e38bf03
    
    # start templated
    INSTALL_PYTHON=/Users/lucabaggi/.local/share/pipx/venvs/pre-commit/bin/python
    ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-push)
    # end templated
    
    HERE="$(cd "$(dirname "$0")" && pwd)"
    ARGS+=(--hook-dir "$HERE" -- "$@")
    
    if [ -x "$INSTALL_PYTHON" ]; then
        exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}"
    elif command -v pre-commit > /dev/null; then
        exec pre-commit "${ARGS[@]}"
    else
        echo '`pre-commit` not found.  Did you forget to activate your virtualenv?' 1>&2
        exit 1
    fi
  18. SsuperL commented on Mar 23, 2023

    @SsuperL
    SsuperL
    on Mar 23, 2023
    Author
    More actions

    Hi, I am having the same issue outside of CI. When I git push with the pre-push pre-commit hook, I get the following:

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

    Whereas if I skip the verification everything works fine.

    Unfortunately the repo is private and I can't share the url, but the configs are:

    default_install_hook_types:
      - pre-commit
      - pre-push
    default_language_version:
      python: python3.9
    repos:
      - repo: https://github.com/commitizen-tools/commitizen
        rev: v2.42.1
        hooks:
          - id: commitizen-branch
            stages: [ push ]

    And the hook (which should not matter) is:

    #!/usr/bin/env bash
    # File generated by pre-commit: https://pre-commit.com
    # ID: 138fd403232d2ddd5efb44317e38bf03
    
    # start templated
    INSTALL_PYTHON=/Users/lucabaggi/.local/share/pipx/venvs/pre-commit/bin/python
    ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-push)
    # end templated
    
    HERE="$(cd "$(dirname "$0")" && pwd)"
    ARGS+=(--hook-dir "$HERE" -- "$@")
    
    if [ -x "$INSTALL_PYTHON" ]; then
        exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}"
    elif command -v pre-commit > /dev/null; then
        exec pre-commit "${ARGS[@]}"
    else
        echo '`pre-commit` not found.  Did you forget to activate your virtualenv?' 1>&2
        exit 1
    fi

    Have you tried git fetch ? That works for me.

  19. baggiponte commented on Mar 23, 2023

    @baggiponte
    baggiponte
    on Mar 23, 2023
    More actions

    Have you tried git fetch ? That works for me.

    Does not for me... Perhaps it can mess up if I have git push --force previously?

  20. baggiponte commented on Mar 27, 2023

    @baggiponte
    baggiponte
    on Mar 27, 2023
    More actions

    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.

    Reacted by Santiago Fraire Willemoes, Charles Aracil, golegario96 and Daniel Black
  21. rpatterson
    added a commit that references this issue on Mar 29, 2023

    build(vcs): Workaround commitizen push hook bug

    65e7847
  22. johanmynhardt commented on Dec 21, 2023

    @johanmynhardt
    johanmynhardt
    on Dec 21, 2023
    More actions

    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.)

    Reacted by Elijas Dapšauskas, marlon, daymade, Damien Storm, Mike-F-G and andyinno
  23. AdrianDC commented on Aug 19, 2024

    @AdrianDC
    AdrianDC
    on Aug 19, 2024
    Contributor
    More actions

    Checking older or related issues to access the tool's status.

    • Access master branch on GitLab CI : Only the current branch commits are accessible + shallow history, fetching is needed for any branch

      • Settings / CI/CD / Git shallow clone: The number of changes to fetch from GitLab when cloning a repository. Lower values can speed up pipeline execution. Set to 0 or blank to fetch all branches and tags for each job (default: 50)
      • Comparing with another branch or even using the current branch or the merge request target branch needs fetching
      • Variables : By default, the *_SHA variables are the ones for detecting the commit's / pipeline's context
      • Predefine variables: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html)
    • The CI_COMMIT_BEFORE_SHA variable can be used to compare a CI with the previously pushed commit, but handlings are needed:

      • Limitations: Value is 000.. in specific cases, and might be unknown if the commit was amended and force-pushed
      • Example: https://gitlab.com/RadianDevCore/tools/gcil/-/blob/45897937b0f2104967921101241cf067ef4beceb/.gitlab-ci.yml#L217
    • origin/HEAD..HEAD push issues : fix(pre-commit-hooks)!: allow empty ranges in 'commitizen-branch' #1209

  24. dboeckenhoff commented on Jan 14, 2025

    @dboeckenhoff
    dboeckenhoff
    on Jan 14, 2025
    More actions

    Having the same issue as new user in 2025; git fetch did not help

  25. Lee-W commented on Mar 30, 2025

    @Lee-W
    Lee-W
    on Mar 30, 2025
    Member
    More actions

    Having the same issue as new user in 2025; git fetch did not help

    Hey could you please provide an example so that we could try to reproduce and see what's happening? Thanks!

  26. Lee-W
    added
    issue-status: wait-for-response
    on Mar 30, 2025
  27. Lee-W
    added the
    Bug
    issue type on Mar 30, 2025
  28. bearomorphism commented on May 9, 2026

    @bearomorphism
    bearomorphism
    on May 9, 2026
    Collaborator
    More actions

    Triage from #1964: This is caused by GitLab CI's shallow clone — origin/master isn't present in the runner's local refs — not a commitizen bug. Workaround: set GIT_DEPTH: 0 in your .gitlab-ci.yml (or git fetch --unshallow / git fetch origin master:master before running cz check --rev-range). Suggesting we close this.

  29. bearomorphism commented on May 9, 2026

    @bearomorphism
    bearomorphism
    on May 9, 2026
    Collaborator
    More actions

    Verification update (re #1964)

    Reproduced against current master (4.15.1):

    • git clone --depth=1 of the default branch — cz check --rev-range origin/master..HEAD works fine (origin/master is present).
    • A more accurate GitLab-runner simulation (shallow + single-branch fetch missing master refs) reproduces the exact failure:
      fatal: ambiguous argument 'origin/master..HEAD': unknown revision or path not in the working tree
      (exit 23)
      
    • Mitigations confirmed working:
      • git fetch --unshallow origin master:master — fixes master..HEAD
      • git fetch origin master:refs/remotes/origin/master — fixes origin/master..HEAD without unshallowing

    Verdict: NOT A BUG / CI ENVIRONMENT.

    The failure is purely a GitLab-CI shallow-clone artifact: origin/master isn't a fetched ref in the runner's local repo. Commitizen passes the rev-range to git log, which errors as expected.

    Workaround for the user's GitLab pipeline:

    variables:
      GIT_DEPTH: "0"   # or sufficient depth to include the merge base
    # or
    script:
      - git fetch origin master:refs/remotes/origin/master
      - cz check --rev-range origin/master..HEAD

    Closing-eligible.

    (One improvement we could make in commitizen itself: catch the git log error in cz check --rev-range and surface a clearer message like "Could not resolve rev-range '<range>': did you forget to fetch the base branch in CI?". Optional.)

  30. bearomorphism commented on May 9, 2026

    @bearomorphism
    bearomorphism
    on May 9, 2026
    Collaborator
    More actions

    Closing as not a bug: reproduced as a CI shallow-clone artifact. Workarounds (GIT_DEPTH: 0 or git fetch origin master:refs/remotes/origin/master) confirmed working. See verification comment above.

  31. bearomorphism
    closed this as not plannedon May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue-status: wait-for-responsetype: bug

    Type

    Bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.