Files
filtry_www/install-cloudflare-hook.ps1
T
2026-09-18 19:38:18 +02:00

22 lines
840 B
PowerShell

$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
$hooks = Join-Path $root ".git\hooks"
$source = Join-Path $root "hooks\pre-push"
$target = Join-Path $hooks "pre-push"
if (-not (Test-Path $hooks)) {
throw "Nie znaleziono folderu .git/hooks. Uruchom skrypt w katalogu repozytorium."
}
git -C $root config --local core.hooksPath "$hooks"
Copy-Item $source $target -Force
Remove-Item (Join-Path $hooks "post-push.cmd") -Force -ErrorAction SilentlyContinue
Remove-Item (Join-Path $hooks "post-push") -Force -ErrorAction SilentlyContinue
$bash = "C:\Program Files\Git\bin\bash.exe"
if (Test-Path $bash) {
& $bash -lc "chmod +x '$($target -replace '\\','/')'"
}
Write-Host "Zainstalowano hook pre-push: $target"
Write-Host "Przed kazdym git push zostanie uruchomiony deploy do Cloudflare Pages."