git

package
v0.128.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MirrorCompactionCompacted = "compacted"
	MirrorCompactionFailed    = "failed"
	// MirrorCompactionCancelled reports a CompactMirror call whose context was
	// cancelled before the new pack was installed; the mirror keeps its packs.
	MirrorCompactionCancelled = "cancelled"
	// MirrorCompactionSkippedBusy reports a CompactMirror call that left the
	// mirror alone because another operation held its lock.
	MirrorCompactionSkippedBusy = "skipped_busy"
	// MirrorCompactionSkippedSize reports a repack skipped because the mirror's
	// packfiles exceed MirrorCompactOptions.MaxSizeBytes.
	MirrorCompactionSkippedSize = "skipped_size"
	// MirrorCompactionSkippedSinglePack reports a CompactMirror call that found
	// nothing to consolidate: a single pack and no loose objects in copy mode,
	// or no objects at all.
	MirrorCompactionSkippedSinglePack = "skipped_single_pack"
)

Results reported in MirrorPackStats.Result when a compaction was attempted.

View Source
const (
	MirrorLockShared    = "shared"
	MirrorLockExclusive = "exclusive"
)

Mirror lock modes reported to the mirror lock observer.

View Source
const (
	DefaultShortSHALength = 7 // Default length for shortened commit SHAs
	RemoteName            = "origin"
	TagPrefix             = "refs/tags/"
	BranchPrefix          = "refs/heads/"
	MainBranch            = "refs/heads/main"
	SwarmModeBranch       = "refs/heads/swarm-mode"
)
View Source
const DefaultHTTPAuthUser = "oauth2"

DefaultHTTPAuthUser is the Basic Auth username used when none is configured. Most providers accept any non-empty username for token auth, but GitLab deploy tokens require their specific username (e.g. gitlab+deploy-token-123), which callers supply via GIT_ACCESS_TOKEN_USER / GIT_AUTH_DOMAINS git_access_token_user.

Variables

View Source
var (
	ErrMissingAuthToken           = errors.New("missing access token")
	ErrCheckoutFailed             = errors.New("failed to checkout repository")
	ErrFetchFailed                = errors.New("failed to fetch repository")
	ErrRepositoryNotExists        = git.ErrRepositoryNotExists
	ErrRepositoryAlreadyExists    = git.ErrRepositoryAlreadyExists
	ErrInvalidReference           = git.ErrInvalidReference
	ErrSSHKeyRequired             = errors.New("ssh URL requires SSH_PRIVATE_KEY to be set")
	ErrPossibleAuthMethodMismatch = errors.New("there might be a mismatch between the authentication method and the repository or submodule remote URL")
	ErrRemoteURLMismatch          = errors.New("remote URL does not match expected URL")
	ErrGetHeadFailed              = errors.New("failed to get HEAD reference")
	ErrLegacyCheckoutNotMigrated  = errors.New("legacy checkout has not been migrated to the store layout yet")
)
View Source
var ErrAbsoluteSymlinkTarget = errors.New("absolute symlink target")

ErrAbsoluteSymlinkTarget identifies absolute links so includes can skip them.

View Source
var ErrInvalidMirrorCompactionMode = errors.New("invalid mirror compaction mode")

ErrInvalidMirrorCompactionMode indicates an unknown MirrorCompactionMode.

View Source
var ErrMissingMirrorDir = errors.New("mirror directory is empty")

ErrMissingMirrorDir is returned when a mirror read is attempted without knowing which bare mirror to read from. Falling back to an unlocked, unscoped read would silently drop both the cross-process exclusion and the freshness guarantee that WithMirrorRead exists to provide, so it is reported instead.

Functions

func AcquireExclusiveMirrorLock added in v0.124.0

func AcquireExclusiveMirrorLock(mirrorDir string) func()

AcquireExclusiveMirrorLock takes the exclusive path lock of the bare mirror at mirrorDir and reports its wait and hold time once released.

func AcquireSharedMirrorLock added in v0.124.0

func AcquireSharedMirrorLock(mirrorDir string) func()

AcquireSharedMirrorLock takes the shared path lock of the bare mirror at mirrorDir and reports its wait and hold time once released.

func CloneOrUpdateBareMirror added in v0.120.0

func CloneOrUpdateBareMirror(
	log *slog.Logger,
	cloneURL, ref, path string,
	private bool,
	sshPrivateKey, sshPrivateKeyPassphrase, gitAccessToken string,
	skipTLSVerify bool, proxyOpts transport.ProxyOptions,
	depth int,
) (*git.Repository, error)

CloneOrUpdateBareMirror ensures a bare, checkout-free mirror of cloneURL exists at path and that ref is fetched into it, then returns the opened repository.

It backs store.GitStore's mirror clone. This mirror never checks anything out: GitStore reads tree objects directly (ExportTree) and materializes submodules itself from tree objects, so the mirror only ever needs fetched objects and refs.

After a clone or fetch, the mirror's packfiles are reported to the MirrorPackObserver and consolidated once they exceed mirrorCompactPackThreshold. Compaction deletes packs, so the returned handle must not be read once the lock is released: a concurrent update may compact the mirror underneath it. Readers that outlive this call take the mirror's shared lock and open a fresh handle instead (see WithMirrorRead).

func ConfigureAuthResolver added in v0.86.0

func ConfigureAuthResolver(scoped []ScopedAuthConfig,
	globalPrivateKey, globalKeyPassphrase, globalToken, globalHTTPAuthUser string,
	globalGitHubApp GitHubAppConfig,
)

ConfigureAuthResolver configures domain-scoped and global Git credentials. This should be called when application config is loaded or updated.

func ConvertSSHUrl added in v0.65.0

func ConvertSSHUrl(url string) string

ConvertSSHUrl converts SSH URLs to the ssh:// format. e.g. convert git@github.com:user/repo.git to ssh://git@github.com/user/repo.git

func ExportTree added in v0.120.0

func ExportTree(dir string, repo *git.Repository, commit plumbing.Hash, opts ExportOptions) error

ExportTree materializes commit's tree into dir: directories, regular files (preserving the executable bit) and symlinks (rejecting any link whose target would resolve outside dir, unless an absolute link is explicitly skipped). If opts.SubmoduleCacheDir is set, submodules are additionally fetched and recursively exported at their configured path, down to DefaultSubmoduleRecursionDepth levels deep.

repo must already have commit reachable in its object database (e.g. via a prior CloneOrUpdateBareMirror call for the reference that named it); ExportTree never fetches to make the top-level commit reachable, only - optionally - to make a submodule's pinned commit reachable in its own mirror.

func FetchRepository added in v0.66.0

func FetchRepository(repo *git.Repository, url string, skipTLSVerify bool, proxyOpts transport.ProxyOptions, auth transport.AuthMethod, depth int) error

FetchRepository fetches updates from the remote repository, including all branches and tags, and prunes deleted references. If depth > 0, a shallow fetch is performed with the specified number of commits. It acquires the repository lock; already-locked callers use fetchRepositoryLocked.

func FetchRepositoryReference added in v0.116.0

func FetchRepositoryReference(repo *git.Repository, url, ref string, skipTLSVerify bool, proxyOpts transport.ProxyOptions, auth transport.AuthMethod, depth int) error

FetchRepositoryReference fetches the requested reference using focused refspecs where possible and falls back to the compatibility all-refs transfer as needed. It acquires the repository lock; already-locked callers use fetchRepositoryLocked.

func FormatGitErrorMessage added in v0.107.0

func FormatGitErrorMessage(err error) string

FormatGitErrorMessage formats a git operation error message by attempting to decode any localized error response bodies embedded in it (e.g. from Azure DevOps Server). It returns the formatted error message suitable for logging.

func GetAuthMethod added in v0.65.0

func GetAuthMethod(url, privateKey, keyPassphrase, token string) (transport.AuthMethod, error)

GetAuthMethod determines the appropriate authentication method based on the URL and provided credentials.

func GetFullName added in v0.83.0

func GetFullName(cloneURL string) string

GetFullName extracts the full repository name without the domain part from the clone URL. E.g., "github.com/kimdre/doco-cd" becomes "kimdre/doco-cd" or "git.example.com/doco-cd" becomes "doco-cd".

func GetLatestCommit added in v0.22.0

func GetLatestCommit(repo *git.Repository, ref string) (string, error)

GetLatestCommit retrieves the last commit hash for a given reference in a repository.

func GetRepoName added in v0.65.0

func GetRepoName(cloneURL string) string

GetRepoName returns the repository name in the form "<host>/<owner>/<repo>" from the given clone URL. Supports:

func GetShortestUniqueCommitHash added in v0.89.0

func GetShortestUniqueCommitHash(repo *git.Repository, commitSHA string, minLength int) (string, error)

GetShortestUniqueCommitHash returns the shortest prefix of a commit SHA, at least minLength characters long, that no other object in the repository shares. Similar to the git command `git rev-parse --short=<length> <commitSHA>`.

func HttpTokenAuth added in v0.58.0

func HttpTokenAuth(username, token string) transport.AuthMethod

HttpTokenAuth returns an AuthMethod for HTTP Basic Auth using a token. An empty username falls back to DefaultHTTPAuthUser.

func IsAncestorCommit added in v0.120.0

func IsAncestorCommit(repo *git.Repository, ancestorHash, descendantHash plumbing.Hash) (bool, error)

IsAncestorCommit reports whether the commit at ancestorHash is an ancestor of, or identical to, the commit at descendantHash. It walks history purely from local objects (no network round-trip), so it is cheap when the mirror already holds both commits.

An error means the relationship could not be determined — most commonly because one of the commits is missing from a shallow mirror, but also on any other lookup or traversal failure. Callers must treat that as "unknown", not "false": fail open (proceed) rather than silently skipping a deployment on an unproven assumption.

func IsCorruptionError added in v0.89.0

func IsCorruptionError(err error) bool

IsCorruptionError checks if an error indicates repository corruption rather than a transient failure.

func IsLocalFile added in v0.111.0

func IsLocalFile(url string) bool

IsLocalFile checks if a given URL points to a local filesystem Git repository (file:// scheme).

func IsNativeGit added in v0.126.0

func IsNativeGit(url string) bool

IsNativeGit checks if a given URL uses the native Git protocol (git:// scheme). The scheme check ignores case because URL parsers and go-git accept schemes such as GIT://.

func IsRefUnreachableError added in v0.107.0

func IsRefUnreachableError(err error) bool

IsRefUnreachableError returns true when the error indicates the requested ref could not be found, which in a shallow clone likely means the ref is outside the fetched depth.

func IsSSH added in v0.57.0

func IsSSH(url string) bool

IsSSH checks if a given URL is an SSH URL.

func MirrorRead added in v0.120.1

func MirrorRead[T any](mirrorDir string, fn func(repo *git.Repository) (T, error)) (T, error)

MirrorRead is the value-returning form of WithMirrorRead, for the common case of a read region that produces a single result. On error it returns the zero value of T alongside the error.

func OpenRepository added in v0.64.0

func OpenRepository(path string) (*git.Repository, error)

OpenRepository opens an existing git repository at the specified path. This is a lightweight operation that doesn't fetch or update the repository.

func ReferenceMatches added in v0.124.0

func ReferenceMatches(resolvedReference, configuredReference string) bool

ReferenceMatches reports whether configuredReference names the reference a job resolved as resolvedReference. A fully qualified branch reference (refs/heads/<name>) also matches its short branch name.

The normalization is asymmetric on purpose: a short configured name can be ambiguous with a same-named tag, while refs/heads/<name> unambiguously identifies the branch that was resolved.

func ResolveHTTPToken added in v0.110.0

func ResolveHTTPToken(url string, resolved ResolvedAuthConfig) (string, error)

ResolveHTTPToken returns the access token to use for HTTP(S) requests (git transport as well as SCM API calls like commit status posting) against a repository URL. It prefers an explicit GitAccessToken and falls back to minting a short-lived GitHub App installation token from resolved.GitHubApp when no access token is configured. Returns an empty string (and no error) when neither credential is configured.

func ResolveReferenceCommit added in v0.118.0

func ResolveReferenceCommit(repo *git.Repository, ref string) (plumbing.Hash, error)

ResolveReferenceCommit resolves ref to the commit hash it points to, without touching the working tree or HEAD.

func ResolveScopedCredentials added in v0.86.0

func ResolveScopedCredentials(url, privateKey, keyPassphrase, token string) (string, string, string)

ResolveScopedCredentials resolves credentials for a repository URL using exact domain matches, then the most specific wildcard suffix, and finally global fallback credentials.

func SSHAuth added in v0.58.0

func SSHAuth(privateKey, keyPassphrase string) (transport.AuthMethod, error)

SSHAuth creates an SSH authentication method using the provided private key.

func SetMirrorLockObserver added in v0.124.0

func SetMirrorLockObserver(observer MirrorLockObserver)

SetMirrorLockObserver configures an observer for bare mirror lock acquisitions.

func SetMirrorPackObserver added in v0.124.0

func SetMirrorPackObserver(observer MirrorPackObserver)

SetMirrorPackObserver registers the observer that receives bare mirror pack statistics. Passing nil disables reporting.

func SwapGitHubAppTokenProviderForTest added in v0.110.0

func SwapGitHubAppTokenProviderForTest(provider func(string, GitHubAppConfig) (string, error)) func()

SwapGitHubAppTokenProviderForTest replaces the GitHub App token provider and returns a restore function.

func WatchLocalGitRef added in v0.111.0

func WatchLocalGitRef(ctx context.Context, repoURL string, log *slog.Logger) (<-chan struct{}, error)

WatchLocalGitRef watches a local git repository for changes to branch refs or packed-refs, signaling on the returned channel whenever new commits may have landed.

The channel is buffered (capacity 1) so a missed tick is never blocking; at most one pending notification is queued at a time. The watcher stops and closes the channel when ctx is canceled.

repoURL must be a file:// URL (e.g. "file:///path/to/repo").

func WithMirrorRead added in v0.120.1

func WithMirrorRead(mirrorDir string, fn func(repo *git.Repository) error) error

WithMirrorRead runs fn against a freshly opened handle on the bare mirror at mirrorDir while holding that mirror's shared path lock, then releases both.

Both halves matter, and neither is sufficient alone:

  • The shared lock excludes a concurrent stack's fetch, which takes the matching exclusive lock in CloneOrUpdateBareMirror/GitStore.Publish. It keeps the pack directory stable for the duration of the read.
  • The *fresh* handle is what makes the lock effective. go-git's filesystem.ObjectStorage caches its packfile index map on first use and never refreshes it (requireIndex returns early once s.index != nil), while dotgit.ObjectPacks re-reads the pack directory on every call. A handle that was opened before some other job fetched therefore enumerates a packfile it has no index for, and go-git dereferences that nil index as a nil idxfile.Index interface inside packfile.GetByType - a SIGSEGV, not an error.

The handle is scoped to fn precisely so it cannot outlive the lock and become stale again: every read must re-enter through this helper rather than retain a long-lived *git.Repository across lock regions.

fn may perform any number of reads; batching them into a single call keeps the handle and the lock to one acquisition per logical read region.

Types

type ChangedFile added in v0.29.0

type ChangedFile struct {
	// From represents the file state before the change.
	From diff.File
	// To represents the file state after the change.
	To diff.File
}

ChangedFile represents a file that has changed between two commits.

func GetChangedFilesBetweenCommits added in v0.29.0

func GetChangedFilesBetweenCommits(repo *git.Repository, commitHash1, commitHash2 plumbing.Hash) ([]ChangedFile, error)

GetChangedFilesBetweenCommits retrieves a list of changed files between two commits in a repository.

type CommitInfo added in v0.104.0

type CommitInfo struct {
	Hash      string
	ShortHash string
	Subject   string
	Author    string
}

CommitInfo is a single commit exposed to notification templates.

func GetCommitsBetween added in v0.104.0

func GetCommitsBetween(log *slog.Logger, repo *git.Repository, oldHash, newHash plumbing.Hash, maxCommits int, pathFilter func(string) bool) ([]CommitInfo, error)

GetCommitsBetween returns commits reachable from newHash but not from oldHash, newest first, capped at maxCommits. After a rebase or force-push, where oldHash is not an ancestor of newHash any more, that is the commits since the histories diverged.

A non-nil pathFilter keeps only the commits that changed a path it matches, so a stack gets a changelog of its own files instead of everything that happened in the repository. Paths are relative to the root of the repository. The cap counts the commits that pass the filter, and a nil filter returns the whole range.

func (CommitInfo) String added in v0.104.0

func (c CommitInfo) String() string

String renders "shortHash subject", the default when a template prints a commit directly.

type ExportOptions added in v0.120.0

type ExportOptions struct {
	// Log receives debug output. Optional; defaults to slog.Default().
	Log *slog.Logger

	// SubmoduleCacheDir enables submodule materialization when non-empty:
	// each resolved submodule URL gets its own dedicated mirror clone
	// under this directory, fetched once and reused across commits and
	// parent repositories that reference the same URL.
	// If empty, submodule (gitlink) entries are left as empty directories,
	// the same way `git archive` treats them.
	SubmoduleCacheDir string

	// SkipAbsoluteSymlinks omits links with absolute targets instead of failing
	// the export. Git includes use this to tolerate unrelated application links.
	// Other links that escape the export directory remain errors.
	SkipAbsoluteSymlinks bool

	// Credentials and network options, applied both to the top-level
	// repository (already fetched by the caller) and to any submodule
	// mirrors this export fetches. Credentials are resolved per submodule
	// URL, so a submodule on another host (or a gist) may fall back to
	// anonymous access.
	SSHPrivateKey           string
	SSHPrivateKeyPassphrase string
	AccessToken             string
	SkipTLSVerify           bool
	ProxyOptions            transport.ProxyOptions
	// Depth bounds how much history a submodule fetch pulls; 0 fetches
	// full history. It has no effect on the top-level repository, which
	// the caller has already fetched.
	Depth int
}

ExportOptions configures ExportTree, in particular its optional submodule materialization.

type GitHubAppConfig added in v0.88.0

type GitHubAppConfig struct {
	ID             string
	PrivateKey     string
	InstallationID int64
}

GitHubAppConfig contains credentials used to mint short-lived GitHub App installation tokens.

type MirrorCompactOptions added in v0.124.0

type MirrorCompactOptions struct {
	// Repository is the mirrored repository in "<host>/<owner>/<repo>" form,
	// reported along with the mirror's statistics.
	Repository string
	Mode       MirrorCompactionMode
	// MaxSizeBytes skips a repack of a mirror whose packfiles are larger, since
	// the encoder needs several times their size in memory. Zero or less
	// disables the limit. Copy mode ignores it.
	MaxSizeBytes int64
}

MirrorCompactOptions configures CompactMirror.

type MirrorCompaction added in v0.124.0

type MirrorCompaction struct {
	MirrorPackStats
	// SizeBytesBefore is the combined size of the packfiles before the
	// compaction, or -1 if it could not be measured.
	SizeBytesBefore int64
	// Objects is the number of objects in the new pack.
	Objects int
	// LooseObjects is the number of loose objects the new pack replaced.
	LooseObjects int
}

MirrorCompaction describes the outcome of a CompactMirror call.

func CompactMirror added in v0.124.0

func CompactMirror(ctx context.Context, log *slog.Logger, path string, opts MirrorCompactOptions) (MirrorCompaction, error)

CompactMirror consolidates the packfiles and loose objects of the bare mirror at path into a single pack, in the given mode. Unlike the automatic compaction after a fetch, it runs regardless of the pack count.

It skips the mirror instead of waiting when another operation holds its lock. Otherwise it holds the mirror's exclusive lock until it is done, so fetches and deploys of the repository wait for it. Once the context is cancelled, a repack stops and keeps the existing packs; a copy runs to completion, since it is bounded by disk throughput.

The statistics are also reported to the MirrorPackObserver. A skipped mirror is not an error.

type MirrorCompactionMode added in v0.124.0

type MirrorCompactionMode string

MirrorCompactionMode selects how a mirror's packfiles are consolidated.

const (
	// MirrorCompactionCopy concatenates the packs and keeps their compressed
	// entries, the way mirrors are compacted automatically after a fetch. It is
	// fast and needs little memory, but keeps every object's encoding, so the
	// new pack is about as large as the packs it replaces.
	MirrorCompactionCopy MirrorCompactionMode = "copy"
	// MirrorCompactionRepack re-encodes every object with a delta search across
	// the whole mirror. The new pack is considerably smaller, but the encoder
	// holds the objects in memory, several times the size of the packs, and
	// takes much longer.
	MirrorCompactionRepack MirrorCompactionMode = "repack"
)

func (MirrorCompactionMode) Valid added in v0.124.0

func (m MirrorCompactionMode) Valid() bool

Valid reports whether m is a known compaction mode.

type MirrorLockObserver added in v0.124.0

type MirrorLockObserver func(mode string, waited, held time.Duration)

MirrorLockObserver receives how long a bare mirror lock was waited for and held.

type MirrorPackObserver added in v0.124.0

type MirrorPackObserver func(MirrorPackStats)

MirrorPackObserver receives MirrorPackStats after every bare mirror clone or fetch, every read of a submodule mirror that skipped its fetch, and every CompactMirror call.

type MirrorPackStats added in v0.124.0

type MirrorPackStats struct {
	// Repository is the mirrored repository in "<host>/<owner>/<repo>" form.
	// Several mirrors can report the same repository, e.g. a deployed
	// repository that is also included or used as a submodule elsewhere.
	Repository string
	// Path is the mirror's directory, which tells such mirrors apart.
	Path string
	// PacksBefore and PacksAfter are -1 if the packfiles could not be listed,
	// e.g. because the mirror was in use.
	PacksBefore int
	PacksAfter  int
	// SizeBytes is the combined size of the packfiles left after any compaction,
	// or -1 if it could not be measured.
	SizeBytes int64
	// Mode is the compaction mode. It is empty when Result is.
	Mode MirrorCompactionMode
	// Result is empty when a fetch left the pack count within the compaction threshold.
	Result   string
	Duration time.Duration
}

MirrorPackStats describes a bare mirror's packfiles after a clone, fetch, read or CompactMirror call, and the compaction attempted, if any.

type RefSet added in v0.22.0

type RefSet struct {
	LocalRef   plumbing.ReferenceName
	RemoteRef  plumbing.ReferenceName
	RemoteHash plumbing.Hash
}

func GetReferenceSet added in v0.22.0

func GetReferenceSet(repo *git.Repository, ref string) (RefSet, error)

GetReferenceSet resolves ref to the local and remote plumbing.ReferenceName to use during checkout, along with the resolved remote commit hash.

Resolution order (first match wins):

  1. Commit SHA: returned directly; no reference store lookup is performed.
  2. For refs/-prefixed names: the exact name, then its remote-tracking counterpart.
  3. For short names: refs/heads/<ref>, refs/remotes/origin/<ref>, refs/tags/<ref>, then the bare name (which only resolves for uppercase pseudo-refs like HEAD).

Candidates whose name cannot be stored safely (see plumbing.ReferenceName.IsSafe) are skipped rather than queried, so a malformed ref yields ErrInvalidReference instead of a storage-layer error. Any other storage error is treated as a transient failure and returned immediately.

type ResolvedAuthConfig added in v0.88.0

type ResolvedAuthConfig struct {
	SSHPrivateKey           string
	SSHPrivateKeyPassphrase string
	GitAccessToken          string
	HTTPAuthUser            string // HTTPAuthUser is the Basic Auth username for token auth; empty defaults to DefaultHTTPAuthUser.
	GitHubApp               GitHubAppConfig
}

ResolvedAuthConfig contains the final credentials selected for a given repository URL.

func ResolveAuthConfig added in v0.88.0

func ResolveAuthConfig(url, privateKey, keyPassphrase, token string) ResolvedAuthConfig

ResolveAuthConfig resolves credentials for a repository URL using exact domain matches, then the most specific wildcard suffix, and finally global fallback credentials. GitHub App credentials are never resolved for gist URLs, because installation tokens cannot access gists; those fall back to an access token or anonymous access.

type ScopedAuthConfig added in v0.86.0

type ScopedAuthConfig struct {
	Domains                 []string `yaml:"domains"`
	GitAccessToken          string   `yaml:"git_access_token"`
	GitAccessTokenUser      string   `yaml:"git_access_token_user"` // GitAccessTokenUser is the username paired with GitAccessToken (e.g. a GitLab deploy token username). Empty defaults to DefaultHTTPAuthUser.
	SSHPrivateKey           string   `yaml:"ssh_private_key"`
	SSHPrivateKeyPassphrase string   `yaml:"ssh_private_key_passphrase"`
	GitHubAppID             string   `yaml:"github_app_id"`
	GitHubAppPrivateKey     string   `yaml:"github_app_private_key"`
	GitHubAppInstallationID int64    `yaml:"github_app_installation_id"`
}

ScopedAuthConfig maps credentials to one or more Git host/domain patterns. Patterns support exact hosts (e.g. github.com) and wildcard subdomains (e.g. *.example.com).

type TreeFS added in v0.118.0

type TreeFS struct {
	// contains filtered or unexported fields
}

TreeFS is a read-only fs.FS view over a single commit's tree, letting callers inspect a reference's contents without checking it out and mutating (or racing on) the shared working tree.

func NewTreeFS added in v0.118.0

func NewTreeFS(repo *git.Repository, ref string) (*TreeFS, error)

NewTreeFS resolves ref and returns a TreeFS backed by the commit's tree.

func NewTreeFSAtCommit added in v0.118.0

func NewTreeFSAtCommit(repo *git.Repository, commit plumbing.Hash) (*TreeFS, error)

NewTreeFSAtCommit returns a TreeFS backed by the tree of the given commit.

func (*TreeFS) Commit added in v0.118.0

func (t *TreeFS) Commit() plumbing.Hash

Commit returns the commit hash this TreeFS is rooted at.

func (*TreeFS) Open added in v0.118.0

func (t *TreeFS) Open(name string) (fs.File, error)

Open implements fs.FS. It is primarily used by fs.Stat/fs.WalkDir to stat the root; ReadDir and ReadFile are used for everything else.

func (*TreeFS) ReadDir added in v0.118.0

func (t *TreeFS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir implements fs.ReadDirFS.

func (*TreeFS) ReadFile added in v0.118.0

func (t *TreeFS) ReadFile(name string) ([]byte, error)

ReadFile implements fs.ReadFileFS.

func (*TreeFS) SubtreeHash added in v0.121.0

func (t *TreeFS) SubtreeHash(name string) (plumbing.Hash, error)

SubtreeHash returns the Git object identity of a directory in this view. This describes only the Git tree, not materialized submodule or decrypted content.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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