From 9134ab9e174a1e7af5d6e0a40b7fe888dc1c6be8 Mon Sep 17 00:00:00 2001 From: Daryl Collins Date: Mon, 20 Jul 2026 15:13:17 +0100 Subject: [PATCH] chore: fix changeset pre-push hook in linked worktrees Git exports GIT_DIR/GIT_WORK_TREE to hooks running in linked worktrees, which makes `changeset status` read the wrong gitdir and falsely report no changesets. Sync the hook with apps-team-ts-template, which unsets both before invoking changesets. Claude-Session: https://claude.ai/code/session_01928TnCS4kMQPd6uVTewNSN --- .husky/pre-push | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.husky/pre-push b/.husky/pre-push index ef4dc8e..1f8ebc5 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -15,6 +15,14 @@ base_branch=$(grep '"baseBranch"' .changeset/config.json | sed 's/.*"baseBranch" # If origin/ doesn't exist yet (brand-new repo), nothing to compare against. git rev-parse --verify "origin/$base_branch" > /dev/null 2>&1 || exit 0 +# Git sets GIT_DIR / GIT_WORK_TREE to the worktree's gitdir when running hooks +# inside a linked worktree (e.g. one created via `git worktree add`). Those vars +# break `changeset status` — it invokes its own `git` subprocesses, which then +# read from the linked gitdir rather than the worktree's actual tree, and report +# "no changesets found" even when a valid one exists. Unset both so changeset's +# git calls resolve against the CWD the hook is running in. +unset GIT_DIR GIT_WORK_TREE + if ! pnpm exec changeset status --since="origin/$base_branch" 2>/dev/null; then echo "" echo " No changeset found. Add one before pushing:"