mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-17 08:01:31 +02:00
Updated the manuals
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
The *watch-commits.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script continuously lists the latest commit in a Git repository in real-time.
|
||||
This PowerShell script continuously lists the latest commits in a Git repository in real-time.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
/home/markus/Repos/PowerShell/scripts/watch-commits.ps1 [[-pathToRepo] <String>] [[-updateInterval] <Int32>] [[-speed] <Int32>] [<CommonParameters>]
|
||||
/Repos/PowerShell/scripts/watch-commits.ps1 [[-pathToRepo] <String>] [[-updateInterval] <Int32>] [[-speed] <Int32>] [<CommonParameters>]
|
||||
|
||||
-pathToRepo <String>
|
||||
Specifies the file path to the local Git repository.
|
||||
@ -21,7 +21,7 @@ Parameters
|
||||
|
||||
Required? false
|
||||
Position? 2
|
||||
Default value 30
|
||||
Default value 60
|
||||
Accept pipeline input? false
|
||||
Accept wildcard characters? false
|
||||
|
||||
@ -29,7 +29,7 @@ Parameters
|
||||
|
||||
Required? false
|
||||
Position? 3
|
||||
Default value 17
|
||||
Default value 10
|
||||
Accept pipeline input? false
|
||||
Accept wildcard characters? false
|
||||
|
||||
@ -42,7 +42,12 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./watch-commits.ps1
|
||||
❇️ Updated general.csv by Markus Fleschutz (HEAD -> main, origin/main, origin/HEAD)
|
||||
|
||||
|
||||
|
||||
TIME COMMIT
|
||||
---- ------
|
||||
11:25 Updated general.csv by Markus Fleschutz (HEAD -> main, origin/main, origin/HEAD)
|
||||
...
|
||||
|
||||
```
|
||||
@ -60,14 +65,17 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Watch commits live.
|
||||
Watch Git commits live.
|
||||
.DESCRIPTION
|
||||
This PowerShell script continuously lists the latest commit in a Git repository in real-time.
|
||||
This PowerShell script continuously lists the latest commits in a Git repository in real-time.
|
||||
.PARAMETER pathToRepo
|
||||
Specifies the file path to the local Git repository.
|
||||
.EXAMPLE
|
||||
PS> ./watch-commits.ps1
|
||||
❇️ Updated general.csv by Markus Fleschutz (HEAD -> main, origin/main, origin/HEAD)
|
||||
|
||||
TIME COMMIT
|
||||
---- ------
|
||||
11:25 Updated general.csv by Markus Fleschutz (HEAD -> main, origin/main, origin/HEAD)
|
||||
...
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -75,7 +83,7 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$pathToRepo = "$PWD", [int]$updateInterval = 30, [int]$speed = 17)
|
||||
param([string]$pathToRepo = "$PWD", [int]$updateInterval = 60, [int]$speed = 10)
|
||||
|
||||
try {
|
||||
Write-Progress "Searching for Git executable..."
|
||||
@ -86,9 +94,9 @@ try {
|
||||
if (-not(Test-Path "$pathToRepo" -pathType container)) { throw "Can't access directory: $pathToRepo" }
|
||||
Write-Progress -completed "Done."
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "TIME COMMIT"
|
||||
Write-Host "---- ------"
|
||||
Write-Output ""
|
||||
Write-Output "TIME COMMIT"
|
||||
Write-Output "---- ------"
|
||||
$prevLine = ""
|
||||
$tzOffset = (Get-Timezone).BaseUtcOffset.TotalSeconds
|
||||
for (;;) {
|
||||
@ -96,10 +104,9 @@ try {
|
||||
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
|
||||
|
||||
$line = (git -C "$pathToRepo" log origin --format=format:'%at %s by %an%d' --max-count=1)
|
||||
if ($line -eq $prevLine) {
|
||||
Start-Sleep -seconds $updateInterval
|
||||
continue
|
||||
}
|
||||
if ($lastExitCode -ne "0") { throw "'git log origin' failed" }
|
||||
if ("$line" -eq "$prevLine") { Start-Sleep -seconds $updateInterval; continue }
|
||||
|
||||
$unixTimestamp = [int64]$line.Substring(0,10)
|
||||
$time = (Get-Date -day 1 -month 1 -year 1970 -hour 0 -minute 0 -second 0).AddSeconds($unixTimestamp)
|
||||
$time = $time.AddSeconds($tzOffset)
|
||||
@ -115,4 +122,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 as of 11/20/2024 11:52:01)*
|
||||
*(page generated by convert-ps2md.ps1 as of 01/17/2025 08:30:58)*
|
||||
|
Reference in New Issue
Block a user