Repository navigation
Use GITCREDS_PAT_* as the canonical cache env var name - #78
Merged
gaborcsardi merged 2 commits intoSep 24, 2026
Merged
Conversation
Groundwork for the prefix change in r-lib#56, with no behavior change yet. Reads accept either name, the new one first. Writes still go to GITHUB_PAT_*, and gitcreds_cache_envvar() still returns that name. The FAIL sentinel is only honored under the canonical prefix, the one this copy of the file writes. A copy of git-auth.R vendored into another package writes FAIL under the prefix it was built with, and honoring a sentinel from a prefix we no longer write would let that package suppress a credential that is present. gitcreds_delete_cache() now clears every accepted name. Clearing only one leaves a stale value that the read chain returns on the next call, so gitcreds_set() would appear to ignore a rotated token. The bare GITHUB_PAT and GITHUB_TOKEN names are still github.com only, and are now consulted after every prefixed name rather than during the first one, so a prefixed value keeps winning over a bare one. gitcreds_cache_envvars() derives its names from gitcreds_cache_envvar() rather than sharing a slug helper, so an invalid URL is still reported against the public function the caller named. Refs r-lib#56
GITHUB_PAT_GITLAB_COM, for a GitLab host, is misleading enough to be a support burden. r-lib#72 proposed this rename first and is the origin of the change; this commit differs only in the prefix it picks and in resting on the compatibility layer added in the previous commit. GIT_PAT_ was the prefix suggested in r-lib#56, but GIT_* is git's own namespace (GIT_DIR, GIT_ASKPASS, GIT_TERMINAL_PROMPT). Nothing collides today, and GITCREDS_PAT_ belongs to the package that owns it. The old names are still read. A warning fires once per session when one of them supplied the credential, never when the new name is set, and not at all for the bare GITHUB_PAT and GITHUB_TOKEN names, which this change does not affect. Once per session rather than per call because gitcreds_get() runs deep inside install paths in gh, pkgdepends and usethis. GITCREDS_LEGACY_WARN=false silences it. Warn-once is a flag in the local() environment and base warning(), because test-standalone.R requires every function here to be base only. The FAIL sentinel now belongs to GITCREDS_PAT_*, so a sentinel written under the old name by an older vendored copy of this file no longer suppresses a lookup. The existing cache tests are updated accordingly; they documented the previous contract. Co-authored-by: melissavanbussel <[email protected]> Closes r-lib#56
SokolovAnatoliy
force-pushed
the
pr3-canonical-gitcreds-pat
branch
from
September 17, 2026 20:21
0d819ba to
426dae8
Compare
Member
|
Great, thank you! |
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.
Builds on #77, which put the compatibility paths in already, so this only moves the write
target and the docs. Revertible on its own.
GITHUB_PAT_GITLAB_COM, for a GitLab host, is misleading enough to be a support burden. Legacynames are still read. A warning fires once per session when a legacy name is what supplied the
credential, and never when the new name is set. It is hand-rolled with base
warning()and a flagin the
local()environment, sincetest-standalone.Rrequires base only.On the spelling: #56 suggests
GIT_PAT_, butGIT_*is git's own namespace (GIT_DIR,GIT_ASKPASS,GIT_TERMINAL_PROMPT). Nothing collides today, andGITCREDS_PAT_*belongs to thepackage that owns it.
#72 from @melissavanbussel proposed this rename in September 2025.
The one-line change here is the same change. What this PR adds is the compatibility
layer in #77 and the warning, which is why it is a separate branch rather than a review comment.
If you would rather take #72 rebased onto #77, close this one. The flip commit carries a
Co-authored-bytrailer either way.Anyone vendoring
git-auth.Rwill want to re-vendor. An older copy computes the legacy name, soits cache no longer shares a slot with this one. Tracked in r-lib/pkgdepends#484.
Closes #56