mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-12 22:17:17 +02:00
Improved check for $lastExitCode
This commit is contained in:
@ -26,11 +26,11 @@ try {
|
||||
if (-not(Test-Path "$pathToRepo" -pathType container)) { throw "Can't access directory: $pathToRepo" }
|
||||
|
||||
$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 updates..."
|
||||
& git -C "$pathToRepo" fetch --all --quiet
|
||||
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
|
||||
if ($lastExitCode -ne 0) { throw "'git fetch' failed" }
|
||||
Write-Progress -Completed "Done."
|
||||
|
||||
if ($format -eq "pretty") {
|
||||
@ -46,7 +46,7 @@ try {
|
||||
"List of Git Commits"
|
||||
"-------------------"
|
||||
& git -C "$pathToRepo" 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" }
|
||||
if ($lastExitCode -ne 0) { throw "'git log' failed" }
|
||||
} elseif ($format -eq "JSON") {
|
||||
& git -C "$pathToRepo" log --pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},'
|
||||
} else {
|
||||
@ -54,7 +54,7 @@ try {
|
||||
"List of Git Commits"
|
||||
"-------------------"
|
||||
& git -C "$pathToRepo" log
|
||||
if ($lastExitCode -ne "0") { throw "'git log' failed" }
|
||||
if ($lastExitCode -ne 0) { throw "'git log' failed" }
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
Reference in New Issue
Block a user