mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-12 13:08:17 +02:00
Improve fetch-repos.ps1 and pull-repos.ps1
This commit is contained in:
parent
c0f1301ac4
commit
2a2320603c
@ -9,28 +9,27 @@
|
|||||||
param($ParentDir = "$PWD")
|
param($ParentDir = "$PWD")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$null = $(git --version)
|
"Fetching updates for Git repositories under $ParentDir ..."
|
||||||
} catch {
|
|
||||||
write-error "ERROR: can't execute 'git' - make sure Git is installed and available"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
write-progress "Fetching updates for Git repositories under $ParentDir ..."
|
|
||||||
|
|
||||||
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
||||||
set-location $ParentDir
|
set-location $ParentDir
|
||||||
|
|
||||||
|
& 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 {
|
get-childItem $ParentDir -attributes Directory | foreach-object {
|
||||||
|
"Fetching Git repository $($_.FullName) ..."
|
||||||
set-location $_.FullName
|
set-location $_.FullName
|
||||||
|
|
||||||
& git fetch --all --recurse-submodules
|
& git fetch --all --recurse-submodules
|
||||||
if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" }
|
if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" }
|
||||||
|
|
||||||
set-location ..
|
set-location ..
|
||||||
|
$Count++
|
||||||
}
|
}
|
||||||
|
|
||||||
write-host -foregroundColor green "OK - fetched updates for Git repositories under $ParentDir"
|
write-host -foregroundColor green "OK - fetched updates for $Count Git repositories under $ParentDir"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -9,28 +9,27 @@
|
|||||||
param($ParentDir = "$PWD")
|
param($ParentDir = "$PWD")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
& git --version
|
"Pulling updates for Git repositories under $ParentDir ..."
|
||||||
} catch {
|
|
||||||
write-error "ERROR: can't execute 'git' - make sure Git is installed and available"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
write-progress "Pulling updates for Git repositories under $ParentDir ..."
|
|
||||||
|
|
||||||
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
||||||
set-location "$ParentDir"
|
set-location "$ParentDir"
|
||||||
|
|
||||||
|
& 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 {
|
get-childItem $ParentDir -attributes Directory | foreach-object {
|
||||||
|
"Pulling Git repository $($_.FullName)..."
|
||||||
|
|
||||||
set-location $_.FullName
|
set-location $_.FullName
|
||||||
write-host ""
|
|
||||||
write-host -nonewline "Pulling $($_.FullName)..."
|
|
||||||
|
|
||||||
& git pull --recurse-submodules
|
& git pull --recurse-submodules
|
||||||
if ($lastExitCode -ne "0") { throw "'git pull --recurse-submodules' failed" }
|
if ($lastExitCode -ne "0") { throw "'git pull --recurse-submodules' failed" }
|
||||||
|
|
||||||
set-location ..
|
set-location ..
|
||||||
|
$Count++
|
||||||
}
|
}
|
||||||
|
write-host -foregroundColor green "OK - pulled updates for $Count Git repositories under $ParentDir"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user