Skip to content

Accept GITCREDS_PAT_* alongside GITHUB_PAT_* - #77

Merged
gaborcsardi merged 2 commits into
r-lib:mainfrom
SokolovAnatoliy:pr2-accept-both-names
Sep 24, 2026
Merged

gaborcsardi merged 2 commits into
r-lib:mainfrom
SokolovAnatoliy:pr2-accept-both-names

Conversation

@SokolovAnatoliy

@SokolovAnatoliy SokolovAnatoliy commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Groundwork for the rename in #56, with no behavior change. Reads accept either name, new one
first. Writes still go to GITHUB_PAT_*, and gitcreds_cache_envvar() still returns the legacy
name, so nothing moves for existing users. Early adopters can start setting the new name now.

Two details worth a look.

The FAIL sentinel is only honored under the canonical name. A vendored older copy of
git-auth.R writes FAIL to the legacy name (pkgdepends does this in git_creds_for_url()), and
honoring that through the fallback would let one package suppress a credential that is present.
Reprex in r-lib/pkgdepends#484.

gitcreds_delete_cache() now unsets both names. With a fallback in place, unsetting only one
leaves a stale legacy value that the fallback then returns, so gitcreds_set() would look like it
ignored a rotated token.

Also widens the ^GITHUB_PAT scrub in tests/testthat/helper.R, so tests stay isolated from the
developer's own environment.

Refs #56

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
@gaborcsardi
gaborcsardi merged commit 4eaa387 into r-lib:main Sep 24, 2026
15 checks passed
@gaborcsardi

Copy link
Copy Markdown
Member

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants