summaryrefslogtreecommitdiff
path: root/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb
diff options
context:
space:
mode:
authorJohn McCrae <john.mccrae@progress.com>2022-08-31 02:58:41 -0700
committerGitHub <noreply@github.com>2022-08-31 02:58:41 -0700
commit6aceb4b788845378e286cfaf90e0641ddedea2f8 (patch)
treefa08763216c4d44676eef1c63ba71130ba026077 /kitchen-tests/cookbooks/end_to_end/recipes/windows.rb
parent4feba0045b312de61a27ed620a8d6bb04e3126a1 (diff)
parent65e2d57afd116b8e0dc34d617c1ed276b569a597 (diff)
downloadchef-6aceb4b788845378e286cfaf90e0641ddedea2f8.tar.gz
Merge branch 'main' into tp/ruby_revert_to_ruby31tp/ruby_revert_to_ruby31
Diffstat (limited to 'kitchen-tests/cookbooks/end_to_end/recipes/windows.rb')
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/windows.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb b/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb
index d37174edd2..0c60bf1b0f 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb
@@ -13,6 +13,59 @@ chef_sleep "2"
execute "dir"
+execute "Print git version" do
+ command "git --version & git --exec-path"
+ live_stream true
+end
+
+# FIXME Uninstall git using powershell
+# this is a temporary band-aid due to the fallback git version in
+# https://github.com/sous-chefs/git defaulting to an older version of git
+# than will be installed on the current image this runs in for GitHub Actions
+powershell_script "uninstall_git" do
+ code <<-EOH
+ $possibleInstalledPaths = @("C:/Program Files/Git/", "C:/Program Files (x64)/Git/", "c:/git/")
+ $foundAnInstallation = $false
+ ### For all places where Git "could" be.
+ foreach ($installPath in $possibleInstalledPaths)
+ {
+ ### If the path where Git could exist
+ if (Test-Path($installPath))
+ {
+ ## Some Git stuff might be running.. kill them.
+ Stop-Process -processname Bash -erroraction 'silentlycontinue'
+ Stop-Process -processname Putty* -erroraction 'silentlycontinue'
+
+ $foundAnInstallation = $true
+ Write-Host "Removing Git from " $installPath
+
+ ### Find if there's an uninstaller in the folder.
+ $uninstallers = Get-ChildItem $installPath"unins*.exe"
+
+ ### In reality, there should only be just one that matches.
+ foreach ($uninstaller in $uninstallers)
+ {
+ ### Invoke the uninstaller.
+ $uninstallerCommandLineOptions = "/SP- /VERYSILENT /SUPPRESSMSGBOXES /FORCECLOSEAPPLICATIONS"
+ Start-Process -Wait -FilePath $uninstaller -ArgumentList $uninstallerCommandLineOptions
+ }
+
+ ### Remove the folder if it didn't clean up properly.
+ if (Test-Path($installPath))
+ {
+ Remove-Item -Recurse -Force $installPath
+ }
+ }
+ }
+
+ if (!($foundAnInstallation))
+ {
+ Write-Host "No git installation found. Nothing to uninstall"
+ }
+ EOH
+ live_stream true
+end
+
powershell_script "sleep 1 second" do
code "Start-Sleep -s 1"
live_stream true