mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-17 02:01:01 +01:00
Update list-commmits-live.ps1
This commit is contained in:
parent
a11c9953b9
commit
4cc43302c2
@ -3,7 +3,7 @@
|
|||||||
List commits live in real-time.
|
List commits live in real-time.
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script permanently lists the latest commit in a Git repository in real-time.
|
This PowerShell script permanently lists the latest commit in a Git repository in real-time.
|
||||||
.PARAMETER RepoDir
|
.PARAMETER pathToRepo
|
||||||
Specifies the file path to the local Git repository.
|
Specifies the file path to the local Git repository.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./commit-ticker.ps1
|
PS> ./commit-ticker.ps1
|
||||||
@ -15,7 +15,7 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([string]$RepoDir = "$PWD")
|
param([string]$pathToRepo = "$PWD")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Write-Progress "Searching for Git executable..."
|
Write-Progress "Searching for Git executable..."
|
||||||
@ -23,21 +23,22 @@ try {
|
|||||||
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 "Checking file patch to Git repository..."
|
Write-Progress "Checking file patch to Git repository..."
|
||||||
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
if (-not(Test-Path "$pathToRepo" -pathType container)) { throw "Can't access directory: $pathToRepo" }
|
||||||
Write-Progress -completed "Done."
|
Write-Progress -completed "Done."
|
||||||
|
|
||||||
$linePrev = ""
|
$linePrev = ""
|
||||||
for (;;) {
|
for (;;) {
|
||||||
& git -C "$RepoDir" fetch --all --recurse-submodules=no --jobs=1 --quiet
|
& git -C "$pathToRepo" fetch --all --recurse-submodules=no --jobs=1 --quiet
|
||||||
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
|
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
|
||||||
|
|
||||||
$lineNow = (git -C "$RepoDir" log --format=format:'%s by %an%d' -n 1)
|
$lineNow = (git -C "$pathToRepo" log origin --format=format:'%s by %an%d' --max-count=1)
|
||||||
if ($lineNow -ne $linePrev) {
|
if ($lineNow -ne $linePrev) {
|
||||||
Write-Host "❇️ $lineNow"
|
Write-Host "❇️ $lineNow"
|
||||||
$linePrev = $lineNow
|
$linePrev = $lineNow
|
||||||
}
|
} else {
|
||||||
Start-Sleep -seconds 10
|
Start-Sleep -seconds 10
|
||||||
}
|
}
|
||||||
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user