Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
18326c0
Chore(deps): Bump org.apache.maven.plugins:maven-site-plugin
dependabot[bot] Sep 17, 2024
e6081da
Merge branch 'main' into dependabot/maven/org.apache.maven.plugins-ma…
bitwiseman Sep 17, 2024
f4a0d34
Prepare release (bitwiseman): github-api-2.0.0-alpha-2
bitwiseman Sep 17, 2024
ff99753
Prepare for next development iteration
bitwiseman Sep 17, 2024
2dbe157
Merge pull request #1948 from hub4j/staging/main
bitwiseman Sep 17, 2024
e5861ef
Merge pull request #1941 from hub4j/dependabot/maven/org.apache.maven…
bitwiseman Sep 18, 2024
66ec1b6
Chore(deps-dev): Bump com.google.guava:guava (#1949)
dependabot[bot] Sep 18, 2024
2936a1d
Chore(deps): Bump com.squareup.okio:okio from 3.9.0 to 3.9.1 (#1950)
dependabot[bot] Sep 18, 2024
cdd42bb
Chore(deps): Bump spring.boot.version from 3.3.3 to 3.3.4 (#1952)
dependabot[bot] Sep 27, 2024
6a5789e
Chore(deps-dev): Bump com.google.guava:guava (#1953)
dependabot[bot] Sep 27, 2024
79a0343
Chore(deps): Bump org.apache.maven.plugins:maven-gpg-plugin (#1954)
dependabot[bot] Sep 27, 2024
a1786c7
Chore(deps): Bump com.github.spotbugs:spotbugs-maven-plugin (#1955)
dependabot[bot] Sep 27, 2024
d675d94
Chore(deps): Bump com.fasterxml.jackson:jackson-bom (#1959)
dependabot[bot] Sep 28, 2024
7150121
Chore(deps-dev): Bump org.mockito:mockito-core from 5.13.0 to 5.14.0 …
dependabot[bot] Sep 28, 2024
7c3a86e
Chore(deps): Bump actions/setup-java from 2 to 4 (#1960)
dependabot[bot] Oct 1, 2024
768c715
Chore(deps): Bump com.infradna.tool:bridge-method-annotation (#1961)
dependabot[bot] Oct 1, 2024
0c9e195
Improve wait handing in abuse retry (#1971)
holly-cummins Oct 14, 2024
6ea075b
Do not assume server time is in sync with local machine time on rate …
holly-cummins Oct 17, 2024
e464f7f
Chore(deps): Bump codecov/codecov-action from 4.5.0 to 4.6.0 (#1981)
dependabot[bot] Nov 1, 2024
766a672
Chore(deps): Bump org.apache.maven.plugins:maven-surefire-plugin (#1978)
dependabot[bot] Nov 1, 2024
82c2dbf
Chore(deps): Bump org.apache.maven.plugins:maven-javadoc-plugin (#1979)
dependabot[bot] Nov 1, 2024
e4ef482
Chore(deps-dev): Bump org.mockito:mockito-core from 5.14.0 to 5.14.2 …
dependabot[bot] Nov 1, 2024
460c9fe
Chore(deps): Bump spring.boot.version from 3.3.4 to 3.3.5 (#1977)
dependabot[bot] Nov 17, 2024
107c8e6
fix GHNotificationStream "Unable to parse If-Modified-Since request h…
AsherSu Nov 21, 2024
bcbf2e9
Chore(deps): Bump org.apache.maven.plugins:maven-surefire-plugin (#1992)
dependabot[bot] Dec 2, 2024
d54f5dd
Chore(deps): Bump org.apache.maven.plugins:maven-site-plugin (#1991)
dependabot[bot] Dec 2, 2024
7e99f42
Chore(deps): Bump com.fasterxml.jackson:jackson-bom (#1990)
dependabot[bot] Dec 2, 2024
11479e5
Chore(deps): Bump org.apache.maven.plugins:maven-javadoc-plugin (#1989)
dependabot[bot] Dec 2, 2024
7565225
Chore(deps): Bump codecov/codecov-action from 4.6.0 to 5.0.7 (#1988)
dependabot[bot] Dec 2, 2024
58dcca1
Add autolink reference function (#1987)
Alaurant Dec 5, 2024
4f505a5
Add ssh keys fields on meta API response (#1996)
jonesbusy Dec 18, 2024
c9df3cb
Chore(deps): Bump org.codehaus.mojo:versions-maven-plugin
dependabot[bot] Jan 1, 2025
01ba72a
Chore(deps-dev): Bump com.google.guava:guava
dependabot[bot] Jan 1, 2025
9e1147b
Chore(deps): Bump org.apache.maven.plugins:maven-help-plugin
dependabot[bot] Jan 1, 2025
1016fd2
Chore(deps): Bump org.apache.maven.plugins:maven-project-info-reports…
dependabot[bot] Jan 1, 2025
35adac1
Chore(deps): Bump codecov/codecov-action from 5.0.7 to 5.1.2 (#1998)
dependabot[bot] Jan 2, 2025
498b98a
Merge pull request #2003 from hub4j/dependabot/maven/org.apache.maven…
bitwiseman Jan 2, 2025
8680ab7
Merge pull request #2002 from hub4j/dependabot/maven/org.apache.maven…
bitwiseman Jan 2, 2025
64c93d6
Merge pull request #2000 from hub4j/dependabot/maven/org.codehaus.moj…
bitwiseman Jan 2, 2025
4732768
Merge pull request #2001 from hub4j/dependabot/maven/com.google.guava…
bitwiseman Jan 2, 2025
c8f4815
Add parameter to listContributors for anonymous contributors (#1907)
augustd Jan 6, 2025
8714d1b
Include triggering actor in workflow run (#2006)
HerrDerb Jan 9, 2025
d37839b
Add option to fork default branch only (#1995)
Alaurant Jan 21, 2025
33c39f3
List app installation requests endpoint (#2012)
anujhydrabadi Jan 21, 2025
fd85f91
Prepare release (bitwiseman): github-api-2.0-alpha-3
bitwiseman Jan 25, 2025
6898869
Prepare for next development iteration
bitwiseman Jan 25, 2025
3fc0451
Merge pull request #2018 from hub4j/staging/main
bitwiseman Jan 25, 2025
cad279e
Merge remote-tracking branch 'upstream/main' into backport/main-1.x
bitwiseman Jan 25, 2025
630078b
Test fixes for 1.x backport
bitwiseman Jan 25, 2025
38ca010
Fix tests
bitwiseman Jan 27, 2025
af54d2c
Improve code coverage
bitwiseman Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

steps:
- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
name: maven-test-target-directory
path: target
- name: Codecov Report
uses: codecov/codecov-action@v4.5.0
uses: codecov/codecov-action@v5.1.2
with:
# Codecov token from https://app.codecov.io/gh/hub4j/github-api/settings
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
26 changes: 13 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
</distributionManagement>

<properties>
<spring.boot.version>3.3.3</spring.boot.version>
<spring.boot.version>3.3.5</spring.boot.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spotbugs-maven-plugin.version>4.8.6.3</spotbugs-maven-plugin.version>
<spotbugs-maven-plugin.version>4.8.6.4</spotbugs-maven-plugin.version>
<spotbugs.version>4.8.6</spotbugs.version>
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
<hamcrest.version>3.0</hamcrest.version>
<okhttp3.version>4.12.0</okhttp3.version>
<okio.version>3.9.0</okio.version>
<okio.version>3.9.1</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 @@ -85,16 +85,16 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.17.1</version>
<version>2.18.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.2</version>
<configuration>
<!-- SUREFIRE-1226 workaround -->
<trimStackTrace>false</trimStackTrace>
Expand All @@ -108,7 +108,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.6</version>
<version>3.2.7</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down Expand Up @@ -223,7 +223,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.10.0</version>
<version>3.11.1</version>
<configuration>
<release>8</release>
<failOnWarnings>true</failOnWarnings>
Expand Down Expand Up @@ -265,7 +265,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
<version>3.21.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -285,7 +285,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.0</version>
<dependencies>
<dependency>
<groupId>org.apache.bcel</groupId>
Expand Down Expand Up @@ -475,7 +475,7 @@
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.17.2</version>
<version>2.18.2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down Expand Up @@ -560,7 +560,7 @@
<dependency>
<groupId>com.infradna.tool</groupId>
<artifactId>bridge-method-annotation</artifactId>
<version>1.29</version>
<version>1.30</version>
<optional>true</optional>
</dependency>
<!-- for stapler-jetty -->
Expand Down Expand Up @@ -649,7 +649,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.13.0</version>
<version>5.14.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
26 changes: 2 additions & 24 deletions src/main/java/org/kohsuke/github/AbuseLimitHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
import org.kohsuke.github.connector.GitHubConnectorResponse;

import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.HttpURLConnection;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

import javax.annotation.Nonnull;

Expand Down Expand Up @@ -88,13 +84,8 @@ public void onError(@Nonnull GitHubConnectorResponse connectorResponse) throws I
public static final AbuseLimitHandler WAIT = new AbuseLimitHandler() {
@Override
public void onError(IOException e, HttpURLConnection uc) throws IOException {
try {
Thread.sleep(parseWaitTime(uc));
} catch (InterruptedException ex) {
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
sleep(parseWaitTime(uc));
}

};

/**
Expand All @@ -116,19 +107,6 @@ public void onError(IOException e, HttpURLConnection uc) throws IOException {
* number or a date (the spec allows both). If no header is found, wait for a reasonably amount of time.
*/
long parseWaitTime(HttpURLConnection uc) {
String v = uc.getHeaderField("Retry-After");
if (v == null) {
// can't tell, wait for unambiguously over one minute per GitHub guidance
return DEFAULT_WAIT_MILLIS;
}

try {
return Math.max(1000, Long.parseLong(v) * 1000);
} catch (NumberFormatException nfe) {
// The retry-after header could be a number in seconds, or an http-date
ZonedDateTime zdt = ZonedDateTime.parse(v, DateTimeFormatter.RFC_1123_DATE_TIME);
return ChronoUnit.MILLIS.between(ZonedDateTime.now(), zdt);
}
return parseWaitTime(uc.getHeaderField("Retry-After"), null, DEFAULT_WAIT_MILLIS, 1000);
}

}
16 changes: 16 additions & 0 deletions src/main/java/org/kohsuke/github/GHApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,22 @@ public void setPermissions(Map<String, String> permissions) {
throw new RuntimeException("Do not use this method.");
}

/**
* Obtains all the installation requests associated with this app.
* <p>
* You must use a JWT to access this endpoint.
*
* @return a list of App installation requests
* @see <a href=
* "https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#list-installation-requests-for-the-authenticated-app">List
* installation requests</a>
*/
public PagedIterable<GHAppInstallationRequest> listInstallationRequests() {
return root().createRequest()
.withUrlPath("/app/installation-requests")
.toIterable(GHAppInstallationRequest[].class, null);
}

/**
* Obtains all the installations associated with this app.
* <p>
Expand Down
52 changes: 52 additions & 0 deletions src/main/java/org/kohsuke/github/GHAppInstallationRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.kohsuke.github;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import java.io.IOException;
import java.net.URL;

/**
* A Github App Installation Request.
*
* @author Anuj Hydrabadi
* @see GHApp#listInstallationRequests() GHApp#listInstallationRequests()
*/
public class GHAppInstallationRequest extends GHObject {
/**
* Create default GHAppInstallationRequest instance
*/
public GHAppInstallationRequest() {
}

private GHOrganization account;

private GHUser requester;

private String htmlUrl;

/**
* Gets the organization where the app was requested to be installed.
*
* @return the organization where the app was requested to be installed.
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP", "UWF_UNWRITTEN_FIELD" }, justification = "Expected behavior")
public GHOrganization getAccount() {
return account;
}

/**
* Gets the user who requested the installation.
*
* @return the user who requested the installation.
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP", "UWF_UNWRITTEN_FIELD" }, justification = "Expected behavior")
public GHUser getRequester() {
return requester;
}

@Override
public URL getHtmlUrl() throws IOException {
return GitHubClient.parseURL(htmlUrl);

Check warning on line 49 in src/main/java/org/kohsuke/github/GHAppInstallationRequest.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/kohsuke/github/GHAppInstallationRequest.java#L49

Added line #L49 was not covered by tests
}

}
100 changes: 100 additions & 0 deletions src/main/java/org/kohsuke/github/GHAutolink.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package org.kohsuke.github;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import java.io.IOException;

/**
* Represents a GitHub repository autolink reference.
*
* @author Alaurant
* @see GHAutolinkBuilder
* @see GHRepository#listAutolinks() GHRepository#listAutolinks()
* @see <a href="https://docs.github.com/en/rest/repos/autolinks">Repository autolinks API</a>
*/
public class GHAutolink {

private int id;
private String key_prefix;
private String url_template;
private boolean is_alphanumeric;
private GHRepository owner;

/**
* Instantiates a new Gh autolink.
*/
public GHAutolink() {
}

/**
* Gets the autolink ID
*
* @return the id
*/
public int getId() {
return id;
}

/**
* Gets the key prefix used to identify issues/PR references
*
* @return the key prefix string
*/
public String getKeyPrefix() {
return key_prefix;
}

/**
* Gets the URL template that will be used for matching
*
* @return the URL template string
*/
public String getUrlTemplate() {
return url_template;
}

/**
* Checks if the autolink uses alphanumeric values
*
* @return true if alphanumeric, false otherwise
*/
public boolean isAlphanumeric() {
return is_alphanumeric;
}

/**
* Gets the repository that owns this autolink
*
* @return the repository instance
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
public GHRepository getOwner() {
return owner;
}

/**
* Deletes this autolink
*
* @throws IOException
* if the deletion fails
*/
public void delete() throws IOException {
owner.root()
.createRequest()
.method("DELETE")
.withUrlPath(String.format("/repos/%s/%s/autolinks/%d", owner.getOwnerName(), owner.getName(), getId()))
.send();
}

/**
* Wraps this autolink with its owner repository.
*
* @param owner
* the repository that owns this autolink
* @return this instance
*/
GHAutolink lateBind(GHRepository owner) {
this.owner = owner;
return this;
}
}
Loading