Add pull-repo.ps1

This commit is contained in:
Markus Fleschutz 2021-03-19 17:47:07 +01:00
parent 60351adce2
commit 9fad979652
3 changed files with 33 additions and 0 deletions

View File

@ -94,6 +94,7 @@ play-mp3.ps1, plays the given sound file (MP3 file format)
play-super-mario.ps1, plays the Super Mario Intro
play-the-imperial-march.ps1, plays the Imperial March (Star Wars)
poweroff.ps1, halts the local computer (requires admin rights)
pull-repo.ps1, pulls updates for the current/given Git repository (including submodules)
pull-repos.ps1, pulls updates for all Git repositories under the current/given directory (including submodules)
query-smart-data.ps1, queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory
new-email.ps1, starts the default email client to write a new email

1 Script Description
94 play-super-mario.ps1 plays the Super Mario Intro
95 play-the-imperial-march.ps1 plays the Imperial March (Star Wars)
96 poweroff.ps1 halts the local computer (requires admin rights)
97 pull-repo.ps1 pulls updates for the current/given Git repository (including submodules)
98 pull-repos.ps1 pulls updates for all Git repositories under the current/given directory (including submodules)
99 query-smart-data.ps1 queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory
100 new-email.ps1 starts the default email client to write a new email

View File

@ -110,6 +110,7 @@ Collection of PowerShell Scripts
* [list-branches.ps1](Scripts/list-branches.ps1) - lists all branches in the current/given Git repository
* [list-commits.ps1](Scripts/list-commits.ps1) - lists all commits in the current/given Git repository
* [list-tags.ps1](Scripts/list-tags.ps1) - lists all tags in the current/given Git repository
* [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)

31
Scripts/pull-repo.ps1 Executable file
View File

@ -0,0 +1,31 @@
#!/bin/powershell
<#
.SYNTAX ./pull-repo.ps1 [<repo-dir>]
.DESCRIPTION pulls updates for the current/given Git repository (including submodules)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($RepoDir = "$PWD")
try {
write-output "Pulling updates for Git repository $RepoDir ..."
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
set-location "$RepoDir"
& git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
& git pull --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git pull --recurse-submodules' failed" }
& git status
if ($lastExitCode -ne "0") { throw "'git status' failed" }
write-host -foregroundColor green "OK - pulled updates for Git repository $RepoDir"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}