mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 09:04:18 +01:00
Improve the output
This commit is contained in:
parent
4f74a5f1ce
commit
899a5b0816
@ -15,21 +15,23 @@ try {
|
||||
$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 ..."
|
||||
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
||||
"Cleaning $($Folders.Count) Git repositories 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" }
|
||||
|
||||
& 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" }
|
||||
|
||||
$Count++
|
||||
}
|
||||
|
||||
[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
|
||||
} catch {
|
||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -11,27 +11,24 @@ 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 {
|
||||
"🢃 Fetching updates for Git repository 📂$($_.Name) ..."
|
||||
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
||||
$ParentDirName = (get-item "$ParentDir").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" }
|
||||
|
||||
set-location ..
|
||||
$Count++
|
||||
}
|
||||
|
||||
$ParentDirName = (get-item "$ParentDir").Name
|
||||
[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
|
||||
} catch {
|
||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -11,27 +11,26 @@ 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 {
|
||||
"🢃 Pulling updates for Git repository 📂$($_.Name) ..."
|
||||
$Folders = (get-childItem "$ParentDir" -attributes Directory)
|
||||
$ParentDirName = (get-item "$ParentDir").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
|
||||
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
||||
|
||||
set-location ..
|
||||
$Count++
|
||||
& git -C "$Folder" pull --recurse-submodules --jobs=4
|
||||
if ($lastExitCode -ne "0") {
|
||||
write-warning "'git pull' on 📂$FolderName failed"
|
||||
}
|
||||
}
|
||||
|
||||
$ParentDirName = (get-item "$ParentDir").Name
|
||||
[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
|
||||
} catch {
|
||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user