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 Git-PushBranch -Name $BranchName -Force $true
$gitHubApi = Get-GitHubApi -RepositoryFullName $RepositoryFullName -AccessToken $AccessToken $gitHubApi = Get-GitHubApi -RepositoryFullName $RepositoryFullName -AccessToken $AccessToken
$repositoryOwner = $RepositoryFullName.Split('/')[0] $pullRequest = $gitHubApi.GetPullRequest($BranchName)
$pullRequest = $gitHubApi.GetPullRequest($BranchName, $repositoryOwner)
if ($pullRequest.Count -gt 0) { if ($pullRequest.Count -gt 0) {
Write-Host "Update pull request" Write-Host "Update pull request"

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

Loading…
Cancel
Save