mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 09:04:18 +01:00
Update sync-repo.ps1
This commit is contained in:
parent
99c5a5e240
commit
ad4fc918ef
@ -1,8 +1,8 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Syncs a Git repo
|
||||
Synchronizes a repo
|
||||
.DESCRIPTION
|
||||
This PowerShell script synchronizes a Git repository by push & pull (including submodules).
|
||||
This PowerShell script synchronizes a local Git repository by push and pull (including submodules).
|
||||
.PARAMETER RepoDir
|
||||
Specifies the path to the Git repository
|
||||
.EXAMPLE
|
||||
@ -22,9 +22,9 @@ try {
|
||||
& git --version
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
$RepoDirName = (Get-Item "$RepoDir").Name
|
||||
Write-Host "⏳ (2/4) Checking Git repository... 📂$RepoDirName"
|
||||
Write-Host "⏳ (2/4) Checking local repository... 📂$RepoDir"
|
||||
if (!(Test-Path "$RepoDir" -pathType container)) { throw "Can't access folder: $RepoDir" }
|
||||
$RepoDirName = (Get-Item "$RepoDir").Name
|
||||
|
||||
Write-Host "⏳ (3/4) Pushing local updates... " -noNewline
|
||||
& git -C "$RepoDir" push
|
||||
@ -35,7 +35,7 @@ try {
|
||||
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
||||
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ synchronized 📂$RepoDirName repository in $Elapsed sec."
|
||||
"✔️ synchronized repo 📂$RepoDirName in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user