mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-24 13:40:59 +01:00
Update fetch-repos.ps1 and pull-repos.ps1
This commit is contained in:
parent
fc97a6054b
commit
0501b9cd26
@ -16,19 +16,20 @@ 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
|
||||||
$ParentDirName = (get-item "$ParentDir").Name
|
$ParentDirName = (get-item "$ParentDir").Name
|
||||||
"Fetching updates for $($Folders.Count) Git repositories at 📂$ParentDirName..."
|
"Fetching updates for $FolderCount Git repositories at 📂$ParentDirName..."
|
||||||
|
|
||||||
foreach ($Folder in $Folders) {
|
foreach ($Folder in $Folders) {
|
||||||
$FolderName = (get-item "$Folder").Name
|
$FolderName = (get-item "$Folder").Name
|
||||||
"🢃 Fetching 📂$FolderName ..."
|
"🢃 Fetching 📂$FolderName..."
|
||||||
|
|
||||||
& git -C "$Folder" fetch --all --recurse-submodules --jobs=4
|
& git -C "$Folder" fetch --all --recurse-submodules --jobs=4
|
||||||
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
|
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
|
||||||
}
|
}
|
||||||
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ fetched $($Folders.Count) Git repositories at 📂$ParentDirName in $Elapsed sec."
|
"✔️ fetched $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -16,12 +16,13 @@ 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
|
||||||
$ParentDirName = (get-item "$ParentDir").Name
|
$ParentDirName = (get-item "$ParentDir").Name
|
||||||
"Pulling updates for $($Folders.Count) Git repositories at 📂$ParentDirName ..."
|
"Pulling updates for $FolderCount Git repositories at 📂$ParentDirName..."
|
||||||
|
|
||||||
foreach ($Folder in $Folders) {
|
foreach ($Folder in $Folders) {
|
||||||
$FolderName = (get-item "$Folder").Name
|
$FolderName = (get-item "$Folder").Name
|
||||||
"🢃 Pulling 📂$FolderName ..."
|
"🢃 Pulling 📂$FolderName..."
|
||||||
|
|
||||||
& git -C "$Folder" pull --recurse-submodules --jobs=4
|
& git -C "$Folder" pull --recurse-submodules --jobs=4
|
||||||
if ($lastExitCode -ne "0") {
|
if ($lastExitCode -ne "0") {
|
||||||
@ -30,7 +31,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ updated $($Folders.Count) Git repositories at 📂$ParentDirName in $Elapsed sec."
|
"✔️ updated $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user