Update fetch-repos.ps1 and pull-repos.ps1

This commit is contained in:
Markus Fleschutz 2023-08-03 07:35:51 +02:00
parent ccc7da102b
commit 882d0d4e7a
2 changed files with 12 additions and 6 deletions

View File

@ -7,6 +7,10 @@
Specifies the path to the parent folder Specifies the path to the parent folder
.EXAMPLE .EXAMPLE
PS> ./fetch-repos C:\MyRepos PS> ./fetch-repos C:\MyRepos
(1) Searching for Git executable... git version 2.41.0.windows.3
(2) Checking parent folder... 33 subfolders
(3/35) Fetching into 📂base256unicode...
...
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -27,7 +31,7 @@ try {
$Folders = (Get-ChildItem "$ParentDir" -attributes Directory) $Folders = (Get-ChildItem "$ParentDir" -attributes Directory)
$NumFolders = $Folders.Count $NumFolders = $Folders.Count
$ParentDirName = (Get-Item "$ParentDir").Name $ParentDirName = (Get-Item "$ParentDir").Name
Write-Host "$NumFolders subfolders in 📂$ParentDirName" Write-Host "$NumFolders subfolders"
[int]$Step = 2 [int]$Step = 2
foreach ($Folder in $Folders) { foreach ($Folder in $Folders) {
@ -39,7 +43,7 @@ try {
if ($lastExitCode -ne "0") { throw "'git fetch' in $Folder failed with exit code $lastExitCode" } if ($lastExitCode -ne "0") { throw "'git fetch' in $Folder failed with exit code $lastExitCode" }
} }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ fetched $NumFolders Git repositories in 📂$ParentDirName in $Elapsed sec." "✔️ Fetching updates for $NumFolders repositories in 📂$ParentDirName 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])"

View File

@ -7,6 +7,10 @@
Specifies the path to the parent folder Specifies the path to the parent folder
.EXAMPLE .EXAMPLE
PS> ./pull-repos C:\MyRepos PS> ./pull-repos C:\MyRepos
(1) Searching for Git executable... git version 2.41.0.windows.3
(2) Checking parent folder... 33 subfolders
(3/35) Pulling into 📂base256unicode...
...
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -27,7 +31,7 @@ try {
$Folders = (Get-ChildItem "$ParentDir" -attributes Directory) $Folders = (Get-ChildItem "$ParentDir" -attributes Directory)
$NumFolders = $Folders.Count $NumFolders = $Folders.Count
$ParentDirName = (Get-Item "$ParentDir").Name $ParentDirName = (Get-Item "$ParentDir").Name
Write-Host "$NumFolders subfolders in 📂$ParentDirName" Write-Host "$NumFolders subfolders"
[int]$Step = 3 [int]$Step = 3
[int]$Failed = 0 [int]$Failed = 0
@ -40,12 +44,10 @@ try {
& git -C "$Folder" submodule update --init --recursive & git -C "$Folder" submodule update --init --recursive
if ($lastExitCode -ne "0") { throw "'git submodule update' in 📂$Folder failed with exit code $lastExitCode" } if ($lastExitCode -ne "0") { throw "'git submodule update' in 📂$Folder failed with exit code $lastExitCode" }
$Step++ $Step++
} }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ pulled $NumFolders Git repositories in 📂$ParentDirName in $Elapsed sec ($Failed failed)." "✔️ Pulling updates for $NumFolders repositories in 📂$ParentDirName took $Elapsed sec ($Failed failed)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"