Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ base_branch=$(grep '"baseBranch"' .changeset/config.json | sed 's/.*"baseBranch"
# If origin/<base_branch> 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:"
Expand Down
Loading