Last active
June 9, 2016 15:18
-
-
Save svdoever/28749d5b72d41da8f0d2a6b0598194db to your computer and use it in GitHub Desktop.
Show the git branch status of all subfolders in a given path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($path = (Get-Item -Path ".\" -Verbose).FullName) | |
Write-Host "Processing for git branch status of subfolders in folder: $path" | |
$items = @() | |
Get-ChildItem -Path $path | ?{$_.PSIsContainer } | Foreach-Object -Process { | |
if (Test-Path -Path (Join-Path -Path $_.FullName -ChildPath '.git')) { | |
pushd $_.FullName | |
Write-Host "Processing $($_)...." | |
git fetch | |
$synced = ((git status -uno) -join ' ') -match 'up-to-date' | |
$branch = git rev-parse --abbrev-ref HEAD | |
$local_branches = (git branch) -join ',' | |
$remote_branches = (git branch -r) -join ',' | |
popd | |
if (!$synced) { | |
$branch += " [NOT SYNCED]" | |
} | |
Write-Host "$($_): $branch" | |
$obj = New-Object System.Object | |
$obj | Add-Member -type NoteProperty -name dir -value $_ | |
$obj | Add-Member -type NoteProperty -name branch -value $branch | |
$obj | Add-Member -type NoteProperty -name local_branches -value $local_branches | |
$obj | Add-Member -type NoteProperty -name remote_branches -value $remote_branches | |
$items += $obj | |
} | |
} | |
$items | Out-GridView -Title "Git branch status of subfolders in path $path" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment