mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-08 20:54:38 +02:00
Updated the Markdown manuals
This commit is contained in:
@ -1,15 +1,15 @@
|
||||
Script: *check-repo.ps1*
|
||||
========================
|
||||
|
||||
This PowerShell script verifies the integrity of a local Git repository.
|
||||
This PowerShell script verifies the integrity of a local Git repository and performs maintenance tasks.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./check-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
|
||||
PS> ./check-repo.ps1 [[-pathToRepo] <String>] [<CommonParameters>]
|
||||
|
||||
-RepoDir <String>
|
||||
Specifies the path to the Git repository (current working directory by default)
|
||||
-pathToRepo <String>
|
||||
Specifies the file path to the local Git repository (current working directory by default)
|
||||
|
||||
Required? false
|
||||
Position? 1
|
||||
@ -27,11 +27,11 @@ Example
|
||||
```powershell
|
||||
PS> ./check-repo.ps1 C:\MyRepo
|
||||
⏳ (1/10) Searching for Git executable... git version 2.41.0.windows.3
|
||||
⏳ (2/10) Checking local folder... 📂C:\MyRepo
|
||||
⏳ (2/10) Checking local repository... 📂C:\MyRepo
|
||||
⏳ (3/10) Querying remote URL... git@github.com:fleschutz/PowerShell.git
|
||||
⏳ (4/10) Querying current branch... main
|
||||
⏳ (5/10) Fetching remote updates...
|
||||
⏳ (6/10) Querying latest tag... v0.8 (commit 02171a401d83b01a0cda0af426840b605e617f08)
|
||||
⏳ (5/10) Fetching remote updates... OK
|
||||
⏳ (6/10) Querying latest tag... v0.8 (at commit 02171a401d83b01a0cda0af426840b605e617f08)
|
||||
⏳ (7/10) Verifying data integrity...
|
||||
...
|
||||
|
||||
@ -50,19 +50,19 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks a repo
|
||||
Checks a Git repository
|
||||
.DESCRIPTION
|
||||
This PowerShell script verifies the integrity of a local Git repository.
|
||||
.PARAMETER RepoDir
|
||||
Specifies the path to the Git repository (current working directory by default)
|
||||
This PowerShell script verifies the integrity of a local Git repository and performs maintenance tasks.
|
||||
.PARAMETER pathToRepo
|
||||
Specifies the file path to the local Git repository (current working directory by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-repo.ps1 C:\MyRepo
|
||||
⏳ (1/10) Searching for Git executable... git version 2.41.0.windows.3
|
||||
⏳ (2/10) Checking local folder... 📂C:\MyRepo
|
||||
⏳ (2/10) Checking local repository... 📂C:\MyRepo
|
||||
⏳ (3/10) Querying remote URL... git@github.com:fleschutz/PowerShell.git
|
||||
⏳ (4/10) Querying current branch... main
|
||||
⏳ (5/10) Fetching remote updates...
|
||||
⏳ (6/10) Querying latest tag... v0.8 (commit 02171a401d83b01a0cda0af426840b605e617f08)
|
||||
⏳ (5/10) Fetching remote updates... OK
|
||||
⏳ (6/10) Querying latest tag... v0.8 (at commit 02171a401d83b01a0cda0af426840b605e617f08)
|
||||
⏳ (7/10) Verifying data integrity...
|
||||
...
|
||||
.LINK
|
||||
@ -71,17 +71,17 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$RepoDir = "$PWD")
|
||||
param([string]$pathToRepo = "$PWD")
|
||||
|
||||
try {
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
Write-Host "⏳ (1/10) Searching for Git executable... " -noNewline
|
||||
& git --version
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
Write-Host "⏳ (2/10) Checking local folder... " -noNewline
|
||||
$FullPath = Resolve-Path "$RepoDir"
|
||||
Write-Host "⏳ (2/10) Checking local repository... " -noNewline
|
||||
$FullPath = Resolve-Path "$pathToRepo"
|
||||
if (!(Test-Path "$FullPath" -pathType Container)) { throw "Can't access folder: $FullPath" }
|
||||
"📂$FullPath"
|
||||
|
||||
@ -93,14 +93,15 @@ try {
|
||||
& git -C "$FullPath" branch --show-current
|
||||
if ($lastExitCode -ne "0") { throw "'git branch --show-current' failed with exit code $lastExitCode" }
|
||||
|
||||
Write-Host "⏳ (5/10) Fetching remote updates..."
|
||||
& git -C "$FullPath" fetch
|
||||
Write-Host "⏳ (5/10) Fetching remote updates... " -noNewline
|
||||
& git -C "$FullPath" fetch --all --recurse-submodules --tags --force --quiet
|
||||
if ($lastExitCode -ne "0") { throw "'git fetch' failed with exit code $lastExitCode" }
|
||||
Write-Host "OK"
|
||||
|
||||
Write-Host "⏳ (6/10) Querying latest tag... " -noNewline
|
||||
$LatestTagCommitID = (git -C "$FullPath" rev-list --tags --max-count=1)
|
||||
$LatestTagName = (git -C "$FullPath" describe --tags $LatestTagCommitID)
|
||||
Write-Host "$LatestTagName (commit $LatestTagCommitID)"
|
||||
$latestTagCommitID = (git -C "$FullPath" rev-list --tags --max-count=1)
|
||||
$latestTagName = (git -C "$FullPath" describe --tags $latestTagCommitID)
|
||||
Write-Host "$latestTagName (at commit $latestTagCommitID)"
|
||||
|
||||
Write-Host "⏳ (7/10) Verifying data integrity..."
|
||||
& git -C "$FullPath" fsck
|
||||
@ -118,9 +119,9 @@ try {
|
||||
& git -C "$FullPath" status
|
||||
if ($lastExitCode -ne "0") { throw "'git status --short' failed with exit code $lastExitCode" }
|
||||
|
||||
$RepoDirName = (Get-Item "$FullPath").Name
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Checked repo 📂$RepoDirName in $Elapsed sec"
|
||||
$repoDirName = (Get-Item "$FullPath").Name
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Checked repo 📂$repoDirName in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -128,4 +129,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-repo.ps1 as of 03/27/2024 17:36:25)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-repo.ps1 as of 05/19/2024 10:25:18)*
|
||||
|
Reference in New Issue
Block a user