FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

pull_request action "edited": changes by seregamorph · Pull Request #979 · hub4j/github-api · GitHub

pull_request action "edited": changes - #979

Merged
bitwiseman merged 6 commits into
hub4j:masterfrom
seregamorph:feature/pull_request-edited
Nov 24, 2020
Merged

pull_request action "edited": changes#979
bitwiseman merged 6 commits into
hub4j:masterfrom
seregamorph:feature/pull_request-edited

Conversation

seregamorph commented Nov 18, 2020
edited
Loading

Copy link
Copy Markdown
Contributor

Description

Webhook with X-GitHub-Event: pull_request and "action": "edited" has a field "changes" that is not present in GHEventPayload.PullRequest. I've found three triggers that leads to "edited" action:

  • Change PR title:
...
  "changes": {
    "title": {
      "from": "REST-276 - easy-random"
    }
  },
...

(full payload - in test data)

  • Change PR description:
...
"changes": {
    "body": {
      "from": "**JIRA Ticket URL:**\r\nhttps://jira.devfactory.com/browse/REST-276\r\n\r\n..."
    }
  },
...
  • Change target branch:
...
  "changes": {
    "base": {
      "ref": {
        "from": "develop"
      },
      "sha": {
        "from": "4b0f3b9fd582b071652ccfccd10bfc8c143cff96"
      }
    }
  },
...

So, "changes" fields contain old value that was changed, while pull_request object has latest values (see UT json payloads). Any other changes of a PR in GitHub UI leads to other types of notifications (e.g. action is assigned or ready_for_review or labeled).

@SuppressFBWarnings("UWF_UNWRITTEN_FIELD")
public class GHPullRequestChanges {

private GHCommitPointer base;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

base changed - covered with UT
title changed - covered with UT
body changed - cover on demand

assertThat(event.getPullRequest().getTitle(), is("REST-276 - easy-random"));
assertThat(event.getChanges().getBase().getRef().getFrom(), is("develop"));
assertThat(event.getChanges().getBase().getSha().getFrom(), is("4b0f3b9fd582b071652ccfccd10bfc8c143cff96"));
assertThat(event.getPullRequest().getBody(), startsWith("**JIRA Ticket URL:**"));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

body not changed - hence "changes" does not contain it

bitwiseman 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Minor changes to test.

assertThat(event.getChanges().getBase(), nullValue());
assertThat(event.getPullRequest().getBody(), startsWith("**JIRA Ticket URL:**"));
assertThat(event.getChanges().getBody(), nullValue());
assertThat(event.getChanges(). getChanges(), nullValue());

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
assertThat(event.getChanges(). getChanges(), nullValue());

Copy link
Copy Markdown
Contributor Author

@bitwiseman not sure what changes did you expect. My logic was: for three fields: title, body and base check old value (in "changes" field) and current value (in "pull_request field). There is a small test enhancement.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL