-
Notifications
You must be signed in to change notification settings - Fork 194
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
fix the PullRequest object so it can parse #285
base: master
Are you sure you want to change the base?
Conversation
src/GitHub/Data/PullRequests.hs
Outdated
@@ -160,6 +159,9 @@ data PullRequestEventType | |||
| PullRequestUnassigned | |||
| PullRequestLabeled | |||
| PullRequestUnlabeled | |||
| PullRequestReviewRequested |
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.
added these because the API docs list them.
Not sure if it makes sense to make a catch-all OtherPullRequestEventType Text
which might make the library a little more future-proof.
Not sure why the PR builder is unable to find |
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.
Please, use real world response as fixture (the more recent, the better!)
@@ -191,7 +193,7 @@ instance FromJSON SimplePullRequest where | |||
<*> o .: "html_url" | |||
<*> o .: "updated_at" | |||
<*> o .:? "body" | |||
<*> o .: "assignees" |
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'm 100% sure that API returns a list, and GitHub docs are wrong. You can have multiple assignees for PR/Issue.
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.
Check: https://api.github.com/repos/phadej/github/pulls/285, there are both keys "assignee" and "assignees"
What do you mean by using the real world response as a fixture? |
@adnelson e.g. the current version of result for that the PR in your fixture https://api.github.com/repos/baxterthehacker/public-repo/pulls/1 has Real-world: don't copy old fixtures from somewhere, grab new ones from the API. |
@phadej I think the problem was that I was confusing the |
Alright, so I added three more fixtures, one that I had of the pull request event, and the two that you had given for pull requests, making four test cases in total. I added some logic which allows either the |
src/GitHub/Data/PullRequests.hs
Outdated
, pullRequestBase :: !PullRequestCommit | ||
, pullRequestCommits :: !Count | ||
, pullRequestMerged :: !Bool | ||
, pullRequestMergeable :: !(Maybe Bool) | ||
, pullRequestMergeableState :: !MergeableState |
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.
why this is removed? (and review comments?)
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.
ah sorry, that was due to my confusion between pull request / pull request event. I'll put it back in
src/GitHub/Data/PullRequests.hs
Outdated
@@ -180,8 +184,22 @@ instance Binary PullRequestReference | |||
-- JSON instances | |||
------------------------------------------------------------------------------- | |||
|
|||
-- | Helper function, reads either the "assignee" OR "assigneed" OR | |||
-- both from a JSON object. | |||
getAssignees :: Object -> Parser (Vector SimpleUser) |
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'd trust there's always assignees
, if there and endpoint which doesn't return plural assignees
?
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 example has an assignee
key but no assignees
keys.
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.
But its current variant https://api.github.com/repos/octocat/Hello-World/pulls does have assignees
. GitHub documentation is outdated, because examples are manually written.
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.
Is there a downside to including both? If we include both then it will work either way. You yourself earlier posted an example which contained both keys (as does the one in that link). I'm fine removing it but this seems like the way to accommodate all configurations which are likely to appear.
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.
@phadej if it's a dealbreaker for getting this merged then I can remove the assignee
part
@phadej any thoughts on this? |
@phadej just checking in here... |
@adnelson : New maintainer here. |
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.
Please resolve conflicts.
I'm not positive this covers every variant of a pull request event, but prior to this change the
FromJSON
instance failed to decode the example json (which is where the JSON I included here comes from) in the API docs, and now it does.