mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-15 01:16:41 +02:00
Improve pull-repo.ps1
This commit is contained in:
parent
f0d82b8342
commit
eaa88e8c97
@ -13,13 +13,13 @@ try {
|
|||||||
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
||||||
set-location "$RepoDir"
|
set-location "$RepoDir"
|
||||||
|
|
||||||
$Null = (git --version)
|
|
||||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
|
||||||
|
|
||||||
$Result = (git status)
|
$Result = (git status)
|
||||||
|
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||||
if ("$Result" -match "HEAD detached at ") {
|
if ("$Result" -match "HEAD detached at ") {
|
||||||
write-warning "Not on a branch, so nothing to pull (in detached HEAD state)"
|
write-warning "Not on a branch, so nothing to pull (in detached HEAD state)"
|
||||||
} else {
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
"🢃 Pulling updates..."
|
"🢃 Pulling updates..."
|
||||||
& git pull --recurse-submodules --jobs=4
|
& git pull --recurse-submodules --jobs=4
|
||||||
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
||||||
@ -27,7 +27,6 @@ try {
|
|||||||
$RepoDirName = (get-item "$RepoDir").Name
|
$RepoDirName = (get-item "$RepoDir").Name
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ pulled updates for Git repository 📂$RepoDirName in $Elapsed sec"
|
"✔️ pulled updates for Git repository 📂$RepoDirName 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…
x
Reference in New Issue
Block a user