From 18e5d726307157ef3690bee6d4c41279b581cb66 Mon Sep 17 00:00:00 2001 From: siwoo Date: Mon, 17 Mar 2025 15:32:59 +0900 Subject: [PATCH 01/10] feat: implement support for general GraphQL Request and Response --- src/main/java/org/kohsuke/github/GitHub.java | 12 +++ .../org/kohsuke/github/GitHubResponse.java | 34 +++++++- .../java/org/kohsuke/github/Requester.java | 34 ++++++++ .../graphql/response/GHGraphQLResponse.java | 83 +++++++++++++++++++ 4 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/kohsuke/github/graphql/response/GHGraphQLResponse.java diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 8ef21e2cd0..726957c5b8 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -1299,6 +1299,18 @@ Requester createRequest() { return requester; } + /** + * Creates a request to GitHub GraphQL API. + * + * @param query + * the query for the GraphQL + * @return the requester + */ + @Nonnull + Requester createGraphQLRequest(String query) { + return createRequest().method("POST").with("query", query).withUrlPath("/graphql"); + } + /** * Intern. * diff --git a/src/main/java/org/kohsuke/github/GitHubResponse.java b/src/main/java/org/kohsuke/github/GitHubResponse.java index defc094b64..cab47f0ca1 100644 --- a/src/main/java/org/kohsuke/github/GitHubResponse.java +++ b/src/main/java/org/kohsuke/github/GitHubResponse.java @@ -1,10 +1,10 @@ package org.kohsuke.github; import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.InjectableValues; -import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.*; import org.apache.commons.io.IOUtils; import org.kohsuke.github.connector.GitHubConnectorResponse; +import org.kohsuke.github.graphql.response.GHGraphQLResponse; import java.io.IOException; import java.io.InputStream; @@ -136,6 +136,36 @@ static T parseBody(GitHubConnectorResponse connectorResponse, T instance) th } } + /** + * Parses a {@link GitHubConnectorResponse} body into a new instance of {@code GHGraphQLResponse}. + * + * @param + * the type + * @param connectorResponse + * the response info to parse. + * @param type + * the type to be constructed in GraphQLResponse. + * @return GHGraphQLResponse + * + * @throws IOException + * if there is an I/O Exception. + */ + @CheckForNull + static GHGraphQLResponse parseGraphQLBody(GitHubConnectorResponse connectorResponse, Class type) + throws IOException { + String data = getBodyAsString(connectorResponse); + try { + ObjectReader objectReader = GitHubClient.getMappingObjectReader(connectorResponse); + JavaType targetType = objectReader.getTypeFactory().constructParametricType(GHGraphQLResponse.class, type); + ObjectReader targetReader = objectReader.forType(targetType); + return targetReader.readValue(data); + } catch (JsonMappingException | JsonParseException e) { + String message = "Failed to deserialize: " + data; + LOGGER.log(Level.FINE, message); + throw e; + } + } + /** * Gets the body of the response as a {@link String}. * diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index ad65f1a2d1..b191a0a9c8 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -27,6 +27,7 @@ import org.apache.commons.io.IOUtils; import org.kohsuke.github.connector.GitHubConnectorResponse; import org.kohsuke.github.function.InputStreamFunction; +import org.kohsuke.github.graphql.response.GHGraphQLResponse; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -103,6 +104,39 @@ public T fetchInto(@Nonnull T existingInstance) throws IOException { .body(); } + /** + * Sends a GraphQL request with no response + * + * @throws IOException + * the io exception + */ + public void sendGraphQL() throws IOException { + fetchGraphQLResponse(Object.class); + } + + /** + * Sends a request and parses the response into the given type via databinding in GraphQL response. + * + * @param + * the type parameter + * @param type + * the type + * @return an instance of {@code GHGraphQLResponse} + * @throws IOException + * if the server returns 4xx/5xx responses. + */ + public T fetchGraphQLResponse(@Nonnull Class type) throws IOException { + GHGraphQLResponse response = client + .sendRequest(this, connectorResponse -> GitHubResponse.parseGraphQLBody(connectorResponse, type)) + .body(); + + if (!response.isSuccessful()) { + throw new IOException("GraphQL request failed by:" + response.getErrorMessages()); + } + + return response.getData(); + } + /** * Makes a request and just obtains the HTTP status code. Method does not throw exceptions for many status codes * that would otherwise throw. diff --git a/src/main/java/org/kohsuke/github/graphql/response/GHGraphQLResponse.java b/src/main/java/org/kohsuke/github/graphql/response/GHGraphQLResponse.java new file mode 100644 index 0000000000..717220ad0f --- /dev/null +++ b/src/main/java/org/kohsuke/github/graphql/response/GHGraphQLResponse.java @@ -0,0 +1,83 @@ +package org.kohsuke.github.graphql.response; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * A response of GraphQL. + *

+ * This class is used to parse the response of GraphQL. + *

+ * + * @param + * the type of data + */ +public class GHGraphQLResponse { + + private final T data; + + private final List 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 errors) { + this.data = data; + this.errors = errors; + } + + /** + * @return request is succeeded + */ + public Boolean isSuccessful() { + return errors == null || errors.isEmpty(); + } + + /** + * @return GraphQL success response + */ + public T getData() { + if (!isSuccessful()) { + throw new RuntimeException("This response is Errors occurred response"); + } + + return data; + } + + /** + * @return GraphQL error messages from Github Response + */ + public List getErrorMessages() { + if (isSuccessful()) { + throw new RuntimeException("No errors occurred"); + } + + return errors.stream().map(GHGraphQLError::getErrorMessage).collect(Collectors.toList()); + } + + /** + * A error of GraphQL response. Minimum implementation for GraphQL error. + */ + static class GHGraphQLError { + + private final String errorMessage; + + @JsonCreator + public GHGraphQLError(@JsonProperty("message") String errorMessage) { + this.errorMessage = errorMessage; + } + + public String getErrorMessage() { + return errorMessage; + } + } +} From e20a6b1f9397647c634ed042cc4ca98f51ea3ef4 Mon Sep 17 00:00:00 2001 From: siwoo Date: Mon, 17 Mar 2025 15:33:58 +0900 Subject: [PATCH 02/10] feat: implement get PR id of GraphQL feature and enabling auto merge for PR feature --- .../org/kohsuke/github/GHPullRequest.java | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index 128f819d5b..5fb2546884 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -23,6 +23,8 @@ */ package org.kohsuke.github; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; @@ -629,6 +631,132 @@ public enum MergeMethod { REBASE } + /** + * Get pull request id for GraphQL + * + * @return The pull request id for GraphQL + * @throws IOException + * the io exception + */ + public String getGraphqlPullRequestId() throws IOException { + if (owner == null) { + throw new IllegalStateException("Repository owner is required to get the pull request ID"); + } + String repositoryName = owner.getName(); + String ownerName = owner.getOwnerName(); + + String graphqlBody = String.format( + "query GetPullRequestID { repository(name: \"%s\", owner: \"%s\") { pullRequest(number: %d) { id } } }", + repositoryName, + ownerName, + number); + + GetGraphqlPullRequestIdResponse response = root().createGraphQLRequest(graphqlBody) + .fetchGraphQLResponse(GetGraphqlPullRequestIdResponse.class); + + return response.getId(); + } + + /** + * The response from the GraphQL query to get the pull request ID. Minimum required fields are included. + */ + private static class GetGraphqlPullRequestIdResponse { + private final PullRequestOwnerRepository repository; + + @JsonCreator + public GetGraphqlPullRequestIdResponse(@JsonProperty("repository") PullRequestOwnerRepository repository) { + this.repository = repository; + } + + public String getId() { + return repository.getId(); + } + + private static class PullRequestOwnerRepository { + private final GraphQLPullRequest pullRequest; + + @JsonCreator + public PullRequestOwnerRepository(@JsonProperty("pullRequest") GraphQLPullRequest pullRequest) { + this.pullRequest = pullRequest; + } + + public String getId() { + return pullRequest.getId(); + } + + private static class GraphQLPullRequest { + private final String id; + + @JsonCreator + public GraphQLPullRequest(@JsonProperty("id") String id) { + this.id = id; + } + + public String getId() { + return id; + } + } + } + } + + /** + * Request to enable auto merge for a pull request. + * + * @param authorEmail + * The email address to associate with this merge. + * @param clientMutationId + * A unique identifier for the client performing the mutation. + * @param commitBody + * Commit body to use for the commit when the PR is mergable; if omitted, a default message will be used. + * NOTE: when merging with a merge queue any input value for commit message is ignored. + * @param commitHeadline + * Commit headline to use for the commit when the PR is mergable; if omitted, a default message will be + * used. NOTE: when merging with a merge queue any input value for commit headline is ignored. + * @param expectedHeadOid + * The expected head OID of the pull request. + * @param mergeMethod + * The merge method to use. If omitted, defaults to `MERGE`. NOTE: when merging with a merge queue any + * input value for merge method is ignored. + * @throws IOException + * the io exception + */ + public void requestEnableAutoMerge(String authorEmail, + String clientMutationId, + String commitBody, + String commitHeadline, + String expectedHeadOid, + MergeMethod mergeMethod) throws IOException { + + StringBuilder inputBuilder = new StringBuilder(); + inputBuilder.append(" pullRequestId: \"").append(getGraphqlPullRequestId()).append("\""); + + if (authorEmail != null) { + inputBuilder.append(" authorEmail: \"").append(authorEmail).append("\""); + } + if (clientMutationId != null) { + inputBuilder.append(" clientMutationId: \"").append(clientMutationId).append("\""); + } + if (commitBody != null) { + inputBuilder.append(" commitBody: \"").append(commitBody).append("\""); + } + if (commitHeadline != null) { + inputBuilder.append(" commitHeadline: \"").append(commitHeadline).append("\""); + } + if (expectedHeadOid != null) { + inputBuilder.append(" expectedHeadOid: \"").append(expectedHeadOid).append("\""); + } + if (mergeMethod != null) { + inputBuilder.append(" mergeMethod: ").append(mergeMethod); + } + + String graphqlBody = "mutation EnableAutoMerge { enablePullRequestAutoMerge(input: {" + inputBuilder + "}) { " + + "pullRequest { id } } }"; + + root().createGraphQLRequest(graphqlBody).sendGraphQL(); + + refresh(); + } + /** * The status of auto merging a {@linkplain GHPullRequest}. * From b9d29006331bf5a26c10543e868a5cf938646fbe Mon Sep 17 00:00:00 2001 From: siwoo Date: Mon, 17 Mar 2025 15:34:24 +0900 Subject: [PATCH 03/10] test: implement test for enable pull request auto merge --- .../github-api/reflect-config.json | 120 ++++++ .../github-api/serialization-config.json | 24 ++ .../kohsuke/github/GHPullRequestMockTest.java | 17 + .../org/kohsuke/github/GHPullRequestTest.java | 59 +++ .../response/GHGraphQLResponseMockTest.java | 69 ++++ .../__files/1-user.json | 36 ++ .../__files/2-r_s_for-test.json | 139 +++++++ .../__files/3-r_s_f_pulls_9.json | 372 ++++++++++++++++++ .../__files/6-r_s_f_pulls_9.json | 372 ++++++++++++++++++ .../__files/7-users_seate.json | 35 ++ .../mappings/1-user.json | 47 +++ .../mappings/2-r_s_for-test.json | 47 +++ .../mappings/3-r_s_f_pulls_9.json | 50 +++ .../mappings/4-graphql.json | 50 +++ .../mappings/5-graphql.json | 50 +++ .../mappings/6-r_s_f_pulls_9.json | 49 +++ .../mappings/7-users_seate.json | 47 +++ .../__files/1-user.json | 36 ++ .../__files/2-r_s_for-test.json | 139 +++++++ .../__files/3-r_s_f_pulls_9.json | 372 ++++++++++++++++++ .../mappings/1-user.json | 47 +++ .../mappings/2-r_s_for-test.json | 47 +++ .../mappings/3-r_s_f_pulls_9.json | 47 +++ .../mappings/4-graphql.json | 50 +++ .../mappings/5-graphql.json | 50 +++ 25 files changed, 2371 insertions(+) create mode 100644 src/test/java/org/kohsuke/github/graphql/response/GHGraphQLResponseMockTest.java create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/1-user.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/2-r_s_for-test.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/3-r_s_f_pulls_9.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/6-r_s_f_pulls_9.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/7-users_seate.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/1-user.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/2-r_s_for-test.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/3-r_s_f_pulls_9.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/4-graphql.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/5-graphql.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/6-r_s_f_pulls_9.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/7-users_seate.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/1-user.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/2-r_s_for-test.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/3-r_s_f_pulls_9.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/1-user.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/2-r_s_for-test.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/3-r_s_f_pulls_9.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/4-graphql.json create mode 100644 src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/5-graphql.json diff --git a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json index 4d691214ec..5008bf2228 100644 --- a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json +++ b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json @@ -6703,5 +6703,125 @@ "allDeclaredMethods": true, "allPublicClasses": true, "allDeclaredClasses": true + }, + { + "name": "org.kohsuke.github.GHPullRequest$EnablePullRequestAutoMergeResponse", + "allPublicFields": true, + "allDeclaredFields": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredConstructors": true, + "queryAllPublicMethods": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredMethods": true, + "allPublicClasses": true, + "allDeclaredClasses": true + }, + { + "name": "org.kohsuke.github.GHPullRequest$EnablePullRequestAutoMergeResponse$EnablePullRequestAutoMerge", + "allPublicFields": true, + "allDeclaredFields": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredConstructors": true, + "queryAllPublicMethods": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredMethods": true, + "allPublicClasses": true, + "allDeclaredClasses": true + }, + { + "name": "org.kohsuke.github.GHPullRequest$EnablePullRequestAutoMergeResponse$EnablePullRequestAutoMerge$EnablePullRequestAutoMergePullRequest", + "allPublicFields": true, + "allDeclaredFields": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredConstructors": true, + "queryAllPublicMethods": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredMethods": true, + "allPublicClasses": true, + "allDeclaredClasses": true + }, + { + "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse", + "allPublicFields": true, + "allDeclaredFields": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredConstructors": true, + "queryAllPublicMethods": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredMethods": true, + "allPublicClasses": true, + "allDeclaredClasses": true + }, + { + "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse$PullRequestOwnerRepository", + "allPublicFields": true, + "allDeclaredFields": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredConstructors": true, + "queryAllPublicMethods": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredMethods": true, + "allPublicClasses": true, + "allDeclaredClasses": true + }, + { + "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse$PullRequestOwnerRepository$GraphQLPullRequest", + "allPublicFields": true, + "allDeclaredFields": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredConstructors": true, + "queryAllPublicMethods": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredMethods": true, + "allPublicClasses": true, + "allDeclaredClasses": true + }, + { + "name": "org.kohsuke.github.graphql.response.GHGraphQLResponse", + "allPublicFields": true, + "allDeclaredFields": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredConstructors": true, + "queryAllPublicMethods": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredMethods": true, + "allPublicClasses": true, + "allDeclaredClasses": true + }, + { + "name": "org.kohsuke.github.graphql.response.GHGraphQLResponse$GHGraphQLError", + "allPublicFields": true, + "allDeclaredFields": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredConstructors": true, + "queryAllPublicMethods": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredMethods": true, + "allPublicClasses": true, + "allDeclaredClasses": true } ] diff --git a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json index 3e80bb939b..f50f497525 100644 --- a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json +++ b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json @@ -1342,5 +1342,29 @@ }, { "name": "org.kohsuke.github.SkipFromToString" + }, + { + "name": "org.kohsuke.github.GHPullRequest$EnablePullRequestAutoMergeResponse" + }, + { + "name": "org.kohsuke.github.GHPullRequest$EnablePullRequestAutoMergeResponse$EnablePullRequestAutoMerge" + }, + { + "name": "org.kohsuke.github.GHPullRequest$EnablePullRequestAutoMergeResponse$EnablePullRequestAutoMerge$EnablePullRequestAutoMergePullRequest" + }, + { + "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse" + }, + { + "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse$PullRequestOwnerRepository" + }, + { + "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse$PullRequestOwnerRepository$GraphQLPullRequest" + }, + { + "name": "org.kohsuke.github.graphql.response.GHGraphQLResponse" + }, + { + "name": "org.kohsuke.github.graphql.response.GHGraphQLResponse$GHGraphQLError" } ] diff --git a/src/test/java/org/kohsuke/github/GHPullRequestMockTest.java b/src/test/java/org/kohsuke/github/GHPullRequestMockTest.java index 45dd9af9f5..521f953f3f 100644 --- a/src/test/java/org/kohsuke/github/GHPullRequestMockTest.java +++ b/src/test/java/org/kohsuke/github/GHPullRequestMockTest.java @@ -5,6 +5,7 @@ import java.io.IOException; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -34,4 +35,20 @@ public void shouldMockGHPullRequest() throws IOException { assertThat("Mock should return true", pullRequest.isDraft()); } + /** + * Cannot get pull request graphQL id when there is no repository. + * + * @throws IOException + * the io exception + */ + @Test + public void getGraphQLPullRequestIdFailure() throws IOException { + GHPullRequest pullRequest = new GHPullRequest(); + + try { + pullRequest.getGraphqlPullRequestId(); + } catch (IllegalStateException e) { + assertThat(e.getMessage(), containsString("Repository owner is required to get the pull request ID")); + } + } } diff --git a/src/test/java/org/kohsuke/github/GHPullRequestTest.java b/src/test/java/org/kohsuke/github/GHPullRequestTest.java index 0a2e4a2712..2beff753dd 100644 --- a/src/test/java/org/kohsuke/github/GHPullRequestTest.java +++ b/src/test/java/org/kohsuke/github/GHPullRequestTest.java @@ -1036,6 +1036,65 @@ public void refreshFromSearchResults() throws Exception { pullRequestFromSearchResults.close(); } + /** + * + * Test enabling auto merge for pull request + * + * @throws IOException + * the Exception + */ + @Test + public void enablePullRequestAutoMerge() throws IOException { + String authorEmail = "sa20207@naver.com"; + String clientMutationId = "github-api"; + String commitBody = "This is commit body."; + String commitTitle = "This is commit title."; + String expectedCommitHeadOid = "4888b44d7204dd05680e90159af839c8b1194b6d"; + + GHPullRequest pullRequest = gitHub.getRepository("seate/for-test").getPullRequest(9); + + pullRequest.requestEnableAutoMerge(authorEmail, + clientMutationId, + commitBody, + commitTitle, + expectedCommitHeadOid, + GHPullRequest.MergeMethod.MERGE); + + AutoMerge autoMerge = pullRequest.getAutoMerge(); + assertThat(autoMerge.getEnabledBy().getEmail(), is(authorEmail)); + assertThat(autoMerge.getCommitMessage(), is(commitBody)); + assertThat(autoMerge.getCommitTitle(), is(commitTitle)); + assertThat(autoMerge.getMergeMethod(), is(GHPullRequest.MergeMethod.MERGE)); + } + + /** + * Test enabling auto merge for pull request with no verified email throws GraphQL exception + * + * @throws IOException + * the io exception + */ + @Test + public void enablePullRequestAutoMergeFailure() throws IOException { + String authorEmail = "failureEmail@gmail.com"; + String clientMutationId = "github-api"; + String commitBody = "This is commit body."; + String commitTitle = "This is commit title."; + String expectedCommitHeadOid = "4888b44d7204dd05680e90159af839c8b1194b6d"; + + GHPullRequest pullRequest = gitHub.getRepository("seate/for-test").getPullRequest(9); + + try { + pullRequest.requestEnableAutoMerge(authorEmail, + clientMutationId, + commitBody, + commitTitle, + expectedCommitHeadOid, + GHPullRequest.MergeMethod.MERGE); + } catch (IOException e) { + assertThat(e.getMessage(), containsString("does not have a verified email")); + } + } + /** * Gets the repository. * diff --git a/src/test/java/org/kohsuke/github/graphql/response/GHGraphQLResponseMockTest.java b/src/test/java/org/kohsuke/github/graphql/response/GHGraphQLResponseMockTest.java new file mode 100644 index 0000000000..1b205aae22 --- /dev/null +++ b/src/test/java/org/kohsuke/github/graphql/response/GHGraphQLResponseMockTest.java @@ -0,0 +1,69 @@ +package org.kohsuke.github.graphql.response; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; + +/** + * Test GHGraphQLResponse's methods + */ +class GHGraphQLResponseMockTest { + + /** + * Test get data throws exception when response means error + * + * @throws JsonProcessingException + */ + @Test + void getDataFailure() throws JsonProcessingException { + String graphQLErrorResponse = "{\"data\": {\"enablePullRequestAutoMerge\": null},\"errors\": [{\"type\": " + + "\"UNPROCESSABLE\",\"path\": [\"enablePullRequestAutoMerge\"],\"locations\": [{\"line\": 2," + + "\"column\": 5}],\"message\": \"hub4j does not have a verified email, which is required to enable " + + "auto-merging.\"}]}"; + + GHGraphQLResponse response = convertJsonToGraphQLResponse(graphQLErrorResponse); + + try { + response.getData(); + } catch (RuntimeException e) { + assertThat(e.getMessage(), containsString("This response is Errors occurred response")); + } + } + + /** + * Test getErrorMessages throws exception when response means not error + * + * @throws JsonProcessingException + */ + @Test + void getErrorMessagesFailure() throws JsonProcessingException { + String graphQLSuccessResponse = "{\"data\": {\"repository\": {\"pullRequest\": {\"id\": " + + "\"PR_TEMP_GRAPHQL_ID\"}}}}"; + + GHGraphQLResponse response = convertJsonToGraphQLResponse(graphQLSuccessResponse); + + try { + response.getErrorMessages(); + } catch (RuntimeException e) { + assertThat(e.getMessage(), containsString("No errors occurred")); + } + } + + private GHGraphQLResponse convertJsonToGraphQLResponse(String json) throws JsonProcessingException { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + ObjectReader objectReader = objectMapper.reader(); + JavaType javaType = objectReader.getTypeFactory() + .constructParametricType(GHGraphQLResponse.class, Object.class); + + return objectReader.forType(javaType).readValue(json); + } + +} diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/1-user.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/1-user.json new file mode 100644 index 0000000000..76578d3e42 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/1-user.json @@ -0,0 +1,36 @@ +{ + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false, + "name": "KIMSIWOO", + "company": "Inha university", + "blog": "", + "location": null, + "email": "sa20207@naver.com", + "hireable": null, + "bio": null, + "twitter_username": null, + "notification_email": "sa20207@naver.com", + "public_repos": 34, + "public_gists": 0, + "followers": 2, + "following": 2, + "created_at": "2021-07-02T07:40:16Z", + "updated_at": "2025-03-03T13:26:53Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/2-r_s_for-test.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/2-r_s_for-test.json new file mode 100644 index 0000000000..c2de0d78c0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/2-r_s_for-test.json @@ -0,0 +1,139 @@ +{ + "id": 933252913, + "node_id": "R_kgDON6BPMQ", + "name": "for-test", + "full_name": "seate/for-test", + "private": false, + "owner": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/seate/for-test", + "description": "깃허브 테스트용 레포", + "fork": false, + "url": "https://api.github.com/repos/seate/for-test", + "forks_url": "https://api.github.com/repos/seate/for-test/forks", + "keys_url": "https://api.github.com/repos/seate/for-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/seate/for-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/seate/for-test/teams", + "hooks_url": "https://api.github.com/repos/seate/for-test/hooks", + "issue_events_url": "https://api.github.com/repos/seate/for-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/seate/for-test/events", + "assignees_url": "https://api.github.com/repos/seate/for-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/seate/for-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/seate/for-test/tags", + "blobs_url": "https://api.github.com/repos/seate/for-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/seate/for-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/seate/for-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/seate/for-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/seate/for-test/languages", + "stargazers_url": "https://api.github.com/repos/seate/for-test/stargazers", + "contributors_url": "https://api.github.com/repos/seate/for-test/contributors", + "subscribers_url": "https://api.github.com/repos/seate/for-test/subscribers", + "subscription_url": "https://api.github.com/repos/seate/for-test/subscription", + "commits_url": "https://api.github.com/repos/seate/for-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/seate/for-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/seate/for-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/seate/for-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/seate/for-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/seate/for-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/seate/for-test/merges", + "archive_url": "https://api.github.com/repos/seate/for-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/seate/for-test/downloads", + "issues_url": "https://api.github.com/repos/seate/for-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/seate/for-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/seate/for-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/seate/for-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/seate/for-test/labels{/name}", + "releases_url": "https://api.github.com/repos/seate/for-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/seate/for-test/deployments", + "created_at": "2025-02-15T14:21:31Z", + "updated_at": "2025-03-15T16:06:51Z", + "pushed_at": "2025-03-15T16:17:01Z", + "git_url": "git://github.com/seate/for-test.git", + "ssh_url": "git@github.com:seate/for-test.git", + "clone_url": "https://github.com/seate/for-test.git", + "svn_url": "https://github.com/seate/for-test", + "homepage": null, + "size": 62, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "develop", + "permissions": { + "admin": true, + "maintain": true, + "push": true, + "triage": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": true, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE", + "security_and_analysis": { + "secret_scanning": { + "status": "disabled" + }, + "secret_scanning_push_protection": { + "status": "disabled" + }, + "dependabot_security_updates": { + "status": "disabled" + }, + "secret_scanning_non_provider_patterns": { + "status": "disabled" + }, + "secret_scanning_validity_checks": { + "status": "disabled" + } + }, + "network_count": 0, + "subscribers_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/3-r_s_f_pulls_9.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/3-r_s_f_pulls_9.json new file mode 100644 index 0000000000..11347dec30 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/3-r_s_f_pulls_9.json @@ -0,0 +1,372 @@ +{ + "url": "https://api.github.com/repos/seate/for-test/pulls/9", + "id": 2395455682, + "node_id": "PR_kwDON6BPMc6Ox8DC", + "html_url": "https://github.com/seate/for-test/pull/9", + "diff_url": "https://github.com/seate/for-test/pull/9.diff", + "patch_url": "https://github.com/seate/for-test/pull/9.patch", + "issue_url": "https://api.github.com/repos/seate/for-test/issues/9", + "number": 9, + "state": "open", + "locked": false, + "title": "github-api enable pull request auto merge test", + "user": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "github-api enable pull request auto merge test", + "created_at": "2025-03-15T16:07:53Z", + "updated_at": "2025-03-15T16:18:20Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "25a5888073ee3d2a975e012492950dddb8c346dc", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/seate/for-test/pulls/9/commits", + "review_comments_url": "https://api.github.com/repos/seate/for-test/pulls/9/comments", + "review_comment_url": "https://api.github.com/repos/seate/for-test/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/seate/for-test/issues/9/comments", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/4888b44d7204dd05680e90159af839c8b1194b6d", + "head": { + "label": "seate:test1", + "ref": "test1", + "sha": "4888b44d7204dd05680e90159af839c8b1194b6d", + "user": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 933252913, + "node_id": "R_kgDON6BPMQ", + "name": "for-test", + "full_name": "seate/for-test", + "private": false, + "owner": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/seate/for-test", + "description": "깃허브 테스트용 레포", + "fork": false, + "url": "https://api.github.com/repos/seate/for-test", + "forks_url": "https://api.github.com/repos/seate/for-test/forks", + "keys_url": "https://api.github.com/repos/seate/for-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/seate/for-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/seate/for-test/teams", + "hooks_url": "https://api.github.com/repos/seate/for-test/hooks", + "issue_events_url": "https://api.github.com/repos/seate/for-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/seate/for-test/events", + "assignees_url": "https://api.github.com/repos/seate/for-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/seate/for-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/seate/for-test/tags", + "blobs_url": "https://api.github.com/repos/seate/for-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/seate/for-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/seate/for-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/seate/for-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/seate/for-test/languages", + "stargazers_url": "https://api.github.com/repos/seate/for-test/stargazers", + "contributors_url": "https://api.github.com/repos/seate/for-test/contributors", + "subscribers_url": "https://api.github.com/repos/seate/for-test/subscribers", + "subscription_url": "https://api.github.com/repos/seate/for-test/subscription", + "commits_url": "https://api.github.com/repos/seate/for-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/seate/for-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/seate/for-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/seate/for-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/seate/for-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/seate/for-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/seate/for-test/merges", + "archive_url": "https://api.github.com/repos/seate/for-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/seate/for-test/downloads", + "issues_url": "https://api.github.com/repos/seate/for-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/seate/for-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/seate/for-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/seate/for-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/seate/for-test/labels{/name}", + "releases_url": "https://api.github.com/repos/seate/for-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/seate/for-test/deployments", + "created_at": "2025-02-15T14:21:31Z", + "updated_at": "2025-03-15T16:06:51Z", + "pushed_at": "2025-03-15T16:17:01Z", + "git_url": "git://github.com/seate/for-test.git", + "ssh_url": "git@github.com:seate/for-test.git", + "clone_url": "https://github.com/seate/for-test.git", + "svn_url": "https://github.com/seate/for-test", + "homepage": null, + "size": 62, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "develop" + } + }, + "base": { + "label": "seate:develop", + "ref": "develop", + "sha": "2bc9cde73b377e4d0ebda0d19f636644808388f5", + "user": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 933252913, + "node_id": "R_kgDON6BPMQ", + "name": "for-test", + "full_name": "seate/for-test", + "private": false, + "owner": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/seate/for-test", + "description": "깃허브 테스트용 레포", + "fork": false, + "url": "https://api.github.com/repos/seate/for-test", + "forks_url": "https://api.github.com/repos/seate/for-test/forks", + "keys_url": "https://api.github.com/repos/seate/for-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/seate/for-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/seate/for-test/teams", + "hooks_url": "https://api.github.com/repos/seate/for-test/hooks", + "issue_events_url": "https://api.github.com/repos/seate/for-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/seate/for-test/events", + "assignees_url": "https://api.github.com/repos/seate/for-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/seate/for-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/seate/for-test/tags", + "blobs_url": "https://api.github.com/repos/seate/for-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/seate/for-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/seate/for-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/seate/for-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/seate/for-test/languages", + "stargazers_url": "https://api.github.com/repos/seate/for-test/stargazers", + "contributors_url": "https://api.github.com/repos/seate/for-test/contributors", + "subscribers_url": "https://api.github.com/repos/seate/for-test/subscribers", + "subscription_url": "https://api.github.com/repos/seate/for-test/subscription", + "commits_url": "https://api.github.com/repos/seate/for-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/seate/for-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/seate/for-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/seate/for-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/seate/for-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/seate/for-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/seate/for-test/merges", + "archive_url": "https://api.github.com/repos/seate/for-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/seate/for-test/downloads", + "issues_url": "https://api.github.com/repos/seate/for-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/seate/for-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/seate/for-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/seate/for-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/seate/for-test/labels{/name}", + "releases_url": "https://api.github.com/repos/seate/for-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/seate/for-test/deployments", + "created_at": "2025-02-15T14:21:31Z", + "updated_at": "2025-03-15T16:06:51Z", + "pushed_at": "2025-03-15T16:17:01Z", + "git_url": "git://github.com/seate/for-test.git", + "ssh_url": "git@github.com:seate/for-test.git", + "clone_url": "https://github.com/seate/for-test.git", + "svn_url": "https://github.com/seate/for-test", + "homepage": null, + "size": 62, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "develop" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/seate/for-test/pulls/9" + }, + "html": { + "href": "https://github.com/seate/for-test/pull/9" + }, + "issue": { + "href": "https://api.github.com/repos/seate/for-test/issues/9" + }, + "comments": { + "href": "https://api.github.com/repos/seate/for-test/issues/9/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/seate/for-test/pulls/9/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/seate/for-test/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/seate/for-test/pulls/9/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/seate/for-test/statuses/4888b44d7204dd05680e90159af839c8b1194b6d" + } + }, + "author_association": "OWNER", + "auto_merge": { + "enabled_by": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "merge_method": "merge", + "commit_title": "This is commit title.", + "commit_message": "This is commit body." + }, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "blocked", + "merged_by": null, + "comments": 1, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 16, + "additions": 642, + "deletions": 0, + "changed_files": 19 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/6-r_s_f_pulls_9.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/6-r_s_f_pulls_9.json new file mode 100644 index 0000000000..11347dec30 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/6-r_s_f_pulls_9.json @@ -0,0 +1,372 @@ +{ + "url": "https://api.github.com/repos/seate/for-test/pulls/9", + "id": 2395455682, + "node_id": "PR_kwDON6BPMc6Ox8DC", + "html_url": "https://github.com/seate/for-test/pull/9", + "diff_url": "https://github.com/seate/for-test/pull/9.diff", + "patch_url": "https://github.com/seate/for-test/pull/9.patch", + "issue_url": "https://api.github.com/repos/seate/for-test/issues/9", + "number": 9, + "state": "open", + "locked": false, + "title": "github-api enable pull request auto merge test", + "user": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "github-api enable pull request auto merge test", + "created_at": "2025-03-15T16:07:53Z", + "updated_at": "2025-03-15T16:18:20Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "25a5888073ee3d2a975e012492950dddb8c346dc", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/seate/for-test/pulls/9/commits", + "review_comments_url": "https://api.github.com/repos/seate/for-test/pulls/9/comments", + "review_comment_url": "https://api.github.com/repos/seate/for-test/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/seate/for-test/issues/9/comments", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/4888b44d7204dd05680e90159af839c8b1194b6d", + "head": { + "label": "seate:test1", + "ref": "test1", + "sha": "4888b44d7204dd05680e90159af839c8b1194b6d", + "user": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 933252913, + "node_id": "R_kgDON6BPMQ", + "name": "for-test", + "full_name": "seate/for-test", + "private": false, + "owner": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/seate/for-test", + "description": "깃허브 테스트용 레포", + "fork": false, + "url": "https://api.github.com/repos/seate/for-test", + "forks_url": "https://api.github.com/repos/seate/for-test/forks", + "keys_url": "https://api.github.com/repos/seate/for-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/seate/for-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/seate/for-test/teams", + "hooks_url": "https://api.github.com/repos/seate/for-test/hooks", + "issue_events_url": "https://api.github.com/repos/seate/for-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/seate/for-test/events", + "assignees_url": "https://api.github.com/repos/seate/for-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/seate/for-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/seate/for-test/tags", + "blobs_url": "https://api.github.com/repos/seate/for-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/seate/for-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/seate/for-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/seate/for-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/seate/for-test/languages", + "stargazers_url": "https://api.github.com/repos/seate/for-test/stargazers", + "contributors_url": "https://api.github.com/repos/seate/for-test/contributors", + "subscribers_url": "https://api.github.com/repos/seate/for-test/subscribers", + "subscription_url": "https://api.github.com/repos/seate/for-test/subscription", + "commits_url": "https://api.github.com/repos/seate/for-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/seate/for-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/seate/for-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/seate/for-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/seate/for-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/seate/for-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/seate/for-test/merges", + "archive_url": "https://api.github.com/repos/seate/for-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/seate/for-test/downloads", + "issues_url": "https://api.github.com/repos/seate/for-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/seate/for-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/seate/for-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/seate/for-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/seate/for-test/labels{/name}", + "releases_url": "https://api.github.com/repos/seate/for-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/seate/for-test/deployments", + "created_at": "2025-02-15T14:21:31Z", + "updated_at": "2025-03-15T16:06:51Z", + "pushed_at": "2025-03-15T16:17:01Z", + "git_url": "git://github.com/seate/for-test.git", + "ssh_url": "git@github.com:seate/for-test.git", + "clone_url": "https://github.com/seate/for-test.git", + "svn_url": "https://github.com/seate/for-test", + "homepage": null, + "size": 62, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "develop" + } + }, + "base": { + "label": "seate:develop", + "ref": "develop", + "sha": "2bc9cde73b377e4d0ebda0d19f636644808388f5", + "user": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 933252913, + "node_id": "R_kgDON6BPMQ", + "name": "for-test", + "full_name": "seate/for-test", + "private": false, + "owner": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/seate/for-test", + "description": "깃허브 테스트용 레포", + "fork": false, + "url": "https://api.github.com/repos/seate/for-test", + "forks_url": "https://api.github.com/repos/seate/for-test/forks", + "keys_url": "https://api.github.com/repos/seate/for-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/seate/for-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/seate/for-test/teams", + "hooks_url": "https://api.github.com/repos/seate/for-test/hooks", + "issue_events_url": "https://api.github.com/repos/seate/for-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/seate/for-test/events", + "assignees_url": "https://api.github.com/repos/seate/for-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/seate/for-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/seate/for-test/tags", + "blobs_url": "https://api.github.com/repos/seate/for-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/seate/for-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/seate/for-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/seate/for-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/seate/for-test/languages", + "stargazers_url": "https://api.github.com/repos/seate/for-test/stargazers", + "contributors_url": "https://api.github.com/repos/seate/for-test/contributors", + "subscribers_url": "https://api.github.com/repos/seate/for-test/subscribers", + "subscription_url": "https://api.github.com/repos/seate/for-test/subscription", + "commits_url": "https://api.github.com/repos/seate/for-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/seate/for-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/seate/for-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/seate/for-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/seate/for-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/seate/for-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/seate/for-test/merges", + "archive_url": "https://api.github.com/repos/seate/for-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/seate/for-test/downloads", + "issues_url": "https://api.github.com/repos/seate/for-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/seate/for-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/seate/for-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/seate/for-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/seate/for-test/labels{/name}", + "releases_url": "https://api.github.com/repos/seate/for-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/seate/for-test/deployments", + "created_at": "2025-02-15T14:21:31Z", + "updated_at": "2025-03-15T16:06:51Z", + "pushed_at": "2025-03-15T16:17:01Z", + "git_url": "git://github.com/seate/for-test.git", + "ssh_url": "git@github.com:seate/for-test.git", + "clone_url": "https://github.com/seate/for-test.git", + "svn_url": "https://github.com/seate/for-test", + "homepage": null, + "size": 62, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "develop" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/seate/for-test/pulls/9" + }, + "html": { + "href": "https://github.com/seate/for-test/pull/9" + }, + "issue": { + "href": "https://api.github.com/repos/seate/for-test/issues/9" + }, + "comments": { + "href": "https://api.github.com/repos/seate/for-test/issues/9/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/seate/for-test/pulls/9/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/seate/for-test/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/seate/for-test/pulls/9/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/seate/for-test/statuses/4888b44d7204dd05680e90159af839c8b1194b6d" + } + }, + "author_association": "OWNER", + "auto_merge": { + "enabled_by": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "merge_method": "merge", + "commit_title": "This is commit title.", + "commit_message": "This is commit body." + }, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "blocked", + "merged_by": null, + "comments": 1, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 16, + "additions": 642, + "deletions": 0, + "changed_files": 19 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/7-users_seate.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/7-users_seate.json new file mode 100644 index 0000000000..ae11f23591 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/__files/7-users_seate.json @@ -0,0 +1,35 @@ +{ + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false, + "name": "KIMSIWOO", + "company": "Inha university", + "blog": "", + "location": null, + "email": "sa20207@naver.com", + "hireable": null, + "bio": null, + "twitter_username": null, + "public_repos": 34, + "public_gists": 0, + "followers": 2, + "following": 2, + "created_at": "2021-07-02T07:40:16Z", + "updated_at": "2025-03-03T13:26:53Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/1-user.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/1-user.json new file mode 100644 index 0000000000..4b252141e4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/1-user.json @@ -0,0 +1,47 @@ +{ + "id": "08dbdf10-b416-4ff3-b2f8-3985f3f99bb9", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "1-user.json", + "headers": { + "Date": "Sat, 15 Mar 2025 18:13:24 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With", + "ETag": "W/\"91439c9cd22b1066c90ef899df4f995dcda9ed34b86d5e107b7c311aaaff2136\"", + "Last-Modified": "Mon, 03 Mar 2025 13:26:53 GMT", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4989", + "X-RateLimit-Reset": "1742065904", + "X-RateLimit-Used": "11", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Server": "github.com", + "X-GitHub-Request-Id": "F688:2B46D8:3A9875:59C85D:67D5C344" + } + }, + "uuid": "08dbdf10-b416-4ff3-b2f8-3985f3f99bb9", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/2-r_s_for-test.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/2-r_s_for-test.json new file mode 100644 index 0000000000..6fcd708edf --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/2-r_s_for-test.json @@ -0,0 +1,47 @@ +{ + "id": "efe9930f-f284-49cb-ac98-1870d22d0454", + "name": "repos_seate_for-test", + "request": { + "url": "/repos/seate/for-test", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "2-r_s_for-test.json", + "headers": { + "Date": "Sat, 15 Mar 2025 18:13:27 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With", + "ETag": "W/\"9181d2d37a58759c6739fb93cdf26cbc7b9cc04f34e87456932f65921cb5473d\"", + "Last-Modified": "Sat, 15 Mar 2025 16:06:51 GMT", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4984", + "X-RateLimit-Reset": "1742065904", + "X-RateLimit-Used": "16", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Server": "github.com", + "X-GitHub-Request-Id": "F68A:165A85:3BCFDE:5B22D9:67D5C347" + } + }, + "uuid": "efe9930f-f284-49cb-ac98-1870d22d0454", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/3-r_s_f_pulls_9.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/3-r_s_f_pulls_9.json new file mode 100644 index 0000000000..f3a8eab80c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/3-r_s_f_pulls_9.json @@ -0,0 +1,50 @@ +{ + "id": "4b26d080-5f51-45ea-90b9-dfbe0751cdb5", + "name": "repos_seate_for-test_pulls_9", + "request": { + "url": "/repos/seate/for-test/pulls/9", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "3-r_s_f_pulls_9.json", + "headers": { + "Date": "Sat, 15 Mar 2025 18:13:27 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With", + "ETag": "W/\"4cb91abd4bd5effc3228763b88c5abec155f063e483efaa6ba284bb351e27687\"", + "Last-Modified": "Sat, 15 Mar 2025 16:18:20 GMT", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4983", + "X-RateLimit-Reset": "1742065904", + "X-RateLimit-Used": "17", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Server": "github.com", + "X-GitHub-Request-Id": "F68B:15724C:3AAF79:5A026E:67D5C347" + } + }, + "uuid": "4b26d080-5f51-45ea-90b9-dfbe0751cdb5", + "persistent": true, + "scenarioName": "scenario-1-repos-seate-for-test-pulls-9", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-seate-for-test-pulls-9-2", + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/4-graphql.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/4-graphql.json new file mode 100644 index 0000000000..42db1e78ba --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/4-graphql.json @@ -0,0 +1,50 @@ +{ + "id": "89c6825e-6277-4ad0-a9f0-d0cb70e5a15b", + "name": "graphql", + "request": { + "url": "/graphql", + "method": "POST", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"query\":\"query GetPullRequestID { repository(name: \\\"for-test\\\", owner: \\\"seate\\\") { pullRequest(number: 9) { id } } }\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ] + }, + "response": { + "status": 200, + "body": "{\"data\":{\"repository\":{\"pullRequest\":{\"id\":\"PR_kwDON6BPMc6Ox8DC\"}}}}", + "headers": { + "Date": "Sat, 15 Mar 2025 18:13:28 GMT", + "Content-Type": "application/json; charset=utf-8", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.v4; format=json", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4981", + "X-RateLimit-Reset": "1742063501", + "X-RateLimit-Used": "19", + "X-RateLimit-Resource": "graphql", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding, Accept, X-Requested-With", + "Server": "github.com", + "X-GitHub-Request-Id": "F68C:2403B3:120286:1B2D2F:67D5C348" + } + }, + "uuid": "89c6825e-6277-4ad0-a9f0-d0cb70e5a15b", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/5-graphql.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/5-graphql.json new file mode 100644 index 0000000000..7aff47b1cf --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/5-graphql.json @@ -0,0 +1,50 @@ +{ + "id": "ff9bdb46-fb2a-44c2-a164-9a790e11c26c", + "name": "graphql", + "request": { + "url": "/graphql", + "method": "POST", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"query\":\"mutation EnableAutoMerge { enablePullRequestAutoMerge(input: { pullRequestId: \\\"PR_kwDON6BPMc6Ox8DC\\\" authorEmail: \\\"sa20207@naver.com\\\" clientMutationId: \\\"github-api\\\" commitBody: \\\"This is commit body.\\\" commitHeadline: \\\"This is commit title.\\\" expectedHeadOid: \\\"4888b44d7204dd05680e90159af839c8b1194b6d\\\" mergeMethod: MERGE}) { pullRequest { id } } }\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ] + }, + "response": { + "status": 200, + "body": "{\"data\":{\"enablePullRequestAutoMerge\":{\"pullRequest\":{\"id\":\"PR_kwDON6BPMc6Ox8DC\"}}}}", + "headers": { + "Date": "Sat, 15 Mar 2025 18:13:28 GMT", + "Content-Type": "application/json; charset=utf-8", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.v4; format=json", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4980", + "X-RateLimit-Reset": "1742063501", + "X-RateLimit-Used": "20", + "X-RateLimit-Resource": "graphql", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding, Accept, X-Requested-With", + "Server": "github.com", + "X-GitHub-Request-Id": "F68D:4F3EE:3B15C8:5A6881:67D5C348" + } + }, + "uuid": "ff9bdb46-fb2a-44c2-a164-9a790e11c26c", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/6-r_s_f_pulls_9.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/6-r_s_f_pulls_9.json new file mode 100644 index 0000000000..f25e8a33f0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/6-r_s_f_pulls_9.json @@ -0,0 +1,49 @@ +{ + "id": "0dd48f53-a8fb-4df8-ba9e-946146f68a33", + "name": "repos_seate_for-test_pulls_9", + "request": { + "url": "/repos/seate/for-test/pulls/9", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "6-r_s_f_pulls_9.json", + "headers": { + "Date": "Sat, 15 Mar 2025 18:13:29 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With", + "ETag": "W/\"4cb91abd4bd5effc3228763b88c5abec155f063e483efaa6ba284bb351e27687\"", + "Last-Modified": "Sat, 15 Mar 2025 16:18:20 GMT", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4982", + "X-RateLimit-Reset": "1742065904", + "X-RateLimit-Used": "18", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Server": "github.com", + "X-GitHub-Request-Id": "F68E:7ED0E:3A2A32:597D10:67D5C348" + } + }, + "uuid": "0dd48f53-a8fb-4df8-ba9e-946146f68a33", + "persistent": true, + "scenarioName": "scenario-1-repos-seate-for-test-pulls-9", + "requiredScenarioState": "scenario-1-repos-seate-for-test-pulls-9-2", + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/7-users_seate.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/7-users_seate.json new file mode 100644 index 0000000000..51c6c8da18 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMerge/mappings/7-users_seate.json @@ -0,0 +1,47 @@ +{ + "id": "90286178-d879-4d06-ac33-48c714b16fc2", + "name": "users_seate", + "request": { + "url": "/users/seate", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "7-users_seate.json", + "headers": { + "Date": "Sat, 15 Mar 2025 18:13:29 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With", + "ETag": "W/\"0e08109bbc9b14a5d7838fffe7e57d5025e9ee8825089eb2c05f3681b890cbf4\"", + "Last-Modified": "Mon, 03 Mar 2025 13:26:53 GMT", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4981", + "X-RateLimit-Reset": "1742065904", + "X-RateLimit-Used": "19", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Server": "github.com", + "X-GitHub-Request-Id": "F68F:124DB4:3CBA1A:5C0D00:67D5C349" + } + }, + "uuid": "90286178-d879-4d06-ac33-48c714b16fc2", + "persistent": true, + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/1-user.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/1-user.json new file mode 100644 index 0000000000..76578d3e42 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/1-user.json @@ -0,0 +1,36 @@ +{ + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false, + "name": "KIMSIWOO", + "company": "Inha university", + "blog": "", + "location": null, + "email": "sa20207@naver.com", + "hireable": null, + "bio": null, + "twitter_username": null, + "notification_email": "sa20207@naver.com", + "public_repos": 34, + "public_gists": 0, + "followers": 2, + "following": 2, + "created_at": "2021-07-02T07:40:16Z", + "updated_at": "2025-03-03T13:26:53Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/2-r_s_for-test.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/2-r_s_for-test.json new file mode 100644 index 0000000000..c2de0d78c0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/2-r_s_for-test.json @@ -0,0 +1,139 @@ +{ + "id": 933252913, + "node_id": "R_kgDON6BPMQ", + "name": "for-test", + "full_name": "seate/for-test", + "private": false, + "owner": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/seate/for-test", + "description": "깃허브 테스트용 레포", + "fork": false, + "url": "https://api.github.com/repos/seate/for-test", + "forks_url": "https://api.github.com/repos/seate/for-test/forks", + "keys_url": "https://api.github.com/repos/seate/for-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/seate/for-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/seate/for-test/teams", + "hooks_url": "https://api.github.com/repos/seate/for-test/hooks", + "issue_events_url": "https://api.github.com/repos/seate/for-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/seate/for-test/events", + "assignees_url": "https://api.github.com/repos/seate/for-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/seate/for-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/seate/for-test/tags", + "blobs_url": "https://api.github.com/repos/seate/for-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/seate/for-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/seate/for-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/seate/for-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/seate/for-test/languages", + "stargazers_url": "https://api.github.com/repos/seate/for-test/stargazers", + "contributors_url": "https://api.github.com/repos/seate/for-test/contributors", + "subscribers_url": "https://api.github.com/repos/seate/for-test/subscribers", + "subscription_url": "https://api.github.com/repos/seate/for-test/subscription", + "commits_url": "https://api.github.com/repos/seate/for-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/seate/for-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/seate/for-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/seate/for-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/seate/for-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/seate/for-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/seate/for-test/merges", + "archive_url": "https://api.github.com/repos/seate/for-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/seate/for-test/downloads", + "issues_url": "https://api.github.com/repos/seate/for-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/seate/for-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/seate/for-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/seate/for-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/seate/for-test/labels{/name}", + "releases_url": "https://api.github.com/repos/seate/for-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/seate/for-test/deployments", + "created_at": "2025-02-15T14:21:31Z", + "updated_at": "2025-03-15T16:06:51Z", + "pushed_at": "2025-03-15T16:17:01Z", + "git_url": "git://github.com/seate/for-test.git", + "ssh_url": "git@github.com:seate/for-test.git", + "clone_url": "https://github.com/seate/for-test.git", + "svn_url": "https://github.com/seate/for-test", + "homepage": null, + "size": 62, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "develop", + "permissions": { + "admin": true, + "maintain": true, + "push": true, + "triage": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": true, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE", + "security_and_analysis": { + "secret_scanning": { + "status": "disabled" + }, + "secret_scanning_push_protection": { + "status": "disabled" + }, + "dependabot_security_updates": { + "status": "disabled" + }, + "secret_scanning_non_provider_patterns": { + "status": "disabled" + }, + "secret_scanning_validity_checks": { + "status": "disabled" + } + }, + "network_count": 0, + "subscribers_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/3-r_s_f_pulls_9.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/3-r_s_f_pulls_9.json new file mode 100644 index 0000000000..11347dec30 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/__files/3-r_s_f_pulls_9.json @@ -0,0 +1,372 @@ +{ + "url": "https://api.github.com/repos/seate/for-test/pulls/9", + "id": 2395455682, + "node_id": "PR_kwDON6BPMc6Ox8DC", + "html_url": "https://github.com/seate/for-test/pull/9", + "diff_url": "https://github.com/seate/for-test/pull/9.diff", + "patch_url": "https://github.com/seate/for-test/pull/9.patch", + "issue_url": "https://api.github.com/repos/seate/for-test/issues/9", + "number": 9, + "state": "open", + "locked": false, + "title": "github-api enable pull request auto merge test", + "user": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "github-api enable pull request auto merge test", + "created_at": "2025-03-15T16:07:53Z", + "updated_at": "2025-03-15T16:18:20Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "25a5888073ee3d2a975e012492950dddb8c346dc", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/seate/for-test/pulls/9/commits", + "review_comments_url": "https://api.github.com/repos/seate/for-test/pulls/9/comments", + "review_comment_url": "https://api.github.com/repos/seate/for-test/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/seate/for-test/issues/9/comments", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/4888b44d7204dd05680e90159af839c8b1194b6d", + "head": { + "label": "seate:test1", + "ref": "test1", + "sha": "4888b44d7204dd05680e90159af839c8b1194b6d", + "user": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 933252913, + "node_id": "R_kgDON6BPMQ", + "name": "for-test", + "full_name": "seate/for-test", + "private": false, + "owner": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/seate/for-test", + "description": "깃허브 테스트용 레포", + "fork": false, + "url": "https://api.github.com/repos/seate/for-test", + "forks_url": "https://api.github.com/repos/seate/for-test/forks", + "keys_url": "https://api.github.com/repos/seate/for-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/seate/for-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/seate/for-test/teams", + "hooks_url": "https://api.github.com/repos/seate/for-test/hooks", + "issue_events_url": "https://api.github.com/repos/seate/for-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/seate/for-test/events", + "assignees_url": "https://api.github.com/repos/seate/for-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/seate/for-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/seate/for-test/tags", + "blobs_url": "https://api.github.com/repos/seate/for-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/seate/for-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/seate/for-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/seate/for-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/seate/for-test/languages", + "stargazers_url": "https://api.github.com/repos/seate/for-test/stargazers", + "contributors_url": "https://api.github.com/repos/seate/for-test/contributors", + "subscribers_url": "https://api.github.com/repos/seate/for-test/subscribers", + "subscription_url": "https://api.github.com/repos/seate/for-test/subscription", + "commits_url": "https://api.github.com/repos/seate/for-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/seate/for-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/seate/for-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/seate/for-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/seate/for-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/seate/for-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/seate/for-test/merges", + "archive_url": "https://api.github.com/repos/seate/for-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/seate/for-test/downloads", + "issues_url": "https://api.github.com/repos/seate/for-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/seate/for-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/seate/for-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/seate/for-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/seate/for-test/labels{/name}", + "releases_url": "https://api.github.com/repos/seate/for-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/seate/for-test/deployments", + "created_at": "2025-02-15T14:21:31Z", + "updated_at": "2025-03-15T16:06:51Z", + "pushed_at": "2025-03-15T16:17:01Z", + "git_url": "git://github.com/seate/for-test.git", + "ssh_url": "git@github.com:seate/for-test.git", + "clone_url": "https://github.com/seate/for-test.git", + "svn_url": "https://github.com/seate/for-test", + "homepage": null, + "size": 62, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "develop" + } + }, + "base": { + "label": "seate:develop", + "ref": "develop", + "sha": "2bc9cde73b377e4d0ebda0d19f636644808388f5", + "user": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 933252913, + "node_id": "R_kgDON6BPMQ", + "name": "for-test", + "full_name": "seate/for-test", + "private": false, + "owner": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/seate/for-test", + "description": "깃허브 테스트용 레포", + "fork": false, + "url": "https://api.github.com/repos/seate/for-test", + "forks_url": "https://api.github.com/repos/seate/for-test/forks", + "keys_url": "https://api.github.com/repos/seate/for-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/seate/for-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/seate/for-test/teams", + "hooks_url": "https://api.github.com/repos/seate/for-test/hooks", + "issue_events_url": "https://api.github.com/repos/seate/for-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/seate/for-test/events", + "assignees_url": "https://api.github.com/repos/seate/for-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/seate/for-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/seate/for-test/tags", + "blobs_url": "https://api.github.com/repos/seate/for-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/seate/for-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/seate/for-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/seate/for-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/seate/for-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/seate/for-test/languages", + "stargazers_url": "https://api.github.com/repos/seate/for-test/stargazers", + "contributors_url": "https://api.github.com/repos/seate/for-test/contributors", + "subscribers_url": "https://api.github.com/repos/seate/for-test/subscribers", + "subscription_url": "https://api.github.com/repos/seate/for-test/subscription", + "commits_url": "https://api.github.com/repos/seate/for-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/seate/for-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/seate/for-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/seate/for-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/seate/for-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/seate/for-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/seate/for-test/merges", + "archive_url": "https://api.github.com/repos/seate/for-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/seate/for-test/downloads", + "issues_url": "https://api.github.com/repos/seate/for-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/seate/for-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/seate/for-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/seate/for-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/seate/for-test/labels{/name}", + "releases_url": "https://api.github.com/repos/seate/for-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/seate/for-test/deployments", + "created_at": "2025-02-15T14:21:31Z", + "updated_at": "2025-03-15T16:06:51Z", + "pushed_at": "2025-03-15T16:17:01Z", + "git_url": "git://github.com/seate/for-test.git", + "ssh_url": "git@github.com:seate/for-test.git", + "clone_url": "https://github.com/seate/for-test.git", + "svn_url": "https://github.com/seate/for-test", + "homepage": null, + "size": 62, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "develop" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/seate/for-test/pulls/9" + }, + "html": { + "href": "https://github.com/seate/for-test/pull/9" + }, + "issue": { + "href": "https://api.github.com/repos/seate/for-test/issues/9" + }, + "comments": { + "href": "https://api.github.com/repos/seate/for-test/issues/9/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/seate/for-test/pulls/9/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/seate/for-test/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/seate/for-test/pulls/9/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/seate/for-test/statuses/4888b44d7204dd05680e90159af839c8b1194b6d" + } + }, + "author_association": "OWNER", + "auto_merge": { + "enabled_by": { + "login": "seate", + "id": 86824703, + "node_id": "MDQ6VXNlcjg2ODI0NzAz", + "avatar_url": "https://avatars.githubusercontent.com/u/86824703?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/seate", + "html_url": "https://github.com/seate", + "followers_url": "https://api.github.com/users/seate/followers", + "following_url": "https://api.github.com/users/seate/following{/other_user}", + "gists_url": "https://api.github.com/users/seate/gists{/gist_id}", + "starred_url": "https://api.github.com/users/seate/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/seate/subscriptions", + "organizations_url": "https://api.github.com/users/seate/orgs", + "repos_url": "https://api.github.com/users/seate/repos", + "events_url": "https://api.github.com/users/seate/events{/privacy}", + "received_events_url": "https://api.github.com/users/seate/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "merge_method": "merge", + "commit_title": "This is commit title.", + "commit_message": "This is commit body." + }, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "blocked", + "merged_by": null, + "comments": 1, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 16, + "additions": 642, + "deletions": 0, + "changed_files": 19 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/1-user.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/1-user.json new file mode 100644 index 0000000000..a6b92d442d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/1-user.json @@ -0,0 +1,47 @@ +{ + "id": "931de630-5c54-4bb3-877f-16430f46887f", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "1-user.json", + "headers": { + "Date": "Mon, 17 Mar 2025 07:04:43 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With", + "ETag": "W/\"91439c9cd22b1066c90ef899df4f995dcda9ed34b86d5e107b7c311aaaff2136\"", + "Last-Modified": "Mon, 03 Mar 2025 13:26:53 GMT", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4990", + "X-RateLimit-Reset": "1742197445", + "X-RateLimit-Used": "10", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Server": "github.com", + "X-GitHub-Request-Id": "E025:4F3EE:A59617:F8E5A6:67D7C98B" + } + }, + "uuid": "931de630-5c54-4bb3-877f-16430f46887f", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/2-r_s_for-test.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/2-r_s_for-test.json new file mode 100644 index 0000000000..268fdf44ea --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/2-r_s_for-test.json @@ -0,0 +1,47 @@ +{ + "id": "cea6580e-f17f-43e1-b5c9-e27077b6ff17", + "name": "repos_seate_for-test", + "request": { + "url": "/repos/seate/for-test", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "2-r_s_for-test.json", + "headers": { + "Date": "Mon, 17 Mar 2025 07:04:45 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With", + "ETag": "W/\"9181d2d37a58759c6739fb93cdf26cbc7b9cc04f34e87456932f65921cb5473d\"", + "Last-Modified": "Sat, 15 Mar 2025 16:06:51 GMT", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4985", + "X-RateLimit-Reset": "1742197445", + "X-RateLimit-Used": "15", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Server": "github.com", + "X-GitHub-Request-Id": "E027:1EF85A:16C064:1D9E9C:67D7C98D" + } + }, + "uuid": "cea6580e-f17f-43e1-b5c9-e27077b6ff17", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/3-r_s_f_pulls_9.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/3-r_s_f_pulls_9.json new file mode 100644 index 0000000000..06d04c10ad --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/3-r_s_f_pulls_9.json @@ -0,0 +1,47 @@ +{ + "id": "88725e34-4c36-4681-bc6a-f82ff05b80ef", + "name": "repos_seate_for-test_pulls_9", + "request": { + "url": "/repos/seate/for-test/pulls/9", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "3-r_s_f_pulls_9.json", + "headers": { + "Date": "Mon, 17 Mar 2025 07:04:46 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With", + "ETag": "W/\"4cb91abd4bd5effc3228763b88c5abec155f063e483efaa6ba284bb351e27687\"", + "Last-Modified": "Sat, 15 Mar 2025 16:18:20 GMT", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4984", + "X-RateLimit-Reset": "1742197445", + "X-RateLimit-Used": "16", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Server": "github.com", + "X-GitHub-Request-Id": "E028:1F17C6:160FCD:1CEEA4:67D7C98D" + } + }, + "uuid": "88725e34-4c36-4681-bc6a-f82ff05b80ef", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/4-graphql.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/4-graphql.json new file mode 100644 index 0000000000..f1e592ffb3 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/4-graphql.json @@ -0,0 +1,50 @@ +{ + "id": "ab9b1fcc-2e83-46f8-82a7-a5a6b19b9958", + "name": "graphql", + "request": { + "url": "/graphql", + "method": "POST", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"query\":\"query GetPullRequestID { repository(name: \\\"for-test\\\", owner: \\\"seate\\\") { pullRequest(number: 9) { id } } }\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ] + }, + "response": { + "status": 200, + "body": "{\"data\":{\"repository\":{\"pullRequest\":{\"id\":\"PR_kwDON6BPMc6Ox8DC\"}}}}", + "headers": { + "Date": "Mon, 17 Mar 2025 07:04:46 GMT", + "Content-Type": "application/json; charset=utf-8", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.v4; format=json", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4923", + "X-RateLimit-Reset": "1742196376", + "X-RateLimit-Used": "77", + "X-RateLimit-Resource": "graphql", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding, Accept, X-Requested-With", + "Server": "github.com", + "X-GitHub-Request-Id": "E029:3882B9:169857:1D842A:67D7C98E" + } + }, + "uuid": "ab9b1fcc-2e83-46f8-82a7-a5a6b19b9958", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/5-graphql.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/5-graphql.json new file mode 100644 index 0000000000..513971c272 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/5-graphql.json @@ -0,0 +1,50 @@ +{ + "id": "d219868c-dc53-4642-863d-64a268d3c115", + "name": "graphql", + "request": { + "url": "/graphql", + "method": "POST", + "headers": { + "Accept": { + "equalTo": "application/vnd.github+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"query\":\"mutation EnableAutoMerge { enablePullRequestAutoMerge(input: { pullRequestId: \\\"PR_kwDON6BPMc6Ox8DC\\\" authorEmail: \\\"failureEmail@gmail.com\\\" clientMutationId: \\\"github-api\\\" commitBody: \\\"This is commit body.\\\" commitHeadline: \\\"This is commit title.\\\" expectedHeadOid: \\\"4888b44d7204dd05680e90159af839c8b1194b6d\\\" mergeMethod: MERGE}) { pullRequest { id } } }\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ] + }, + "response": { + "status": 200, + "body": "{\"data\":{\"enablePullRequestAutoMerge\":null},\"errors\":[{\"type\":\"UNPROCESSABLE\",\"path\":[\"enablePullRequestAutoMerge\"],\"locations\":[{\"line\":1,\"column\":28}],\"message\":\"seate does not have a verified email, which is required to enable auto-merging.\"}]}", + "headers": { + "Date": "Mon, 17 Mar 2025 07:04:47 GMT", + "Content-Type": "application/json; charset=utf-8", + "X-OAuth-Scopes": "admin:repo_hook, gist, notifications, read:discussion, read:org, read:project, repo, user:email", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.v4; format=json", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4922", + "X-RateLimit-Reset": "1742196376", + "X-RateLimit-Used": "78", + "X-RateLimit-Resource": "graphql", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding, Accept, X-Requested-With", + "Server": "github.com", + "X-GitHub-Request-Id": "E02A:FA314:AB056F:FE5536:67D7C98E" + } + }, + "uuid": "d219868c-dc53-4642-863d-64a268d3c115", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file From 15642593b6844a20c4bca77fbbcae4452d8a5a2c Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Tue, 18 Mar 2025 20:01:21 -0700 Subject: [PATCH 04/10] Tidy up GraphQL methods and classes --- .../org/kohsuke/github/GHPullRequest.java | 72 +------------------ .../org/kohsuke/github/GitHubResponse.java | 31 -------- .../java/org/kohsuke/github/Requester.java | 10 ++- .../graphql/response/GHGraphQLResponse.java | 23 ++++-- .../github-api/reflect-config.json | 36 +--------- .../github-api/serialization-config.json | 12 +--- 6 files changed, 28 insertions(+), 156 deletions(-) rename src/main/java/org/kohsuke/github/{ => internal}/graphql/response/GHGraphQLResponse.java (69%) diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index 5fb2546884..6d7972a967 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -23,8 +23,6 @@ */ package org.kohsuke.github; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; @@ -631,74 +629,6 @@ public enum MergeMethod { REBASE } - /** - * Get pull request id for GraphQL - * - * @return The pull request id for GraphQL - * @throws IOException - * the io exception - */ - public String getGraphqlPullRequestId() throws IOException { - if (owner == null) { - throw new IllegalStateException("Repository owner is required to get the pull request ID"); - } - String repositoryName = owner.getName(); - String ownerName = owner.getOwnerName(); - - String graphqlBody = String.format( - "query GetPullRequestID { repository(name: \"%s\", owner: \"%s\") { pullRequest(number: %d) { id } } }", - repositoryName, - ownerName, - number); - - GetGraphqlPullRequestIdResponse response = root().createGraphQLRequest(graphqlBody) - .fetchGraphQLResponse(GetGraphqlPullRequestIdResponse.class); - - return response.getId(); - } - - /** - * The response from the GraphQL query to get the pull request ID. Minimum required fields are included. - */ - private static class GetGraphqlPullRequestIdResponse { - private final PullRequestOwnerRepository repository; - - @JsonCreator - public GetGraphqlPullRequestIdResponse(@JsonProperty("repository") PullRequestOwnerRepository repository) { - this.repository = repository; - } - - public String getId() { - return repository.getId(); - } - - private static class PullRequestOwnerRepository { - private final GraphQLPullRequest pullRequest; - - @JsonCreator - public PullRequestOwnerRepository(@JsonProperty("pullRequest") GraphQLPullRequest pullRequest) { - this.pullRequest = pullRequest; - } - - public String getId() { - return pullRequest.getId(); - } - - private static class GraphQLPullRequest { - private final String id; - - @JsonCreator - public GraphQLPullRequest(@JsonProperty("id") String id) { - this.id = id; - } - - public String getId() { - return id; - } - } - } - } - /** * Request to enable auto merge for a pull request. * @@ -728,7 +658,7 @@ public void requestEnableAutoMerge(String authorEmail, MergeMethod mergeMethod) throws IOException { StringBuilder inputBuilder = new StringBuilder(); - inputBuilder.append(" pullRequestId: \"").append(getGraphqlPullRequestId()).append("\""); + inputBuilder.append(" pullRequestId: \"").append(this.getNodeId()).append("\""); if (authorEmail != null) { inputBuilder.append(" authorEmail: \"").append(authorEmail).append("\""); diff --git a/src/main/java/org/kohsuke/github/GitHubResponse.java b/src/main/java/org/kohsuke/github/GitHubResponse.java index cab47f0ca1..4bb8ef688f 100644 --- a/src/main/java/org/kohsuke/github/GitHubResponse.java +++ b/src/main/java/org/kohsuke/github/GitHubResponse.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.*; import org.apache.commons.io.IOUtils; import org.kohsuke.github.connector.GitHubConnectorResponse; -import org.kohsuke.github.graphql.response.GHGraphQLResponse; import java.io.IOException; import java.io.InputStream; @@ -136,36 +135,6 @@ static T parseBody(GitHubConnectorResponse connectorResponse, T instance) th } } - /** - * Parses a {@link GitHubConnectorResponse} body into a new instance of {@code GHGraphQLResponse}. - * - * @param - * the type - * @param connectorResponse - * the response info to parse. - * @param type - * the type to be constructed in GraphQLResponse. - * @return GHGraphQLResponse - * - * @throws IOException - * if there is an I/O Exception. - */ - @CheckForNull - static GHGraphQLResponse parseGraphQLBody(GitHubConnectorResponse connectorResponse, Class type) - throws IOException { - String data = getBodyAsString(connectorResponse); - try { - ObjectReader objectReader = GitHubClient.getMappingObjectReader(connectorResponse); - JavaType targetType = objectReader.getTypeFactory().constructParametricType(GHGraphQLResponse.class, type); - ObjectReader targetReader = objectReader.forType(targetType); - return targetReader.readValue(data); - } catch (JsonMappingException | JsonParseException e) { - String message = "Failed to deserialize: " + data; - LOGGER.log(Level.FINE, message); - throw e; - } - } - /** * Gets the body of the response as a {@link String}. * diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index b191a0a9c8..8a012ef0e2 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -27,7 +27,7 @@ import org.apache.commons.io.IOUtils; import org.kohsuke.github.connector.GitHubConnectorResponse; import org.kohsuke.github.function.InputStreamFunction; -import org.kohsuke.github.graphql.response.GHGraphQLResponse; +import org.kohsuke.github.internal.graphql.response.GHGraphQLResponse; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -111,7 +111,7 @@ public T fetchInto(@Nonnull T existingInstance) throws IOException { * the io exception */ public void sendGraphQL() throws IOException { - fetchGraphQLResponse(Object.class); + fetchGraphQL(GHGraphQLResponse.ObjectResponse.class); } /** @@ -125,10 +125,8 @@ public void sendGraphQL() throws IOException { * @throws IOException * if the server returns 4xx/5xx responses. */ - public T fetchGraphQLResponse(@Nonnull Class type) throws IOException { - GHGraphQLResponse response = client - .sendRequest(this, connectorResponse -> GitHubResponse.parseGraphQLBody(connectorResponse, type)) - .body(); + public , S> S fetchGraphQL(@Nonnull Class type) throws IOException { + T response = fetch(type); if (!response.isSuccessful()) { throw new IOException("GraphQL request failed by:" + response.getErrorMessages()); diff --git a/src/main/java/org/kohsuke/github/graphql/response/GHGraphQLResponse.java b/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java similarity index 69% rename from src/main/java/org/kohsuke/github/graphql/response/GHGraphQLResponse.java rename to src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java index 717220ad0f..57bd8014ee 100644 --- a/src/main/java/org/kohsuke/github/graphql/response/GHGraphQLResponse.java +++ b/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java @@ -1,4 +1,4 @@ -package org.kohsuke.github.graphql.response; +package org.kohsuke.github.internal.graphql.response; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -20,7 +20,7 @@ public class GHGraphQLResponse { private final T data; - private final List errors; + private final List errors; /** * @param data @@ -30,7 +30,7 @@ public class GHGraphQLResponse { */ @JsonCreator @SuppressFBWarnings(value = { "EI_EXPOSE_REP2" }, justification = "Spotbugs also doesn't like this") - public GHGraphQLResponse(@JsonProperty("data") T data, @JsonProperty("errors") List errors) { + public GHGraphQLResponse(@JsonProperty("data") T data, @JsonProperty("errors") List errors) { this.data = data; this.errors = errors; } @@ -61,18 +61,18 @@ public List getErrorMessages() { throw new RuntimeException("No errors occurred"); } - return errors.stream().map(GHGraphQLError::getErrorMessage).collect(Collectors.toList()); + return errors.stream().map(GraphQLError::getErrorMessage).collect(Collectors.toList()); } /** * A error of GraphQL response. Minimum implementation for GraphQL error. */ - static class GHGraphQLError { + private static class GraphQLError { private final String errorMessage; @JsonCreator - public GHGraphQLError(@JsonProperty("message") String errorMessage) { + public GraphQLError(@JsonProperty("message") String errorMessage) { this.errorMessage = errorMessage; } @@ -80,4 +80,15 @@ public String getErrorMessage() { return errorMessage; } } + + public static class ObjectResponse extends GHGraphQLResponse { + /** + * {@inheritDoc} + */ + @JsonCreator + @SuppressFBWarnings(value = { "EI_EXPOSE_REP2" }, justification = "Spotbugs also doesn't like this") + public ObjectResponse(@JsonProperty("data") Object data, @JsonProperty("errors") List errors) { + super(data, errors); + } + } } diff --git a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json index 5008bf2228..24935c34be 100644 --- a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json +++ b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json @@ -6750,7 +6750,7 @@ "allDeclaredClasses": true }, { - "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse", + "name": "org.kohsuke.github.internal.graphql.response.GHGraphQLResponse", "allPublicFields": true, "allDeclaredFields": true, "queryAllPublicConstructors": true, @@ -6765,7 +6765,7 @@ "allDeclaredClasses": true }, { - "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse$PullRequestOwnerRepository", + "name": "org.kohsuke.github.internal.graphql.response.GHGraphQLResponse$GraphQLError", "allPublicFields": true, "allDeclaredFields": true, "queryAllPublicConstructors": true, @@ -6780,37 +6780,7 @@ "allDeclaredClasses": true }, { - "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse$PullRequestOwnerRepository$GraphQLPullRequest", - "allPublicFields": true, - "allDeclaredFields": true, - "queryAllPublicConstructors": true, - "queryAllDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredConstructors": true, - "queryAllPublicMethods": true, - "queryAllDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredMethods": true, - "allPublicClasses": true, - "allDeclaredClasses": true - }, - { - "name": "org.kohsuke.github.graphql.response.GHGraphQLResponse", - "allPublicFields": true, - "allDeclaredFields": true, - "queryAllPublicConstructors": true, - "queryAllDeclaredConstructors": true, - "allPublicConstructors": true, - "allDeclaredConstructors": true, - "queryAllPublicMethods": true, - "queryAllDeclaredMethods": true, - "allPublicMethods": true, - "allDeclaredMethods": true, - "allPublicClasses": true, - "allDeclaredClasses": true - }, - { - "name": "org.kohsuke.github.graphql.response.GHGraphQLResponse$GHGraphQLError", + "name": "org.kohsuke.github.internal.graphql.response.GHGraphQLResponse$ObjectResponse", "allPublicFields": true, "allDeclaredFields": true, "queryAllPublicConstructors": true, diff --git a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json index f50f497525..0bb21a1624 100644 --- a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json +++ b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json @@ -1353,18 +1353,12 @@ "name": "org.kohsuke.github.GHPullRequest$EnablePullRequestAutoMergeResponse$EnablePullRequestAutoMerge$EnablePullRequestAutoMergePullRequest" }, { - "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse" + "name": "org.kohsuke.github.internal.graphql.response.GHGraphQLResponse" }, { - "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse$PullRequestOwnerRepository" + "name": "org.kohsuke.github.internal.graphql.response.GHGraphQLResponse$GraphQLError" }, { - "name": "org.kohsuke.github.GHPullRequest$GetGraphqlPullRequestIdResponse$PullRequestOwnerRepository$GraphQLPullRequest" - }, - { - "name": "org.kohsuke.github.graphql.response.GHGraphQLResponse" - }, - { - "name": "org.kohsuke.github.graphql.response.GHGraphQLResponse$GHGraphQLError" + "name": "org.kohsuke.github.internal.graphql.response.GHGraphQLResponse$ObjectResponse" } ] From 5e598858b219eaf9cb2638c7d11ecc2f7f169791 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 19 Mar 2025 01:41:50 -0700 Subject: [PATCH 05/10] Additional cleanup and code coverage --- .../org/kohsuke/github/GHPullRequest.java | 44 ++++++++++--------- .../graphql/response/GHGraphQLResponse.java | 39 ++++++++-------- .../org/kohsuke/github/GHPullRequestTest.java | 6 +-- .../mappings/5-graphql.json | 2 +- 4 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index 6d7972a967..ac91ad8c3b 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -650,7 +650,7 @@ public enum MergeMethod { * @throws IOException * the io exception */ - public void requestEnableAutoMerge(String authorEmail, + public void enablePullRequestAutoMerge(String authorEmail, String clientMutationId, String commitBody, String commitHeadline, @@ -658,26 +658,13 @@ public void requestEnableAutoMerge(String authorEmail, MergeMethod mergeMethod) throws IOException { StringBuilder inputBuilder = new StringBuilder(); - inputBuilder.append(" pullRequestId: \"").append(this.getNodeId()).append("\""); - - if (authorEmail != null) { - inputBuilder.append(" authorEmail: \"").append(authorEmail).append("\""); - } - if (clientMutationId != null) { - inputBuilder.append(" clientMutationId: \"").append(clientMutationId).append("\""); - } - if (commitBody != null) { - inputBuilder.append(" commitBody: \"").append(commitBody).append("\""); - } - if (commitHeadline != null) { - inputBuilder.append(" commitHeadline: \"").append(commitHeadline).append("\""); - } - if (expectedHeadOid != null) { - inputBuilder.append(" expectedHeadOid: \"").append(expectedHeadOid).append("\""); - } - if (mergeMethod != null) { - inputBuilder.append(" mergeMethod: ").append(mergeMethod); - } + addParameter(inputBuilder, "pullRequestId", this.getNodeId()); + addOptionalParameter(inputBuilder, "authorEmail", authorEmail); + addOptionalParameter(inputBuilder, "clientMutationId", clientMutationId); + addOptionalParameter(inputBuilder, "commitBody", commitBody); + addOptionalParameter(inputBuilder, "commitHeadline", commitHeadline); + addOptionalParameter(inputBuilder, "expectedHeadOid", expectedHeadOid); + addOptionalParameter(inputBuilder, "mergeMethod", mergeMethod); String graphqlBody = "mutation EnableAutoMerge { enablePullRequestAutoMerge(input: {" + inputBuilder + "}) { " + "pullRequest { id } } }"; @@ -687,6 +674,21 @@ public void requestEnableAutoMerge(String authorEmail, refresh(); } + private void addOptionalParameter(StringBuilder inputBuilder, String name, Object value) { + if (value != null) { + addParameter(inputBuilder, name, value); + } + } + + private void addParameter(StringBuilder inputBuilder, String name, Object value) { + Objects.requireNonNull(value); + String formatString = " %s: \"%s\""; + if (value instanceof Enum) { + formatString = " %s: %s"; + } + + inputBuilder.append(String.format(formatString, name, value)); + } /** * The status of auto merging a {@linkplain GHPullRequest}. * diff --git a/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java b/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java index 57bd8014ee..54960aa556 100644 --- a/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java +++ b/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java @@ -4,6 +4,7 @@ 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; @@ -31,15 +32,18 @@ public class GHGraphQLResponse { @JsonCreator @SuppressFBWarnings(value = { "EI_EXPOSE_REP2" }, justification = "Spotbugs also doesn't like this") public GHGraphQLResponse(@JsonProperty("data") T data, @JsonProperty("errors") List errors) { + if (errors == null) { + errors = Collections.emptyList(); + } this.data = data; - this.errors = errors; + this.errors = Collections.unmodifiableList(errors); } /** - * @return request is succeeded + * @return request is succeeded. True when error list is empty. */ - public Boolean isSuccessful() { - return errors == null || errors.isEmpty(); + public boolean isSuccessful() { + return errors.isEmpty(); } /** @@ -47,40 +51,35 @@ public Boolean isSuccessful() { */ public T getData() { if (!isSuccessful()) { - throw new RuntimeException("This response is Errors occurred response"); + throw new RuntimeException("Response not successful, data invalid"); } return data; } /** - * @return GraphQL error messages from Github Response + * @return GraphQL error messages from Github Response. Empty list when no errors occurred. */ public List getErrorMessages() { - if (isSuccessful()) { - throw new RuntimeException("No errors occurred"); - } - - return errors.stream().map(GraphQLError::getErrorMessage).collect(Collectors.toList()); + 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; - private final String errorMessage; - - @JsonCreator - public GraphQLError(@JsonProperty("message") String errorMessage) { - this.errorMessage = errorMessage; - } - - public String getErrorMessage() { - return errorMessage; + public String getMessage() { + return message; } } + /** + * A GraphQL response with basic Object data type. + */ public static class ObjectResponse extends GHGraphQLResponse { /** * {@inheritDoc} diff --git a/src/test/java/org/kohsuke/github/GHPullRequestTest.java b/src/test/java/org/kohsuke/github/GHPullRequestTest.java index 2beff753dd..6cccefe51e 100644 --- a/src/test/java/org/kohsuke/github/GHPullRequestTest.java +++ b/src/test/java/org/kohsuke/github/GHPullRequestTest.java @@ -1053,7 +1053,7 @@ public void enablePullRequestAutoMerge() throws IOException { GHPullRequest pullRequest = gitHub.getRepository("seate/for-test").getPullRequest(9); - pullRequest.requestEnableAutoMerge(authorEmail, + pullRequest.enablePullRequestAutoMerge(authorEmail, clientMutationId, commitBody, commitTitle, @@ -1084,12 +1084,12 @@ public void enablePullRequestAutoMergeFailure() throws IOException { GHPullRequest pullRequest = gitHub.getRepository("seate/for-test").getPullRequest(9); try { - pullRequest.requestEnableAutoMerge(authorEmail, + pullRequest.enablePullRequestAutoMerge(authorEmail, clientMutationId, commitBody, commitTitle, expectedCommitHeadOid, - GHPullRequest.MergeMethod.MERGE); + null); } catch (IOException e) { assertThat(e.getMessage(), containsString("does not have a verified email")); } diff --git a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/5-graphql.json b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/5-graphql.json index 513971c272..1f2dc6f418 100644 --- a/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/5-graphql.json +++ b/src/test/resources/org/kohsuke/github/GHPullRequestTest/wiremock/enablePullRequestAutoMergeFailure/mappings/5-graphql.json @@ -11,7 +11,7 @@ }, "bodyPatterns": [ { - "equalToJson": "{\"query\":\"mutation EnableAutoMerge { enablePullRequestAutoMerge(input: { pullRequestId: \\\"PR_kwDON6BPMc6Ox8DC\\\" authorEmail: \\\"failureEmail@gmail.com\\\" clientMutationId: \\\"github-api\\\" commitBody: \\\"This is commit body.\\\" commitHeadline: \\\"This is commit title.\\\" expectedHeadOid: \\\"4888b44d7204dd05680e90159af839c8b1194b6d\\\" mergeMethod: MERGE}) { pullRequest { id } } }\"}", + "equalToJson": "{\"query\":\"mutation EnableAutoMerge { enablePullRequestAutoMerge(input: { pullRequestId: \\\"PR_kwDON6BPMc6Ox8DC\\\" authorEmail: \\\"failureEmail@gmail.com\\\" clientMutationId: \\\"github-api\\\" commitBody: \\\"This is commit body.\\\" commitHeadline: \\\"This is commit title.\\\" expectedHeadOid: \\\"4888b44d7204dd05680e90159af839c8b1194b6d\\\"}) { pullRequest { id } } }\"}", "ignoreArrayOrder": true, "ignoreExtraElements": false } From bb612c62ee0f2beb3d0a3929c0672cdb0dba6027 Mon Sep 17 00:00:00 2001 From: siwoo Date: Wed, 19 Mar 2025 19:14:00 +0900 Subject: [PATCH 06/10] test: update test for tidy up --- .../kohsuke/github/GHPullRequestMockTest.java | 18 ------------------ .../response/GHGraphQLResponseMockTest.java | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 25 deletions(-) rename src/test/java/org/kohsuke/github/{ => internal}/graphql/response/GHGraphQLResponseMockTest.java (83%) diff --git a/src/test/java/org/kohsuke/github/GHPullRequestMockTest.java b/src/test/java/org/kohsuke/github/GHPullRequestMockTest.java index 521f953f3f..b84c905546 100644 --- a/src/test/java/org/kohsuke/github/GHPullRequestMockTest.java +++ b/src/test/java/org/kohsuke/github/GHPullRequestMockTest.java @@ -5,7 +5,6 @@ import java.io.IOException; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -34,21 +33,4 @@ public void shouldMockGHPullRequest() throws IOException { assertThat("Mock should return true", pullRequest.isDraft()); } - - /** - * Cannot get pull request graphQL id when there is no repository. - * - * @throws IOException - * the io exception - */ - @Test - public void getGraphQLPullRequestIdFailure() throws IOException { - GHPullRequest pullRequest = new GHPullRequest(); - - try { - pullRequest.getGraphqlPullRequestId(); - } catch (IllegalStateException e) { - assertThat(e.getMessage(), containsString("Repository owner is required to get the pull request ID")); - } - } } diff --git a/src/test/java/org/kohsuke/github/graphql/response/GHGraphQLResponseMockTest.java b/src/test/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponseMockTest.java similarity index 83% rename from src/test/java/org/kohsuke/github/graphql/response/GHGraphQLResponseMockTest.java rename to src/test/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponseMockTest.java index 1b205aae22..5365c9e69f 100644 --- a/src/test/java/org/kohsuke/github/graphql/response/GHGraphQLResponseMockTest.java +++ b/src/test/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponseMockTest.java @@ -1,4 +1,4 @@ -package org.kohsuke.github.graphql.response; +package org.kohsuke.github.internal.graphql.response; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -7,8 +7,12 @@ import com.fasterxml.jackson.databind.ObjectReader; import org.junit.jupiter.api.Test; +import java.util.List; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.is; /** * Test GHGraphQLResponse's methods @@ -19,6 +23,8 @@ class GHGraphQLResponseMockTest { * Test get data throws exception when response means error * * @throws JsonProcessingException + * Json parse exception + * */ @Test void getDataFailure() throws JsonProcessingException { @@ -32,7 +38,7 @@ void getDataFailure() throws JsonProcessingException { try { response.getData(); } catch (RuntimeException e) { - assertThat(e.getMessage(), containsString("This response is Errors occurred response")); + assertThat(e.getMessage(), containsString("Response not successful, data invalid")); } } @@ -40,6 +46,7 @@ void getDataFailure() throws JsonProcessingException { * Test getErrorMessages throws exception when response means not error * * @throws JsonProcessingException + * Json parse exception */ @Test void getErrorMessagesFailure() throws JsonProcessingException { @@ -48,11 +55,9 @@ void getErrorMessagesFailure() throws JsonProcessingException { GHGraphQLResponse response = convertJsonToGraphQLResponse(graphQLSuccessResponse); - try { - response.getErrorMessages(); - } catch (RuntimeException e) { - assertThat(e.getMessage(), containsString("No errors occurred")); - } + List errorMessages = response.getErrorMessages(); + + assertThat(errorMessages, is(empty())); } private GHGraphQLResponse convertJsonToGraphQLResponse(String json) throws JsonProcessingException { From f47c276f416053caffd022c51e393f26be75c718 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 19 Mar 2025 08:22:52 -0700 Subject: [PATCH 07/10] Update src/main/java/org/kohsuke/github/GitHubResponse.java --- src/main/java/org/kohsuke/github/GitHubResponse.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GitHubResponse.java b/src/main/java/org/kohsuke/github/GitHubResponse.java index 4bb8ef688f..defc094b64 100644 --- a/src/main/java/org/kohsuke/github/GitHubResponse.java +++ b/src/main/java/org/kohsuke/github/GitHubResponse.java @@ -1,7 +1,8 @@ package org.kohsuke.github; import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.InjectableValues; +import com.fasterxml.jackson.databind.JsonMappingException; import org.apache.commons.io.IOUtils; import org.kohsuke.github.connector.GitHubConnectorResponse; From 6c6d016c082786790388856f408308c354e306b8 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 19 Mar 2025 08:25:02 -0700 Subject: [PATCH 08/10] Update src/main/java/org/kohsuke/github/GitHub.java --- src/main/java/org/kohsuke/github/GitHub.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 726957c5b8..dbda5612d0 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -1308,7 +1308,7 @@ Requester createRequest() { */ @Nonnull Requester createGraphQLRequest(String query) { - return createRequest().method("POST").with("query", query).withUrlPath("/graphql"); + return createRequest().method("POST").rateLimit(RateLimitTarget.GRAPHQL).with("query", query).withUrlPath("/graphql"); } /** From 64f7f3ccdb857d188af6db452292b038c6475c45 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 19 Mar 2025 08:33:38 -0700 Subject: [PATCH 09/10] Update src/main/java/org/kohsuke/github/GitHub.java --- src/main/java/org/kohsuke/github/GitHub.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index dbda5612d0..5010a1666f 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -1308,7 +1308,11 @@ Requester createRequest() { */ @Nonnull Requester createGraphQLRequest(String query) { - return createRequest().method("POST").rateLimit(RateLimitTarget.GRAPHQL).with("query", query).withUrlPath("/graphql"); + return createRequest() + .method("POST") + .rateLimit(RateLimitTarget.GRAPHQL) + .with("query", query) + .withUrlPath("/graphql"); } /** From cc0d0fd7eec143f1b27fb0227d86da39ef1673c1 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 19 Mar 2025 08:41:33 -0700 Subject: [PATCH 10/10] Update src/main/java/org/kohsuke/github/GitHub.java --- src/main/java/org/kohsuke/github/GitHub.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 5010a1666f..33cc329be1 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -1308,8 +1308,7 @@ Requester createRequest() { */ @Nonnull Requester createGraphQLRequest(String query) { - return createRequest() - .method("POST") + return createRequest().method("POST") .rateLimit(RateLimitTarget.GRAPHQL) .with("query", query) .withUrlPath("/graphql");