gitcache

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 14 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuditFileConfig

func AuditFileConfig(ctx context.Context, baseURL string) ([]string, error)

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

func New(dir, baseURL, token string, logger *slog.Logger) (*Manager, error)

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

func (m *Manager) Bundle(ctx context.Context, repoSlug string, w io.Writer) error

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

func (m *Manager) ContainerPath(repoSlug, os string) string

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

func (m *Manager) EnsureMirror(ctx context.Context, repoSlug string) (string, error)

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

func (m *Manager) MirrorPath(repoSlug string) string

MirrorPath returns the host path of a repo's bare mirror.

func (*Manager) Sweep

func (m *Manager) Sweep(ctx context.Context, maxAge time.Duration) (int, error)

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.

Jump to

Keyboard shortcuts

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