Skip to content

Commit

Permalink
Merge tag 'github-api-1.319' into release/v1.x-unbridged
Browse files Browse the repository at this point in the history
github-api-1.319
  • Loading branch information
bitwiseman committed Feb 21, 2024
2 parents dd75ef6 + 7a5121c commit dc51859
Show file tree
Hide file tree
Showing 119 changed files with 43,705 additions and 51 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -46,7 +46,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -57,7 +57,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -71,4 +71,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/create_release_tag.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/maven-build.yml
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
Expand All @@ -35,7 +35,7 @@ jobs:
env:
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
run: mvn -B clean install -DskipTests --file pom.xml
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: maven-target-directory
path: target/
Expand All @@ -48,7 +48,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
Expand All @@ -68,7 +68,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
Expand All @@ -86,20 +86,20 @@ jobs:
run: mvn -B clean install -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
- name: Codecov Report
if: matrix.os == 'ubuntu' && matrix.java == '17'
uses: codecov/codecov-action@v3.1.4
uses: codecov/codecov-action@v4.0.0

test-java-8:
name: test Java 8 (no-build)
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: maven-target-directory
path: target
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 8
distribution: 'temurin'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_release_branch.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand All @@ -29,7 +29,7 @@ jobs:
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
run: mvn -B clean install site -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: maven-target-directory
path: target/
Expand Down
20 changes: 10 additions & 10 deletions pom.xml
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.kohsuke</groupId>
<artifactId>github-api-unbridged</artifactId>
<version>1.318</version>
<version>1.319</version>
<name>GitHub API for Java</name>
<url>https://github-api.kohsuke.org/</url>
<description>GitHub API for Java</description>
Expand Down Expand Up @@ -33,12 +33,12 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spotbugs-maven-plugin.version>4.7.3.0</spotbugs-maven-plugin.version>
<spotbugs-maven-plugin.version>4.8.1.0</spotbugs-maven-plugin.version>
<spotbugs.version>4.7.3</spotbugs.version>
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
<hamcrest.version>2.2</hamcrest.version>
<okhttp3.version>4.9.2</okhttp3.version>
<okio.version>3.5.0</okio.version>
<okio.version>3.7.0</okio.version>
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
<jacoco.coverage.target.bundle.method>0.70</jacoco.coverage.target.bundle.method>
<jacoco.coverage.target.class.method>0.50</jacoco.coverage.target.class.method>
Expand Down Expand Up @@ -93,7 +93,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<configuration>
<!-- SUREFIRE-1226 workaround -->
<trimStackTrace>false</trimStackTrace>
Expand All @@ -112,7 +112,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.10</version>
<version>0.8.11</version>
<configuration>
<!-- no need to get data about external code. It dramatically reduces performance of JaCoCo for nothing -->
<excludes>
Expand Down Expand Up @@ -294,12 +294,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.4.2</version>
<version>3.5.0</version>
<dependencies>
<dependency>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
<version>6.6.1</version>
<version>6.8.1</version>
</dependency>
</dependencies>
</plugin>
Expand Down Expand Up @@ -370,7 +370,7 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.27.2</version>
<version>2.43.0</version>
<executions>
<execution>
<id>spotless-check</id>
Expand Down Expand Up @@ -482,7 +482,7 @@
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -641,7 +641,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10</version>
<version>2.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
Expand Up @@ -102,6 +102,23 @@ private GHCheckRunBuilder(GHRepository repo, Requester requester) {
.withUrlPath(repo.getApiTailUrl("check-runs/" + checkId)));
}

/**
* With name.
*
* @param name
* the name
* @param oldName
* the old name
* @return the GH check run builder
*/
public @NonNull GHCheckRunBuilder withName(@CheckForNull String name, String oldName) {
if (oldName == null) {
throw new GHException("Can not update uncreated check run");
}
requester.with("name", name);
return this;
}

/**
* With details URL.
*
Expand Down
Expand Up @@ -23,6 +23,10 @@ public enum GHCommentAuthorAssociation {
* Author has not previously committed to the repository.
*/
FIRST_TIME_CONTRIBUTOR,
/**
* Author is a placeholder for an unclaimed user.
*/
MANNEQUIN,
/**
* Author is a member of the organization that owns the repository.
*/
Expand Down
38 changes: 36 additions & 2 deletions src/main/java/org/kohsuke/github/GHEventPayload.java
Expand Up @@ -1639,8 +1639,8 @@ public GHLabelChanges getChanges() {
}

/**
* A discussion was created, edited, deleted, pinned, unpinned, locked, unlocked, transferred, category_changed,
* answered, or unanswered.
* A discussion was closed, reopened, created, edited, deleted, pinned, unpinned, locked, unlocked, transferred,
* category_changed, answered, or unanswered.
*
* @see <a href=
* "https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion">
Expand Down Expand Up @@ -1673,6 +1673,40 @@ public GHLabel getLabel() {
}
}

/**
* A discussion comment was created, deleted, or edited.
*
* @see <a href=
* "https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion_comment">
* discussion event</a>
*/
public static class DiscussionComment extends GHEventPayload {

private GHRepositoryDiscussion discussion;

private GHRepositoryDiscussionComment comment;

/**
* Gets discussion.
*
* @return the discussion
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
public GHRepositoryDiscussion getDiscussion() {
return discussion;
}

/**
* Gets discussion comment.
*
* @return the discussion
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
public GHRepositoryDiscussionComment getComment() {
return comment;
}
}

/**
* A star was created or deleted on a repository.
*
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/org/kohsuke/github/GHIssue.java
Expand Up @@ -27,6 +27,7 @@
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.internal.EnumUtils;

import java.io.IOException;
import java.net.URL;
Expand All @@ -35,8 +36,10 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;

import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
Expand Down Expand Up @@ -67,6 +70,9 @@ public class GHIssue extends GHObject implements Reactable {
/** The state. */
protected String state;

/** The state reason. */
protected String state_reason;

/** The number. */
protected int number;

Expand Down Expand Up @@ -198,6 +204,15 @@ public GHIssueState getState() {
return Enum.valueOf(GHIssueState.class, state.toUpperCase(Locale.ENGLISH));
}

/**
* Gets state reason.
*
* @return the state reason
*/
public GHIssueStateReason getStateReason() {
return EnumUtils.getNullableEnumOrDefault(GHIssueStateReason.class, state_reason, GHIssueStateReason.UNKNOWN);
}

/**
* Gets labels.
*
Expand Down Expand Up @@ -273,6 +288,10 @@ private void edit(String key, Object value) throws IOException {
root().createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}

private void edit(Map<String, Object> map) throws IOException {
root().createRequest().with(map).method("PATCH").withUrlPath(getApiRoute()).send();
}

/**
* Identical to edit(), but allows null for the value.
*/
Expand All @@ -294,6 +313,21 @@ public void close() throws IOException {
edit("state", "closed");
}

/**
* Closes this issue.
*
* @param reason
* the reason the issue was closed
* @throws IOException
* the io exception
*/
public void close(GHIssueStateReason reason) throws IOException {
Map<String, Object> map = new HashMap<>();
map.put("state", "closed");
map.put("state_reason", reason.name().toLowerCase(Locale.ENGLISH));
edit(map);
}

/**
* Reopens this issue.
*
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/kohsuke/github/GHIssueStateReason.java
@@ -0,0 +1,16 @@
package org.kohsuke.github;

/**
* The enum GHIssueStateReason.
*/
public enum GHIssueStateReason {

/** Completed **/
COMPLETED,

/** Closed as not planned **/
NOT_PLANNED,

/** Uknown **/
UNKNOWN
}
7 changes: 6 additions & 1 deletion src/main/java/org/kohsuke/github/GHPullRequest.java
Expand Up @@ -100,7 +100,12 @@ protected String getApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
return StringUtils.prependIfMissing(url.toString().replace(root().getApiUrl(), ""), "/");
// The url sourced above is of the form '/repos/<owner>/<reponame>/issues/', which
// subsequently issues requests against the `/issues/` handler, causing a 404 when
// asking for, say, a list of commits associated with a PR. Replace the `/issues/`
// with `/pulls/` to avoid that.
return StringUtils.prependIfMissing(url.toString().replace(root().getApiUrl(), ""), "/")
.replace("/issues/", "/pulls/");
}
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/pulls/" + number;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHRepository.java
Expand Up @@ -1508,7 +1508,7 @@ public void delete() throws IOException {
} catch (FileNotFoundException x) {
throw (FileNotFoundException) new FileNotFoundException("Failed to delete " + getOwnerName() + "/" + name
+ "; might not exist, or you might need the delete_repo scope in your token: http://stackoverflow.com/a/19327004/12916")
.initCause(x);
.initCause(x);
}
}

Expand Down

0 comments on commit dc51859

Please sign in to comment.