-
Notifications
You must be signed in to change notification settings - Fork 730
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
pull_request action "edited": changes #979
Merged
bitwiseman
merged 6 commits into
hub4j:master
from
seregamorph:feature/pull_request-edited
Nov 24, 2020
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
04b283c
pull_request action "edited": changes
seregamorph 9ad0329
Apply suggestions from code review
bitwiseman 8c81e48
Update src/test/java/org/kohsuke/github/GHEventPayloadTest.java
bitwiseman 4415ac8
Update src/test/java/org/kohsuke/github/GHEventPayloadTest.java
bitwiseman ca365b1
Merge remote-tracking branch 'origin/master' into feature/pull_reques…
seregamorph 0feb520
pull_request action "edited": changes - test
seregamorph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
86 changes: 86 additions & 0 deletions
86
src/main/java/org/kohsuke/github/GHPullRequestChanges.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package org.kohsuke.github; | ||
|
||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
|
||
/** | ||
* Wrapper to define changed fields on pull_request action="edited" | ||
* | ||
* @see GHEventPayload.PullRequest | ||
*/ | ||
@SuppressFBWarnings("UWF_UNWRITTEN_FIELD") | ||
public class GHPullRequestChanges { | ||
|
||
private GHCommitPointer base; | ||
private GHFrom title; | ||
private GHFrom body; | ||
|
||
/** | ||
* Old target branch for pull request. | ||
* | ||
* @return old target branch info (or null if not changed) | ||
*/ | ||
public GHCommitPointer getBase() { | ||
return base; | ||
} | ||
|
||
/** | ||
* Old pull request title. | ||
* | ||
* @return old pull request title (or null if not changed) | ||
*/ | ||
public GHFrom getTitle() { | ||
return title; | ||
} | ||
|
||
/** | ||
* Old pull request body. | ||
* | ||
* @return old pull request body (or null if not changed) | ||
*/ | ||
public GHFrom getBody() { | ||
return body; | ||
} | ||
|
||
/** | ||
* @see org.kohsuke.github.GHCommitPointer | ||
*/ | ||
public static class GHCommitPointer { | ||
private GHFrom ref; | ||
private GHFrom sha; | ||
|
||
/** | ||
* Named ref to the commit. This (from value) appears to be a "short ref" that doesn't include "refs/heads/" | ||
* portion. | ||
* | ||
* @return the ref | ||
*/ | ||
public GHFrom getRef() { | ||
return ref; | ||
} | ||
|
||
/** | ||
* SHA1 of the commit. | ||
* | ||
* @return sha | ||
*/ | ||
public GHFrom getSha() { | ||
return sha; | ||
} | ||
} | ||
|
||
/** | ||
* Wrapper for changed values. | ||
*/ | ||
public static class GHFrom { | ||
private String from; | ||
|
||
/** | ||
* Previous value that was changed. | ||
* | ||
* @return previous value | ||
*/ | ||
public String getFrom() { | ||
return from; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,6 +214,33 @@ public void pull_request() throws Exception { | |
assertThat(event.getSender().getLogin(), is("baxterthehacker")); | ||
} | ||
|
||
@Test | ||
public void pull_request_edited_base() throws Exception { | ||
GHEventPayload.PullRequest event = GitHub.offline() | ||
.parseEventPayload(payload.asReader(), GHEventPayload.PullRequest.class); | ||
|
||
assertThat(event.getAction(), is("edited")); | ||
assertThat(event.getChanges().getTitle(), nullValue()); | ||
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:**")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. body not changed - hence |
||
assertThat(event.getChanges().getBody(), nullValue()); | ||
bitwiseman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
@Test | ||
public void pull_request_edited_title() throws Exception { | ||
GHEventPayload.PullRequest event = GitHub.offline() | ||
.parseEventPayload(payload.asReader(), GHEventPayload.PullRequest.class); | ||
|
||
assertThat(event.getAction(), is("edited")); | ||
assertThat(event.getChanges().getTitle().getFrom(), is("REST-276 - easy-random")); | ||
assertThat(event.getPullRequest().getTitle(), is("REST-276 - easy-random 4.3.0")); | ||
assertThat(event.getChanges().getBase(), nullValue()); | ||
assertThat(event.getPullRequest().getBody(), startsWith("**JIRA Ticket URL:**")); | ||
assertThat(event.getChanges().getBody(), nullValue()); | ||
bitwiseman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
@Test | ||
public void pull_request_labeled() throws Exception { | ||
GHEventPayload.PullRequest event = GitHub.offline() | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
base
changed - covered with UTtitle
changed - covered with UTbody
changed - cover on demand