@@ -38,7 +38,6 @@ test('installs repository-level hooks from a nested project', () => {
3838 } ) ;
3939 expect ( runGit ( cwd , [ 'config' , '--local' , '--get' , 'core.hooksPath' ] ) ) . toBe ( hooksPath ) ;
4040 expect ( existsSync ( path . join ( cwd , hooksPath , 'runner' ) ) ) . toBe ( true ) ;
41- expect ( existsSync ( path . join ( projectDirectory , '.rstack' ) ) ) . toBe ( false ) ;
4241 expect ( readFileSync ( path . join ( cwd , hooksPath , '.owner' ) , 'utf8' ) ) . toBe ( 'frontend\n' ) ;
4342
4443 expect ( runHook ( cwd ) . status ) . toBe ( 0 ) ;
@@ -50,7 +49,6 @@ test('installs a root-relative custom hooks directory from a nested project', ()
5049 withRepository ( ( cwd ) => {
5150 const projectDirectory = path . join ( cwd , 'frontend app' ) ;
5251 mkdirSync ( projectDirectory ) ;
53- writeHook ( cwd , "printf 'ran\\n' > custom-hook-ran\n" , 'config/hooks' ) ;
5452
5553 expect ( installHooks ( { cwd : projectDirectory , hooksDir : 'config\\hooks' } ) ) . toEqual ( {
5654 status : 'installed' ,
@@ -62,60 +60,5 @@ test('installs a root-relative custom hooks directory from a nested project', ()
6260 } ) ;
6361 expect ( runGit ( cwd , [ 'config' , '--local' , '--get' , 'core.hooksPath' ] ) ) . toBe ( 'config/hooks/_' ) ;
6462 expect ( existsSync ( path . join ( cwd , 'config' , 'hooks' , '_' , 'runner' ) ) ) . toBe ( true ) ;
65- expect ( existsSync ( path . join ( projectDirectory , 'config' ) ) ) . toBe ( false ) ;
66- expect ( runHook ( cwd ) . status ) . toBe ( 0 ) ;
67- expect ( readFileSync ( path . join ( projectDirectory , 'custom-hook-ran' ) , 'utf8' ) ) . toBe ( 'ran\n' ) ;
68- } ) ;
69- } ) ;
70-
71- test ( 'does not replace another Rstack project owner' , ( ) => {
72- withRepository ( ( cwd ) => {
73- const frontend = path . join ( cwd , 'frontend' ) ;
74- const docs = path . join ( cwd , 'docs' ) ;
75- mkdirSync ( frontend ) ;
76- mkdirSync ( docs ) ;
77- writeHook ( cwd , 'printf \'%s\\n\' "$PWD" > hook-cwd\n' ) ;
78-
79- expect ( installHooks ( { cwd : frontend } ) . status ) . toBe ( 'installed' ) ;
80- expect ( installHooks ( { cwd : docs } ) ) . toEqual ( {
81- status : 'skipped' ,
82- reason : 'owned-by-another-project' ,
83- message : 'Git hooks are already managed by Rstack project "frontend"' ,
84- } ) ;
85- expect ( readFileSync ( path . join ( cwd , hooksPath , '.owner' ) , 'utf8' ) ) . toBe ( 'frontend\n' ) ;
86-
87- expect ( runHook ( cwd ) . status ) . toBe ( 0 ) ;
88- expect ( readFileSync ( path . join ( frontend , 'hook-cwd' ) , 'utf8' ) ) . toBe ( `${ frontend } \n` ) ;
89- expect ( existsSync ( path . join ( docs , 'hook-cwd' ) ) ) . toBe ( false ) ;
90- } ) ;
91- } ) ;
92-
93- test ( 'installs generated hooks relative to the current worktree' , ( ) => {
94- withRepository ( ( cwd ) => {
95- runGit ( cwd , [
96- '-c' ,
97- 'user.name=Rstack' ,
98- '-c' ,
99- 'user.email=rstack@example.com' ,
100- 'commit' ,
101- '--allow-empty' ,
102- '--quiet' ,
103- '-m' ,
104- 'Initial commit' ,
105- ] ) ;
106- const worktree = path . join ( cwd , 'linked' , 'secondary' ) ;
107- mkdirSync ( path . dirname ( worktree ) , { recursive : true } ) ;
108- runGit ( cwd , [ 'worktree' , 'add' , '--quiet' , '-b' , 'secondary' , worktree ] ) ;
109-
110- const projectDirectory = path . join ( worktree , 'frontend' ) ;
111- mkdirSync ( projectDirectory ) ;
112- writeHook ( worktree , "printf 'ran\\n' > worktree-hook-ran\n" ) ;
113-
114- expect ( installHooks ( { cwd : projectDirectory } ) . status ) . toBe ( 'installed' ) ;
115- expect ( existsSync ( path . join ( worktree , hooksPath , 'runner' ) ) ) . toBe ( true ) ;
116- expect ( existsSync ( path . join ( cwd , hooksPath , 'runner' ) ) ) . toBe ( false ) ;
117-
118- expect ( runHook ( worktree ) . status ) . toBe ( 0 ) ;
119- expect ( readFileSync ( path . join ( projectDirectory , 'worktree-hook-ran' ) , 'utf8' ) ) . toBe ( 'ran\n' ) ;
12063 } ) ;
12164} ) ;
0 commit comments