Help us shape the future of Go! Take the 2026 Go Developer Survey

acquire

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package acquire manages explicit, native-git clone/fetch operations into a local cache. It creates a clean checkout (worktree) for indexing and records provenance metadata without executing repository-controlled code.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidRepo indicates the owner/repo reference is malformed.
	ErrInvalidRepo = errors.New("invalid repository reference")

	// ErrInvalidRemote indicates the remote URL is not a supported Git transport.
	ErrInvalidRemote = errors.New("invalid remote URL")

	// ErrRemoteMismatch indicates an existing cache has a different remote URL.
	ErrRemoteMismatch = errors.New("existing cache remote does not match requested remote")

	// ErrNoCommit indicates the repository has no resolvable default branch.
	ErrNoCommit = errors.New("no commit found")

	// ErrNotBare indicates a cache path exists but is not a bare repository.
	ErrNotBare = errors.New("cache is not a bare repository")
)

Functions

This section is empty.

Types

type Acquisition

type Acquisition struct {
	Owner         string    `json:"owner"`
	Repo          string    `json:"repo"`
	Remote        string    `json:"remote"`
	DefaultBranch string    `json:"default_branch"`
	CommitSHA     string    `json:"commit_sha"`
	AcquiredAt    time.Time `json:"acquired_at"`
	// CachePath is the bare mirror managed by the acquisition manager.
	CachePath string `json:"cache_path"`
	// Path is a clean checkout (worktree) at CommitSHA. The caller should
	// call Manager.Cleanup when done.
	Path string `json:"path,omitempty"`
}

Acquisition records the result of an explicit clone or fetch.

type Manager

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

Manager manages bare repository caches and transient clean checkouts.

func NewManager

func NewManager(root string, runner runner) (*Manager, error)

NewManager creates a manager rooted at root. A nil runner uses the local git executable.

func (*Manager) Acquire

func (m *Manager) Acquire(ctx context.Context, owner, repo, remote string) (*Acquisition, error)

Acquire clones or fetches a repository into the managed cache and creates a clean checkout at the resolved default branch. The returned Acquisition records remote URL, default branch, commit SHA, and acquisition time.

func (*Manager) Cleanup

func (m *Manager) Cleanup(ctx context.Context, acq *Acquisition) error

Cleanup removes the transient checkout created by Acquire.

Jump to

Keyboard shortcuts

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