Skip to content

Commit 21cfc39

Browse files
authored
refactor: pre-push hook resilience (#59)
* refactor: pre-push hook resilience * refactor: test * Revert "refactor: test" This reverts commit c94290c.
1 parent 2cdb01f commit 21cfc39

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

.husky/pre-push

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ CHECKS=('^(package\.json|pnpm-lock\.yaml)$' 'pnpm install --lockfile-only --igno
66
## Get the upstream branch
77
UPSTREAM=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null || echo "")
88
if [ -z "$UPSTREAM" ]; then
9-
echo "No upstream configured, skipping pre-push checks."
10-
exit 0
9+
echo "No upstream configured, detecting default branch."
10+
# Try to detect the default branch from origin/HEAD
11+
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
12+
if [ -z "$DEFAULT_BRANCH" ]; then
13+
echo "Could not detect default branch, falling back to 'main'."
14+
DEFAULT_BRANCH="main"
15+
fi
16+
UPSTREAM="$DEFAULT_BRANCH"
1117
fi
1218

1319
## Get the list of files changed between upstream and HEAD

0 commit comments

Comments
 (0)