File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,12 +121,21 @@ function Get-GitRepos {
121121function 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}
You can’t perform that action at this time.
0 commit comments