Skip to content

Commit

Permalink
gitUpdate: give progress feedback during update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yetenol committed Oct 11, 2022
1 parent beead6d commit aa494a9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
44 changes: 37 additions & 7 deletions scripts/gitUpdateAll.ps1.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,41 @@

$rootPath = "D:\"

Get-ChildItem -Path $rootPath -Directory -Recurse |
% { $_.FullName } |
? { Test-Path -Path "$_\.git" } |
Write-Host "Scanning for repositories in $rootPath..."

# Find repositories
$repositories = @()
$repositories = Get-ChildItem -Path $rootPath -Directory -Hidden -Recurse -Filter ".git" -ErrorAction SilentlyContinue |
? { $_.FullName -notmatch '\\\$RECYCLE\.BIN\\' } |
% { $_.Parent } |
sort LastWriteTime -Descending # update recently modified repositories first

$repositories |
% {
$unchanged = ([DateTime]::Now - $_.LastWriteTime)
if ($unchanged.Days -ge 1) {
$unchanged = "" + $unchanged.Days + " days"
} else {
$unchanged = $unchanged.ToString().Substring(0,8)
}
$repositories += $_
([PSCustomObject]@{
Name = $_.Name;
Unchanged = $unchanged;
Location = $_.Parent.FullName;
})} | Out-String

# update recently modified repositories first
$repositories = $repositories | sort LastWriteTime -Descending

# Update repositories
$index = 0
$repositories |
% {
Write-Host "$_`t" -f Cyan -NoNewline
git -C $_ pull --all
git -C $_ push --all
}
Write-Host @("`n(" + (++$index) + "/" + $repositories.Length + ") Found ") -NoNewline
Write-Host $_.Name -ForegroundColor Cyan -NoNewline
Write-Host " at " -NoNewline
Write-Host $_.Parent.FullName -ForegroundColor Cyan
git -C $_.FullName pull --all
git -C $_.FullName push --all
}
2 changes: 2 additions & 0 deletions scripts/wingetUpdateAll.ps1.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# & cls & powershell -Command Start-Process wt -Verb RunAs -ArgumentList """PowerShell.exe -Command Invoke-Command -ScriptBlock ([ScriptBlock]::Create(((Get-Content %0) -join [Environment]::NewLine)))""" & exit
# Script is executable and self-elevating when renamed *.cmd or *.bat

Write-Host "Fetching application updates...`n"

# Import known folder
$env:CommonDesktop = (New-Object -ComObject Shell.Application).NameSpace('shell:Common Desktop').Self.Path
$env:Desktop = (New-Object -ComObject Shell.Application).NameSpace('shell:Desktop').Self.Path
Expand Down

0 comments on commit aa494a9

Please sign in to comment.