scm

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT, MIT Imports: 9 Imported by: 0

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

func SanitizeOutput(text, token string) string

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.

type GitConfig

type GitConfig struct {
	Key   string
	Value string
}

GitConfig is a single git config entry applied to a command invocation.

type Platform

type Platform int
const (
	UnknownPlatform Platform = iota
	NoPlatform               // Explicitly disable the feature
	GitHubPlatform
	GitLabPlatform
	AzureDevOpsPlatform
	GiteaPlatform
	BitbucketPlatform
)

func PlatformFromString

func PlatformFromString(s string) (Platform, error)

func (Platform) String

func (p Platform) String() string

Jump to

Keyboard shortcuts

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