forked from MicrosoftDocs/azure-devops-docs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.ps1
29 lines (23 loc) · 1.11 KB
/
install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Set-Variable -Name GitRoot -Value (git rev-parse --show-toplevel)
Set-Variable -Name GitCommitMessageHookPath -Value (Join-Path $GitRoot "/.git/hooks/commit-msg")
Set-Variable -Name NewCommitMessageHookFile -Value "/hooks/commit-msg"
Set-Variable -Name NewCommitMessageHookPath -Value (Join-Path $PSScriptRoot $NewCommitMessageHookFile)
if(!(Test-Path -Path $NewCommitMessageHookPath -PathType Leaf))
{
Write-Error "Something's gone wrong, I can't find $NewCommitMessageHookPath"
exit 1
}
Write-Host "Installing Git commit-msg hook..."
if (Test-Path -Path $GitCommitMessageHookPath)
{
Set-Variable -Name BackedUpCommitMessageHook -Value "$GitCommitMessageHookPath.previous"
Write-Warning "You already have a Git commit-msg hook installed."
Write-Warning "Backing it up as $GitCommitMessageHookPath.previous"
if (Test-Path -Path $GitCommitMessageHookPath)
{
Remove-Item -Path $BackedUpCommitMessageHook
}
Rename-Item -Path $GitCommitMessageHookPath -NewName $BackedUpCommitMessageHook
}
Copy-Item -Path $NewCommitMessageHookPath -Destination $GitCommitMessageHookPath
Write-Host "Done."