fix(version): suppress staleness warning for fork builds

When the gt binary is built from a local fork (e.g., ~/src/gastown),
the staleness check would incorrectly warn about being stale because
it compared against the rig's repo HEAD. This confused agents.

The fix detects fork builds by checking if the binary's embedded
commit exists in the target repo. If not, the binary was built from
a different repo and we report "fork build" instead of "stale".

Changes:
- Add IsForkBuild field to StaleBinaryInfo
- Add commitExistsInRepo helper to detect fork scenarios
- Update gt stale command to show "Binary built from fork" status
- Update doctor check to report fork builds as OK

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
furiosa
2026-01-26 11:10:35 -08:00
committed by John Ogle
parent d0036b0768
commit 5ab01f383a
3 changed files with 37 additions and 2 deletions

View File

@@ -43,6 +43,7 @@ func init() {
// StaleOutput represents the JSON output structure.
type StaleOutput struct {
Stale bool `json:"stale"`
ForkBuild bool `json:"fork_build,omitempty"`
BinaryCommit string `json:"binary_commit"`
RepoCommit string `json:"repo_commit"`
CommitsBehind int `json:"commits_behind,omitempty"`
@@ -77,8 +78,9 @@ func runStale(cmd *cobra.Command, args []string) error {
}
// Quiet mode: just exit with appropriate code
// Fork builds are treated as "fresh" (exit 1) since they're intentional
if staleQuiet {
if info.IsStale {
if info.IsStale && !info.IsForkBuild {
os.Exit(0)
}
os.Exit(1)
@@ -87,6 +89,7 @@ func runStale(cmd *cobra.Command, args []string) error {
// Build output
output := StaleOutput{
Stale: info.IsStale,
ForkBuild: info.IsForkBuild,
BinaryCommit: info.BinaryCommit,
RepoCommit: info.RepoCommit,
CommitsBehind: info.CommitsBehind,
@@ -106,7 +109,11 @@ func outputStaleJSON(output StaleOutput) error {
}
func outputStaleText(output StaleOutput) error {
if output.Stale {
if output.ForkBuild {
fmt.Printf("%s Binary built from fork\n", style.Success.Render("✓"))
fmt.Printf(" Commit: %s\n", version.ShortCommit(output.BinaryCommit))
fmt.Printf(" %s\n", style.Dim.Render("(commit not in rig repo - likely built from local fork)"))
} else if output.Stale {
fmt.Printf("%s Binary is stale\n", style.Warning.Render("⚠"))
fmt.Printf(" Binary: %s\n", version.ShortCommit(output.BinaryCommit))
fmt.Printf(" Repo: %s\n", version.ShortCommit(output.RepoCommit))