mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-23 23:29:02 +01:00
Update sync-repo.ps1
This commit is contained in:
parent
45d72ecc4b
commit
b0330be96c
@ -16,22 +16,25 @@
|
||||
param([string]$RepoDir = "$PWD")
|
||||
|
||||
try {
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
"⏳ Step 1/3: Checking requirements..."
|
||||
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 ..."
|
||||
|
||||
$Null = (git --version)
|
||||
& git --version
|
||||
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" }
|
||||
|
||||
& 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" }
|
||||
|
||||
"✔️ synchronized Git repository 📂$RepoDirName"
|
||||
$RepoDirName = (Get-Item "$RepoDir").Name
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ synchronized Git repo 📂$RepoDirName in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
Loading…
Reference in New Issue
Block a user