@@ -826,6 +826,31 @@ describe('detectAllHooks', () => {
826826 }
827827 } ) ;
828828
829+ test ( 'Copilot CLI: unknown version still honors inline disableAllHooks over repo hook files' , ( ) => {
830+ const tmpBase = join ( tmpdir ( ) , `doctor-copilot-${ Date . now ( ) } ` ) ;
831+ const homeDir = join ( tmpBase , 'home' ) ;
832+ const projectDir = join ( tmpBase , 'project' ) ;
833+ const hooksDir = join ( projectDir , '.github' , 'hooks' ) ;
834+ const configDir = join ( projectDir , '.github' , 'copilot' ) ;
835+ mkdirSync ( hooksDir , { recursive : true } ) ;
836+ mkdirSync ( configDir , { recursive : true } ) ;
837+ _writeCopilotHook ( join ( hooksDir , 'safety-net.json' ) ) ;
838+ writeFileSync ( join ( configDir , 'settings.json' ) , JSON . stringify ( { disableAllHooks : true } ) ) ;
839+
840+ try {
841+ const hooks = detectAllHooks ( projectDir , { homeDir } ) ;
842+ const copilot = hooks . find ( ( hook ) => hook . platform === 'copilot-cli' ) ;
843+
844+ expect ( copilot ?. status ) . toBe ( 'disabled' ) ;
845+ expect ( copilot ?. configPath ) . toBe ( join ( configDir , 'settings.json' ) ) ;
846+ expect ( copilot ?. configPaths ) . toEqual ( [ join ( configDir , 'settings.json' ) ] ) ;
847+ expect ( copilot ?. errors ?. some ( ( e ) => e . includes ( 'version unavailable' ) ) ) . toBe ( true ) ;
848+ expect ( copilot ?. selfTest ) . toBeUndefined ( ) ;
849+ } finally {
850+ rmSync ( tmpBase , { recursive : true , force : true } ) ;
851+ }
852+ } ) ;
853+
829854 test ( 'Copilot CLI: repository settings can override user disableAllHooks' , ( ) => {
830855 const tmpBase = join ( tmpdir ( ) , `doctor-copilot-${ Date . now ( ) } ` ) ;
831856 const homeDir = join ( tmpBase , 'home' ) ;
0 commit comments