Skip to content

Commit cce445b

Browse files
committed
fix:fixed hooks error on windows
1 parent d87abd7 commit cce445b

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

update-all-repos.ps1

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,21 @@ function Get-GitRepos {
121121
function Install-Hooks {
122122
param([string]$RepoDir)
123123
$hooksDir = Join-Path $RepoDir ".git\hooks"
124-
if (-not (Test-Path $hooksDir)) { return $false }
124+
# Create hooks directory if it doesn't exist
125+
if (-not (Test-Path $hooksDir)) {
126+
try {
127+
New-Item -ItemType Directory -Path $hooksDir -Force -ErrorAction Stop | Out-Null
128+
} catch {
129+
Write-Fail "Cannot create hooks dir: $hooksDir - $($_.Exception.Message)"
130+
return $false
131+
}
132+
}
125133
try {
126-
Copy-Item -Path $preCommitSrc -Destination (Join-Path $hooksDir "pre-commit") -Force
127-
Copy-Item -Path $commitMsgSrc -Destination (Join-Path $hooksDir "commit-msg") -Force
134+
Copy-Item -Path $preCommitSrc -Destination (Join-Path $hooksDir "pre-commit") -Force -ErrorAction Stop
135+
Copy-Item -Path $commitMsgSrc -Destination (Join-Path $hooksDir "commit-msg") -Force -ErrorAction Stop
128136
return $true
129137
} catch {
138+
Write-Fail "Hook copy error: $($_.Exception.Message)"
130139
return $false
131140
}
132141
}

0 commit comments

Comments
 (0)