workcopy

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 17 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 workcopy manages a vx working copy on disk: the files, the .vx directory with its config, a local object cache and a stat index that avoids rehashing unchanged files.

Index

Constants

View Source
const Dir = ".vx"

Dir is the name of the metadata directory at the root of a working copy.

Variables

View Source
var ErrNotFound = errors.New("not inside a vx working copy (no .vx directory found); use `vx clone` first")

ErrNotFound means no working copy contains the directory.

Functions

func HasConflictMarkers

func HasConflictMarkers(data []byte) bool

HasConflictMarkers reports whether text contains unresolved conflict markers written by vx sync.

Types

type Config

type Config struct {
	Repo   string `json:"repo"`
	Effort string `json:"effort"`
	// Base is the changeset the files are based on, and BaseTree its tree.
	Base     string `json:"base"`
	BaseTree string `json:"base_tree"`
	// Workspace is the open workspace, if any.
	Workspace string `json:"workspace,omitempty"`
	Intent    string `json:"intent,omitempty"`
	ChangeID  string `json:"change_id,omitempty"`
	// PendingLand holds the evidence flags of a land that did not finish
	// (conflicts, failed checks), so a bare `vx land` can run it again.
	PendingLand *PendingLand `json:"pending_land,omitempty"`
	// BoardSeenAt is when this working copy was last shown the effort's
	// board (RFC 3339, the server time of the newest note it was shown), so
	// vx sync, land and status show only notes that arrived after it.
	BoardSeenAt string `json:"board_seen_at,omitempty"`
	// Rebase is set while this working copy holds the conflicts of a
	// stopped effort rebase (vx effort rebase). Base and BaseTree then point
	// at the rebased chain so far, not at the effort head.
	Rebase *Rebasing `json:"rebase,omitempty"`
}

Config is what a working copy knows about where it came from.

func (Config) BaseHash

func (c Config) BaseHash() hash.Hash

BaseHash returns the parsed base changeset.

func (Config) BaseTreeHash

func (c Config) BaseTreeHash() hash.Hash

BaseTreeHash returns the parsed base tree.

type PendingLand added in v0.2.0

type PendingLand struct {
	Workspace       string   `json:"workspace"`
	Runs            []string `json:"runs,omitempty"`
	Checks          []string `json:"checks,omitempty"`
	NewTests        []string `json:"new_tests,omitempty"`
	DependsOn       []string `json:"depends_on,omitempty"`
	AllowFailing    bool     `json:"allow_failing,omitempty"`
	AllowUnverified bool     `json:"allow_unverified,omitempty"`
}

PendingLand is the evidence a `vx land` asked for, kept until a land in the same workspace succeeds.

func (PendingLand) Command added in v0.2.0

func (p PendingLand) Command() string

Command is the vx land command line the pending land stands for.

type Rebasing added in v0.2.0

type Rebasing struct {
	StoppedAt  string `json:"stopped_at"` // old-chain changeset being replayed
	ChangeID   string `json:"change_id"`
	Intent     string `json:"intent"`
	OntoBranch string `json:"onto_branch"`
	OntoGitSHA string `json:"onto_git_sha,omitempty"`
	// Conflicts and Generated (a subset) are the paths that conflicted.
	Conflicts []string `json:"conflicts,omitempty"`
	Generated []string `json:"generated,omitempty"`
	// SavedBase and SavedBaseTree are where the files were before the
	// rebase wrote its conflicts here; --abort puts them back.
	SavedBase     string `json:"saved_base"`
	SavedBaseTree string `json:"saved_base_tree"`
}

Rebasing is a stopped effort rebase whose conflicts are written into the working copy, waiting for vx effort rebase --continue or --abort.

type WorkingCopy

type WorkingCopy struct {
	Root    string
	Config  Config
	Objects blob.Store
	// contains filtered or unexported fields
}

WorkingCopy is an opened working copy.

func Create

func Create(root string, cfg Config) (*WorkingCopy, error)

Create makes a new working copy at root, which must be empty or missing.

func Find

func Find(dir string) (*WorkingCopy, error)

Find opens the working copy containing dir.

func Open

func Open(root string) (*WorkingCopy, error)

Open opens the working copy rooted at root.

func (*WorkingCopy) Apply

func (wc *WorkingCopy) Apply(ctx context.Context, changes []object.Change) error

Apply writes changes to disk: deletes first (pruning emptied directories), then writes. The index is updated for every written file.

func (*WorkingCopy) BaseManifest

func (wc *WorkingCopy) BaseManifest(ctx context.Context) (object.Manifest, error)

BaseManifest returns the files of the base snapshot.

func (*WorkingCopy) ReadBlob

func (wc *WorkingCopy) ReadBlob(ctx context.Context, h hash.Hash) ([]byte, error)

ReadFile returns the content of a blob from the local store.

func (*WorkingCopy) Save

func (wc *WorkingCopy) Save() error

Save writes the config and index.

func (*WorkingCopy) Scan

func (wc *WorkingCopy) Scan(ctx context.Context) (object.Manifest, error)

Scan walks the working copy and returns its files. Files whose size and modification time match the index are not read again. Contents of new or changed files are stored in the local object store as a side effect, so a snapshot never has to read them twice.

func (*WorkingCopy) Snapshot

func (wc *WorkingCopy) Snapshot(ctx context.Context) (hash.Hash, []object.Change, error)

Snapshot stores the current files as a tree and returns it with the changes relative to the base. File contents are already in the local store after Scan; only the changed directories' trees are written.

func (*WorkingCopy) Status

func (wc *WorkingCopy) Status(ctx context.Context) ([]object.Change, error)

Status lists the local changes relative to the base snapshot.

Jump to

Keyboard shortcuts

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