Artifact 898d24cf6a4bf2e93cece6c4af14fe2bcb45a9724eda7f50d2e66d2fe2177c21:
- File
cli/repo_branch.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: 4834) [annotate] [blame] [check-ins using]
package cli import ( "fmt" "time" libfossil "github.com/danmestas/go-libfossil" "github.com/danmestas/go-libfossil/internal/content" "github.com/danmestas/go-libfossil/internal/fsltype" "github.com/danmestas/go-libfossil/internal/tag" ) // RepoBranchCmd groups branch operations. type RepoBranchCmd struct { Ls RepoBranchLsCmd `cmd:"" help:"List branches"` New RepoBranchNewCmd `cmd:"" help:"Create new branch"` Close RepoBranchCloseCmd `cmd:"" help:"Close a branch"` } // RepoBranchLsCmd lists branches. type RepoBranchLsCmd struct { Closed bool `help:"Show only closed branches"` All bool `help:"Show all branches (open and closed)"` } func (c *RepoBranchLsCmd) Run(g *Globals) error { r, err := g.OpenRepo() if err != nil { return err } defer r.Close() db := r.Inner().DB() var filter string switch { case c.All: // no filter case c.Closed: filter = " AND tx.tagtype = 0" default: filter = " AND tx.tagtype > 0" } query := ` SELECT DISTINCT substr(t.tagname, 5) AS branch, b.uuid, datetime(e.mtime), e.user FROM tag t JOIN tagxref tx ON tx.tagid = t.tagid JOIN blob b ON b.rid = tx.rid LEFT JOIN event e ON e.objid = tx.rid WHERE t.tagname LIKE 'sym-%'` + filter + ` ORDER BY e.mtime DESC` rows, err := db.Query(query) if err != nil { return err } defer rows.Close() count := 0 for rows.Next() { var branch, uuid string var mtime, user *string if err := rows.Scan(&branch, &uuid, &mtime, &user); err != nil { return err } short := uuid if len(short) > 10 { short = short[:10] } mt := "" if mtime != nil { mt = *mtime } u := "" if user != nil { u = *user } fmt.Printf("%-20s %s %s %s\n", branch, short, mt, u) count++ } if err := rows.Err(); err != nil { return err } if count == 0 { fmt.Println("no branches found") } return nil } // RepoBranchNewCmd creates a new branch. type RepoBranchNewCmd struct { Name string `arg:"" help:"Branch name"` From string `help:"Parent version (default: tip)"` Message string `short:"m" help:"Checkin comment"` User string `help:"Checkin user (default: OS username)"` } func (c *RepoBranchNewCmd) Run(g *Globals) error { r, err := g.OpenRepo() if err != nil { return err } defer r.Close() parentRid, err := resolveRID(r, c.From) if err != nil { return fmt.Errorf("resolving parent: %w", err) } entries, err := r.ListFiles(parentRid) if err != nil { return fmt.Errorf("listing parent files: %w", err) } db := r.Inner().DB() files := make([]libfossil.FileToCommit, 0, len(entries)) for _, e := range entries { fileRid, ok := content.AvailableByUUID(db, e.UUID) if !ok { return fmt.Errorf("blob %s not found for %s", e.UUID, e.Name) } data, err := content.Expand(db, fileRid) if err != nil { return fmt.Errorf("expanding %s: %w", e.Name, err) } files = append(files, libfossil.FileToCommit{ Name: e.Name, Content: data, Perm: e.Perm, }) } user := c.User if user == "" { user = currentUser() } comment := c.Message if comment == "" { comment = "Create branch " + c.Name } rid, uuid, err := r.Commit(libfossil.CommitOpts{ Files: files, Comment: comment, User: user, ParentID: parentRid, Time: time.Now().UTC(), Tags: []libfossil.TagSpec{ {Name: "branch", Value: c.Name}, {Name: "sym-" + c.Name}, }, }) if err != nil { return err } short := uuid if len(short) > 10 { short = short[:10] } fmt.Printf("branch %s created at %s (rid=%d)\n", c.Name, short, rid) return nil } // RepoBranchCloseCmd closes a branch. type RepoBranchCloseCmd struct { Name string `arg:"" help:"Branch name to close"` User string `help:"User for control artifacts (default: OS username)"` } func (c *RepoBranchCloseCmd) Run(g *Globals) error { r, err := g.OpenRepo() if err != nil { return err } defer r.Close() db := r.Inner().DB() tagName := "sym-" + c.Name var tipRID int64 err = db.QueryRow(` SELECT tx.rid FROM tagxref tx JOIN tag t ON t.tagid = tx.tagid WHERE t.tagname = ? AND tx.tagtype > 0 ORDER BY tx.mtime DESC LIMIT 1`, tagName).Scan(&tipRID) if err != nil { return fmt.Errorf("branch %q not found or already closed", c.Name) } user := c.User if user == "" { user = currentUser() } inner := r.Inner() fslID := fsltype.FslID(tipRID) if _, err := tag.AddTag(inner, tag.TagOpts{ TargetRID: fslID, TagName: tagName, TagType: tag.TagCancel, User: user, }); err != nil { return fmt.Errorf("cancelling branch tag: %w", err) } if _, err := tag.AddTag(inner, tag.TagOpts{ TargetRID: fslID, TagName: "closed", TagType: tag.TagSingleton, User: user, }); err != nil { return fmt.Errorf("adding closed tag: %w", err) } fmt.Printf("branch %s closed\n", c.Name) return nil }