microsoft / PowerShellForGitHub

Microsoft PowerShell wrapper for GitHub API
Other
584 stars 184 forks source link

How do I add requested reviewers to a new PR? #348

Closed andyleejordan closed 2 years ago

andyleejordan commented 2 years ago

A description of your problem or question

When using New-GitHubPullRequest, I'd like to specify a list of GitHub users as requested reviewers. I found the following reference to this:

https://github.com/microsoft/PowerShellForGitHub/blob/002363505f5738209f4b25d4d31c3d0434bc015e/GitHubPullRequests.ps1#L471-L477

But I cannot figure out how to actually specify that information to the cmdlet.

I'm trying to add these requested users to my code here:

    $Repo = Get-GitHubRepository -OwnerName PowerShell -RepositoryName $RepositoryName

    $Params = @{
        Head  = "release"
        Base  = "master"
        Draft = $true
        Title = "Release ``v$Version``"
        Body  = "Automated PR for new release!"
    }

    $PR = $Repo | New-GitHubPullRequest @Params

Operating System

Name                           Value
----                           -----
OSVersion                      Unix 12.2.1
Is 64-bit                      True
Current culture                en-US
Current UI culture             en-US

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Darwin 21.3.0 Darwin Kernel Version 21.3.0: Wed…
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module Version

Running: 0.16.0
Installed: 0.16.0
HowardWolosky commented 2 years ago

That's not something that the API allows for.

Creating a pull request and requesting a reviewer are two discreet API calls. PowerShellForGitHub (for the most part) mirrors the GitHub API.

The expected flow in your scenario when using PowerShellForGitHub would be to do something like this:

New-GitHubPullRequest @params | New-GitHubPullRequestReviewRequest -Reviewer $listOfReviewers

The unfortunate thing is that New-GitHubPullRequestReviewRequest is still stuck in my development branch along with the rest of the work that completes the Pull Request API set: https://github.com/HowardWolosky/PowerShellForGitHub/blob/pullRequests/

All that work was done before a lot of the major updates to this module (like pipelining), and thus requires a significant rebase before it can be merged in, and I haven't had the time to sit down and do that rebase/update.

andyleejordan commented 2 years ago

Ahh, got it. Thank you @HowardWolosky! I look forward to when that gets merged 😁