conventional-changelog / commitlint

📓 Lint commit messages
https://commitlint.js.org
MIT License
16.88k stars 909 forks source link

fix: I encountered an 'unknown revision' error in GitHub Actions. #4159

Closed Leinark closed 4 weeks ago

Leinark commented 1 month ago

Steps to Reproduce

steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v3
        name: Install pnpm
        with:
          version: 8
          run_install: false
      - name: Print versions
        run: |
          git --version
          node --version
          pnpm --version
          pnpm dlx commitlint --version
      - name: Install commitlint
        run: |
          pnpm install

      - name: Validate PR commits with commitlint
        if: github.event_name == 'pull_request'
        run: pnpm dlx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose

Current Behavior

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

    at Transform.transform [as _transform] (/home/runner/setup-pnpm/node_modules/.bin/store/v3/tmp/dlx-[17](https://github.com/matchersteam/poc-bo-v3/actions/runs/10959823335/job/30433008152#step:6:18)49/node_modules/.pnpm/git-raw-commits@4.0.0/node_modules/git-raw-commits/index.js:100:36)

Expected Behavior

Good | Error ### Affected packages - [X] cli - [ ] core - [ ] prompt - [ ] config-angular ### Possible Solution _No response_ ### Context I want to check the lint of commits in all pull requests in my repository ### commitlint --version 19.5.0 ### git --version 2.46.0 ### node --version v18.20.4
jellehuibregtse commented 1 month ago

@MatthieuLeterme For me, changing to fetch-depth: 0 fixes this:

    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
Leinark commented 4 weeks ago

It work for me. Thanks