mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-25 05:26:47 +01:00
Improve output of fetch-repo.ps1 and pull-repo.ps1
This commit is contained in:
parent
bb5e5d4b82
commit
e9dd4329b0
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
.SYNTAX fetch-repo.ps1 [<repo-dir>]
|
||||
.DESCRIPTION fetches updates for the current/given Git repository (including submodules)
|
||||
.DESCRIPTION fetches updates for a local Git repository (including submodules)
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
@ -9,14 +9,18 @@
|
||||
param($RepoDir = "$PWD")
|
||||
|
||||
try {
|
||||
"⏳ Fetching updates for Git repository $($RepoDir)..."
|
||||
|
||||
$RepoDir = resolve-path "$RepoDir"
|
||||
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
||||
set-location "$RepoDir"
|
||||
|
||||
"⏳ Fetching updates for Git repository 📂$RepoDir ..."
|
||||
|
||||
$Null = (git --version)
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
& git fetch --all --recurse-submodules --jobs=4
|
||||
if ($lastExitCode -ne "0") {
|
||||
# retry once:
|
||||
write-warning "Retrying once ..."
|
||||
start-sleep -milliseconds 1000
|
||||
& git fetch --all --recurse-submodules --jobs=1
|
||||
if ($lastExitCode -ne "0") { throw "'git fetch' failed (twice)" }
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
.SYNTAX pull-repo.ps1 [<repo-dir>]
|
||||
.DESCRIPTION pulls updates a Git repository (including submodules)
|
||||
.DESCRIPTION pulls updates for a local Git repository (including submodules)
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
@ -9,10 +9,11 @@
|
||||
param($RepoDir = "$PWD")
|
||||
|
||||
try {
|
||||
"⏳ Pulling updates for Git repository $($RepoDir)..."
|
||||
|
||||
$RepoDir = resolve-path "$RepoDir"
|
||||
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
||||
set-location "$RepoDir"
|
||||
|
||||
"⏳ Updating Git repository 📂$RepoDir ..."
|
||||
|
||||
$Null = (git --version)
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
@ -20,7 +21,7 @@ try {
|
||||
& git pull --all --recurse-submodules --jobs=4
|
||||
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
||||
|
||||
"✔️ Git repository $RepoDir is up to date"
|
||||
"✔️ updated Git repository 📂$RepoDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user