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 PassedCheck
- 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) CheckDuration(command string) (int64, bool)
- func (wc *WorkingCopy) CheckLogPath(n int) string
- func (wc *WorkingCopy) PassedCheck(command, tree string) (PassedCheck, bool)
- func (wc *WorkingCopy) ReadBlob(ctx context.Context, h hash.Hash) ([]byte, error)
- func (wc *WorkingCopy) RecordCheckDuration(command string, ms int64) error
- func (wc *WorkingCopy) RecordPassedCheck(c PassedCheck) error
- func (wc *WorkingCopy) RemoveCheckLogs()
- 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"`
// Review is the open workspace's pending review: its last land waits
// for a person under a "human" landing policy of vx.toml.
Review string `json:"review,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 PassedCheck ¶ added in v0.5.0
type PassedCheck struct {
Command string `json:"command"`
Tree string `json:"tree"`
DurationMs int64 `json:"duration_ms"`
Notes string `json:"notes,omitempty"`
At time.Time `json:"at"`
}
PassedCheck is a vx land --run command that passed on exactly the files of Tree (the working copy snapshot, ignored files excluded).
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.
// Regenerated are the generated ones vx regenerated with their
// vx.toml command; Generated still need it.
Conflicts []string `json:"conflicts,omitempty"`
Generated []string `json:"generated,omitempty"`
Regenerated []string `json:"regenerated,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) CheckDuration ¶ added in v0.7.0
func (wc *WorkingCopy) CheckDuration(command string) (int64, bool)
CheckDuration is how long command took when it last ran here.
func (*WorkingCopy) CheckLogPath ¶ added in v0.5.0
func (wc *WorkingCopy) CheckLogPath(n int) string
CheckLogPath is where vx land --run keeps the full output of its nth command (1-based) of the last run.
func (*WorkingCopy) PassedCheck ¶ added in v0.5.0
func (wc *WorkingCopy) PassedCheck(command, tree string) (PassedCheck, bool)
PassedCheck returns the remembered passing run of command on tree.
func (*WorkingCopy) RecordCheckDuration ¶ added in v0.7.0
func (wc *WorkingCopy) RecordCheckDuration(command string, ms int64) error
RecordCheckDuration remembers how long command took, passed or failed.
func (*WorkingCopy) RecordPassedCheck ¶ added in v0.5.0
func (wc *WorkingCopy) RecordPassedCheck(c PassedCheck) error
RecordPassedCheck remembers that c.Command passed on c.Tree.
func (*WorkingCopy) RemoveCheckLogs ¶ added in v0.5.0
func (wc *WorkingCopy) RemoveCheckLogs()
RemoveCheckLogs deletes the check logs of an earlier run.
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.