diff --git a/internal/tools/builtin/grep.go b/internal/tools/builtin/grep.go index e1f5d4669..c038fb981 100644 --- a/internal/tools/builtin/grep.go +++ b/internal/tools/builtin/grep.go @@ -4,6 +4,10 @@ // Mutations from upstream: // - package renamed tools -> builtin (archie-core already has an // internal/tools package holding the registry these are registered into). +// - the embedded ripgrep binaries (upstream internal/tools/builtin/rg) were +// removed. They were 14MB of tracked binaries that were re-extracted to a +// temporary directory on every run. grepBinary now resolves rg from PATH +// and the existing pure-Go grepFallback covers its absence. // // Refresh by diffing against that path at a newer tau commit. Do not // edit without recording the change above. @@ -21,8 +25,6 @@ import ( "regexp" "strings" "unicode/utf8" - - "github.com/samcharles93/archie-core/internal/tools/builtin/rg" ) const ( @@ -574,9 +576,15 @@ func buildGrepArgs(p GrepParams) []string { return args } +// grepBinary resolves ripgrep from PATH. When it is absent the caller falls +// back to grepFallback, the pure-Go search, so this returning an error is an +// ordinary outcome rather than a failure. +// +// Upstream tau embeds ripgrep binaries for each platform and extracts one to +// a temporary directory on demand. That cost 14MB of tracked binaries and +// wrote the binary out again on every run, which is why it was removed here. func grepBinary() (string, error) { - // Use the embedded statically-linked ripgrep binary. - return rg.Path() + return exec.LookPath("rg") } // hasUppercase reports whether s contains any uppercase ASCII letter. diff --git a/internal/tools/builtin/rg/rg-darwin-amd64 b/internal/tools/builtin/rg/rg-darwin-amd64 deleted file mode 100644 index 4fdb58b25..000000000 Binary files a/internal/tools/builtin/rg/rg-darwin-amd64 and /dev/null differ diff --git a/internal/tools/builtin/rg/rg-linux-amd64 b/internal/tools/builtin/rg/rg-linux-amd64 deleted file mode 100644 index 477c4756e..000000000 Binary files a/internal/tools/builtin/rg/rg-linux-amd64 and /dev/null differ diff --git a/internal/tools/builtin/rg/rg-windows-amd64.exe b/internal/tools/builtin/rg/rg-windows-amd64.exe deleted file mode 100644 index 1c6cc8cb5..000000000 Binary files a/internal/tools/builtin/rg/rg-windows-amd64.exe and /dev/null differ diff --git a/internal/tools/builtin/rg/rg.go b/internal/tools/builtin/rg/rg.go deleted file mode 100644 index 6985c3b9a..000000000 --- a/internal/tools/builtin/rg/rg.go +++ /dev/null @@ -1,45 +0,0 @@ -//go:build (darwin && amd64) || (linux && amd64) || (windows && amd64) - -// Package rg embeds a statically-linked ripgrep binary and exposes a single -// entry point so the grep tool can always use authoritative rg matching. -package rg - -import ( - "fmt" - "os" - "path/filepath" - "sync" -) - -var ( - extractOnce sync.Once - extractPath string - extractErr error -) - -// Path returns the filesystem path to the embedded rg binary, extracting it -// to a temporary file on first call. The caller must not remove the file. -func Path() (string, error) { - extractOnce.Do(func() { - extractPath, extractErr = extract() - }) - if extractErr != nil { - return "", extractErr - } - return extractPath, nil -} - -func extract() (string, error) { - dir, err := os.MkdirTemp("", "tau-rg-*") - if err != nil { - return "", fmt.Errorf("create rg temp dir: %w", err) - } - exe := filepath.Join(dir, "rg") - if isWindows { - exe += ".exe" - } - if err := os.WriteFile(exe, binary, 0o755); err != nil { - return "", fmt.Errorf("write embedded rg: %w", err) - } - return exe, nil -} diff --git a/internal/tools/builtin/rg/rg_darwin_amd64.go b/internal/tools/builtin/rg/rg_darwin_amd64.go deleted file mode 100644 index 74bcc7973..000000000 --- a/internal/tools/builtin/rg/rg_darwin_amd64.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build darwin && amd64 - -package rg - -import _ "embed" - -const isWindows = false - -//go:embed rg-darwin-amd64 -var binary []byte diff --git a/internal/tools/builtin/rg/rg_linux_amd64.go b/internal/tools/builtin/rg/rg_linux_amd64.go deleted file mode 100644 index 86ebd6f9b..000000000 --- a/internal/tools/builtin/rg/rg_linux_amd64.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build linux && amd64 - -package rg - -import _ "embed" - -const isWindows = false - -//go:embed rg-linux-amd64 -var binary []byte diff --git a/internal/tools/builtin/rg/rg_unsupported.go b/internal/tools/builtin/rg/rg_unsupported.go deleted file mode 100644 index 216e8ce01..000000000 --- a/internal/tools/builtin/rg/rg_unsupported.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build !((darwin && amd64) || (linux && amd64) || (windows && amd64)) - -// Package rg embeds a statically-linked ripgrep binary and exposes a single -// entry point so the grep tool can always use authoritative rg matching. -package rg - -import "errors" - -// Path reports that no ripgrep binary is bundled for this platform/arch. -// Callers fall back to the pure-Go grep implementation. -func Path() (string, error) { - return "", errors.New("no embedded ripgrep binary for this platform") -} diff --git a/internal/tools/builtin/rg/rg_windows_amd64.go b/internal/tools/builtin/rg/rg_windows_amd64.go deleted file mode 100644 index 8b277b2c0..000000000 --- a/internal/tools/builtin/rg/rg_windows_amd64.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build windows && amd64 - -package rg - -import _ "embed" - -const isWindows = true - -//go:embed rg-windows-amd64.exe -var binary []byte