From 842c43d5579126f98d07956e74fca65578eab0f2 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Wed, 19 Oct 2022 20:27:55 +0200 Subject: [PATCH] [Windows] Install git from gh (#6427) * Install Git from GitHub * get installer file name --- images/win/scripts/Installers/Install-Git.ps1 | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/images/win/scripts/Installers/Install-Git.ps1 b/images/win/scripts/Installers/Install-Git.ps1 index 4bc561e0c..eac134129 100644 --- a/images/win/scripts/Installers/Install-Git.ps1 +++ b/images/win/scripts/Installers/Install-Git.ps1 @@ -4,15 +4,32 @@ ################################################################################ Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" -# Install git -Choco-Install -PackageName git -ArgumentList '--installargs="/VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /o:PathOption=CmdTools /o:BashTerminalOption=ConHost /o:EnableSymlinks=Enabled /COMPONENTS=gitlfs"' +# Install the latest version of Git for Windows +$gitReleases = Invoke-RestMethod "https://api.github.com/repos/git-for-windows/git/releases/latest" +[string]$downloadUrl = $gitReleases.assets.browser_download_url -match "Git-.+-64-bit.exe" + +$installerFile = Split-Path $downloadUrl -Leaf +Install-Binary -Url $downloadUrl ` + -Name $installerFile ` + -ArgumentList ( + "/VERYSILENT", ` + "/NORESTART", ` + "/NOCANCEL", ` + "/SP-", ` + "/CLOSEAPPLICATIONS", ` + "/RESTARTAPPLICATIONS", ` + "/o:PathOption=CmdTools", ` + "/o:BashTerminalOption=ConHost", ` + "/o:EnableSymlinks=Enabled", ` + "/COMPONENTS=gitlfs") Update-SessionEnvironment git config --system --add safe.directory "*" -# Install hub -Choco-Install -PackageName hub +# Install hub with --ignore-dependencies option to prevent the installation of the git package. +# See details in https://github.com/actions/runner-images/issues/2375 +Choco-Install -PackageName hub -ArgumentList "--ignore-dependencies" # Disable GCM machine-wide [Environment]::SetEnvironmentVariable("GCM_INTERACTIVE", "Never", [System.EnvironmentVariableTarget]::Machine)