Artifact 2c26e7bb41ef3d52a437cd52fe039e51218f51d5b95958e2eed929854f24cc0d:
- File
internal/manifest/log.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: 4083) [annotate] [blame] [check-ins using]
package manifest import ( "database/sql" "fmt" "time" "github.com/danmestas/go-libfossil/db" libfossil "github.com/danmestas/go-libfossil/internal/fsltype" "github.com/danmestas/go-libfossil/internal/repo" ) type LogOpts struct { Start libfossil.FslID Limit int } // LogEntry represents a single event as returned by Log (the ancestry // walk). It carries no pagination cursor: Log paginates by Start/Limit, // not by cursor, so there is nothing valid to put in one. See // TimelineEntry, Timeline's result type, for the cursor-carrying // counterpart. type LogEntry struct { RID libfossil.FslID UUID string Comment string User string Time time.Time Kind libfossil.EventKind Parents []string } // maxAncestryDepth bounds the first-parent walk in Log so that a cyclic or // otherwise corrupt plink table cannot hang the process (TigerStyle: every // loop needs an explicit, defensible bound). It is a var rather than a // const so tests can shrink it to exercise the bound deterministically // without walking a million rows. No real fossil repository's primary-parent // chain approaches this depth. var maxAncestryDepth = 1_000_000 func Log(r *repo.Repo, opts LogOpts) ([]LogEntry, error) { if r == nil { panic("manifest.Log: r must not be nil") } if opts.Start <= 0 { return nil, fmt.Errorf("manifest.Log: invalid start rid %d", opts.Start) } var entries []LogEntry current := opts.Start for depth := 0; ; depth++ { if depth >= maxAncestryDepth { return nil, fmt.Errorf("manifest.Log: exceeded max ancestry depth %d starting at rid=%d (possible plink cycle)", maxAncestryDepth, opts.Start) } if opts.Limit > 0 && len(entries) >= opts.Limit { break } // event.user and event.comment are nullable in fossil's schema: the // U-card and C-card are optional on a check-in manifest (the only // required cards are "D" and "Z"). A NULL here is valid data, not // malformed input, so scan through sql.NullString and let its zero // value ("") stand in for "no value recorded" — the same substitution // fossil itself makes when reading these columns. var uuid string var user, comment sql.NullString var mtimeScanned any err := r.DB().QueryRow( "SELECT b.uuid, e.user, e.comment, e.mtime FROM blob b JOIN event e ON e.objid=b.rid WHERE b.rid=?", current, ).Scan(&uuid, &user, &comment, &mtimeScanned) if err != nil { return nil, fmt.Errorf("manifest.Log: rid=%d: %w", current, err) } // mtime is a julianday float. modernc returns float64; // ncruces returns time.Time for DATETIME/TIMESTAMP columns. Handle both. mtime, ok := db.ScanJulianDay(mtimeScanned) if !ok { return nil, fmt.Errorf("manifest.Log: rid=%d: unexpected mtime type %T", current, mtimeScanned) } entries = append(entries, LogEntry{ RID: current, UUID: uuid, Comment: comment.String, User: user.String, Time: libfossil.JulianToTime(mtime), Kind: libfossil.EventKindCheckin, Parents: parentUUIDs(r, current), }) var parentRid int64 if err := r.DB().QueryRow( "SELECT pid FROM plink WHERE cid=? AND isprim=1", current, ).Scan(&parentRid); err != nil { break } current = libfossil.FslID(parentRid) } return entries, nil } // parentUUIDs returns the UUIDs of cid's parents (primary parent first), // via the plink table. Best-effort: a query or scan failure yields a nil // (empty) result rather than aborting the caller's walk or enumeration — // matching the original manifest.Log behavior this was extracted from. // Shared by Log (ancestry walk) and Timeline (enumeration) so entry // construction is not duplicated between the two query paths. func parentUUIDs(r *repo.Repo, cid libfossil.FslID) []string { var parents []string rows, err := r.DB().Query( "SELECT b.uuid FROM plink p JOIN blob b ON b.rid=p.pid WHERE p.cid=? ORDER BY p.isprim DESC", cid, ) if err != nil { return parents } defer rows.Close() for rows.Next() { var puuid string if err := rows.Scan(&puuid); err != nil { continue } parents = append(parents, puuid) } return parents }