Before
export function isProtectedBranch(branch?: string) { // '' is falsy → falls through to real git! const currentBranch = branch || getCurrentBranch(); return getProtectedBranches().includes(currentBranch); }
export function isProtectedBranch(branch?: string) { // '' is falsy → falls through to real git! const currentBranch = branch || getCurrentBranch(); return getProtectedBranches().includes(currentBranch); }
export function isProtectedBranch(branch?: string) { const currentBranch = branch === undefined ? getCurrentBranch() : branch; if (!currentBranch) return false; return getProtectedBranches().includes(currentBranch); }
isProtectedBranch(undefined) → read current branch // prod default, unchanged isProtectedBranch('') → false // "unknown, don't protect" (tests + git failures) isProtectedBranch('main') → true // protected isProtectedBranch('dev') → false // not in default protected list isProtectedBranch('feat/x') → false // unchanged
Before fix (on main): src/__tests__/pretool/git-validator.test.ts 8 failed / 61 passed src/__tests__/security-critical-hooks.test.ts 226 passed After fix: src/__tests__/pretool/git-validator.test.ts 69 passed src/__tests__/security-critical-hooks.test.ts 226 passed