Skip to content

fix the PullRequest object so it can parse#285

Open
adnelson wants to merge 6 commits into
haskell-github:masterfrom
adnelson:fix_pull_request
Open

fix the PullRequest object so it can parse#285
adnelson wants to merge 6 commits into
haskell-github:masterfrom
adnelson:fix_pull_request

Conversation

@adnelson

Copy link
Copy Markdown

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.

| PullRequestUnassigned
| PullRequestLabeled
| PullRequestUnlabeled
| PullRequestReviewRequested

Copy link
Copy Markdown
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

adnelson commented Aug 1, 2017

Copy link
Copy Markdown
Author

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

@phadej phadej left a comment

Copy link
Copy Markdown
Contributor

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

<*> o .: "html_url"
<*> o .: "updated_at"
<*> o .:? "body"
<*> o .: "assignees"

Copy link
Copy Markdown
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
Copy Markdown
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

adnelson commented Aug 1, 2017

Copy link
Copy Markdown
Author

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

@phadej

phadej commented Aug 2, 2017

Copy link
Copy Markdown
Contributor

@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

adnelson commented Aug 2, 2017

Copy link
Copy Markdown
Author

@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

adnelson commented Aug 2, 2017

Copy link
Copy Markdown
Author

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.

, pullRequestCommits :: !Count
, pullRequestMerged :: !Bool
, pullRequestMergeable :: !(Maybe Bool)
, pullRequestMergeableState :: !MergeableState

Copy link
Copy Markdown
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
Copy Markdown
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


-- | Helper function, reads either the "assignee" OR "assigneed" OR
-- both from a JSON object.
getAssignees :: Object -> Parser (Vector SimpleUser)

Copy link
Copy Markdown
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
Copy Markdown
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.

@phadej phadej Aug 2, 2017

Copy link
Copy Markdown
Contributor

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.

@adnelson adnelson Aug 3, 2017

Copy link
Copy Markdown
Author

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
Copy Markdown
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
Copy Markdown
Author

@phadej any thoughts on this?

@adnelson

adnelson commented Oct 3, 2017

Copy link
Copy Markdown
Author

@phadej just checking in here...

@andreasabel

Copy link
Copy Markdown
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)?

@andreasabel andreasabel left a comment

Copy link
Copy Markdown
Member

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