From ac815530e6d68164754dd63ceef8e3f0368e5c44 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Tue, 18 Apr 2023 14:42:59 +0200 Subject: [PATCH] Update check-repo.ps1 --- Scripts/check-repo.ps1 | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/Scripts/check-repo.ps1 b/Scripts/check-repo.ps1 index 6ab043d3..11320070 100644 --- a/Scripts/check-repo.ps1 +++ b/Scripts/check-repo.ps1 @@ -18,58 +18,51 @@ param([string]$RepoDir = "$PWD") try { $StopWatch = [system.diagnostics.stopwatch]::startNew() - Write-Host "⏳ (1/11) Searching for Git executable... " -noNewline + 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/11) Checking file path... " -noNewline + Write-Host "⏳ (2/10) Checking repository... " -noNewline $FullPath = Resolve-Path "$RepoDir" if (!(Test-Path "$FullPath" -pathType Container)) { throw "Can't access folder: $FullPath" } "📂$FullPath" - Write-Host "⏳ (3/11) Searching for 📂.git... " -noNewline - if (!(Test-Path "$FullPath/.git" -pathType container)) { throw "Can't access folder: $FullPath/.git" } - "OK" - - Write-Host "⏳ (4/11) Querying remote URL... " -noNewline + Write-Host "⏳ (3/10) Querying remote URL... " -noNewline & git -C "$FullPath" remote get-url origin if ($lastExitCode -ne "0") { throw "'git remote get-url origin' failed with exit code $lastExitCode" } - Write-Host "⏳ (5/11) Querying current branch... " -noNewline + Write-Host "⏳ (4/10) Querying current branch... " -noNewline & git -C "$FullPath" branch --show-current if ($lastExitCode -ne "0") { throw "'git branch --show-current' failed with exit code $lastExitCode" } - Write-Host "⏳ (6/11) Trying to fetch... " -noNewline + Write-Host "⏳ (5/10) Fetching updates..." & git -C "$FullPath" fetch if ($lastExitCode -ne "0") { throw "'git branch --show-current' failed with exit code $lastExitCode" } - Write-Host "OK" - Write-Host "⏳ (7/11) Querying latest tag... " -noNewline + 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)" - Write-Host "⏳ (8/11) Verifying data integrity..." + Write-Host "⏳ (7/10) Verifying data integrity..." & git -C "$FullPath" fsck if ($lastExitCode -ne "0") { throw "'git fsck' failed with exit code $lastExitCode" } - Write-Host "⏳ (9/11) Running maintenance tasks..." + Write-Host "⏳ (8/10) Running maintenance tasks..." & git -C "$FullPath" maintenance run if ($lastExitCode -ne "0") { throw "'git maintenance run' failed with exit code $lastExitCode" } - Write-Host "⏳ (10/11) Querying submodule status... " -noNewline + Write-Host "⏳ (9/10) Checking submodule status..." & git -C "$FullPath" submodule status if ($lastExitCode -ne "0") { throw "'git submodule status' failed with exit code $lastExitCode" } - " " - Write-Host "⏳ (11/11) Querying repo status... " -noNewline - & git -C "$FullPath" status --short + Write-Host "⏳ (10/10) Checking repo status... " -noNewline + & 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" + "✔️ successfully checked repo 📂$RepoDirName in $Elapsed sec" exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"