Artifact a4a494916553c01e818938b3ddc82ac7c0ebff85bb0bc507c66f1300c063b6cf:
- File
cli/exit.go
— part of check-in
[beed361c03]
at
2026-10-19 20:17:37
on branch feat/cli-snapshot
— feat(cli): checkout-free snapshot, per-path log, cat --at and diff --json
repo snapshot commits one file's bytes onto trunk with no checkout, a no-op when they equal the tip. repo log --path lists the check-ins that changed a path, repo cat --at reads a file as a version holds it, and repo diff --json A B [PATH] diffs two versions. Exit 2 means not found. A snapshot re-checks the check-in stamp inside its write transaction and retries, so concurrent processes build one linear trunk.
Tracked in #451 (user: [email protected], size: 1208) [annotate] [blame] [check-ins using] [more...]
package cli import ( "errors" "fmt" libfossil "github.com/danmestas/go-libfossil" ) // Exit statuses the machine-facing commands (snapshot, log, cat --at, diff) // document and keep stable. Every other failure, including a usage error, is // ExitFailure. const ( ExitOK = 0 ExitFailure = 1 ExitNotFound = 2 // the version, path or history asked for does not exist ) // ExitError is a command failure that carries the process exit status it // maps to. The binary's main exits with Code after printing Err. type ExitError struct { Code int Err error } func (e *ExitError) Error() string { return e.Err.Error() } func (e *ExitError) Unwrap() error { return e.Err } // notFound marks err as an ExitNotFound failure. func notFound(err error) error { return &ExitError{Code: ExitNotFound, Err: err} } // resolveVersionExit is resolveRID with a version that does not exist // reported as ExitNotFound. func resolveVersionExit(r *libfossil.Repo, version string) (int64, error) { rid, err := resolveRID(r, version) if errors.Is(err, libfossil.ErrVersionNotFound) { return 0, notFound(err) } if err != nil { return 0, fmt.Errorf("resolving %q: %w", version, err) } return rid, nil }