Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneAuthed ¶
func CloneAuthed(ctx context.Context, remote, token, dest string, opts CloneOptions) error
CloneAuthed clones remote into dest. If token is non-empty and the remote is HTTPS, it is passed via a temporary git config entry so the clone can authenticate without mutating the remote URL. The token is stripped from any returned error message via SanitizeOutput.
The intent is to let multiple SCM sources (GitHub today, GitLab/Bitbucket later) share one clone helper.
func CloneToTempDir ¶
func CloneToTempDir(ctx context.Context, remote, token, tempDirPattern string, opts CloneOptions, fn func(repoPath string) error) error
CloneToTempDir clones a remote into a temporary directory, invokes fn with the cloned repo path, and removes the directory afterwards.
func SanitizeOutput ¶
SanitizeOutput redacts the token (and any URL-encoded form of it) from text. It also strips userinfo from any URL that looks like https://user:pass@host. Use it whenever you log or wrap text that may have come from a `git` invocation.
Types ¶
type CloneOptions ¶
type CloneOptions struct {
// Bare clones with --bare (no working tree). Recommended for scanning
// since we only need objects.
Bare bool
// Mirror clones with --mirror (implies bare). Useful when the caller
// wants the full set of refs (e.g. PR refs, tags) without further
// configuration.
Mirror bool
// SingleBranch limits the clone to the default branch only.
SingleBranch bool
// Depth, if > 0, requests a shallow clone of that many commits.
Depth int
// Configs are extra git config key/value pairs applied only to this clone.
Configs []GitConfig
}
CloneOptions configures a CloneAuthed call. Zero value is valid: full (non-bare, non-mirror) clone with no extra options.