Files
Inboxintel/scripts/install-hooks.ps1
T
cesnimda 101deb9546 chore: add version-controlled git hooks + installer
pre-commit runs fast checks (block committed .env/secrets, verify dotnet
format); pre-push mirrors CI (Release build + tests + frontend build) to catch
failures before they leave the machine. install-hooks.ps1 wires core.hooksPath
so the hooks are shared and reviewable rather than living in un-tracked
.git/hooks. Bypass with --no-verify; CI still enforces the gate server-side.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 10:14:37 +02:00

25 lines
1016 B
PowerShell

<#
.SYNOPSIS
Point git at the version-controlled hooks in scripts/git-hooks.
.DESCRIPTION
Uses `git config core.hooksPath` so the hooks live in the repo (reviewable,
shared, updatable) instead of the un-tracked .git/hooks directory. Run once
per clone. Git for Windows ships the bash needed to execute the POSIX hooks.
.EXAMPLE
./scripts/install-hooks.ps1
#>
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
Push-Location $root
try {
git config core.hooksPath scripts/git-hooks
# Best-effort exec bit (matters on Linux/WSL; harmless on Windows). Only applies
# once the hooks are tracked; ignored on a first run before they're committed.
foreach ($h in 'pre-commit','pre-push') {
try { git update-index --chmod=+x "scripts/git-hooks/$h" 2>$null } catch {}
}
Write-Host "Installed git hooks -> scripts/git-hooks (core.hooksPath set)." -ForegroundColor Green
Write-Host "Bypass in an emergency with --no-verify." -ForegroundColor DarkGray
}
finally { Pop-Location }