From 55f9c2e19f65cc8a456efa0e12d8ed4606ebc7fc Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Thu, 15 Apr 2021 13:37:42 +0200 Subject: [PATCH] Improve both scripts --- Scripts/fetch-repo.ps1 | 13 +++++++------ Scripts/fetch-repos.ps1 | 8 ++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Scripts/fetch-repo.ps1 b/Scripts/fetch-repo.ps1 index 681023d8..8c2e6dd9 100755 --- a/Scripts/fetch-repo.ps1 +++ b/Scripts/fetch-repo.ps1 @@ -9,7 +9,7 @@ param($RepoDir = "$PWD") try { - write-output "Fetching updates for Git repository $RepoDir ..." + "Fetching updates for Git repository $RepoDir ..." if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } set-location "$RepoDir" @@ -17,11 +17,12 @@ try { & git --version if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } - & git fetch --all --recurse-submodules - if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" } - - & git status - if ($lastExitCode -ne "0") { throw "'git status' failed" } + & git fetch --all --recurse-submodules --jobs=4 + if ($lastExitCode -ne "0") { # retry once: + start-sleep -milliseconds 1000 + & git fetch --all --recurse-submodules --jobs=1 + if ($lastExitCode -ne "0") { throw "'git fetch' failed" } + } write-host -foregroundColor green "OK - fetched updates for Git repository $RepoDir" exit 0 diff --git a/Scripts/fetch-repos.ps1 b/Scripts/fetch-repos.ps1 index 48858b98..658be79f 100755 --- a/Scripts/fetch-repos.ps1 +++ b/Scripts/fetch-repos.ps1 @@ -20,13 +20,9 @@ try { [int]$Count = 0 get-childItem $ParentDir -attributes Directory | foreach-object { - "Fetching updates for $($_.FullName)..." - set-location $_.FullName + & "$PSScriptRoot/fetch-repo.ps1" "$($_.FullName)" + if ($lastExitCode -ne "0") { throw "Script 'fetch-repo.ps1' failed" } - & git fetch --all --recurse-submodules - if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" } - - set-location .. $Count++ }