Artifact 358097f926fbe530be8d630462fd1f8e6bd315ea0b595b58b80669595c810db9:
- File
cli/repo_open.go
— part of check-in
[318f46de9e]
at
2026-10-21 11:48:51
on branch feat/submanifest-reader
— feat(checkout): verify a present R card on extract, as fossil's checkout
Extract now runs fossil's repo-cksum check after materializing: a present R card is compared with the aggregate over every file the manifest names, read from the store, so a sparse checkout over a dense store reaches the same verdict as a dense one, and a sparse store skips the check. Like fossil, a disagreement is a warning delivered through ExtractOpts.Warn and never fails the extract; repo-cksum off disables it. The conformance case builds its repository with fossil and checks fossil warns exactly where go-libfossil does. Clears the SC-4.3-4 scope note. (user: [email protected], size: 1858) [annotate] [blame] [check-ins using] [more...]
package cli import ( "fmt" "os" "path/filepath" libfossil "github.com/danmestas/go-libfossil" ) // RepoOpenCmd opens a checkout in a directory, creating the .fslckout database. type RepoOpenCmd struct { Dir string `arg:"" optional:"" help:"Checkout directory (default: current dir)" default:"."` Cone []string `name:"cone" help:"Make a sparse checkout: materialize and track only this path's subtree (repeatable)"` ConeNot []string `name:"cone-not" help:"Exclude this path's subtree from an enclosing --cone (repeatable)"` } func (c *RepoOpenCmd) Run(g *Globals) error { if g.Repo == "" { return fmt.Errorf("repository required (use -R <path>)") } absRepo, err := filepath.Abs(g.Repo) if err != nil { return err } ckoutPath := filepath.Join(c.Dir, ".fslckout") if _, err := os.Stat(ckoutPath); err == nil { return fmt.Errorf("checkout already exists: %s", ckoutPath) } cone, err := coneFlags(c.Cone, c.ConeNot) if err != nil { return err } g.Repo = absRepo r, err := g.OpenRepo() if err != nil { return err } defer r.Close() co, err := r.CreateCheckout(c.Dir, libfossil.CheckoutCreateOpts{Cone: cone}) if err != nil { os.Remove(ckoutPath) return err } defer co.Close() tipRid, tipHash, err := co.Version() if err != nil { os.Remove(ckoutPath) return err } fmt.Printf("opened checkout in %s (repo: %s)\n", c.Dir, absRepo) if tipRid > 0 && cone != nil { // A sparse open materializes the cone: what it covers is the point. warn := func(message string) { fmt.Printf("WARNING: %s\n", message) } if err := co.Extract(tipRid, libfossil.ExtractOpts{Warn: warn}); err != nil { return err } fmt.Printf("sparse cone: %s\n", cone) } if tipRid > 0 { fmt.Printf("checked out version %s\n", tipHash[:10]) } else { fmt.Println("empty repository -- no checkins yet") } return nil }