Created
September 21, 2017 09:07
-
-
Save fcharlie/be9326e19e967cab1fb6de92b9ed3ec4 to your computer and use it in GitHub Desktop.
Create Hook SymblocLink for all repo (Gitlab like)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env powershell | |
### bind hook | |
$Repositories = "/home/git/repositories" | |
$Global:Installroot = "/home/git/gitlab-shell" | |
Function SymlinkNative { | |
param( | |
[string]$Path, | |
[string[]]$Hooks | |
) | |
if ($null -ne $env:DEBUGHOOK) { | |
Write-Host -ForegroundColor Yellow "update $Path" | |
} | |
try { | |
$null = New-Item -Force -ItemType SymbolicLink -Target "$Global:Installroot/hooks/update" -Path "$Path/hooks/update" | |
} | |
catch { | |
Write-Host -ForegroundColor Red "$_ $Path" | |
} | |
} | |
# /home/git/repositories | |
# /home/git/repositories/ex | |
# /home/git/repositories/ex/example | |
# /home/git/repositories/ex/example/repo.git | |
# so look all | |
[long]$Completed = 0 | |
Get-ChildItem -Path $Repositories |ForEach-Object { | |
Get-ChildItem -Path $_.FullName |ForEach-Object { | |
Get-ChildItem -Path $_.FullName|ForEach-Object { | |
if ($_.FullName.EndsWith(".git")) { | |
SymlinkNative -Path $_.FullName -Hooks $Hooks | |
$Completed++ | |
} | |
} | |
} | |
Write-Host "$Completed completed." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment