10000 Merge pull request #2019 from bitwiseman/backport/main-1.x · hub4j/github-api@8850efc · GitHub
[go: up one dir, main page]

Skip to content

Commit 8850efc

Browse files
authored
Merge pull request #2019 from bitwiseman/backport/main-1.x
Backport changes from 2.x to 1.x
2 parents e1c84cf + af54d2c commit 8850efc

File tree

182 files changed

+14565
-94
lines changed
  • GHRepositoryForkBuilderTest/wiremock
  • GHRepositoryTest/wiremock/listContributorsAnon
  • GHWorkflowRunTest/wiremock/testManualRunAndBasicInformation/__files
  • GitHubTest/wiremock/getMeta/__files
  • RateLimitHandlerTest/wiremock
  • WireMockStatusReporterTest/wiremock
  • extras/authorization/AuthorizationTokenRefreshTest/wiremock
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    182 files changed

    +14565
    -94
    lines changed

    .github/workflows/codeql-analysis.yml

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -42,7 +42,7 @@ jobs:
    4242

    4343
    steps:
    4444
    - name: Set up JDK
    45-
    uses: actions/setup-java@v2
    45+
    uses: actions/setup-java@v4
    4646
    with:
    4747
    distribution: 'temurin'
    4848
    java-version: 17

    .github/workflows/maven-build.yml

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -107,7 +107,7 @@ jobs:
    107107
    name: maven-test-target-directory
    108108
    path: target
    109109
    - name: Codecov Report
    110-
    uses: codecov/codecov-action@v4.5.0
    110+
    uses: codecov/codecov-action@v5.1.2
    111111
    with:
    112112
    # Codecov token from https://app.codecov.io/gh/hub4j/github-api/settings
    113113
    token: ${{ secrets.CODECOV_TOKEN }}

    pom.xml

    Lines changed: 13 additions & 13 deletions
    Original file line numberDiff line numberDiff line change
    @@ -32,14 +32,14 @@
    3232
    </distributionManagement>
    3333

    3434
    <properties>
    35-
    <spring.boot.version>3.3.3</spring.boot.version>
    35+
    <spring.boot.version>3.3.5</spring.boot.version>
    3636
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    37-
    <spotbugs-maven-plugin.version>4.8.6.3</spotbugs-maven-plugin.version>
    37+
    <spotbugs-maven-plugin.version>4.8.6.4</spotbugs-maven-plugin.version>
    3838
    <spotbugs.version>4.8.6</spotbugs.version>
    3939
    <spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
    4040
    <hamcrest.version>3.0</hamcrest.version>
    4141
    <okhttp3.version>4.12.0</okhttp3.version>
    42-
    <okio.version>3.9.0</okio.version>
    42+
    <okio.version>3.9.1</okio.version>
    4343
    <!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
    4444
    <jacoco.coverage.target.bundle.method>0.70</jacoco.coverage.target.bundle.method>
    4545
    <jacoco.coverage.target.class.method>0.50</jacoco.coverage.target.class.method>
    @@ -85,16 +85,16 @@
    8585
    <plugin>
    8686
    <groupId>org.codehaus.mojo</groupId>
    8787
    <artifactId>versions-maven-plugin</artifactId>
    88-
    <version>2.17.1</version>
    88+
    <version>2.18.0</version>
    8989
    </plugin>
    9090
    <plugin>
    9191
    <groupId>org.apache.maven.plugins</groupId>
    9292
    <artifactId>maven-help-plugin</artifactId>
    93-
    <version>3.5.0</version>
    93+
    <version>3.5.1</version>
    9494
    </plugin>
    9595
    <plugin>
    9696
    <artifactId>maven-surefire-plugin</artifactId>
    97-
    <version>3.5.0</version>
    97+
    <version>3.5.2</version>
    9898
    <configuration>
    9999
    <!-- SUREFIRE-1226 workaround -->
    100100
    <trimStackTrace>false</trimStackTrace>
    @@ -108,7 +108,7 @@
    108108
    <plugin>
    109109
    <groupId>org.apache.maven.plugins</groupId>
    110110
    <artifactId>maven-gpg-plugin</artifactId>
    111-
    <version>3.2.6</version>
    111+
    <version>3.2.7</version>
    112112
    </plugin>
    113113
    <plugin>
    114114
    <groupId>org.jacoco</groupId>
    @@ -223,7 +223,7 @@
    223223
    <plugin>
    224224
    <groupId>org.apache.maven.plugins</groupId>
    225225
    <artifactId>maven-javadoc-plugin</artifactId>
    226-
    <version>3.10.0</version>
    226+
    <version>3.11.1</version>
    227227
    <configuration>
    228228
    <release>8</release>
    229229
    <failOnWarnings>true</failOnWarnings>
    @@ -265,7 +265,7 @@
    265265
    <plugin>
    266266
    <groupId>org.apache.maven.plugins</groupId>
    267267
    <artifactId>maven-site-plugin</artifactId>
    268-
    <version>3.12.1</version>
    268+
    <version>3.21.0</version>
    269269
    </plugin>
    270270
    <plugin>
    271271
    <groupId>org.apache.maven.plugins</groupId>
    @@ -285,7 +285,7 @@
    285285
    <plugin>
    286286
    <groupId>org.apache.maven.plugins</groupId>
    287287
    <artifactId>maven-project-info-reports-plugin</artifactId>
    288-
    <version>3.7.0</version>
    288+
    <version>3.8.0</version>
    289289
    <dependencies>
    290290
    <dependency>
    291291
    <groupId>org.apache.bcel</groupId>
    @@ -475,7 +475,7 @@
    475475
    <dependency>
    476476
    <groupId>com.fasterxml.jackson</groupId>
    477477
    <artifactId>jackson-bom</artifactId>
    478-
    <version>2.17.2</version>
    478+
    <version>2.18.2</version>
    479479
    <scope>import</scope>
    480480
    <type>pom</type>
    481481
    </dependency>
    @@ -560,7 +560,7 @@
    560560
    <dependency>
    561561
    <groupId>com.infradna.tool</groupId>
    562562
    <artifactId>bridge-method-annotation</artifactId>
    563-
    <version>1.29</version>
    563+
    <version>1.30</version>
    564564
    <optional>true</optional>
    565565
    </dependency>
    566566
    <!-- for stapler-jetty -->
    @@ -649,7 +649,7 @@
    649649
    <dependency>
    650650
    <groupId>org.mockito</groupId>
    651651
    <artifactId>mockito-core</artifactId>
    652-
    <version>5.13.0</version>
    652+
    <version>5.14.2</version>
    653653
    <scope>test</scope>
    654654
    </dependency>
    655655
    <dependency>

    src/main/java/org/kohsuke/github/AbuseLimitHandler.java

    Lines changed: 2 additions & 24 deletions
    Original file line numberDiff line numberDiff line change
    @@ -3,11 +3,7 @@
    33
    import org.kohsuke.github.connector.GitHubConnectorResponse;
    44

    55
    import java.io.IOException;
    6-
    import java.io.InterruptedIOException;
    76
    import java.net.HttpURLConnection;
    8-
    import java.time.ZonedDateTime;
    9-
    import java.time.format.DateTimeFormatter;
    10-
    import java.time.temporal.ChronoUnit;
    117

    128
    import javax.annotation.Nonnull;
    139

    @@ -88,13 +84,8 @@ public void onError(@Nonnull GitHubConnectorResponse connectorResponse) throws I
    8884
    public static final AbuseLimitHandler WAIT = new AbuseLimitHandler() {
    8985
    @Override
    9086
    public void onError(IOException e, HttpURLConnection uc) throws IOException {
    91-
    try {
    92-
    Thread.sleep(parseWaitTime(uc));
    93-
    } catch (InterruptedException ex) {
    94-
    throw (InterruptedIOException) new InterruptedIOException().initCause(e);
    95-
    }
    87+
    sleep(parseWaitTime(uc));
    9688
    }
    97-
    9889
    };
    9990

    10091
    /**
    @@ -116,19 +107,6 @@ public void onError(IOException e, HttpURLConnection uc) throws IOException {
    116107
    * number or a date (the spec allows both). If no header is found, wait for a reasonably amount of time.
    117108
    */
    118109
    long parseWaitTime(HttpURLConnection uc) {
    119-
    String v = uc.getHeaderField("Retry-After");
    120-
    if (v == null) {
    121-
    // can't tell, wait for unambiguously over one minute per GitHub guidance
    122-
    return DEFAULT_WAIT_MILLIS;
    123-
    }
    124-
    125-
    try {
    126-
    return Math.max(1000, Long.parseLong(v) * 1000);
    127-
    } catch (NumberFormatException nfe) {
    128-
    // The retry-after header could be a number in seconds, or an http-date
    129-
    ZonedDateTime zdt = ZonedDateTime.parse(v, DateTimeFormatter.RFC_1123_DATE_TIME);
    130-
    return ChronoUnit.MILLIS.between(ZonedDateTime.now(), zdt);
    131-
    }
    110+
    return parseWaitTime(uc.getHeaderField("Retry-After"), null, DEFAULT_WAIT_MILLIS, 1000);
    132111
    }
    133-
    134112
    }

    src/main/java/org/kohsuke/github/GHApp.java

    Lines changed: 16 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -204,6 +204,22 @@ public void setPermissions(Map<String, String> permissions) {
    204204
    throw new RuntimeException("Do not use this method.");
    205205
    }
    206206

    207+
    /**
    208+
    * Obtains all the installation requests associated with this app.
    209+
    * <p>
    210+
    * You must use a JWT to access this endpoint.
    211+
    *
    212+
    * @return a list of App installation requests
    213+
    * @see <a href=
    214+
    * "https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#list-installation-requests-for-the-authenticated-app">List
    215+
    * installation requests</a>
    216+
    */
    217+
    public PagedIterable<GHAppInstallationRequest> listInstallationRequests() {
    218+
    return root().createRequest()
    219+
    .withUrlPath("/app/installation-requests")
    220+
    .toIterable(GHAppInstallationRequest[].class, null);
    221+
    }
    222+
    207223
    /**
    208224
    * Obtains all the installations associated with this app.
    209225
    * <p>
    Lines changed: 52 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,52 @@
    1+
    package org.kohsuke.github;
    2+
    3+
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    4+
    5+
    import java.io.IOException;
    6+
    import java.net.URL;
    7+
    8+
    /**
    9+
    * A Github App Installation Request.
    10+
    *
    11+
    * @author Anuj Hydrabadi
    12+
    * @see GHApp#listInstallationRequests() GHApp#listInstallationRequests()
    13+
    */
    14+
    public class GHAppInstallationRequest extends GHObject {
    15+
    /**
    16+
    * Create default GHAppInstallationRequest instance
    17+
    */
    18+
    public GHAppInstallationRequest() {
    19+
    }
    20+
    21+
    private GHOrganization account;
    22+
    23+
    private GHUser requester;
    24+
    25+
    private String htmlUrl;
    26+
    27+
    /**
    28+
    * Gets the organization where the app was requested to be installed.
    29+
    *
    30+
    * @return the organization where the app was requested to be installed.
    31+
    */
    32+
    @SuppressFBWarnings(value = { "EI_EXPOSE_REP", "UWF_UNWRITTEN_FIELD" }, justification = "Expected behavior")
    33+
    public GHOrganization getAccount() {
    34+
    return account;
    35+
    }
    36+
    37+
    /**
    38+
    * Gets the user who requested the installation.
    39+
    *
    40+
    * @return the user who requested the installation.
    41+
    */
    42+
    @SuppressFBWarnings(value = { "EI_EXPOSE_REP", "UWF_UNWRITTEN_FIELD" }, justification = "Expected behavior")
    43+
    public GHUser getRequester() {
    44+
    return requester;
    45+
    }
    46+
    47+
    @Override
    48+
    public URL getHtmlUrl() throws IOException {
    49+
    return GitHubClient.parseURL(htmlUrl);
    50+
    }
    51+
    52+
    }
    Lines changed: 100 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,100 @@
    1+
    package org.kohsuke.github;
    2+
    3+
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    4+
    5+
    import java.io.IOException;
    6+
    7+
    /**
    8+
    * Represents a GitHub repository autolink reference.
    9+
    *
    10+
    * @author Alaurant
    11+
    * @see GHAutolinkBuilder
    12+
    * @see GHRepository#listAutolinks() GHRepository#listAutolinks()
    13+
    * @see <a href="https://docs.github.com/en/rest/repos/autolinks">Repository autolinks API</a>
    14+
    */
    15+
    public class GHAutolink {
    16+
    17+
    private int id;
    18+
    private String key_prefix;
    19+
    private String url_template;
    20+
    private boolean is_alphanumeric;
    21+
    private GHRepository owner;
    22+
    23+
    /**
    24+
    * Instantiates a new Gh autolink.
    25+
    */
    26+
    public GHAutolink() {
    27+
    }
    28+
    29+
    /**
    30+
    * Gets the autolink ID
    31+
    *
    32+
    * @return the id
    33+
    */
    34+
    public int getId() {
    35+
    return id;
    36+
    }
    37+
    38+
    /**
    39+
    * Gets the key prefix used to identify issues/PR references
    40+
    *
    41+
    * @return the key prefix string
    42+
    */
    43+
    public String getKeyPrefix() {
    44+
    return key_prefix;
    45+
    }
    46+
    47+
    /**
    48+
    * Gets the URL template that will be used for matching
    49+
    *
    50+
    * @return the URL template string
    51+
    */
    52+
    public String getUrlTemplate() {
    53+
    return url_template;
    54+
    }
    55+
    56+
    /**
    57+
    * Checks if the autolink uses alphanumeric values
    58+
    *
    59+
    * @return true if alphanumeric, false otherwise
    60+
    */
    61+
    public boolean isAlphanumeric() {
    62+
    return is_alphanumeric;
    63+
    }
    64+
    65+
    /**
    66+
    * Gets the repository that owns this autolink
    67+
    *
    68+
    * @return the repository instance
    69+
    */
    70+
    @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
    71+
    public GHRepository getOwner() {
    72+
    return owner;
    73+
    }
    74+
    75+
    /**
    76+
    * Deletes this autolink
    77+
    *
    78+
    * @throws IOException
    79+
    * if the deletion fails
    80+
    */
    81+
    public void delete() throws IOException {
    82+
    owner.root()
    83+
    .createRequest()
    84+
    .method("DELETE")
    85+
    .withUrlPath(String.format("/repos/%s/%s/autolinks/%d", owner.getOwnerName(), owner.getName(), getId()))
    86+
    .send();
    87+
    }
    88+
    89+
    /**
    90+
    * Wraps this autolink with its owner repository.
    91+
    *
    92+
    * @param owner
    93+
    * the repository that owns this autolink
    94+
    * @return this instance
    95+
    */
    96+
    GHAutolink lateBind(GHRepository owner) {
    97+
    this.owner = owner;
    98+
    return this;
    99+
    }
    100+
    }

    0 commit comments

    Comments
     (0)
    0