mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-22 01:48:20 +02: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" }
|
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||||
|
|
||||||
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
||||||
$FolderCount = $Folders.Count
|
$NumFolders = $Folders.Count
|
||||||
$ParentDirName = (get-item "$ParentDir").Name
|
$ParentDirName = (get-item "$ParentDir").Name
|
||||||
"Found $FolderCount subfolders in 📂$ParentDirName..."
|
"Found $NumFolders subfolders in 📂$ParentDirName..."
|
||||||
|
|
||||||
[int]$Step = 1
|
[int]$Step = 1
|
||||||
foreach ($Folder in $Folders) {
|
foreach ($Folder in $Folders) {
|
||||||
$FolderName = (get-item "$Folder").Name
|
$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
|
& 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++
|
$Step++
|
||||||
}
|
}
|
||||||
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[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
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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" }
|
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||||
|
|
||||||
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
||||||
$FolderCount = $Folders.Count
|
$NumFolders = $Folders.Count
|
||||||
$ParentDirName = (get-item "$ParentDir").Name
|
$ParentDirName = (get-item "$ParentDir").Name
|
||||||
"Found $FolderCount subfolders in 📂$ParentDirName..."
|
"Found $NumFolders subfolders in 📂$ParentDirName..."
|
||||||
|
|
||||||
[int]$Step = 1
|
[int]$Step = 1
|
||||||
foreach ($Folder in $Folders) {
|
foreach ($Folder in $Folders) {
|
||||||
$FolderName = (get-item "$Folder").Name
|
$FolderName = (get-item "$Folder").Name
|
||||||
"⏳ Step $Step/$($FolderCount): Pulling 📂$FolderName..."
|
"⏳ Pulling 📂$FolderName... [step $Step/$NumFolders]"
|
||||||
|
|
||||||
& git -C "$Folder" pull --recurse-submodules --jobs=4
|
& 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
|
& 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++
|
$Step++
|
||||||
}
|
}
|
||||||
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[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
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
Loading…
Reference in New Issue
Block a user