mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-11 15:50:17 +00:00
Compare commits
224 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e92f1321d4 | ||
|
|
208904b634 | ||
|
|
a433bcda2e | ||
|
|
77baafa643 | ||
|
|
224d8c7cb4 | ||
|
|
0feb520549 | ||
|
|
ca365b12f6 | ||
|
|
bde6ad9a06 | ||
|
|
4953f4500d | ||
|
|
4415ac8fd2 | ||
|
|
8c81e48a31 | ||
|
|
9ad0329c56 | ||
|
|
78f533bbfc | ||
|
|
79c7dd9ecf | ||
|
|
5d796d1f79 | ||
|
|
68a82be6c4 | ||
|
|
2676ef2b73 | ||
|
|
04b283c539 | ||
|
|
98b067937a | ||
|
|
8ababb60bf | ||
|
|
b51d655f77 | ||
|
|
74496d32da | ||
|
|
316e278be1 | ||
|
|
d881bf6504 | ||
|
|
c74fbbe1fd | ||
|
|
929d9fb7bd | ||
|
|
5d069d0531 | ||
|
|
dd9e6dc5d3 | ||
|
|
d22c77c41d | ||
|
|
3a11b7ccbf | ||
|
|
9d161b28bb | ||
|
|
9b16a1caa0 | ||
|
|
9a918e3bac | ||
|
|
d4c5c6a1e0 | ||
|
|
63fda3555c | ||
|
|
6a2381c06b | ||
|
|
e9c0a16c26 | ||
|
|
2101a67ac1 | ||
|
|
ddac568aaa | ||
|
|
262ae9f635 | ||
|
|
381502fb80 | ||
|
|
92fb441eb2 | ||
|
|
29e08037a8 | ||
|
|
84cc6d9315 | ||
|
|
b8d5a1c732 | ||
|
|
0197ab9661 | ||
|
|
b7915e61a6 | ||
|
|
586db99450 | ||
|
|
5377d0dd18 | ||
|
|
c5d3a7d573 | ||
|
|
8267050f06 | ||
|
|
c21bd5765a | ||
|
|
b78c37a695 | ||
|
|
2f151d45c3 | ||
|
|
3ebe3afdbd | ||
|
|
f4845df6c0 | ||
|
|
272b87f04d | ||
|
|
6e3f754366 | ||
|
|
6360112432 | ||
|
|
f1ca0b5417 | ||
|
|
0894c8007c | ||
|
|
0456f10709 | ||
|
|
b7d03f7463 | ||
|
|
07a392c2a7 | ||
|
|
5b69de770f | ||
|
|
bf67069768 | ||
|
|
91764c1c74 | ||
|
|
8b2a3e1221 | ||
|
|
def2f0b37d | ||
|
|
5d7479a3dd | ||
|
|
ceb2d35f9f | ||
|
|
fc38dba59a | ||
|
|
75b383d398 | ||
|
|
ee2d9491fb | ||
|
|
bf86a7c75a | ||
|
|
70f6d129e2 | ||
|
|
a4ac2aa99a | ||
|
|
ae3b6fbe6b | ||
|
|
e357fca963 | ||
|
|
c84cc89805 | ||
|
|
181238cd50 | ||
|
|
214c24c736 | ||
|
|
cf51ce8f26 | ||
|
|
2b7ed40d01 | ||
|
|
349ef7a54c | ||
|
|
94df5fc389 | ||
|
|
906238a297 | ||
|
|
7963fa82b5 | ||
|
|
1aba6012fb | ||
|
|
ff4324ac67 | ||
|
|
11bc669e1d | ||
|
|
dcf26d58e4 | ||
|
|
4d46872c35 | ||
|
|
4f0d62f421 | ||
|
|
f7ad1f517b | ||
|
|
345d6197f3 | ||
|
|
bb4d44138a | ||
|
|
a8ef0cde53 | ||
|
|
77dc009c95 | ||
|
|
aa298c93cc | ||
|
|
dfb0a5240e | ||
|
|
9cfc3c22b5 | ||
|
|
b177d98e29 | ||
|
|
5405fb0370 | ||
|
|
72a1c24b3b | ||
|
|
f146ae94ec | ||
|
|
a0bbba748a | ||
|
|
81bf818573 | ||
|
|
d5913dc292 | ||
|
|
e1e901b794 | ||
|
|
2f2f26767e | ||
|
|
bffa78c1b8 | ||
|
|
c55719c67a | ||
|
|
cb3b4a6642 | ||
|
|
92c141cee6 | ||
|
|
fd1a1a1c23 | ||
|
|
b835884b2e | ||
|
|
660763908d | ||
|
|
fe8bdb755a | ||
|
|
67dc6d2d23 | ||
|
|
9c8d73cbe2 | ||
|
|
5db97d92dd | ||
|
|
ac470dddb5 | ||
|
|
43063fe8ce | ||
|
|
59e0046c1e | ||
|
|
36ab05c265 | ||
|
|
2b2be05dae | ||
|
|
fb1adbd1ef | ||
|
|
ab68a59b25 | ||
|
|
9c7de767e9 | ||
|
|
8ba5cf7c2e | ||
|
|
b194a19b98 | ||
|
|
1d344b016f | ||
|
|
474f3ef4ca | ||
|
|
9830927020 | ||
|
|
727932a442 | ||
|
|
cd92b51845 | ||
|
|
fe26d16411 | ||
|
|
d68c66ce2b | ||
|
|
e7bfbfb48f | ||
|
|
f2a88ae61c | ||
|
|
e2113f6ee5 | ||
|
|
3867224024 | ||
|
|
9ee0bf43bc | ||
|
|
2844542efa | ||
|
|
e3fcae9392 | ||
|
|
c6ccfa91f3 | ||
|
|
b6fcee1cb9 | ||
|
|
9071befb04 | ||
|
|
bdd5fe98f3 | ||
|
|
a3d3e83a49 | ||
|
|
08bde72028 | ||
|
|
108a136368 | ||
|
|
57d87ad6b1 | ||
|
|
0c22815ff7 | ||
|
|
0ca792ecfd | ||
|
|
987c34c69e | ||
|
|
c1c02bc8ab | ||
|
|
4ee369f27c | ||
|
|
c9012efdcb | ||
|
|
41524fc67d | ||
|
|
04ff61e981 | ||
|
|
532468dc67 | ||
|
|
9c9a2dae47 | ||
|
|
c8a868b57f | ||
|
|
4b3f81ee34 | ||
|
|
afa170ba7c | ||
|
|
46e3b2272e | ||
|
|
52472e90ec | ||
|
|
4ef0d00846 | ||
|
|
580f2537f2 | ||
|
|
3d9fd96026 | ||
|
|
f449b92721 | ||
|
|
3b0216b023 | ||
|
|
98cf839737 | ||
|
|
0bb0846505 | ||
|
|
70969400a3 | ||
|
|
147e8d5d12 | ||
|
|
cacc3e6edd | ||
|
|
a284eca147 | ||
|
|
0d3ba9d7f0 | ||
|
|
be8064d642 | ||
|
|
e30dba742d | ||
|
|
44b72ed647 | ||
|
|
666bd77dac | ||
|
|
0a6613e60d | ||
|
|
62e186c123 | ||
|
|
50dd8f5bcc | ||
|
|
d5fcac9c45 | ||
|
|
c2bed85190 | ||
|
|
183b463ef2 | ||
|
|
92fdac44a0 | ||
|
|
12829ecc73 | ||
|
|
51319c3b26 | ||
|
|
8fd827040b | ||
|
|
5ec46eae0d | ||
|
|
32c03301be | ||
|
|
df7f29b2ab | ||
|
|
e863113c36 | ||
|
|
8e2c1d7382 | ||
|
|
ab7b9cccba | ||
|
|
81bf61a161 | ||
|
|
b40f008647 | ||
|
|
734e41702b | ||
|
|
038dd20a91 | ||
|
|
1dd62b8550 | ||
|
|
715deebe05 | ||
|
|
b3fe3d8590 | ||
|
|
f74c3ed3ea | ||
|
|
2c9aebeeed | ||
|
|
7474f1e11f | ||
|
|
dba9c55b64 | ||
|
|
b432364397 | ||
|
|
696967bdd1 | ||
|
|
b76889efc3 | ||
|
|
e6a7b64ebe | ||
|
|
9daa0df311 | ||
|
|
612800bda5 | ||
|
|
a6bbb1dec9 | ||
|
|
873c93ab64 | ||
|
|
d15242e2d2 | ||
|
|
992d2b937c | ||
|
|
1e05ddad4b | ||
|
|
4f8a64610b |
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "maven"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
time: "02:00"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
time: "02:00"
|
||||
5
.github/release-drafter.yml
vendored
5
.github/release-drafter.yml
vendored
@@ -1,5 +1,6 @@
|
||||
name-template: 'v$NEXT_PATCH_VERSION 🌈'
|
||||
tag-template: 'v$NEXT_PATCH_VERSION'
|
||||
name-template: 'v$NEXT_MINOR_VERSION 🌈'
|
||||
tag-template: 'github-api-$NEXT_MINOR_VERSION'
|
||||
version-template: '$MAJOR.$MINOR'
|
||||
categories:
|
||||
- title: '🚀 Features'
|
||||
labels:
|
||||
|
||||
6
.github/workflows/maven-build.yml
vendored
6
.github/workflows/maven-build.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
- name: Cached .m2
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
- uses: actions/cache@v1
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
- uses: actions/cache@v1
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
For changes after v1.101 see the [GitHub Releases page](https://github.com/hub4j/github-api/releases) for the project.
|
||||
|
||||
## [github-api-1.101](https://github.com/hub4j/github-api/tree/github-api-1.101) (2019-11-27)
|
||||
|
||||
[Full Changelog](https://github.com/hub4j/github-api/compare/github-api-1.100...github-api-1.101)
|
||||
|
||||
86
pom.xml
86
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.kohsuke</groupId>
|
||||
<artifactId>github-api</artifactId>
|
||||
<version>1.113</version>
|
||||
<version>1.117</version>
|
||||
<name>GitHub API for Java</name>
|
||||
<url>https://github-api.kohsuke.org/</url>
|
||||
<description>GitHub API for Java</description>
|
||||
@@ -11,7 +11,7 @@
|
||||
<connection>scm:git:git@github.com/hub4j/${project.artifactId}.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/hub4j/${project.artifactId}.git</developerConnection>
|
||||
<url>https://github.com/hub4j/github-api/</url>
|
||||
<tag>github-api-1.113</tag>
|
||||
<tag>github-api-1.117</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
@@ -33,8 +33,8 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spotbugs-maven-plugin.version>4.0.0</spotbugs-maven-plugin.version>
|
||||
<spotbugs.version>4.0.3</spotbugs.version>
|
||||
<spotbugs-maven-plugin.version>4.0.4</spotbugs-maven-plugin.version>
|
||||
<spotbugs.version>4.1.2</spotbugs.version>
|
||||
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
|
||||
<hamcrest.version>2.2</hamcrest.version>
|
||||
<okhttp3.version>4.4.1</okhttp3.version>
|
||||
@@ -79,6 +79,14 @@
|
||||
</testResources>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<configuration>
|
||||
<!-- SUREFIRE-1226 workaround -->
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
@@ -92,7 +100,7 @@
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.5</version>
|
||||
<version>0.8.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -233,7 +241,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.9.0</version>
|
||||
<version>3.9.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -258,7 +266,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.bcel</groupId>
|
||||
<artifactId>bcel</artifactId>
|
||||
<version>6.4.1</version>
|
||||
<version>6.5.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
@@ -280,16 +288,31 @@
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<configuration>
|
||||
<!-- SUREFIRE-1226 workaround -->
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-test</id>
|
||||
<configuration>
|
||||
<excludesFile>src/test/resources/slow-or-flaky-tests.txt</excludesFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>slow-or-flaky-test</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rerunFailingTestsCount>2</rerunFailingTestsCount>
|
||||
<!-- There are some tests that take longer or are a little flaky. Run them here. -->
|
||||
<includesFile>src/test/resources/slow-or-flaky-tests.txt</includesFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>animal-sniffer-maven-plugin</artifactId>
|
||||
<version>1.18</version>
|
||||
<version>1.19</version>
|
||||
<configuration>
|
||||
<signature>
|
||||
<groupId>org.codehaus.mojo.signature</groupId>
|
||||
@@ -322,7 +345,7 @@
|
||||
<plugin>
|
||||
<groupId>net.revelc.code.formatter</groupId>
|
||||
<artifactId>formatter-maven-plugin</artifactId>
|
||||
<version>2.11.0</version>
|
||||
<version>2.12.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -330,6 +353,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<configFile>src/main/resources/eclipse/formatter.xml</configFile>
|
||||
<cachedir>${project.build.directory}/.cache</cachedir>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@@ -408,7 +432,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13</version>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -445,7 +469,7 @@
|
||||
<dependency>
|
||||
<groupId>org.kohsuke.stapler</groupId>
|
||||
<artifactId>stapler</artifactId>
|
||||
<version>1.259</version>
|
||||
<version>1.260</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -457,7 +481,25 @@
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jgit</groupId>
|
||||
<artifactId>org.eclipse.jgit</artifactId>
|
||||
<version>5.7.0.202003110725-r</version>
|
||||
<version>5.9.0.202009080501-r</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-api</artifactId>
|
||||
<version>0.11.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-impl</artifactId>
|
||||
<version>0.11.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>0.11.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -495,7 +537,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.3.3</version>
|
||||
<version>3.6.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -507,7 +549,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock-jre8-standalone</artifactId>
|
||||
<version>2.26.3</version>
|
||||
<version>2.27.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -516,6 +558,12 @@
|
||||
<version>2.8.6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
||||
@@ -3,11 +3,13 @@ package org.kohsuke.github;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.kohsuke.github.Previews.GAMBIT;
|
||||
import static org.kohsuke.github.Previews.MACHINE_MAN;
|
||||
|
||||
/**
|
||||
* A Github App Installation.
|
||||
@@ -117,6 +119,36 @@ public class GHAppInstallation extends GHObject {
|
||||
return repositoriesUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* List repositories that this app installation can access.
|
||||
*
|
||||
* @return the paged iterable
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public PagedSearchIterable<GHRepository> listRepositories() {
|
||||
GitHubRequest request;
|
||||
|
||||
try {
|
||||
request = root.createRequest().withPreview(MACHINE_MAN).withUrlPath("/installation/repositories").build();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new GHException("", e);
|
||||
}
|
||||
|
||||
return new PagedSearchIterable<>(root, request, GHAppInstallationRepositoryResult.class);
|
||||
}
|
||||
|
||||
private static class GHAppInstallationRepositoryResult extends SearchResult<GHRepository> {
|
||||
private GHRepository[] repositories;
|
||||
|
||||
@Override
|
||||
GHRepository[] getItems(GitHub root) {
|
||||
for (GHRepository item : repositories)
|
||||
item.wrap(root);
|
||||
return repositories;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repositories url.
|
||||
*
|
||||
|
||||
@@ -9,6 +9,8 @@ import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
/**
|
||||
* A branch in a repository.
|
||||
*
|
||||
@@ -101,7 +103,11 @@ public class GHBranch {
|
||||
* the io exception
|
||||
*/
|
||||
public GHBranchProtection getProtection() throws IOException {
|
||||
return root.createRequest().setRawUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this);
|
||||
return root.createRequest()
|
||||
.withPreview(Previews.LUKE_CAGE)
|
||||
.setRawUrlPath(protection_url)
|
||||
.fetch(GHBranchProtection.class)
|
||||
.wrap(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,6 +167,59 @@ public class GHBranch {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge a branch into this branch.
|
||||
*
|
||||
* @param headBranch
|
||||
* the branch whose head will be merged
|
||||
*
|
||||
* @param commitMessage
|
||||
* the commit message
|
||||
*
|
||||
* @return the merge {@link GHCommit} created, or {@code null} if the base already contains the head (nothing to
|
||||
* merge).
|
||||
*
|
||||
* @throws IOException
|
||||
* if merging fails
|
||||
*/
|
||||
@CheckForNull
|
||||
public GHCommit merge(GHBranch headBranch, String commitMessage) throws IOException {
|
||||
return merge(headBranch.getName(), commitMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge a ref into this branch.
|
||||
*
|
||||
* @param head
|
||||
* the ref name that will be merged into this branch. Follows the usual ref naming rules, could be a
|
||||
* branch name, tag, or commit sha.
|
||||
*
|
||||
* @param commitMessage
|
||||
* the commit message
|
||||
*
|
||||
* @return the merge {@link GHCommit} created, or {@code null} if the base already contains the head (nothing to
|
||||
* merge).
|
||||
*
|
||||
* @throws IOException
|
||||
* if merging fails
|
||||
*/
|
||||
@CheckForNull
|
||||
public GHCommit merge(String head, String commitMessage) throws IOException {
|
||||
GHCommit result = root.createRequest()
|
||||
.withUrlPath(owner.getApiTailUrl("merges"))
|
||||
.method("POST")
|
||||
.with("commit_message", commitMessage)
|
||||
.with("base", this.name)
|
||||
.with("head", head)
|
||||
.fetch(GHCommit.class);
|
||||
|
||||
if (result != null) {
|
||||
result.wrapUp(owner);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String getApiRoute() {
|
||||
return owner.getApiTailUrl("/branches/" + name);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import static org.kohsuke.github.Previews.ZZZAX;
|
||||
|
||||
/**
|
||||
* The type GHBranchProtection.
|
||||
*
|
||||
* @see <a href="https://docs.github.com/en/rest/reference/repos#get-branch-protection">GitHub Branch Protection</a>
|
||||
*/
|
||||
@SuppressFBWarnings(
|
||||
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a check run.
|
||||
@@ -14,6 +19,8 @@ import java.util.Date;
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHCheckRun extends GHObject {
|
||||
|
||||
@JsonProperty("repository")
|
||||
GHRepository owner;
|
||||
GitHub root;
|
||||
|
||||
@@ -34,7 +41,7 @@ public class GHCheckRun extends GHObject {
|
||||
|
||||
GHCheckRun wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
wrap(owner.root);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -42,7 +49,24 @@ public class GHCheckRun extends GHObject {
|
||||
this.root = root;
|
||||
if (owner != null) {
|
||||
owner.wrap(root);
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.wrap(owner);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (checkSuite != null) {
|
||||
if (owner != null) {
|
||||
checkSuite.wrap(owner);
|
||||
} else {
|
||||
checkSuite.wrap(root);
|
||||
}
|
||||
}
|
||||
if (app != null) {
|
||||
app.wrapUp(root);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -74,8 +98,14 @@ public class GHCheckRun extends GHObject {
|
||||
return conclusion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Final conclusion of the check.
|
||||
*
|
||||
* From <a href="https://docs.github.com/en/rest/reference/checks#create-a-check-run--parameters">Check Run
|
||||
* Parameters - <code>conclusion</code></a>.
|
||||
*/
|
||||
public static enum Conclusion {
|
||||
SUCCESS, FAILURE, NEUTRAL, CANCELLED, TIMED_OUT, ACTION_REQUIRED
|
||||
SUCCESS, FAILURE, NEUTRAL, CANCELLED, TIMED_OUT, ACTION_REQUIRED, SKIPPED
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,15 +129,22 @@ public class GHCheckRun extends GHObject {
|
||||
/**
|
||||
* Gets the pull requests participated in this check run.
|
||||
*
|
||||
* @return Pull requests of this check run
|
||||
* Note this field is only populated for events. When getting a {@link GHCheckRun} outside of an event, this is
|
||||
* always empty.
|
||||
*
|
||||
* @return the list of {@link GHPullRequest}s for this check run. Only populated for events.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
GHPullRequest[] getPullRequests() throws IOException {
|
||||
public List<GHPullRequest> getPullRequests() throws IOException {
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.refresh();
|
||||
// Only refresh if we haven't do so before
|
||||
singlePull.refresh(singlePull.getTitle());
|
||||
}
|
||||
return Collections.unmodifiableList(Arrays.asList(pullRequests));
|
||||
}
|
||||
return pullRequests;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,4 +293,15 @@ public class GHCheckRun extends GHObject {
|
||||
NOTICE, WARNING, FAILURE
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates this check run.
|
||||
*
|
||||
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public @NonNull GHCheckRunBuilder update() {
|
||||
return new GHCheckRunBuilder(owner, getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,30 +37,45 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Drafts a check run.
|
||||
* Drafts or updates a check run.
|
||||
*
|
||||
* @see GHCheckRun
|
||||
* @see GHRepository#createCheckRun
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#create-a-check-run">documentation</a>
|
||||
* @see GHCheckRun#update()
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#update-a-check-run">documentation</a>
|
||||
*/
|
||||
@SuppressFBWarnings(value = "URF_UNREAD_FIELD", justification = "Jackson serializes these even without a getter")
|
||||
@Preview
|
||||
@Deprecated
|
||||
public final class GHCheckRunBuilder {
|
||||
|
||||
private final GHRepository repo;
|
||||
private final Requester requester;
|
||||
protected final GHRepository repo;
|
||||
protected final Requester requester;
|
||||
private Output output;
|
||||
private List<Action> actions;
|
||||
|
||||
GHCheckRunBuilder(GHRepository repo, String name, String headSHA) {
|
||||
private GHCheckRunBuilder(GHRepository repo, Requester requester) {
|
||||
this.repo = repo;
|
||||
requester = repo.root.createRequest()
|
||||
.withPreview(Previews.ANTIOPE)
|
||||
.method("POST")
|
||||
.with("name", name)
|
||||
.with("head_sha", headSHA)
|
||||
.withUrlPath(repo.getApiTailUrl("check-runs"));
|
||||
this.requester = requester;
|
||||
}
|
||||
|
||||
GHCheckRunBuilder(GHRepository repo, String name, String headSHA) {
|
||||
this(repo,
|
||||
repo.root.createRequest()
|
||||
.withPreview(Previews.ANTIOPE)
|
||||
.method("POST")
|
||||
.with("name", name)
|
||||
.with("head_sha", headSHA)
|
||||
.withUrlPath(repo.getApiTailUrl("check-runs")));
|
||||
}
|
||||
|
||||
GHCheckRunBuilder(GHRepository repo, long checkId) {
|
||||
this(repo,
|
||||
repo.root.createRequest()
|
||||
.withPreview(Previews.ANTIOPE)
|
||||
.method("PATCH")
|
||||
.withUrlPath(repo.getApiTailUrl("check-runs/" + checkId)));
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withDetailsURL(@CheckForNull String detailsURL) {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a check suite.
|
||||
@@ -14,6 +18,8 @@ import java.util.Date;
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHCheckSuite extends GHObject {
|
||||
|
||||
@JsonProperty("repository")
|
||||
GHRepository owner;
|
||||
GitHub root;
|
||||
|
||||
@@ -32,7 +38,7 @@ public class GHCheckSuite extends GHObject {
|
||||
|
||||
GHCheckSuite wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
this.wrap(owner.root);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -40,6 +46,14 @@ public class GHCheckSuite extends GHObject {
|
||||
this.root = root;
|
||||
if (owner != null) {
|
||||
owner.wrap(root);
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.wrap(owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (app != null) {
|
||||
app.wrapUp(root);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -153,15 +167,22 @@ public class GHCheckSuite extends GHObject {
|
||||
/**
|
||||
* Gets the pull requests participated in this check suite.
|
||||
*
|
||||
* @return Pull requests
|
||||
* Note this field is only populated for events. When getting a {@link GHCheckSuite} outside of an event, this is
|
||||
* always empty.
|
||||
*
|
||||
* @return the list of {@link GHPullRequest}s for this check suite. Only populated for events.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
GHPullRequest[] getPullRequests() throws IOException {
|
||||
public List<GHPullRequest> getPullRequests() throws IOException {
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.refresh();
|
||||
// Only refresh if we haven't do so before
|
||||
singlePull.refresh(singlePull.getTitle());
|
||||
}
|
||||
return Collections.unmodifiableList(Arrays.asList(pullRequests));
|
||||
}
|
||||
return pullRequests;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,8 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.kohsuke.github.Previews.GROOT;
|
||||
|
||||
/**
|
||||
* A commit in a repository.
|
||||
*
|
||||
@@ -446,6 +448,39 @@ public class GHCommit {
|
||||
return owner.root.getUser(author.login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of pull requests which contain this commit.
|
||||
*
|
||||
* @return {@link PagedIterable} with the pull requests which contain this commit
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public PagedIterable<GHPullRequest> listPullRequests() {
|
||||
return owner.root.createRequest()
|
||||
.withPreview(GROOT)
|
||||
.withUrlPath(String.format("/repos/%s/%s/commits/%s/pulls", owner.getOwnerName(), owner.getName(), sha))
|
||||
.toIterable(GHPullRequest[].class, item -> item.wrapUp(owner));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of branches where this commit is the head commit.
|
||||
*
|
||||
* @return {@link PagedIterable} with the branches where the commit is the head commit
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public PagedIterable<GHBranch> listBranchesWhereHead() throws IOException {
|
||||
return owner.root.createRequest()
|
||||
.withPreview(GROOT)
|
||||
.withUrlPath(String.format("/repos/%s/%s/commits/%s/branches-where-head",
|
||||
owner.getOwnerName(),
|
||||
owner.getName(),
|
||||
sha))
|
||||
.toIterable(GHBranch[].class, item -> item.wrap(owner));
|
||||
}
|
||||
|
||||
/**
|
||||
* List comments paged iterable.
|
||||
*
|
||||
|
||||
@@ -89,6 +89,19 @@ public class GHCommitBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the PGP signature of this commit.
|
||||
*
|
||||
* @param signature
|
||||
* the signature calculated from the commit
|
||||
*
|
||||
* @return the gh commit builder
|
||||
*/
|
||||
public GHCommitBuilder withSignature(String signature) {
|
||||
req.with("signature", signature);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the committer of this commit.
|
||||
*
|
||||
|
||||
@@ -30,6 +30,7 @@ public class GHContent implements Refreshable {
|
||||
private String sha;
|
||||
private String name;
|
||||
private String path;
|
||||
private String target;
|
||||
private String content;
|
||||
private String url; // this is the API url
|
||||
private String git_url; // this is the Blob url
|
||||
@@ -99,6 +100,15 @@ public class GHContent implements Refreshable {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets target of a symlink. This will only be set if {@code "symlink".equals(getType())}
|
||||
*
|
||||
* @return the target
|
||||
*/
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the decoded content that is stored at this location.
|
||||
*
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.kohsuke.github;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.kohsuke.github.Previews.BAPTISE;
|
||||
|
||||
/**
|
||||
* Creates a repository
|
||||
*
|
||||
@@ -11,7 +13,7 @@ import java.net.URL;
|
||||
public class GHCreateRepositoryBuilder {
|
||||
private final GitHub root;
|
||||
protected final Requester builder;
|
||||
private final String apiUrlTail;
|
||||
private String apiUrlTail;
|
||||
|
||||
GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) {
|
||||
this.root = root;
|
||||
@@ -200,6 +202,51 @@ public class GHCreateRepositoryBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether the repository is a template.
|
||||
*
|
||||
* @param enabled
|
||||
* true if enabled
|
||||
* @return a builder to continue with building
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public GHCreateRepositoryBuilder templateRepository(boolean enabled) {
|
||||
this.builder.withPreview(BAPTISE);
|
||||
this.builder.with("is_template", enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the ownership of the repository.
|
||||
*
|
||||
* @param owner
|
||||
* organization or personage
|
||||
* @return a builder to continue with building
|
||||
*/
|
||||
public GHCreateRepositoryBuilder owner(String owner) {
|
||||
this.builder.with("owner", owner);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create repository from template repository.
|
||||
*
|
||||
* @param templateOwner
|
||||
* template repository owner
|
||||
* @param templateRepo
|
||||
* template repository
|
||||
* @return a builder to continue with building
|
||||
* @see <a href="https://developer.github.com/v3/previews/">GitHub API Previews</a>
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public GHCreateRepositoryBuilder fromTemplateRepository(String templateOwner, String templateRepo) {
|
||||
this.builder.withPreview(BAPTISE);
|
||||
this.apiUrlTail = "/repos/" + templateOwner + "/" + templateRepo + "/generate";
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a repository with all the parameters.
|
||||
*
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents a deployment
|
||||
@@ -60,7 +61,8 @@ public class GHDeployment extends GHObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets payload.
|
||||
* Gets payload. <b>NOTE:</b> only use this method if you can guarantee the payload will be a simple string,
|
||||
* otherwise use {@link #getPayloadObject()}.
|
||||
*
|
||||
* @return the payload
|
||||
*/
|
||||
@@ -68,6 +70,25 @@ public class GHDeployment extends GHObject {
|
||||
return (String) payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets payload. <b>NOTE:</b> only use this method if you can guarantee the payload will be a JSON object (Map),
|
||||
* otherwise use {@link #getPayloadObject()}.
|
||||
*
|
||||
* @return the payload
|
||||
*/
|
||||
public Map<String, Object> getPayloadMap() {
|
||||
return (Map<String, Object>) payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets payload without assuming its type. It could be a String or a Map.
|
||||
*
|
||||
* @return the payload
|
||||
*/
|
||||
public Object getPayloadObject() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets environment.
|
||||
*
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
@@ -158,7 +157,6 @@ public class GHDiscussion extends GHObject {
|
||||
team.root.createRequest().method("DELETE").setRawUrlPath(getRawUrlPath(team, number)).send();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getRawUrlPath(@Nonnull GHTeam team, @CheckForNull Long discussionNumber) {
|
||||
return team.getUrl().toString() + "/discussions" + (discussionNumber == null ? "" : "/" + discussionNumber);
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ public enum GHEvent {
|
||||
TEAM,
|
||||
TEAM_ADD,
|
||||
WATCH,
|
||||
WORKFLOW_DISPATCH,
|
||||
WORKFLOW_RUN,
|
||||
|
||||
/**
|
||||
* Special event type that means "every possible event"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -158,10 +158,8 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
* Gets labels.
|
||||
*
|
||||
* @return the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public Collection<GHLabel> getLabels() throws IOException {
|
||||
public Collection<GHLabel> getLabels() {
|
||||
if (labels == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -239,7 +237,7 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
}
|
||||
|
||||
private void editIssue(String key, Object value) throws IOException {
|
||||
root.createRequest().with(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
|
||||
root.createRequest().withNullable(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,9 +294,9 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
*/
|
||||
public void setMilestone(GHMilestone milestone) throws IOException {
|
||||
if (milestone == null) {
|
||||
editNullable("milestone", null);
|
||||
editIssue("milestone", null);
|
||||
} else {
|
||||
edit("milestone", milestone.getNumber());
|
||||
editIssue("milestone", milestone.getNumber());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -421,7 +421,7 @@ public class GHOrganization extends GHPerson {
|
||||
* The enum Permission.
|
||||
*/
|
||||
public enum Permission {
|
||||
ADMIN, PUSH, PULL
|
||||
ADMIN, MAINTAIN, PUSH, TRIAGE, PULL
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -154,10 +154,7 @@ public abstract class GHPerson extends GHObject {
|
||||
*/
|
||||
public GHRepository getRepository(String name) throws IOException {
|
||||
try {
|
||||
return root.createRequest()
|
||||
.withUrlPath("/repos/" + login + '/' + name)
|
||||
.fetch(GHRepository.class)
|
||||
.wrap(root);
|
||||
return GHRepository.read(root, login, name);
|
||||
} catch (FileNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -80,10 +80,8 @@ public class GHProject extends GHObject {
|
||||
} else if (owner_url.contains("/users/")) {
|
||||
owner = root.createRequest().withUrlPath(getOwnerUrl().getPath()).fetch(GHUser.class).wrapUp(root);
|
||||
} else if (owner_url.contains("/repos/")) {
|
||||
owner = root.createRequest()
|
||||
.withUrlPath(getOwnerUrl().getPath())
|
||||
.fetch(GHRepository.class)
|
||||
.wrap(root);
|
||||
String[] pathElements = getOwnerUrl().getPath().split("/");
|
||||
owner = GHRepository.read(root, pathElements[1], pathElements[2]);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
return null;
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -37,6 +36,7 @@ import java.util.Objects;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
import static org.kohsuke.github.Previews.LYDIAN;
|
||||
import static org.kohsuke.github.Previews.SHADOW_CAT;
|
||||
|
||||
/**
|
||||
@@ -72,13 +72,6 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
private GHUser[] requested_reviewers;
|
||||
private GHTeam[] requested_teams;
|
||||
|
||||
/**
|
||||
* GitHub doesn't return some properties of {@link GHIssue} when requesting the GET on the 'pulls' API route as
|
||||
* opposed to 'issues' API route. This flag remembers whether we made the GET call on the 'issues' route on this
|
||||
* object to fill in those missing details
|
||||
*/
|
||||
private transient boolean fetchedIssueDetails;
|
||||
|
||||
GHPullRequest wrapUp(GHRepository owner) {
|
||||
this.wrap(owner);
|
||||
return wrapUp(owner.root);
|
||||
@@ -177,12 +170,6 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
return GitHubClient.parseDate(merged_at);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<GHLabel> getLabels() throws IOException {
|
||||
fetchIssue();
|
||||
return super.getLabels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GHUser getClosedBy() {
|
||||
return null;
|
||||
@@ -565,6 +552,41 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the base branch on the pull request
|
||||
*
|
||||
* @param newBaseBranch
|
||||
* the name of the new base branch
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @return the updated pull request
|
||||
*/
|
||||
public GHPullRequest setBaseBranch(String newBaseBranch) throws IOException {
|
||||
return root.createRequest()
|
||||
.method("PATCH")
|
||||
.with("base", newBaseBranch)
|
||||
.withUrlPath(getApiRoute())
|
||||
.fetch(GHPullRequest.class)
|
||||
.wrapUp(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the branch. The same as pressing the button in the web GUI.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public void updateBranch() throws IOException {
|
||||
root.createRequest()
|
||||
.withPreview(LYDIAN)
|
||||
.method("PUT")
|
||||
.with("expected_head_sha", head.getSha())
|
||||
.withUrlPath(getApiRoute() + "/update-branch")
|
||||
.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge this pull request.
|
||||
* <p>
|
||||
@@ -626,10 +648,4 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
MERGE, SQUASH, REBASE
|
||||
}
|
||||
|
||||
private void fetchIssue() throws IOException {
|
||||
if (!fetchedIssueDetails) {
|
||||
root.createRequest().withUrlPath(getIssuesApiRoute()).fetchInto(this);
|
||||
fetchedIssueDetails = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
86
src/main/java/org/kohsuke/github/GHPullRequestChanges.java
Normal file
86
src/main/java/org/kohsuke/github/GHPullRequestChanges.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
/**
|
||||
* Wrapper to define changed fields on pull_request action="edited"
|
||||
*
|
||||
* @see GHEventPayload.PullRequest
|
||||
*/
|
||||
@SuppressFBWarnings("UWF_UNWRITTEN_FIELD")
|
||||
public class GHPullRequestChanges {
|
||||
|
||||
private GHCommitPointer base;
|
||||
private GHFrom title;
|
||||
private GHFrom body;
|
||||
|
||||
/**
|
||||
* Old target branch for pull request.
|
||||
*
|
||||
* @return old target branch info (or null if not changed)
|
||||
*/
|
||||
public GHCommitPointer getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Old pull request title.
|
||||
*
|
||||
* @return old pull request title (or null if not changed)
|
||||
*/
|
||||
public GHFrom getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Old pull request body.
|
||||
*
|
||||
* @return old pull request body (or null if not changed)
|
||||
*/
|
||||
public GHFrom getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.kohsuke.github.GHCommitPointer
|
||||
*/
|
||||
public static class GHCommitPointer {
|
||||
private GHFrom ref;
|
||||
private GHFrom sha;
|
||||
|
||||
/**
|
||||
* Named ref to the commit. This (from value) appears to be a "short ref" that doesn't include "refs/heads/"
|
||||
* portion.
|
||||
*
|
||||
* @return the ref
|
||||
*/
|
||||
public GHFrom getRef() {
|
||||
return ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA1 of the commit.
|
||||
*
|
||||
* @return sha
|
||||
*/
|
||||
public GHFrom getSha() {
|
||||
return sha;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for changed values.
|
||||
*/
|
||||
public static class GHFrom {
|
||||
private String from;
|
||||
|
||||
/**
|
||||
* Previous value that was changed.
|
||||
*
|
||||
* @return previous value
|
||||
*/
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ public class GHPullRequestReview extends GHObject {
|
||||
private String commit_id;
|
||||
private GHPullRequestReviewState state;
|
||||
private String submitted_at;
|
||||
private String html_url;
|
||||
|
||||
GHPullRequestReview wrapUp(GHPullRequest owner) {
|
||||
this.owner = owner;
|
||||
@@ -102,7 +103,7 @@ public class GHPullRequestReview extends GHObject {
|
||||
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return null;
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
@@ -29,7 +30,7 @@ public class GHRateLimit {
|
||||
/**
|
||||
* Remaining calls that can be made.
|
||||
*
|
||||
* @deprecated This value should never have been made public. Use {@link #getRemaining()}
|
||||
* @deprecated This field should never have been made public. Use {@link #getRemaining()}
|
||||
*/
|
||||
@Deprecated
|
||||
public int remaining;
|
||||
@@ -37,7 +38,7 @@ public class GHRateLimit {
|
||||
/**
|
||||
* Allotted API call per hour.
|
||||
*
|
||||
* @deprecated This value should never have been made public. Use {@link #getLimit()}
|
||||
* @deprecated This field should never have been made public. Use {@link #getLimit()}
|
||||
*/
|
||||
@Deprecated
|
||||
public int limit;
|
||||
@@ -48,7 +49,7 @@ public class GHRateLimit {
|
||||
* date. To use this field in any meaningful way, it must be converted to a long using {@link Date#getTime()}
|
||||
* multiplied by 1000.
|
||||
*
|
||||
* @deprecated This value should never have been made public. Use {@link #getResetDate()}
|
||||
* @deprecated This field should never have been made public. Use {@link #getResetDate()}
|
||||
*/
|
||||
@Deprecated
|
||||
public Date reset;
|
||||
@@ -65,17 +66,58 @@ public class GHRateLimit {
|
||||
@Nonnull
|
||||
private final Record integrationManifest;
|
||||
|
||||
/**
|
||||
* The default GHRateLimit provided to new {@link GitHubClient}s.
|
||||
*
|
||||
* Contains all expired records that will cause {@link GitHubClient#rateLimit(RateLimitTarget)} to refresh with new
|
||||
* data when called.
|
||||
*
|
||||
* Private, but made internal for testing.
|
||||
*/
|
||||
@Nonnull
|
||||
static GHRateLimit Unknown() {
|
||||
return new GHRateLimit(new UnknownLimitRecord(),
|
||||
new UnknownLimitRecord(),
|
||||
new UnknownLimitRecord(),
|
||||
new UnknownLimitRecord());
|
||||
}
|
||||
static final GHRateLimit DEFAULT = new GHRateLimit(UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT);
|
||||
|
||||
/**
|
||||
* Creates a new {@link GHRateLimit} from a single record for the specified endpoint with place holders for other
|
||||
* records.
|
||||
*
|
||||
* This is used to create {@link GHRateLimit} instances that can merged with other instances.
|
||||
*
|
||||
* @param record
|
||||
* the rate limit record. Can be a regular {@link Record} constructed from header information or an
|
||||
* {@link UnknownLimitRecord} placeholder.
|
||||
* @param rateLimitTarget
|
||||
* which rate limit record to fill
|
||||
* @return a new {@link GHRateLimit} instance containing the supplied record
|
||||
*/
|
||||
@Nonnull
|
||||
static GHRateLimit fromHeaderRecord(Record header) {
|
||||
return new GHRateLimit(header, new UnknownLimitRecord(), new UnknownLimitRecord(), new UnknownLimitRecord());
|
||||
static GHRateLimit fromRecord(@Nonnull Record record, @Nonnull RateLimitTarget rateLimitTarget) {
|
||||
if (rateLimitTarget == RateLimitTarget.CORE || rateLimitTarget == RateLimitTarget.NONE) {
|
||||
return new GHRateLimit(record,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT);
|
||||
} else if (rateLimitTarget == RateLimitTarget.SEARCH) {
|
||||
return new GHRateLimit(UnknownLimitRecord.DEFAULT,
|
||||
record,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT);
|
||||
} else if (rateLimitTarget == RateLimitTarget.GRAPHQL) {
|
||||
return new GHRateLimit(UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
record,
|
||||
UnknownLimitRecord.DEFAULT);
|
||||
} else if (rateLimitTarget == RateLimitTarget.INTEGRATION_MANIFEST) {
|
||||
return new GHRateLimit(UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
record);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown rate limit target: " + rateLimitTarget.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
@@ -142,7 +184,7 @@ public class GHRateLimit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the rate limit reset date for this instance has passed.
|
||||
* Whether the reset date for the Core API rate limit has passed.
|
||||
*
|
||||
* @return true if the rate limit reset date has passed. Otherwise false.
|
||||
* @since 1.100
|
||||
@@ -152,7 +194,7 @@ public class GHRateLimit {
|
||||
}
|
||||
|
||||
/**
|
||||
* The core object provides your rate limit status for all non-search-related resources in the REST API.
|
||||
* The core object provides the rate limit status for all non-search-related resources in the REST API.
|
||||
*
|
||||
* @return a rate limit record
|
||||
* @since 1.100
|
||||
@@ -163,42 +205,43 @@ public class GHRateLimit {
|
||||
}
|
||||
|
||||
/**
|
||||
* The search object provides your rate limit status for the Search API. TODO: integrate with header limit updating.
|
||||
* Issue #605.
|
||||
* The search record provides the rate limit status for the Search API.
|
||||
*
|
||||
* @return a rate limit record
|
||||
* @since 1.115
|
||||
*/
|
||||
@Nonnull
|
||||
Record getSearch() {
|
||||
public Record getSearch() {
|
||||
return search;
|
||||
}
|
||||
|
||||
/**
|
||||
* The graphql object provides your rate limit status for the GraphQL API. TODO: integrate with header limit
|
||||
* updating. Issue #605.
|
||||
* The graphql record provides the rate limit status for the GraphQL API.
|
||||
*
|
||||
* @return a rate limit record
|
||||
* @since 1.115
|
||||
*/
|
||||
@Nonnull
|
||||
Record getGraphQL() {
|
||||
public Record getGraphQL() {
|
||||
return graphql;
|
||||
}
|
||||
|
||||
/**
|
||||
* The integration_manifest object provides your rate limit status for the GitHub App Manifest code conversion
|
||||
* endpoint. TODO: integrate with header limit updating. Issue #605.
|
||||
* The integration manifest record provides the rate limit status for the GitHub App Manifest code conversion
|
||||
* endpoint.
|
||||
*
|
||||
* @return a rate limit record
|
||||
* @since 1.115
|
||||
*/
|
||||
@Nonnull
|
||||
Record getIntegrationManifest() {
|
||||
public Record getIntegrationManifest() {
|
||||
return integrationManifest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GHRateLimit {" + "core " + getCore().toString() + "search " + getSearch().toString() + "graphql "
|
||||
+ getGraphQL().toString() + "integrationManifest " + getIntegrationManifest().toString() + '}';
|
||||
return "GHRateLimit {" + "core " + getCore().toString() + ", search " + getSearch().toString() + ", graphql "
|
||||
+ getGraphQL().toString() + ", integrationManifest " + getIntegrationManifest().toString() + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,44 +264,111 @@ public class GHRateLimit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the appropriate {@link Record} for a particular url path.
|
||||
*
|
||||
* @param urlPath
|
||||
* the url path of the request
|
||||
* @return the {@link Record} for a url path.
|
||||
* Merge a {@link GHRateLimit} with another one to create a new {@link GHRateLimit} keeping the latest
|
||||
* {@link Record}s from each.
|
||||
*
|
||||
* @param newLimit
|
||||
* {@link GHRateLimit} with potentially updated {@link Record}s.
|
||||
* @return a merged {@link GHRateLimit} with the latest {@link Record}s from these two instances. If the merged
|
||||
* instance is equal to the current instance, the current instance is returned.
|
||||
*/
|
||||
@Nonnull
|
||||
Record getRecordForUrlPath(@Nonnull String urlPath) {
|
||||
if (urlPath.equals("/rate_limit")) {
|
||||
return new UnknownLimitRecord();
|
||||
} else if (urlPath.startsWith("/search")) {
|
||||
return getSearch();
|
||||
} else if (urlPath.startsWith("/graphql")) {
|
||||
return getGraphQL();
|
||||
} else if (urlPath.startsWith("/app-manifests")) {
|
||||
return getIntegrationManifest();
|
||||
} else {
|
||||
GHRateLimit getMergedRateLimit(@Nonnull GHRateLimit newLimit) {
|
||||
|
||||
GHRateLimit merged = new GHRateLimit(getCore().currentOrUpdated(newLimit.getCore()),
|
||||
getSearch().currentOrUpdated(newLimit.getSearch()),
|
||||
getGraphQL().currentOrUpdated(newLimit.getGraphQL()),
|
||||
getIntegrationManifest().currentOrUpdated(newLimit.getIntegrationManifest()));
|
||||
|
||||
if (merged.equals(this)) {
|
||||
merged = this;
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the specified {@link Record}.
|
||||
*
|
||||
* {@link RateLimitTarget#NONE} will return {@link UnknownLimitRecord#DEFAULT} to prevent any clients from
|
||||
* accidentally waiting on that record to reset before continuing.
|
||||
*
|
||||
* @param rateLimitTarget
|
||||
* the target rate limit record
|
||||
* @return the target {@link Record} from this instance.
|
||||
*/
|
||||
@Nonnull
|
||||
Record getRecord(@Nonnull RateLimitTarget rateLimitTarget) {
|
||||
if (rateLimitTarget == RateLimitTarget.CORE) {
|
||||
return getCore();
|
||||
} else if (rateLimitTarget == RateLimitTarget.SEARCH) {
|
||||
return getSearch();
|
||||
} else if (rateLimitTarget == RateLimitTarget.GRAPHQL) {
|
||||
return getGraphQL();
|
||||
} else if (rateLimitTarget == RateLimitTarget.INTEGRATION_MANIFEST) {
|
||||
return getIntegrationManifest();
|
||||
} else if (rateLimitTarget == RateLimitTarget.NONE) {
|
||||
return UnknownLimitRecord.DEFAULT;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown rate limit target: " + rateLimitTarget.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A limit record used as a placeholder when the the actual limit is not known.
|
||||
* <p>
|
||||
* Has a large limit and long duration so that it will doesn't expire too often.
|
||||
*
|
||||
* @since 1.100
|
||||
*/
|
||||
public static class UnknownLimitRecord extends Record {
|
||||
|
||||
// One hour
|
||||
private static final long unknownLimitResetSeconds = 60L * 60L;
|
||||
private static final long defaultUnknownLimitResetSeconds = Duration.ofSeconds(30).getSeconds();
|
||||
|
||||
/**
|
||||
* The number of seconds until a {@link UnknownLimitRecord} will expire.
|
||||
*
|
||||
* This is set to a somewhat short duration, rather than a long one. This avoids
|
||||
* {@link {@link GitHubClient#rateLimit(RateLimitTarget)}} requesting rate limit updates continuously, but also
|
||||
* avoids holding on to stale unknown records indefinitely.
|
||||
*
|
||||
* When merging {@link GHRateLimit} instances, {@link UnknownLimitRecord}s will be superseded by incoming
|
||||
* regular {@link Record}s.
|
||||
*
|
||||
* @see GHRateLimit#getMergedRateLimit(GHRateLimit)
|
||||
*/
|
||||
static long unknownLimitResetSeconds = defaultUnknownLimitResetSeconds;
|
||||
|
||||
static final int unknownLimit = 1000000;
|
||||
static final int unknownRemaining = 999999;
|
||||
|
||||
private UnknownLimitRecord() {
|
||||
super(unknownLimit, unknownRemaining, System.currentTimeMillis() / 1000L + unknownLimitResetSeconds);
|
||||
// The default UnknownLimitRecord is an expired record.
|
||||
private static final UnknownLimitRecord DEFAULT = new UnknownLimitRecord(Long.MIN_VALUE);
|
||||
|
||||
// The starting current UnknownLimitRecord is an expired record.
|
||||
private static UnknownLimitRecord current = DEFAULT;
|
||||
|
||||
/**
|
||||
* Create a new unknown record that resets at the specified time.
|
||||
*
|
||||
* @param resetEpochSeconds
|
||||
* the epoch second time when this record will expire.
|
||||
*/
|
||||
private UnknownLimitRecord(long resetEpochSeconds) {
|
||||
super(unknownLimit, unknownRemaining, resetEpochSeconds);
|
||||
}
|
||||
|
||||
static synchronized Record current() {
|
||||
if (current.isExpired()) {
|
||||
current = new UnknownLimitRecord(System.currentTimeMillis() / 1000L + unknownLimitResetSeconds);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the current UnknownLimitRecord. For use during testing only.
|
||||
*/
|
||||
static synchronized void reset() {
|
||||
current = DEFAULT;
|
||||
unknownLimitResetSeconds = defaultUnknownLimitResetSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,14 +384,12 @@ public class GHRateLimit {
|
||||
private final int remaining;
|
||||
|
||||
/**
|
||||
* Allotted API call per hour.
|
||||
* Allotted API call per time period.
|
||||
*/
|
||||
private final int limit;
|
||||
|
||||
/**
|
||||
* The time at which the current rate limit window resets in UTC epoch seconds.
|
||||
*
|
||||
* This is the raw value returned by the server.
|
||||
*/
|
||||
private final long resetEpochSeconds;
|
||||
|
||||
@@ -291,9 +399,11 @@ public class GHRateLimit {
|
||||
private final long createdAtEpochSeconds = System.currentTimeMillis() / 1000;
|
||||
|
||||
/**
|
||||
* The time at which the rate limit will reset. This value is calculated based on
|
||||
* {@link #getResetEpochSeconds()} by calling {@link #calculateResetDate}. If the clock on the local machine not
|
||||
* synchronized with the server clock, this time value will be adjusted to match the local machine's clock.
|
||||
* The date at which the rate limit will reset, adjusted to local machine time if the local machine's clock not
|
||||
* synchronized with to the same clock as the GitHub server.
|
||||
*
|
||||
* @see #calculateResetDate(String)
|
||||
* @see #getResetDate()
|
||||
*/
|
||||
@Nonnull
|
||||
private final Date resetDate;
|
||||
@@ -341,12 +451,58 @@ public class GHRateLimit {
|
||||
this.resetDate = calculateResetDate(updatedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current {@link Record} is outdated compared to another. Rate Limit dates are only accurate
|
||||
* to the second, so we look at other information in the record as well.
|
||||
*
|
||||
* {@link Record}s with earlier {@link #getResetEpochSeconds()} are replaced by those with later.
|
||||
* {@link Record}s with the same {@link #getResetEpochSeconds()} are replaced by those with less remaining
|
||||
* count.
|
||||
*
|
||||
* {@link UnknownLimitRecord}s compare with each other like regular {@link Record}s.
|
||||
*
|
||||
* {@link Record}s are replaced by {@link UnknownLimitRecord}s only when the current {@link Record} is expired
|
||||
* and the {@link UnknownLimitRecord} is not. Otherwise Regular {@link Record}s are not replaced by
|
||||
* {@link UnknownLimitRecord}s.
|
||||
*
|
||||
* Expiration is only considered after other checks, meaning expired records may sometimes be replaced by other
|
||||
* expired records.
|
||||
*
|
||||
* @param other
|
||||
* the other {@link Record}
|
||||
* @return the {@link Record} that is most current
|
||||
*/
|
||||
Record currentOrUpdated(@Nonnull Record other) {
|
||||
// This set of checks avoids most calls to isExpired()
|
||||
// Depends on UnknownLimitRecord.current() to prevent continuous updating of GHRateLimit rateLimit()
|
||||
if (getResetEpochSeconds() > other.getResetEpochSeconds()
|
||||
|| (getResetEpochSeconds() == other.getResetEpochSeconds()
|
||||
&& getRemaining() <= other.getRemaining())) {
|
||||
// If the current record has a later reset
|
||||
// or the current record has the same reset and fewer or same requests remaining
|
||||
// Then it is most recent
|
||||
return this;
|
||||
} else if (!(other instanceof UnknownLimitRecord)) {
|
||||
// If the above is not the case that means other has a later reset
|
||||
// or the same resent and fewer requests remaining.
|
||||
// If the other record is not an unknown record, the the other is more recent
|
||||
return other;
|
||||
} else if (this.isExpired() && !other.isExpired()) {
|
||||
// The other is an unknown record.
|
||||
// If the current record has expired and the other hasn't, return the other.
|
||||
return other;
|
||||
}
|
||||
|
||||
// If none of the above, the current record is most valid.
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculates the {@link #resetDate} relative to the local machine clock.
|
||||
* <p>
|
||||
* {@link RateLimitChecker}s and {@link RateLimitHandler}s use {@link #getResetDate()} to make decisions about
|
||||
* how long to wait for until for the rate limit to reset. That means that {@link #getResetDate()} needs to be
|
||||
* accurate to the local machine.
|
||||
* calculated based on the local machine clock.
|
||||
* </p>
|
||||
* <p>
|
||||
* When we say that the clock on two machines is "synchronized", we mean that the UTC time returned from
|
||||
@@ -415,7 +571,7 @@ public class GHRateLimit {
|
||||
* {@link #getResetDate()} or implement a {@link RateLimitChecker} instead.
|
||||
*
|
||||
* @return a long representing the time in epoch seconds when the rate limit will reset
|
||||
* @see #getResetDate() #getResetDate()
|
||||
* @see #getResetDate()
|
||||
*/
|
||||
public long getResetEpochSeconds() {
|
||||
return resetEpochSeconds;
|
||||
@@ -424,6 +580,8 @@ public class GHRateLimit {
|
||||
/**
|
||||
* Whether the rate limit reset date indicated by this instance is expired
|
||||
*
|
||||
* If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead.
|
||||
*
|
||||
* @return true if the rate limit reset date has passed. Otherwise false.
|
||||
*/
|
||||
public boolean isExpired() {
|
||||
@@ -431,8 +589,8 @@ public class GHRateLimit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date at which the rate limit will reset, adjusted to local machine time if the local machine's
|
||||
* clock not synchronized with to the same clock as the GitHub server.
|
||||
* The date at which the rate limit will reset, adjusted to local machine time if the local machine's clock not
|
||||
* synchronized with to the same clock as the GitHub server.
|
||||
*
|
||||
* If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -90,6 +91,78 @@ public class GHRef {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrive a ref of the given type for the current GitHub repository.
|
||||
*
|
||||
* @param repository
|
||||
* the repository to read from
|
||||
* @param refName
|
||||
* eg: heads/branch
|
||||
* @return refs matching the request type
|
||||
* @throws IOException
|
||||
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
|
||||
*/
|
||||
static GHRef read(GHRepository repository, String refName) throws IOException {
|
||||
// Also accept e.g. "refs/heads/branch" for consistency with createRef().
|
||||
if (refName.startsWith("refs/")) {
|
||||
refName = refName.replaceFirst("refs/", "");
|
||||
}
|
||||
|
||||
// We would expect this to use `git/ref/%s` but some versions of GHE seem to not support it
|
||||
// Instead use `git/refs/%s` and check the result actually matches the ref
|
||||
GHRef result = null;
|
||||
try {
|
||||
result = repository.root.createRequest()
|
||||
.withUrlPath(repository.getApiTailUrl(String.format("git/refs/%s", refName)))
|
||||
.fetch(GHRef.class)
|
||||
.wrap(repository.root);
|
||||
} catch (IOException e) {
|
||||
// If the parse exception is due to the above returning an array instead of a single ref
|
||||
// that means the individual ref did not exist. Handled by result check below.
|
||||
// Otherwise, rethrow.
|
||||
if (!(e.getCause() instanceof JsonMappingException)) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that the ref returned is the one requested
|
||||
// Used .endsWith(refName) instead of .equals("refs/" + refName) to workaround a GitBucket
|
||||
// issue where the "ref" field omits the "refs/" prefix. "endsWith()" is functionally
|
||||
// the same for this scenario - the server refs matching is prefix-based, so
|
||||
// a ref that ends with the correct string will always be the correct one.
|
||||
if (result == null || !result.getRef().endsWith(refName)) {
|
||||
throw new GHFileNotFoundException(String.format("git/refs/%s", refName)
|
||||
+ " {\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/git/refs/#get-a-reference\"}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all refs of the given type for the current GitHub repository.
|
||||
*
|
||||
* @param repository
|
||||
* the repository to read from
|
||||
* @param refType
|
||||
* the type of reg to search for e.g. <code>tags</code> or <code>commits</code>
|
||||
* @return paged iterable of all refs of the specified type
|
||||
* @throws IOException
|
||||
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
|
||||
*/
|
||||
static PagedIterable<GHRef> readMatching(GHRepository repository, String refType) throws IOException {
|
||||
if (refType.startsWith("refs/")) {
|
||||
refType = refType.replaceFirst("refs/", "");
|
||||
}
|
||||
|
||||
String url = repository.getApiTailUrl(String.format("git/refs/%s", refType));
|
||||
// if no types, do not end with slash just to be safe.
|
||||
if (refType.equals("")) {
|
||||
url = url.substring(0, url.length() - 1);
|
||||
}
|
||||
return repository.root.createRequest()
|
||||
.withUrlPath(url)
|
||||
.toIterable(GHRef[].class, item -> item.wrap(repository.root));
|
||||
}
|
||||
|
||||
/**
|
||||
* The type GHObject.
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,7 @@ import static java.lang.String.*;
|
||||
* Release in a github repository.
|
||||
*
|
||||
* @see GHRepository#getReleases() GHRepository#getReleases()
|
||||
* @see GHRepository#listReleases() () GHRepository#listReleases()
|
||||
* @see GHRepository#createRelease(String) GHRepository#createRelease(String)
|
||||
*/
|
||||
public class GHRelease extends GHObject {
|
||||
@@ -23,6 +24,7 @@ public class GHRelease extends GHObject {
|
||||
|
||||
private String html_url;
|
||||
private String assets_url;
|
||||
private List<GHAsset> assets;
|
||||
private String upload_url;
|
||||
private String tag_name;
|
||||
private String target_commitish;
|
||||
@@ -249,18 +251,45 @@ public class GHRelease extends GHObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets assets.
|
||||
* Get the cached assets.
|
||||
*
|
||||
* @return the assets
|
||||
*
|
||||
* @deprecated This should be the default behavior of {@link #getAssets()} in a future release. This method is
|
||||
* introduced in addition to enable a transition to using cached asset information while keeping the
|
||||
* existing logic in place for backwards compatibility.
|
||||
*/
|
||||
@Deprecated
|
||||
@Preview
|
||||
public List<GHAsset> assets() {
|
||||
return assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-fetch the assets of this release.
|
||||
*
|
||||
* @return the assets
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated The behavior of this method will change in a future release. It will then provide cached assets as
|
||||
* provided by {@link #assets()}. Use {@link #listAssets()} instead to fetch up-to-date information of
|
||||
* assets.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<GHAsset> getAssets() throws IOException {
|
||||
return listAssets().toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-fetch the assets of this release.
|
||||
*
|
||||
* @return the assets
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHAsset> getAssets() throws IOException {
|
||||
public PagedIterable<GHAsset> listAssets() throws IOException {
|
||||
Requester builder = owner.root.createRequest();
|
||||
|
||||
return builder.withUrlPath(getApiTailUrl("assets"))
|
||||
.toIterable(GHAsset[].class, item -> item.wrap(this))
|
||||
.toList();
|
||||
return builder.withUrlPath(getApiTailUrl("assets")).toIterable(GHAsset[].class, item -> item.wrap(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,6 +46,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -68,7 +69,9 @@ public class GHRepository extends GHObject {
|
||||
/* package almost final */ transient GitHub root;
|
||||
|
||||
private String nodeId, description, homepage, name, full_name;
|
||||
|
||||
private String html_url; // this is the UI
|
||||
|
||||
/*
|
||||
* The license information makes use of the preview API.
|
||||
*
|
||||
@@ -77,22 +80,30 @@ public class GHRepository extends GHObject {
|
||||
private GHLicense license;
|
||||
|
||||
private String git_url, ssh_url, clone_url, svn_url, mirror_url;
|
||||
|
||||
private GHUser owner; // not fully populated. beware.
|
||||
|
||||
private boolean has_issues, has_wiki, fork, has_downloads, has_pages, archived, has_projects;
|
||||
|
||||
private boolean allow_squash_merge;
|
||||
|
||||
private boolean allow_merge_commit;
|
||||
|
||||
private boolean allow_rebase_merge;
|
||||
|
||||
private boolean delete_branch_on_merge;
|
||||
|
||||
@JsonProperty("private")
|
||||
private boolean _private;
|
||||
|
||||
private int forks_count, stargazers_count, watchers_count, size, open_issues_count, subscribers_count;
|
||||
|
||||
private String pushed_at;
|
||||
|
||||
private Map<Integer, GHMilestone> milestones = new WeakHashMap<Integer, GHMilestone>();
|
||||
|
||||
private String default_branch, language;
|
||||
|
||||
private Map<String, GHCommit> commits = new WeakHashMap<String, GHCommit>();
|
||||
|
||||
@SkipFromToString
|
||||
@@ -100,6 +111,12 @@ public class GHRepository extends GHObject {
|
||||
|
||||
private GHRepository source, parent;
|
||||
|
||||
private Boolean isTemplate;
|
||||
|
||||
static GHRepository read(GitHub root, String owner, String name) throws IOException {
|
||||
return root.createRequest().withUrlPath("/repos/" + owner + '/' + name).fetch(GHRepository.class).wrap(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create deployment gh deployment builder.
|
||||
*
|
||||
@@ -681,6 +698,28 @@ public class GHRepository extends GHObject {
|
||||
return _private;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is template boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
@Deprecated
|
||||
@Preview
|
||||
public boolean isTemplate() {
|
||||
// isTemplate is still in preview, we do not want to retrieve it unless needed.
|
||||
if (isTemplate == null) {
|
||||
try {
|
||||
populate();
|
||||
} catch (IOException e) {
|
||||
// Convert this to a runtime exception to avoid messy method signature
|
||||
throw new GHException("Could not populate the template setting of the repository", e);
|
||||
}
|
||||
// if this somehow is not populated, set it to false;
|
||||
isTemplate = Boolean.TRUE.equals(isTemplate);
|
||||
}
|
||||
return isTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has downloads boolean.
|
||||
*
|
||||
@@ -970,12 +1009,12 @@ public class GHRepository extends GHObject {
|
||||
@NonNull String method,
|
||||
@CheckForNull GHOrganization.Permission permission) throws IOException {
|
||||
Requester requester = root.createRequest().method(method);
|
||||
|
||||
if (permission != null) {
|
||||
requester = requester.with("permission", permission).inBody();
|
||||
}
|
||||
|
||||
for (GHUser user : users) {
|
||||
// Make sure that the users collection doesn't have any duplicates
|
||||
for (GHUser user : new LinkedHashSet<GHUser>(users)) {
|
||||
requester.withUrlPath(getApiTailUrl("collaborators/" + user.getLogin())).send();
|
||||
}
|
||||
}
|
||||
@@ -1002,8 +1041,9 @@ public class GHRepository extends GHObject {
|
||||
|
||||
private void edit(String key, String value) throws IOException {
|
||||
Requester requester = root.createRequest();
|
||||
if (!key.equals("name"))
|
||||
if (!key.equals("name")) {
|
||||
requester.with("name", name); // even when we don't change the name, we need to send it in
|
||||
}
|
||||
requester.with(key, value).method("PATCH").withUrlPath(getApiTailUrl("")).send();
|
||||
}
|
||||
|
||||
@@ -1248,8 +1288,9 @@ public class GHRepository extends GHObject {
|
||||
// this API is asynchronous. we need to wait for a bit
|
||||
for (int i = 0; i < 10; i++) {
|
||||
GHRepository r = root.getMyself().getRepository(name);
|
||||
if (r != null)
|
||||
if (r != null) {
|
||||
return r;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
@@ -1278,8 +1319,9 @@ public class GHRepository extends GHObject {
|
||||
// this API is asynchronous. we need to wait for a bit
|
||||
for (int i = 0; i < 10; i++) {
|
||||
GHRepository r = org.getRepository(name);
|
||||
if (r != null)
|
||||
if (r != null) {
|
||||
return r;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
@@ -1540,8 +1582,7 @@ public class GHRepository extends GHObject {
|
||||
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
|
||||
*/
|
||||
public PagedIterable<GHRef> listRefs() throws IOException {
|
||||
final String url = String.format("/repos/%s/%s/git/refs", getOwnerName(), name);
|
||||
return root.createRequest().withUrlPath(url).toIterable(GHRef[].class, item -> item.wrap(root));
|
||||
return listRefs("");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1567,11 +1608,7 @@ public class GHRepository extends GHObject {
|
||||
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
|
||||
*/
|
||||
public PagedIterable<GHRef> listRefs(String refType) throws IOException {
|
||||
if (refType.startsWith("refs/")) {
|
||||
refType = refType.replaceFirst("refs/", "");
|
||||
}
|
||||
final String url = String.format("/repos/%s/%s/git/refs/%s", getOwnerName(), name, refType);
|
||||
return root.createRequest().withUrlPath(url).toIterable(GHRef[].class, item -> item.wrap(root));
|
||||
return GHRef.readMatching(this, refType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1584,15 +1621,7 @@ public class GHRepository extends GHObject {
|
||||
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
|
||||
*/
|
||||
public GHRef getRef(String refName) throws IOException {
|
||||
// Also accept e.g. "refs/heads/branch" for consistency with createRef().
|
||||
if (refName.startsWith("refs/")) {
|
||||
refName = refName.replaceFirst("refs/", "");
|
||||
}
|
||||
|
||||
return root.createRequest()
|
||||
.withUrlPath(getApiTailUrl(String.format("git/ref/%s", refName)))
|
||||
.fetch(GHRef.class)
|
||||
.wrap(root);
|
||||
return GHRef.read(this, refName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1759,6 +1788,20 @@ public class GHRepository extends GHObject {
|
||||
.toIterable(GHCommitComment[].class, item -> item.wrap(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all comments on a specific commit.
|
||||
*
|
||||
* @param commitSha
|
||||
* the hash of the commit
|
||||
*
|
||||
* @return the paged iterable
|
||||
*/
|
||||
public PagedIterable<GHCommitComment> listCommitComments(String commitSha) {
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/repos/%s/%s/commits/%s/comments", getOwnerName(), name, commitSha))
|
||||
.toIterable(GHCommitComment[].class, item -> item.wrap(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the basic license details for the repository.
|
||||
* <p>
|
||||
@@ -1915,6 +1958,19 @@ public class GHRepository extends GHObject {
|
||||
return new GHCheckRunBuilder(this, name, headSHA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing check run.
|
||||
*
|
||||
* @param checkId
|
||||
* the existing checkId
|
||||
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public @NonNull GHCheckRunBuilder updateCheckRun(long checkId) {
|
||||
return new GHCheckRunBuilder(this, checkId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists repository events.
|
||||
*
|
||||
@@ -2734,8 +2790,9 @@ public class GHRepository extends GHObject {
|
||||
}
|
||||
|
||||
String getApiTailUrl(String tail) {
|
||||
if (tail.length() > 0 && !tail.startsWith("/"))
|
||||
if (tail.length() > 0 && !tail.startsWith("/")) {
|
||||
tail = '/' + tail;
|
||||
}
|
||||
return "/repos/" + getOwnerName() + "/" + name + tail;
|
||||
}
|
||||
|
||||
@@ -2842,8 +2899,9 @@ public class GHRepository extends GHObject {
|
||||
* The IO exception
|
||||
*/
|
||||
void populate() throws IOException {
|
||||
if (root.isOffline())
|
||||
if (root.isOffline()) {
|
||||
return; // can't populate if the root is offline
|
||||
}
|
||||
|
||||
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
|
||||
|
||||
@@ -2852,10 +2910,10 @@ public class GHRepository extends GHObject {
|
||||
// There is bug in Push event payloads that returns the wrong url.
|
||||
// All other occurrences of "url" take the form "https://api.github.com/...".
|
||||
// For Push event repository records, they take the form "https://github.com/{fullName}".
|
||||
root.createRequest().setRawUrlPath(url.toString()).fetchInto(this).wrap(root);
|
||||
root.createRequest().withPreview(BAPTISE).setRawUrlPath(url.toString()).fetchInto(this).wrap(root);
|
||||
} catch (HttpException e) {
|
||||
if (e.getCause() instanceof JsonParseException) {
|
||||
root.createRequest().withUrlPath("/repos/" + full_name).fetchInto(this).wrap(root);
|
||||
root.createRequest().withPreview(BAPTISE).withUrlPath("/repos/" + full_name).fetchInto(this).wrap(root);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public abstract class GHSearchBuilder<T> extends GHQueryBuilder<T> {
|
||||
super(root);
|
||||
this.receiverType = receiverType;
|
||||
req.withUrlPath(getApiUrl());
|
||||
req.rateLimit(RateLimitTarget.SEARCH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -145,6 +145,22 @@ public class GHTeam extends GHObject implements Refreshable {
|
||||
return GHDiscussion.readAll(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* List members with specified role paged iterable.
|
||||
*
|
||||
* @param role
|
||||
* the role
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHUser> listMembers(String role) throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(api("/members"))
|
||||
.with("role", role)
|
||||
.toIterable(GHUser[].class, item -> item.wrapUp(root));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single discussion by ID.
|
||||
*
|
||||
@@ -171,7 +187,20 @@ public class GHTeam extends GHObject implements Refreshable {
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHUser> listMembers() throws IOException {
|
||||
return root.createRequest().withUrlPath(api("/members")).toIterable(GHUser[].class, item -> item.wrapUp(root));
|
||||
return listMembers("all");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the teams that are children of this team.
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHTeam> listChildTeams() throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(api("/teams"))
|
||||
.toIterable(GHTeam[].class, item -> item.wrapUp(this.organization));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,7 +75,7 @@ public class GHTeamBuilder {
|
||||
* parentTeamId of team
|
||||
* @return a builder to continue with building
|
||||
*/
|
||||
public GHTeamBuilder parentTeamId(int parentTeamId) {
|
||||
public GHTeamBuilder parentTeamId(long parentTeamId) {
|
||||
this.builder.with("parent_team_id", parentTeamId);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -373,12 +373,20 @@ public class GitHub {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current rate limit.
|
||||
* Gets the current full rate limit information from the server.
|
||||
*
|
||||
* For some versions of GitHub Enterprise, the {@code /rate_limit} endpoint returns a {@code 404 Not Found}. In that
|
||||
* case, the most recent {@link GHRateLimit} information will be returned, including rate limit information returned
|
||||
* in the response header for this request in if was present.
|
||||
*
|
||||
* For most use cases it would be better to implement a {@link RateLimitChecker} and add it via
|
||||
* {@link GitHubBuilder#withRateLimitChecker(RateLimitChecker)}.
|
||||
*
|
||||
* @return the rate limit
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Nonnull
|
||||
public GHRateLimit getRateLimit() throws IOException {
|
||||
return client.getRateLimit();
|
||||
}
|
||||
@@ -388,8 +396,11 @@ public class GitHub {
|
||||
* GitHub Enterprise) or if no requests have been made.
|
||||
*
|
||||
* @return the most recently observed rate limit data or {@code null}.
|
||||
* @deprecated implement a {@link RateLimitChecker} and add it via
|
||||
* {@link GitHubBuilder#withRateLimitChecker(RateLimitChecker)}.
|
||||
*/
|
||||
@CheckForNull
|
||||
@Nonnull
|
||||
@Deprecated
|
||||
public GHRateLimit lastRateLimit() {
|
||||
return client.lastRateLimit();
|
||||
}
|
||||
@@ -400,10 +411,13 @@ public class GitHub {
|
||||
* @return the current rate limit data.
|
||||
* @throws IOException
|
||||
* if we couldn't get the current rate limit data.
|
||||
* @deprecated implement a {@link RateLimitChecker} and add it via
|
||||
* {@link GitHubBuilder#withRateLimitChecker(RateLimitChecker)}.
|
||||
*/
|
||||
@Nonnull
|
||||
@Deprecated
|
||||
public GHRateLimit rateLimit() throws IOException {
|
||||
return client.rateLimit();
|
||||
return client.rateLimit(RateLimitTarget.CORE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -518,7 +532,7 @@ public class GitHub {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the repository object from 'user/reponame' string that GitHub calls as "repository name"
|
||||
* Gets the repository object from 'owner/repo' string that GitHub calls as "repository name"
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
@@ -529,9 +543,10 @@ public class GitHub {
|
||||
*/
|
||||
public GHRepository getRepository(String name) throws IOException {
|
||||
String[] tokens = name.split("/");
|
||||
return createRequest().withUrlPath("/repos/" + tokens[0] + '/' + tokens[1])
|
||||
.fetch(GHRepository.class)
|
||||
.wrap(this);
|
||||
if (tokens.length < 2) {
|
||||
throw new IllegalArgumentException("Repository name must be in format owner/repo");
|
||||
}
|
||||
return GHRepository.read(this, tokens[0], tokens[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -358,6 +358,18 @@ public class GitHubBuilder implements Cloneable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link RateLimitChecker} for the Core API for this {@link GitHubBuilder}.
|
||||
*
|
||||
* @param coreRateLimitChecker
|
||||
* the {@link RateLimitChecker} for core GitHub API requests
|
||||
* @return the git hub builder
|
||||
* @see #withRateLimitChecker(RateLimitChecker, RateLimitTarget)
|
||||
*/
|
||||
public GitHubBuilder withRateLimitChecker(@Nonnull RateLimitChecker coreRateLimitChecker) {
|
||||
return withRateLimitChecker(coreRateLimitChecker, RateLimitTarget.CORE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link RateLimitChecker} to this {@link GitHubBuilder}.
|
||||
* <p>
|
||||
@@ -376,15 +388,15 @@ public class GitHubBuilder implements Cloneable {
|
||||
* request.
|
||||
* </p>
|
||||
*
|
||||
* @param coreRateLimitChecker
|
||||
* the {@link RateLimitChecker} for core GitHub API requests
|
||||
* @param rateLimitChecker
|
||||
* the {@link RateLimitChecker} for requests
|
||||
* @param rateLimitTarget
|
||||
* the {@link RateLimitTarget} specifying which rate limit record to check
|
||||
* @return the git hub builder
|
||||
*/
|
||||
public GitHubBuilder withRateLimitChecker(@Nonnull RateLimitChecker coreRateLimitChecker) {
|
||||
this.rateLimitChecker = new GitHubRateLimitChecker(coreRateLimitChecker,
|
||||
RateLimitChecker.NONE,
|
||||
RateLimitChecker.NONE,
|
||||
RateLimitChecker.NONE);
|
||||
public GitHubBuilder withRateLimitChecker(@Nonnull RateLimitChecker rateLimitChecker,
|
||||
@Nonnull RateLimitTarget rateLimitTarget) {
|
||||
this.rateLimitChecker = this.rateLimitChecker.with(rateLimitChecker, rateLimitTarget);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||
import com.fasterxml.jackson.databind.introspect.VisibilityChecker;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@@ -19,15 +19,15 @@ import java.net.SocketException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TimeZone;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -44,7 +44,7 @@ import static java.util.logging.Level.*;
|
||||
* A GitHub API Client
|
||||
* <p>
|
||||
* A GitHubClient can be used to send requests and retrieve their responses. GitHubClient is thread-safe and can be used
|
||||
* to send multiple requests. GitHubClient also track some GitHub API information such as {@link #rateLimit()}.
|
||||
* to send multiple requests. GitHubClient also track some GitHub API information such as {@link GHRateLimit}.
|
||||
* </p>
|
||||
*/
|
||||
abstract class GitHubClient {
|
||||
@@ -70,18 +70,18 @@ abstract class GitHubClient {
|
||||
|
||||
private HttpConnector connector;
|
||||
|
||||
private final Object headerRateLimitLock = new Object();
|
||||
private GHRateLimit headerRateLimit = null;
|
||||
private volatile GHRateLimit rateLimit = null;
|
||||
private final Object rateLimitLock = new Object();
|
||||
|
||||
@Nonnull
|
||||
private GHRateLimit rateLimit = GHRateLimit.DEFAULT;
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(GitHubClient.class.getName());
|
||||
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
static final String GITHUB_URL = "https://api.github.com";
|
||||
|
||||
private static final String[] TIME_FORMATS = { "yyyy/MM/dd HH:mm:ss ZZZZ", "yyyy-MM-dd'T'HH:mm:ss'Z'",
|
||||
"yyyy-MM-dd'T'HH:mm:ss.S'Z'" // GitHub App endpoints return a different date format
|
||||
};
|
||||
private static final DateTimeFormatter DATE_TIME_PARSER_SLASHES = DateTimeFormatter
|
||||
.ofPattern("yyyy/MM/dd HH:mm:ss Z");
|
||||
|
||||
static {
|
||||
MAPPER.setVisibility(new VisibilityChecker.Std(NONE, NONE, NONE, NONE, ANY));
|
||||
@@ -141,10 +141,8 @@ abstract class GitHubClient {
|
||||
}
|
||||
|
||||
private <T> T fetch(Class<T> type, String urlPath) throws IOException {
|
||||
return this
|
||||
.sendRequest(GitHubRequest.newBuilder().withApiUrl(getApiUrl()).withUrlPath(urlPath).build(),
|
||||
(responseInfo) -> GitHubResponse.parseBody(responseInfo, type))
|
||||
.body();
|
||||
GitHubRequest request = GitHubRequest.newBuilder().withApiUrl(getApiUrl()).withUrlPath(urlPath).build();
|
||||
return this.sendRequest(request, (responseInfo) -> GitHubResponse.parseBody(responseInfo, type)).body();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,11 +206,14 @@ abstract class GitHubClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current rate limit from the server.
|
||||
* Gets the current full rate limit information from the server.
|
||||
*
|
||||
* For some versions of GitHub Enterprise, the {@code /rate_limit} endpoint returns a {@code 404 Not Found}. In
|
||||
* that, if {@link #lastRateLimit()} is not {@code null} and is not expired, it will be returned. Otherwise, a
|
||||
* placeholder {@link GHRateLimit} instance with {@link GHRateLimit.UnknownLimitRecord}s will be returned.
|
||||
* For some versions of GitHub Enterprise, the {@code /rate_limit} endpoint returns a {@code 404 Not Found}. In that
|
||||
* case, the most recent {@link GHRateLimit} information will be returned, including rate limit information returned
|
||||
* in the response header for this request in if was present.
|
||||
*
|
||||
* For most use cases it would be better to implement a {@link RateLimitChecker} and add it via
|
||||
* {@link GitHubBuilder#withRateLimitChecker(RateLimitChecker)}.
|
||||
*
|
||||
* @return the rate limit
|
||||
* @throws IOException
|
||||
@@ -220,59 +221,95 @@ abstract class GitHubClient {
|
||||
*/
|
||||
@Nonnull
|
||||
public GHRateLimit getRateLimit() throws IOException {
|
||||
return getRateLimit(RateLimitTarget.NONE);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
GHRateLimit getRateLimit(@Nonnull RateLimitTarget rateLimitTarget) throws IOException {
|
||||
GHRateLimit result;
|
||||
try {
|
||||
result = fetch(JsonRateLimit.class, "/rate_limit").resources;
|
||||
GitHubRequest request = GitHubRequest.newBuilder()
|
||||
.rateLimit(RateLimitTarget.NONE)
|
||||
.withApiUrl(getApiUrl())
|
||||
.withUrlPath("/rate_limit")
|
||||
.build();
|
||||
result = this
|
||||
.sendRequest(request, (responseInfo) -> GitHubResponse.parseBody(responseInfo, JsonRateLimit.class))
|
||||
.body().resources;
|
||||
} catch (FileNotFoundException e) {
|
||||
// For some versions of GitHub Enterprise, the rate_limit endpoint returns a 404.
|
||||
LOGGER.log(FINE, "/rate_limit returned 404 Not Found.");
|
||||
|
||||
// However some newer versions of GHE include rate limit header information
|
||||
// Use that if available
|
||||
result = lastRateLimit();
|
||||
if (result == null || result.isExpired()) {
|
||||
// return a default rate limit
|
||||
result = GHRateLimit.Unknown();
|
||||
}
|
||||
// If the header info is missing and the endpoint returns 404, fill the rate limit
|
||||
// with unknown
|
||||
result = GHRateLimit.fromRecord(GHRateLimit.UnknownLimitRecord.current(), rateLimitTarget);
|
||||
}
|
||||
|
||||
return rateLimit = result;
|
||||
return updateRateLimit(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the most recently observed rate limit data or {@code null} if either there is no rate limit (for example
|
||||
* GitHub Enterprise) or if no requests have been made.
|
||||
* Returns the most recently observed rate limit data.
|
||||
*
|
||||
* @return the most recently observed rate limit data or {@code null}.
|
||||
* Generally, instead of calling this you should implement a {@link RateLimitChecker} or call
|
||||
*
|
||||
* @return the most recently observed rate limit data. This may include expired or
|
||||
* {@link GHRateLimit.UnknownLimitRecord} entries.
|
||||
* @deprecated implement a {@link RateLimitChecker} and add it via
|
||||
* {@link GitHubBuilder#withRateLimitChecker(RateLimitChecker)}.
|
||||
*/
|
||||
@CheckForNull
|
||||
public GHRateLimit lastRateLimit() {
|
||||
synchronized (headerRateLimitLock) {
|
||||
return headerRateLimit;
|
||||
@Nonnull
|
||||
@Deprecated
|
||||
GHRateLimit lastRateLimit() {
|
||||
synchronized (rateLimitLock) {
|
||||
return rateLimit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current rate limit while trying not to actually make any remote requests unless absolutely necessary.
|
||||
* Gets the current rate limit for an endpoint while trying not to actually make any remote requests unless
|
||||
* absolutely necessary.
|
||||
*
|
||||
* If {@link #lastRateLimit()} is not {@code null} and is not expired, it will be returned. If the information
|
||||
* returned from the last call to {@link #getRateLimit()} is not {@code null} and is not expired, then it will be
|
||||
* returned. Otherwise, the result of a call to {@link #getRateLimit()} will be returned.
|
||||
* If the {@link GHRateLimit.Record} for {@code urlPath} is not expired, it is returned. If the
|
||||
* {@link GHRateLimit.Record} for {@code urlPath} is expired, {@link #getRateLimit()} will be called to get the
|
||||
* current rate limit.
|
||||
*
|
||||
* @return the current rate limit data.
|
||||
* @param rateLimitTarget
|
||||
* the endpoint to get the rate limit for.
|
||||
*
|
||||
* @return the current rate limit data. {@link GHRateLimit.Record}s in this instance may be expired when returned.
|
||||
* @throws IOException
|
||||
* if there was an error getting current rate limit data.
|
||||
*/
|
||||
@Nonnull
|
||||
public GHRateLimit rateLimit() throws IOException {
|
||||
synchronized (headerRateLimitLock) {
|
||||
if (headerRateLimit != null && !headerRateLimit.isExpired()) {
|
||||
return headerRateLimit;
|
||||
GHRateLimit rateLimit(@Nonnull RateLimitTarget rateLimitTarget) throws IOException {
|
||||
synchronized (rateLimitLock) {
|
||||
if (rateLimit.getRecord(rateLimitTarget).isExpired()) {
|
||||
getRateLimit(rateLimitTarget);
|
||||
}
|
||||
return rateLimit;
|
||||
}
|
||||
GHRateLimit result = this.rateLimit;
|
||||
if (result == null || result.isExpired()) {
|
||||
result = getRateLimit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Rate Limit with the latest info from response header.
|
||||
*
|
||||
* Due to multi-threading, requests might complete out of order. This method calls
|
||||
* {@link GHRateLimit#getMergedRateLimit(GHRateLimit)} to ensure the most current records are used.
|
||||
*
|
||||
* @param observed
|
||||
* {@link GHRateLimit.Record} constructed from the response header information
|
||||
*/
|
||||
private GHRateLimit updateRateLimit(@Nonnull GHRateLimit observed) {
|
||||
synchronized (rateLimitLock) {
|
||||
observed = rateLimit.getMergedRateLimit(observed);
|
||||
|
||||
if (rateLimit != observed) {
|
||||
rateLimit = observed;
|
||||
LOGGER.log(FINE, "Rate limit now: {0}", rateLimit);
|
||||
}
|
||||
return rateLimit;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -351,39 +388,43 @@ abstract class GitHubClient {
|
||||
|
||||
GitHubResponse.ResponseInfo responseInfo = null;
|
||||
try {
|
||||
if (LOGGER.isLoggable(FINE)) {
|
||||
LOGGER.log(FINE,
|
||||
"GitHub API request [" + (login == null ? "anonymous" : login) + "]: " + request.method()
|
||||
+ " " + request.url().toString());
|
||||
try {
|
||||
if (LOGGER.isLoggable(FINE)) {
|
||||
LOGGER.log(FINE,
|
||||
"GitHub API request [" + (login == null ? "anonymous" : login) + "]: "
|
||||
+ request.method() + " " + request.url().toString());
|
||||
}
|
||||
|
||||
rateLimitChecker.checkRateLimit(this, request);
|
||||
|
||||
responseInfo = getResponseInfo(request);
|
||||
noteRateLimit(responseInfo);
|
||||
detectOTPRequired(responseInfo);
|
||||
|
||||
if (isInvalidCached404Response(responseInfo)) {
|
||||
// Setting "Cache-Control" to "no-cache" stops the cache from supplying
|
||||
// "If-Modified-Since" or "If-None-Match" values.
|
||||
// This makes GitHub give us current data (not incorrectly cached data)
|
||||
request = request.toBuilder().setHeader("Cache-Control", "no-cache").build();
|
||||
continue;
|
||||
}
|
||||
if (!(isRateLimitResponse(responseInfo) || isAbuseLimitResponse(responseInfo))) {
|
||||
return createResponse(responseInfo, handler);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// For transient errors, retry
|
||||
if (retryConnectionError(e, request.url(), retries)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
throw interpretApiError(e, request, responseInfo);
|
||||
}
|
||||
|
||||
rateLimitChecker.checkRateLimit(this, request);
|
||||
|
||||
responseInfo = getResponseInfo(request);
|
||||
noteRateLimit(responseInfo);
|
||||
detectOTPRequired(responseInfo);
|
||||
|
||||
if (isInvalidCached404Response(responseInfo)) {
|
||||
// Setting "Cache-Control" to "no-cache" stops the cache from supplying
|
||||
// "If-Modified-Since" or "If-None-Match" values.
|
||||
// This makes GitHub give us current data (not incorrectly cached data)
|
||||
request = request.toBuilder().withHeader("Cache-Control", "no-cache").build();
|
||||
continue;
|
||||
}
|
||||
if (!(isRateLimitResponse(responseInfo) || isAbuseLimitResponse(responseInfo))) {
|
||||
return createResponse(responseInfo, handler);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// For transient errors, retry
|
||||
if (retryConnectionError(e, request.url(), retries)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
throw interpretApiError(e, request, responseInfo);
|
||||
handleLimitingErrors(responseInfo);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(responseInfo);
|
||||
}
|
||||
|
||||
handleLimitingErrors(responseInfo);
|
||||
|
||||
} while (--retries >= 0);
|
||||
|
||||
throw new GHIOException("Ran out of retries for URL: " + request.url().toString());
|
||||
@@ -512,58 +553,25 @@ abstract class GitHubClient {
|
||||
}
|
||||
|
||||
private void noteRateLimit(@Nonnull GitHubResponse.ResponseInfo responseInfo) {
|
||||
if (responseInfo.request().urlPath().startsWith("/search")) {
|
||||
// the search API uses a different rate limit
|
||||
return;
|
||||
}
|
||||
|
||||
String limitString = responseInfo.headerField("X-RateLimit-Limit");
|
||||
if (StringUtils.isBlank(limitString)) {
|
||||
// if we are missing a header, return fast
|
||||
return;
|
||||
}
|
||||
String remainingString = responseInfo.headerField("X-RateLimit-Remaining");
|
||||
if (StringUtils.isBlank(remainingString)) {
|
||||
// if we are missing a header, return fast
|
||||
return;
|
||||
}
|
||||
String resetString = responseInfo.headerField("X-RateLimit-Reset");
|
||||
if (StringUtils.isBlank(resetString)) {
|
||||
// if we are missing a header, return fast
|
||||
return;
|
||||
}
|
||||
|
||||
int limit, remaining;
|
||||
long reset;
|
||||
try {
|
||||
String limitString = Objects.requireNonNull(responseInfo.headerField("X-RateLimit-Limit"),
|
||||
"Missing X-RateLimit-Limit");
|
||||
String remainingString = Objects.requireNonNull(responseInfo.headerField("X-RateLimit-Remaining"),
|
||||
"Missing X-RateLimit-Remaining");
|
||||
String resetString = Objects.requireNonNull(responseInfo.headerField("X-RateLimit-Reset"),
|
||||
"Missing X-RateLimit-Reset");
|
||||
int limit, remaining;
|
||||
long reset;
|
||||
limit = Integer.parseInt(limitString);
|
||||
} catch (NumberFormatException e) {
|
||||
if (LOGGER.isLoggable(FINEST)) {
|
||||
LOGGER.log(FINEST, "Malformed X-RateLimit-Limit header value " + limitString, e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
remaining = Integer.parseInt(remainingString);
|
||||
} catch (NumberFormatException e) {
|
||||
if (LOGGER.isLoggable(FINEST)) {
|
||||
LOGGER.log(FINEST, "Malformed X-RateLimit-Remaining header value " + remainingString, e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
reset = Long.parseLong(resetString);
|
||||
} catch (NumberFormatException e) {
|
||||
GHRateLimit.Record observed = new GHRateLimit.Record(limit, remaining, reset, responseInfo);
|
||||
updateRateLimit(GHRateLimit.fromRecord(observed, responseInfo.request().rateLimitTarget()));
|
||||
} catch (NumberFormatException | NullPointerException e) {
|
||||
if (LOGGER.isLoggable(FINEST)) {
|
||||
LOGGER.log(FINEST, "Malformed X-RateLimit-Reset header value " + resetString, e);
|
||||
LOGGER.log(FINEST, "Missing or malformed X-RateLimit header: ", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
GHRateLimit.Record observed = new GHRateLimit.Record(limit, remaining, reset, responseInfo);
|
||||
|
||||
updateCoreRateLimit(observed);
|
||||
}
|
||||
|
||||
private static void detectOTPRequired(@Nonnull GitHubResponse.ResponseInfo responseInfo) throws GHIOException {
|
||||
@@ -583,23 +591,6 @@ abstract class GitHubClient {
|
||||
"This operation requires a credential but none is given to the GitHub constructor");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Rate Limit with the latest info from response header. Due to multi-threading requests might complete
|
||||
* out of order, we want to pick the one with the most recent info from the server. Calls
|
||||
* {@link #shouldReplace(GHRateLimit.Record, GHRateLimit.Record)}
|
||||
*
|
||||
* @param observed
|
||||
* {@link GHRateLimit.Record} constructed from the response header information
|
||||
*/
|
||||
private void updateCoreRateLimit(@Nonnull GHRateLimit.Record observed) {
|
||||
synchronized (headerRateLimitLock) {
|
||||
if (headerRateLimit == null || shouldReplace(observed, headerRateLimit.getCore())) {
|
||||
headerRateLimit = GHRateLimit.fromHeaderRecord(observed);
|
||||
LOGGER.log(FINE, "Rate limit now: {0}", headerRateLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class GHApiInfo {
|
||||
private String rate_limit_url;
|
||||
|
||||
@@ -649,37 +640,6 @@ abstract class GitHubClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if one {@link GHRateLimit.Record} should replace another. Header date is only accurate to the second,
|
||||
* so we look at the information in the record itself.
|
||||
*
|
||||
* {@link GHRateLimit.UnknownLimitRecord}s are always replaced by regular {@link GHRateLimit.Record}s. Regular
|
||||
* {@link GHRateLimit.Record}s are never replaced by {@link GHRateLimit.UnknownLimitRecord}s. Candidates with
|
||||
* resetEpochSeconds later than current record are more recent. Candidates with the same reset and a lower remaining
|
||||
* count are more recent. Candidates with an earlier reset are older.
|
||||
*
|
||||
* @param candidate
|
||||
* {@link GHRateLimit.Record} constructed from the response header information
|
||||
* @param current
|
||||
* the current {@link GHRateLimit.Record} record
|
||||
*/
|
||||
static boolean shouldReplace(@Nonnull GHRateLimit.Record candidate, @Nonnull GHRateLimit.Record current) {
|
||||
if (candidate instanceof GHRateLimit.UnknownLimitRecord
|
||||
&& !(current instanceof GHRateLimit.UnknownLimitRecord)) {
|
||||
// Unknown candidate never replaces a regular record
|
||||
return false;
|
||||
} else if (current instanceof GHRateLimit.UnknownLimitRecord
|
||||
&& !(candidate instanceof GHRateLimit.UnknownLimitRecord)) {
|
||||
// Any real record should replace an unknown Record.
|
||||
return true;
|
||||
} else {
|
||||
// records of the same type compare to each other as normal.
|
||||
return current.getResetEpochSeconds() < candidate.getResetEpochSeconds()
|
||||
|| (current.getResetEpochSeconds() == candidate.getResetEpochSeconds()
|
||||
&& current.getRemaining() > candidate.getRemaining());
|
||||
}
|
||||
}
|
||||
|
||||
static URL parseURL(String s) {
|
||||
try {
|
||||
return s == null ? null : new URL(s);
|
||||
@@ -691,22 +651,24 @@ abstract class GitHubClient {
|
||||
static Date parseDate(String timestamp) {
|
||||
if (timestamp == null)
|
||||
return null;
|
||||
for (String f : TIME_FORMATS) {
|
||||
try {
|
||||
SimpleDateFormat df = new SimpleDateFormat(f);
|
||||
df.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
return df.parse(timestamp);
|
||||
} catch (ParseException e) {
|
||||
// try next
|
||||
}
|
||||
|
||||
return Date.from(parseInstant(timestamp));
|
||||
}
|
||||
|
||||
static Instant parseInstant(String timestamp) {
|
||||
if (timestamp == null)
|
||||
return null;
|
||||
|
||||
if (timestamp.charAt(4) == '/') {
|
||||
// Unsure where this is used, but retained for compatibility.
|
||||
return Instant.from(DATE_TIME_PARSER_SLASHES.parse(timestamp));
|
||||
} else {
|
||||
return Instant.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(timestamp));
|
||||
}
|
||||
throw new IllegalStateException("Unable to parse the timestamp: " + timestamp);
|
||||
}
|
||||
|
||||
static String printDate(Date dt) {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
df.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
return df.format(dt);
|
||||
return DateTimeFormatter.ISO_INSTANT.format(Instant.ofEpochMilli(dt.getTime()).truncatedTo(ChronoUnit.SECONDS));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@ import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
* A GitHub API Client for HttpUrlConnection
|
||||
* <p>
|
||||
* A GitHubClient can be used to send requests and retrieve their responses. GitHubClient is thread-safe and can be used
|
||||
* to send multiple requests. GitHubClient also track some GitHub API information such as {@link #rateLimit()}.
|
||||
* to send multiple requests. GitHubClient also track some GitHub API information such as {@link GHRateLimit}.
|
||||
* </p>
|
||||
* <p>
|
||||
* GitHubHttpUrlConnectionClient gets a new {@link HttpURLConnection} for each call to send.
|
||||
@@ -235,6 +235,10 @@ class GitHubHttpUrlConnectionClient extends GitHubClient {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(GitHubClient.class.getName());
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
IOUtils.closeQuietly(connection.getInputStream());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,26 +3,28 @@ package org.kohsuke.github;
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* A GitHub API Rate Limit Checker called before each request. This class provides the basic infrastructure for calling
|
||||
* the appropriate {@link RateLimitChecker} for a request and retrying as many times as needed. This class supports more
|
||||
* complex throttling strategies and polling, but leaves the specifics to the {@link RateLimitChecker} implementations.
|
||||
* A GitHub API Rate Limit Checker called before each request.
|
||||
*
|
||||
* <p>
|
||||
* GitHub allots a certain number of requests to each user or application per period of time (usually per hour). The
|
||||
* number of requests remaining is returned in the response header and can also be requested using
|
||||
* {@link GitHub#getRateLimit()}. This requests per interval is referred to as the "rate limit".
|
||||
* GitHub allots a certain number of requests to each user or application per period of time. The number of requests
|
||||
* remaining and the time when the number will be reset is returned in the response header and can also be requested
|
||||
* using {@link GitHub#getRateLimit()}. The "requests per interval" is referred to as the "rate limit".
|
||||
* </p>
|
||||
* <p>
|
||||
* GitHub prefers that clients stop before exceeding their rate limit rather than stopping after they exceed it. The
|
||||
* {@link RateLimitChecker} is called before each request to check the rate limit and wait if the checker criteria are
|
||||
* met.
|
||||
* Different parts of the GitHub API have separate rate limits, but most of REST API uses {@link RateLimitTarget#CORE}.
|
||||
* Checking your rate limit using {@link GitHub#getRateLimit()} does not effect your rate limit. GitHub prefers that
|
||||
* clients stop before exceeding their rate limit rather than stopping after they exceed it.
|
||||
* </p>
|
||||
* <p>
|
||||
* Checking your rate limit using {@link GitHub#getRateLimit()} does not effect your rate limit, but each {@link GitHub}
|
||||
* instance will attempt to cache and reuse the last see rate limit rather than making a new request.
|
||||
* This class provides the infrastructure for calling the appropriate {@link RateLimitChecker} before each request and
|
||||
* retrying than call many times as needed. Each {@link RateLimitChecker} decides whether to wait and for how long. This
|
||||
* allows for a wide range of {@link RateLimitChecker} implementations, including complex throttling strategies and
|
||||
* polling.
|
||||
* </p>
|
||||
*/
|
||||
class GitHubRateLimitChecker {
|
||||
@@ -39,6 +41,8 @@ class GitHubRateLimitChecker {
|
||||
@Nonnull
|
||||
private final RateLimitChecker integrationManifest;
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(GitHubRateLimitChecker.class.getName());
|
||||
|
||||
GitHubRateLimitChecker() {
|
||||
this(RateLimitChecker.NONE, RateLimitChecker.NONE, RateLimitChecker.NONE, RateLimitChecker.NONE);
|
||||
}
|
||||
@@ -48,40 +52,57 @@ class GitHubRateLimitChecker {
|
||||
@Nonnull RateLimitChecker graphql,
|
||||
@Nonnull RateLimitChecker integrationManifest) {
|
||||
this.core = Objects.requireNonNull(core);
|
||||
|
||||
// for now only support rate limiting on core
|
||||
// remove these asserts when that changes
|
||||
assert search == RateLimitChecker.NONE;
|
||||
assert graphql == RateLimitChecker.NONE;
|
||||
assert integrationManifest == RateLimitChecker.NONE;
|
||||
|
||||
this.search = Objects.requireNonNull(search);
|
||||
this.graphql = Objects.requireNonNull(graphql);
|
||||
this.integrationManifest = Objects.requireNonNull(integrationManifest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link GitHubRateLimitChecker} with a new checker for a particular target.
|
||||
*
|
||||
* Only one {@link RateLimitChecker} is allowed per target.
|
||||
*
|
||||
* @param checker
|
||||
* the {@link RateLimitChecker} to apply.
|
||||
* @param rateLimitTarget
|
||||
* the {@link RateLimitTarget} for this checker. If {@link RateLimitTarget#NONE}, checker will be ignored
|
||||
* and no change will be made.
|
||||
* @return a new {@link GitHubRateLimitChecker}
|
||||
*/
|
||||
GitHubRateLimitChecker with(@Nonnull RateLimitChecker checker, @Nonnull RateLimitTarget rateLimitTarget) {
|
||||
return new GitHubRateLimitChecker(rateLimitTarget == RateLimitTarget.CORE ? checker : core,
|
||||
rateLimitTarget == RateLimitTarget.SEARCH ? checker : search,
|
||||
rateLimitTarget == RateLimitTarget.GRAPHQL ? checker : graphql,
|
||||
rateLimitTarget == RateLimitTarget.INTEGRATION_MANIFEST ? checker : integrationManifest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether there is sufficient requests remaining within this client's rate limit quota to make the current
|
||||
* request.
|
||||
* <p>
|
||||
* This method does not do the actual check. Instead it select the appropriate {@link RateLimitChecker} and
|
||||
* {@link GHRateLimit.Record} for the current request's urlPath. If the {@link RateLimitChecker} for this the
|
||||
* current request's urlPath is {@link RateLimitChecker#NONE} the rate limit is not checked. If not, it calls
|
||||
* {@link RateLimitChecker#checkRateLimit(GHRateLimit.Record, long)}. which decides if the rate limit has been
|
||||
* exceeded and then sleeps for as long is it choose.
|
||||
* This method does not do the actual check. Instead it selects the appropriate {@link RateLimitChecker} and
|
||||
* {@link GHRateLimit.Record} for the current request's {@link RateLimitTarget}. It then calls
|
||||
* {@link RateLimitChecker#checkRateLimit(GHRateLimit.Record, long)}.
|
||||
* </p>
|
||||
* <p>
|
||||
* It is up to the {@link RateLimitChecker#checkRateLimit(GHRateLimit.Record, long)} which decide if the rate limit
|
||||
* has been exceeded. If it has, that method will sleep for as long is it chooses and then return {@code true}. If
|
||||
* not, that method will return {@code false}.
|
||||
* It is up to {@link RateLimitChecker#checkRateLimit(GHRateLimit.Record, long)} to which decide if the rate limit
|
||||
* has been exceeded. If it has, {@link RateLimitChecker#checkRateLimit(GHRateLimit.Record, long)} will sleep for as
|
||||
* long is it chooses and then return {@code true}. If not, that method will return {@code false}.
|
||||
* </p>
|
||||
* <p>
|
||||
* As long as {@link RateLimitChecker#checkRateLimit(GHRateLimit.Record, long)} returns {@code true}, this method
|
||||
* will request updated rate limit information and call
|
||||
* {@link RateLimitChecker#checkRateLimit(GHRateLimit.Record, long)} again. This looping allows implementers of
|
||||
* {@link RateLimitChecker#checkRateLimit(GHRateLimit.Record, long)} to apply any number of strategies to
|
||||
* controlling the speed at which requests are made. When it returns {@code false} this method will return and the
|
||||
* request will be sent.
|
||||
* {@link RateLimitChecker#checkRateLimit(GHRateLimit.Record, long)} again. This looping allows different
|
||||
* {@link RateLimitChecker} implementations to apply any number of strategies to controlling the speed at which
|
||||
* requests are made.
|
||||
* </p>
|
||||
* <p>
|
||||
* When the {@link RateLimitChecker} returns {@code false} this method will return and the request processing will
|
||||
* continue.
|
||||
* </p>
|
||||
* <p>
|
||||
* If the {@link RateLimitChecker} for this the current request's urlPath is {@link RateLimitChecker#NONE} the rate
|
||||
* limit is not checked.
|
||||
* </p>
|
||||
*
|
||||
* @param client
|
||||
@@ -92,14 +113,14 @@ class GitHubRateLimitChecker {
|
||||
* if there is an I/O error
|
||||
*/
|
||||
void checkRateLimit(GitHubClient client, GitHubRequest request) throws IOException {
|
||||
RateLimitChecker guard = selectChecker(request.urlPath());
|
||||
RateLimitChecker guard = selectChecker(request.rateLimitTarget());
|
||||
if (guard == RateLimitChecker.NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For the first rate limit, accept the current limit if a valid one is already present.
|
||||
GHRateLimit rateLimit = client.rateLimit();
|
||||
GHRateLimit.Record rateLimitRecord = rateLimit.getRecordForUrlPath(request.urlPath());
|
||||
GHRateLimit rateLimit = client.rateLimit(request.rateLimitTarget());
|
||||
GHRateLimit.Record rateLimitRecord = rateLimit.getRecord(request.rateLimitTarget());
|
||||
long waitCount = 0;
|
||||
try {
|
||||
while (guard.checkRateLimit(rateLimitRecord, waitCount)) {
|
||||
@@ -112,8 +133,8 @@ class GitHubRateLimitChecker {
|
||||
Thread.sleep(1000);
|
||||
|
||||
// After the first wait, always request a new rate limit from the server.
|
||||
rateLimit = client.getRateLimit();
|
||||
rateLimitRecord = rateLimit.getRecordForUrlPath(request.urlPath());
|
||||
rateLimit = client.getRateLimit(request.rateLimitTarget());
|
||||
rateLimitRecord = rateLimit.getRecord(request.rateLimitTarget());
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw (IOException) new InterruptedIOException(e.getMessage()).initCause(e);
|
||||
@@ -121,25 +142,28 @@ class GitHubRateLimitChecker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the appropriate {@link RateLimitChecker} for a particular url path. Similar to
|
||||
* {@link GHRateLimit#getRecordForUrlPath(String)}.
|
||||
* Gets the appropriate {@link RateLimitChecker} for a particular target.
|
||||
*
|
||||
* @param urlPath
|
||||
* the url path of the request
|
||||
* @return the {@link RateLimitChecker} for a url path.
|
||||
* Analogous with {@link GHRateLimit#getRecord(RateLimitTarget)}.
|
||||
*
|
||||
* @param rateLimitTarget
|
||||
* the rate limit to check
|
||||
* @return the {@link RateLimitChecker} for a particular target
|
||||
*/
|
||||
@Nonnull
|
||||
private RateLimitChecker selectChecker(@Nonnull String urlPath) {
|
||||
if (urlPath.equals("/rate_limit")) {
|
||||
private RateLimitChecker selectChecker(@Nonnull RateLimitTarget rateLimitTarget) {
|
||||
if (rateLimitTarget == RateLimitTarget.NONE) {
|
||||
return RateLimitChecker.NONE;
|
||||
} else if (urlPath.startsWith("/search")) {
|
||||
} else if (rateLimitTarget == RateLimitTarget.CORE) {
|
||||
return core;
|
||||
} else if (rateLimitTarget == RateLimitTarget.SEARCH) {
|
||||
return search;
|
||||
} else if (urlPath.startsWith("/graphql")) {
|
||||
} else if (rateLimitTarget == RateLimitTarget.GRAPHQL) {
|
||||
return graphql;
|
||||
} else if (urlPath.startsWith("/app-manifests")) {
|
||||
} else if (rateLimitTarget == RateLimitTarget.INTEGRATION_MANIFEST) {
|
||||
return integrationManifest;
|
||||
} else {
|
||||
return core;
|
||||
throw new IllegalArgumentException("Unknown rate limit target: " + rateLimitTarget.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ class GitHubRequest {
|
||||
private final String apiUrl;
|
||||
private final String urlPath;
|
||||
private final String method;
|
||||
private final RateLimitTarget rateLimitTarget;
|
||||
private final InputStream body;
|
||||
private final boolean forceBody;
|
||||
|
||||
@@ -56,6 +57,7 @@ class GitHubRequest {
|
||||
@Nonnull String apiUrl,
|
||||
@Nonnull String urlPath,
|
||||
@Nonnull String method,
|
||||
@Nonnull RateLimitTarget rateLimitTarget,
|
||||
@CheckForNull InputStream body,
|
||||
boolean forceBody) throws MalformedURLException {
|
||||
this.args = Collections.unmodifiableList(new ArrayList<>(args));
|
||||
@@ -64,6 +66,7 @@ class GitHubRequest {
|
||||
this.apiUrl = apiUrl;
|
||||
this.urlPath = urlPath;
|
||||
this.method = method;
|
||||
this.rateLimitTarget = rateLimitTarget;
|
||||
this.body = body;
|
||||
this.forceBody = forceBody;
|
||||
String tailApiUrl = buildTailApiUrl();
|
||||
@@ -119,6 +122,16 @@ class GitHubRequest {
|
||||
return method;
|
||||
}
|
||||
|
||||
/**
|
||||
* The rate limit target for this request.
|
||||
*
|
||||
* @return the rate limit to use for this request.
|
||||
*/
|
||||
@Nonnull
|
||||
public RateLimitTarget rateLimitTarget() {
|
||||
return rateLimitTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* The arguments for this request. Depending on the {@link #method()} and {@code #inBody()} these maybe added to the
|
||||
* url or to the request body.
|
||||
@@ -217,7 +230,15 @@ class GitHubRequest {
|
||||
* @return a {@link Builder} based on this request.
|
||||
*/
|
||||
public Builder<?> toBuilder() {
|
||||
return new Builder<>(args, headers, injectedMappingValues, apiUrl, urlPath, method, body, forceBody);
|
||||
return new Builder<>(args,
|
||||
headers,
|
||||
injectedMappingValues,
|
||||
apiUrl,
|
||||
urlPath,
|
||||
method,
|
||||
rateLimitTarget,
|
||||
body,
|
||||
forceBody);
|
||||
}
|
||||
|
||||
private String buildTailApiUrl() {
|
||||
@@ -281,6 +302,10 @@ class GitHubRequest {
|
||||
*/
|
||||
@Nonnull
|
||||
private String method;
|
||||
|
||||
@Nonnull
|
||||
private RateLimitTarget rateLimitTarget;
|
||||
|
||||
private InputStream body;
|
||||
private boolean forceBody;
|
||||
|
||||
@@ -294,6 +319,7 @@ class GitHubRequest {
|
||||
GitHubClient.GITHUB_URL,
|
||||
"/",
|
||||
"GET",
|
||||
RateLimitTarget.CORE,
|
||||
null,
|
||||
false);
|
||||
}
|
||||
@@ -304,6 +330,7 @@ class GitHubRequest {
|
||||
@Nonnull String apiUrl,
|
||||
@Nonnull String urlPath,
|
||||
@Nonnull String method,
|
||||
@Nonnull RateLimitTarget rateLimitTarget,
|
||||
@CheckForNull @WillClose InputStream body,
|
||||
boolean forceBody) {
|
||||
this.args = new ArrayList<>(args);
|
||||
@@ -312,6 +339,7 @@ class GitHubRequest {
|
||||
this.apiUrl = apiUrl;
|
||||
this.urlPath = urlPath;
|
||||
this.method = method;
|
||||
this.rateLimitTarget = rateLimitTarget;
|
||||
this.body = body;
|
||||
this.forceBody = forceBody;
|
||||
}
|
||||
@@ -324,7 +352,15 @@ class GitHubRequest {
|
||||
* if the GitHub API URL cannot be constructed
|
||||
*/
|
||||
public GitHubRequest build() throws MalformedURLException {
|
||||
return new GitHubRequest(args, headers, injectedMappingValues, apiUrl, urlPath, method, body, forceBody);
|
||||
return new GitHubRequest(args,
|
||||
headers,
|
||||
injectedMappingValues,
|
||||
apiUrl,
|
||||
urlPath,
|
||||
method,
|
||||
rateLimitTarget,
|
||||
body,
|
||||
forceBody);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,9 +384,11 @@ class GitHubRequest {
|
||||
* the name
|
||||
* @param value
|
||||
* the value
|
||||
* @return the request builder
|
||||
*/
|
||||
public void setHeader(String name, String value) {
|
||||
public B setHeader(String name, String value) {
|
||||
headers.put(name, value);
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,8 +401,11 @@ class GitHubRequest {
|
||||
* @return the request builder
|
||||
*/
|
||||
public B withHeader(String name, String value) {
|
||||
setHeader(name, value);
|
||||
return (B) this;
|
||||
String oldValue = headers.get(name);
|
||||
if (!StringUtils.isBlank(oldValue)) {
|
||||
value = oldValue + ", " + value;
|
||||
}
|
||||
return setHeader(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -562,6 +603,18 @@ class GitHubRequest {
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method requester.
|
||||
*
|
||||
* @param rateLimitTarget
|
||||
* the rate limit target for this request. Default is {@link RateLimitTarget#CORE}.
|
||||
* @return the request builder
|
||||
*/
|
||||
public B rateLimit(@Nonnull RateLimitTarget rateLimitTarget) {
|
||||
this.rateLimitTarget = rateLimitTarget;
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Content type requester.
|
||||
*
|
||||
@@ -623,13 +676,9 @@ class GitHubRequest {
|
||||
tailUrlPath += "/" + String.join("/", urlPathItems);
|
||||
}
|
||||
|
||||
if (this.urlPath.endsWith("/")) {
|
||||
tailUrlPath = StringUtils.stripStart(tailUrlPath, "/");
|
||||
} else {
|
||||
tailUrlPath = StringUtils.prependIfMissing(tailUrlPath, "/");
|
||||
}
|
||||
tailUrlPath = StringUtils.prependIfMissing(tailUrlPath, "/");
|
||||
|
||||
this.urlPath += urlPathEncode(tailUrlPath);
|
||||
this.urlPath = urlPathEncode(tailUrlPath);
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.InjectableValues;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -77,9 +78,14 @@ class GitHubResponse<T> {
|
||||
@CheckForNull
|
||||
static <T> T parseBody(ResponseInfo responseInfo, Class<T> type) throws IOException {
|
||||
|
||||
if (responseInfo.statusCode() == HttpURLConnection.HTTP_NO_CONTENT && type != null && type.isArray()) {
|
||||
// no content
|
||||
return type.cast(Array.newInstance(type.getComponentType(), 0));
|
||||
if (responseInfo.statusCode() == HttpURLConnection.HTTP_NO_CONTENT) {
|
||||
if (type != null && type.isArray()) {
|
||||
// no content for array should be empty array
|
||||
return type.cast(Array.newInstance(type.getComponentType(), 0));
|
||||
} else {
|
||||
// no content for object should be null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String data = responseInfo.getBodyAsString();
|
||||
@@ -212,7 +218,7 @@ class GitHubResponse<T> {
|
||||
* Initial response information supplied to a {@link BodyHandler} when a response is initially received and before
|
||||
* the body is processed.
|
||||
*/
|
||||
static abstract class ResponseInfo {
|
||||
static abstract class ResponseInfo implements Closeable {
|
||||
|
||||
private static final Comparator<String> nullableCaseInsensitiveComparator = Comparator
|
||||
.nullsFirst(String.CASE_INSENSITIVE_ORDER);
|
||||
@@ -317,12 +323,8 @@ class GitHubResponse<T> {
|
||||
@Nonnull
|
||||
String getBodyAsString() throws IOException {
|
||||
InputStreamReader r = null;
|
||||
try {
|
||||
r = new InputStreamReader(this.bodyStream(), StandardCharsets.UTF_8);
|
||||
return IOUtils.toString(r);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(r);
|
||||
}
|
||||
r = new InputStreamReader(this.bodyStream(), StandardCharsets.UTF_8);
|
||||
return IOUtils.toString(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
/**
|
||||
* Represents a user in Git who authors/commits a commit.
|
||||
* <p>
|
||||
@@ -15,10 +17,10 @@ import java.util.Date;
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GitUser {
|
||||
private String name, email, date;
|
||||
private String name, email, date, username;
|
||||
|
||||
/**
|
||||
* Gets name.
|
||||
* Gets the git user name for an author or committer on a git commit.
|
||||
*
|
||||
* @return Human readable name of the user, such as "Kohsuke Kawaguchi"
|
||||
*/
|
||||
@@ -27,14 +29,26 @@ public class GitUser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets email.
|
||||
* Gets the git email for an author or committer on a git commit.
|
||||
*
|
||||
* @return E -mail address, such as "foo@example.com"
|
||||
* @return E-mail address, such as "foo@example.com"
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets username. Note: it presents only in events.
|
||||
*
|
||||
* @return GitHub username
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
@CheckForNull
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets date.
|
||||
*
|
||||
|
||||
@@ -15,6 +15,14 @@ class Previews {
|
||||
*/
|
||||
static final String ANTIOPE = "application/vnd.github.antiope-preview+json";
|
||||
|
||||
/**
|
||||
* Create repository from template repository
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/previews/#create-and-use-repository-templates">GitHub API
|
||||
* Previews</a>
|
||||
*/
|
||||
static final String BAPTISE = "application/vnd.github.baptiste-preview+json";
|
||||
|
||||
/**
|
||||
* Commit Search
|
||||
*
|
||||
@@ -29,6 +37,14 @@ class Previews {
|
||||
*/
|
||||
static final String GAMBIT = "application/vnd.github.gambit-preview+json";
|
||||
|
||||
/**
|
||||
* List branches or pull requests for a commit
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/previews/#list-branches-or-pull-requests-for-a-commit">GitHub API
|
||||
* Previews</a>
|
||||
*/
|
||||
static final String GROOT = "application/vnd.github.groot-preview+json";
|
||||
|
||||
/**
|
||||
* Manage projects
|
||||
*
|
||||
@@ -36,6 +52,13 @@ class Previews {
|
||||
*/
|
||||
static final String INERTIA = "application/vnd.github.inertia-preview+json";
|
||||
|
||||
/**
|
||||
* Update a pull request branch
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/previews/#update-a-pull-request-branch">GitHub API Previews</a>
|
||||
*/
|
||||
static final String LYDIAN = "application/vnd.github.lydian-preview+json";
|
||||
|
||||
/**
|
||||
* Require multiple approving reviews
|
||||
*
|
||||
@@ -58,6 +81,14 @@ class Previews {
|
||||
*/
|
||||
static final String MERCY = "application/vnd.github.mercy-preview+json";
|
||||
|
||||
/**
|
||||
* New visibility parameter for the Repositories API
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/previews/#new-visibility-parameter-for-the-repositories-api">GitHub
|
||||
* API Previews</a>
|
||||
*/
|
||||
static final String NEBULA = "application/vnd.github.nebula-preview+json";
|
||||
|
||||
/**
|
||||
* Draft pull requests
|
||||
*
|
||||
@@ -78,4 +109,5 @@ class Previews {
|
||||
* @see <a href="https://developer.github.com/v3/previews/#require-signed-commits">GitHub API Previews</a>
|
||||
*/
|
||||
static final String ZZZAX = "application/vnd.github.zzzax-preview+json";
|
||||
|
||||
}
|
||||
|
||||
@@ -5,20 +5,17 @@ import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A GitHub API Rate Limit Checker called before each request
|
||||
*
|
||||
* <p>
|
||||
* GitHub allots a certain number of requests to each user or application per period of time (usually per hour). The
|
||||
* number of requests remaining is returned in the response header and can also be requested using
|
||||
* {@link GitHub#getRateLimit()}. This requests per interval is referred to as the "rate limit".
|
||||
* GitHub allots a certain number of requests to each user or application per period of time. The number of requests
|
||||
* remaining and the time when the number will be reset is returned in the response header and can also be requested
|
||||
* using {@link GitHub#getRateLimit()}. The "requests per interval" is referred to as the "rate limit".
|
||||
* </p>
|
||||
* <p>
|
||||
* GitHub prefers that clients stop before exceeding their rate limit rather than stopping after they exceed it. The
|
||||
* {@link RateLimitChecker} is called before each request to check the rate limit and wait if the checker criteria are
|
||||
* met.
|
||||
* </p>
|
||||
* <p>
|
||||
* Checking your rate limit using {@link GitHub#getRateLimit()} does not effect your rate limit, but each {@link GitHub}
|
||||
* instance will attempt to cache and reuse the last see rate limit rather than making a new request.
|
||||
* </p>
|
||||
*/
|
||||
public abstract class RateLimitChecker {
|
||||
|
||||
@@ -33,28 +30,21 @@ public abstract class RateLimitChecker {
|
||||
* free to choose whatever strategy they prefer for what is considered to exceed the budget and how long to sleep.
|
||||
*
|
||||
* <p>
|
||||
* The caller of this method figures out which {@link GHRateLimit.Record} applies for the current request add
|
||||
* The caller of this method figures out which {@link GHRateLimit.Record} applies for the current request and
|
||||
* provides it to this method.
|
||||
* </p>
|
||||
* <p>
|
||||
* It is important to remember that rate limit reset times are only accurate to the second. Trying to sleep to
|
||||
* exactly the reset time would be likely to produce worse behavior rather than better. For this reason
|
||||
* {@link GitHubRateLimitChecker} may choose to add more sleep times when a checker indicates the rate limit was
|
||||
* exceeded.
|
||||
* As long as this method returns {@code true} it is guaranteed that {@link GitHubRateLimitChecker} will retrieve
|
||||
* updated rate limit information and call this method again with {@code count} incremented by one. When this
|
||||
* checker returns {@code false}, the calling {@link GitHubRateLimitChecker} will let the request continue.
|
||||
* </p>
|
||||
* <p>
|
||||
* As long as this method returns {@code true} it is guaranteed that {@link GitHubRateLimitChecker} will get updated
|
||||
* rate limit information and call this method again with {@code count} incremented by one. After this method
|
||||
* returns {@code true} at least once, the calling {@link GitHubRateLimitChecker} may choose to wait some additional
|
||||
* period of time between calls to this checker.
|
||||
* Rate limit reset times are only accurate to the second. Trying to sleep to exactly the reset time could result in
|
||||
* requests being sent before the new rate limit was available. For this reason, if this method returned
|
||||
* {@code true} at least once for a particular request, {@link GitHubRateLimitChecker} may choose to sleep for some
|
||||
* small additional between calls and before letting the request continue.
|
||||
* </p>
|
||||
* <p>
|
||||
* After this checker returns {@code false}, the calling {@link GitHubRateLimitChecker} will let the request
|
||||
* continue. If this method returned {@code true} at least once for a particular request, the calling
|
||||
* {@link GitHubRateLimitChecker} may choose to wait some additional period of time before letting the request be
|
||||
* sent.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param rateLimitRecord
|
||||
* the current {@link GHRateLimit.Record} to check against.
|
||||
* @param count
|
||||
|
||||
36
src/main/java/org/kohsuke/github/RateLimitTarget.java
Normal file
36
src/main/java/org/kohsuke/github/RateLimitTarget.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
/**
|
||||
* Specifies the rate limit record of an operation.
|
||||
*
|
||||
* @see GitHubBuilder#withRateLimitChecker(RateLimitChecker, RateLimitTarget)
|
||||
*/
|
||||
public enum RateLimitTarget {
|
||||
/**
|
||||
* Selects or updates the {@link GHRateLimit#getCore()} record.
|
||||
*/
|
||||
CORE,
|
||||
|
||||
/**
|
||||
* Selects or updates the {@link GHRateLimit#getSearch()} record.
|
||||
*/
|
||||
SEARCH,
|
||||
|
||||
/**
|
||||
* Selects or updates the {@link GHRateLimit#getGraphQL()} record.
|
||||
*/
|
||||
GRAPHQL,
|
||||
|
||||
/**
|
||||
* Selects or updates the {@link GHRateLimit#getIntegrationManifest()} record.
|
||||
*/
|
||||
INTEGRATION_MANIFEST,
|
||||
|
||||
/**
|
||||
* Selects no rate limit.
|
||||
*
|
||||
* This request uses no rate limit. If the response header includes rate limit information, it will apply to
|
||||
* {@link #CORE}.
|
||||
*/
|
||||
NONE
|
||||
}
|
||||
@@ -23,6 +23,9 @@
|
||||
*/
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
@@ -108,7 +111,10 @@ class Requester extends GitHubRequest.Builder<Requester> {
|
||||
* the io exception
|
||||
*/
|
||||
public InputStream fetchStream() throws IOException {
|
||||
return client.sendRequest(this, (responseInfo) -> responseInfo.bodyStream()).body();
|
||||
return client
|
||||
.sendRequest(this,
|
||||
(responseInfo) -> new ByteArrayInputStream(IOUtils.toByteArray(responseInfo.bodyStream())))
|
||||
.body();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
31
src/site/apt/createorglevelresources.apt
Normal file
31
src/site/apt/createorglevelresources.apt
Normal file
@@ -0,0 +1,31 @@
|
||||
Creating resources at the organization level
|
||||
|
||||
In order to create resources in GitHub for a given organization, you must first create an object of type <<<GHOrganization>>>.
|
||||
As an example:
|
||||
|
||||
+-----+
|
||||
GHOrganization organizationClient(GitHub gitHub, String organizationName) throws IOException {
|
||||
return gitHub.getOrganization(organizationName);
|
||||
}
|
||||
+-----+
|
||||
|
||||
Now you can easily work with the GHOrganization, and all methods that will create resources will create them
|
||||
in the given organization.
|
||||
|
||||
One of the most common use cases is to create a repository in a given organization:
|
||||
|
||||
+-----+
|
||||
void createRepository(GHOrganization organization) {
|
||||
organization.createRepository("repository-name")
|
||||
.private_(true)
|
||||
.wiki(false)
|
||||
.projects(false)
|
||||
.description("Description")
|
||||
.allowMergeCommit(true)
|
||||
.allowSquashMerge(false)
|
||||
.allowRebaseMerge(false)
|
||||
.create()
|
||||
}
|
||||
+-----+
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<item name="JWT Authentication" href="/githubappjwtauth.html"/>
|
||||
<item name="App Installation Token " href="/githubappappinsttokenauth.html"/>
|
||||
</item>
|
||||
<item name="Working with organizations" href="/createorglevelresources.html"/>
|
||||
</menu>
|
||||
|
||||
<menu name="References">
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
|
||||
public class AbstractGHAppInstallationTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
private static String TEST_APP_ID_1 = "82994";
|
||||
private static String TEST_APP_ID_2 = "83009";
|
||||
private static String TEST_APP_ID_3 = "89368";
|
||||
private static String PRIVATE_KEY_FILE_APP_1 = "/ghapi-test-app-1.private-key.pem";
|
||||
private static String PRIVATE_KEY_FILE_APP_2 = "/ghapi-test-app-2.private-key.pem";
|
||||
private static String PRIVATE_KEY_FILE_APP_3 = "/ghapi-test-app-3.private-key.pem";
|
||||
|
||||
private String createJwtToken(String keyFileResouceName, String appId) {
|
||||
try {
|
||||
String keyPEM = IOUtils.toString(this.getClass().getResource(keyFileResouceName), "US-ASCII")
|
||||
.replaceAll("(?m)^--.*", "") // remove comments from PEM to allow decoding
|
||||
.replaceAll("\\s", "");
|
||||
|
||||
PKCS8EncodedKeySpec keySpecPKCS8 = new PKCS8EncodedKeySpec(Base64.getDecoder().decode(keyPEM));
|
||||
PrivateKey privateKey = KeyFactory.getInstance("RSA").generatePrivate(keySpecPKCS8);
|
||||
|
||||
return Jwts.builder()
|
||||
.setIssuedAt(Date.from(Instant.now()))
|
||||
.setExpiration(Date.from(Instant.now().plus(5, ChronoUnit.MINUTES)))
|
||||
.setIssuer(appId)
|
||||
.signWith(privateKey)
|
||||
.compact();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error creating JWT token.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private GHAppInstallation getAppInstallationWithToken(String jwtToken) throws IOException {
|
||||
GitHub gitHub = getGitHubBuilder().withJwtToken(jwtToken)
|
||||
.withEndpoint(mockGitHub.apiServer().baseUrl())
|
||||
.build();
|
||||
|
||||
GHAppInstallation appInstallation = gitHub.getApp()
|
||||
.listInstallations()
|
||||
.toList()
|
||||
.stream()
|
||||
.filter(it -> it.getAccount().login.equals("hub4j-test-org"))
|
||||
.findFirst()
|
||||
.get();
|
||||
|
||||
appInstallation
|
||||
.setRoot(getGitHubBuilder().withAppInstallationToken(appInstallation.createToken().create().getToken())
|
||||
.withEndpoint(mockGitHub.apiServer().baseUrl())
|
||||
.build());
|
||||
|
||||
return appInstallation;
|
||||
}
|
||||
|
||||
protected GHAppInstallation getAppInstallationWithTokenApp1() throws IOException {
|
||||
return getAppInstallationWithToken(createJwtToken(PRIVATE_KEY_FILE_APP_1, TEST_APP_ID_1));
|
||||
}
|
||||
|
||||
protected GHAppInstallation getAppInstallationWithTokenApp2() throws IOException {
|
||||
return getAppInstallationWithToken(createJwtToken(PRIVATE_KEY_FILE_APP_2, TEST_APP_ID_2));
|
||||
}
|
||||
|
||||
protected GHAppInstallation getAppInstallationWithTokenApp3() throws IOException {
|
||||
return getAppInstallationWithToken(createJwtToken(PRIVATE_KEY_FILE_APP_3, TEST_APP_ID_3));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||
import static org.hamcrest.Matchers.hasProperty;
|
||||
import static org.hamcrest.Matchers.oneOf;
|
||||
|
||||
@@ -108,7 +109,7 @@ public class AppTest extends AbstractGitHubWireMockTest {
|
||||
gitHub = getGitHubBuilder().withOAuthToken("bogus", "user")
|
||||
.withEndpoint(mockGitHub.apiServer().baseUrl())
|
||||
.build();
|
||||
assertThat(gitHub.lastRateLimit(), nullValue());
|
||||
assertThat(gitHub.lastRateLimit(), sameInstance(GHRateLimit.DEFAULT));
|
||||
assertFalse(gitHub.isCredentialValid());
|
||||
// For invalid credentials, we get a 401 but it includes anonymous rate limit headers
|
||||
assertThat(gitHub.lastRateLimit().getCore(), not(instanceOf(GHRateLimit.UnknownLimitRecord.class)));
|
||||
@@ -118,18 +119,22 @@ public class AppTest extends AbstractGitHubWireMockTest {
|
||||
@Test
|
||||
public void testCredentialValidEnterprise() throws IOException {
|
||||
// Simulated GHE: getRateLimit returns 404
|
||||
assertThat(gitHub.lastRateLimit(), nullValue());
|
||||
assertThat(gitHub.lastRateLimit(), sameInstance(GHRateLimit.DEFAULT));
|
||||
assertThat(gitHub.lastRateLimit().getCore().isExpired(), is(true));
|
||||
assertTrue(gitHub.isCredentialValid());
|
||||
// lastRateLimit stays null when 404 is encountered
|
||||
assertThat(gitHub.lastRateLimit(), nullValue());
|
||||
|
||||
// lastRateLimitUpdates because 404 still includes header rate limit info
|
||||
assertThat(gitHub.lastRateLimit(), notNullValue());
|
||||
assertThat(gitHub.lastRateLimit(), not(equalTo(GHRateLimit.DEFAULT)));
|
||||
assertThat(gitHub.lastRateLimit().getCore().isExpired(), is(false));
|
||||
|
||||
gitHub = getGitHubBuilder().withOAuthToken("bogus", "user")
|
||||
.withEndpoint(mockGitHub.apiServer().baseUrl())
|
||||
.build();
|
||||
assertThat(gitHub.lastRateLimit(), nullValue());
|
||||
assertThat(gitHub.lastRateLimit(), sameInstance(GHRateLimit.DEFAULT));
|
||||
assertFalse(gitHub.isCredentialValid());
|
||||
// Simulated GHE: For invalid credentials, we get a 401 that does not include ratelimit info
|
||||
assertThat(gitHub.lastRateLimit(), nullValue());
|
||||
assertThat(gitHub.lastRateLimit(), sameInstance(GHRateLimit.DEFAULT));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.google.common.collect.Iterables;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
@@ -25,6 +27,83 @@ public class CommitTest extends AbstractGitHubWireMockTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listPullRequestsOfNotIncludedCommit() throws Exception {
|
||||
GHRepository repo = gitHub.getOrganization("hub4j-test-org").getRepository("listPrsListHeads");
|
||||
|
||||
GHCommit commit = repo.getCommit("f66f7ca691ace6f4a9230292efb932b49214d72c");
|
||||
|
||||
assertThat("The commit is supposed to be not part of any pull request",
|
||||
commit.listPullRequests().toList().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listPullRequests() throws Exception {
|
||||
GHRepository repo = gitHub.getOrganization("hub4j-test-org").getRepository("listPrsListHeads");
|
||||
Integer prNumber = 2;
|
||||
|
||||
GHCommit commit = repo.getCommit("6b9956fe8c3d030dbc49c9d4c4166b0ceb4198fc");
|
||||
|
||||
List<GHPullRequest> listedPrs = commit.listPullRequests().toList();
|
||||
|
||||
assertEquals(listedPrs.size(), 1);
|
||||
|
||||
assertThat("Pull request " + prNumber + " not found by searching from commit.",
|
||||
listedPrs.stream().findFirst().filter(it -> it.getNumber() == prNumber).isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listPullRequestsOfCommitWith2PullRequests() throws Exception {
|
||||
GHRepository repo = gitHub.getOrganization("hub4j-test-org").getRepository("listPrsListHeads");
|
||||
Integer[] expectedPrs = new Integer[]{ 1, 2 };
|
||||
|
||||
GHCommit commit = repo.getCommit("442aa213f924a5984856f16e52a18153aaf41ad3");
|
||||
|
||||
List<GHPullRequest> listedPrs = commit.listPullRequests().toList();
|
||||
|
||||
assertEquals(listedPrs.size(), 2);
|
||||
|
||||
listedPrs.stream()
|
||||
.forEach(pr -> assertThat("PR#" + pr.getNumber() + " not expected to be matched.",
|
||||
Arrays.stream(expectedPrs).anyMatch(prNumber -> prNumber.equals(pr.getNumber()))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listBranchesWhereHead() throws Exception {
|
||||
GHRepository repo = gitHub.getOrganization("hub4j-test-org").getRepository("listPrsListHeads");
|
||||
|
||||
GHCommit commit = repo.getCommit("ab92e13c0fc844fd51a379a48a3ad0b18231215c");
|
||||
|
||||
assertThat("Commit which was supposed to be HEAD in the \"master\" branch was not found.",
|
||||
commit.listBranchesWhereHead()
|
||||
.toList()
|
||||
.stream()
|
||||
.findFirst()
|
||||
.filter(it -> it.getName().equals("master"))
|
||||
.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listBranchesWhereHead2Heads() throws Exception {
|
||||
GHRepository repo = gitHub.getOrganization("hub4j-test-org").getRepository("listPrsListHeads");
|
||||
|
||||
GHCommit commit = repo.getCommit("ab92e13c0fc844fd51a379a48a3ad0b18231215c");
|
||||
|
||||
assertEquals("Commit which was supposed to be HEAD in 2 branches was not found as such.",
|
||||
2,
|
||||
commit.listBranchesWhereHead().toList().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listBranchesWhereHeadOfCommitWithHeadNowhere() throws Exception {
|
||||
GHRepository repo = gitHub.getOrganization("hub4j-test-org").getRepository("listPrsListHeads");
|
||||
|
||||
GHCommit commit = repo.getCommit("7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e");
|
||||
|
||||
assertThat("Commit which was not supposed to be HEAD in any branch was found as HEAD.",
|
||||
commit.listBranchesWhereHead().toList().isEmpty());
|
||||
}
|
||||
|
||||
@Test // issue 737
|
||||
public void commitSignatureVerification() throws Exception {
|
||||
GHRepository repo = gitHub.getRepository("stapler/stapler");
|
||||
|
||||
29
src/test/java/org/kohsuke/github/GHAppInstallationTest.java
Normal file
29
src/test/java/org/kohsuke/github/GHAppInstallationTest.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class GHAppInstallationTest extends AbstractGHAppInstallationTest {
|
||||
|
||||
@Test
|
||||
public void testListRepositoriesTwoRepos() throws IOException {
|
||||
GHAppInstallation appInstallation = getAppInstallationWithTokenApp1();
|
||||
|
||||
List<GHRepository> repositories = appInstallation.listRepositories().toList();
|
||||
|
||||
assertEquals(2, repositories.size());
|
||||
assertTrue(repositories.stream().anyMatch(it -> it.getName().equals("empty")));
|
||||
assertTrue(repositories.stream().anyMatch(it -> it.getName().equals("test-readme")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListRepositoriesNoPermissions() throws IOException {
|
||||
GHAppInstallation appInstallation = getAppInstallationWithTokenApp2();
|
||||
|
||||
assertTrue("App does not have permissions and should have 0 repositories",
|
||||
appInstallation.listRepositories().toList().isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import org.kohsuke.github.GHBranchProtection.EnforceAdmins;
|
||||
import org.kohsuke.github.GHBranchProtection.RequiredReviews;
|
||||
import org.kohsuke.github.GHBranchProtection.RequiredStatusChecks;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
|
||||
public class GHBranchProtectionTest extends AbstractGitHubWireMockTest {
|
||||
private static final String BRANCH = "master";
|
||||
private static final String BRANCH_REF = "heads/" + BRANCH;
|
||||
@@ -32,6 +34,14 @@ public class GHBranchProtectionTest extends AbstractGitHubWireMockTest {
|
||||
.includeAdmins()
|
||||
.enable();
|
||||
|
||||
verifyBranchProtection(protection);
|
||||
|
||||
// Get goes through a different code path. Make sure it also gets the correct data.
|
||||
protection = branch.getProtection();
|
||||
verifyBranchProtection(protection);
|
||||
}
|
||||
|
||||
private void verifyBranchProtection(GHBranchProtection protection) {
|
||||
RequiredStatusChecks statusChecks = protection.getRequiredStatusChecks();
|
||||
assertNotNull(statusChecks);
|
||||
assertTrue(statusChecks.isRequiresBranchUpToDate());
|
||||
@@ -66,7 +76,20 @@ public class GHBranchProtectionTest extends AbstractGitHubWireMockTest {
|
||||
public void testEnableRequireReviewsOnly() throws Exception {
|
||||
GHBranchProtection protection = branch.enableProtection().requireReviews().enable();
|
||||
|
||||
RequiredReviews requiredReviews = protection.getRequiredReviews();
|
||||
assertNotNull(protection.getRequiredReviews());
|
||||
assertFalse(requiredReviews.isDismissStaleReviews());
|
||||
assertFalse(requiredReviews.isRequireCodeOwnerReviews());
|
||||
assertThat(protection.getRequiredReviews().getRequiredReviewers(), equalTo(1));
|
||||
|
||||
// Get goes through a different code path. Make sure it also gets the correct data.
|
||||
protection = branch.getProtection();
|
||||
requiredReviews = protection.getRequiredReviews();
|
||||
|
||||
assertNotNull(protection.getRequiredReviews());
|
||||
assertFalse(requiredReviews.isDismissStaleReviews());
|
||||
assertFalse(requiredReviews.isRequireCodeOwnerReviews());
|
||||
assertThat(protection.getRequiredReviews().getRequiredReviewers(), equalTo(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
47
src/test/java/org/kohsuke/github/GHBranchTest.java
Normal file
47
src/test/java/org/kohsuke/github/GHBranchTest.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
public class GHBranchTest extends AbstractGitHubWireMockTest {
|
||||
private static final String BRANCH_1 = "testBranch1";
|
||||
private static final String BRANCH_2 = "testBranch2";
|
||||
|
||||
private GHRepository repository;
|
||||
|
||||
@Test
|
||||
public void testMergeBranch() throws Exception {
|
||||
repository = getTempRepository();
|
||||
|
||||
String masterHead = repository.getRef("heads/master").getObject().getSha();
|
||||
createRefAndPostContent(BRANCH_1, masterHead);
|
||||
createRefAndPostContent(BRANCH_2, masterHead);
|
||||
|
||||
GHBranch otherBranch = repository.getBranch(BRANCH_2);
|
||||
String commitMessage = "merging " + BRANCH_2;
|
||||
GHCommit mergeCommit = repository.getBranch(BRANCH_1).merge(otherBranch, commitMessage);
|
||||
assertThat(mergeCommit, notNullValue());
|
||||
assertThat(mergeCommit.getCommitShortInfo().getMessage(), equalTo(commitMessage));
|
||||
|
||||
// Merging commit sha should work
|
||||
commitMessage = "merging from " + mergeCommit.getSHA1();
|
||||
GHBranch master = repository.getBranch("master");
|
||||
mergeCommit = master.merge(mergeCommit.getSHA1(), commitMessage);
|
||||
|
||||
assertThat(mergeCommit, notNullValue());
|
||||
assertThat(mergeCommit.getCommitShortInfo().getMessage(), equalTo(commitMessage));
|
||||
|
||||
mergeCommit = master.merge(mergeCommit.getSHA1(), commitMessage);
|
||||
// Should be null since all changes already merged
|
||||
assertThat(mergeCommit, nullValue());
|
||||
}
|
||||
|
||||
private void createRefAndPostContent(String branchName, String sha) throws IOException {
|
||||
String refName = "refs/heads/" + branchName;
|
||||
repository.createRef(refName, sha);
|
||||
repository.createContent().content(branchName).message(branchName).path(branchName).branch(branchName).commit();
|
||||
}
|
||||
}
|
||||
@@ -26,17 +26,22 @@ package org.kohsuke.github;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
@SuppressWarnings("deprecation") // preview
|
||||
public class GHCheckRunBuilderTest extends AbstractGitHubWireMockTest {
|
||||
public class GHCheckRunBuilderTest extends AbstractGHAppInstallationTest {
|
||||
|
||||
protected GitHub getInstallationGithub() throws IOException {
|
||||
return getAppInstallationWithTokenApp3().getRoot();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createCheckRun() throws Exception {
|
||||
GHCheckRun checkRun = gitHub.getRepository("jglick/github-api-test")
|
||||
.createCheckRun("foo", "4a929d464a2fae7ee899ce603250f7dab304bc4b")
|
||||
GHCheckRun checkRun = getInstallationGithub().getRepository("hub4j-test-org/test-checks")
|
||||
.createCheckRun("foo", "89a9ae301e35e667756034fdc933b1fc94f63fc1")
|
||||
.withStatus(GHCheckRun.Status.COMPLETED)
|
||||
.withConclusion(GHCheckRun.Conclusion.SUCCESS)
|
||||
.withDetailsURL("http://nowhere.net/stuff")
|
||||
@@ -55,7 +60,7 @@ public class GHCheckRunBuilderTest extends AbstractGitHubWireMockTest {
|
||||
.create();
|
||||
assertEquals("completed", checkRun.getStatus());
|
||||
assertEquals(1, checkRun.getOutput().getAnnotationsCount());
|
||||
assertEquals(546384586, checkRun.getId());
|
||||
assertEquals(1424883286, checkRun.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,8 +70,8 @@ public class GHCheckRunBuilderTest extends AbstractGitHubWireMockTest {
|
||||
output.add(
|
||||
new GHCheckRunBuilder.Annotation("stuff.txt", 1, GHCheckRun.AnnotationLevel.NOTICE, "hello #" + i));
|
||||
}
|
||||
GHCheckRun checkRun = gitHub.getRepository("jglick/github-api-test")
|
||||
.createCheckRun("big", "4a929d464a2fae7ee899ce603250f7dab304bc4b")
|
||||
GHCheckRun checkRun = getInstallationGithub().getRepository("hub4j-test-org/test-checks")
|
||||
.createCheckRun("big", "89a9ae301e35e667756034fdc933b1fc94f63fc1")
|
||||
.withConclusion(GHCheckRun.Conclusion.SUCCESS)
|
||||
.add(output)
|
||||
.create();
|
||||
@@ -74,37 +79,37 @@ public class GHCheckRunBuilderTest extends AbstractGitHubWireMockTest {
|
||||
assertEquals("Big Run", checkRun.getOutput().getTitle());
|
||||
assertEquals("Lots of stuff here »", checkRun.getOutput().getSummary());
|
||||
assertEquals(101, checkRun.getOutput().getAnnotationsCount());
|
||||
assertEquals(546384622, checkRun.getId());
|
||||
assertEquals(1424883599, checkRun.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createCheckRunNoAnnotations() throws Exception {
|
||||
GHCheckRun checkRun = gitHub.getRepository("jglick/github-api-test")
|
||||
.createCheckRun("quick", "4a929d464a2fae7ee899ce603250f7dab304bc4b")
|
||||
GHCheckRun checkRun = getInstallationGithub().getRepository("hub4j-test-org/test-checks")
|
||||
.createCheckRun("quick", "89a9ae301e35e667756034fdc933b1fc94f63fc1")
|
||||
.withConclusion(GHCheckRun.Conclusion.NEUTRAL)
|
||||
.add(new GHCheckRunBuilder.Output("Quick note", "nothing more to see here"))
|
||||
.create();
|
||||
assertEquals("completed", checkRun.getStatus());
|
||||
assertEquals(0, checkRun.getOutput().getAnnotationsCount());
|
||||
assertEquals(546384705, checkRun.getId());
|
||||
assertEquals(1424883957, checkRun.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPendingCheckRun() throws Exception {
|
||||
GHCheckRun checkRun = gitHub.getRepository("jglick/github-api-test")
|
||||
.createCheckRun("outstanding", "4a929d464a2fae7ee899ce603250f7dab304bc4b")
|
||||
GHCheckRun checkRun = getInstallationGithub().getRepository("hub4j-test-org/test-checks")
|
||||
.createCheckRun("outstanding", "89a9ae301e35e667756034fdc933b1fc94f63fc1")
|
||||
.withStatus(GHCheckRun.Status.IN_PROGRESS)
|
||||
.create();
|
||||
assertEquals("in_progress", checkRun.getStatus());
|
||||
assertNull(checkRun.getConclusion());
|
||||
assertEquals(546469053, checkRun.getId());
|
||||
assertEquals(1424883451, checkRun.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createCheckRunErrMissingConclusion() throws Exception {
|
||||
try {
|
||||
gitHub.getRepository("jglick/github-api-test")
|
||||
.createCheckRun("outstanding", "4a929d464a2fae7ee899ce603250f7dab304bc4b")
|
||||
getInstallationGithub().getRepository("hub4j-test-org/test-checks")
|
||||
.createCheckRun("outstanding", "89a9ae301e35e667756034fdc933b1fc94f63fc1")
|
||||
.withStatus(GHCheckRun.Status.COMPLETED)
|
||||
.create();
|
||||
fail("should have been rejected");
|
||||
@@ -114,4 +119,26 @@ public class GHCheckRunBuilderTest extends AbstractGitHubWireMockTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateCheckRun() throws Exception {
|
||||
GHCheckRun checkRun = getInstallationGithub().getRepository("hub4j-test-org/test-checks")
|
||||
.createCheckRun("foo", "89a9ae301e35e667756034fdc933b1fc94f63fc1")
|
||||
.withStatus(GHCheckRun.Status.IN_PROGRESS)
|
||||
.withStartedAt(new Date(999_999_000))
|
||||
.add(new GHCheckRunBuilder.Output("Some Title", "what happened…")
|
||||
.add(new GHCheckRunBuilder.Annotation("stuff.txt",
|
||||
1,
|
||||
GHCheckRun.AnnotationLevel.NOTICE,
|
||||
"hello to you too").withTitle("Look here")))
|
||||
.create();
|
||||
GHCheckRun updated = checkRun.update()
|
||||
.withStatus(GHCheckRun.Status.COMPLETED)
|
||||
.withConclusion(GHCheckRun.Conclusion.SUCCESS)
|
||||
.withCompletedAt(new Date(999_999_999))
|
||||
.create();
|
||||
assertEquals(updated.getStartedAt(), new Date(999_999_000));
|
||||
assertEquals(updated.getName(), "foo");
|
||||
assertEquals(1, checkRun.getOutput().getAnnotationsCount());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.Matchers.hasProperty;
|
||||
|
||||
/**
|
||||
* Integration test for {@link GHContent}.
|
||||
@@ -170,4 +171,24 @@ public class GHContentIntegrationTest extends AbstractGitHubWireMockTest {
|
||||
final GHContent fileContent2 = repo.getFileContent(fileContent.getPath());
|
||||
assertThat(IOUtils.readLines(fileContent2.read(), StandardCharsets.UTF_8), hasItems("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFileContentWithSymlink() throws Exception {
|
||||
final GHRepository repo = gitHub.getRepository("hub4j-test-org/GHContentIntegrationTest");
|
||||
|
||||
final GHContent fileContent = repo.getFileContent("ghcontent-ro/a-symlink-to-a-file");
|
||||
// for whatever reason GH says this is a file :-o
|
||||
assertThat(IOUtils.toString(fileContent.read(), StandardCharsets.UTF_8), is("thanks for reading me\n"));
|
||||
|
||||
final GHContent dirContent = repo.getFileContent("ghcontent-ro/a-symlink-to-a-dir");
|
||||
// but symlinks to directories are symlinks!
|
||||
assertThat(dirContent,
|
||||
allOf(hasProperty("target", is("a-dir-with-3-entries")), hasProperty("type", is("symlink"))));
|
||||
|
||||
// future somehow...
|
||||
|
||||
// final GHContent fileContent2 = repo.getFileContent("ghcontent-ro/a-symlink-to-a-dir/entry-one");
|
||||
// this needs special handling and will 404 from GitHub
|
||||
// assertThat(IOUtils.toString(fileContent.read(), StandardCharsets.UTF_8), is(""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.kohsuke.github;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Martin van Zijl
|
||||
@@ -10,17 +12,42 @@ import java.io.IOException;
|
||||
public class GHDeploymentTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
@Test
|
||||
public void testGetDeploymentById() throws IOException {
|
||||
GHRepository repo = getRepository();
|
||||
GHDeployment deployment = repo.getDeployment(178653229);
|
||||
public void testGetDeploymentByIdStringPayload() throws IOException {
|
||||
final GHRepository repo = getRepository();
|
||||
final GHDeployment deployment = repo.getDeployment(178653229);
|
||||
assertNotNull(deployment);
|
||||
assertEquals(178653229, deployment.getId());
|
||||
assertEquals("production", deployment.getEnvironment());
|
||||
assertEquals("custom", deployment.getPayload());
|
||||
assertEquals("custom", deployment.getPayloadObject());
|
||||
assertEquals("master", deployment.getRef());
|
||||
assertEquals("3a09d2de4a9a1322a0ba2c3e2f54a919ca8fe353", deployment.getSha());
|
||||
assertEquals("deploy", deployment.getTask());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDeploymentByIdObjectPayload() throws IOException {
|
||||
final GHRepository repo = getRepository();
|
||||
final GHDeployment deployment = repo.getDeployment(178653229);
|
||||
assertNotNull(deployment);
|
||||
assertEquals(178653229, deployment.getId());
|
||||
assertEquals("production", deployment.getEnvironment());
|
||||
assertEquals("master", deployment.getRef());
|
||||
assertEquals("3a09d2de4a9a1322a0ba2c3e2f54a919ca8fe353", deployment.getSha());
|
||||
assertEquals("deploy", deployment.getTask());
|
||||
final Map<String, Object> payload = deployment.getPayloadMap();
|
||||
assertEquals(4, payload.size());
|
||||
assertEquals(1, payload.get("custom1"));
|
||||
assertEquals("two", payload.get("custom2"));
|
||||
assertEquals(Arrays.asList("3", 3, "three"), payload.get("custom3"));
|
||||
assertNull(payload.get("custom4"));
|
||||
}
|
||||
|
||||
protected GHRepository getRepository() throws IOException {
|
||||
return getRepository(gitHub);
|
||||
}
|
||||
|
||||
private GHRepository getRepository(GitHub gitHub) throws IOException {
|
||||
private GHRepository getRepository(final GitHub gitHub) throws IOException {
|
||||
return gitHub.getOrganization("hub4j-test-org").getRepository("github-api");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ package org.kohsuke.github;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
@@ -159,6 +161,16 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
// @Test
|
||||
// public void page_build() throws Exception {}
|
||||
|
||||
@Test
|
||||
public void ping() throws Exception {
|
||||
GHEventPayload.Ping event = GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Ping.class);
|
||||
|
||||
assertThat(event.getAction(), nullValue());
|
||||
assertThat(event.getSender().getLogin(), is("seregamorph"));
|
||||
assertThat(event.getRepository().getName(), is("acme-project-project"));
|
||||
assertThat(event.getOrganization(), nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Payload("public")
|
||||
public void public_() throws Exception {
|
||||
@@ -202,6 +214,75 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(event.getSender().getLogin(), is("baxterthehacker"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pull_request_edited_base() throws Exception {
|
||||
GHEventPayload.PullRequest event = GitHub.offline()
|
||||
.parseEventPayload(payload.asReader(), GHEventPayload.PullRequest.class);
|
||||
|
||||
assertThat(event.getAction(), is("edited"));
|
||||
assertThat(event.getChanges().getTitle(), nullValue());
|
||||
assertThat(event.getPullRequest().getTitle(), is("REST-276 - easy-random"));
|
||||
assertThat(event.getChanges().getBase().getRef().getFrom(), is("develop"));
|
||||
assertThat(event.getChanges().getBase().getSha().getFrom(), is("4b0f3b9fd582b071652ccfccd10bfc8c143cff96"));
|
||||
assertThat(event.getPullRequest().getBase().getRef(), is("4.3"));
|
||||
assertThat(event.getPullRequest().getBody(), startsWith("**JIRA Ticket URL:**"));
|
||||
assertThat(event.getChanges().getBody(), nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pull_request_edited_title() throws Exception {
|
||||
GHEventPayload.PullRequest event = GitHub.offline()
|
||||
.parseEventPayload(payload.asReader(), GHEventPayload.PullRequest.class);
|
||||
|
||||
assertThat(event.getAction(), is("edited"));
|
||||
assertThat(event.getChanges().getTitle().getFrom(), is("REST-276 - easy-random"));
|
||||
assertThat(event.getPullRequest().getTitle(), is("REST-276 - easy-random 4.3.0"));
|
||||
assertThat(event.getChanges().getBase(), nullValue());
|
||||
assertThat(event.getPullRequest().getBase().getRef(), is("4.3"));
|
||||
assertThat(event.getPullRequest().getBody(), startsWith("**JIRA Ticket URL:**"));
|
||||
assertThat(event.getChanges().getBody(), nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pull_request_labeled() throws Exception {
|
||||
GHEventPayload.PullRequest event = GitHub.offline()
|
||||
.parseEventPayload(payload.asReader(), GHEventPayload.PullRequest.class);
|
||||
assertThat(event.getAction(), is("labeled"));
|
||||
assertThat(event.getNumber(), is(79));
|
||||
assertThat(event.getPullRequest().getNumber(), is(79));
|
||||
assertThat(event.getPullRequest().getTitle(), is("Base POJO test enhancement"));
|
||||
assertThat(event.getPullRequest().getBody(),
|
||||
is("This is a pretty simple change that we need to pull into develop."));
|
||||
assertThat(event.getPullRequest().getUser().getLogin(), is("seregamorph"));
|
||||
assertThat(event.getPullRequest().getHead().getUser().getLogin(), is("trilogy-group"));
|
||||
assertThat(event.getPullRequest().getHead().getRef(), is("changes"));
|
||||
assertThat(event.getPullRequest().getHead().getLabel(), is("trilogy-group:changes"));
|
||||
assertThat(event.getPullRequest().getHead().getSha(), is("4b91e3a970fb967fb7be4d52e0969f8e3fb063d0"));
|
||||
assertThat(event.getPullRequest().getBase().getUser().getLogin(), is("trilogy-group"));
|
||||
assertThat(event.getPullRequest().getBase().getRef(), is("3.10"));
|
||||
assertThat(event.getPullRequest().getBase().getLabel(), is("trilogy-group:3.10"));
|
||||
assertThat(event.getPullRequest().getBase().getSha(), is("7a735f17d686c6a1fc7df5b9d395e5863868f364"));
|
||||
assertThat(event.getPullRequest().isMerged(), is(false));
|
||||
assertThat(event.getPullRequest().getMergeable(), is(TRUE));
|
||||
assertThat(event.getPullRequest().getMergeableState(), is("draft"));
|
||||
assertThat(event.getPullRequest().getMergedBy(), nullValue());
|
||||
assertThat(event.getPullRequest().getCommentsCount(), is(1));
|
||||
assertThat(event.getPullRequest().getReviewComments(), is(14));
|
||||
assertThat(event.getPullRequest().getAdditions(), is(137));
|
||||
assertThat(event.getPullRequest().getDeletions(), is(81));
|
||||
assertThat(event.getPullRequest().getChangedFiles(), is(22));
|
||||
assertThat(event.getPullRequest().getLabels().iterator().next().getName(), is("Ready for Review"));
|
||||
assertThat(event.getRepository().getName(), is("trilogy-rest-api-framework"));
|
||||
assertThat(event.getRepository().getOwner().getLogin(), is("trilogy-group"));
|
||||
assertThat(event.getSender().getLogin(), is("schernov-xo"));
|
||||
assertThat(event.getLabel().getUrl(),
|
||||
is("https://api.github.com/repos/trilogy-group/trilogy-rest-api-framework/labels/rest%20api"));
|
||||
assertThat(event.getLabel().getName(), is("rest api"));
|
||||
assertThat(event.getLabel().getColor(), is("fef2c0"));
|
||||
assertThat(event.getLabel().getDescription(), is("REST API pull request"));
|
||||
assertThat(event.getOrganization().getLogin(), is("trilogy-group"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pull_request_review() throws Exception {
|
||||
GHEventPayload.PullRequestReview event = GitHub.offline()
|
||||
@@ -215,6 +296,8 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(event.getPullRequest().getNumber(), is(8));
|
||||
assertThat(event.getPullRequest().getTitle(), is("Add a README description"));
|
||||
assertThat(event.getPullRequest().getBody(), is("Just a few more details"));
|
||||
assertThat(event.getReview().getHtmlUrl(),
|
||||
hasToString("https://github.com/baxterthehacker/public-repo/pull/8#pullrequestreview-2626884"));
|
||||
assertThat(event.getPullRequest().getUser().getLogin(), is("skalnik"));
|
||||
assertThat(event.getPullRequest().getHead().getUser().getLogin(), is("skalnik"));
|
||||
assertThat(event.getPullRequest().getHead().getRef(), is("patch-2"));
|
||||
@@ -271,7 +354,9 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(event.getCommits().size(), is(1));
|
||||
assertThat(event.getCommits().get(0).getSha(), is("0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c"));
|
||||
assertThat(event.getCommits().get(0).getAuthor().getEmail(), is("baxterthehacker@users.noreply.github.com"));
|
||||
assertThat(event.getCommits().get(0).getAuthor().getUsername(), is("baxterthehacker"));
|
||||
assertThat(event.getCommits().get(0).getCommitter().getEmail(), is("baxterthehacker@users.noreply.github.com"));
|
||||
assertThat(event.getCommits().get(0).getCommitter().getUsername(), is("baxterthehacker"));
|
||||
assertThat(event.getCommits().get(0).getAdded().size(), is(0));
|
||||
assertThat(event.getCommits().get(0).getRemoved().size(), is(0));
|
||||
assertThat(event.getCommits().get(0).getModified().size(), is(1));
|
||||
@@ -283,6 +368,8 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(event.getPusher().getName(), is("baxterthehacker"));
|
||||
assertThat(event.getPusher().getEmail(), is("baxterthehacker@users.noreply.github.com"));
|
||||
assertThat(event.getSender().getLogin(), is("baxterthehacker"));
|
||||
assertThat(event.getCompare(),
|
||||
is("https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -349,9 +436,20 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
}
|
||||
|
||||
// TODO implement support classes and write test
|
||||
// @Test
|
||||
// public void release() throws Exception {}
|
||||
@Test
|
||||
public void release_published() throws Exception {
|
||||
GHEventPayload.Release event = GitHub.offline()
|
||||
.parseEventPayload(payload.asReader(), GHEventPayload.Release.class);
|
||||
|
||||
assertThat(event.getAction(), is("published"));
|
||||
assertThat(event.getSender().getLogin(), is("seregamorph"));
|
||||
assertThat(event.getRepository().getName(), is("company-rest-api-framework"));
|
||||
assertThat(event.getOrganization().getLogin(), is("company-group"));
|
||||
assertThat(event.getInstallation(), nullValue());
|
||||
assertThat(event.getRelease().getName(), is("4.2"));
|
||||
assertThat(event.getRelease().getTagName(), is("rest-api-framework-4.2"));
|
||||
assertThat(event.getRelease().getBody(), is("REST-269 - unique test executions (#86) Sergey Chernov"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repository() throws Exception {
|
||||
@@ -387,7 +485,25 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
@Payload("check-run")
|
||||
public void checkRunEvent() throws Exception {
|
||||
GHEventPayload.CheckRun event = GitHub.offline()
|
||||
.parseEventPayload(payload.asReader(), GHEventPayload.CheckRun.class);
|
||||
.parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub), GHEventPayload.CheckRun.class);
|
||||
GHCheckRun checkRun = verifyBasicCheckRunEvent(event);
|
||||
assertThat("pull body not populated offline", checkRun.getPullRequests().get(0).getBody(), nullValue());
|
||||
assertThat("using offline github", mockGitHub.getRequestCount(), equalTo(0));
|
||||
|
||||
gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).build();
|
||||
event = gitHub.parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub), GHEventPayload.CheckRun.class);
|
||||
checkRun = verifyBasicCheckRunEvent(event);
|
||||
|
||||
int expectedRequestCount = mockGitHub.isUseProxy() ? 3 : 2;
|
||||
assertThat("pull body should be populated",
|
||||
checkRun.getPullRequests().get(0).getBody(),
|
||||
equalTo("This is a pretty simple change that we need to pull into master."));
|
||||
assertThat("multiple getPullRequests() calls are made, the pull is populated only once",
|
||||
mockGitHub.getRequestCount(),
|
||||
equalTo(expectedRequestCount));
|
||||
}
|
||||
|
||||
private GHCheckRun verifyBasicCheckRunEvent(GHEventPayload.CheckRun event) throws IOException {
|
||||
assertThat(event.getRepository().getName(), is("Hello-World"));
|
||||
assertThat(event.getRepository().getOwner().getLogin(), is("Codertocat"));
|
||||
assertThat(event.getAction(), is("created"));
|
||||
@@ -406,9 +522,9 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(formatter.format(checkRun.getCompletedAt()), is("2019-05-15T20:22:22Z"));
|
||||
|
||||
assertThat(checkRun.getConclusion(), is("success"));
|
||||
assertThat(checkRun.getUrl().toString(),
|
||||
is("https://api.github.com/repos/Codertocat/Hello-World/check-runs/128620228"));
|
||||
assertThat(checkRun.getHtmlUrl().toString(), is("https://github.com/Codertocat/Hello-World/runs/128620228"));
|
||||
assertThat(checkRun.getUrl().toString(), endsWith("/repos/Codertocat/Hello-World/check-runs/128620228"));
|
||||
assertThat(checkRun.getHtmlUrl().toString(),
|
||||
endsWith("https://github.com/Codertocat/Hello-World/runs/128620228"));
|
||||
assertThat(checkRun.getDetailsUrl().toString(), is("https://octocoders.io"));
|
||||
assertThat(checkRun.getApp().getId(), is(29310L));
|
||||
assertThat(checkRun.getCheckSuite().getId(), is(118578147L));
|
||||
@@ -417,18 +533,41 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(checkRun.getOutput().getText(), nullValue());
|
||||
assertThat(checkRun.getOutput().getAnnotationsCount(), is(0));
|
||||
assertThat(checkRun.getOutput().getAnnotationsUrl().toString(),
|
||||
is("https://api.github.com/repos/Codertocat/Hello-World/check-runs/128620228/annotations"));
|
||||
endsWith("/repos/Codertocat/Hello-World/check-runs/128620228/annotations"));
|
||||
|
||||
// Checks the deserialization of sender
|
||||
assertThat(event.getSender().getId(), is(21031067L));
|
||||
|
||||
assertThat(checkRun.getPullRequests(), notNullValue());
|
||||
assertThat(checkRun.getPullRequests().size(), equalTo(1));
|
||||
assertThat(checkRun.getPullRequests().get(0).getNumber(), equalTo(2));
|
||||
return checkRun;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Payload("check-suite")
|
||||
public void checkSuiteEvent() throws Exception {
|
||||
GHEventPayload.CheckSuite event = GitHub.offline()
|
||||
.parseEventPayload(payload.asReader(), GHEventPayload.CheckSuite.class);
|
||||
.parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub), GHEventPayload.CheckSuite.class);
|
||||
GHCheckSuite checkSuite = verifyBasicCheckSuiteEvent(event);
|
||||
assertThat("pull body not populated offline", checkSuite.getPullRequests().get(0).getBody(), nullValue());
|
||||
assertThat("using offline github", mockGitHub.getRequestCount(), equalTo(0));
|
||||
|
||||
gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).build();
|
||||
event = gitHub.parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub),
|
||||
GHEventPayload.CheckSuite.class);
|
||||
checkSuite = verifyBasicCheckSuiteEvent(event);
|
||||
|
||||
int expectedRequestCount = mockGitHub.isUseProxy() ? 3 : 2;
|
||||
assertThat("pull body should be populated",
|
||||
checkSuite.getPullRequests().get(0).getBody(),
|
||||
equalTo("This is a pretty simple change that we need to pull into master."));
|
||||
assertThat("multiple getPullRequests() calls are made, the pull is populated only once",
|
||||
mockGitHub.getRequestCount(),
|
||||
lessThanOrEqualTo(expectedRequestCount));
|
||||
}
|
||||
|
||||
private GHCheckSuite verifyBasicCheckSuiteEvent(GHEventPayload.CheckSuite event) throws IOException {
|
||||
assertThat(event.getRepository().getName(), is("Hello-World"));
|
||||
assertThat(event.getRepository().getOwner().getLogin(), is("Codertocat"));
|
||||
assertThat(event.getAction(), is("completed"));
|
||||
@@ -445,7 +584,7 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(checkSuite.getAfter(), is("ec26c3e57ca3a959ca5aad62de7213c562f8c821"));
|
||||
assertThat(checkSuite.getLatestCheckRunsCount(), is(1));
|
||||
assertThat(checkSuite.getCheckRunsUrl().toString(),
|
||||
is("https://api.github.com/repos/Codertocat/Hello-World/check-suites/118578147/check-runs"));
|
||||
endsWith("/repos/Codertocat/Hello-World/check-suites/118578147/check-runs"));
|
||||
assertThat(checkSuite.getHeadCommit().getMessage(), is("Update README.md"));
|
||||
assertThat(checkSuite.getHeadCommit().getId(), is("ec26c3e57ca3a959ca5aad62de7213c562f8c821"));
|
||||
assertThat(checkSuite.getHeadCommit().getTreeId(), is("31b122c26a97cf9af023e9ddab94a82c6e77b0ea"));
|
||||
@@ -457,6 +596,11 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(formatter.format(checkSuite.getHeadCommit().getTimestamp()), is("2019-05-15T15:20:30Z"));
|
||||
|
||||
assertThat(checkSuite.getApp().getId(), is(29310L));
|
||||
|
||||
assertThat(checkSuite.getPullRequests(), notNullValue());
|
||||
assertThat(checkSuite.getPullRequests().size(), equalTo(1));
|
||||
assertThat(checkSuite.getPullRequests().get(0).getNumber(), equalTo(2));
|
||||
return checkSuite;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -41,7 +40,6 @@ public class GHIssueEventAttributeTest extends AbstractGitHubWireMockTest {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<GHIssueEvent> listEvents(final Type type) throws IOException {
|
||||
return StreamSupport
|
||||
.stream(gitHub.getRepository("chids/project-milestone-test").getIssue(1).listEvents().spliterator(),
|
||||
|
||||
@@ -70,6 +70,26 @@ public class GHMilestoneTest extends AbstractGitHubWireMockTest {
|
||||
assertEquals(null, issue.getMilestone());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsetMilestoneFromPullRequest() throws IOException {
|
||||
GHRepository repo = getRepository();
|
||||
GHMilestone milestone = repo.createMilestone("Unset Test Milestone", "For testUnsetMilestone");
|
||||
GHPullRequest p = repo.createPullRequest("testUnsetMilestoneFromPullRequest",
|
||||
"test/stable",
|
||||
"master",
|
||||
"## test pull request");
|
||||
|
||||
// set the milestone
|
||||
p.setMilestone(milestone);
|
||||
p = repo.getPullRequest(p.getNumber()); // force reload
|
||||
assertEquals(milestone.getNumber(), p.getMilestone().getNumber());
|
||||
|
||||
// remove the milestone
|
||||
p.setMilestone(null);
|
||||
p = repo.getPullRequest(p.getNumber()); // force reload
|
||||
assertNull(p.getMilestone());
|
||||
}
|
||||
|
||||
protected GHRepository getRepository() throws IOException {
|
||||
return getRepository(gitHub);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,12 @@ import org.kohsuke.github.GHOrganization.Permission;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
public class GHOrganizationTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
public static final String GITHUB_API_TEST = "github-api-test";
|
||||
public static final String GITHUB_API_TEMPLATE_TEST = "github-api-template-test";
|
||||
public static final String TEAM_NAME_CREATE = "create-team-test";
|
||||
|
||||
@Before
|
||||
@@ -56,6 +59,58 @@ public class GHOrganizationTest extends AbstractGitHubWireMockTest {
|
||||
Assert.assertNotNull(repository.getReadme());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateRepositoryWithParameterIsTemplate() throws IOException {
|
||||
cleanupRepository(GITHUB_API_TEST_ORG + '/' + GITHUB_API_TEMPLATE_TEST);
|
||||
|
||||
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);
|
||||
GHTeam team = org.getTeamByName("Core Developers");
|
||||
|
||||
int requestCount = mockGitHub.getRequestCount();
|
||||
GHRepository repository = org.createRepository(GITHUB_API_TEMPLATE_TEST)
|
||||
.description("a test template repository used to test kohsuke's github-api")
|
||||
.homepage("http://github-api.kohsuke.org/")
|
||||
.team(team)
|
||||
.autoInit(true)
|
||||
.templateRepository(true)
|
||||
.create();
|
||||
Assert.assertNotNull(repository);
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(requestCount + 1));
|
||||
|
||||
Assert.assertNotNull(repository.getReadme());
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(requestCount + 2));
|
||||
|
||||
// isTemplate() does not call populate() from create
|
||||
assertThat(repository.isTemplate(), equalTo(true));
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(requestCount + 2));
|
||||
|
||||
repository = org.getRepository(GITHUB_API_TEMPLATE_TEST);
|
||||
|
||||
// first isTemplate() calls populate()
|
||||
assertThat(repository.isTemplate(), equalTo(true));
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(requestCount + 4));
|
||||
|
||||
// second isTemplate() does not call populate()
|
||||
assertThat(repository.isTemplate(), equalTo(true));
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(requestCount + 4));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateRepositoryWithTemplate() throws IOException {
|
||||
cleanupRepository(GITHUB_API_TEST_ORG + '/' + GITHUB_API_TEST);
|
||||
|
||||
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);
|
||||
GHRepository repository = org.createRepository(GITHUB_API_TEST)
|
||||
.fromTemplateRepository(GITHUB_API_TEST_ORG, GITHUB_API_TEMPLATE_TEST)
|
||||
.owner(GITHUB_API_TEST_ORG)
|
||||
.create();
|
||||
|
||||
Assert.assertNotNull(repository);
|
||||
Assert.assertNotNull(repository.getReadme());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInviteUser() throws IOException {
|
||||
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);
|
||||
|
||||
@@ -211,6 +211,106 @@ public class GHPullRequestTest extends AbstractGitHubWireMockTest {
|
||||
fail();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setBaseBranch() throws Exception {
|
||||
String prName = "testSetBaseBranch";
|
||||
String originalBaseBranch = "master";
|
||||
String newBaseBranch = "gh-pages";
|
||||
|
||||
GHPullRequest pullRequest = getRepository().createPullRequest(prName, "test/stable", "master", "## test");
|
||||
|
||||
assertEquals("Pull request base branch is supposed to be " + originalBaseBranch,
|
||||
originalBaseBranch,
|
||||
pullRequest.getBase().getRef());
|
||||
|
||||
GHPullRequest responsePullRequest = pullRequest.setBaseBranch(newBaseBranch);
|
||||
|
||||
assertEquals("Pull request base branch is supposed to be " + newBaseBranch,
|
||||
newBaseBranch,
|
||||
responsePullRequest.getBase().getRef());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setBaseBranchNonExisting() throws Exception {
|
||||
String prName = "testSetBaseBranchNonExisting";
|
||||
String originalBaseBranch = "master";
|
||||
String newBaseBranch = "non-existing";
|
||||
|
||||
GHPullRequest pullRequest = getRepository().createPullRequest(prName, "test/stable", "master", "## test");
|
||||
|
||||
assertEquals("Pull request base branch is supposed to be " + originalBaseBranch,
|
||||
originalBaseBranch,
|
||||
pullRequest.getBase().getRef());
|
||||
|
||||
try {
|
||||
pullRequest.setBaseBranch(newBaseBranch);
|
||||
} catch (HttpException e) {
|
||||
assertThat(e, instanceOf(HttpException.class));
|
||||
assertThat(e.toString(), containsString("Proposed base branch 'non-existing' was not found"));
|
||||
}
|
||||
|
||||
pullRequest.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateOutdatedBranchesUnexpectedHead() throws Exception {
|
||||
String prName = "testUpdateOutdatedBranches";
|
||||
String outdatedRefName = "refs/heads/outdated";
|
||||
GHRepository repository = gitHub.getOrganization("hub4j-test-org").getRepository("updateOutdatedBranches");
|
||||
|
||||
GHRef outdatedRef = repository.getRef(outdatedRefName);
|
||||
outdatedRef.updateTo("6440189369f9f33b2366556a94dbc26f2cfdd969", true);
|
||||
|
||||
GHPullRequest outdatedPullRequest = repository.createPullRequest(prName, "outdated", "master", "## test");
|
||||
|
||||
do {
|
||||
Thread.sleep(5000);
|
||||
outdatedPullRequest.refresh();
|
||||
} while (outdatedPullRequest.getMergeableState().equalsIgnoreCase("unknown"));
|
||||
|
||||
assertEquals("Pull request is supposed to be not up to date",
|
||||
"behind",
|
||||
outdatedPullRequest.getMergeableState());
|
||||
|
||||
outdatedRef.updateTo("f567328eb81270487864963b7d7446953353f2b5", true);
|
||||
|
||||
try {
|
||||
outdatedPullRequest.updateBranch();
|
||||
} catch (HttpException e) {
|
||||
assertThat(e, instanceOf(HttpException.class));
|
||||
assertThat(e.toString(), containsString("expected head sha didn’t match current head ref."));
|
||||
}
|
||||
|
||||
outdatedPullRequest.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateOutdatedBranches() throws Exception {
|
||||
String prName = "testUpdateOutdatedBranches";
|
||||
String outdatedRefName = "refs/heads/outdated";
|
||||
GHRepository repository = gitHub.getOrganization("hub4j-test-org").getRepository("updateOutdatedBranches");
|
||||
|
||||
repository.getRef(outdatedRefName).updateTo("6440189369f9f33b2366556a94dbc26f2cfdd969", true);
|
||||
|
||||
GHPullRequest outdatedPullRequest = repository.createPullRequest(prName, "outdated", "master", "## test");
|
||||
|
||||
do {
|
||||
Thread.sleep(5000);
|
||||
outdatedPullRequest.refresh();
|
||||
} while (outdatedPullRequest.getMergeableState().equalsIgnoreCase("unknown"));
|
||||
|
||||
assertEquals("Pull request is supposed to be not up to date",
|
||||
"behind",
|
||||
outdatedPullRequest.getMergeableState());
|
||||
|
||||
outdatedPullRequest.updateBranch();
|
||||
outdatedPullRequest.refresh();
|
||||
|
||||
assertNotEquals("Pull request is supposed to be up to date", "behind", outdatedPullRequest.getMergeableState());
|
||||
|
||||
outdatedPullRequest.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void squashMerge() throws Exception {
|
||||
String name = "squashMerge";
|
||||
|
||||
@@ -3,13 +3,15 @@ package org.kohsuke.github;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
import com.fasterxml.jackson.databind.exc.ValueInstantiationException;
|
||||
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.core.IsInstanceOf.instanceOf;
|
||||
|
||||
@@ -51,13 +53,16 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
public void testGitHubRateLimit() throws Exception {
|
||||
// Customized response that templates the date to keep things working
|
||||
snapshotNotAllowed();
|
||||
GHRateLimit.UnknownLimitRecord.reset();
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(0));
|
||||
|
||||
// 4897 is just the what the limit was when the snapshot was taken
|
||||
previousLimit = GHRateLimit.fromHeaderRecord(new GHRateLimit.Record(5000,
|
||||
4897,
|
||||
(templating.testStartDate.getTime() + Duration.ofHours(1).toMillis()) / 1000L));
|
||||
previousLimit = GHRateLimit.fromRecord(
|
||||
new GHRateLimit.Record(5000,
|
||||
4897,
|
||||
(templating.testStartDate.getTime() + Duration.ofHours(1).toMillis()) / 1000L),
|
||||
RateLimitTarget.CORE);
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// /user gets response with rate limit information
|
||||
@@ -76,8 +81,8 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
// Give this a moment
|
||||
Thread.sleep(1500);
|
||||
|
||||
// ratelimit() uses headerRateLimit if available and headerRateLimit is not expired
|
||||
assertThat(gitHub.rateLimit(), equalTo(headerRateLimit));
|
||||
// ratelimit() uses cached rate limit if available and not expired
|
||||
assertThat(gitHub.rateLimit(), sameInstance(headerRateLimit));
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(1));
|
||||
|
||||
@@ -88,8 +93,13 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
rateLimit = gitHub.getRateLimit();
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(2));
|
||||
|
||||
// Because remaining and reset date are unchanged, the header should be unchanged as well
|
||||
assertThat(gitHub.lastRateLimit(), sameInstance(headerRateLimit));
|
||||
// Because remaining and reset date are unchanged in core, the header should be unchanged as well
|
||||
// But the overall instance has changed because of filling in of unknown data.
|
||||
assertThat(gitHub.lastRateLimit(), not(sameInstance(headerRateLimit)));
|
||||
// Identical Records should be preserved even when GHRateLimit is merged
|
||||
assertThat(gitHub.lastRateLimit().getCore(), sameInstance(headerRateLimit.getCore()));
|
||||
assertThat(gitHub.lastRateLimit().getSearch(), not(sameInstance(headerRateLimit.getSearch())));
|
||||
headerRateLimit = gitHub.lastRateLimit();
|
||||
|
||||
// rate limit request is free, remaining is unchanged
|
||||
verifyRateLimitValues(previousLimit, previousLimit.getRemaining());
|
||||
@@ -141,9 +151,8 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
verifyRateLimitValues(previousLimit, previousLimit.getRemaining(), true);
|
||||
previousLimit = rateLimit;
|
||||
|
||||
// When getRateLimit() succeeds, headerRateLimit updates as usual as well (if needed)
|
||||
// These are separate instances, but should be equal
|
||||
assertThat(gitHub.rateLimit(), not(sameInstance(rateLimit)));
|
||||
// When getRateLimit() succeeds, cached rate limit updates as usual as well (if needed)
|
||||
assertThat(gitHub.rateLimit(), sameInstance(rateLimit));
|
||||
|
||||
// Verify different record instances can be compared
|
||||
assertThat(gitHub.rateLimit().getCore(), equalTo(rateLimit.getCore()));
|
||||
@@ -154,8 +163,43 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
assertThat(gitHub.rateLimit(), not(sameInstance(headerRateLimit)));
|
||||
assertThat(gitHub.rateLimit(), sameInstance(gitHub.lastRateLimit()));
|
||||
headerRateLimit = gitHub.lastRateLimit();
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(5));
|
||||
|
||||
// Verify the requesting a search url updates the search rate limit
|
||||
assertThat(gitHub.lastRateLimit().getSearch().getRemaining(), equalTo(30));
|
||||
|
||||
HashMap<String, Object> searchResult = (HashMap<String, Object>) gitHub.createRequest()
|
||||
.rateLimit(RateLimitTarget.SEARCH)
|
||||
.setRawUrlPath(mockGitHub.apiServer().baseUrl()
|
||||
+ "/search/repositories?q=tetris+language%3Aassembly&sort=stars&order=desc")
|
||||
.fetch(HashMap.class);
|
||||
|
||||
assertThat(searchResult.get("total_count"), equalTo(1918));
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(6));
|
||||
|
||||
assertThat(gitHub.lastRateLimit(), not(sameInstance(headerRateLimit)));
|
||||
assertThat(gitHub.lastRateLimit().getCore(), sameInstance(headerRateLimit.getCore()));
|
||||
assertThat(gitHub.lastRateLimit().getSearch(), not(sameInstance(headerRateLimit.getSearch())));
|
||||
assertThat(gitHub.lastRateLimit().getSearch().getRemaining(), equalTo(29));
|
||||
|
||||
PagedSearchIterable<GHRepository> searchResult2 = gitHub.searchRepositories()
|
||||
.q("tetris")
|
||||
.language("assembly")
|
||||
.sort(GHRepositorySearchBuilder.Sort.STARS)
|
||||
.order(GHDirection.DESC)
|
||||
.list();
|
||||
|
||||
assertThat(searchResult2.getTotalCount(), equalTo(1918));
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(7));
|
||||
|
||||
assertThat(gitHub.lastRateLimit(), not(sameInstance(headerRateLimit)));
|
||||
assertThat(gitHub.lastRateLimit().getCore(), sameInstance(headerRateLimit.getCore()));
|
||||
assertThat(gitHub.lastRateLimit().getSearch(), not(sameInstance(headerRateLimit.getSearch())));
|
||||
assertThat(gitHub.lastRateLimit().getSearch().getRemaining(), equalTo(28));
|
||||
}
|
||||
|
||||
private void verifyRateLimitValues(GHRateLimit previousLimit, int remaining) {
|
||||
@@ -194,6 +238,8 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
|
||||
// Customized response that results in file not found the same as GitHub Enterprise
|
||||
snapshotNotAllowed();
|
||||
GHRateLimit.UnknownLimitRecord.reset();
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(0));
|
||||
GHRateLimit rateLimit = null;
|
||||
|
||||
@@ -203,13 +249,14 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
Thread.sleep(1500);
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Before any queries, rate limit starts as null but may be requested
|
||||
// Before any queries, rate limit starts as default but may be requested
|
||||
gitHub = GitHub.connectToEnterprise(mockGitHub.apiServer().baseUrl(), "bogus", "bogus");
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(0));
|
||||
|
||||
assertThat(gitHub.lastRateLimit(), CoreMatchers.nullValue());
|
||||
assertThat(gitHub.lastRateLimit(), sameInstance(GHRateLimit.DEFAULT));
|
||||
|
||||
rateLimit = gitHub.rateLimit();
|
||||
assertThat(gitHub.lastRateLimit(), not(equalTo(GHRateLimit.DEFAULT)));
|
||||
assertThat(rateLimit.getCore(), instanceOf(GHRateLimit.UnknownLimitRecord.class));
|
||||
assertThat(rateLimit.getLimit(), equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit));
|
||||
assertThat(rateLimit.getRemaining(), equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining));
|
||||
@@ -218,8 +265,8 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(1));
|
||||
|
||||
// last is still null, because it actually means lastHeaderRateLimit
|
||||
assertThat(gitHub.lastRateLimit(), CoreMatchers.nullValue());
|
||||
// lastRateLimit the same as rateLimit
|
||||
assertThat(gitHub.lastRateLimit(), sameInstance(rateLimit));
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(1));
|
||||
|
||||
@@ -233,13 +280,14 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
gitHub.getMyself();
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(2));
|
||||
|
||||
assertThat(gitHub.lastRateLimit(), CoreMatchers.nullValue());
|
||||
assertThat(gitHub.lastRateLimit(), sameInstance(GHRateLimit.DEFAULT));
|
||||
|
||||
rateLimit = gitHub.rateLimit();
|
||||
assertThat(rateLimit.getCore(), instanceOf(GHRateLimit.UnknownLimitRecord.class));
|
||||
assertThat(rateLimit.getLimit(), equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit));
|
||||
assertThat(rateLimit.getRemaining(), equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining));
|
||||
assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1));
|
||||
// Same unknown instance is reused for a while
|
||||
assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(0));
|
||||
lastReset = rateLimit.getResetDate();
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(3));
|
||||
@@ -258,17 +306,19 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(rateLimit.getCore(), instanceOf(GHRateLimit.UnknownLimitRecord.class));
|
||||
assertThat(rateLimit.getLimit(), equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit));
|
||||
assertThat(rateLimit.getRemaining(), equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining));
|
||||
assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1));
|
||||
// When not expired, unknowns do not replace each other so last reset remains unchanged
|
||||
assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(0));
|
||||
|
||||
// Give this a moment
|
||||
Thread.sleep(1500);
|
||||
|
||||
// last is still null, because it actually means lastHeaderRateLimit
|
||||
assertThat(gitHub.lastRateLimit(), CoreMatchers.nullValue());
|
||||
// lastRateLimit the same as rateLimit
|
||||
assertThat(gitHub.lastRateLimit(), sameInstance(rateLimit));
|
||||
|
||||
// ratelimit() tries not to make additional requests, uses queried rate limit since header not available
|
||||
Thread.sleep(1500);
|
||||
assertThat(gitHub.rateLimit(), sameInstance(rateLimit));
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(4));
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Some versions of GHE include header rate limit information, some do not
|
||||
@@ -282,10 +332,12 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(rateLimit, notNullValue());
|
||||
assertThat(rateLimit.getLimit(), equalTo(5000));
|
||||
assertThat(rateLimit.getRemaining(), equalTo(4978));
|
||||
// The previous record was an "Unknown", so even though this records resets sooner we take it
|
||||
assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(-1));
|
||||
assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1));
|
||||
lastReset = rateLimit.getResetDate();
|
||||
|
||||
// When getting only header updates, the unknowns are also expired
|
||||
assertThat(rateLimit.getSearch().isExpired(), is(true));
|
||||
|
||||
GHRateLimit headerRateLimit = rateLimit;
|
||||
|
||||
// Give this a moment
|
||||
@@ -320,14 +372,49 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
// getRateLimit() uses headerRateLimit if /rate_limit returns a 404
|
||||
// and headerRateLimit is available and not expired
|
||||
assertThat(rateLimit, sameInstance(gitHub.lastRateLimit()));
|
||||
headerRateLimit = rateLimit;
|
||||
|
||||
// ratelimit() should prefer headerRateLimit when getRateLimit fails and headerRateLimit is not expired
|
||||
assertThat(gitHub.rateLimit(), sameInstance(rateLimit));
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(6));
|
||||
|
||||
// Wait for the header
|
||||
Thread.sleep(1500);
|
||||
// Verify the requesting a search url updates the search rate limit
|
||||
// Core rate limit record should not change while search is updated.
|
||||
assertThat(gitHub.lastRateLimit().getSearch(), instanceOf(GHRateLimit.UnknownLimitRecord.class));
|
||||
assertThat(gitHub.lastRateLimit().getSearch().isExpired(), equalTo(true));
|
||||
|
||||
HashMap<String, Object> searchResult = (HashMap<String, Object>) gitHub.createRequest()
|
||||
.rateLimit(RateLimitTarget.SEARCH)
|
||||
.setRawUrlPath(mockGitHub.apiServer().baseUrl()
|
||||
+ "/search/repositories?q=tetris+language%3Aassembly&sort=stars&order=desc")
|
||||
.fetch(Object.class);
|
||||
|
||||
assertThat(searchResult.get("total_count"), equalTo(1918));
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(7));
|
||||
|
||||
assertThat(gitHub.lastRateLimit(), not(sameInstance(headerRateLimit)));
|
||||
assertThat(gitHub.lastRateLimit().getCore(), sameInstance(headerRateLimit.getCore()));
|
||||
assertThat(gitHub.lastRateLimit().getSearch(), not(sameInstance(headerRateLimit.getSearch())));
|
||||
assertThat(gitHub.lastRateLimit().getSearch().getRemaining(), equalTo(29));
|
||||
|
||||
PagedSearchIterable<GHRepository> searchResult2 = gitHub.searchRepositories()
|
||||
.q("tetris")
|
||||
.language("assembly")
|
||||
.sort(GHRepositorySearchBuilder.Sort.STARS)
|
||||
.order(GHDirection.DESC)
|
||||
.list();
|
||||
|
||||
assertThat(searchResult2.getTotalCount(), equalTo(1918));
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(8));
|
||||
|
||||
assertThat(gitHub.lastRateLimit(), not(sameInstance(headerRateLimit)));
|
||||
assertThat(gitHub.lastRateLimit().getCore(), sameInstance(headerRateLimit.getCore()));
|
||||
assertThat(gitHub.lastRateLimit().getSearch(), not(sameInstance(headerRateLimit.getSearch())));
|
||||
assertThat(gitHub.lastRateLimit().getSearch().getRemaining(), equalTo(28));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -372,6 +459,7 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
private void executeExpirationTest() throws Exception {
|
||||
// Customized response that templates the date to keep things working
|
||||
snapshotNotAllowed();
|
||||
GHRateLimit.UnknownLimitRecord.reset();
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(0));
|
||||
GHRateLimit rateLimit = null;
|
||||
@@ -413,15 +501,15 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
assertThat("Header instance has expired", gitHub.lastRateLimit().isExpired(), is(true));
|
||||
|
||||
assertThat("rateLimit() will ask server when header instance expires and it has not called getRateLimit() yet",
|
||||
assertThat("rateLimit() will ask server when cached instance has expired",
|
||||
gitHub.rateLimit(),
|
||||
not(sameInstance(rateLimit)));
|
||||
|
||||
assertThat("lastRateLimit() (header instance) is populated as part of internal call to getRateLimit()",
|
||||
assertThat("lastRateLimit() is populated as part of internal call to getRateLimit()",
|
||||
gitHub.lastRateLimit(),
|
||||
not(sameInstance(rateLimit)));
|
||||
|
||||
assertThat("After request, rateLimit() selects header instance since it has been refreshed",
|
||||
assertThat("After request, rateLimit() selects cached since it has been refreshed",
|
||||
gitHub.rateLimit(),
|
||||
sameInstance(gitHub.lastRateLimit()));
|
||||
|
||||
@@ -429,27 +517,27 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(2));
|
||||
|
||||
// This time, rateLimit() should find an expired header record, but a valid returned record
|
||||
// During the previous call we returned expired header info but valid returned record
|
||||
// Merging means this has already been merged into a valid cached instance
|
||||
Thread.sleep(4000);
|
||||
|
||||
rateLimit = gitHub.rateLimit();
|
||||
|
||||
// Using custom data to have a header instance that expires before the queried instance
|
||||
assertThat(
|
||||
"if header instance expires but queried instance is valid, ratelimit() uses it without asking server",
|
||||
assertThat("if valid ratelimit() uses it without asking server",
|
||||
gitHub.rateLimit(),
|
||||
not(sameInstance(gitHub.lastRateLimit())));
|
||||
sameInstance(gitHub.lastRateLimit()));
|
||||
|
||||
assertThat("ratelimit() should almost never return a return a GHRateLimit that is already expired",
|
||||
gitHub.rateLimit().isExpired(),
|
||||
is(false));
|
||||
|
||||
assertThat("Header instance hasn't been reloaded", gitHub.lastRateLimit(), sameInstance(headerRateLimit));
|
||||
assertThat("Header instance has expired", gitHub.lastRateLimit().isExpired(), is(true));
|
||||
assertThat("Cached instance hasn't been reloaded", gitHub.lastRateLimit(), sameInstance(headerRateLimit));
|
||||
assertThat("Cached instance has not expired", gitHub.lastRateLimit().isExpired(), is(false));
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(2));
|
||||
|
||||
// Finally they both expire and rateLimit() should find both expired and get a new record
|
||||
// Finally the cached instance expires and rateLimit() should get a new record
|
||||
Thread.sleep(2000);
|
||||
|
||||
headerRateLimit = gitHub.rateLimit();
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.core.IsInstanceOf.instanceOf;
|
||||
import static org.kohsuke.github.GHVerification.Reason.*;
|
||||
|
||||
/**
|
||||
* @author Liam Newman
|
||||
@@ -75,6 +76,40 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(branch.getName(), is("test/#UrlEncode"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createSignedCommitVerifyError() throws IOException {
|
||||
GHRepository repository = getRepository();
|
||||
|
||||
GHTree ghTree = new GHTreeBuilder(repository).textEntry("a", "", false).create();
|
||||
|
||||
GHVerification verification = repository.createCommit()
|
||||
.message("test signing")
|
||||
.withSignature("-----BEGIN PGP SIGNATURE-----\ninvalid\n-----END PGP SIGNATURE-----")
|
||||
.tree(ghTree.getSha())
|
||||
.create()
|
||||
.getCommitShortInfo()
|
||||
.getVerification();
|
||||
|
||||
assertEquals(GPGVERIFY_ERROR, verification.getReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createSignedCommitUnknownSignatureType() throws IOException {
|
||||
GHRepository repository = getRepository();
|
||||
|
||||
GHTree ghTree = new GHTreeBuilder(repository).textEntry("a", "", false).create();
|
||||
|
||||
GHVerification verification = repository.createCommit()
|
||||
.message("test signing")
|
||||
.withSignature("unknown")
|
||||
.tree(ghTree.getSha())
|
||||
.create()
|
||||
.getCommitShortInfo()
|
||||
.getVerification();
|
||||
|
||||
assertEquals(UNKNOWN_SIGNATURE_TYPE, verification.getReason());
|
||||
}
|
||||
|
||||
// Issue #607
|
||||
@Test
|
||||
public void getBranchNonExistentBut200Status() throws Exception {
|
||||
@@ -191,6 +226,7 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
|
||||
List<GHUser> users = new ArrayList<GHUser>();
|
||||
|
||||
users.add(user);
|
||||
users.add(gitHub.getUser("jimmysombrero2"));
|
||||
repo.addCollaborators(users, GHOrganization.Permission.PUSH);
|
||||
|
||||
GHPersonSet<GHUser> collabs = repo.getCollaborators();
|
||||
@@ -250,6 +286,26 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
|
||||
assertTrue(r.listLanguages().containsKey(mainLanguage));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listCommitCommentsNoComments() throws IOException {
|
||||
List<GHCommitComment> commitComments = getRepository()
|
||||
.listCommitComments("c413fc1e3057332b93850ea48202627d29a37de5")
|
||||
.toList();
|
||||
|
||||
assertThat("Commit has no comments", commitComments.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listCommitCommentsSomeComments() throws IOException {
|
||||
List<GHCommitComment> commitComments = getRepository()
|
||||
.listCommitComments("499d91f9f846b0087b2a20cf3648b49dc9c2eeef")
|
||||
.toList();
|
||||
|
||||
assertThat("Two comments present", commitComments.size() == 2);
|
||||
assertThat("Comment text found", commitComments.stream().anyMatch(it -> it.body.equals("comment 1")));
|
||||
assertThat("Comment text found", commitComments.stream().anyMatch(it -> it.body.equals("comment 2")));
|
||||
}
|
||||
|
||||
@Test // Issue #261
|
||||
public void listEmptyContributors() throws IOException {
|
||||
for (GHRepository.Contributor c : gitHub.getRepository(GITHUB_API_TEST_ORG + "/empty").listContributors()) {
|
||||
@@ -429,7 +485,6 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(e.getMessage(),
|
||||
containsString(
|
||||
"{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/git/refs/#get-a-reference\"}"));
|
||||
assertThat(e.getCause(), instanceOf(FileNotFoundException.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +529,6 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(e.getMessage(),
|
||||
containsString(
|
||||
"{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/git/refs/#get-a-reference\"}"));
|
||||
assertThat(e.getCause(), instanceOf(FileNotFoundException.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,8 +559,7 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(e, instanceOf(GHFileNotFoundException.class));
|
||||
assertThat(e.getMessage(),
|
||||
containsString(
|
||||
"{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/git/refs/#get-a-single-reference\"}"));
|
||||
assertThat(e.getCause(), instanceOf(FileNotFoundException.class));
|
||||
"{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/git/refs/#get-a-reference\"}"));
|
||||
}
|
||||
|
||||
// git/refs/headz
|
||||
@@ -517,8 +570,7 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(e, instanceOf(GHFileNotFoundException.class));
|
||||
assertThat(e.getMessage(),
|
||||
containsString(
|
||||
"{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/git/refs/#get-a-single-reference\"}"));
|
||||
assertThat(e.getCause(), instanceOf(FileNotFoundException.class));
|
||||
"{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/git/refs/#get-a-reference\"}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
32
src/test/java/org/kohsuke/github/GHTeamBuilderTest.java
Normal file
32
src/test/java/org/kohsuke/github/GHTeamBuilderTest.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GHTeamBuilderTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
@Test
|
||||
public void testCreateChildTeam() throws IOException {
|
||||
String parentTeamSlug = "dummy-team";
|
||||
String childTeamSlug = "dummy-team-child";
|
||||
String description = "description";
|
||||
|
||||
// Get the parent team
|
||||
GHTeam parentTeam = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug(parentTeamSlug);
|
||||
|
||||
// Create a child team, using the parent team identifier
|
||||
GHTeam childTeam = gitHub.getOrganization(GITHUB_API_TEST_ORG)
|
||||
.createTeam(childTeamSlug)
|
||||
.description(description)
|
||||
.privacy(GHTeam.Privacy.CLOSED)
|
||||
.parentTeamId(parentTeam.getId())
|
||||
.create();
|
||||
|
||||
assertEquals(description, childTeam.getDescription());
|
||||
assertEquals(childTeamSlug, childTeam.getName());
|
||||
assertEquals(childTeamSlug, childTeam.getSlug());
|
||||
assertEquals(GHTeam.Privacy.CLOSED, childTeam.getPrivacy());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import org.junit.Test;
|
||||
import org.kohsuke.github.GHTeam.Privacy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -33,6 +35,31 @@ public class GHTeamTest extends AbstractGitHubWireMockTest {
|
||||
assertEquals(description, team.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testlistMembersAdmin() throws IOException {
|
||||
String teamSlug = "dummy-team";
|
||||
|
||||
GHTeam team = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug(teamSlug);
|
||||
|
||||
List<GHUser> admins = team.listMembers("admin").asList();
|
||||
|
||||
assertNotNull(admins);
|
||||
assertThat("One admin in dummy team", admins.size() == 1);
|
||||
assertThat("Specific user in admin team",
|
||||
admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("bitwiseman")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testlistMembersNoMatch() throws IOException {
|
||||
String teamSlug = "dummy-team";
|
||||
|
||||
GHTeam team = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug(teamSlug);
|
||||
|
||||
List<GHUser> justMembers = team.listMembers("member").asList();
|
||||
|
||||
assertThat("No regular members in team", justMembers.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetPrivacy() throws IOException {
|
||||
String teamSlug = "dummy-team";
|
||||
@@ -56,4 +83,27 @@ public class GHTeamTest extends AbstractGitHubWireMockTest {
|
||||
assertEquals(privacy, team.getPrivacy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchChildTeams() throws IOException {
|
||||
String teamSlug = "dummy-team";
|
||||
|
||||
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);
|
||||
GHTeam team = org.getTeamBySlug(teamSlug);
|
||||
Set<GHTeam> result = team.listChildTeams().toSet();
|
||||
|
||||
assertEquals(1, result.size());
|
||||
assertEquals("child-team-for-dummy", result.toArray(new GHTeam[]{})[0].getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchEmptyChildTeams() throws IOException {
|
||||
String teamSlug = "simple-team";
|
||||
|
||||
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);
|
||||
GHTeam team = org.getTeamBySlug(teamSlug);
|
||||
Set<GHTeam> result = team.listChildTeams().toSet();
|
||||
|
||||
assertEquals(0, result.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@ import org.junit.Test;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Unit test for {@link GitHub} static helpers.
|
||||
@@ -20,25 +21,38 @@ public class GitHubStaticTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
@Test
|
||||
public void timeRoundTrip() throws Exception {
|
||||
Instant instantNow = Instant.now();
|
||||
final long stableInstantEpochMilli = 1533721222255L;
|
||||
Instant instantNow = Instant.ofEpochMilli(stableInstantEpochMilli);
|
||||
|
||||
Date instantSeconds = Date.from(instantNow.truncatedTo(ChronoUnit.SECONDS));
|
||||
Date instantMillis = Date.from(instantNow.truncatedTo(ChronoUnit.MILLIS));
|
||||
|
||||
// if we happen to land exactly on zero milliseconds, add 1 milli
|
||||
if (instantSeconds.equals(instantMillis)) {
|
||||
instantMillis = Date.from(instantNow.plusMillis(1).truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
String instantFormatSlash = formatZonedDate(instantMillis, "yyyy/MM/dd HH:mm:ss ZZZZ", "PST");
|
||||
assertThat(instantFormatSlash, equalTo("2018/08/08 02:40:22 -0700"));
|
||||
|
||||
// TODO: other formats
|
||||
String instantFormatSlash = formatDate(instantMillis, "yyyy/MM/dd HH:mm:ss ZZZZ");
|
||||
String instantFormatDash = formatDate(instantMillis, "yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
assertThat(instantFormatDash, equalTo("2018-08-08T09:40:22Z"));
|
||||
|
||||
String instantFormatMillis = formatDate(instantMillis, "yyyy-MM-dd'T'HH:mm:ss.S'Z'");
|
||||
assertThat(instantFormatMillis, equalTo("2018-08-08T09:40:22.255Z"));
|
||||
|
||||
String instantFormatMillisZoned = formatZonedDate(instantMillis, "yyyy-MM-dd'T'HH:mm:ss.SXXX", "PST");
|
||||
assertThat(instantFormatMillisZoned, equalTo("2018-08-08T02:40:22.255-07:00"));
|
||||
|
||||
String instantSecondsFormatMillis = formatDate(instantSeconds, "yyyy-MM-dd'T'HH:mm:ss.S'Z'");
|
||||
assertThat(instantSecondsFormatMillis, equalTo("2018-08-08T09:40:22.0Z"));
|
||||
|
||||
String instantSecondsFormatMillisZoned = formatZonedDate(instantSeconds, "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", "PST");
|
||||
assertThat(instantSecondsFormatMillisZoned, equalTo("2018-08-08T02:40:22.000-07:00"));
|
||||
|
||||
String instantBadFormat = formatDate(instantMillis, "yy-MM-dd'T'HH:mm'Z'");
|
||||
assertThat(instantBadFormat, equalTo("18-08-08T09:40Z"));
|
||||
|
||||
assertThat(GitHubClient.parseDate(GitHubClient.printDate(instantSeconds)),
|
||||
equalTo(GitHubClient.parseDate(GitHubClient.printDate(instantMillis))));
|
||||
assertThat(GitHubClient.printDate(instantSeconds), equalTo("2018-08-08T09:40:22Z"));
|
||||
assertThat(GitHubClient.printDate(GitHubClient.parseDate(instantFormatMillisZoned)),
|
||||
equalTo("2018-08-08T09:40:22Z"));
|
||||
|
||||
assertThat(instantSeconds, equalTo(GitHubClient.parseDate(GitHubClient.printDate(instantSeconds))));
|
||||
|
||||
@@ -51,82 +65,153 @@ public class GitHubStaticTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
// This parser does not truncate to the nearest second, so it will be equal
|
||||
assertThat(instantMillis, equalTo(GitHubClient.parseDate(instantFormatMillis)));
|
||||
assertThat(instantMillis, equalTo(GitHubClient.parseDate(instantFormatMillisZoned)));
|
||||
|
||||
assertThat(instantSeconds, equalTo(GitHubClient.parseDate(instantSecondsFormatMillis)));
|
||||
assertThat(instantSeconds, equalTo(GitHubClient.parseDate(instantSecondsFormatMillisZoned)));
|
||||
|
||||
try {
|
||||
GitHubClient.parseDate(instantBadFormat);
|
||||
fail("Bad time format should throw.");
|
||||
} catch (IllegalStateException e) {
|
||||
assertThat(e.getMessage(), equalTo("Unable to parse the timestamp: " + instantBadFormat));
|
||||
} catch (DateTimeParseException e) {
|
||||
assertThat(e.getMessage(), equalTo("Text '" + instantBadFormat + "' could not be parsed at index 0"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGitHubRateLimitShouldReplaceRateLimit() throws Exception {
|
||||
|
||||
GHRateLimit.Record unknown0 = GHRateLimit.Unknown().getCore();
|
||||
GHRateLimit.Record unknown1 = GHRateLimit.Unknown().getCore();
|
||||
GHRateLimit.UnknownLimitRecord.reset();
|
||||
GHRateLimit.UnknownLimitRecord.unknownLimitResetSeconds = 5;
|
||||
|
||||
GHRateLimit.Record record0 = new GHRateLimit.Record(10, 10, 10L);
|
||||
GHRateLimit.Record record1 = new GHRateLimit.Record(10, 9, 10L);
|
||||
GHRateLimit.Record record2 = new GHRateLimit.Record(10, 2, 10L);
|
||||
GHRateLimit.Record record3 = new GHRateLimit.Record(10, 10, 20L);
|
||||
GHRateLimit.Record record4 = new GHRateLimit.Record(10, 5, 20L);
|
||||
GHRateLimit.Record unknown0 = GHRateLimit.UnknownLimitRecord.current();
|
||||
|
||||
Thread.sleep(2000);
|
||||
Thread.sleep(1500);
|
||||
GHRateLimit.UnknownLimitRecord.reset();
|
||||
GHRateLimit.UnknownLimitRecord.unknownLimitResetSeconds = 5;
|
||||
|
||||
// For testing, we create an new unknown.
|
||||
GHRateLimit.Record unknown1 = GHRateLimit.UnknownLimitRecord.current();
|
||||
|
||||
assertThat("Valid unknown should not replace an existing one, regardless of created or reset time",
|
||||
unknown1.currentOrUpdated(unknown0),
|
||||
sameInstance(unknown1));
|
||||
assertThat("Valid unknown should not replace an existing one, regardless of created or reset time",
|
||||
unknown0.currentOrUpdated(unknown1),
|
||||
sameInstance(unknown0));
|
||||
|
||||
// Sleep to make different created time
|
||||
Thread.sleep(1500);
|
||||
|
||||
// To reduce object creation: There is only one valid Unknown record at a time.
|
||||
assertThat("Unknown current should should limit the creation of new unknown records",
|
||||
unknown1,
|
||||
sameInstance(GHRateLimit.UnknownLimitRecord.current()));
|
||||
|
||||
long epochSeconds = Instant.now().getEpochSecond();
|
||||
|
||||
GHRateLimit.Record record0 = new GHRateLimit.Record(10, 10, epochSeconds + 10L);
|
||||
GHRateLimit.Record record1 = new GHRateLimit.Record(10, 9, epochSeconds + 10L);
|
||||
GHRateLimit.Record record2 = new GHRateLimit.Record(10, 2, epochSeconds + 10L);
|
||||
GHRateLimit.Record record3 = new GHRateLimit.Record(10, 10, epochSeconds + 20L);
|
||||
GHRateLimit.Record record4 = new GHRateLimit.Record(10, 5, epochSeconds + 20L);
|
||||
GHRateLimit.Record recordExpired0 = new GHRateLimit.Record(10, 10, epochSeconds - 1L);
|
||||
GHRateLimit.Record recordExpired1 = new GHRateLimit.Record(10, 10, epochSeconds + 2L);
|
||||
|
||||
// Sleep to make expired and different created time
|
||||
Thread.sleep(4000);
|
||||
|
||||
GHRateLimit.Record recordWorst = new GHRateLimit.Record(Integer.MAX_VALUE, Integer.MAX_VALUE, Long.MIN_VALUE);
|
||||
GHRateLimit.Record record00 = new GHRateLimit.Record(10, 10, 10L);
|
||||
GHRateLimit.Record unknown2 = GHRateLimit.Unknown().getCore();
|
||||
GHRateLimit.Record record00 = new GHRateLimit.Record(10, 10, epochSeconds + 10L);
|
||||
|
||||
GHRateLimit.Record unknownExpired0 = unknown0;
|
||||
GHRateLimit.Record unknownExpired1 = unknown1;
|
||||
unknown0 = GHRateLimit.UnknownLimitRecord.current();
|
||||
|
||||
// Rate-limit records maybe created and returned in different orders.
|
||||
// We should update to the regular records over unknowns.
|
||||
// We should update to the unexpired regular records over unknowns.
|
||||
// After that, we should update to the candidate if its limit is lower or its reset is later.
|
||||
|
||||
assertThat("Equivalent unknown should not replace", GitHubClient.shouldReplace(unknown0, unknown1), is(false));
|
||||
assertThat("Equivalent unknown should not replace", GitHubClient.shouldReplace(unknown1, unknown0), is(false));
|
||||
assertThat("Expired unknowns should not replace another expired one, regardless of created or reset time",
|
||||
unknownExpired0.currentOrUpdated(unknownExpired1),
|
||||
sameInstance(unknownExpired0));
|
||||
assertThat("Expired unknowns should not replace another expired one, regardless of created or reset time",
|
||||
unknownExpired1.currentOrUpdated(unknownExpired0),
|
||||
sameInstance(unknownExpired1));
|
||||
|
||||
assertThat("Later unknown should replace earlier", GitHubClient.shouldReplace(unknown2, unknown0), is(true));
|
||||
assertThat("Earlier unknown should not replace later",
|
||||
GitHubClient.shouldReplace(unknown0, unknown2),
|
||||
is(false));
|
||||
assertThat("Expired unknown should not be replaced by expired earlier normal record",
|
||||
unknownExpired0.currentOrUpdated(recordExpired0),
|
||||
sameInstance(unknownExpired0));
|
||||
assertThat("Expired normal record should not be replaced an expired earlier unknown record",
|
||||
recordExpired0.currentOrUpdated(unknownExpired0),
|
||||
sameInstance(recordExpired0));
|
||||
|
||||
assertThat("Worst record should replace later unknown",
|
||||
GitHubClient.shouldReplace(recordWorst, unknown1),
|
||||
is(true));
|
||||
assertThat("Unknown should not replace worst record",
|
||||
GitHubClient.shouldReplace(unknown1, recordWorst),
|
||||
is(false));
|
||||
assertThat("Expired unknown should be replaced by expired later normal record",
|
||||
unknownExpired0.currentOrUpdated(recordExpired1),
|
||||
sameInstance(recordExpired1));
|
||||
assertThat(
|
||||
"Expired later normal record should not be replaced an expired unknown record, regardless of created or reset time",
|
||||
recordExpired1.currentOrUpdated(unknownExpired0),
|
||||
sameInstance(recordExpired1));
|
||||
|
||||
assertThat("Earlier record should replace later worst",
|
||||
GitHubClient.shouldReplace(record0, recordWorst),
|
||||
is(true));
|
||||
assertThat("Valid unknown should not be replaced by an expired unknown",
|
||||
unknown0.currentOrUpdated(unknownExpired0),
|
||||
sameInstance(unknown0));
|
||||
assertThat("Expired unknown should be replaced by valid unknown",
|
||||
unknownExpired0.currentOrUpdated(unknown0),
|
||||
sameInstance(unknown0));
|
||||
|
||||
assertThat("Valid unknown should replace an expired normal record",
|
||||
recordExpired1.currentOrUpdated(unknown0),
|
||||
sameInstance(unknown0));
|
||||
assertThat("Valid unknown record should not be replaced by expired normal record",
|
||||
unknown0.currentOrUpdated(recordExpired1),
|
||||
sameInstance(unknown0));
|
||||
|
||||
// In normal comparision, expiration doesn't matter
|
||||
assertThat("Expired normal should not be replaced by an earlier expired one",
|
||||
recordExpired1.currentOrUpdated(recordExpired0),
|
||||
sameInstance(recordExpired1));
|
||||
assertThat("Expired normal should be replaced by a later expired one",
|
||||
recordExpired0.currentOrUpdated(recordExpired1),
|
||||
sameInstance(recordExpired1));
|
||||
|
||||
assertThat("Later worst record should be replaced by earlier record",
|
||||
recordWorst.currentOrUpdated(record0),
|
||||
sameInstance(record0));
|
||||
assertThat("Later worst record should not replace earlier",
|
||||
GitHubClient.shouldReplace(recordWorst, record0),
|
||||
is(false));
|
||||
record0.currentOrUpdated(recordWorst),
|
||||
sameInstance(record0));
|
||||
|
||||
assertThat("Equivalent record should not replace", GitHubClient.shouldReplace(record0, record00), is(false));
|
||||
assertThat("Equivalent record should not replace", GitHubClient.shouldReplace(record00, record0), is(false));
|
||||
assertThat("Equivalent record should not replace other",
|
||||
record00.currentOrUpdated(record0),
|
||||
sameInstance(record00));
|
||||
assertThat("Equivalent record should not replace other",
|
||||
record0.currentOrUpdated(record00),
|
||||
sameInstance(record0));
|
||||
|
||||
assertThat("Lower limit record should replace higher", GitHubClient.shouldReplace(record1, record0), is(true));
|
||||
assertThat("Lower limit record should replace higher", GitHubClient.shouldReplace(record2, record1), is(true));
|
||||
assertThat("Higher limit record should be replaced by lower",
|
||||
record0.currentOrUpdated(record1),
|
||||
sameInstance(record1));
|
||||
assertThat("Higher limit record should be replaced by lower",
|
||||
record1.currentOrUpdated(record2),
|
||||
sameInstance(record2));
|
||||
|
||||
assertThat("Higher limit record should not replace lower",
|
||||
GitHubClient.shouldReplace(record1, record2),
|
||||
is(false));
|
||||
assertThat("Lower limit record should not be replaced higher",
|
||||
record2.currentOrUpdated(record1),
|
||||
sameInstance(record2));
|
||||
|
||||
assertThat("Higher limit record with later reset should replace lower",
|
||||
GitHubClient.shouldReplace(record3, record2),
|
||||
is(true));
|
||||
assertThat("Lower limit record should be replaced by higher limit record with later reset",
|
||||
record2.currentOrUpdated(record3),
|
||||
sameInstance(record3));
|
||||
|
||||
assertThat("Lower limit record with later reset should replace higher",
|
||||
GitHubClient.shouldReplace(record4, record1),
|
||||
is(true));
|
||||
assertThat("Higher limit record should be replaced by lower limit record with later reset",
|
||||
record1.currentOrUpdated(record4),
|
||||
sameInstance(record4));
|
||||
|
||||
assertThat("Lower limit record with earlier reset should not replace higher",
|
||||
GitHubClient.shouldReplace(record2, record4),
|
||||
is(false));
|
||||
assertThat("Higher limit record should not be replaced by lower limit record with earlier reset",
|
||||
record4.currentOrUpdated(record2),
|
||||
sameInstance(record4));
|
||||
|
||||
}
|
||||
|
||||
@@ -157,8 +242,12 @@ public class GitHubStaticTest extends AbstractGitHubWireMockTest {
|
||||
}
|
||||
|
||||
static String formatDate(Date dt, String format) {
|
||||
return formatZonedDate(dt, format, "GMT");
|
||||
}
|
||||
|
||||
static String formatZonedDate(Date dt, String format, String timeZone) {
|
||||
SimpleDateFormat df = new SimpleDateFormat(format);
|
||||
df.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
df.setTimeZone(TimeZone.getTimeZone(timeZone));
|
||||
return df.format(dt);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ public class LifecycleTest extends AbstractGitHubWireMockTest {
|
||||
private GHAsset uploadAsset(GHRelease release) throws IOException {
|
||||
GHAsset asset = release.uploadAsset(new File("LICENSE.txt"), "application/text");
|
||||
assertNotNull(asset);
|
||||
List<GHAsset> cachedAssets = release.assets();
|
||||
assertEquals(0, cachedAssets.size());
|
||||
List<GHAsset> assets = release.getAssets();
|
||||
assertEquals(1, assets.size());
|
||||
assertEquals("LICENSE.txt", assets.get(0).getName());
|
||||
|
||||
@@ -32,6 +32,7 @@ public class RateLimitCheckerTest extends AbstractGitHubWireMockTest {
|
||||
public void testGitHubRateLimit() throws Exception {
|
||||
// Customized response that templates the date to keep things working
|
||||
snapshotNotAllowed();
|
||||
GHRateLimit.UnknownLimitRecord.reset();
|
||||
|
||||
assertThat(mockGitHub.getRequestCount(), equalTo(0));
|
||||
|
||||
@@ -45,7 +46,7 @@ public class RateLimitCheckerTest extends AbstractGitHubWireMockTest {
|
||||
.withEndpoint(mockGitHub.apiServer().baseUrl())
|
||||
.build();
|
||||
|
||||
assertThat(gitHub.lastRateLimit(), nullValue());
|
||||
assertThat(gitHub.lastRateLimit(), sameInstance(GHRateLimit.DEFAULT));
|
||||
|
||||
// Checks the rate limit before getting myself
|
||||
gitHub.getMyself();
|
||||
|
||||
@@ -2,9 +2,13 @@ package org.kohsuke.github;
|
||||
|
||||
import com.github.tomakehurst.wiremock.http.Fault;
|
||||
import com.github.tomakehurst.wiremock.stubbing.Scenario;
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.kohsuke.github.extras.ImpatientHttpConnector;
|
||||
import org.kohsuke.github.extras.okhttp3.OkHttpConnector;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -20,6 +24,7 @@ import java.net.URL;
|
||||
import java.security.Permission;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.SimpleFormatter;
|
||||
import java.util.logging.StreamHandler;
|
||||
@@ -57,7 +62,8 @@ public class RequesterRetryTest extends AbstractGitHubWireMockTest {
|
||||
public void attachLogCapturer() {
|
||||
logCapturingStream = new ByteArrayOutputStream();
|
||||
customLogHandler = new StreamHandler(logCapturingStream, new SimpleFormatter());
|
||||
log.addHandler(customLogHandler);
|
||||
Logger.getLogger(GitHubClient.class.getName()).addHandler(customLogHandler);
|
||||
Logger.getLogger(OkHttpClient.class.getName()).addHandler(customLogHandler);
|
||||
}
|
||||
|
||||
public String getTestCapturedLog() throws IOException {
|
||||
@@ -66,11 +72,40 @@ public class RequesterRetryTest extends AbstractGitHubWireMockTest {
|
||||
}
|
||||
|
||||
public void resetTestCapturedLog() throws IOException {
|
||||
log.removeHandler(customLogHandler);
|
||||
Logger.getLogger(GitHubClient.class.getName()).removeHandler(customLogHandler);
|
||||
Logger.getLogger(OkHttpClient.class.getName()).removeHandler(customLogHandler);
|
||||
customLogHandler.close();
|
||||
attachLogCapturer();
|
||||
}
|
||||
|
||||
@Ignore("Used okhttp3 and this to verify connection closing. To variable for CI system.")
|
||||
@Test
|
||||
public void testGitHubIsApiUrlValid() throws Exception {
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectionPool(new ConnectionPool(2, 100, TimeUnit.MILLISECONDS))
|
||||
.build();
|
||||
|
||||
OkHttpConnector connector = new OkHttpConnector(client);
|
||||
|
||||
for (int x = 0; x < 100; x++) {
|
||||
|
||||
this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl())
|
||||
.withConnector(connector)
|
||||
.build();
|
||||
|
||||
try {
|
||||
gitHub.checkApiUrlValidity();
|
||||
} catch (IOException ioe) {
|
||||
assertTrue(ioe.getMessage().contains("private mode enabled"));
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
String capturedLog = getTestCapturedLog();
|
||||
assertThat(capturedLog, not(containsString("leaked")));
|
||||
}
|
||||
|
||||
// Issue #539
|
||||
@Test
|
||||
public void testSocketConnectionAndRetry() throws Exception {
|
||||
|
||||
@@ -125,7 +125,7 @@ public class WireMockStatusReporterTest extends AbstractGitHubWireMockTest {
|
||||
assertThat(e, Matchers.<Exception>instanceOf(GHFileNotFoundException.class));
|
||||
assertThat(e.getMessage(),
|
||||
containsString(
|
||||
"{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/#get\"}"));
|
||||
"{\"message\":\"Not Found\",\"documentation_url\":\"https://docs.github.com/rest/reference/repos#get-a-repository\"}"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.kohsuke.github.junit;
|
||||
|
||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||
import com.github.tomakehurst.wiremock.admin.model.*;
|
||||
import com.github.tomakehurst.wiremock.client.CountMatchingStrategy;
|
||||
import com.github.tomakehurst.wiremock.client.MappingBuilder;
|
||||
import com.github.tomakehurst.wiremock.client.VerificationException;
|
||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||
@@ -221,6 +222,10 @@ public class WireMockRule implements MethodRule, TestRule, Container, Stubbing,
|
||||
wireMockServer.verify(count, requestPatternBuilder);
|
||||
}
|
||||
|
||||
public void verify(CountMatchingStrategy countMatchingStrategy, RequestPatternBuilder requestPatternBuilder) {
|
||||
wireMockServer.verify(countMatchingStrategy, requestPatternBuilder);
|
||||
}
|
||||
|
||||
public List<LoggedRequest> findAll(RequestPatternBuilder requestPatternBuilder) {
|
||||
return wireMockServer.findAll(requestPatternBuilder);
|
||||
}
|
||||
|
||||
@@ -109,6 +109,10 @@ public class WireMockRuleConfiguration implements Options {
|
||||
return parent.browserProxyingEnabled();
|
||||
}
|
||||
|
||||
public BrowserProxySettings browserProxySettings() {
|
||||
return parent.browserProxySettings();
|
||||
}
|
||||
|
||||
public ProxySettings proxyVia() {
|
||||
return parent.proxyVia();
|
||||
}
|
||||
@@ -180,4 +184,8 @@ public class WireMockRuleConfiguration implements Options {
|
||||
public boolean getStubRequestLoggingDisabled() {
|
||||
return parent.getStubRequestLoggingDisabled();
|
||||
}
|
||||
|
||||
public boolean getStubCorsEnabled() {
|
||||
return parent.getStubCorsEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
28
src/test/resources/ghapi-test-app-1.private-key.pem
Normal file
28
src/test/resources/ghapi-test-app-1.private-key.pem
Normal file
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDG98AU2pNVCCp/
|
||||
THwEqlDUZ8GRKY9TO52x+3FPTnx69D63f4k44N0DOCEk4q1mKQ0QYy6rgQcyWtwd
|
||||
GYRpgP/KU5Q3ozEnHUJ82d5HgOCMcYdpqaOb9wJRmj0s9cibDd7TmGBv0DTx5KZi
|
||||
ilqv1mYFbeIC/eVv/id0aG6PMef1+fJeGplQQ1mfdvQP/6ftxsVBHyIhYvZLLGLL
|
||||
FrcONmKTJ9Iy4F4M64PE7YkNVIEMu2cVpIxkHiZuTamr3DPgm4nRp2qe3EA2bLRA
|
||||
Zp4Q+WJmJsVgaDRqJYe8U2IVO72eHdWjoG/lV9HOfc+eH4ns8ZnRNtTnH67DnocT
|
||||
+GAbZp0NAgMBAAECggEARlWIGhcWI+XqF+vynzeRsTQoUedOGg8l9Ke861sEV/aF
|
||||
QRqdaHTcy+mIleBniYiTbKqS8d9/qsZBryu5Cg6m3V/kMjLHClumiDoAAGjHd/4d
|
||||
7zUfd9++exg57e3Ihz9E+KmR1ZTVUnkQdB8SZbw1fk/UqFgWRhui2Nyd0JLEu8eK
|
||||
QTE7MMs3w8Iv8FtC7BJBrEW2uc0h/f5gV4XrS2PR+YFKlFDN566+TILS2Q3h1h6p
|
||||
yqriZygLTQc/z0nqB098KgRcNr3LtCTlaSBBKfFEwG5Glj9QybfEuP6PihrYOFN1
|
||||
SeDCI+/b/WNDsspBheks/AYy6zVSPsWxWoHXhLxSQQKBgQD2Q4FtH6n8gqFMmFX3
|
||||
74Suvoi1YKKbeFjloQ4Pu3rPdEKuza5lgfw+YlO/nMDnQF0b+mogRD2Xs23CIub5
|
||||
RS3TZuhxkdz7VhPRwKHuYs7D5oa3BGAgRyEjG0JIZePNHO1kUSkIRrF4FXFgGpQ8
|
||||
ghdDtodXbrMjZNak8bIq6X/zkQKBgQDO1Y0ifMv3rAu0PEbfnaqXrl09c892cpjP
|
||||
A57T7e53x2WKaNwQbYixNdAbDtGEKXjIHRaV9csG1XSQh+OchT7BSOpgIDxFtK5l
|
||||
aRuov+tcMInjojZjwMv87Pet0QrZhLIZU1883q+LiM/HtHPtgsem0AzovcLoY8mH
|
||||
RuR37oebvQKBgA54ewN5h9iRqH7CuNJ/3ZETGx9lVUjDcp3Tr+rWvmmwUDbLWUMX
|
||||
t0XHK1qoEGHGU3JQbaoFuITQg1OUD3R4TzAL7P63bn/KWBHMOveyEKpMQoBAnpFm
|
||||
/Jh+go+UhSVJXN23My0MUmNXBzl5dlpz3oAZGqzVkWs0ArTgivKgk+cxAoGAGp7r
|
||||
ulubmPYAz6LOcGuHkFw1zfoA4rrfJg3OPHKsNahpTkYuxMKETGKjtUfT+ZGo5QCx
|
||||
bn2jMu74QL3ssrGHoTL0T4j2mPYnWBAOKksBTO1GYhD3tSEUYCpTuoBkSBjHH3FW
|
||||
mawDpg7mx0pXfWNOtQ6kCrSZyHVHc+zQ7Qq7U3UCgYBAZEnFW3MIwAizcioEmc53
|
||||
TJuWSvdvRsfJRNqFSpPxj5xfY9HfgpPceRlh4+jwG1bRWzt4MQKh4DyFvi06NhD7
|
||||
MnYhTX+P1jIyzV5SU8GUud/r6TFwhOWpW3zqaTCep5+VIS5W2rR322NQAZmD2u1+
|
||||
h+U8DZTYFDiNzmsHem2tNA==
|
||||
-----END PRIVATE KEY-----
|
||||
28
src/test/resources/ghapi-test-app-2.private-key.pem
Normal file
28
src/test/resources/ghapi-test-app-2.private-key.pem
Normal file
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDYm8i4enZxXwQR
|
||||
rfyBkKIroJIMGw3JSG+JPaxvcxpp6GpGOqmGsEQwzEOeuxX705CeTjpZ6/5xOCYV
|
||||
kNLmwTBG/wGpsjGLY1kV6FAC1jHkFIBWSxkmQaZRsK+MhQtREd81uMa1wA/2j3II
|
||||
AUNd0aVWLRlGte2RlDq16mvnqlgzfKB40TgC0Rww2OdoEYsVJ0tph9JvpVgGSMJD
|
||||
Irr3ZVn5hwpJBliC+obst8lIJw1JfEoYT8jU6QvfgViMzRhKNNPy22fCazfxsk1m
|
||||
+uh7c3tM0I8jnaNFkHgRXPzuXFrcgyixXczHThEP+bifWtsBRPYSVy5/RAGDIzXO
|
||||
e3npKTS1AgMBAAECggEBAMXhs4IMpm21zsLT/ozi87QFccbLZFHQ8cwf4orCTYwZ
|
||||
PhVAfCTGnNUzlkbJRTEUutZUQuxpMr59/BTRhEo4jQEe74b2elqLfRQNciLVSSjD
|
||||
Lecnnicb7HROhGFMHeWG/TJXxni9qBeoPhVgCgoIfxH2C1RU2V6YWvZb3Q37ya3l
|
||||
6kCoRfHkSBTkAySdlZDEfYCmIyx6KPIzLFX3VI/T1CAcSuTJnHe+7gdiX4ngq4Ee
|
||||
ZPppHLo76kyQjd05reGTtLq40utIfzHkSgh5nLHMnU+O3xNyyPZbZE1Gp8czgaBe
|
||||
AoAMCPfwY7l1fBy4RQ1TE2FT9sRksNO6VuV+AT4fwzUCgYEA/dVvhT8hVVldLwgn
|
||||
EObgyU35NLyHWba3AanhETI+bCERq1sUXd5LMVPCRJoT/i+zNRMhELmMeVxMYEqW
|
||||
hzBF9XoE6ONqJ7pdRh9brysfKOye0goOXWr2XKZL8mO8utWsV6ehYiKLvgrAjEDR
|
||||
rToknzp8jIQqPaiheWZZIjFvdCMCgYEA2nUFQGss5Iy3FyNLQITwNRgzu75XAYML
|
||||
wM69iW5eF5dNF5p/6kcu12pgSW2mMI9rSVPiMqJqig2F5sIsqvBxIKS1yWuWn1CO
|
||||
wdP3O7GVHiDXpdra0j8z8PBhJ0jRHED5q259dXC0BvqqU8U8cOFxlgr96ZZP+TS3
|
||||
2Tw/RRzkdUcCgYBpcjXuu4gEZahBNnjMG6070wl4b+0mRrIFneWieCXYU3B8p8xx
|
||||
JjxEVJA6YWt2x6gBn124DeyeKcqMoc+gf1xAmpzZhkd+E3xV+gbjYN2D6bAcfxLy
|
||||
mdGYMXkRS3+GeecrTrbLBqDYpKzSVscD2EiIYQqGcQz/KkNSJENY4gJz0wKBgQCX
|
||||
6eR7BYy0an4v4uVDuq5n3aqsFhLfBEg6DgqT9WINObPshA4L1vBl8J2AsnVtM27C
|
||||
EUktOPCpi/nfnIv/WzDwKFoZ9W1K4HRFqac1paoyx1fvCCA/MKBoHmERNnvkD/MP
|
||||
Gci40GUArXOgyXncbYnVc1NbCqIWhGiM8m51G0BrpQKBgAffan4sPiNnWeQlvbAj
|
||||
kW1GkGCIOqMHVgjOxVlDGri/GLwAt1zOxHT7i9nQb6wpE0fAb05ydjPOuA7iIeG4
|
||||
jZdQWfY6QIhlYkDq7JiRCkcQ3auMzplSV17rDSiBL+ttOY8tLdX5fJVmeGdq7Gs1
|
||||
YPW1uoYsHNTFWew5Ae31KaLn
|
||||
-----END PRIVATE KEY-----
|
||||
28
src/test/resources/ghapi-test-app-3.private-key.pem
Normal file
28
src/test/resources/ghapi-test-app-3.private-key.pem
Normal file
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC4vG2q4zLRcQGe
|
||||
5Z4seo8LY2hROKkdy4LmA96TeCxwDd/bnFIIQGmWMZHVZkyruuLLArTt50/mJ4yC
|
||||
ggedRiw8CmH8s6iQmZQyRu+6gKVqm5KozQ2omniGAJU6KqZTbUUpvytpmmcWcoLU
|
||||
eMoLCJTScRK2rofbiSCFy1WwlyVe1b+nBNf2b9VG9bE461K47kgk1cI1/TqZ3QeI
|
||||
jc/0jV+w7qdTdCqD5A2FyFZa5mU6jj83bVyC0O0AlZlEnwHN58vvN3j7uljF6Mh0
|
||||
sx+0xtRjmTncl7puUhpQBJrH/pIfjuY5MAefMaOAhXMZM3lZyh75URlO3vh1KKwQ
|
||||
EJcdCi+FAgMBAAECggEARDIDBf+DJf/iikbXgjHoFlsnCjyxaXdUJhctliDZvq/Q
|
||||
gKCPQ86La892t2FhUk/WIv0nz18BhsP4wcDAkNVzxOJMU936jw6yv3CiVKXi6pzt
|
||||
ofS4YxJLBaS3cdaGuetvib6xhvVhss6o70h7xWDwl1L4homdS3SuldV/F4ZkXEJI
|
||||
v5uyh0TFy44dSS01muJQfZHXGF7Pvqx18CY8p/NSOKTYJRghSI3GiLOD7S12GHi1
|
||||
dBVp3D9roXCFUG0zijIIntcWnQGoCr71GwQHlwg0hPz3v/lOQZBB814+j5tUKw78
|
||||
zrXAAIb9yQbsNkmY5rVm69kg+ixG0uq9JVqJmkBvrQKBgQDrmJGuQrfuzE5PoYJC
|
||||
SYNOzjjTgTc3mCW6mqBTmngOUV/DEX5aLVzMxaHCIuslNjB1Ila6Hg4Am2SFFiUj
|
||||
OSVZPBe/A+EGU6itxwCzTj7M4jQtVfWRsq8IjaLm0A222RhDp9D/Zc5/T6563obW
|
||||
n4GT/HOM95CvoYvjdcULPOqWVwKBgQDIvDylKw3dRQm3q2IX34JjFMrJM+wzDXAv
|
||||
lIsURQFI/jezos95CGS0ArgG0gNn0117ul++N1Tt44YFDOqbG9kzS9ccYukRIe+v
|
||||
knVkogtXPwLoWR8amOyK2SP7P2DSkrZsE3HRRWhzNARs8RTfa5stp9eKKyrYyXAF
|
||||
28RC7agngwKBgQDEKCWzd615T/Yr6wdvdZG0fZNm1oFI8o8HTVMMCOLI2QvoeJpB
|
||||
Lt/DRxGleDlcpD+4ZzzafceezcLl5EhLiXsFTzleOzaSc/lPpw94Oz+iivxyes2Z
|
||||
37JIZtUpZDTm9t5zBjjHTNafvZJCjyCpdekHc/wpdL6s3M6CNj43WyLexQKBgCDL
|
||||
eBD39rzmsY67RjxmPLQZSoQSoo04rdJoL0yxdWNKfSkw+Tpp36H1K8GZgArvYj97
|
||||
lHbMLWjsGhIrKQ0MQLD7u/ocQr2U0MbbY6h8POQVHFF/dfBveX25ugIrOZNNetYv
|
||||
WxH4h/cCUZLG1EUoHGMaH8GoCcj/J/kdDXRtxWInAoGAQbJ/6Ry5+cLGYgt6e/7Z
|
||||
33wvwVjRmeZxAiE+msdKqXljGmxHKvat3l4eURh1CSqJ5tw0+J/LzXF2WrK8ncQj
|
||||
d3S4tPQW7yMBxXhJuFNczowmB8QiXFQCAdFe9sMRYyRe7EHJSNYEFjPuPDEVIfwO
|
||||
nqEDUjQ6neGvMei09uX1eVk=
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -2,7 +2,7 @@
|
||||
"id": "257aa346-b2fa-4808-a587-ce26a6859bf7",
|
||||
"name": "repos_jenkinsci_jenkins_git_refs_heads_master",
|
||||
"request": {
|
||||
"url": "/repos/jenkinsci/jenkins/git/ref/heads/master",
|
||||
"url": "/repos/jenkinsci/jenkins/git/refs/heads/master",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"login": "hub4j-test-org",
|
||||
"id": 7544739,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
|
||||
"url": "https://api.github.com/orgs/hub4j-test-org",
|
||||
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
|
||||
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
|
||||
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
|
||||
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
|
||||
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
|
||||
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
|
||||
"description": "Hub4j Test Org Description (this could be null or blank too)",
|
||||
"name": "Hub4j Test Org Name (this could be null or blank too)",
|
||||
"company": null,
|
||||
"blog": "https://hub4j.url.io/could/be/null",
|
||||
"location": "Hub4j Test Org Location (this could be null or blank too)",
|
||||
"email": "hub4jtestorgemail@could.be.null.com",
|
||||
"twitter_username": null,
|
||||
"is_verified": false,
|
||||
"has_organization_projects": true,
|
||||
"has_repository_projects": true,
|
||||
"public_repos": 13,
|
||||
"public_gists": 0,
|
||||
"followers": 0,
|
||||
"following": 0,
|
||||
"html_url": "https://github.com/hub4j-test-org",
|
||||
"created_at": "2014-05-10T19:39:11Z",
|
||||
"updated_at": "2020-06-04T05:56:10Z",
|
||||
"type": "Organization",
|
||||
"total_private_repos": 1,
|
||||
"owned_private_repos": 1,
|
||||
"private_gists": 0,
|
||||
"disk_usage": 149,
|
||||
"collaborators": 0,
|
||||
"billing_email": "kk@kohsuke.org",
|
||||
"default_repository_permission": "none",
|
||||
"members_can_create_repositories": false,
|
||||
"two_factor_requirement_enabled": false,
|
||||
"plan": {
|
||||
"name": "free",
|
||||
"space": 976562499,
|
||||
"private_repos": 10000,
|
||||
"filled_seats": 18,
|
||||
"seats": 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"id": 292666372,
|
||||
"node_id": "MDEwOlJlcG9zaXRvcnkyOTI2NjYzNzI=",
|
||||
"name": "listPrsListHeads",
|
||||
"full_name": "hub4j-test-org/listPrsListHeads",
|
||||
"private": true,
|
||||
"owner": {
|
||||
"login": "hub4j-test-org",
|
||||
"id": 7544739,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/hub4j-test-org",
|
||||
"html_url": "https://github.com/hub4j-test-org",
|
||||
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
|
||||
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
|
||||
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
|
||||
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"html_url": "https://github.com/hub4j-test-org/listPrsListHeads",
|
||||
"description": null,
|
||||
"fork": false,
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads",
|
||||
"forks_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/forks",
|
||||
"keys_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/teams",
|
||||
"hooks_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/events",
|
||||
"assignees_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/tags",
|
||||
"blobs_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/subscription",
|
||||
"commits_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/merges",
|
||||
"archive_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/downloads",
|
||||
"issues_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/releases{/id}",
|
||||
"deployments_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/deployments",
|
||||
"created_at": "2020-09-03T19:52:43Z",
|
||||
"updated_at": "2020-09-03T19:52:47Z",
|
||||
"pushed_at": "2020-09-03T20:10:17Z",
|
||||
"git_url": "git://github.com/hub4j-test-org/listPrsListHeads.git",
|
||||
"ssh_url": "git@github.com:hub4j-test-org/listPrsListHeads.git",
|
||||
"clone_url": "https://github.com/hub4j-test-org/listPrsListHeads.git",
|
||||
"svn_url": "https://github.com/hub4j-test-org/listPrsListHeads",
|
||||
"homepage": null,
|
||||
"size": 0,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": null,
|
||||
"has_issues": true,
|
||||
"has_projects": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"archived": false,
|
||||
"disabled": false,
|
||||
"open_issues_count": 2,
|
||||
"license": null,
|
||||
"forks": 0,
|
||||
"open_issues": 2,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"permissions": {
|
||||
"admin": true,
|
||||
"push": true,
|
||||
"pull": true
|
||||
},
|
||||
"temp_clone_token": "AOXG3USV2CAWD4FHBELB7RS7KFIGU",
|
||||
"allow_squash_merge": true,
|
||||
"allow_merge_commit": true,
|
||||
"allow_rebase_merge": true,
|
||||
"delete_branch_on_merge": false,
|
||||
"organization": {
|
||||
"login": "hub4j-test-org",
|
||||
"id": 7544739,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/hub4j-test-org",
|
||||
"html_url": "https://github.com/hub4j-test-org",
|
||||
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
|
||||
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
|
||||
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
|
||||
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"network_count": 0,
|
||||
"subscribers_count": 7
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"sha": "ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"node_id": "MDY6Q29tbWl0MjkyNjY2MzcyOmFiOTJlMTNjMGZjODQ0ZmQ1MWEzNzlhNDhhM2FkMGIxODIzMTIxNWM=",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "Tadas Giniotis",
|
||||
"email": "61763026+tginiotis-at-work@users.noreply.github.com",
|
||||
"date": "2020-09-03T19:52:44Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "GitHub",
|
||||
"email": "noreply@github.com",
|
||||
"date": "2020-09-03T19:52:44Z"
|
||||
},
|
||||
"message": "Initial commit",
|
||||
"tree": {
|
||||
"sha": "aef4c126549f4900bec20cd8ea5a6546f9d72342",
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/trees/aef4c126549f4900bec20cd8ea5a6546f9d72342"
|
||||
},
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": true,
|
||||
"reason": "valid",
|
||||
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJfUUmMCRBK7hj4Ov3rIwAAdHIIAANckXa7twOvglP8Ro+QhRXJ\nQ68XvpHa/tP+Q1wn/ATZcaNMfwLzVD4EUksmct5PfpBiqSGIsoCDmVsNcEd88hum\nYjDSWBGlD3pOedlGXJtW+y//yUIZRmfaZP69sehrkN7JTOfhdEDFlsfhoJDgsrYh\n5KoD4/pmWMiG4NvCMZ265BeMXHw7KSFLAD4vSlBVo/kBJe2IQyW1GvGemZa5fwbk\nBS77fQcxZlv6w7EC9NvWlPc7nxHfS4C5shbB1Cm6nMPaz73PcrH3cWLz2A7esdrU\nhxaCiZ9uF+iqQUQVbzQ8s5r3Hiz1cWsFH2qND/RAaqpLlkLzH43/SyVyiwCmqlM=\n=649h\n-----END PGP SIGNATURE-----\n",
|
||||
"payload": "tree aef4c126549f4900bec20cd8ea5a6546f9d72342\nauthor Tadas Giniotis <61763026+tginiotis-at-work@users.noreply.github.com> 1599162764 +0300\ncommitter GitHub <noreply@github.com> 1599162764 +0300\n\nInitial commit"
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"html_url": "https://github.com/hub4j-test-org/listPrsListHeads/commit/ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"comments_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c/comments",
|
||||
"author": {
|
||||
"login": "tginiotis-at-work",
|
||||
"id": 61763026,
|
||||
"node_id": "MDQ6VXNlcjYxNzYzMDI2",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/61763026?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/tginiotis-at-work",
|
||||
"html_url": "https://github.com/tginiotis-at-work",
|
||||
"followers_url": "https://api.github.com/users/tginiotis-at-work/followers",
|
||||
"following_url": "https://api.github.com/users/tginiotis-at-work/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/tginiotis-at-work/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/tginiotis-at-work/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/tginiotis-at-work/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/tginiotis-at-work/orgs",
|
||||
"repos_url": "https://api.github.com/users/tginiotis-at-work/repos",
|
||||
"events_url": "https://api.github.com/users/tginiotis-at-work/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/tginiotis-at-work/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"committer": {
|
||||
"login": "web-flow",
|
||||
"id": 19864447,
|
||||
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/web-flow",
|
||||
"html_url": "https://github.com/web-flow",
|
||||
"followers_url": "https://api.github.com/users/web-flow/followers",
|
||||
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/web-flow/orgs",
|
||||
"repos_url": "https://api.github.com/users/web-flow/repos",
|
||||
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/web-flow/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"parents": [],
|
||||
"stats": {
|
||||
"total": 1,
|
||||
"additions": 1,
|
||||
"deletions": 0
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"sha": "c0fa81448132f7f9eb303a93d9047fe5fafbfcd9",
|
||||
"filename": "README.md",
|
||||
"status": "added",
|
||||
"additions": 1,
|
||||
"deletions": 0,
|
||||
"changes": 1,
|
||||
"blob_url": "https://github.com/hub4j-test-org/listPrsListHeads/blob/ab92e13c0fc844fd51a379a48a3ad0b18231215c/README.md",
|
||||
"raw_url": "https://github.com/hub4j-test-org/listPrsListHeads/raw/ab92e13c0fc844fd51a379a48a3ad0b18231215c/README.md",
|
||||
"contents_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/contents/README.md?ref=ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"patch": "@@ -0,0 +1 @@\n+# listPrsListHeads\n\\ No newline at end of file"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"name": "master",
|
||||
"commit": {
|
||||
"sha": "ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c"
|
||||
},
|
||||
"protected": false
|
||||
},
|
||||
{
|
||||
"name": "secondHead",
|
||||
"commit": {
|
||||
"sha": "ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c"
|
||||
},
|
||||
"protected": false
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"id": "56e319b6-29d0-4813-98b5-e4fafad7d29d",
|
||||
"name": "orgs_hub4j-test-org",
|
||||
"request": {
|
||||
"url": "/orgs/hub4j-test-org",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "orgs_hub4j-test-org-1.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:17:02 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"7445c740dec9798d5d204bef66278a8a\"",
|
||||
"Last-Modified": "Thu, 04 Jun 2020 05:56:10 GMT",
|
||||
"X-GitHub-Media-Type": "unknown, github.v3",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4946",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "54",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4DC:2C9E:141122AB:184D2941:5F514F3E"
|
||||
}
|
||||
},
|
||||
"uuid": "56e319b6-29d0-4813-98b5-e4fafad7d29d",
|
||||
"persistent": true,
|
||||
"insertionIndex": 1
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"id": "194934af-a877-4e0a-8fa8-0e0de487e0cf",
|
||||
"name": "repos_hub4j-test-org_listprslistheads",
|
||||
"request": {
|
||||
"url": "/repos/hub4j-test-org/listPrsListHeads",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "repos_hub4j-test-org_listprslistheads-2.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:17:02 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"69a5845ef0ffc8391df2ef254dd25f79\"",
|
||||
"Last-Modified": "Thu, 03 Sep 2020 19:52:47 GMT",
|
||||
"X-GitHub-Media-Type": "unknown, github.v3",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4945",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "55",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4DC:2C9E:14112357:184D29C2:5F514F3E"
|
||||
}
|
||||
},
|
||||
"uuid": "194934af-a877-4e0a-8fa8-0e0de487e0cf",
|
||||
"persistent": true,
|
||||
"insertionIndex": 2
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"id": "614b7f95-2bc6-49df-92d0-9b094469c339",
|
||||
"name": "repos_hub4j-test-org_listprslistheads_commits_ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"request": {
|
||||
"url": "/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "repos_hub4j-test-org_listprslistheads_commits_ab92e13c0fc844fd51a379a48a3ad0b18231215c-3.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:17:03 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"290934ae7ccd3931f79ff23d81407114\"",
|
||||
"Last-Modified": "Thu, 03 Sep 2020 19:52:44 GMT",
|
||||
"X-GitHub-Media-Type": "unknown, github.v3",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4944",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "56",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4DC:2C9E:14112444:184D2ADE:5F514F3E"
|
||||
}
|
||||
},
|
||||
"uuid": "614b7f95-2bc6-49df-92d0-9b094469c339",
|
||||
"persistent": true,
|
||||
"insertionIndex": 3
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"id": "fba03664-02be-4198-8659-9c6cd9a29bf4",
|
||||
"name": "repos_hub4j-test-org_listprslistheads_commits_ab92e13c0fc844fd51a379a48a3ad0b18231215c_branches-where-head",
|
||||
"request": {
|
||||
"url": "/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c/branches-where-head",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "application/vnd.github.groot-preview+json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "repos_hub4j-test-org_listprslistheads_commits_ab92e13c0fc844fd51a379a48a3ad0b18231215c_branches-where-head-4.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:17:03 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"6f6a81bc3ae02760f8875b30cf4e2eec\"",
|
||||
"X-GitHub-Media-Type": "github.groot-preview; format=json",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4943",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "57",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4DC:2C9E:141124ED:184D2B9B:5F514F3F"
|
||||
}
|
||||
},
|
||||
"uuid": "fba03664-02be-4198-8659-9c6cd9a29bf4",
|
||||
"persistent": true,
|
||||
"insertionIndex": 4
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"login": "hub4j-test-org",
|
||||
"id": 7544739,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
|
||||
"url": "https://api.github.com/orgs/hub4j-test-org",
|
||||
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
|
||||
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
|
||||
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
|
||||
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
|
||||
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
|
||||
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
|
||||
"description": "Hub4j Test Org Description (this could be null or blank too)",
|
||||
"name": "Hub4j Test Org Name (this could be null or blank too)",
|
||||
"company": null,
|
||||
"blog": "https://hub4j.url.io/could/be/null",
|
||||
"location": "Hub4j Test Org Location (this could be null or blank too)",
|
||||
"email": "hub4jtestorgemail@could.be.null.com",
|
||||
"twitter_username": null,
|
||||
"is_verified": false,
|
||||
"has_organization_projects": true,
|
||||
"has_repository_projects": true,
|
||||
"public_repos": 13,
|
||||
"public_gists": 0,
|
||||
"followers": 0,
|
||||
"following": 0,
|
||||
"html_url": "https://github.com/hub4j-test-org",
|
||||
"created_at": "2014-05-10T19:39:11Z",
|
||||
"updated_at": "2020-06-04T05:56:10Z",
|
||||
"type": "Organization",
|
||||
"total_private_repos": 1,
|
||||
"owned_private_repos": 1,
|
||||
"private_gists": 0,
|
||||
"disk_usage": 149,
|
||||
"collaborators": 0,
|
||||
"billing_email": "kk@kohsuke.org",
|
||||
"default_repository_permission": "none",
|
||||
"members_can_create_repositories": false,
|
||||
"two_factor_requirement_enabled": false,
|
||||
"plan": {
|
||||
"name": "free",
|
||||
"space": 976562499,
|
||||
"private_repos": 10000,
|
||||
"filled_seats": 18,
|
||||
"seats": 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"id": 292666372,
|
||||
"node_id": "MDEwOlJlcG9zaXRvcnkyOTI2NjYzNzI=",
|
||||
"name": "listPrsListHeads",
|
||||
"full_name": "hub4j-test-org/listPrsListHeads",
|
||||
"private": true,
|
||||
"owner": {
|
||||
"login": "hub4j-test-org",
|
||||
"id": 7544739,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/hub4j-test-org",
|
||||
"html_url": "https://github.com/hub4j-test-org",
|
||||
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
|
||||
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
|
||||
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
|
||||
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"html_url": "https://github.com/hub4j-test-org/listPrsListHeads",
|
||||
"description": null,
|
||||
"fork": false,
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads",
|
||||
"forks_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/forks",
|
||||
"keys_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/teams",
|
||||
"hooks_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/events",
|
||||
"assignees_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/tags",
|
||||
"blobs_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/subscription",
|
||||
"commits_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/merges",
|
||||
"archive_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/downloads",
|
||||
"issues_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/releases{/id}",
|
||||
"deployments_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/deployments",
|
||||
"created_at": "2020-09-03T19:52:43Z",
|
||||
"updated_at": "2020-09-03T19:52:47Z",
|
||||
"pushed_at": "2020-09-03T20:10:17Z",
|
||||
"git_url": "git://github.com/hub4j-test-org/listPrsListHeads.git",
|
||||
"ssh_url": "git@github.com:hub4j-test-org/listPrsListHeads.git",
|
||||
"clone_url": "https://github.com/hub4j-test-org/listPrsListHeads.git",
|
||||
"svn_url": "https://github.com/hub4j-test-org/listPrsListHeads",
|
||||
"homepage": null,
|
||||
"size": 0,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": null,
|
||||
"has_issues": true,
|
||||
"has_projects": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"archived": false,
|
||||
"disabled": false,
|
||||
"open_issues_count": 2,
|
||||
"license": null,
|
||||
"forks": 0,
|
||||
"open_issues": 2,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"permissions": {
|
||||
"admin": true,
|
||||
"push": true,
|
||||
"pull": true
|
||||
},
|
||||
"temp_clone_token": "AOXG3UQBFQLK2I7WKI43SAK7KFIGE",
|
||||
"allow_squash_merge": true,
|
||||
"allow_merge_commit": true,
|
||||
"allow_rebase_merge": true,
|
||||
"delete_branch_on_merge": false,
|
||||
"organization": {
|
||||
"login": "hub4j-test-org",
|
||||
"id": 7544739,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/hub4j-test-org",
|
||||
"html_url": "https://github.com/hub4j-test-org",
|
||||
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
|
||||
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
|
||||
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
|
||||
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"network_count": 0,
|
||||
"subscribers_count": 7
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"sha": "ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"node_id": "MDY6Q29tbWl0MjkyNjY2MzcyOmFiOTJlMTNjMGZjODQ0ZmQ1MWEzNzlhNDhhM2FkMGIxODIzMTIxNWM=",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "Tadas Giniotis",
|
||||
"email": "61763026+tginiotis-at-work@users.noreply.github.com",
|
||||
"date": "2020-09-03T19:52:44Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "GitHub",
|
||||
"email": "noreply@github.com",
|
||||
"date": "2020-09-03T19:52:44Z"
|
||||
},
|
||||
"message": "Initial commit",
|
||||
"tree": {
|
||||
"sha": "aef4c126549f4900bec20cd8ea5a6546f9d72342",
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/trees/aef4c126549f4900bec20cd8ea5a6546f9d72342"
|
||||
},
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": true,
|
||||
"reason": "valid",
|
||||
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJfUUmMCRBK7hj4Ov3rIwAAdHIIAANckXa7twOvglP8Ro+QhRXJ\nQ68XvpHa/tP+Q1wn/ATZcaNMfwLzVD4EUksmct5PfpBiqSGIsoCDmVsNcEd88hum\nYjDSWBGlD3pOedlGXJtW+y//yUIZRmfaZP69sehrkN7JTOfhdEDFlsfhoJDgsrYh\n5KoD4/pmWMiG4NvCMZ265BeMXHw7KSFLAD4vSlBVo/kBJe2IQyW1GvGemZa5fwbk\nBS77fQcxZlv6w7EC9NvWlPc7nxHfS4C5shbB1Cm6nMPaz73PcrH3cWLz2A7esdrU\nhxaCiZ9uF+iqQUQVbzQ8s5r3Hiz1cWsFH2qND/RAaqpLlkLzH43/SyVyiwCmqlM=\n=649h\n-----END PGP SIGNATURE-----\n",
|
||||
"payload": "tree aef4c126549f4900bec20cd8ea5a6546f9d72342\nauthor Tadas Giniotis <61763026+tginiotis-at-work@users.noreply.github.com> 1599162764 +0300\ncommitter GitHub <noreply@github.com> 1599162764 +0300\n\nInitial commit"
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"html_url": "https://github.com/hub4j-test-org/listPrsListHeads/commit/ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"comments_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c/comments",
|
||||
"author": {
|
||||
"login": "tginiotis-at-work",
|
||||
"id": 61763026,
|
||||
"node_id": "MDQ6VXNlcjYxNzYzMDI2",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/61763026?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/tginiotis-at-work",
|
||||
"html_url": "https://github.com/tginiotis-at-work",
|
||||
"followers_url": "https://api.github.com/users/tginiotis-at-work/followers",
|
||||
"following_url": "https://api.github.com/users/tginiotis-at-work/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/tginiotis-at-work/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/tginiotis-at-work/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/tginiotis-at-work/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/tginiotis-at-work/orgs",
|
||||
"repos_url": "https://api.github.com/users/tginiotis-at-work/repos",
|
||||
"events_url": "https://api.github.com/users/tginiotis-at-work/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/tginiotis-at-work/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"committer": {
|
||||
"login": "web-flow",
|
||||
"id": 19864447,
|
||||
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/web-flow",
|
||||
"html_url": "https://github.com/web-flow",
|
||||
"followers_url": "https://api.github.com/users/web-flow/followers",
|
||||
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/web-flow/orgs",
|
||||
"repos_url": "https://api.github.com/users/web-flow/repos",
|
||||
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/web-flow/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"parents": [],
|
||||
"stats": {
|
||||
"total": 1,
|
||||
"additions": 1,
|
||||
"deletions": 0
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"sha": "c0fa81448132f7f9eb303a93d9047fe5fafbfcd9",
|
||||
"filename": "README.md",
|
||||
"status": "added",
|
||||
"additions": 1,
|
||||
"deletions": 0,
|
||||
"changes": 1,
|
||||
"blob_url": "https://github.com/hub4j-test-org/listPrsListHeads/blob/ab92e13c0fc844fd51a379a48a3ad0b18231215c/README.md",
|
||||
"raw_url": "https://github.com/hub4j-test-org/listPrsListHeads/raw/ab92e13c0fc844fd51a379a48a3ad0b18231215c/README.md",
|
||||
"contents_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/contents/README.md?ref=ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"patch": "@@ -0,0 +1 @@\n+# listPrsListHeads\n\\ No newline at end of file"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"name": "master",
|
||||
"commit": {
|
||||
"sha": "ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c"
|
||||
},
|
||||
"protected": false
|
||||
},
|
||||
{
|
||||
"name": "secondHead",
|
||||
"commit": {
|
||||
"sha": "ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c"
|
||||
},
|
||||
"protected": false
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"id": "f7bb3a61-b47e-4403-aa76-b0e76f550645",
|
||||
"name": "orgs_hub4j-test-org",
|
||||
"request": {
|
||||
"url": "/orgs/hub4j-test-org",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "orgs_hub4j-test-org-1.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:16:53 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"7445c740dec9798d5d204bef66278a8a\"",
|
||||
"Last-Modified": "Thu, 04 Jun 2020 05:56:10 GMT",
|
||||
"X-GitHub-Media-Type": "unknown, github.v3",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4966",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "34",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4C6:DA25:1594933A:1A26D3B7:5F514F35"
|
||||
}
|
||||
},
|
||||
"uuid": "f7bb3a61-b47e-4403-aa76-b0e76f550645",
|
||||
"persistent": true,
|
||||
"insertionIndex": 1
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"id": "d9a742ee-0c30-48ff-9671-859dec573e4e",
|
||||
"name": "repos_hub4j-test-org_listprslistheads",
|
||||
"request": {
|
||||
"url": "/repos/hub4j-test-org/listPrsListHeads",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "repos_hub4j-test-org_listprslistheads-2.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:16:54 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"2b94bdb622f978bd84a5dc272e79d717\"",
|
||||
"Last-Modified": "Thu, 03 Sep 2020 19:52:47 GMT",
|
||||
"X-GitHub-Media-Type": "unknown, github.v3",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4965",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "35",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4C6:DA25:15949418:1A26D428:5F514F35"
|
||||
}
|
||||
},
|
||||
"uuid": "d9a742ee-0c30-48ff-9671-859dec573e4e",
|
||||
"persistent": true,
|
||||
"insertionIndex": 2
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"id": "3aa83e8c-ac77-4bf7-91dd-cb88ae0055d4",
|
||||
"name": "repos_hub4j-test-org_listprslistheads_commits_ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"request": {
|
||||
"url": "/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "repos_hub4j-test-org_listprslistheads_commits_ab92e13c0fc844fd51a379a48a3ad0b18231215c-3.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:16:54 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"290934ae7ccd3931f79ff23d81407114\"",
|
||||
"Last-Modified": "Thu, 03 Sep 2020 19:52:44 GMT",
|
||||
"X-GitHub-Media-Type": "unknown, github.v3",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4964",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "36",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4C6:DA25:15949488:1A26D51F:5F514F36"
|
||||
}
|
||||
},
|
||||
"uuid": "3aa83e8c-ac77-4bf7-91dd-cb88ae0055d4",
|
||||
"persistent": true,
|
||||
"insertionIndex": 3
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"id": "90802902-122b-4c2e-9236-8578f603326c",
|
||||
"name": "repos_hub4j-test-org_listprslistheads_commits_ab92e13c0fc844fd51a379a48a3ad0b18231215c_branches-where-head",
|
||||
"request": {
|
||||
"url": "/repos/hub4j-test-org/listPrsListHeads/commits/ab92e13c0fc844fd51a379a48a3ad0b18231215c/branches-where-head",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "application/vnd.github.groot-preview+json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "repos_hub4j-test-org_listprslistheads_commits_ab92e13c0fc844fd51a379a48a3ad0b18231215c_branches-where-head-4.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:16:55 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"6f6a81bc3ae02760f8875b30cf4e2eec\"",
|
||||
"X-GitHub-Media-Type": "github.groot-preview; format=json",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4963",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "37",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4C6:DA25:15949516:1A26D5C6:5F514F36"
|
||||
}
|
||||
},
|
||||
"uuid": "90802902-122b-4c2e-9236-8578f603326c",
|
||||
"persistent": true,
|
||||
"insertionIndex": 4
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"login": "hub4j-test-org",
|
||||
"id": 7544739,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
|
||||
"url": "https://api.github.com/orgs/hub4j-test-org",
|
||||
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
|
||||
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
|
||||
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
|
||||
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
|
||||
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
|
||||
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
|
||||
"description": "Hub4j Test Org Description (this could be null or blank too)",
|
||||
"name": "Hub4j Test Org Name (this could be null or blank too)",
|
||||
"company": null,
|
||||
"blog": "https://hub4j.url.io/could/be/null",
|
||||
"location": "Hub4j Test Org Location (this could be null or blank too)",
|
||||
"email": "hub4jtestorgemail@could.be.null.com",
|
||||
"twitter_username": null,
|
||||
"is_verified": false,
|
||||
"has_organization_projects": true,
|
||||
"has_repository_projects": true,
|
||||
"public_repos": 13,
|
||||
"public_gists": 0,
|
||||
"followers": 0,
|
||||
"following": 0,
|
||||
"html_url": "https://github.com/hub4j-test-org",
|
||||
"created_at": "2014-05-10T19:39:11Z",
|
||||
"updated_at": "2020-06-04T05:56:10Z",
|
||||
"type": "Organization",
|
||||
"total_private_repos": 1,
|
||||
"owned_private_repos": 1,
|
||||
"private_gists": 0,
|
||||
"disk_usage": 149,
|
||||
"collaborators": 0,
|
||||
"billing_email": "kk@kohsuke.org",
|
||||
"default_repository_permission": "none",
|
||||
"members_can_create_repositories": false,
|
||||
"two_factor_requirement_enabled": false,
|
||||
"plan": {
|
||||
"name": "free",
|
||||
"space": 976562499,
|
||||
"private_repos": 10000,
|
||||
"filled_seats": 18,
|
||||
"seats": 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"id": 292666372,
|
||||
"node_id": "MDEwOlJlcG9zaXRvcnkyOTI2NjYzNzI=",
|
||||
"name": "listPrsListHeads",
|
||||
"full_name": "hub4j-test-org/listPrsListHeads",
|
||||
"private": true,
|
||||
"owner": {
|
||||
"login": "hub4j-test-org",
|
||||
"id": 7544739,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/hub4j-test-org",
|
||||
"html_url": "https://github.com/hub4j-test-org",
|
||||
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
|
||||
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
|
||||
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
|
||||
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"html_url": "https://github.com/hub4j-test-org/listPrsListHeads",
|
||||
"description": null,
|
||||
"fork": false,
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads",
|
||||
"forks_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/forks",
|
||||
"keys_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/teams",
|
||||
"hooks_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/events",
|
||||
"assignees_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/tags",
|
||||
"blobs_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/subscription",
|
||||
"commits_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/merges",
|
||||
"archive_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/downloads",
|
||||
"issues_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/releases{/id}",
|
||||
"deployments_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/deployments",
|
||||
"created_at": "2020-09-03T19:52:43Z",
|
||||
"updated_at": "2020-09-03T19:52:47Z",
|
||||
"pushed_at": "2020-09-03T20:10:17Z",
|
||||
"git_url": "git://github.com/hub4j-test-org/listPrsListHeads.git",
|
||||
"ssh_url": "git@github.com:hub4j-test-org/listPrsListHeads.git",
|
||||
"clone_url": "https://github.com/hub4j-test-org/listPrsListHeads.git",
|
||||
"svn_url": "https://github.com/hub4j-test-org/listPrsListHeads",
|
||||
"homepage": null,
|
||||
"size": 0,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": null,
|
||||
"has_issues": true,
|
||||
"has_projects": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"archived": false,
|
||||
"disabled": false,
|
||||
"open_issues_count": 2,
|
||||
"license": null,
|
||||
"forks": 0,
|
||||
"open_issues": 2,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"permissions": {
|
||||
"admin": true,
|
||||
"push": true,
|
||||
"pull": true
|
||||
},
|
||||
"temp_clone_token": "AOXG3USIKELUIJ56L57BZ7K7KFIGK",
|
||||
"allow_squash_merge": true,
|
||||
"allow_merge_commit": true,
|
||||
"allow_rebase_merge": true,
|
||||
"delete_branch_on_merge": false,
|
||||
"organization": {
|
||||
"login": "hub4j-test-org",
|
||||
"id": 7544739,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/hub4j-test-org",
|
||||
"html_url": "https://github.com/hub4j-test-org",
|
||||
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
|
||||
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
|
||||
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
|
||||
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"network_count": 0,
|
||||
"subscribers_count": 7
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"sha": "7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e",
|
||||
"node_id": "MDY6Q29tbWl0MjkyNjY2MzcyOjc0NjA5MTZiZmI4ZTk5NjZkNmI5ZDNlOGFlMzc4YzgyYzZiOGU0M2U=",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "Tadas Giniotis",
|
||||
"email": "61763026+tginiotis-at-work@users.noreply.github.com",
|
||||
"date": "2020-09-03T20:08:55Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "GitHub",
|
||||
"email": "noreply@github.com",
|
||||
"date": "2020-09-03T20:08:55Z"
|
||||
},
|
||||
"message": "Create 3",
|
||||
"tree": {
|
||||
"sha": "f6de816da0313f4aa5076a767543cead4306c407",
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/trees/f6de816da0313f4aa5076a767543cead4306c407"
|
||||
},
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/git/commits/7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": true,
|
||||
"reason": "valid",
|
||||
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJfUU1XCRBK7hj4Ov3rIwAAdHIIAJyE1uW45qdn/bQfnROgDQDu\ndbI6Vbv7PvQah66cLnM9mkbF5W6hu2PulE8G7bnkeUyovluwbQHfwv2l2BdmRgC7\nrMTmN/285vxc9whSY5WI0rfuxkc6x75eH3kuN4ZTRkpRfyQ1/M2G2aizpRZ+g/ky\nnNd63ZuCx6eAkfDHu20+yFhLIELYXb82zoLimnfdSOHBUmfHYQ39REQsDb7+uvUS\nglHhiSGYXVQNLir7coHam1v1Xd2Le8sOZ6ACEtyfa/J0OEmWylQC84spidYJqJXR\nPtEzoB2eKRmwj7OoMtX/tYMP2y2beUQV+FUWimpgx/4dCMe/kaNr4OoUQCwUdz8=\n=ZjBh\n-----END PGP SIGNATURE-----\n",
|
||||
"payload": "tree f6de816da0313f4aa5076a767543cead4306c407\nparent 6b9956fe8c3d030dbc49c9d4c4166b0ceb4198fc\nauthor Tadas Giniotis <61763026+tginiotis-at-work@users.noreply.github.com> 1599163735 +0300\ncommitter GitHub <noreply@github.com> 1599163735 +0300\n\nCreate 3"
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e",
|
||||
"html_url": "https://github.com/hub4j-test-org/listPrsListHeads/commit/7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e",
|
||||
"comments_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e/comments",
|
||||
"author": {
|
||||
"login": "tginiotis-at-work",
|
||||
"id": 61763026,
|
||||
"node_id": "MDQ6VXNlcjYxNzYzMDI2",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/61763026?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/tginiotis-at-work",
|
||||
"html_url": "https://github.com/tginiotis-at-work",
|
||||
"followers_url": "https://api.github.com/users/tginiotis-at-work/followers",
|
||||
"following_url": "https://api.github.com/users/tginiotis-at-work/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/tginiotis-at-work/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/tginiotis-at-work/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/tginiotis-at-work/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/tginiotis-at-work/orgs",
|
||||
"repos_url": "https://api.github.com/users/tginiotis-at-work/repos",
|
||||
"events_url": "https://api.github.com/users/tginiotis-at-work/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/tginiotis-at-work/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"committer": {
|
||||
"login": "web-flow",
|
||||
"id": 19864447,
|
||||
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/web-flow",
|
||||
"html_url": "https://github.com/web-flow",
|
||||
"followers_url": "https://api.github.com/users/web-flow/followers",
|
||||
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/web-flow/orgs",
|
||||
"repos_url": "https://api.github.com/users/web-flow/repos",
|
||||
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/web-flow/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"parents": [
|
||||
{
|
||||
"sha": "6b9956fe8c3d030dbc49c9d4c4166b0ceb4198fc",
|
||||
"url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/commits/6b9956fe8c3d030dbc49c9d4c4166b0ceb4198fc",
|
||||
"html_url": "https://github.com/hub4j-test-org/listPrsListHeads/commit/6b9956fe8c3d030dbc49c9d4c4166b0ceb4198fc"
|
||||
}
|
||||
],
|
||||
"stats": {
|
||||
"total": 1,
|
||||
"additions": 1,
|
||||
"deletions": 0
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"sha": "00750edc07d6415dcc07ae0351e9397b0222b7ba",
|
||||
"filename": "3",
|
||||
"status": "added",
|
||||
"additions": 1,
|
||||
"deletions": 0,
|
||||
"changes": 1,
|
||||
"blob_url": "https://github.com/hub4j-test-org/listPrsListHeads/blob/7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e/3",
|
||||
"raw_url": "https://github.com/hub4j-test-org/listPrsListHeads/raw/7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e/3",
|
||||
"contents_url": "https://api.github.com/repos/hub4j-test-org/listPrsListHeads/contents/3?ref=7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e",
|
||||
"patch": "@@ -0,0 +1 @@\n+3"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"id": "466a8cc6-9929-4670-98f8-b14e84977ea9",
|
||||
"name": "orgs_hub4j-test-org",
|
||||
"request": {
|
||||
"url": "/orgs/hub4j-test-org",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "orgs_hub4j-test-org-1.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:16:57 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"7445c740dec9798d5d204bef66278a8a\"",
|
||||
"Last-Modified": "Thu, 04 Jun 2020 05:56:10 GMT",
|
||||
"X-GitHub-Media-Type": "unknown, github.v3",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4958",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "42",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4D0:59C5:B791ED0:DDDB920:5F514F39"
|
||||
}
|
||||
},
|
||||
"uuid": "466a8cc6-9929-4670-98f8-b14e84977ea9",
|
||||
"persistent": true,
|
||||
"insertionIndex": 1
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"id": "4af92eb6-2de5-4bfa-989b-b1b9f026a731",
|
||||
"name": "repos_hub4j-test-org_listprslistheads",
|
||||
"request": {
|
||||
"url": "/repos/hub4j-test-org/listPrsListHeads",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "repos_hub4j-test-org_listprslistheads-2.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:16:57 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"66a89ba688bce54b7315c889cf935290\"",
|
||||
"Last-Modified": "Thu, 03 Sep 2020 19:52:47 GMT",
|
||||
"X-GitHub-Media-Type": "unknown, github.v3",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4957",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "43",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4D0:59C5:B791F14:DDDB959:5F514F39"
|
||||
}
|
||||
},
|
||||
"uuid": "4af92eb6-2de5-4bfa-989b-b1b9f026a731",
|
||||
"persistent": true,
|
||||
"insertionIndex": 2
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"id": "a239ee35-c210-4a58-880a-a01e1f29e0e2",
|
||||
"name": "repos_hub4j-test-org_listprslistheads_commits_7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e",
|
||||
"request": {
|
||||
"url": "/repos/hub4j-test-org/listPrsListHeads/commits/7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"bodyFileName": "repos_hub4j-test-org_listprslistheads_commits_7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e-3.json",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:16:58 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "W/\"4ac6625fabe6147c68b33b6cc3f2ea2b\"",
|
||||
"Last-Modified": "Thu, 03 Sep 2020 20:08:55 GMT",
|
||||
"X-GitHub-Media-Type": "unknown, github.v3",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4956",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "44",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4D0:59C5:B791F54:DDDB9B2:5F514F39"
|
||||
}
|
||||
},
|
||||
"uuid": "a239ee35-c210-4a58-880a-a01e1f29e0e2",
|
||||
"persistent": true,
|
||||
"insertionIndex": 3
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"id": "d391dfba-43a5-4c07-ae13-ac94badbaf42",
|
||||
"name": "repos_hub4j-test-org_listprslistheads_commits_7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e_branches-where-head",
|
||||
"request": {
|
||||
"url": "/repos/hub4j-test-org/listPrsListHeads/commits/7460916bfb8e9966d6b9d3e8ae378c82c6b8e43e/branches-where-head",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Accept": {
|
||||
"equalTo": "application/vnd.github.groot-preview+json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"body": "[]",
|
||||
"headers": {
|
||||
"Date": "Thu, 03 Sep 2020 20:16:58 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Server": "GitHub.com",
|
||||
"Status": "200 OK",
|
||||
"Cache-Control": "private, max-age=60, s-maxage=60",
|
||||
"Vary": [
|
||||
"Accept, Authorization, Cookie, X-GitHub-OTP",
|
||||
"Accept-Encoding, Accept, X-Requested-With",
|
||||
"Accept-Encoding"
|
||||
],
|
||||
"ETag": "\"64f4770525bcc22cc6d2500a957a939c\"",
|
||||
"X-GitHub-Media-Type": "github.groot-preview; format=json",
|
||||
"X-RateLimit-Limit": "5000",
|
||||
"X-RateLimit-Remaining": "4955",
|
||||
"X-RateLimit-Reset": "1599165440",
|
||||
"X-RateLimit-Used": "45",
|
||||
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
|
||||
"X-Frame-Options": "deny",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
|
||||
"Content-Security-Policy": "default-src 'none'",
|
||||
"X-GitHub-Request-Id": "B4D0:59C5:B791FA1:DDDBA08:5F514F3A"
|
||||
}
|
||||
},
|
||||
"uuid": "d391dfba-43a5-4c07-ae13-ac94badbaf42",
|
||||
"persistent": true,
|
||||
"insertionIndex": 4
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"login": "hub4j-test-org",
|
||||
"id": 7544739,
|
||||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
|
||||
"url": "https://api.github.com/orgs/hub4j-test-org",
|
||||
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
|
||||
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
|
||||
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
|
||||
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
|
||||
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
|
||||
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
|
||||
"description": "Hub4j Test Org Description (this could be null or blank too)",
|
||||
"name": "Hub4j Test Org Name (this could be null or blank too)",
|
||||
"company": null,
|
||||
"blog": "https://hub4j.url.io/could/be/null",
|
||||
"location": "Hub4j Test Org Location (this could be null or blank too)",
|
||||
"email": "hub4jtestorgemail@could.be.null.com",
|
||||
"twitter_username": null,
|
||||
"is_verified": false,
|
||||
"has_organization_projects": true,
|
||||
"has_repository_projects": true,
|
||||
"public_repos": 13,
|
||||
"public_gists": 0,
|
||||
"followers": 0,
|
||||
"following": 0,
|
||||
"html_url": "https://github.com/hub4j-test-org",
|
||||
"created_at": "2014-05-10T19:39:11Z",
|
||||
"updated_at": "2020-06-04T05:56:10Z",
|
||||
"type": "Organization",
|
||||
"total_private_repos": 1,
|
||||
"owned_private_repos": 1,
|
||||
"private_gists": 0,
|
||||
"disk_usage": 149,
|
||||
"collaborators": 0,
|
||||
"billing_email": "kk@kohsuke.org",
|
||||
"default_repository_permission": "none",
|
||||
"members_can_create_repositories": false,
|
||||
"two_factor_requirement_enabled": false,
|
||||
"plan": {
|
||||
"name": "free",
|
||||
"space": 976562499,
|
||||
"private_repos": 10000,
|
||||
"filled_seats": 18,
|
||||
"seats": 3
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user