fix(stale): enable stale binary warning and fix source detection
- Add checkStaleBinaryWarning() call to persistentPreRun (was only in deprecated function) - Fix GetRepoRoot() to look in correct location ($GT_ROOT/gastown/mayor/rig) - Use hasGtSource() with os.Stat instead of shell test command Agents will now see warnings when running gt with a stale binary. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,11 @@ func persistentPreRun(cmd *cobra.Command, args []string) error {
|
|||||||
// Get the root command name being run
|
// Get the root command name being run
|
||||||
cmdName := cmd.Name()
|
cmdName := cmd.Name()
|
||||||
|
|
||||||
|
// Check for stale binary (warning only, doesn't block)
|
||||||
|
if !beadsExemptCommands[cmdName] {
|
||||||
|
checkStaleBinaryWarning()
|
||||||
|
}
|
||||||
|
|
||||||
// Check town root branch (warning only, non-blocking)
|
// Check town root branch (warning only, non-blocking)
|
||||||
if !branchCheckExemptCommands[cmdName] {
|
if !branchCheckExemptCommands[cmdName] {
|
||||||
warnIfTownRootOffMain()
|
warnIfTownRootOffMain()
|
||||||
|
|||||||
+16
-16
@@ -107,12 +107,13 @@ func CheckStaleBinary(repoDir string) *StaleBinaryInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetRepoRoot returns the git repository root for the gt source code.
|
// GetRepoRoot returns the git repository root for the gt source code.
|
||||||
// It looks for the gastown repo by checking known paths.
|
// The gt source lives in the gastown rig at $GT_ROOT/gastown/mayor/rig.
|
||||||
func GetRepoRoot() (string, error) {
|
func GetRepoRoot() (string, error) {
|
||||||
// First, check if GT_ROOT environment variable is set
|
// Check if GT_ROOT environment variable is set (agents always have this)
|
||||||
if gtRoot := os.Getenv("GT_ROOT"); gtRoot != "" {
|
if gtRoot := os.Getenv("GT_ROOT"); gtRoot != "" {
|
||||||
if isGitRepo(gtRoot) && hasGastownMarker(gtRoot) {
|
rigPath := gtRoot + "/gastown/mayor/rig"
|
||||||
return gtRoot, nil
|
if hasGtSource(rigPath) {
|
||||||
|
return rigPath, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,23 +121,22 @@ func GetRepoRoot() (string, error) {
|
|||||||
home := os.Getenv("HOME")
|
home := os.Getenv("HOME")
|
||||||
if home != "" {
|
if home != "" {
|
||||||
candidates := []string{
|
candidates := []string{
|
||||||
home + "/gt/gastown",
|
home + "/gt/gastown/mayor/rig",
|
||||||
home + "/gastown",
|
home + "/gastown/mayor/rig",
|
||||||
home + "/src/gastown",
|
home + "/src/gastown/mayor/rig",
|
||||||
home + "/dev/gastown",
|
|
||||||
}
|
}
|
||||||
for _, candidate := range candidates {
|
for _, candidate := range candidates {
|
||||||
if isGitRepo(candidate) && hasGastownMarker(candidate) {
|
if hasGtSource(candidate) {
|
||||||
return candidate, nil
|
return candidate, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if current directory is in a gastown repo
|
// Check if current directory is in the gt source repo
|
||||||
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
|
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
|
||||||
if output, err := cmd.Output(); err == nil {
|
if output, err := cmd.Output(); err == nil {
|
||||||
root := strings.TrimSpace(string(output))
|
root := strings.TrimSpace(string(output))
|
||||||
if hasGastownMarker(root) {
|
if hasGtSource(root) {
|
||||||
return root, nil
|
return root, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,11 +151,11 @@ func isGitRepo(dir string) bool {
|
|||||||
return cmd.Run() == nil
|
return cmd.Run() == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// hasGastownMarker checks if a directory looks like the gastown repo.
|
// hasGtSource checks if a directory contains the gt source code.
|
||||||
func hasGastownMarker(dir string) bool {
|
// We look for cmd/gt/main.go as the definitive marker.
|
||||||
// Check for cmd/gt directory which is unique to gastown
|
func hasGtSource(dir string) bool {
|
||||||
cmd := exec.Command("test", "-d", dir+"/cmd/gt")
|
_, err := os.Stat(dir + "/cmd/gt/main.go")
|
||||||
return cmd.Run() == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetCommit allows the cmd package to pass in the build-time commit.
|
// SetCommit allows the cmd package to pass in the build-time commit.
|
||||||
|
|||||||
Reference in New Issue
Block a user