Improve the output

This commit is contained in:
Markus Fleschutz 2022-01-18 21:02:19 +01:00
parent e8df5794cd
commit fd7b60182d
7 changed files with 31 additions and 34 deletions

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Cleans all Git repositories in a folder from untracked files (including submodules) Cleans all Git repositories in a folder from untracked files
.DESCRIPTION .DESCRIPTION
This script cleans all Git repositories in a folder from untracked files (including submodules). This script cleans all Git repositories in a folder from untracked files (including submodules).
.PARAMETER ParentDir .PARAMETER ParentDir
@ -8,7 +8,7 @@
.EXAMPLE .EXAMPLE
PS> ./clean-repos C:\MyRepos PS> ./clean-repos C:\MyRepos
.NOTES .NOTES
Author: Markus Fleschutz · License: CC0 Author: Markus Fleschutz / License: CC0
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
#> #>
@ -31,7 +31,7 @@ try {
[int]$Step = 1 [int]$Step = 1
foreach ($Folder in $Folders) { foreach ($Folder in $Folders) {
$FolderName = (get-item "$Folder").Name $FolderName = (get-item "$Folder").Name
"Cleaning 📂$FolderName (step $Step/$($FolderCount))..." "Step $Step/$FolderCount: Cleaning 📂$FolderName..."
& git -C "$Folder" clean -xfd -f # force + recurse into dirs + don't use the standard ignore rules & 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" } if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' failed" }
@ -41,7 +41,6 @@ try {
$Step++ $Step++
} }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ cleaned $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec" "✔️ cleaned $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec"
exit 0 # success exit 0 # success

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Fetches updates for all Git repositories in a folder (including submodules) Fetches updates for all Git repositories in a folder
.DESCRIPTION .DESCRIPTION
This script fetches updates for all Git repositories in a folder (including submodules). This script fetches updates for all Git repositories in a folder (including submodules).
.PARAMETER ParentDir .PARAMETER ParentDir
@ -8,7 +8,7 @@
.EXAMPLE .EXAMPLE
PS> ./fetch-repos C:\MyRepos PS> ./fetch-repos C:\MyRepos
.NOTES .NOTES
Author: Markus Fleschutz · License: CC0 Author: Markus Fleschutz / License: CC0
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
#> #>
@ -31,7 +31,7 @@ try {
[int]$Step = 1 [int]$Step = 1
foreach ($Folder in $Folders) { foreach ($Folder in $Folders) {
$FolderName = (get-item "$Folder").Name $FolderName = (get-item "$Folder").Name
"Fetching 📂$FolderName... [step $Step/$NumFolders]" "Step $Step/$NumFolders: Fetching 📂$FolderName..."
& git -C "$Folder" fetch --all --recurse-submodules --prune --prune-tags --force & git -C "$Folder" fetch --all --recurse-submodules --prune --prune-tags --force
if ($lastExitCode -ne "0") { throw "'git fetch' in $FolderName failed" } if ($lastExitCode -ne "0") { throw "'git fetch' in $FolderName failed" }

View File

@ -17,16 +17,16 @@ try {
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
if ($IsLinux) { if ($IsLinux) {
"(1/4) Fetching update infos for installed Debian packages..." "Step 1/4: Fetching update infos for installed Debian packages..."
& sudo apt update & sudo apt update
"(2/4) Upgrading installed Debian packages..." "Step 2/4: Upgrading installed Debian packages..."
& sudo apt upgrade --yes & sudo apt upgrade --yes
"(3/4) Removing obsolete Debian packages..." "Step 3/4: Removing obsolete Debian packages..."
& sudo apt autoremove --yes & sudo apt autoremove --yes
"(4/4) Upgrading installed Snap packages..." "Step 4/4: Upgrading installed Snap packages..."
& sudo snap refresh & sudo snap refresh
} else { } else {
"Sorry, not supported yet" "Sorry, not supported yet"

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Pulls updates for a Git repository (including submodules) Pulls updates for a Git repository
.DESCRIPTION .DESCRIPTION
This script pulls updates for a local Git repository (including submodules). This script pulls updates for a local Git repository (including submodules).
.PARAMETER RepoDir .PARAMETER RepoDir
@ -8,7 +8,7 @@
.EXAMPLE .EXAMPLE
PS> ./pull-repo C:\MyRepo PS> ./pull-repo C:\MyRepo
.NOTES .NOTES
Author: Markus Fleschutz · License: CC0 Author: Markus Fleschutz / License: CC0
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
#> #>
@ -18,7 +18,7 @@ param([string]$RepoDir = "$PWD")
try { try {
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
"(1/3) Checking requirements... " "Step 1/3: Checking requirements... "
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
set-location "$RepoDir" set-location "$RepoDir"
@ -29,11 +29,11 @@ try {
exit 0 # success exit 0 # success
} }
"(2/3) Pulling updates... " "Step 2/3: Pulling updates... "
& git pull --recurse-submodules --jobs=4 & git pull --recurse-submodules --jobs=4
if ($lastExitCode -ne "0") { throw "'git pull' failed" } if ($lastExitCode -ne "0") { throw "'git pull' failed" }
"(3/3) Updating submodules... " "Step 3/3: Updating submodules... "
& git submodule update --init --recursive & git submodule update --init --recursive
if ($lastExitCode -ne "0") { throw "'git submodule update' failed" } if ($lastExitCode -ne "0") { throw "'git submodule update' failed" }

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Pulls updates for all Git repositories in a folder (including submodules) Pulls updates for all Git repositories in a folder
.DESCRIPTION .DESCRIPTION
This PowerShell script pulls updates for all Git repositories in a folder (including submodules). This PowerShell script pulls updates for all Git repositories in a folder (including submodules).
.PARAMETER ParentDir .PARAMETER ParentDir
@ -8,7 +8,7 @@
.EXAMPLE .EXAMPLE
PS> ./pull-repos C:\MyRepos PS> ./pull-repos C:\MyRepos
.NOTES .NOTES
Author: Markus Fleschutz · License: CC0 Author: Markus Fleschutz / License: CC0
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
#> #>
@ -31,7 +31,7 @@ try {
[int]$Step = 1 [int]$Step = 1
foreach ($Folder in $Folders) { foreach ($Folder in $Folders) {
$FolderName = (get-item "$Folder").Name $FolderName = (get-item "$Folder").Name
"($Step/$NumFolders) Pulling 📂$FolderName... " "Step $Step/$NumFolders: Pulling 📂$FolderName... "
& git -C "$Folder" pull --recurse-submodules --jobs=4 & git -C "$Folder" pull --recurse-submodules --jobs=4
if ($lastExitCode -ne "0") { write-warning "'git pull' in 📂$FolderName failed" } if ($lastExitCode -ne "0") { write-warning "'git pull' in 📂$FolderName failed" }

View File

@ -6,7 +6,7 @@
.EXAMPLE .EXAMPLE
PS> ./start-ipfs-server PS> ./start-ipfs-server
.NOTES .NOTES
Author: Markus Fleschutz · License: CC0 Author: Markus Fleschutz / License: CC0
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
#> #>
@ -14,16 +14,14 @@
try { try {
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
"" "⏳ Step 1/5: Searching for IPFS executable..."
" ($Step/$NumFolders) Pulling 📂$FolderName... "
"⏳ (1/5) Searching for IPFS executable..."
& ipfs --version & ipfs --version
if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" } if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" }
"" ""
"(2/5) Initializing IPFS with server profile..." "Step 2/5: Initializing IPFS with server profile..."
& ipfs init --profile server & ipfs init --profile server
"(3/5) Configuring IPFS..." "Step 3/5: Configuring IPFS..."
& ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 & ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.API' failed" } if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.API' failed" }
@ -37,11 +35,11 @@ try {
& ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '[\"PUT\", \"POST\"]' & ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '[\"PUT\", \"POST\"]'
if ($lastExitCode -ne "0") { throw "'ipfs config Access-Control-Allow-Methods' failed" } if ($lastExitCode -ne "0") { throw "'ipfs config Access-Control-Allow-Methods' failed" }
"" ""
"(4/5) Increasing UDP receive buffer size..." "Step 4/5: Increasing UDP receive buffer size..."
& sudo sysctl -w net.core.rmem_max=2500000 & sudo sysctl -w net.core.rmem_max=2500000
if ($lastExitCode -ne "0") { throw "'sysctl' failed" } if ($lastExitCode -ne "0") { throw "'sysctl' failed" }
"" ""
"(5/5) Starting IPFS daemon..." "Step 5/5: Starting IPFS daemon..."
# Start-Process nohup 'ipfs daemon' # Start-Process nohup 'ipfs daemon'
Start-Process nohup -ArgumentList 'ipfs','daemon' -RedirectStandardOutput "$HOME/console.out" -RedirectStandardError "$HOME/console.err" Start-Process nohup -ArgumentList 'ipfs','daemon' -RedirectStandardOutput "$HOME/console.out" -RedirectStandardError "$HOME/console.err"

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Switches the branch in a Git repository (including submodules) Switches the branch in a Git repository
.DESCRIPTION .DESCRIPTION
This script switches to another branch in a Git repository (including submodules). This script switches to another branch in a Git repository (including submodules).
.PARAMETER BranchName .PARAMETER BranchName
@ -10,7 +10,7 @@
.EXAMPLE .EXAMPLE
PS> ./switch-branch main C:\MyRepo PS> ./switch-branch main C:\MyRepo
.NOTES .NOTES
Author: Markus Fleschutz · License: CC0 Author: Markus Fleschutz / License: CC0
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
#> #>
@ -22,7 +22,7 @@ try {
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
"(1/5) Checking requirements... " "Step 1/5: Checking requirements... "
$RepoDir = resolve-path "$RepoDir" $RepoDir = resolve-path "$RepoDir"
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
set-location "$RepoDir" set-location "$RepoDir"
@ -34,19 +34,19 @@ try {
if ($lastExitCode -ne "0") { throw "'git status' failed in $RepoDir" } if ($lastExitCode -ne "0") { throw "'git status' failed in $RepoDir" }
if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Git repository is NOT clean: $Result" } if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Git repository is NOT clean: $Result" }
"(2/5) Fetching latest updates..." "Step 2/5: Fetching latest updates..."
& git fetch --all --recurse-submodules --prune --prune-tags --force & git fetch --all --recurse-submodules --prune --prune-tags --force
if ($lastExitCode -ne "0") { throw "'git fetch' failed" } if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
"(3/5) Switching branch..." "Step 3/5: Switching branch..."
& git checkout --recurse-submodules "$BranchName" & git checkout --recurse-submodules "$BranchName"
if ($lastExitCode -ne "0") { throw "'git checkout $BranchName' failed" } if ($lastExitCode -ne "0") { throw "'git checkout $BranchName' failed" }
"(4/5) Pulling updates..." "Step 4/5: Pulling updates..."
& git pull --recurse-submodules & git pull --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git pull' failed" } if ($lastExitCode -ne "0") { throw "'git pull' failed" }
"(5/5) Updating submodules..." "Step 5/5: Updating submodules..."
& git submodule update --init --recursive & git submodule update --init --recursive
if ($lastExitCode -ne "0") { throw "'git submodule update' failed" } if ($lastExitCode -ne "0") { throw "'git submodule update' failed" }