@@ -3,6 +3,7 @@ import * as path from "node:path";
33import { GitSaga , type GitSagaInput } from "../git-saga" ;
44import { addToLocalExclude , branchExists , getDefaultBranch } from "../queries" ;
55import { safeSymlink } from "../utils" ;
6+ import { processWorktreeInclude , runPostCheckoutHook } from "../worktree" ;
67
78export interface CreateWorktreeInput extends GitSagaInput {
89 worktreePath : string ;
@@ -35,7 +36,16 @@ export class CreateWorktreeSaga extends GitSaga<
3536 await this . step ( {
3637 name : "create-worktree" ,
3738 execute : ( ) =>
38- this . git . raw ( [ "worktree" , "add" , "-b" , branchName , worktreePath , base ] ) ,
39+ this . git . raw ( [
40+ "-c" ,
41+ "core.hooksPath=/dev/null" ,
42+ "worktree" ,
43+ "add" ,
44+ "-b" ,
45+ branchName ,
46+ worktreePath ,
47+ base ,
48+ ] ) ,
3949 rollback : async ( ) => {
4050 try {
4151 await this . git . raw ( [ "worktree" , "remove" , worktreePath , "--force" ] ) ;
@@ -86,6 +96,18 @@ export class CreateWorktreeSaga extends GitSaga<
8696 } ,
8797 } ) ;
8898
99+ await this . step ( {
100+ name : "process-worktree-include" ,
101+ execute : ( ) => processWorktreeInclude ( baseDir , worktreePath ) ,
102+ rollback : async ( ) => { } ,
103+ } ) ;
104+
105+ await this . step ( {
106+ name : "run-post-checkout-hook" ,
107+ execute : ( ) => runPostCheckoutHook ( baseDir , worktreePath ) ,
108+ rollback : async ( ) => { } ,
109+ } ) ;
110+
89111 return { worktreePath, branchName, baseBranch : base } ;
90112 }
91113}
@@ -123,7 +145,14 @@ export class CreateWorktreeForBranchSaga extends GitSaga<
123145 await this . step ( {
124146 name : "create-worktree" ,
125147 execute : ( ) =>
126- this . git . raw ( [ "worktree" , "add" , worktreePath , branchName ] ) ,
148+ this . git . raw ( [
149+ "-c" ,
150+ "core.hooksPath=/dev/null" ,
151+ "worktree" ,
152+ "add" ,
153+ worktreePath ,
154+ branchName ,
155+ ] ) ,
127156 rollback : async ( ) => {
128157 try {
129158 await this . git . raw ( [ "worktree" , "remove" , worktreePath , "--force" ] ) ;
@@ -171,6 +200,18 @@ export class CreateWorktreeForBranchSaga extends GitSaga<
171200 } ,
172201 } ) ;
173202
203+ await this . step ( {
204+ name : "process-worktree-include" ,
205+ execute : ( ) => processWorktreeInclude ( baseDir , worktreePath ) ,
206+ rollback : async ( ) => { } ,
207+ } ) ;
208+
209+ await this . step ( {
210+ name : "run-post-checkout-hook" ,
211+ execute : ( ) => runPostCheckoutHook ( baseDir , worktreePath ) ,
212+ rollback : async ( ) => { } ,
213+ } ) ;
214+
174215 return { worktreePath, branchName } ;
175216 }
176217}
0 commit comments