gitcred

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 25 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const EnvTokenSource = "GITHUB_TOKEN/GH_TOKEN"

EnvTokenSource names the GITHUB_TOKEN or GH_TOKEN candidate in rejection lists and the stale token hint

Variables

View Source
var ErrSecretReaderUnregistered = errors.New("gitcred: no secret reader registered, import pkg/provider")

ErrSecretReaderUnregistered is returned when a GitHub env token lookup runs before pkg/provider registered its reader

Functions

func GhCliToken

func GhCliToken() string

Token from the gh CLI keyring login with exported GitHub tokens hidden, empty when gh is absent or fails

func IsCredentialRequiredError

func IsCredentialRequiredError(stderr, stdout string) bool

Reports whether failed git output says the remote demands a credential rather than another failure

func IterGitBasicAuth

func IterGitBasicAuth(ctx context.Context, url string) iter.Seq2[Credential, error]

Every credential the user owns for the URL host in precedence order without duplicates, looked up lazily

func SetSecretReader

func SetSecretReader(fn func(ctx context.Context, name string) (string, error))

Installs the profile scoped secret lookup that GITHUB_TOKEN and GH_TOKEN resolve through

func WithGitAuth

func WithGitAuth(ctx context.Context, env map[string]string, url string, auth *BasicAuth) (map[string]string, error)

Copy of env carrying an http extraheader for the URL origin when a credential is given or stored

Types

type BasicAuth

type BasicAuth struct{ Username, Password string }

BasicAuth is the username and password pair git sends as an Authorization basic header

func ResolveGitBasicAuth

func ResolveGitBasicAuth(ctx context.Context, url string) (BasicAuth, bool, error)

First credential the user owns for the URL, absent for non https URLs or when none is stored

type Credential

type Credential struct {
	Source string
	Auth   BasicAuth
}

Credential is one owned credential with the source that supplied it

type GitResult

type GitResult struct {
	Code           int
	Stdout, Stderr string
}

Completed git process of a credential fallback run

func RunGitWithCredentialFallback

func RunGitWithCredentialFallback(ctx context.Context, argv []string, url string, env map[string]string, runner GitRunner) (GitResult, error)

Runs a git network verb anonymously, then with each owned credential while the remote keeps refusing for credentials

type GitRunner

type GitRunner func(ctx context.Context, argv []string, env map[string]string) (code int, stdout, stderr string, err error)

One git subprocess run under the caller's run options, the run_kwargs of the signature

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL