mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 16:03:22 +01:00
Improved list-commits.ps1
This commit is contained in:
parent
9d4b5a7b18
commit
df7587b122
@ -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
|
||||
|
|
@ -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)
|
||||
|
||||
|
@ -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" }
|
||||
|
@ -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 ..
|
||||
}
|
||||
|
@ -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" }
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user