beads/cmd/bd/preflight_versions.go
Julian Knutsen 555b01d789
fix(release): name the version-drift remedies that work (#7083)
Post-merge review follow-up to #5614.

#5614 replaced the shell checker's three-way drift remedy with a bare
"Run: scripts/update-versions.sh <canonical>" in both the Go checker
(status 1) and bd preflight's Version sync output, and the release-tag
pre-push hook kept answering status 1 with "Fix with:
scripts/update-versions.sh <version>". update-versions.sh derives the old
version from cmd/bd/version.go and anchors its substitutions on it, so
with version.go already at the canonical version that re-run rewrites
only the .githooks markers and uv.lock and leaves any other drifted file
as it was.

Restore the remedy as versioncheck.Report.MismatchRemedy, shared by the
checker and preflight:
- one file drifted: edit it to the expected value
- several drifted: set version.go to the previous version, then replay
  scripts/update-versions.sh <canonical>
- version.go is wrong: scripts/update-versions.sh <intended-version>

The hook's status-1 text now points at the checker output instead of
prescribing update-versions.sh; status 3 is unchanged. The text is sized
so one drifted file shows in full within preflight's 500-byte human
output, with the several-files case ahead of the version.go one.

Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR

Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 11:34:06 -07:00

69 lines
1.6 KiB
Go

package main
import (
"fmt"
"github.com/steveyegge/beads/internal/versioncheck"
)
func runBeadsVersionSyncCheck(root string) CheckResult {
return runBeadsVersionSyncCheckWithUV(
root,
versioncheck.CheckUVLockFreshness,
)
}
func runBeadsVersionSyncCheckWithUV(
root string,
checkUVLock versioncheck.UVLockChecker,
) CheckResult {
report, err := versioncheck.Check(root)
if err != nil {
output := err.Error()
if report.CanonicalVersion != "" {
output += "\n" + report.MismatchRemedy()
}
return CheckResult{
Name: "Version sync",
Passed: false,
Output: output,
Command: versioncheck.CommandDescription,
}
}
uvAvailable := false
if checkUVLock != nil {
var uvErr error
uvAvailable, uvErr = checkUVLock(root)
if uvAvailable && uvErr != nil {
return CheckResult{
Name: "Version sync",
Passed: false,
Output: "MCP uv.lock: stale — run: uv lock --directory integrations/beads-mcp",
Command: versioncheck.CommandDescription,
}
}
}
output := report.SuccessMessage()
if uvAvailable {
output += "\nMCP uv.lock: fresh (uv lock --check)"
}
return CheckResult{
Name: "Version sync",
Passed: true,
Output: output,
Command: versioncheck.CommandDescription,
}
}
func resolveBeadsVersionRoot(start string) (string, bool, CheckResult) {
root, found, err := versioncheck.FindRoot(start)
if err == nil {
return root, found, CheckResult{}
}
return "", false, CheckResult{
Name: "Version sync",
Passed: false,
Output: fmt.Sprintf("Cannot identify Beads release root: %v", err),
Command: versioncheck.CommandDescription,
}
}