I am trying to run pre-commit using hooks from a private repository using a GIT_TOKEN
.
Before running pre-commit run --all-files
, I insert my GIT_TOKEN
(which has read access to the hooks repository) into the URL used for GitHub.
git config --global url."https://${GIT_TOKEN}@github.com/".insteadOf "https://github.com/"
git config --global url."https://${GIT_TOKEN}@github.com/".insteadOf "ssh://[email protected]/"
Nonetheless, I get the following error:
An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', 'fetch', 'origin', '--tags')
return code: 128
stdout: (none)
stderr:
fatal: could not read Username for 'https://github.com': No such device or address
Check the log at /home/jdh/.cache/pre-commit/pre-commit.log
I have the following simple .pre-commit-config.yaml
:
- repo: https://github.com/JakobHavtorn/private-repository
rev: v0.1.0
hooks:
- id: some-hook
I have looked through the documentation at https://pre-commit.com but was not able to find much detail on handling private hook repos.
I have verified that my token is correct and is set correctly in the URL (I can clone a different private repository).
I have tried running pre-commit run --all-files
locally using try-repo
, which works as expected.
I have also tried running the command with a SSH token defined for the github.com
host via the /.ssh/config
file (see below), which also works as expected.
host github.com
HostName github.com
IdentityFile ~/.ssh/github
User git
Thanks for your work on the tool and for taking the time with this question.