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

fatal: ambiguous argument 'HEAD1..HEAD' error on Windows #4106

Open
matyasf opened this issue Jul 26, 2024 · 4 comments
Open

fatal: ambiguous argument 'HEAD1..HEAD' error on Windows #4106

matyasf opened this issue Jul 26, 2024 · 4 comments
Labels

Comments

@matyasf
Copy link

matyasf commented Jul 26, 2024

Steps to Reproduce

We are running the following command: commitlint --from=HEAD^1. This works fine on OSX, but fails in Windows 10 (cmd.exe) with the following error:

/node_modules/@commitlint/cli/lib/cli.js:127
        throw err;
        ^

Error: fatal: ambiguous argument 'HEAD1..HEAD': 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] (C:\CODE\instructure-ui\node_modules\git-raw-commits\index.js:100:36)
    at Transform._write (node:internal/streams/transform:171:8)
    at writeOrBuffer (node:internal/streams/writable:570:12)
    at _write (node:internal/streams/writable:499:10)
    at Writable.write (node:internal/streams/writable:508:10)
    at Socket.ondata (node:internal/streams/readable:1007:22)
    at Socket.emit (node:events:532:35)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)

Node version: 22

commitlint.config.js:

module.exports = {
  extends: ['@commitlint/config-conventional'],
  parserOpts: {
    headerPattern: /^(\w*)\((\w*)\)-(\w*)\s(.*)$/,
    headerCorrespondence: ['type', 'scope', 'subject']
  },
  // see https://commitlint.js.org/#/reference-rules
  rules: {
    'type-enum': [
      2,
      'always',
      [
        'WIP',
        'feat',
        'fix',
        'docs',
        'chore',
        'style',
        'refactor',
        'test',
        'perf',
        'revert'
      ]
    ],
    'type-case': [0],
    'header-max-length': [0, 'always', 150] // commit message first field (subject) length
  }
}

versions:

"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",

(was producing the same error on v17)

running via Husky



### Current Behavior

crash

### Expected Behavior

no crash

### Affected packages

- [X] cli
- [ ] core
- [ ] prompt
- [ ] config-angular

### Possible Solution

_No response_

### Context

_No response_

### commitlint --version

19.3.0

### git --version

2.45.2.windows.1

### node --version

v22.5.1
@escapedcat
Copy link
Member

Does this duplicate or relate to #6?

@knocte
Copy link
Contributor

knocte commented Aug 31, 2024

We are running the following command: commitlint --from=HEAD^1

What does HEAD^1 mean? is it the same as HEAD~1? And why are you not using --to?

@Leinark
Copy link

Leinark commented Sep 20, 2024

I have the same error in GitHub Actions. I use runs-on: ubuntu-latest and install the packages: cli, config-conventional, and types. The command I run is: pnpm dlx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose

@knocte
Copy link
Contributor

knocte commented Sep 20, 2024

@MatthieuLeterme you are using ~ but the reporter of this bug used ^, please open a new bug.

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

4 participants