mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-23 23:29:02 +01:00
Improve sync-repo.ps1
This commit is contained in:
parent
0f9dcffc68
commit
c927d7263c
@ -171,7 +171,7 @@ speak-text.ps1, speaks the given text by text-to-speech (TTS)
|
||||
speak-time.ps1, speaks the current time by text-to-speech (TTS)
|
||||
switch-branch.ps1, switches the branch in the current/given Git repository (including submodules)
|
||||
switch-shelly1.ps1, switches a Shelly1 device in the local network
|
||||
sync-repo.ps1, synchronizes a Git repository (pull&push, including submodules)
|
||||
sync-repo.ps1, synchronizes a Git repository by push & pull (including submodules)
|
||||
take-screenshot.ps1, takes a single screenshot
|
||||
take-screenshots.ps1, takes multiple screenshots
|
||||
translate-file.ps1, translates the given text file into another language
|
||||
|
Can't render this file because it has a wrong number of fields in line 174.
|
@ -150,7 +150,7 @@ Mega Collection of PowerShell Scripts
|
||||
* [pull-repo.ps1](Scripts/pull-repo.ps1) - pulls updates for the current/given Git repository (including submodules)
|
||||
* [pull-repos.ps1](Scripts/pull-repos.ps1) - pulls updates for all Git repositories under the current/given directory (including submodules)
|
||||
* [switch-branch.ps1](Scripts/switch-branch.ps1) - switches the branch in the current/given Git repository (including submodules)
|
||||
* [sync-repo.ps1](Scripts/sync-repo.ps1) - synchronizes a Git repository (pull&push, including submodules)
|
||||
* [sync-repo.ps1](Scripts/sync-repo.ps1) - synchronizes a Git repository by push & pull (including submodules)
|
||||
|
||||
🔎 Scripts for PowerShell
|
||||
------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
<#
|
||||
.SYNTAX sync-repo.ps1 [<repo-dir>]
|
||||
.DESCRIPTION synchronizes a Git repository by pull & push (including submodules)
|
||||
.DESCRIPTION synchronizes a Git repository by push & pull (including submodules)
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
@ -8,21 +8,22 @@
|
||||
param($RepoDir = "$PWD")
|
||||
|
||||
try {
|
||||
"⏳ Synchronizing Git repository 📂$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 ..."
|
||||
|
||||
$Null = (git --version)
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
& git pull --all --recurse-submodules --jobs=4
|
||||
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
||||
|
||||
& git push
|
||||
if ($lastExitCode -ne "0") { throw "'git push' failed" }
|
||||
|
||||
"✔️ synchronized Git repository 📂$RepoDir"
|
||||
& git pull --all --recurse-submodules --jobs=4
|
||||
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
||||
|
||||
"✔️ synchronized Git repository 📂$RepoDirName"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user