mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 17:14:28 +01:00
Update pull-repo.ps1
This commit is contained in:
parent
60024da825
commit
3ccf9d1124
@ -19,14 +19,13 @@ try {
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
"⏳ Step 1/3: Checking requirements... "
|
||||
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
||||
|
||||
$Result = (git -C "$RepoDir" status)
|
||||
& git --version
|
||||
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)"
|
||||
exit 0 # success
|
||||
}
|
||||
|
||||
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access folder: $RepoDir" }
|
||||
|
||||
$Result = (git -C "$RepoDir" status)
|
||||
if ("$Result" -match "HEAD detached at ") { throw "Not on a branch, so nothing to pull (in detached HEAD state)" }
|
||||
|
||||
"⏳ Step 2/3: Pulling updates... "
|
||||
& git -C "$RepoDir" pull --recurse-submodules --jobs=4
|
||||
@ -39,8 +38,9 @@ try {
|
||||
$RepoDirName = (Get-Item "$RepoDir").Name
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ pulled updates for Git repository 📂$RepoDirName in $Elapsed sec"
|
||||
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
"⚠️ Error $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user