conventional-changelog / commitlint

📓 Lint commit messages

Home Page:https://commitlint.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: failure in GitLab with "Error: fatal: Invalid revision range"

abitrolly opened this issue · comments

Steps to Reproduce

I am not sure if it is dup of #885 or not, but I've got this failure here https://gitlab.com/gitlab-community/modelops/applied-ml/code-suggestions/ai-assist/-/jobs/7430104908

$ npm install --save-dev @commitlint/config-conventional @commitlint/cli
added 125 packages in 9s
28 packages are looking for funding
  run `npm fund` for details
$ echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
$ npx commitlint --from="$CI_MERGE_REQUEST_DIFF_BASE_SHA" --help-url 'https://www.conventionalcommits.org/en'
file:///builds/gitlab-community/modelops/applied-ml/code-suggestions/ai-assist/node_modules/@commitlint/cli/lib/cli.js:127
        throw err;
        ^
Error: fatal: Invalid revision range 6e97dc894774a3d16b9d6abf5bf762ee240abd08..HEAD
    at Transform.transform [as _transform] (/builds/gitlab-community/modelops/applied-ml/code-suggestions/ai-assist/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.js v22.5.1


The commit from "Invalid revision range" is here https://gitlab.com/gitlab-community/modelops/applied-ml/code-suggestions/ai-assist/-/commit/6e97dc894774a3d16b9d6abf5bf762ee240abd08 and it precedes the MR, so I am not sure what this error is about.

Current Behavior

No response

Expected Behavior

Expected actionable error message.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

No response

Context

No response

commitlint --version

i don't know

git --version

i don't know

node --version

v22.5.1

Okay. #885 (comment) pinpoints the problem.

The default git depth in GitLab pipelines is 20 (https://docs.gitlab.com/ee/ci/pipelines/settings.html#limit-the-number-of-changes-fetched-during-clone).

And there are exactly 20 commits in my MR.
image

So the solution to my problem is to remove git depth limitation in the lint job (https://gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/-/merge_requests/1143).

  variables:
    GIT_DEPTH: 0

The proper fix on commitlint side is to detect this condition, and show user the fix. On GitLab side - to ensure that MR default clone depth always includes parent commit.

Might be already good to add a comment to the docs first

Opened an issue in GitLab for long term fix https://gitlab.com/gitlab-org/gitlab/-/issues/474701