Update fetch-repo.ps1

This commit is contained in:
Markus Fleschutz 2023-07-30 21:10:46 +02:00
parent 24561ea5f3
commit d81531ee34

View File

@ -22,16 +22,16 @@ try {
& git --version & git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
Write-Host "⏳ (2/3) Checking repository... 📂$RepoDir" Write-Host "⏳ (2/3) Checking local folder ... 📂$RepoDir"
if (!(Test-Path "$RepoDir" -pathType container)) { throw "Can't access folder: $RepoDir" } if (!(Test-Path "$RepoDir" -pathType container)) { throw "Can't access folder: $RepoDir" }
$RepoDirName = (Get-Item "$RepoDir").Name $RepoDirName = (Get-Item "$RepoDir").Name
Write-Host "⏳ (3/3) Fetching updates... " Write-Host "⏳ (3/3) Fetching updates... " -noNewline
& git -C "$RepoDir" fetch --all --recurse-submodules --prune --prune-tags --force & git -C "$RepoDir" fetch --all --recurse-submodules --tags --prune --prune-tags --force
if ($lastExitCode -ne "0") { throw "'git fetch' failed with exit code $lastExitCode" } if ($lastExitCode -ne "0") { throw "'git fetch --all' failed with exit code $lastExitCode" }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ fetched updates into repo 📂$RepoDirName in $Elapsed sec" "✔️ Fetching updates into 📂$RepoDirName repo took $Elapsed sec"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"