mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-01 06:04:41 +02:00
Update list-commits.ps1
This commit is contained in:
parent
729e662ef0
commit
6baf8dba24
@ -1,12 +1,12 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Lists all commits in a Git repository
|
Lists Git commits
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script lists all commits in a Git repository. Supported output formats are: list, compact, normal or JSON.
|
This PowerShell script lists all commits in a Git repository. Supported output formats are: pretty, list, compact, normal or JSON.
|
||||||
.PARAMETER RepoDir
|
.PARAMETER RepoDir
|
||||||
Specifies the path to the Git repository.
|
Specifies the path to the Git repository.
|
||||||
.PARAMETER Format
|
.PARAMETER Format
|
||||||
Specifies the output format: list|compact|normal|JSON
|
Specifies the output format: pretty|list|compact|normal|JSON (pretty by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-commits
|
PS> ./list-commits
|
||||||
|
|
||||||
@ -21,7 +21,7 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([string]$RepoDir = "$PWD", [string]$Format = "list")
|
param([string]$RepoDir = "$PWD", [string]$Format = "pretty")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
||||||
@ -29,12 +29,15 @@ try {
|
|||||||
$Null = (git --version)
|
$Null = (git --version)
|
||||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||||
|
|
||||||
Write-Progress "🢃 Fetching latest tags..."
|
Write-Progress "⏳ Fetching latest updates..."
|
||||||
& git -C "$RepoDir" fetch --all --quiet
|
& git -C "$RepoDir" fetch --all --quiet
|
||||||
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
|
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
|
||||||
Write-Progress -Completed " "
|
Write-Progress -Completed " "
|
||||||
|
|
||||||
if ($Format -eq "list") {
|
if ($Format -eq "pretty") {
|
||||||
|
""
|
||||||
|
& git -C "$RepoDir" log --graph --format=format:'%h %C(bold green)%cs %C(bold yellow)%s%C(reset)%d by %C(bold blue)%an%C(reset)' --all
|
||||||
|
} elseif ($Format -eq "list") {
|
||||||
""
|
""
|
||||||
"Hash Date Author Description"
|
"Hash Date Author Description"
|
||||||
"---- ---- ------ -----------"
|
"---- ---- ------ -----------"
|
||||||
|
Loading…
Reference in New Issue
Block a user