Artifact f90bfa2e8e515168923e4a4c44770788e6751cef535135d68dff8cc4b7b18b74:
- File
cli/repo_status_test.go
— part of check-in
[ea23bc8a41]
at
2026-10-21 16:41:13
on branch feat/submanifest-reader
— fix(cli): repo status reports the checkout's changes
Run from inside a checkout with the default --dir ".", repo status reported every tracked file MISSING: filepath.WalkDir's root entry is named ".", and the hidden-directory rule skipped it, and with it the whole tree. The command also compared the disk with tip rather than the checked-out version, so a checkout of an older version read as edited.
The command now opens the checkout and prints Checkout.Status, which classifies changes against the checkout's version as fossil's changes command does, cone included, with fossil's labels. Untracked files are no longer listed; fossil status leaves those to fossil extras. (user: [email protected], size: 2187) [annotate] [blame] [check-ins using] [more...]
package cli_test import ( "os" "path/filepath" "testing" libfossil "github.com/danmestas/go-libfossil" "github.com/danmestas/go-libfossil/cli" ) // status reports a checkout's changes against the version it has checked out, // from inside the checkout with the default --dir ".". Two faults it had: // the walk skipped its own root, named ".", as a hidden directory, so every // file read MISSING; and it compared the disk with tip, so a checkout of an // older version read as edited. Method: commit two versions, check out the // first, run status clean, then edit a file and run it again. func TestRepoStatusReportsCheckoutChanges(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "repo.fossil") r, err := libfossil.Create(path, libfossil.CreateOpts{User: "u"}) if err != nil { t.Fatal(err) } first, _, err := r.Commit(libfossil.CommitOpts{User: "u", Comment: "one", Files: []libfossil.FileToCommit{ {Name: "a.txt", Content: []byte("a\n")}, {Name: "src/b.txt", Content: []byte("b\n")}, }}) if err != nil { t.Fatal(err) } if _, _, err := r.Commit(libfossil.CommitOpts{User: "u", Comment: "two", ParentID: first, Files: []libfossil.FileToCommit{ {Name: "a.txt", Content: []byte("a\n")}, {Name: "src/b.txt", Content: []byte("b at tip\n")}, }}); err != nil { t.Fatal(err) } work := filepath.Join(dir, "work") co, err := r.CreateCheckout(work, libfossil.CheckoutCreateOpts{}) if err != nil { t.Fatal(err) } if err := co.Extract(first, libfossil.ExtractOpts{}); err != nil { t.Fatal(err) } if err := co.Close(); err != nil { t.Fatal(err) } if err := r.Close(); err != nil { t.Fatal(err) } t.Chdir(work) status := func() string { return captureStdout(t, func() error { return (&cli.RepoStatusCmd{Dir: "."}).Run(&cli.Globals{Repo: path}) }) } if out := status(); out != "" { t.Fatalf("status of a clean checkout of the first version = %q, want none", out) } if err := os.WriteFile(filepath.Join(work, "src", "b.txt"), []byte("changed\n"), 0o644); err != nil { t.Fatal(err) } if out, want := status(), "EDITED src/b.txt\n"; out != want { t.Fatalf("status after an edit = %q, want %q", out, want) } }