Skip to content

Commit 782829f

Browse files
committed
Merge branch 'master' into feat/add-ot-support
2 parents 5b26395 + 9d6e361 commit 782829f

File tree

19 files changed

+1052
-36
lines changed

19 files changed

+1052
-36
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ jobs:
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 }}

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.7-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>
@@ -67,7 +67,7 @@
6767
<properties>
6868
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
6969
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
70-
<project.build.outputTimestamp>1738229414</project.build.outputTimestamp>
70+
<project.build.outputTimestamp>1740484047</project.build.outputTimestamp>
7171
<spotbugs.excludeFilterFile>spotbugsexclude.xml</spotbugs.excludeFilterFile>
7272
<checkstyle.violationSeverity>error</checkstyle.violationSeverity>
7373
<checkstyle.config.location>checkstyle.xml</checkstyle.config.location>
@@ -236,6 +236,12 @@
236236
<version>${junit.version}</version>
237237
<scope>test</scope>
238238
</dependency>
239+
<dependency>
240+
<groupId>org.junit.jupiter</groupId>
241+
<artifactId>junit-jupiter-params</artifactId>
242+
<version>${junit.version}</version>
243+
<scope>test</scope>
244+
</dependency>
239245

240246
<dependency>
241247
<groupId>org.mockito</groupId>
@@ -374,6 +380,8 @@
374380
<serverId>ossrh</serverId>
375381
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
376382
<autoReleaseAfterClose>true</autoReleaseAfterClose>
383+
<connectTimeout>600000</connectTimeout> <!-- 10 minutes -->
384+
<readTimeout>600000</readTimeout> <!-- 10 minutes -->
377385
</configuration>
378386
</plugin>
379387
</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/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
}

src/main/java/com/spotify/github/v3/comment/Comment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public interface Comment extends UpdateTracking {
4646
URI htmlUrl();
4747

4848
/** Comment ID. */
49-
int id();
49+
Long id();
5050

5151
/** The {@link User} that made the comment. */
5252
@Nullable
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.v3.comment;
21+
22+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
23+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
24+
import com.spotify.github.GithubStyle;
25+
import com.spotify.github.UpdateTracking;
26+
import com.spotify.github.v3.User;
27+
import org.immutables.value.Value;
28+
29+
/**
30+
* Comment reaction object.
31+
*
32+
* <p>See <a
33+
* href="https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#about-reactions">About
34+
* GitHub Issue Comment reactions</a>
35+
*/
36+
@Value.Immutable
37+
@GithubStyle
38+
@JsonSerialize(as = ImmutableCommentReaction.class)
39+
@JsonDeserialize(as = ImmutableCommentReaction.class)
40+
public interface CommentReaction extends UpdateTracking {
41+
42+
/** Reaction ID. */
43+
long id();
44+
45+
/** Reaction user. */
46+
User user();
47+
48+
/** Reaction content. */
49+
CommentReactionContent content();
50+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.v3.comment;
21+
22+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
23+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
24+
import com.spotify.github.jackson.CommentReactionContentDeserializer;
25+
import com.spotify.github.jackson.CommentReactionContentSerializer;
26+
27+
/**
28+
* Comment reaction content.
29+
*
30+
* <p>See <a
31+
* href="https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#about-reactions">About
32+
* GitHub Issue Comment reactions</a>
33+
*/
34+
@JsonDeserialize(using = CommentReactionContentDeserializer.class)
35+
@JsonSerialize(using = CommentReactionContentSerializer.class)
36+
public enum CommentReactionContent {
37+
THUMBS_UP("+1"), // 👍
38+
THUMBS_DOWN("-1"), // 👎
39+
LAUGH("laugh"), // 😄
40+
HOORAY("hooray"), // 🎉
41+
CONFUSED("confused"), // 😕
42+
HEART("heart"), // ❤️
43+
ROCKET("rocket"), // 🚀
44+
EYES("eyes"); // 👀
45+
46+
private final String reaction;
47+
48+
CommentReactionContent(final String reaction) {
49+
this.reaction = reaction;
50+
}
51+
52+
@Override
53+
public String toString() {
54+
return reaction;
55+
}
56+
}

src/main/java/com/spotify/github/v3/issues/Issue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public interface Issue extends CloseTracking {
4141

4242
/** ID. */
4343
@Nullable
44-
Integer id();
44+
Long id();
4545

4646
/** URL. */
4747
@Nullable

src/main/java/com/spotify/github/v3/prs/PullRequestItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public interface PullRequestItem extends CloseTracking {
4343

4444
/** ID. */
4545
@Nullable
46-
Integer id();
46+
Long id();
4747

4848
/** URL. */
4949
@Nullable

0 commit comments

Comments
 (0)