Artifact 1dd3fe6e096fd4910cb84985fe530bcae2e9d925ddc2c4b540703e5668e4000f:
- File
internal/checkout/status.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: 3568) [annotate] [blame] [check-ins using]
package checkout import ( "database/sql" "fmt" libfossil "github.com/danmestas/go-libfossil/internal/fsltype" ) // HasChanges returns true if the checkout has any modified, deleted, or renamed files. // This is a DB-only check that does NOT scan the filesystem. // Use ScanChanges first if you need to detect on-disk modifications. // // Panics if c is nil (TigerStyle precondition). func (c *Checkout) HasChanges() (bool, error) { if c == nil { panic("checkout.HasChanges: nil *Checkout") } // Get current checkout version rid, _, err := c.Version() if err != nil { return false, fmt.Errorf("checkout.HasChanges: %w", err) } // Check for any changed or deleted files var count int err = c.db.QueryRow(` SELECT count(*) FROM vfile WHERE (chnged > 0 OR deleted > 0) AND vid = ? `, int64(rid)).Scan(&count) if err != nil { return false, fmt.Errorf("checkout.HasChanges: query: %w", err) } return count > 0, nil } // VisitChanges iterates over all changed files in the checkout, calling fn for each. // If scan=true, calls ScanChanges(ScanHash) first to detect on-disk modifications. // Otherwise, only reports files marked as changed in the vfile table. // // The function classifies each changed file: // - deleted > 0 → ChangeRemoved // - rid == 0 → ChangeAdded (newly managed file, not yet committed) // - origname != "" → ChangeRenamed // - chnged > 0 → ChangeModified // // If fn returns a non-nil error, iteration stops and that error is returned. // // Panics if c is nil (TigerStyle precondition). func (c *Checkout) VisitChanges(vid libfossil.FslID, scan bool, fn ChangeVisitor) error { if c == nil { panic("checkout.VisitChanges: nil *Checkout") } // Scan filesystem if requested if scan { if err := c.ScanChanges(ScanHash); err != nil { return fmt.Errorf("checkout.VisitChanges: %w", err) } } // Query all changed/deleted/renamed files rows, err := c.db.Query(` SELECT id, pathname, CAST(chnged AS INTEGER), CAST(deleted AS INTEGER), CAST(isexe AS INTEGER), CAST(islink AS INTEGER), origname, rid FROM vfile WHERE vid = ? AND (chnged > 0 OR deleted > 0 OR origname IS NOT NULL) `, int64(vid)) if err != nil { return fmt.Errorf("checkout.VisitChanges: query: %w", err) } defer rows.Close() // Iterate over each changed file for rows.Next() { var id, chnged, deleted, isexe, islink, rid int64 var pathname string var origname sql.NullString if err := rows.Scan( &id, &pathname, &chnged, &deleted, &isexe, &islink, &origname, &rid, ); err != nil { return fmt.Errorf("checkout.VisitChanges: scan: %w", err) } // Determine change type (priority order: deleted > added > renamed > modified) var changeType FileChange if deleted > 0 { changeType = ChangeRemoved } else if rid == 0 { changeType = ChangeAdded } else if origname.Valid && origname.String != "" { changeType = ChangeRenamed } else if chnged > 0 { changeType = ChangeModified } else { // Should not reach here given WHERE clause, but handle gracefully changeType = ChangeNone } // Build change entry entry := ChangeEntry{ Name: pathname, Change: changeType, VFileID: libfossil.FslID(id), IsExec: isexe != 0, IsLink: islink != 0, OrigName: origname.String, } // Call visitor function if err := fn(entry); err != nil { return fmt.Errorf("checkout.VisitChanges: visitor for %s: %w", pathname, err) } } if err := rows.Err(); err != nil { return fmt.Errorf("checkout.VisitChanges: iterate: %w", err) } return nil }