diff --git a/github/create-pull-request.ps1 b/github/create-pull-request.ps1 index a2ea0ab..a30d4fb 100644 --- a/github/create-pull-request.ps1 +++ b/github/create-pull-request.ps1 @@ -84,7 +84,7 @@ Git-CommitAllChanges -Message $CommitMessage Write-Host "Push branch: $BranchName" Git-PushBranch -Name $BranchName -Force $true -$gitHubApi = Get-GitHubApi -RepositoryName $RepositoryFullName -AccessToken $AccessToken +$gitHubApi = Get-GitHubApi -RepositoryFullName $RepositoryFullName -AccessToken $AccessToken $repositoryOwner = $RepositoryFullName.Split('/')[0] $pullRequest = $gitHubApi.GetPullRequest($BranchName, $repositoryOwner) diff --git a/github/github-api.psm1 b/github/github-api.psm1 index cd16b0b..1e95355 100644 --- a/github/github-api.psm1 +++ b/github/github-api.psm1 @@ -145,19 +145,17 @@ class GitHubApi function Get-GitHubApi { param ( - [Parameter(ParameterSetName = 'RepositoryOwner')] - [Parameter(ParameterSetName = 'RepositoryName')] + [Parameter(ParameterSetName = 'RepositorySingle')] + [string] $RepositoryFullName, + [Parameter(ParameterSetName = 'RepositorySplitted')] [string] $RepositoryOwner, - - [Parameter(ParameterSetName = 'RepositoryName')] + [Parameter(ParameterSetName = 'RepositorySplitted')] [string] $RepositoryName, - [string] $AccessToken ) - # Split repository name (like 'actions/versions-package-tools') in case when owner is not set - if (-not $RepositoryOwner) { - $RepositoryOwner = $RepositoryName.Split('/')[0] + if ($PSCmdlet.ParameterSetName -eq "RepositorySingle") { + $RepositoryOwner, $RepositoryName = $Repository.Split('/', 2) } return [GitHubApi]::New($RepositoryOwner, $RepositoryName, $AccessToken) diff --git a/github/run-ci-builds.ps1 b/github/run-ci-builds.ps1 index 1010e6c..e4b8a03 100644 --- a/github/run-ci-builds.ps1 +++ b/github/run-ci-builds.ps1 @@ -81,7 +81,7 @@ function Queue-Builds { } } -$gitHubApi = Get-GitHubApi -RepositoryName $RepositoryFullName -AccessToken $AccessToken +$gitHubApi = Get-GitHubApi -RepositoryFullName $RepositoryFullName -AccessToken $AccessToken Write-Host "Versions to build: $ToolVersions" Queue-Builds -GitHubApi $gitHubApi ` diff --git a/packages-generation/manifest-generator.ps1 b/packages-generation/manifest-generator.ps1 index 42a343c..75acd89 100644 --- a/packages-generation/manifest-generator.ps1 +++ b/packages-generation/manifest-generator.ps1 @@ -25,7 +25,7 @@ Import-Module (Join-Path $PSScriptRoot "manifest-utils.psm1") -Force $configuration = Read-ConfigurationFile -Filepath $ConfigurationFile -$gitHubApi = Get-GitHubApi -RepositoryName $RepositoryFullName -AccessToken $GitHubAccessToken +$gitHubApi = Get-GitHubApi -RepositoryFullName $RepositoryFullName -AccessToken $GitHubAccessToken $releases = $gitHubApi.GetReleases() $versionIndex = Build-VersionsManifest -Releases $releases -Configuration $configuration $versionIndex | ConvertTo-Json -Depth 5 | Out-File $OutputFile -Encoding UTF8NoBOM -Force