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
- Variables
- func HasConflictMarkers(data []byte) bool
- type Config
- type PendingLand
- type Rebasing
- type WorkingCopy
- func (wc *WorkingCopy) Apply(ctx context.Context, changes []object.Change) error
- func (wc *WorkingCopy) BaseManifest(ctx context.Context) (object.Manifest, error)
- func (wc *WorkingCopy) ReadBlob(ctx context.Context, h hash.Hash) ([]byte, error)
- func (wc *WorkingCopy) Save() error
- func (wc *WorkingCopy) Scan(ctx context.Context) (object.Manifest, error)
- func (wc *WorkingCopy) Snapshot(ctx context.Context) (hash.Hash, []object.Change, error)
- func (wc *WorkingCopy) Status(ctx context.Context) ([]object.Change, error)
Constants ¶
const Dir = ".vx"
Dir is the name of the metadata directory at the root of a working copy.
Variables ¶
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 ¶
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) BaseTreeHash ¶
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 Open ¶
func Open(root string) (*WorkingCopy, error)
Open opens the working copy rooted at root.
func (*WorkingCopy) Apply ¶
Apply writes changes to disk: deletes first (pruning emptied directories), then writes. The index is updated for every written file.
func (*WorkingCopy) BaseManifest ¶
BaseManifest returns the files of the base snapshot.
func (*WorkingCopy) Scan ¶
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.