File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -971,6 +971,54 @@ function Get-GitHubOrganizationRepository
971
971
return $resultToReturn
972
972
}
973
973
974
+ function Get-GitHubRepositoryBranch
975
+ {
976
+ param
977
+ (
978
+ [Parameter (Mandatory = $true )]
979
+ [ValidateNotNullOrEmpty ()]
980
+ [String ] $owner ,
981
+ [Parameter (Mandatory = $true )]
982
+ [ValidateNotNullOrEmpty ()]
983
+ [String ] $repository ,
984
+ $gitHubAccessToken = $script :gitHubToken
985
+ )
986
+
987
+ $resultToReturn = @ ()
988
+
989
+ $query = " $script :gitHubApiUrl /repos/$owner /$repository /branches?"
990
+
991
+ if (! [string ]::IsNullOrEmpty($gitHubAccessToken ))
992
+ {
993
+ $query += " &access_token=$gitHubAccessToken "
994
+ }
995
+
996
+ do
997
+ {
998
+ try
999
+ {
1000
+ $jsonResult = Invoke-WebRequest $query
1001
+ $branches = (ConvertFrom-Json - InputObject $jsonResult.content )
1002
+ }
1003
+ catch [System.Net.WebException ] {
1004
+ Write-Error " Failed to execute query with exception: $ ( $_.Exception ) `n HTTP status code: $ ( $_.Exception.Response.StatusCode ) "
1005
+ return $null
1006
+ }
1007
+ catch {
1008
+ Write-Error " Failed to execute query with exception: $ ( $_.Exception ) "
1009
+ return $null
1010
+ }
1011
+
1012
+ foreach ($branch in $branches )
1013
+ {
1014
+ $resultToReturn += $branch
1015
+ }
1016
+ $query = Get-NextResultPage - jsonResult $jsonResult
1017
+ } while ($query -ne $null )
1018
+
1019
+ return $resultToReturn
1020
+ }
1021
+
974
1022
<#
975
1023
.SYNOPSIS Function to get next page with results from query to GitHub API
976
1024
You can’t perform that action at this time.
0 commit comments