mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-07 07:51:54 +02:00
Update clean-repo.ps1
This commit is contained in:
parent
e6110bcdd8
commit
8f1393ae3b
@ -11,7 +11,7 @@
|
|||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz / License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([string]$RepoDir = "$PWD")
|
param([string]$RepoDir = "$PWD")
|
||||||
@ -22,7 +22,7 @@ try {
|
|||||||
"⏳ Step 1/3: Checking requirements..."
|
"⏳ Step 1/3: Checking requirements..."
|
||||||
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access repository folder at: $RepoDir - maybe a typo or missing folder permissions?" }
|
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access repository folder at: $RepoDir - maybe a typo or missing folder permissions?" }
|
||||||
|
|
||||||
$Null = (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" }
|
||||||
|
|
||||||
"⏳ Step 2/3: Cleaning repository..."
|
"⏳ Step 2/3: Cleaning repository..."
|
||||||
@ -33,9 +33,10 @@ try {
|
|||||||
& git -C "$RepoDir" submodule foreach --recursive git clean -xfd -f
|
& git -C "$RepoDir" submodule foreach --recursive git clean -xfd -f
|
||||||
if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' in submodules failed with exit code $lastExitCode)" }
|
if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' in submodules failed with exit code $lastExitCode)" }
|
||||||
|
|
||||||
$RepoDirName = (get-item "$RepoDir").Name
|
$RepoDirName = (Get-Item "$RepoDir").Name
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ cleaned Git repository 📂$RepoDirName in $Elapsed sec"
|
"✔️ cleaned Git repository 📂$RepoDirName in $Elapsed sec"
|
||||||
|
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
Loading…
Reference in New Issue
Block a user