mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-13 06:27:16 +02:00
Updated the manuals
This commit is contained in:
@ -16,6 +16,7 @@ Parameters
|
||||
Position? 1
|
||||
Default value "$PWD"
|
||||
Accept pipeline input? false
|
||||
Aliases
|
||||
Accept wildcard characters? false
|
||||
|
||||
[<CommonParameters>]
|
||||
@ -27,11 +28,11 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./clean-repo.ps1 C:\Repos\rust
|
||||
⏳ (1/4) Searching for Git executable... git version 2.45.0
|
||||
⏳ (1/4) Searching for Git executable... git version 2.47.0
|
||||
⏳ (2/4) Checking local repository... C:\Repos\rust
|
||||
⏳ (3/4) Removing untracked files in repository...
|
||||
⏳ (4/4) Removing untracked files in submodules...
|
||||
✅ Cleaned up repo 📂rust in 2s.
|
||||
✅ Repo 📂rust is clean now.
|
||||
|
||||
```
|
||||
|
||||
@ -56,11 +57,11 @@ Script Content
|
||||
Specifies the file path to the local Git repository (current working directory by default)
|
||||
.EXAMPLE
|
||||
PS> ./clean-repo.ps1 C:\Repos\rust
|
||||
⏳ (1/4) Searching for Git executable... git version 2.45.0
|
||||
⏳ (1/4) Searching for Git executable... git version 2.47.0
|
||||
⏳ (2/4) Checking local repository... C:\Repos\rust
|
||||
⏳ (3/4) Removing untracked files in repository...
|
||||
⏳ (4/4) Removing untracked files in submodules...
|
||||
✅ Cleaned up repo 📂rust in 2s.
|
||||
✅ Repo 📂rust is clean now.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -70,11 +71,9 @@ Script Content
|
||||
param([string]$path = "$PWD")
|
||||
|
||||
try {
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
Write-Host "⏳ (1/4) Searching for Git executable... " -noNewline
|
||||
& 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" }
|
||||
|
||||
"⏳ (2/4) Checking local repository... $path"
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Can't access repo folder '$path' - maybe a typo or missing folder permissions?" }
|
||||
@ -82,18 +81,17 @@ try {
|
||||
|
||||
"⏳ (3/4) Removing untracked files in repository..."
|
||||
& git -C "$path" clean -xfd -f # to delete all untracked files in the main repo
|
||||
if ($lastExitCode -ne "0") {
|
||||
if ($lastExitCode -ne 0) {
|
||||
Write-Warning "'git clean' failed with exit code $lastExitCode, retrying once..."
|
||||
& git -C "$path" clean -xfd -f
|
||||
if ($lastExitCode -ne "0") { throw "'git clean' failed with exit code $lastExitCode" }
|
||||
if ($lastExitCode -ne 0) { throw "'git clean' failed with exit code $lastExitCode" }
|
||||
}
|
||||
|
||||
"⏳ (4/4) Removing untracked files in submodules..."
|
||||
& git -C "$path" submodule foreach --recursive git clean -xfd -f # to delete all untracked files in the submodules
|
||||
if ($lastExitCode -ne "0") { throw "'git clean' in the submodules failed with exit code $lastExitCode" }
|
||||
if ($lastExitCode -ne 0) { throw "'git clean' in the submodules failed with exit code $lastExitCode" }
|
||||
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ Cleaned up repo 📂$repoName in $($elapsed)s."
|
||||
"✅ Repo 📂$repoName is clean now."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -101,4 +99,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 01/23/2025 12:15:20)*
|
||||
*(page generated by convert-ps2md.ps1 as of 05/12/2025 22:02:53)*
|
||||
|
Reference in New Issue
Block a user