Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

adnelson
Copy link

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.

@@ -160,6 +159,9 @@ data PullRequestEventType
| PullRequestUnassigned
| PullRequestLabeled
| PullRequestUnlabeled
| PullRequestReviewRequested
Copy link
Author

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.

@phadej phadej self-assigned this Jul 31, 2017
@adnelson
Copy link
Author

adnelson commented Aug 1, 2017

Not sure why the PR builder is unable to find fixtures/pull-request.json; it's in the same directory as other fixtures and it worked locally

Copy link
Contributor

@phadej phadej left a 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"
Copy link
Contributor

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.

Copy link
Contributor

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"

@adnelson
Copy link
Author

adnelson commented Aug 1, 2017

What do you mean by using the real world response as a fixture?

@phadej
Copy link
Contributor

phadej commented Aug 2, 2017

@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 assignees list.

Real-world: don't copy old fixtures from somewhere, grab new ones from the API.

@adnelson
Copy link
Author

adnelson commented Aug 2, 2017

@phadej I think the problem was that I was confusing the PullRequest and PullRequestEvent types. I'll add fixtures for each case and test them separately

@adnelson
Copy link
Author

adnelson commented Aug 2, 2017

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 assignee or assignees keys, or both, to be present in a pull request blob.

, pullRequestBase :: !PullRequestCommit
, pullRequestCommits :: !Count
, pullRequestMerged :: !Bool
, pullRequestMergeable :: !(Maybe Bool)
, pullRequestMergeableState :: !MergeableState
Copy link
Contributor

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?)

Copy link
Author

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

@@ -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)
Copy link
Contributor

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?

Copy link
Author

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.

Copy link
Contributor

@phadej phadej Aug 2, 2017

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.

Copy link
Author

@adnelson adnelson Aug 3, 2017

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.

Copy link
Author

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

@adnelson
Copy link
Author

@phadej any thoughts on this?

@adnelson
Copy link
Author

adnelson commented Oct 3, 2017

@phadej just checking in here...

@andreasabel
Copy link
Member

@adnelson : New maintainer here.
Are you willing to fix the conflicts so that this PR can be merged (assuming it is still serving its purpose)?

Copy link
Member

@andreasabel andreasabel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants