-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSetup Git with Azure Devops.ps1
39 lines (28 loc) · 1.43 KB
/
Setup Git with Azure Devops.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
30
31
32
33
34
35
36
37
38
39
$url = "https://github.com/Azure/azure-devops-cli-extension/releases/download/0.1.4/vsts-cli-0.1.4.msi"
$outpath = "$PSScriptRoot\vsts-cli.msi"
$gitToken = Read-Host -Prompt 'Enter your Personal Access Token'
if ($gitToken -eq "")
{
Write-Output("Invalid git token")
exit
}
Write-Output("Your git token: $gitTOken")
Write-Output("Downloading file...")
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest $url -OutFile $outpath
Write-Output("Installing VSTS CLI...")
$args = @("/i",$outpath)
Start-Process -Filepath msiexec -ArgumentList $args -Wait
Write-Output("Refresh env viarables...")
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
vsts login --token $gitToken
vsts configure --use-git-aliases yes
Write-Output("Setting git aliases...")
git config --global alias.prb "!git pr create --target-branch"
git config --global alias.prm "!git prb master --query pullRequestId"
git config --global alias.prmc "!git prm --auto-complete"
git config --global alias.prl "!git pr list -output table"
git config --global alias.prc "!git pr update --query status --auto-complete on --id"
git config --global alias.url "!git config --get remote.origin.url"
git config --global alias.execurl "`"!f() { exec start chrome \`"$@/pullrequests?_a=mine\`"; } ; f"
git config --global alias.web "!git execurl `$(git url)"