From 1669b0d3d48310e970fb55460af34527d7bde602 Mon Sep 17 00:00:00 2001 From: Fernando Serboncini Date: Tue, 21 Apr 2026 11:42:53 -0400 Subject: [PATCH] misc/git_hook: fix building git_hook in a nested worktree (#19473) When the repo is checked out as a nested worktree, a go.work in the outer tree hijacks module resolution, which makes the rebuild fails with "main module does not contain package." Set GOWORK=off for the build since the hook is self-contained. Bumps HOOK_VERSION so existing installs pick up the fix. Updates #cleanup Change-Id: Ibd14849efc26e4e1893c5b8e300caa71573f54bd Signed-off-by: Fernando Serboncini --- misc/git_hook/HOOK_VERSION | 2 +- misc/git_hook/githook/launcher.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/git_hook/HOOK_VERSION b/misc/git_hook/HOOK_VERSION index 0cfbf0888..00750edc0 100644 --- a/misc/git_hook/HOOK_VERSION +++ b/misc/git_hook/HOOK_VERSION @@ -1 +1 @@ -2 +3 diff --git a/misc/git_hook/githook/launcher.sh b/misc/git_hook/githook/launcher.sh index 8a6d00885..1171bc7b1 100755 --- a/misc/git_hook/githook/launcher.sh +++ b/misc/git_hook/githook/launcher.sh @@ -36,7 +36,7 @@ if [ "$WANT" != "$HAVE" ]; then GO="$REPO_ROOT/tool/go$EXE" if [ ! -x "$GO" ]; then GO=go; fi echo "git-hook: rebuilding ts-git-hook-bin..." >&2 - (cd "$REPO_ROOT" && "$GO" build -o "$BINARY" ./misc/git_hook) || { + (cd "$REPO_ROOT" && GOWORK=off "$GO" build -o "$BINARY" ./misc/git_hook) || { echo "git-hook: rebuild failed, run: ./tool/go run ./misc/install-git-hooks.go" >&2 exit 1 }