gitcredentials

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureHelper

func ConfigureHelper(ctx context.Context, binaryPath, userName string, port int) error

ConfigureHelper installs credential helper into the user's global git config, replacing any previously configured helper.

func GetHTTPPath

func GetHTTPPath(ctx context.Context, params GetHttpPathParameters) (string, error)

GetHTTPPath returns the repository path component when git's `credential.<url>.useHttpPath` is enabled for the host+protocol, else "".

func GetLocalGitConfigPath

func GetLocalGitConfigPath(repoPath string) string

GetLocalGitConfigPath resolves the local git config for a repository path.

func RemoveHelper

func RemoveHelper(ctx context.Context, userName string) error

RemoveHelper removes credential helper from the user's global config.

func RemoveHelperFromPath

func RemoveHelperFromPath(ctx context.Context, gitConfigPath string) error

RemoveHelperFromPath removes the credential.helper setting from the config at path, leaving any other credential.* settings intact.

func SetUser

func SetUser(ctx context.Context, userName string, user *GitUser) error

SetUser sets the global git identity for the given OS user.

func SetupGpgGitKey

func SetupGpgGitKey(ctx context.Context, gitSignKey string) error

SetupGpgGitKey sets the global signing key.

Types

type GetHttpPathParameters

type GetHttpPathParameters struct {
	Host        string
	Protocol    string
	CurrentPath string
	Repository  string
}

type GitCredentials

type GitCredentials struct {
	Protocol string `json:"protocol,omitempty"`
	URL      string `json:"url,omitempty"`
	Host     string `json:"host,omitempty"`
	Path     string `json:"path,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

GitCredentials is the git credential-helper record. Its wire form is git's documented key=value line protocol (see gitcredentials(7)).

func GetCredentials

func GetCredentials(ctx context.Context, request *GitCredentials) (*GitCredentials, error)

GetCredentials resolves credentials for a request, using devsy's credential server when a helper port is configured, otherwise `git credential fill`.

func ParseCredentials added in v1.4.1

func ParseCredentials(raw string) GitCredentials

ParseCredentials parses git's key=value credential line format. It is the inverse of Encode. Unknown keys are ignored, matching git's tolerant parsing.

func (GitCredentials) Encode added in v1.4.1

func (c GitCredentials) Encode() string

Encode renders the credentials in git's key=value line format, terminated by a trailing newline. Only non-empty fields are emitted, matching git's helper protocol.

type GitUser

type GitUser struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
}

GitUser is a git identity (user.name / user.email).

func GetUser

func GetUser(ctx context.Context, userName, workingDir string) (*GitUser, error)

GetUser retrieves the global git identity for the given OS user.

type Resolver added in v1.4.1

type Resolver struct{}

func (Resolver) Resolve added in v1.4.1

func (Resolver) Resolve(
	ctx context.Context,
	protocol, host, path string,
) (username, password string, err error)

Resolve implements download.CredentialResolver.

Jump to

Keyboard shortcuts

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