Created
September 14, 2021 06:54
-
-
Save schneidr/18ac65250a0bc98ffb0c124a93b949a1 to your computer and use it in GitHub Desktop.
List all branches of forks from a GitHub repository that don't exist on the root repository
This file contains hidden or 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( | |
[Parameter(Mandatory=$true)] | |
[string]$rootRepo | |
) | |
$gh = 'C:\Program Files (x86)\GitHub CLI\gh.exe' | |
$rootBranches = (. $gh api /repos/$rootRepo/branches | ConvertFrom-Json).name | |
$repos = . $gh api /repos/$rootRepo/forks | ConvertFrom-Json | |
$repos | ForEach-Object { | |
$repo = $_.full_name | |
$branches = (. $gh api /repos/$repo/branches | ConvertFrom-Json).name | |
$differences = Compare-Object -ReferenceObject $rootBranches -DifferenceObject $branches | | |
Where-Object { $_.SideIndicator -eq '=>' } | | |
Select-Object InputObject,@{n='URL';e={ "https://github.com/$repo/tree/$($_.InputObject)" }} | |
if ($differences.Length -gt 0) { | |
Write-Host -ForegroundColor Green $repo | |
$differences | Format-Table -HideTableHeaders | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment