Documentation
¶
Overview ¶
Package gitcache maintains host-resident bare git mirrors so ephemeral runners can seed a workspace from a local clone (git alternates / --reference) instead of full-cloning from GitHub every job. The heavy object history comes from the local mirror; the per-job checkout still fetches the tip delta from GitHub with its own token, so private-repo auth is unaffected.
Index ¶
- func AuditFileConfig(ctx context.Context, baseURL string) ([]string, error)
- type Manager
- func (m *Manager) Bundle(ctx context.Context, repoSlug string, w io.Writer) error
- func (m *Manager) ContainerPath(repoSlug, os string) string
- func (m *Manager) EnsureMirror(ctx context.Context, repoSlug string) (string, error)
- func (m *Manager) MirrorPath(repoSlug string) string
- func (m *Manager) Sweep(ctx context.Context, maxAge time.Duration) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuditFileConfig ¶
AuditFileConfig reports git configuration read from files (system and global config, including GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEM overrides) that would affect authenticated mirror operations. The subprocess environment is filtered, but file config is the operator's own machine state and still applies to every git call, so a rewrite of the GitHub base URL or a stored Authorization header there deserves a warning before jobs depend on the cache. Each returned string is one human-readable warning.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns the mirror directory and serializes updates per repo.
func New ¶
New creates a Manager rooted at dir. baseURL is the GitHub base (github.com or GHES); token (optional) authenticates mirror fetches for private repos.
func (*Manager) Bundle ¶
Bundle ensures the mirror is current, then writes a git bundle of all refs to w. A runner job-started hook clones the workspace from this bundle (bulk objects, no GitHub bandwidth) and re-points origin at GitHub so checkout fetches only the delta. The bundle carries objects only — no credentials.
func (*Manager) ContainerPath ¶
ContainerPath returns the in-container mount target for a repo's mirror, in the path style of the target container OS ("windows" => C:\gitcache\..., else /gitcache/...).
func (*Manager) EnsureMirror ¶
EnsureMirror clones the repo as a bare mirror on first use, or fetches updates if it already exists. Concurrent calls for the same repo are serialized.
func (*Manager) MirrorPath ¶
MirrorPath returns the host path of a repo's bare mirror.
func (*Manager) Sweep ¶
Sweep removes bare mirrors not used within maxAge. maxAge <= 0 disables it. Only mirrors carrying this manager's last-used marker are candidates: the cache root may be shared with bare repositories the operator keeps for other reasons, and those are never deleted. Returns the number of mirrors removed.