mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-12 08:58:16 +01:00
Update sync-repo.ps1
This commit is contained in:
parent
45d72ecc4b
commit
b0330be96c
@ -16,22 +16,25 @@
|
|||||||
param([string]$RepoDir = "$PWD")
|
param([string]$RepoDir = "$PWD")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
|
"⏳ Step 1/3: Checking requirements..."
|
||||||
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"
|
|
||||||
$RepoDirName = (Get-Item "$RepoDir").Name
|
|
||||||
|
|
||||||
"⏳ Synchronizing Git repository 📂$RepoDirName ..."
|
& git --version
|
||||||
|
|
||||||
$Null = (git --version)
|
|
||||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||||
|
|
||||||
& git push
|
"⏳ Step 2/3: Pushing local updates..."
|
||||||
|
& git -C "$RepoDir" push
|
||||||
if ($lastExitCode -ne "0") { throw "'git push' failed" }
|
if ($lastExitCode -ne "0") { throw "'git push' failed" }
|
||||||
|
|
||||||
& git pull --all --recurse-submodules --jobs=4
|
"⏳ Step 3/3: Pulling remote updates..."
|
||||||
|
& git -C "$RepoDir" pull --all --recurse-submodules --jobs=4
|
||||||
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
||||||
|
|
||||||
"✔️ synchronized Git repository 📂$RepoDirName"
|
$RepoDirName = (Get-Item "$RepoDir").Name
|
||||||
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
|
"✔️ synchronized Git repo 📂$RepoDirName in $Elapsed sec"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
Loading…
Reference in New Issue
Block a user