functions/github/Get-GitHubRepoDefaultBranch.ps1
function Get-GitHubRepoDefaultBranch { [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [string] $OrgName, [Parameter(Mandatory=$true)] [string] $RepoName ) $url = "https://api.github.com/repos/$OrgName/$RepoName" $resp = Invoke-GitHubRestRequest -Url $url $repo = $resp.Content | ConvertFrom-Json if ([string]::IsNullOrEmpty($repo.default_branch)) { throw ("Unable to retrieve the default branch for repository {0}/{1}" -f $OrgName, $RepoName) } else { return $repo.default_branch } } |