Repository navigation
Conversation
A git dependency from a private repository cannot be fetched by any of the uv based modules: the default base has git, but no way to give it credentials. gitToken, on pytest, uv, mypy and ty, takes a secret that the shared library hands to git as a credential helper declared through GIT_CONFIG_* variables, for gitHost only (github.com by default). uv runs the git CLI with its environment, so the helper reaches it with no config file written, and the token stays out of every layer, URL and uv.lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: telchak <scanachib@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The default base has git, so a git dependency from a public repository works. One from a private repository can't be fetched by any of the uv-based modules, because nothing can hand git a credential. We hit this with a project that depends on
pkg @ git+https://github.com/<org>/<private-repo>.git@<sha>, with CI on GitHub Actions, where a GitHub App mints a short-lived token for that one repository.What
PyprojecttakesgitToken: Secret = nullandgitHost: String! = "github.com".pytest,uv,mypyandtyexpose both and forward them.ruffnever touches uv, so it doesn't.With a token,
withGitTokenapplies to whichever base is used, default or custom:https://<gitHost>only is declared throughGIT_CONFIG_COUNT/GIT_CONFIG_KEY_0/GIT_CONFIG_VALUE_0(git 2.31+).uv runs the git CLI with its environment, so the helper reaches it with no config file written. The token stays out of every layer, URL and
uv.lock, and it is read only when the host asks for credentials.The README documents the setting in the Python environment section and in the three settings tables.
One limitation: a custom base that already sets its own
GIT_CONFIG_*variables would have them replaced while a token is set.Tests
New
gitTokenCheckin the e2e suite, which checks that:git credential fillforgithub.comreturns the token (compared inside the shell, since stdout comes back scrubbed);I ran the e2e suite from a Windows client.
git-token-checkpasses. Every other result matches a run of unmodifiedmainon the same machine, failure for failure: there, the workspace search fails withpath cannot escape search rootand ghcr.io pulls are refused. That host also neededpyproject/images/uv/Dockerfiletemporarily pointed atastral/uv:0.12.9on Docker Hub; the change isn't part of this PR. A run from a Linux client would be welcome.Used for real through the fork in prairialab/reliability-engine, whose tests install a private dependency this way.
🤖 Generated with Claude Code