Updated list-branches.ps1 and list-commits.ps1

This commit is contained in:
Markus Fleschutz 2021-03-15 13:43:35 +01:00
parent 3485a5c4b8
commit ffabb1c8c6
2 changed files with 12 additions and 7 deletions

View File

@ -9,7 +9,7 @@
param($RepoDir = "$PWD", $Pattern = "*")
try {
write-progress "Fetching changes in repository $RepoDir ..."
write-output "Fetching changes in repository $RepoDir ..."
if (-not(test-path "$RepoDir")) { throw "Can't access Git repository directory: $RepoDir" }
set-location $RepoDir
@ -20,7 +20,9 @@ try {
& git fetch --all --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" }
write-output "List of Git branches in repository $($RepoDir):"
write-output ""
write-output "List of Git Branches"
write-output "--------------------"
$Branches = $(git branch --list --remotes --no-color --no-column)
if ($lastExitCode -ne "0") { throw "'git branch --list' failed" }
@ -30,6 +32,7 @@ try {
if ("$BranchName" -notlike "$Pattern") { continue }
write-output "$BranchName"
}
write-output ""
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -9,7 +9,7 @@
param($RepoDir = "$PWD", $Format = "compact")
try {
write-progress "Fetching changes in Git repository $RepoDir ..."
write-output "Fetching changes in Git repository $RepoDir ..."
if (-not(test-path "$RepoDir")) { throw "Can't access Git repository directory: $RepoDir" }
set-location $RepoDir
@ -20,15 +20,17 @@ try {
& git fetch --all --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" }
write-output "List of commits in Git repository $($RepoDir):"
write-output ""
write-output "List of Git Commits"
write-output "-------------------"
if ($Format -eq "compact") {
& git log --graph --pretty=format:'%Cred%h%Creset%C(yellow)%d%Creset %s %C(bold blue)by %an %cr%Creset' --abbrev-commit
if ($lastExitCode -ne "0") { throw "'git log' failed" }
} else {
& git log
if ($lastExitCode -ne "0") { throw "'git log' failed" }
}
if ($lastExitCode -ne "0") { throw "'git log' failed" }
write-output ""
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"