-
Notifications
You must be signed in to change notification settings - Fork 752
FEAT: Implement enabling auto merge for PR by GraphQL #2056
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
18e5d72
feat: implement support for general GraphQL Request and Response
nyatda0116 e20a6b1
feat: implement get PR id of GraphQL feature and enabling auto merge …
nyatda0116 b9d2900
test: implement test for enable pull request auto merge
nyatda0116 1564259
Tidy up GraphQL methods and classes
bitwiseman 5e59885
Additional cleanup and code coverage
bitwiseman bb612c6
test: update test for tidy up
nyatda0116 f47c276
Update src/main/java/org/kohsuke/github/GitHubResponse.java
bitwiseman 6c6d016
Update src/main/java/org/kohsuke/github/GitHub.java
bitwiseman 64f7f3c
Update src/main/java/org/kohsuke/github/GitHub.java
bitwiseman cc0d0fd
Update src/main/java/org/kohsuke/github/GitHub.java
bitwiseman 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 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
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
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
93 changes: 93 additions & 0 deletions
93
src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.kohsuke.github.internal.graphql.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* A response of GraphQL. | ||
* <p> | ||
* This class is used to parse the response of GraphQL. | ||
* </p> | ||
* | ||
* @param <T> | ||
* the type of data | ||
*/ | ||
public class GHGraphQLResponse<T> { | ||
|
||
private final T data; | ||
|
||
private final List<GraphQLError> errors; | ||
|
||
/** | ||
* @param data | ||
* GraphQL success response | ||
* @param errors | ||
* GraphQL failure response, This will be empty if not fail | ||
*/ | ||
@JsonCreator | ||
@SuppressFBWarnings(value = { "EI_EXPOSE_REP2" }, justification = "Spotbugs also doesn't like this") | ||
public GHGraphQLResponse(@JsonProperty("data") T data, @JsonProperty("errors") List<GraphQLError> errors) { | ||
if (errors == null) { | ||
errors = Collections.emptyList(); | ||
} | ||
this.data = data; | ||
this.errors = Collections.unmodifiableList(errors); | ||
} | ||
|
||
/** | ||
* @return request is succeeded. True when error list is empty. | ||
*/ | ||
public boolean isSuccessful() { | ||
return errors.isEmpty(); | ||
} | ||
|
||
/** | ||
* @return GraphQL success response | ||
*/ | ||
public T getData() { | ||
if (!isSuccessful()) { | ||
throw new RuntimeException("Response not successful, data invalid"); | ||
} | ||
|
||
return data; | ||
} | ||
|
||
/** | ||
* @return GraphQL error messages from Github Response. Empty list when no errors occurred. | ||
*/ | ||
public List<String> getErrorMessages() { | ||
return errors.stream().map(GraphQLError::getMessage).collect(Collectors.toList()); | ||
} | ||
|
||
/** | ||
* A error of GraphQL response. Minimum implementation for GraphQL error. | ||
*/ | ||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, | ||
justification = "JSON API") | ||
private static class GraphQLError { | ||
private String message; | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
} | ||
|
||
/** | ||
* A GraphQL response with basic Object data type. | ||
*/ | ||
public static class ObjectResponse extends GHGraphQLResponse<Object> { | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@JsonCreator | ||
@SuppressFBWarnings(value = { "EI_EXPOSE_REP2" }, justification = "Spotbugs also doesn't like this") | ||
public ObjectResponse(@JsonProperty("data") Object data, @JsonProperty("errors") List<GraphQLError> errors) { | ||
super(data, errors); | ||
} | ||
} | ||
} |
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.