-
Notifications
You must be signed in to change notification settings - Fork 191
Add New-GitHubPullRequest command #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thanks so much for doing this.
Regarding testing, I'm not quite sure what the best approach is.
I think we could have a test that:
- Creates a fork of PowerShellForGitHub to
$script:organizationName
, and then create a fork of that one to$script:ownerName
. It could then do a pull request of master from$script:ownerName
's to
$script:organizationName
's. I just don't know what the API returns if a PR is created where there are no differences betweenhead
andbase
...
GitHubPullRequests.ps1
Outdated
'base' = $Base | ||
} | ||
|
||
if ($Body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
if ($Body) | |
if (-not [String]::IsNullOrWhitespace($Body)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just thought about this again. It's possible to open a PR that has only whitespace in the body I think.
The current implementation doesn't put a restriction on $Title
.
So the possible approaches are:
- Allow whitespace as
$Title
or$Body
- Silently drop
$Body
when it's whitespace and throw when$Title
is whitespace - Throw when
$Body
or$Title
is whitespacet
Co-Authored-By: Howard Wolosky <[email protected]>
Co-Authored-By: Howard Wolosky <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great update! Thanks for adding the additional parameterset.
Super minor feedback remaining (new comment in this iteration, as well as the [String]::IsNulllOrWhiteSpace comments from the previous iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for these updates. Your analysis of the Title/Body situation make sense.
In general my philosophy is: If it's something that the API would permit, I don't want to prevent that. If it's something that we know we can catch/validate beforehand, we should since it'll save users time.
One minor change request given a change you made to another part of the file. In general I prefer tests to accompany any new feature. For this one, since it most likely requires a committed change a fork, I'm ok to not have the test. Just let me know if you're planning on writing a test to go with the code before I merge this in once you make the other fix.
Thanks again for the contribution!
GitHubPullRequests.ps1
Outdated
@@ -117,7 +117,7 @@ function Get-GitHubPullRequest | |||
|
|||
$uriFragment = "/repos/$OwnerName/$RepositoryName/pulls" | |||
$description = "Getting pull requests for $RepositoryName" | |||
if (-not [String]::IsNullOrEmpty($PullRequest)) | |||
if (-not [String]::IsNullOrWhiteSpace($PullRequest)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm....if you're making this change here, we should probably be changing $PullRequest
from a [string]
to [Int]
(or [Int64]
) since it should really be a number and not a string.
Hey @rjmholt -- just checking back in with you after the long weekend. I'm just looking to see if you were intending to iterate any further on this, or if I should make the updates to this myself after merging in your change. Thanks again for this contribution! |
Hi sorry! Yes will continue working on this. Going to add a test this week -- ideally one for each set. I'll also revert that unrelated change in the other function |
I've found and fixed a bug, but when I try to open a PR from this master from my master it gives me a 404 (I'm pretty sure -- I tried it a few different ways). If I could guarantee other branches it might be possible |
PR microsoft#111 adds support for creating new pull requests, but the creator has indicated that there may be a problem with it. Using this to see if I can reproduce the bug.
@rjmholt - Apologies, I missed your previous comment until now. I just tried two PR's using your current submitted code and it works fine for me. Can you clarify the scenario that's giving you the |
Hey @rjmholt -- just wanted to check-in with you on this one. |
It looks like this for me:
Unless there's two branches that exist that we can guarantee commits between, I'm not sure what the best way to proceed with tests is (also just constantly creating PRs will drive the issue number up pretty heavily). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey -- I think at this point we abandon the idea of the Pester test with this one given the problems you're encountering.
You've done a fantastic job here, and I'd like to just merge in the changes at this point.
Can you just remove the trailing spaces that you have in your change? Once that's done, I'll get this merged in.
Thanks again, so much, for this contribution!
GitHubPullRequests.ps1
Outdated
<# | ||
.SYNOPSIS | ||
Create a new pull request in the specified repository. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can you remove the trailing spaces from the empty lines?
Yeah -- sorry I wasn't able to get good tests working. It might be possible to mock
No worries, sorry it took so long |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thanks again for the new feature.
/azp run PowerShellForGitHub-CI |
Azure Pipelines successfully started running 1 pipeline(s). |
@rjmholt - I was reviewing this code today, and I can't find anywhere in the documentation that talks about creating an issue from a pull request: PowerShellForGitHub/GitHubPullRequests.ps1 Lines 357 to 361 in 788465f
Is this something that they've removed from the API since you added it? Any idea where you got this idea from? Thanks |
Resolves #30.
Adds a command for creating new pull requests.
Outstanding questions: