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

@ -41,7 +41,7 @@ list-aliases.ps1, lists all PowerShell aliases
list-anagrams.ps1, lists all anagrams of the given word
list-automatic-variables.ps1, lists the automatic variables of PowerShell
list-branches.ps1, lists the branches of the current/given Git repository
list-commits.ps1, lists the commits of the current/given Git repository in the given branch
list-commits.ps1, lists the commits of the current/given Git repository
list-current-timezone.ps1, lists the current time zone details
list-clipboard.ps1, lists the contents of the clipboard
list-environment-variables.ps1, lists all environment variables

1 Script Description
41 list-anagrams.ps1 lists all anagrams of the given word
42 list-automatic-variables.ps1 lists the automatic variables of PowerShell
43 list-branches.ps1 lists the branches of the current/given Git repository
44 list-commits.ps1 lists the commits of the current/given Git repository in the given branch lists the commits of the current/given Git repository
45 list-current-timezone.ps1 lists the current time zone details
46 list-clipboard.ps1 lists the contents of the clipboard
47 list-environment-variables.ps1 lists all environment variables

View File

@ -103,7 +103,7 @@ Collection of PowerShell Scripts
* [fetch-repo.ps1](Scripts/fetch-repo.ps1) - fetches a single Git repository at the current/given directory (including submodules)
* [fetch-repos.ps1](Scripts/fetch-repos.ps1) - fetches all Git repositories under the current/given directory (including submodules)
* [list-branches.ps1](Scripts/list-branches.ps1) - lists the branches of the current/given Git repository
* [list-commits.ps1](Scripts/list-commits.ps1) - lists the commits of the current/given Git repository in the given branch
* [list-commits.ps1](Scripts/list-commits.ps1) - lists the commits of the current/given Git repository
* [switch-branch.ps1](Scripts/switch-branch.ps1) - switches the current Git repository to the given branch (including submodules)
* [update-repos.ps1](Scripts/update-repos.ps1) - updates all Git repositories under the current/given directory (including submodules)

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