mirror

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mirror implements the bare-clone object store shared across GitRepository fetches. One bare mirror per upstream URL is kept warm across runs; per-(URL, ref) cache slots materialize their worktrees from it without re-cloning on every reconcile.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProxyOptions added in v0.4.6

func ProxyOptions(proxy *source.ProxyConfig) transport.ProxyOptions

ProxyOptions converts a nullable ProxyConfig into go-git's inline struct so every call site doesn't repeat the nil guard.

Types

type Cache

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

Cache holds one bare clone per unique upstream URL. The mirror is the persistent object store that incremental Fetches update; the per-(URL, ref) cache slots materialize their worktrees from it without re-cloning across runs or across refs of the same repo. Cache instances sharing a Layout serialize mirror updates through per-URL filesystem locks.

Construct via New; pass to git.Fetcher.Mirrors. A nil Fetcher.Mirrors disables mirroring — the legacy PlainClone-into-slot path runs unchanged (used by tests and any caller that prefers the older behavior).

func New

func New(layout cacheroot.Layout) *Cache

New constructs a Cache backed by the supplied Layout. The git-mirrors subtree is created lazily on first OpenOrFetch.

func (*Cache) OpenOrFetch

func (m *Cache) OpenOrFetch(ctx context.Context, url string, auth transport.AuthMethod, proxy *source.ProxyConfig, plan FetchPlan) (*git.Repository, error)

OpenOrFetch returns the bare mirror repo for url, ensuring it carries up-to-date refs. First call for a URL runs a bare clone; subsequent calls incrementally Fetch. Holds process-local and file locks across the network operation so concurrent callers sharing a cache root serialize even when they use separate Cache instances.

type FetchPlan

type FetchPlan struct {
	RefSpecs []config.RefSpec
	Depth    int
}

FetchPlan narrows the mirror update to the refs needed by one GitRepository. An empty RefSpecs slice preserves the historical full mirror refresh.

Depth caps the clone/fetch history. 0 (the zero value) preserves the historical full clone. A positive depth maps to go-git's shallow CloneOptions.Depth / FetchOptions.Depth — only the tip commit's tree is what the worktree materialization needs, so depth=1 is sufficient for tag/branch/HEAD refs. The fetcher gates this off for commit-pinned refs (see git.effectiveDepth).

Jump to

Keyboard shortcuts

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