Skip to content

fix(desktop): disable git hooks during worktree creation#1384

Merged
Kitenite merged 1 commit into
superset-sh:mainfrom
FelipeLahti:fix/disable-hooks-worktree-creation
Feb 11, 2026
Merged

fix(desktop): disable git hooks during worktree creation#1384
Kitenite merged 1 commit into
superset-sh:mainfrom
FelipeLahti:fix/disable-hooks-worktree-creation

Conversation

@FelipeLahti
Copy link
Copy Markdown
Contributor

@FelipeLahti FelipeLahti commented Feb 11, 2026

Summary

  • Adds -c core.hooksPath=/dev/null to all git worktree add invocations to prevent post-checkout hooks (Husky, lefthook, etc.) from blocking worktree creation
  • When hook managers like Husky restrict PATH (removing NVM/asdf/volta paths), hooks calling pnpm/npm/yarn fail with "command not found", causing git worktree add to return non-zero and blocking worktree creation entirely
  • This is the standard approach used by VS Code, JetBrains, and similar tools — worktree creation is programmatic, and new worktrees don't have dependencies installed so post-checkout hooks would fail anyway

Fixes #961

Test plan

  • Added 3 new tests in git.test.ts covering:
    • createWorktree succeeds despite failing post-checkout hook
    • createWorktreeFromExistingBranch succeeds despite failing post-checkout hook
    • Proof test showing a failing hook blocks vanilla git worktree add but succeeds with core.hooksPath=/dev/null
  • All 15 tests pass: bun test apps/desktop/src/lib/trpc/routers/workspaces/utils/git.test.ts
  • Manual: create a worktree in a repo with a failing Husky post-checkout hook

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Worktree creation now disables Git hooks during all worktree operations to ensure reliable creation across scenarios (new branches, existing local branches, and PR branches).
  • Tests

    • Added tests covering worktree creation with failing Git hooks, verifying success and cleanup of repositories and worktrees.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 11, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds bypass for Git hooks during worktree creation by injecting -c core.hooksPath=/dev/null into worktree-related git commands and adds tests ensuring worktree creation succeeds when post-checkout hooks fail.

Changes

Cohort / File(s) Summary
Test Suite for Hook Handling
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.test.ts
Adds tests and helpers to create isolated repos with a failing post-checkout hook; verifies createWorktree and createWorktreeFromExistingBranch succeed despite failing hooks and confirms normal git worktree add is blocked without the workaround.
Core Worktree Operations
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
Prepends -c core.hooksPath=/dev/null to git commands used in createWorktree, createWorktreeFromExistingBranch (local and remote cases), and createWorktreeFromPr to bypass hooks during worktree add/checkout operations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • AviPeltz

Poem

🐰
I hopped into code with a curious soul,
Hooks tried to stop me, but I stayed in control.
/dev/null a tunnel where troubles take flight,
Worktrees now sprout clean, under moonbeam light.
Cheers — a rabbit's small, delightful fix tonight. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(desktop): disable git hooks during worktree creation' clearly and concisely summarizes the main change, using conventional commit format and accurately reflecting the primary objective.
Description check ✅ Passed The PR description comprehensively covers all template sections including Summary, Related Issues, Type of Change (implicit via fix keyword), Testing with checkboxes, and Additional Notes, providing clear context for the changes.
Linked Issues check ✅ Passed The code changes fully address the linked issue #961 by disabling hooks during programmatic worktree creation, with comprehensive test coverage demonstrating the fix works as intended.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the git hooks issue: modifications to git.ts add hook-disabling flags to worktree operations, and git.test.ts adds tests validating the fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

When Husky/lefthook hooks restrict PATH (removing NVM/asdf/volta paths),
hooks calling pnpm/npm/yarn fail with "command not found" during
`git worktree add`, blocking worktree creation entirely.

Add `-c core.hooksPath=/dev/null` to all `git worktree add` invocations
to bypass hooks. Worktree creation is programmatic and new worktrees
don't have dependencies installed, so post-checkout hooks would fail
anyway.

Fixes superset-sh#961

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@FelipeLahti FelipeLahti force-pushed the fix/disable-hooks-worktree-creation branch from aa20fcb to 41f5765 Compare February 11, 2026 01:29
@Kitenite
Copy link
Copy Markdown
Collaborator

Ah dang, thanks for debugging and adding the fix @FelipeLahti!

@Kitenite Kitenite merged commit af44e27 into superset-sh:main Feb 11, 2026
5 of 6 checks passed
@FelipeLahti FelipeLahti deleted the fix/disable-hooks-worktree-creation branch February 12, 2026 05:19
@de1mat
Copy link
Copy Markdown
Contributor

de1mat commented Feb 12, 2026

I have been using Superset for a monorepo that I have git hooks configured, that take care of a lot of config for me. With this MR the hook no longer runs, and the worktree is useless to me.

If you could please reconsider this PR and revert this sledgehammer as soon as possible 🙏 @Kitenite

PS: Added additional thoughts here #1432

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Superset fails with Husky hooks when using NVM-managed package managers

3 participants