Improve the output

This commit is contained in:
Markus Fleschutz
2021-05-07 14:47:06 +02:00
parent 4f74a5f1ce
commit 899a5b0816
3 changed files with 29 additions and 31 deletions

View File

@ -11,27 +11,24 @@ try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
set-location $ParentDir
$Null = (git --version)
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
[int]$Count = 0
get-childItem $ParentDir -attributes Directory | foreach-object {
"🢃 Fetching updates for Git repository 📂$($_.Name) ..."
$Folders = (get-childItem "$ParentDir" -attributes Directory)
$ParentDirName = (get-item "$ParentDir").Name
"Fetching updates for $($Folders.Count) Git repositories at 📂$ParentDirName..."
set-location "$($_.FullName)"
foreach ($Folder in $Folders) {
$FolderName = (get-item "$Folder").Name
"🢃 Fetching 📂$FolderName ..."
& git fetch --all --recurse-submodules --jobs=4
& git -C "$Folder" fetch --all --recurse-submodules --jobs=4
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
set-location ..
$Count++
}
$ParentDirName = (get-item "$ParentDir").Name
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ fetched $Count Git repositories at 📂$ParentDirName in $Elapsed sec."
"✔️ fetched $($Folders.Count) Git repositories at 📂$ParentDirName in $Elapsed sec."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"