Artifact e07d69067cf9420f3222bd7b13db2f2ac583d519651346753c08a0e559c4b8cd:
- File
repo_checkout_test.go
— part of check-in
[6273a0750d]
at
2026-07-22 23:03:24
on branch trunk
— fix: correct go.mod module path to go-libfossil (#76) (#117)
* fix: correct go.mod module path to go-libfossil (#76)
The module directive still declared github.com/danmestas/libfossil after the repository was renamed to go-libfossil. pkg.go.dev/godoc scraping matches the declared module path against its hosting path, so the stale path broke SDK doc generation.
Rename the module path across all four in-repo modules (root, the two db/driver submodules, observer/otel, and docs/site) and every internal import, plus the release workflow, the doc-generation script, and the docs.
No tag has been published under the go-libfossil path yet, so the cross-module requires cannot resolve from the proxy. Add replace directives pointing the in-repo requires at their local directories so GOWORK=off builds and the CI matrix resolve without a published version. These replaces are ignored by downstream consumers and can be dropped once new-path tags are cut.
* Guard releases against replace directives; regenerate SDK docs
The go-libfossil rename bridges the in-repo modules with `replace` directives. Go refuses a main module that carries them, so a tag cut while they are present breaks `go install .../cmd/libfossil@<tag>` and every `@version` fetch of the driver submodules. Add a Release workflow step that fails the job before anything is published if any tracked go.mod still contains a replace directive, so the bridge is a CI-enforced TODO rather than a silent landmine. The step comment records what unblocks a release: re-tag the submodules with the corrected module paths, bump the root requires, then drop the replace blocks.
Regenerate the SDK reference docs. The previous pass only substituted URLs over the pre-existing generated files, leaving stale signatures (Repo.Timeline was still documented as taking LogOpts rather than TimelineOpts). Note that gomarkdoc must be run outside a git worktree — inside one it silently strips every source link.
Also reword the README rename note, which read as though the import path had not changed, and re-sort the ncruces require block. (user: [email protected], size: 4715) [annotate] [blame] [check-ins using]
package libfossil import ( "path/filepath" "testing" _ "github.com/danmestas/go-libfossil/internal/testdriver" ) func TestCommitAndAncestry(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "test.fossil") r, err := Create(path, CreateOpts{User: "test"}) if err != nil { t.Fatal(err) } defer r.Close() rid1, uuid, err := r.Commit(CommitOpts{ Files: []FileToCommit{ {Name: "hello.txt", Content: []byte("hello world\n")}, }, Comment: "initial commit", User: "test", }) if err != nil { t.Fatal(err) } if uuid == "" { t.Fatal("Commit returned empty UUID") } if len(uuid) != 40 && len(uuid) != 64 { t.Errorf("UUID length = %d, want 40 or 64", len(uuid)) } if rid1 <= 0 { t.Fatalf("Commit returned rid=%d, want > 0", rid1) } // Second commit to test the ancestry walk. rid2, uuid2, err := r.Commit(CommitOpts{ ParentID: rid1, Files: []FileToCommit{ {Name: "hello.txt", Content: []byte("hello world v2\n")}, }, Comment: "second commit", User: "test", }) if err != nil { t.Fatal(err) } entries, err := r.Ancestry(LogOpts{Start: rid2, Limit: 10}) if err != nil { t.Fatal(err) } if len(entries) < 2 { t.Fatalf("Ancestry returned %d entries, want >= 2", len(entries)) } if entries[0].UUID != uuid2 { t.Errorf("first entry UUID = %q, want %q", entries[0].UUID, uuid2) } if entries[0].Comment != "second commit" { t.Errorf("first entry Comment = %q, want %q", entries[0].Comment, "second commit") } if entries[1].UUID != uuid { t.Errorf("second entry UUID = %q, want %q", entries[1].UUID, uuid) } } // TestCommitPreservesParentFiles is the regression for #30: a child // commit that supplies only a subset of the parent's tracked files must // still produce a full-tree manifest. Before the fix, the child's // manifest contained only the supplied subset and a checkout at the // child's rev silently lost every file the caller did not re-supply. func TestCommitPreservesParentFiles(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "test.fossil") r, err := Create(path, CreateOpts{User: "test"}) if err != nil { t.Fatal(err) } defer r.Close() parentRID, _, err := r.Commit(CommitOpts{ Files: []FileToCommit{ {Name: "a.txt", Content: []byte("alpha\n")}, {Name: "b.txt", Content: []byte("bravo v1\n")}, {Name: "c.txt", Content: []byte("charlie\n")}, }, Comment: "parent: a, b, c", User: "test", }) if err != nil { t.Fatalf("parent commit: %v", err) } childRID, _, err := r.Commit(CommitOpts{ ParentID: parentRID, Files: []FileToCommit{ {Name: "b.txt", Content: []byte("bravo v2\n")}, }, Comment: "child: only b modified", User: "test", }) if err != nil { t.Fatalf("child commit: %v", err) } files, err := r.ListFiles(childRID) if err != nil { t.Fatalf("ListFiles(child): %v", err) } got := map[string]string{} for _, f := range files { got[f.Name] = f.UUID } if len(got) != 3 { t.Fatalf("child manifest has %d files, want 3 (a.txt, b.txt, c.txt); got %v", len(got), got) } for _, name := range []string{"a.txt", "b.txt", "c.txt"} { if _, ok := got[name]; !ok { t.Errorf("child manifest missing %q (file tracked at parent was dropped)", name) } } // a.txt and c.txt should keep the parent's blob UUIDs (untouched). parentFiles, err := r.ListFiles(parentRID) if err != nil { t.Fatalf("ListFiles(parent): %v", err) } parentUUIDs := map[string]string{} for _, f := range parentFiles { parentUUIDs[f.Name] = f.UUID } if got["a.txt"] != parentUUIDs["a.txt"] { t.Errorf("a.txt UUID changed across commits: parent=%s child=%s", parentUUIDs["a.txt"], got["a.txt"]) } if got["c.txt"] != parentUUIDs["c.txt"] { t.Errorf("c.txt UUID changed across commits: parent=%s child=%s", parentUUIDs["c.txt"], got["c.txt"]) } // b.txt should have a NEW UUID — caller supplied new content. if got["b.txt"] == parentUUIDs["b.txt"] { t.Errorf("b.txt UUID unchanged despite new content: %s", got["b.txt"]) } } func TestListFiles(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "test.fossil") r, err := Create(path, CreateOpts{User: "test"}) if err != nil { t.Fatal(err) } defer r.Close() rid, _, err := r.Commit(CommitOpts{ Files: []FileToCommit{ {Name: "a.txt", Content: []byte("aaa\n")}, {Name: "b.txt", Content: []byte("bbb\n")}, }, Comment: "two files", User: "test", }) if err != nil { t.Fatal(err) } files, err := r.ListFiles(rid) if err != nil { t.Fatal(err) } if len(files) != 2 { t.Fatalf("ListFiles returned %d files, want 2", len(files)) } if files[0].Name != "a.txt" || files[1].Name != "b.txt" { t.Errorf("files = %v, want a.txt and b.txt", files) } }