microsoft / PowerShellForGitHub

Microsoft PowerShell wrapper for GitHub API
Other
588 stars 185 forks source link

Modify PRs as Issues #333

Open andyleejordan opened 3 years ago

andyleejordan commented 3 years ago

Feature Idea Summary

Hello,

According to the GitHub API Documentation

Every pull request is an issue, but not every issue is a pull request. For this reason, "shared" actions for both features, like manipulating assignees, labels and milestones, are provided within the Issues API.

Take, for example, adding a Label to a PR. This module currently has no direct cmdlet to do so, that is, there's no Add-GitHubPRLabel. There is, of course, Add-GitHubIssueLabel. This cmdlet works with PRs, but only in a hacky way (take the PullRequestNumber field of a PullRequest object and supply it to Add-GitHubIssueLabel as the value for the -Issue parameter. Instead, all Issue cmdlets in this module should support PRs: that is, a PR object when pipelined to an Issue cmdlet should be treated just like an issue.

Feature Idea Additional Details

Here's the current hacky way to add a label to a PR (and please correct me if I'm wrong!), assuming $Repo is a Repo object and @Params is an adequate set of params for New-GitHubPullRequest:

$PR = $Repo | New-GitHubPullRequest @Params
$Repo | Add-GitHubIssueLabel -Issue $PR.PullRequestNumber -LabelName "SomeCoolLabel"

When instead it should just be:

$PR | Add-GitHubIssueLabel -LabelName "SomeCoolLabel"

I imagine based on my cusory browsing of the module's implementation that we could add some filter that turns a PR object into an Issue object, and then modify every Issue cmdlet to do that for PRs, or something to that effect.

Requested Assignment

Operating System

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

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Darwin 20.5.0 Darwin Kernel Version 20.5.0: Sat…
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: 
Installed: 0.16.0
HowardWolosky commented 3 years ago

Hi @andschwa -- I appreciate the suggestion. I've actually completed most of the work to properly support the pull requests API's last year (see here). The work got side-tracked when I started tackling larger scale issues (like pipelining and function consistency) and I haven't found the time to revisit and complete it, but I'm hoping to do so in the near future. At this point, the remaining work (I think) is to update it to support pipelining (as it was implemented before this module had pipeline support) and add tests.