Added list-branches.ps1

This commit is contained in:
Markus Fleschutz
2021-02-28 18:26:20 +01:00
parent b0772a7f93
commit 032113200c
5 changed files with 43 additions and 19 deletions

27
Scripts/list-branches.ps1 Executable file
View File

@ -0,0 +1,27 @@
#!/bin/powershell
<#
.SYNTAX ./list-branches.ps1 [<repo-dir>]
.DESCRIPTION lists the branches of the current/given Git repository
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($RepoDir = "$PWD")
try {
$null = $(git --version)
} catch {
write-error "ERROR: can't execute 'git' - make sure Git is installed and available"
exit 1
}
try {
set-location $RepoDir
& git branch --list --no-color --no-column
if ($lastExitCode -ne "0") { throw "'git branch' failed" }
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}