20 lines
777 B
PowerShell
20 lines
777 B
PowerShell
# Installs repo pre-push hook (gdlint + gdformat). Same behavior as install-git-hooks.sh.
|
|
# Run from repo root: pwsh -File scripts/install-git-hooks.ps1
|
|
$ErrorActionPreference = "Stop"
|
|
$repoRoot = (git rev-parse --show-toplevel).Trim()
|
|
$hookDir = Join-Path $repoRoot ".git/hooks"
|
|
$hookPath = Join-Path $hookDir "pre-push"
|
|
New-Item -ItemType Directory -Force -Path $hookDir | Out-Null
|
|
$unixRoot = $repoRoot -replace "\\", "/"
|
|
$lines = @(
|
|
"#!/bin/sh",
|
|
"set -e",
|
|
"repo_root=`"$unixRoot`"",
|
|
'cd "$repo_root" || exit 1',
|
|
'exec sh "$repo_root/scripts/git-hooks/pre-push" "$@"'
|
|
)
|
|
$content = ($lines -join "`n") + "`n"
|
|
$utf8 = New-Object System.Text.UTF8Encoding $false
|
|
[System.IO.File]::WriteAllText($hookPath, $content, $utf8)
|
|
Write-Host "Installed pre-push hook at $hookPath"
|