Skip to content

fix(husky): quote branch comparison to handle detached HEAD - #69708

Merged
rnegron merged 1 commit into
masterfrom
worktree-fix-husky-prepush-detached-head
Jul 9, 2026
Merged

fix(husky): quote branch comparison to handle detached HEAD#69708
rnegron merged 1 commit into
masterfrom
worktree-fix-husky-prepush-detached-head

Conversation

@rnegron

@rnegron rnegron commented Jul 9, 2026

Copy link
Copy Markdown
Member

Problem

The pre-push hook compares branch names unquoted:

if [ $protected_branch = $current_branch ]

On a detached HEAD, git branch --show-current returns an empty string, so the test expands to [ master = ] and sh aborts with [: master: unary operator expected on every push from a detached-HEAD worktree.
Surfaced via hogli devex:feedback (reported twice).

Changes

Quote both operands so an empty current_branch is compared as a string, not dropped:

-if [ $protected_branch = $current_branch ]
+if [ "$protected_branch" = "$current_branch" ]

How did you test this code?

  • Pushed this branch: the hook ran clean and ci:preflight passed.
  • Shell repro of the empty-branch case (what a detached HEAD produces):
    • before (unquoted): sh: [: master: unary operator expected
    • after (quoted): no error, prints neq
    • master vs master still returns eq, so pushing to master is still blocked (behavior preserved).
  • No automated test added: a shell-hook test for a one-token quoting fix would be low value and there is no existing harness for .husky/*.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Raúl surfaced this while triaging hogli devex:feedback entries for low-hanging fixes.
I (Claude) confirmed the root cause at .husky/pre-push:7, applied the quoting fix, and verified before/after behavior plus the preserved master-block in a scratch shell.
No repo skills were needed beyond the CI-failure triage that found it.

@rnegron rnegron self-assigned this Jul 9, 2026
@rnegron rnegron added the skip-agent-review Save $$$, skip auto agent reviews (Greptile) — use for trivial or chore PRs label Jul 9, 2026
@rnegron
rnegron marked this pull request as ready for review July 9, 2026 17:51
@rnegron rnegron added the stamphog Request AI approval (no full review) label Jul 9, 2026
@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(husky): quote branch comparison to h..." | Re-trigger Greptile

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial one-line quoting fix in a git hook script, no risky territory, verified behavior preserved.

  • 👍 on the PR from greptile-apps[bot], hex-security-app[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 2L, 1F substantive — within ceiling
tier T1-agent / T1a-trivial (2L, 1F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ c5c378d · reviewed head b501e5e

@rnegron
rnegron enabled auto-merge (squash) July 9, 2026 17:56
@rnegron
rnegron merged commit 7963eba into master Jul 9, 2026
331 of 364 checks passed
@rnegron
rnegron deleted the worktree-fix-husky-prepush-detached-head branch July 9, 2026 17:57
@trunk-io

trunk-io Bot commented Jul 9, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@deployment-status-posthog

deployment-status-posthog Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-09 18:51 UTC Run
prod-us ✅ Deployed 2026-07-09 19:04 UTC Run
prod-eu ✅ Deployed 2026-07-09 19:07 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-agent-review Save $$$, skip auto agent reviews (Greptile) — use for trivial or chore PRs stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant