mirror

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

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.

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 the per-URL lock across the network operation so two concurrent callers serialize.

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