Fix Git hook installation flagging matching script as mismatch

fixes 124a1ea50
This commit is contained in:
YoshiRulz 2024-06-09 22:16:46 +10:00
parent 68c160b96b
commit 65219d03e6
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 2 additions and 1 deletions

View File

@ -2,13 +2,14 @@
$targetDir = "$PSScriptRoot/../.git/hooks"
if (Test-Path $targetDir -PathType Container) { # is Git repo
$PSCommandFilename = Split-Path $PSCommandPath -Leaf
$shimChecksum = (Get-FileHash "$PSScriptRoot/git_hook_shim.sh").Hash
foreach ($f in Get-ChildItem "$PSScriptRoot/git_hooks") {
$target = Join-Path $targetDir (Split-Path $f -LeafBase)
if (!(Test-Path $target -PathType Leaf)) { # target file doesn't exist
echo "[$PSCommandFilename] creating Git hook $($f.Name)"
Copy-Item "$PSScriptRoot/git_hook_shim.sh" $target
#TODO use symlinks on Linux
} elseif ($(Get-FileHash $target).Hash -ne $(Get-FileHash $f.FullName).Hash) { # files differ
} elseif ((Get-FileHash $target).Hash -ne $shimChecksum) { # files differ
$head = Get-Content $target -TotalCount 3
echo "[$PSCommandFilename] found existing Git hook $($f.Name), please resolve conflict manually"
exit 1