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 ¶
This section is empty.
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 ¶
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 ¶
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).