返回 DeepSeek-Reasonix
git_preflight_darwin.go
根目录 / internal / sandbox / git_preflight_darwin.go
1 //go:build darwin
2
3 package sandbox
4
5 import (
6 "context"
7 "os/exec"
8 "path/filepath"
9 "time"
10 )
11
12 // gitCandidatePreflight avoids executing Apple's /usr/bin/git shim before the
13 // Command Line Tools are active. Invoking that shim on a fresh macOS install
14 // opens the system download prompt, which capability discovery must not do.
15 func gitCandidatePreflight(path string) bool {
16 clean := filepath.Clean(path)
17 if resolved, err := filepath.EvalSymlinks(clean); err == nil {
18 clean = resolved
19 }
20 if clean != "/usr/bin/git" {
21 return true
22 }
23 ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
24 defer cancel()
25 return exec.CommandContext(ctx, "/usr/bin/xcode-select", "--print-path").Run() == nil
26 }
27
27 lines GO