mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-24 19:08:27 +02:00
Improve the output
This commit is contained in:
parent
4f74a5f1ce
commit
899a5b0816
@ -15,21 +15,23 @@ try {
|
|||||||
$Null = (git --version)
|
$Null = (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" }
|
||||||
|
|
||||||
[int]$Count = 0
|
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
||||||
get-childItem "$ParentDir" -attributes Directory | foreach-object {
|
"Cleaning $($Folders.Count) Git repositories from untracked files ..."
|
||||||
"🧹 Cleaning Git repository 📂$($_.Name) from untracked files ..."
|
|
||||||
|
|
||||||
& git -C "$_.FullName" clean -fdx # force + recurse into dirs + don't use the standard ignore rules
|
foreach ($Folder in $Folders) {
|
||||||
|
$FolderName = (get-item "$Folder").Name
|
||||||
|
"🧹 Cleaning 📂$FolderName ..."
|
||||||
|
|
||||||
|
& git -C "$Folder" clean -fdx # force + recurse into dirs + don't use the standard ignore rules
|
||||||
if ($lastExitCode -ne "0") { throw "'git clean -fdx' failed" }
|
if ($lastExitCode -ne "0") { throw "'git clean -fdx' failed" }
|
||||||
|
|
||||||
& git -C "$._FullName" submodule foreach --recursive git clean -fdx
|
& git -C "$Folder" submodule foreach --recursive git clean -fdx
|
||||||
if ($lastExitCode -ne "0") { throw "'git clean -fdx' in submodules failed" }
|
if ($lastExitCode -ne "0") { throw "'git clean -fdx' in submodules failed" }
|
||||||
|
|
||||||
$Count++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
write-host -foregroundColor green "✔️ cleaned $Count Git repositories at $ParentDir in $Elapsed sec."
|
"✔️ cleaned $($Folders.Count) Git repositories at $ParentDir in $Elapsed sec."
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -11,27 +11,24 @@ try {
|
|||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
||||||
set-location $ParentDir
|
|
||||||
|
|
||||||
$Null = (git --version)
|
$Null = (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" }
|
||||||
|
|
||||||
[int]$Count = 0
|
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
||||||
get-childItem $ParentDir -attributes Directory | foreach-object {
|
$ParentDirName = (get-item "$ParentDir").Name
|
||||||
"🢃 Fetching updates for Git repository 📂$($_.Name) ..."
|
"Fetching updates for $($Folders.Count) Git repositories at 📂$ParentDirName..."
|
||||||
|
|
||||||
set-location "$($_.FullName)"
|
foreach ($Folder in $Folders) {
|
||||||
|
$FolderName = (get-item "$Folder").Name
|
||||||
|
"🢃 Fetching 📂$FolderName ..."
|
||||||
|
|
||||||
& git fetch --all --recurse-submodules --jobs=4
|
& git -C "$Folder" fetch --all --recurse-submodules --jobs=4
|
||||||
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
|
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
|
||||||
|
|
||||||
set-location ..
|
|
||||||
$Count++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ParentDirName = (get-item "$ParentDir").Name
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ fetched $Count Git repositories at 📂$ParentDirName in $Elapsed sec."
|
"✔️ fetched $($Folders.Count) Git repositories at 📂$ParentDirName in $Elapsed sec."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -11,27 +11,26 @@ try {
|
|||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
||||||
set-location "$ParentDir"
|
|
||||||
|
|
||||||
$Null = (git --version)
|
$Null = (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" }
|
||||||
|
|
||||||
[int]$Count = 0
|
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
||||||
get-childItem $ParentDir -attributes Directory | foreach-object {
|
$ParentDirName = (get-item "$ParentDir").Name
|
||||||
"🢃 Pulling updates for Git repository 📂$($_.Name) ..."
|
"Pulling updates for $($Folders.Count) Git repositories at 📂$ParentDirName ..."
|
||||||
|
|
||||||
set-location $_.FullName
|
foreach ($Folder in $Folders) {
|
||||||
|
$FolderName = (get-item "$Folder").Name
|
||||||
|
"🢃 Pulling 📂$FolderName ..."
|
||||||
|
|
||||||
& git pull --recurse-submodules --jobs=4
|
& git -C "$Folder" pull --recurse-submodules --jobs=4
|
||||||
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
if ($lastExitCode -ne "0") {
|
||||||
|
write-warning "'git pull' on 📂$FolderName failed"
|
||||||
set-location ..
|
}
|
||||||
$Count++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ParentDirName = (get-item "$ParentDir").Name
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ updated $Count Git repositories at 📂$ParentDirName in $Elapsed sec."
|
"✔️ updated $($Folders.Count) Git repositories at 📂$ParentDirName in $Elapsed sec."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user