Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 49878bc

Browse filesBrowse files
authored
Merge branch 'master' into patch-1
2 parents a0fb0d1 + 909a274 commit 49878bc
Copy full SHA for 49878bc

File tree

Expand file treeCollapse file tree

390 files changed

+43857
-80
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

390 files changed

+43857
-80
lines changed

‎.github/workflows/maven-build.yml

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Java CI Build and Test
2+
3+
on: [push, pull_request]
4+
5+
6+
jobs:
7+
build:
8+
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v1
13+
- name: Set up JDK 1.8
14+
uses: actions/setup-java@v1
15+
with:
16+
java-version: 1.8
17+
- name: Maven Download all dependencies
18+
run: mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline
19+
- name: Maven Build
20+
run: mvn -B package --file pom.xml -Dtest=CommitTest,GistTest,PullRequestTest,UserTest,WireMockStatusReporterTest

‎CONTRIBUTING.md

Copy file name to clipboard
+62Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Contributing
2+
3+
## Using WireMock and Snapshots
4+
5+
This project has started converting to using WireMock to stub out http responses instead of use live data.
6+
This change will allow tests to run in a CI environment without needing to touch github.com.
7+
The tests will instead serve previously recorded responses from local data files.
8+
9+
### Running WireMock tests
10+
11+
Example:
12+
13+
`mvn install -Dtest=WireMockStatusReporterTest`
14+
15+
This the default behavior.
16+
17+
18+
### Setting up credential
19+
20+
1. Create an OAuth token on github.com
21+
2. Set the GITHUB_OAUTH environment variable to the value of that token
22+
3. Set the system property `test.github.useProxy` (usually like "-Dtest.github.useProxy" as a Java VM option)
23+
24+
`mvn install -Dtest.github.useProxy -Dtest=WireMockStatusReporterTest`
25+
26+
4. The above should report no test failures and include the following console output:
27+
28+
`WireMockStatusReporterTest: GitHub proxying and user auth correctly configured for user login: <your login>`
29+
30+
Whenever you run tests with `-Dtest.github.useProxy`, they will try to get data from local files but will fallback to proxying to github if not found.
31+
32+
33+
### Writing a new test
34+
35+
Once you have credentials setup, you add new test classes and test methods as you would normally.
36+
Keep `useProxy` enabled and iterate on your tests as needed. Remember, while proxying your tests are interacting with GitHub - you will need to clean up your state between runs.
37+
38+
When you are ready to create a snapshot of your test data,
39+
run your test with `test.github.takeSnapshot` ("-Dtest.github.takeSnapshot" as a Java VM option). For example:
40+
41+
`mvn install -Dtest.github.takeSnapshot -Dtest=YourTestClassName`
42+
43+
The above command would create snapshot WireMock data files under the path `src/test/resources/org/kohsuhke/github/YourTestClassName/wiremock`.
44+
Each method would get a separate director that would hold the data files for that test method.
45+
46+
Add all files including the generated data to your commit and submit a PR.
47+
48+
### Modifying existing tests
49+
50+
When modifying existing tests, you can change the stubbed WireMock data files by hand or you can try generating a new snapshot.
51+
52+
#### Manual editing of data (minor changes only)
53+
54+
If you know what data will change, it is sometimes simplest to make any required changes to the data files manually.
55+
This can be easier if the changes are minor or when you development environment is not setup to to take updated snapshots.
56+
57+
#### Generating a new snapshot
58+
59+
For more most changes, it is recommended to take a new snapshot when updating tests.
60+
Delete the wiremock data files for the test method you will be modifying.
61+
For more significant changes, you can even delete the WireMock files for an entire test class.
62+
Then follow the same as when writing a new test: run with proxy enabled to debug, take a new snapshot when done, commit everything, and submit the PR.

‎README

Copy file name to clipboardExpand all lines: README
-3Lines changed: 0 additions & 3 deletions
This file was deleted.

‎README.md

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Java API for GitHub
2+
3+
See https://github-api.kohsuke.org/ for more details

‎pom.xml

Copy file name to clipboardExpand all lines: pom.xml
+74-24Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
<parent>
44
<groupId>org.kohsuke</groupId>
55
<artifactId>pom</artifactId>
6-
<version>20</version>
6+
<version>21</version>
7+
<relativePath />
78
</parent>
89

910
<artifactId>github-api</artifactId>
1011
<version>1.96-SNAPSHOT</version>
1112
<name>GitHub API for Java</name>
12-
<url>http://github-api.kohsuke.org/</url>
13+
<url>https://github-api.kohsuke.org/</url>
1314
<description>GitHub API for Java</description>
1415

1516
<scm>
1617
<connection>scm:git:git@github.com/kohsuke/${project.artifactId}.git</connection>
1718
<developerConnection>scm:git:ssh://git@github.com/kohsuke/${project.artifactId}.git</developerConnection>
18-
<url>http://${project.artifactId}.kohsuke.org/</url>
19+
<url>https://${project.artifactId}.kohsuke.org/</url>
1920
<tag>HEAD</tag>
2021
</scm>
2122

@@ -28,12 +29,23 @@
2829

2930
<properties>
3031
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
31-
<findbugs-maven-plugin.version>3.0.5</findbugs-maven-plugin.version>
32-
<findbugs-maven-plugin.failOnError>true</findbugs-maven-plugin.failOnError>
32+
<spotbugs-maven-plugin.version>3.1.11</spotbugs-maven-plugin.version>
33+
<spotbugs.version>3.1.12</spotbugs.version>
34+
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
35+
<hamcrest.version>2.1</hamcrest.version>
3336
</properties>
3437

3538
<build>
3639
<plugins>
40+
<plugin>
41+
<artifactId>maven-compiler-plugin</artifactId>
42+
<version>3.8.1</version>
43+
<configuration>
44+
<source>7</source>
45+
<target>7</target>
46+
</configuration>
47+
</plugin>
48+
3749
<plugin>
3850
<artifactId>maven-surefire-plugin</artifactId>
3951
<version>2.22.1</version>
@@ -75,22 +87,41 @@
7587
</executions>
7688
</plugin>
7789
<plugin>
78-
<groupId>org.codehaus.mojo</groupId>
79-
<artifactId>findbugs-maven-plugin</artifactId>
80-
<version>${findbugs-maven-plugin.version}</version>
90+
<groupId>com.github.spotbugs</groupId>
91+
<artifactId>spotbugs-maven-plugin</artifactId>
92+
<version>${spotbugs-maven-plugin.version}</version>
8193
<configuration>
8294
<xmlOutput>true</xmlOutput>
83-
<failOnError>${findbugs-maven-plugin.failOnError}</failOnError>
95+
<failOnError>${spotbugs-maven-plugin.failOnError}</failOnError>
8496
</configuration>
8597
<executions>
8698
<execution>
87-
<id>run-findbugs</id>
99+
<id>run-spotbugs</id>
88100
<phase>verify</phase>
89101
<goals>
90102
<goal>check</goal>
91103
</goals>
92104
</execution>
93105
</executions>
106+
<dependencies>
107+
<!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
108+
<dependency>
109+
<groupId>com.github.spotbugs</groupId>
110+
<artifactId>spotbugs</artifactId>
111+
<version>${spotbugs.version}</version>
112+
</dependency>
113+
</dependencies>
114+
</plugin>
115+
<!-- Do not use gmaven plugin -->
116+
<plugin>
117+
<groupId>org.codehaus.gmaven</groupId>
118+
<artifactId>gmaven-plugin</artifactId>
119+
<executions>
120+
<execution>
121+
<goals>
122+
</goals>
123+
</execution>
124+
</executions>
94125
</plugin>
95126
</plugins>
96127
</build>
@@ -106,22 +137,35 @@
106137
<artifactId>commons-codec</artifactId>
107138
<version>1.7</version>
108139
</dependency>
140+
<dependency>
141+
<groupId>org.hamcrest</groupId>
142+
<artifactId>hamcrest</artifactId>
143+
<version>${hamcrest.version}</version>
144+
<scope>test</scope>
145+
</dependency>
146+
<!-- This is needed in order to force junit4 and JTH tests to use newer hamcrest version -->
147+
<dependency>
148+
<groupId>org.hamcrest</groupId>
149+
<artifactId>hamcrest-core</artifactId>
150+
<version>${hamcrest.version}</version>
151+
<scope>test</scope>
152+
</dependency>
153+
<dependency>
154+
<groupId>org.hamcrest</groupId>
155+
<artifactId>hamcrest-library</artifactId>
156+
<version>${hamcrest.version}</version>
157+
<scope>test</scope>
158+
</dependency>
109159
<dependency>
110160
<groupId>junit</groupId>
111161
<artifactId>junit</artifactId>
112162
<version>4.12</version>
113163
<scope>test</scope>
114164
</dependency>
115-
<dependency>
116-
<groupId>org.hamcrest</groupId>
117-
<artifactId>hamcrest-all</artifactId>
118-
<version>1.3</version>
119-
<scope>test</scope>
120-
</dependency>
121165
<dependency>
122166
<groupId>com.fasterxml.jackson.core</groupId>
123167
<artifactId>jackson-databind</artifactId>
124-
<version>2.9.2</version>
168+
<version>2.9.9.3</version>
125169
</dependency>
126170
<dependency>
127171
<groupId>commons-io</groupId>
@@ -171,22 +215,28 @@
171215
<scope>test</scope>
172216
</dependency>
173217
<dependency>
174-
<groupId>com.google.code.findbugs</groupId>
175-
<artifactId>annotations</artifactId>
176-
<version>3.0.1</version>
177-
<scope>provided</scope>
218+
<groupId>com.github.spotbugs</groupId>
219+
<artifactId>spotbugs-annotations</artifactId>
220+
<version>${spotbugs.version}</version>
221+
<optional>true</optional>
222+
</dependency>
223+
<dependency>
224+
<groupId>com.github.tomakehurst</groupId>
225+
<artifactId>wiremock-jre8-standalone</artifactId>
226+
<version>2.24.1</version>
227+
<scope>test</scope>
178228
</dependency>
179229
</dependencies>
180230
<repositories>
181231
<repository>
182232
<id>repo.jenkins-ci.org</id>
183-
<url>http://repo.jenkins-ci.org/public/</url>
233+
<url>https://repo.jenkins-ci.org/public/</url>
184234
</repository>
185235
</repositories>
186236
<pluginRepositories>
187237
<pluginRepository>
188238
<id>repo.jenkins-ci.org</id>
189-
<url>http://repo.jenkins-ci.org/public/</url>
239+
<url>https://repo.jenkins-ci.org/public/</url>
190240
</pluginRepository>
191241
</pluginRepositories>
192242

@@ -202,7 +252,7 @@
202252
<licenses>
203253
<license>
204254
<name>The MIT license</name>
205-
<url>http://www.opensource.org/licenses/mit-license.php</url>
255+
<url>https://www.opensource.org/licenses/mit-license.php</url>
206256
<distribution>repo</distribution>
207257
</license>
208258
</licenses>

‎src/main/java/org/kohsuke/github/GHPullRequestQueryBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHPullRequestQueryBuilder.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public GHPullRequestQueryBuilder state(GHIssueState state) {
2020
}
2121

2222
public GHPullRequestQueryBuilder head(String head) {
23+
if (head != null && !head.contains(":")) {
24+
head = repo.getOwnerName() + ":" + head;
25+
}
2326
req.with("head",head);
2427
return this;
2528
}

‎src/main/java/org/kohsuke/github/GitHubBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GitHubBuilder.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public static GitHubBuilder fromEnvironment() throws IOException {
126126
}
127127
return fromProperties(props);
128128
}
129-
129+
130130
public static GitHubBuilder fromPropertyFile() throws IOException {
131131
File homeDir = new File(System.getProperty("user.home"));
132132
File propertyFile = new File(homeDir, ".github");

‎src/main/java/org/kohsuke/github/Requester.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/Requester.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ private void fetch() {
526526
}
527527
}
528528
} catch (IOException e) {
529-
throw new GHException("Failed to retrieve "+url);
529+
throw new GHException("Failed to retrieve " + url, e);
530530
}
531531
}
532532

‎src/test/java/org/kohsuke/github/AbstractGitHubApiTestBase.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/AbstractGitHubApiTestBase.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public abstract class AbstractGitHubApiTestBase extends Assert {
1818

1919
protected GitHub gitHub;
2020

21+
2122
@Before
2223
public void setUp() throws Exception {
2324
File f = new File(System.getProperty("user.home"), ".github.kohsuke2");

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.