fix: make git hooks opt-in only — do not modify hooks when disabled

Remove the else branch that actively called GitHooksService.disableHooks()
for every user where gitHooksEnabled was false (the default). This was a
breaking change that silently modified core.hooksPath to point at an empty
directory, disabling any existing git hooks (husky, lefthook, pre-commit, etc.).

When gitHooksEnabled is false (default), the action now does nothing
regarding hooks — exactly matching the behavior on main before the hooks
feature was added. The hooks feature only activates when users explicitly
set gitHooksEnabled: true.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
frostebite
2026-03-06 08:53:15 +00:00
parent f2e7568d47
commit 7b8f109334
3 changed files with 3 additions and 10 deletions

6
dist/index.js generated vendored
View File

@@ -101,7 +101,7 @@ async function runMain() {
await LocalCacheService.restoreLibraryCache(projectFullPath, cacheRoot, cacheKey);
}
}
// Git hooks
// Git hooks — opt-in only. When disabled (default), do not touch hooks at all.
if (buildParameters.gitHooksEnabled) {
const { GitHooksService } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(9146)));
await GitHooksService.installHooks(workspace);
@@ -110,10 +110,6 @@ async function runMain() {
Object.assign(process.env, environment);
}
}
else {
const { GitHooksService } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(9146)));
await GitHooksService.disableHooks(workspace);
}
await platform_setup_1.default.setup(buildParameters, actionFolder);
exitCode =
process.platform === 'darwin'

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -102,7 +102,7 @@ async function runMain() {
}
}
// Git hooks
// Git hooks — opt-in only. When disabled (default), do not touch hooks at all.
if (buildParameters.gitHooksEnabled) {
const { GitHooksService } = await import('./model/orchestrator/services/hooks/git-hooks-service');
await GitHooksService.installHooks(workspace);
@@ -110,9 +110,6 @@ async function runMain() {
const environment = GitHooksService.configureSkipList(buildParameters.gitHooksSkipList.split(','));
Object.assign(process.env, environment);
}
} else {
const { GitHooksService } = await import('./model/orchestrator/services/hooks/git-hooks-service');
await GitHooksService.disableHooks(workspace);
}
await PlatformSetup.setup(buildParameters, actionFolder);