checkout

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package checkout gets the repository under review onto disk. Three modes (managed cache clone, user-supplied path, structured git root) all converge on one invariant: the review runs in a detached git worktree at the MR head SHA, never in a user's working tree.

Index

Constants

View Source
const AskpassTokenEnv = "GITLAB_REVIEWER_ASKPASS_TOKEN" //nolint:gosec // env var name, not a credential

AskpassTokenEnv carries the GitLab token to the inline git credential helper, scoped to git subprocesses only.

Variables

This section is empty.

Functions

func LocalRepoDir added in v1.19.0

func LocalRepoDir(cfg config.Checkout, baseURL, projectPath string) (string, bool)

LocalRepoDir resolves the local clone the checkout config points at for projectPath — the user's own working tree in path and root modes. It reports false in clone mode or when the directory does not exist. Used to read repo-shipped review agents straight from disk, which covers definitions deliberately kept untracked (e.g. via .git/info/exclude); unlike Manager.Ensure it never clones, fetches, or validates remotes.

Types

type Checkout

type Checkout struct {
	// Path of the detached worktree at the MR head SHA.
	Path string
	// contains filtered or unexported fields
}

Checkout is a ready review worktree. Close removes it (unless the user asked to keep worktrees).

func (*Checkout) Close

func (c *Checkout) Close(ctx context.Context) error

Close removes the worktree.

type CleanResult

type CleanResult struct {
	Removed    []string
	FreedBytes int64
}

CleanResult reports what CleanCache removed.

func CleanCache

func CleanCache(_ context.Context, cacheDir string, maxMB int, all bool) (*CleanResult, error)

CleanCache removes review worktrees and, when the clone cache exceeds maxMB (0 = no limit; all=true removes everything), evicts least-recently used clones until it fits.

type Manager

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

Manager prepares review worktrees.

func NewManager

func NewManager(cfg config.Checkout, baseURL, token string) (*Manager, error)

NewManager builds a Manager. baseURL is the GitLab instance URL; token may be empty when transport is ssh.

func (*Manager) Ensure

func (m *Manager) Ensure(ctx context.Context, mr gitlabx.MRDetail, progress func(string)) (*Checkout, error)

Ensure produces a worktree at the MR's head SHA, cloning or fetching as needed. progress receives human-readable status lines for the TUI.

func (*Manager) EvictIfNeeded

func (m *Manager) EvictIfNeeded(ctx context.Context) (*CleanResult, error)

EvictIfNeeded enforces the configured cache budget in the background after a checkout; errors are reported to the caller for logging only.

type RepoInfo

type RepoInfo struct {
	// Project is host/group/app derived from the cache layout.
	Project string
	Path    string
	Size    int64
	LastUse time.Time
}

RepoInfo describes one cached clone.

func ListCache

func ListCache(cacheDir string) ([]RepoInfo, error)

ListCache returns the cached clones under cacheDir/repos, largest first.

Jump to

Keyboard shortcuts

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