mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-25 21:46:43 +01:00
Improve output of clean-repo.ps1 and clean-repos.ps1
This commit is contained in:
parent
96ae539454
commit
4f74a5f1ce
@ -8,22 +8,21 @@
|
||||
param($RepoDir = "$PWD")
|
||||
|
||||
try {
|
||||
$RepoDir = resolve-path "$RepoDir"
|
||||
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
||||
set-location "$RepoDir"
|
||||
|
||||
"⏳ Cleaning Git repository 📂$RepoDir from untracked files..."
|
||||
$RepoDirName = (get-item "$RepoDir").Name
|
||||
|
||||
"🧹 Cleaning Git repository 📂$RepoDirName from untracked files..."
|
||||
|
||||
$Null = (git --version)
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
& git clean -fdx # force + recurse into dirs + don't use the standard ignore rules
|
||||
& git -C "$RepoDir" clean -fdx # force + recurse into dirs + don't use the standard ignore rules
|
||||
if ($lastExitCode -ne "0") { throw "'git clean -fdx' failed" }
|
||||
|
||||
& git submodule foreach --recursive git clean -fdx
|
||||
& git -C "$RepoDir" submodule foreach --recursive git clean -fdx
|
||||
if ($lastExitCode -ne "0") { throw "'git clean -fdx' in submodules failed" }
|
||||
|
||||
"✔️ cleaned Git repository 📂$RepoDir"
|
||||
"✔️ cleaned Git repository 📂$RepoDirName"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -11,23 +11,20 @@ try {
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
||||
set-location $ParentDir
|
||||
|
||||
$Null = (git --version)
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
[int]$Count = 0
|
||||
get-childItem "$ParentDir" -attributes Directory | foreach-object {
|
||||
"Cleaning Git repository 📂$($_.Name) from untracked files ..."
|
||||
set-location $_.FullName
|
||||
"🧹 Cleaning Git repository 📂$($_.Name) from untracked files ..."
|
||||
|
||||
& git clean -fdx # force + recurse into dirs + don't use the standard ignore rules
|
||||
& git -C "$_.FullName" clean -fdx # force + recurse into dirs + don't use the standard ignore rules
|
||||
if ($lastExitCode -ne "0") { throw "'git clean -fdx' failed" }
|
||||
|
||||
& git submodule foreach --recursive git clean -fdx
|
||||
& git -C "$._FullName" submodule foreach --recursive git clean -fdx
|
||||
if ($lastExitCode -ne "0") { throw "'git clean -fdx' in submodules failed" }
|
||||
|
||||
set-location ..
|
||||
$Count++
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user