Skip to content

Commit 1d9a8d0

Browse files
authored
Merge branch 'master' into BUG-id-can-be-bigger-than-int32
2 parents 9b54bf4 + 44eb801 commit 1d9a8d0

29 files changed

+579
-52
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,20 @@ jobs:
2424
server-username: MAVEN_USERNAME
2525
server-password: MAVEN_PASSWORD
2626
settings-path: ${{ github.workspace }} # Location for settings.xml file
27-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
27+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY_ABHI }}
2828
gpg-passphrase: GPG_PASSPHRASE
2929

3030
- name: Publish with Maven deploy
31-
run: >
32-
mvn
33-
--batch-mode
34-
--activate-profiles deploy
35-
--settings $GITHUB_WORKSPACE/settings.xml
36-
-Pcoverage
37-
clean deploy
31+
run: |
32+
if [ "${{ env.ACTIONS_STEP_DEBUG }}" == "true" ]; then
33+
mvn --batch-mode --activate-profiles deploy --settings $GITHUB_WORKSPACE/settings.xml -Pcoverage clean deploy -X
34+
else
35+
mvn --batch-mode --activate-profiles deploy --settings $GITHUB_WORKSPACE/settings.xml -Pcoverage clean deploy
36+
fi
3837
env:
3938
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
4039
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
41-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
40+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE_ABHI }}
4241

4342
- name: Upload coverage to Codecov
4443
uses: codecov/codecov-action@v3

pom.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44

55
<artifactId>github-client</artifactId>
6-
<version>0.3.3-SNAPSHOT</version>
6+
<version>0.3.10-SNAPSHOT</version>
77

88
<parent>
99
<groupId>com.spotify</groupId>
@@ -23,7 +23,7 @@
2323
<connection>scm:git:https://github.com/spotify/github-java-client.git</connection>
2424
<developerConnection>scm:git:[email protected]:spotify/github-java-client.git</developerConnection>
2525
<url>scm:https://github.com/spotify/github-java-client/</url>
26-
<tag>HEAD</tag>
26+
<tag>v0.3.7</tag>
2727
</scm>
2828

2929
<organization>
@@ -84,7 +84,7 @@
8484
<properties>
8585
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
8686
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
87-
<project.build.outputTimestamp>1726146382</project.build.outputTimestamp>
87+
<project.build.outputTimestamp>1740484047</project.build.outputTimestamp>
8888
<spotbugs.excludeFilterFile>spotbugsexclude.xml</spotbugs.excludeFilterFile>
8989
<checkstyle.violationSeverity>error</checkstyle.violationSeverity>
9090
<checkstyle.config.location>checkstyle.xml</checkstyle.config.location>
@@ -221,6 +221,12 @@
221221
<version>${junit.version}</version>
222222
<scope>test</scope>
223223
</dependency>
224+
<dependency>
225+
<groupId>org.junit.jupiter</groupId>
226+
<artifactId>junit-jupiter-params</artifactId>
227+
<version>${junit.version}</version>
228+
<scope>test</scope>
229+
</dependency>
224230

225231
<dependency>
226232
<groupId>org.mockito</groupId>
@@ -359,6 +365,8 @@
359365
<serverId>ossrh</serverId>
360366
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
361367
<autoReleaseAfterClose>true</autoReleaseAfterClose>
368+
<connectTimeout>600000</connectTimeout> <!-- 10 minutes -->
369+
<readTimeout>600000</readTimeout> <!-- 10 minutes -->
362370
</configuration>
363371
</plugin>
364372
</plugins>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*-
2+
* -\-\-
3+
* github-api
4+
* --
5+
* Copyright (C) 2016 - 2020 Spotify AB
6+
* --
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* -/-/-
19+
*/
20+
package com.spotify.github.jackson;
21+
22+
import com.fasterxml.jackson.core.JsonParser;
23+
import com.fasterxml.jackson.databind.DeserializationContext;
24+
import com.fasterxml.jackson.databind.JsonDeserializer;
25+
import com.spotify.github.v3.comment.CommentReactionContent;
26+
27+
import java.io.IOException;
28+
/**
29+
* Custom deserializer for {@link CommentReactionContent}.
30+
*/
31+
public class CommentReactionContentDeserializer extends JsonDeserializer<CommentReactionContent> {
32+
@Override
33+
public CommentReactionContent deserialize(final JsonParser p, final DeserializationContext ctxt)
34+
throws IOException {
35+
String value = p.getText();
36+
for (CommentReactionContent content : CommentReactionContent.values()) {
37+
if (content.toString().equals(value)) {
38+
return content;
39+
}
40+
}
41+
return null;
42+
}
43+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*-
2+
* -\-\-
3+
* github-api
4+
* --
5+
* Copyright (C) 2016 - 2020 Spotify AB
6+
* --
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* -/-/-
19+
*/
20+
package com.spotify.github.jackson;
21+
22+
import com.fasterxml.jackson.core.JsonGenerator;
23+
import com.fasterxml.jackson.databind.JsonSerializer;
24+
import com.fasterxml.jackson.databind.SerializerProvider;
25+
import com.spotify.github.v3.comment.CommentReactionContent;
26+
import java.io.IOException;
27+
/**
28+
* Custom serializer for {@link CommentReactionContent}.
29+
*/
30+
public class CommentReactionContentSerializer extends JsonSerializer<CommentReactionContent> {
31+
@Override
32+
public void serialize(final CommentReactionContent value, final JsonGenerator gen, final SerializerProvider serializers) throws IOException {
33+
gen.writeString(value.toString());
34+
}
35+
}

src/main/java/com/spotify/github/jackson/Json.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
package com.spotify.github.jackson;
2222

23-
import static com.fasterxml.jackson.databind.PropertyNamingStrategy.SNAKE_CASE;
23+
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
2424
import static java.util.Objects.isNull;
2525

2626
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -248,6 +248,6 @@ private static class DefaultMapper {
248248
.enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID)
249249
.enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
250250
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
251-
.setPropertyNamingStrategy(SNAKE_CASE);
251+
.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
252252
}
253253
}

src/main/java/com/spotify/github/v3/activity/events/CreateEvent.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public interface CreateEvent extends BaseEvent {
4747
String masterBranch();
4848

4949
/** The repository's current description. */
50-
@Nullable
5150
Optional<String> description();
5251

5352
/** No doc found on github - Usually is "user". */

src/main/java/com/spotify/github/v3/activity/events/PushEvent.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public interface PushEvent {
9393
List<PushCommit> commits();
9494

9595
/** The push commit object of the most recent commit on ref after the push. */
96-
@Nullable
9796
Optional<PushCommit> headCommit();
9897

9998
/** Pusher */

src/main/java/com/spotify/github/v3/activity/events/StatusEvent.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public interface StatusEvent extends BaseEvent, UpdateTracking {
6666
String context();
6767

6868
/** The optional human-readable description added to the status. */
69-
@Nullable
7069
Optional<String> description();
7170

7271
/** The new state. Can be pending, success, failure, or error. */

src/main/java/com/spotify/github/v3/clients/GitHubClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.spotify.github.v3.checks.AccessToken;
3333
import com.spotify.github.v3.checks.Installation;
3434
import com.spotify.github.v3.comment.Comment;
35+
import com.spotify.github.v3.comment.CommentReaction;
3536
import com.spotify.github.v3.exceptions.ReadOnlyRepositoryException;
3637
import com.spotify.github.v3.exceptions.RequestNotOkException;
3738
import com.spotify.github.v3.git.Reference;
@@ -85,6 +86,8 @@ public class GitHubClient {
8586
};
8687
static final TypeReference<List<Comment>> LIST_COMMENT_TYPE_REFERENCE =
8788
new TypeReference<>() {};
89+
static final TypeReference<List<CommentReaction>> LIST_COMMENT_REACTION_TYPE_REFERENCE =
90+
new TypeReference<>() {};
8891
static final TypeReference<List<Repository>> LIST_REPOSITORY =
8992
new TypeReference<>() {};
9093
static final TypeReference<List<CommitItem>> LIST_COMMIT_TYPE_REFERENCE =

src/main/java/com/spotify/github/v3/clients/IssueClient.java

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,15 +20,18 @@
2020

2121
package com.spotify.github.v3.clients;
2222

23-
import static com.spotify.github.v3.clients.GitHubClient.IGNORE_RESPONSE_CONSUMER;
24-
import static com.spotify.github.v3.clients.GitHubClient.LIST_COMMENT_TYPE_REFERENCE;
23+
import static com.spotify.github.v3.clients.GitHubClient.*;
2524

2625
import com.google.common.collect.ImmutableMap;
2726
import com.spotify.github.async.AsyncPage;
2827
import com.spotify.github.v3.comment.Comment;
28+
import com.spotify.github.v3.comment.CommentReaction;
29+
import com.spotify.github.v3.comment.CommentReactionContent;
30+
import com.spotify.github.v3.issues.Issue;
2931
import java.lang.invoke.MethodHandles;
3032
import java.util.Iterator;
3133
import java.util.concurrent.CompletableFuture;
34+
import okhttp3.Response;
3235
import org.slf4j.Logger;
3336
import org.slf4j.LoggerFactory;
3437

@@ -38,6 +41,9 @@ public class IssueClient {
3841
static final String COMMENTS_URI_NUMBER_TEMPLATE = "/repos/%s/%s/issues/%s/comments";
3942
static final String COMMENTS_URI_TEMPLATE = "/repos/%s/%s/issues/comments";
4043
static final String COMMENTS_URI_ID_TEMPLATE = "/repos/%s/%s/issues/comments/%s";
44+
static final String COMMENTS_REACTION_TEMPLATE = "/repos/%s/%s/issues/comments/%s/reactions";
45+
static final String COMMENTS_REACTION_ID_TEMPLATE = "/repos/%s/%s/issues/%s/reactions/%s";
46+
static final String ISSUES_URI_ID_TEMPLATE = "/repos/%s/%s/issues/%s";
4147
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
4248

4349
private final GitHubClient github;
@@ -125,4 +131,60 @@ public CompletableFuture<Void> deleteComment(final int id) {
125131
private Iterator<AsyncPage<Comment>> listComments(final String path) {
126132
return new GithubPageIterator<>(new GithubPage<>(github, path, LIST_COMMENT_TYPE_REFERENCE));
127133
}
134+
135+
/**
136+
* Get issue by id
137+
*
138+
* @param id issue id
139+
* @return the Issue for the given id if exists.
140+
*/
141+
public CompletableFuture<Issue> getIssue(final int id) {
142+
return github.request(String.format(ISSUES_URI_ID_TEMPLATE, owner, repo, id), Issue.class);
143+
}
144+
145+
/**
146+
* Create a reaction on a comment. See <a *
147+
* href="https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-an-issue-comment">Create
148+
* reaction for an issue comment</a>
149+
*
150+
* @param commentId comment id
151+
* @param reaction reaction content
152+
* @return the Comment that was just created
153+
*/
154+
public CompletableFuture<CommentReaction> createCommentReaction(
155+
final long commentId, final CommentReactionContent reaction) {
156+
final String path = String.format(COMMENTS_REACTION_TEMPLATE, owner, repo, commentId);
157+
final String requestBody =
158+
github.json().toJsonUnchecked(ImmutableMap.of("content", reaction.toString()));
159+
return github.post(path, requestBody, CommentReaction.class);
160+
}
161+
162+
/**
163+
* Delete a reaction on a comment. See <a
164+
* href="https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#delete-an-issue-comment-reaction">List
165+
* reactions for an issue comment</a>
166+
*
167+
* @param issueNumber issue number
168+
* @param reactionId reaction id
169+
*/
170+
public CompletableFuture<Response> deleteCommentReaction(
171+
final long issueNumber, final long reactionId) {
172+
final String path =
173+
String.format(COMMENTS_REACTION_ID_TEMPLATE, owner, repo, issueNumber, reactionId);
174+
return github.delete(path);
175+
}
176+
177+
/**
178+
* List reactions on a comment. See <a
179+
* href="https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-an-issue-comment">List
180+
* reactions for an issue comment</a>
181+
*
182+
* @param commentId comment id
183+
* @return reactions
184+
*/
185+
public GithubPageIterator<CommentReaction> listCommentReaction(final long commentId) {
186+
final String path = String.format(COMMENTS_REACTION_TEMPLATE, owner, repo, commentId);
187+
return new GithubPageIterator<>(
188+
new GithubPage<>(github, path, LIST_COMMENT_REACTION_TYPE_REFERENCE));
189+
}
128190
}

0 commit comments

Comments
 (0)