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

pullRequestReview.review.htmlUrl #946

Merged

Conversation

seregamorph
Copy link
Contributor

Description

Webhook event GHPullRequestReviewEvent: pull_request_review has review object in it which declares html_url field:

{
  "action": "submitted",
  "review": {
    "id": 496232606,
    "node_id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3NDk2MjMyNjA2",
    "user": {
      "login": "schernov-xo",
      "id": 41187778,
      "node_id": "MDQ6VXNlcjQxMTg3Nzc4",
      "avatar_url": "https://avatars3.githubusercontent.com/u/41187778?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/schernov-xo",
      "html_url": "https://github.com/schernov-xo",
      "followers_url": "https://api.github.com/users/schernov-xo/followers",
      "following_url": "https://api.github.com/users/schernov-xo/following{/other_user}",
      "gists_url": "https://api.github.com/users/schernov-xo/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/schernov-xo/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/schernov-xo/subscriptions",
      "organizations_url": "https://api.github.com/users/schernov-xo/orgs",
      "repos_url": "https://api.github.com/users/schernov-xo/repos",
      "events_url": "https://api.github.com/users/schernov-xo/events{/privacy}",
      "received_events_url": "https://api.github.com/users/schernov-xo/received_events",
      "type": "User",
      "site_admin": false
    },
    "body": "",
    "commit_id": "c3acd4733a645e1c6ae3b6da83068ae12099f616",
    "submitted_at": "2020-09-25T09:52:57Z",
    "state": "commented",
    "html_url": "https://github.com/trilogy-group/northplains-telescope-api/pull/21#pullrequestreview-496232606",
    "pull_request_url": "https://api.github.com/repos/trilogy-group/northplains-telescope-api/pulls/21",
...

Old implementation ignores it (always null).

Proof: see the test, event existing test payload pull_request_review.json has it (ignored in test).

Before submitting a PR:

We love getting PRs, but we hate asking people for the same basic changes every time.

  • Push your changes to a branch other than master. Create your PR from that branch.
  • Add JavaDocs and other comments
  • Write tests that run and pass in CI. See CONTRIBUTING.md for details on how to capture snapshot data.
  • Run mvn clean compile locally. This may reformat your code, commit those changes.
  • Run mvn -D enable-ci clean install site locally. If this command doesn't succeed, your change will not pass CI.

When creating a PR:

  • Fill in the "Description" above.
  • Enable "Allow edits from maintainers".

@@ -46,6 +46,7 @@
private String commit_id;
private GHPullRequestReviewState state;
private String submitted_at;
private String html_url;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ObjectMapper configuration explicitly declares snake_case strategy, but there is no single standard of field naming - I see both standard java (htmlUrl) and snake case (html_url) over the project (only fields, not getters for sure). This is confusing, IMHO it should be better to standardize it (personal preference - to java).

Copy link
Member

Choose a reason for hiding this comment

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

@seregamorph "standardize to java naming" - agreed. It just hasn't been a priority. Especially since we don't have
sufficient code coverage to have high confidence in tests ensuring it is done right. PR welcome.

@@ -102,7 +103,7 @@ public GHPullRequestReviewState getState() {

@Override
public URL getHtmlUrl() {
return null;
return GitHubClient.parseURL(html_url);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

back compatibility saved. If field is not present, the return value is still null

@seregamorph
Copy link
Contributor Author

Please note, that https://docs.github.com/en/rest/reference/pulls#reviews does not explicitly declare this parameter. I assume it only present in the webhook.

@bitwiseman bitwiseman merged commit f1ca0b5 into hub4j:master Sep 25, 2020
@seregamorph seregamorph deleted the feature/pull-request-review-html-url branch September 26, 2020 09:03
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.

2 participants