mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-17 02:01:01 +01:00
Add pull-repo.ps1
This commit is contained in:
parent
60351adce2
commit
9fad979652
@ -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
|
||||
|
|
@ -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
31
Scripts/pull-repo.ps1
Executable 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user