Update GetPullRequest function

pull/13/head
MaksimZhukov 4 years ago
parent 5e417400d9
commit 606411ff6f

@ -85,8 +85,7 @@ Write-Host "Push branch: $BranchName"
Git-PushBranch -Name $BranchName -Force $true
$gitHubApi = Get-GitHubApi -RepositoryFullName $RepositoryFullName -AccessToken $AccessToken
$repositoryOwner = $RepositoryFullName.Split('/')[0]
$pullRequest = $gitHubApi.GetPullRequest($BranchName, $repositoryOwner)
$pullRequest = $gitHubApi.GetPullRequest($BranchName)
if ($pullRequest.Count -gt 0) {
Write-Host "Update pull request"

@ -6,6 +6,7 @@ class GitHubApi
{
[string] $BaseUrl
[object] $AuthHeader
[string] $RepositoryOwner
GitHubApi(
[string] $AccountName,
@ -14,6 +15,7 @@ class GitHubApi
) {
$this.BaseUrl = $this.BuildBaseUrl($AccountName, $ProjectName)
$this.AuthHeader = $this.BuildAuth($AccessToken)
$this.RepositoryOwner = $AccountName
}
[object] hidden BuildAuth([string]$AccessToken) {
@ -42,9 +44,9 @@ class GitHubApi
return $this.InvokeRestMethod($url, 'Post', $null, $requestBody)
}
[object] GetPullRequest([string]$BranchName, [string]$RepositoryOwner){
[object] GetPullRequest([string]$BranchName){
$url = "pulls"
return $this.InvokeRestMethod($url, 'GET', "head=${RepositoryOwner}:$BranchName&base=main", $null)
return $this.InvokeRestMethod($url, 'GET', "head=$($this.RepositoryOwner):${BranchName}&base=main", $null)
}
[object] UpdatePullRequest([string]$Title, [string]$Body, [string]$BranchName, [string]$PullRequestNumber){

Loading…
Cancel
Save