iris/_benchmarks/benchmarker/scripts/git-install.ps1
Gerasimos (Makis) Maropoulos c512222b9b nothing serious here yet, just having fun with powershell and my nerves - but it works
Former-commit-id: ec83062ab7a588e9bfc6c42ce59834abf24723fa
2019-06-24 04:49:24 +03:00

40 lines
1.4 KiB
PowerShell

# borrowed: https://github.com/PowerShell/vscode-powershell/blob/develop/scripts/Install-VSCode.ps1
# edited to support a custom install directory and fix an issue with ssl and
# simplify the script - we don't need update only a temp installation.
param([string]$InstallDir="$env:TEMP")
If(!(test-path $InstallDir))
{
New-Item -ItemType Directory -Force -Path $InstallDir
}
$filename=-join($InstallDir, "\", "git-installer.exe")
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
foreach ($asset in (Invoke-RestMethod https://api.github.com/repos/git-for-windows/git/releases/latest).assets) {
if ($asset.name -match 'Git-\d*\.\d*\.\d*-64-bit\.exe') {
$dlurl = $asset.browser_download_url
$newver = $asset.name
}
}
try {
$ProgressPreference = 'SilentlyContinue'
Write-Host "`nDownloading latest stable git..." -ForegroundColor Yellow
Remove-Item -Force $filename -ErrorAction SilentlyContinue
Invoke-WebRequest -Uri $dlurl -OutFile $filename
Write-Host "`nInstalling git..." -ForegroundColor Yellow
Start-Process -Wait $filename -ArgumentList /VERYSILENT, /DIR="$InstallDir", \FORCECLOSEAPPLICATIONS
# or SILENT
Write-Host "`nInstallation complete!`n`n" -ForegroundColor Green
}
finally {
$ProgressPreference = 'Continue'
}
$s = get-process ssh-agent -ErrorAction SilentlyContinue
if ($s) {$true}