mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-23 05:01:37 +01:00
Update fetch-repos.ps1 and pull-repos.ps1
This commit is contained in:
parent
ae5a828ec2
commit
4ca038db30
@ -22,23 +22,23 @@ try {
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
||||
$FolderCount = $Folders.Count
|
||||
$NumFolders = $Folders.Count
|
||||
$ParentDirName = (get-item "$ParentDir").Name
|
||||
"Found $FolderCount subfolders in 📂$ParentDirName..."
|
||||
"Found $NumFolders subfolders in 📂$ParentDirName..."
|
||||
|
||||
[int]$Step = 1
|
||||
foreach ($Folder in $Folders) {
|
||||
$FolderName = (get-item "$Folder").Name
|
||||
"⏳ Step $Step/$($FolderCount): Fetching 📂$FolderName..."
|
||||
"⏳ Fetching 📂$FolderName... [step $Step/$NumFolders]"
|
||||
|
||||
& git -C "$Folder" fetch --all --recurse-submodules --prune --prune-tags --force
|
||||
if ($lastExitCode -ne "0") { throw "'git fetch' in $Folder failed" }
|
||||
if ($lastExitCode -ne "0") { throw "'git fetch' in $FolderName failed" }
|
||||
|
||||
$Step++
|
||||
}
|
||||
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ fetched $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec"
|
||||
"✔️ fetched $NumFolders Git repositories at 📂$ParentDirName in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -22,26 +22,26 @@ try {
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
||||
$FolderCount = $Folders.Count
|
||||
$NumFolders = $Folders.Count
|
||||
$ParentDirName = (get-item "$ParentDir").Name
|
||||
"Found $FolderCount subfolders in 📂$ParentDirName..."
|
||||
"Found $NumFolders subfolders in 📂$ParentDirName..."
|
||||
|
||||
[int]$Step = 1
|
||||
foreach ($Folder in $Folders) {
|
||||
$FolderName = (get-item "$Folder").Name
|
||||
"⏳ Step $Step/$($FolderCount): Pulling 📂$FolderName..."
|
||||
"⏳ Pulling 📂$FolderName... [step $Step/$NumFolders]"
|
||||
|
||||
& git -C "$Folder" pull --recurse-submodules --jobs=4
|
||||
if ($lastExitCode -ne "0") { write-warning "'git pull' on 📂$FolderName failed" }
|
||||
if ($lastExitCode -ne "0") { write-warning "'git pull' in 📂$FolderName failed" }
|
||||
|
||||
& git -C "$Folder" submodule update --init --recursive
|
||||
if ($lastExitCode -ne "0") { throw "'git submodule update' failed" }
|
||||
if ($lastExitCode -ne "0") { throw "'git submodule update' in 📂$FolderName failed" }
|
||||
|
||||
$Step++
|
||||
}
|
||||
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ pulled $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec"
|
||||
"✔️ pulled $NumFolders Git repositories at 📂$ParentDirName in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
Loading…
Reference in New Issue
Block a user