Improve output of clean-repos.ps1 and pull-repos.ps1

This commit is contained in:
Markus Fleschutz 2021-07-02 15:15:29 +02:00
parent b2628a0cec
commit b4177e8442
2 changed files with 7 additions and 7 deletions

View File

@ -16,12 +16,13 @@ try {
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
$Folders = (get-childItem "$ParentDir" -attributes Directory)
$FolderCount = $Folders.Count
$ParentDirName = (get-item "$ParentDir").Name
"Found $($Folders.Count) Git repositories in 📂$ParentDirName ..."
"Found $FolderCount subfolders in 📂$ParentDirName..."
foreach ($Folder in $Folders) {
$FolderName = (get-item "$Folder").Name
"🧹 Cleaning 📂$FolderName from untracked files..."
"🧹 Cleaning 📂$FolderName from untracked files (#$Step/$FolderCount)..."
& git -C "$Folder" clean -xfd -f # force + recurse into dirs + don't use the standard ignore rules
if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' failed" }
@ -31,8 +32,7 @@ try {
}
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ cleaned $($Folders.Count) Git repositories at 📂$ParentDirName in $Elapsed sec"
"✔️ cleaned $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -18,13 +18,13 @@ try {
$Folders = (get-childItem "$ParentDir" -attributes Directory)
$FolderCount = $Folders.Count
$ParentDirName = (get-item "$ParentDir").Name
"Found $FolderCount subfolders under 📂$ParentDirName..."
"Found $FolderCount subfolders in 📂$ParentDirName..."
[int]$Step = 0
foreach ($Folder in $Folders) {
$FolderName = (get-item "$Folder").Name
$Step++
"🢃 Pulling #$($Step): 📂$FolderName ..."
"🢃 Pulling 📂$FolderName (#$Step/$FolderCount)..."
& git -C "$Folder" pull --recurse-submodules --jobs=4
if ($lastExitCode -ne "0") { write-warning "'git pull' on 📂$FolderName failed" }
@ -34,7 +34,7 @@ try {
}
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ pulled $FolderCount Git repositories under 📂$ParentDirName in $Elapsed sec"
"✔️ pulled $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"