Improved list-commits.ps1

This commit is contained in:
Markus Fleschutz
2021-03-10 16:00:16 +01:00
parent 9d4b5a7b18
commit df7587b122
6 changed files with 19 additions and 20 deletions

View File

@ -17,8 +17,8 @@ try {
& git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
& git fetch --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git fetch --recurse-submodules' failed" }
& git fetch --all --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" }
& git status
if ($lastExitCode -ne "0") { throw "'git status' failed" }

View File

@ -21,8 +21,8 @@ try {
get-childItem $ParentDir -attributes Directory | foreach-object {
set-location $_.FullName
& git fetch --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git fetch --recurse-submodules' failed" }
& git fetch --all --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" }
set-location ..
}

View File

@ -17,8 +17,8 @@ try {
$null = (git --version)
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
& git fetch --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git fetch --recurse-submodules' failed" }
& git fetch --all --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" }
$Branches = $(git branch --list --remotes --no-color --no-column)
if ($lastExitCode -ne "0") { throw "'git branch --list' failed" }

View File

@ -1,12 +1,12 @@
#!/bin/powershell
<#
.SYNTAX ./list-commits.ps1 [<repo-dir>] [<branch>]
.DESCRIPTION lists all commits of the current/given Git repository in the given branch
.SYNTAX ./list-commits.ps1 [<repo-dir>] [<format>]
.DESCRIPTION lists all commits of the current/given Git repository
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($RepoDir = "$PWD", $Branch = "main")
param($RepoDir = "$PWD", $Format = "compact")
try {
write-output "Listing commits of Git repository $RepoDir ..."
@ -17,16 +17,15 @@ try {
$null = (git --version)
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
& git switch --recurse-submodules $Branch
if ($lastExitCode -ne "0") { throw "'git switch --recurse-submodules $Branch' failed" }
& git fetch --all --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" }
& git submodule update --init --recursive
if ($lastExitCode -ne "0") { throw "'git submodule update' failed" }
& git pull --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
& git log
if ($Format -eq "compact") {
& git log --pretty=format:'%Cred%h%Creset %C(yellow)%d%Creset %s %C(bold blue)by %an %cr%Creset' --abbrev-commit
} else {
& git log
}
if ($lastExitCode -ne "0") { throw "'git log' failed" }
exit 0