Updated some scripts

This commit is contained in:
Markus Fleschutz 2024-06-13 11:51:19 +02:00
parent 3187d04df6
commit 142f14bb44
3 changed files with 7 additions and 7 deletions

View File

@ -8,7 +8,7 @@
.EXAMPLE .EXAMPLE
PS> ./check-repo.ps1 C:\MyRepo PS> ./check-repo.ps1 C:\MyRepo
(1/10) Searching for Git executable... git version 2.41.0.windows.3 (1/10) Searching for Git executable... git version 2.41.0.windows.3
(2/10) Checking local repository... 📂C:\MyRepo (2/10) Checking local repository... C:\MyRepo
(3/10) Querying remote URL... git@github.com:fleschutz/PowerShell.git (3/10) Querying remote URL... git@github.com:fleschutz/PowerShell.git
(4/10) Querying current branch... main (4/10) Querying current branch... main
(5/10) Fetching remote updates... OK (5/10) Fetching remote updates... OK
@ -33,7 +33,7 @@ try {
Write-Host "⏳ (2/10) Checking local repository... " -noNewline Write-Host "⏳ (2/10) Checking local repository... " -noNewline
$FullPath = Resolve-Path "$pathToRepo" $FullPath = Resolve-Path "$pathToRepo"
if (!(Test-Path "$FullPath" -pathType Container)) { throw "Can't access folder: $FullPath" } if (!(Test-Path "$FullPath" -pathType Container)) { throw "Can't access folder: $FullPath" }
"📂$FullPath" "$FullPath"
Write-Host "⏳ (3/10) Querying remote URL... " -noNewline Write-Host "⏳ (3/10) Querying remote URL... " -noNewline
& git -C "$FullPath" remote get-url origin & git -C "$FullPath" remote get-url origin
@ -71,7 +71,7 @@ try {
$repoDirName = (Get-Item "$FullPath").Name $repoDirName = (Get-Item "$FullPath").Name
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds [int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✔️ Checked repo 📂$repoDirName in $($elapsed)s." "✔️ Checked repository 📂$repoDirName in $($elapsed)s."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -8,7 +8,7 @@
.EXAMPLE .EXAMPLE
PS> ./pull-repo.ps1 PS> ./pull-repo.ps1
(1/4) Searching for Git executable... git version 2.44.0.windows.1 (1/4) Searching for Git executable... git version 2.44.0.windows.1
(2/4) Checking local repository... 📂C:\Repos\rust (2/4) Checking local repository... C:\Repos\rust
(3/4) Pulling remote updates... (3/4) Pulling remote updates...
(4/4) Updating submodules... (4/4) Updating submodules...
Updates pulled into 📂rust repo in 14s. Updates pulled into 📂rust repo in 14s.
@ -27,7 +27,7 @@ try {
& git --version & 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-Host "⏳ (2/4) Checking local repository... 📂$pathToRepo" Write-Host "⏳ (2/4) Checking local repository... $pathToRepo"
if (-not(Test-Path "$pathToRepo" -pathType container)) { throw "Can't access folder: $pathToRepo" } if (-not(Test-Path "$pathToRepo" -pathType container)) { throw "Can't access folder: $pathToRepo" }
$result = (git -C "$pathToRepo" status) $result = (git -C "$pathToRepo" status)
if ("$result" -match "HEAD detached at ") { throw "Nothing to pull due to detached HEAD state (not on a branch!)" } if ("$result" -match "HEAD detached at ") { throw "Nothing to pull due to detached HEAD state (not on a branch!)" }

View File

@ -48,10 +48,10 @@ try {
} }
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds [int]$elapsed = $stopWatch.Elapsed.TotalSeconds
if ($failed -eq 0) { if ($failed -eq 0) {
"✔️ Updated $numFolders repositories in 📂$parentDirName (took $($elapsed)s)." "✔️ Updated $numFolders repositories under 📂$parentDirName in $($elapsed)s."
exit 0 # success exit 0 # success
} else { } else {
"⚠️ Updated $numFolders repositories in 📂$parentDirName but $failed failed (took $($elapsed)s)." "⚠️ Updated $numFolders repositories under 📂$parentDirName in $($elapsed)s but $failed failed!"
exit 1 exit 1
} }
} catch { } catch {