mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-02 19:09:13 +01:00
Improve output of clean-repos.ps1 and pull-repos.ps1
This commit is contained in:
parent
b2628a0cec
commit
b4177e8442
@ -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])"
|
||||
|
@ -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])"
|
||||
|
Loading…
Reference in New Issue
Block a user