From eaa88e8c972f4b70c555a31c3601f939ec639daa Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Tue, 8 Jun 2021 14:03:12 +0200 Subject: [PATCH] Improve pull-repo.ps1 --- Scripts/pull-repo.ps1 | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Scripts/pull-repo.ps1 b/Scripts/pull-repo.ps1 index dddba146..9425f75a 100755 --- a/Scripts/pull-repo.ps1 +++ b/Scripts/pull-repo.ps1 @@ -13,21 +13,20 @@ try { if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $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) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } if ("$Result" -match "HEAD detached at ") { write-warning "Not on a branch, so nothing to pull (in detached HEAD state)" - } else { - "🢃 Pulling updates..." - & git pull --recurse-submodules --jobs=4 - if ($lastExitCode -ne "0") { throw "'git pull' failed" } + exit 0 + } - $RepoDirName = (get-item "$RepoDir").Name - [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds - "✔️ pulled updates for Git repository 📂$RepoDirName in $Elapsed sec" - } + "🢃 Pulling updates..." + & git pull --recurse-submodules --jobs=4 + if ($lastExitCode -ne "0") { throw "'git pull' failed" } + + $RepoDirName = (get-item "$RepoDir").Name + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "✔️ pulled updates for Git repository 📂$RepoDirName in $Elapsed sec" exit 0 } catch { write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"