Compare commits

...

71 Commits

Author SHA1 Message Date
Liam Newman
d5667d2473 [maven-release-plugin] prepare release github-api-1.108 2020-03-04 16:54:42 -08:00
Liam Newman
a42305dd59 Revert "Removed extraneous author javadocs"
This reverts commit 888abc9e2a.
2020-03-04 11:32:12 -08:00
Liam Newman
c22a718d14 Merge pull request #723 from XiongKezhi/complete-checks-api
Complete checks api
2020-03-03 23:03:10 -08:00
Liam Newman
d0b23c79e2 Merge branch 'master' into complete-checks-api 2020-03-03 19:59:21 -08:00
Liam Newman
76da04afd8 Merge pull request #725 from github-api/dependabot/maven/com.github.tomakehurst-wiremock-jre8-standalone-2.26.2
Bump wiremock-jre8-standalone from 2.26.1 to 2.26.2
2020-03-03 12:55:59 -08:00
XiongKezhi
768f60709f Add Output and more tests 2020-03-03 23:45:01 +08:00
dependabot-preview[bot]
8cd3acd318 Bump wiremock-jre8-standalone from 2.26.1 to 2.26.2
Bumps [wiremock-jre8-standalone](https://github.com/tomakehurst/wiremock) from 2.26.1 to 2.26.2.
- [Release notes](https://github.com/tomakehurst/wiremock/releases)
- [Commits](https://github.com/tomakehurst/wiremock/compare/2.26.1...2.26.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-03 06:35:55 +00:00
Kezhi Xiong
ce7cfc0648 Merge branch 'master' into complete-checks-api 2020-03-03 12:57:42 +08:00
Liam Newman
8b6cf55473 Merge pull request #719 from bitwiseman/task/deprecated
Remove a few long deprecated methods and fully annotate others
2020-03-02 14:06:50 -08:00
Liam Newman
75d95d844c Update src/test/java/org/kohsuke/github/AppTest.java
Co-Authored-By: Karl Shultz <kshultz@cloudbees.com>
2020-03-02 08:41:21 -08:00
XiongKezhi
f54bfd3fb5 Fixed JavaDoc warning reported by maven site 2020-03-01 22:18:36 +08:00
XiongKezhi
f8a8ee9b9d Format code 2020-03-01 22:14:53 +08:00
XiongKezhi
16faaae199 Add GHCheckSuite 2020-03-01 21:59:16 +08:00
XiongKezhi
375417527b Change timestamps property back to String 2020-03-01 15:17:24 +08:00
XiongKezhi
10b01ca6b3 using Date for timestamps and add more JavaDoc 2020-03-01 14:01:59 +08:00
Liam Newman
f9006af04c Merge branch 'master' into complete-checks-api 2020-02-29 15:39:38 -08:00
Kezhi Xiong
57f947576e Delete empty line in JavaDoc 2020-02-29 20:15:32 +08:00
XiongKezhi
5a8f8c345b parse completedAt and startedAt into Date in getters 2020-02-29 18:09:25 +08:00
XiongKezhi
e96067e3c8 Merge remote-tracking branch 'origin/complete-checks-api' into complete-checks-api 2020-02-29 13:27:02 +08:00
XiongKezhi
2242174515 add Output in GHCheckRun 2020-02-29 13:26:59 +08:00
Kezhi Xiong
73179c118b Fixed typo in JavaDoc of getApp 2020-02-29 13:19:14 +08:00
Liam Newman
5b575134fc Merge branch 'master' into task/deprecated 2020-02-28 14:38:30 -08:00
Liam Newman
c11c06b896 Merge pull request #720 from bitwiseman/task/inject-root
Enable injection of GitHub and other values into mapping
2020-02-28 14:38:09 -08:00
Liam Newman
ba8d2a251f Merge branch 'master' into task/deprecated 2020-02-28 08:37:51 -08:00
Liam Newman
c9589b73f4 Merge pull request #722 from github-api/dependabot/maven/org.mockito-mockito-core-3.3.1
Bump mockito-core from 3.3.0 to 3.3.1
2020-02-28 08:37:41 -08:00
Liam Newman
32f4425100 Merge pull request #721 from github-api/dependabot/maven/com.github.tomakehurst-wiremock-jre8-standalone-2.26.1
Bump wiremock-jre8-standalone from 2.26.0 to 2.26.1
2020-02-28 08:37:27 -08:00
XiongKezhi
05e81484f1 format code 2020-02-28 16:57:19 +08:00
XiongKezhi
10cc79f737 add more properties to GHCheckRun 2020-02-28 15:40:51 +08:00
dependabot-preview[bot]
957d9b180d Bump mockito-core from 3.3.0 to 3.3.1
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.3.0 to 3.3.1.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.3.0...v3.3.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-28 06:31:41 +00:00
dependabot-preview[bot]
883204fc43 Bump wiremock-jre8-standalone from 2.26.0 to 2.26.1
Bumps [wiremock-jre8-standalone](https://github.com/tomakehurst/wiremock) from 2.26.0 to 2.26.1.
- [Release notes](https://github.com/tomakehurst/wiremock/releases)
- [Commits](https://github.com/tomakehurst/wiremock/compare/2.26.0...2.26.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-28 06:31:11 +00:00
Liam Newman
6d3904fbbd Change name of inject methods 2020-02-27 14:27:57 -08:00
Liam Newman
56a51f18e7 Update src/main/java/org/kohsuke/github/GHIssue.java 2020-02-27 14:20:03 -08:00
Liam Newman
307508b7a0 Move GHGist from late binding to inject bind 2020-02-27 10:23:54 -08:00
Liam Newman
66fce79427 Add ability to inject other local bindings 2020-02-27 10:23:31 -08:00
Liam Newman
5e5708d8d4 Clean up GHPerson deprecated a bit more 2020-02-27 10:16:48 -08:00
Liam Newman
944d92bbb4 Make more methods as deprecated 2020-02-27 09:40:03 -08:00
Liam Newman
0155d5aa39 Make HttpConnector a functional interface 2020-02-27 09:39:03 -08:00
Liam Newman
fe4f45c2b0 Remove DeleteToken class the was never in github v3 api 2020-02-27 09:38:50 -08:00
Liam Newman
1b63a58e63 Increase coverage 2020-02-27 09:38:24 -08:00
Liam Newman
46a141db9c Use consistent templating for all tests 2020-02-25 14:43:37 -08:00
Liam Newman
66de06956c Merge pull request #696 from nobe0716/feature/delete_branch_automatically
Add automatic deletion of branches that merged by PR
2020-02-25 13:44:01 -08:00
Liam Newman
713dd62bd1 Take new snapshot 2020-02-25 12:37:58 -08:00
Liam Newman
5ac65aafad Merge pull request #715 from Sage-Pierce/#714
[#714]Fix query parameter construction of org member filter
2020-02-25 12:17:30 -08:00
Liam Newman
4aef92e6fe Merge pull request #717 from bitwiseman/task/remove-fetch-array
Deprecate PagedIterable.asList() and PagedIterable.asSet()
2020-02-25 12:14:39 -08:00
Sage Pierce
a1b0e771e5 Merge branch 'master' into #714 2020-02-25 08:46:30 -06:00
spierce
5baeac4706 [#714]More specific assertions; Add test for members with filter 2020-02-25 08:42:10 -06:00
Noah J
87aa9bd673 Merge branch 'master' into feature/delete_branch_automatically 2020-02-25 14:22:14 +09:00
Liam Newman
2ec5ca56d5 Merge branch 'master' into task/remove-fetch-array 2020-02-24 20:34:26 -08:00
Liam Newman
b5c7f83ec8 Merge pull request #718 from bitwiseman/task/iterator-remove
Task/iterator remove
2020-02-24 20:30:35 -08:00
Liam Newman
eb3ebdbf52 Merge pull request #716 from bitwiseman/task/inject-response
Use InjectableValue to provide response info
2020-02-24 20:04:40 -08:00
Liam Newman
c60698ff7e Iterator.remove() has a default implementation 2020-02-24 20:03:50 -08:00
Liam Newman
f8c2cda257 Use InjectableValue to provide response info 2020-02-24 19:54:40 -08:00
Liam Newman
48f6c195e0 Remove toIterable from RequestBuilder 2020-02-24 19:31:53 -08:00
Liam Newman
804fa60317 Deprecate asList and asSet 2020-02-24 18:40:23 -08:00
Liam Newman
d77b99d3d4 Remove fetchArray method 2020-02-24 18:28:18 -08:00
spierce
006f1271d6 [#714]Add test for new method 2020-02-24 17:22:03 -06:00
spierce
0d14514712 [#714]Formatting fix 2020-02-24 16:47:35 -06:00
spierce
f25e5f9488 [#714]Fix query parameter construction of org member filter 2020-02-24 15:57:08 -06:00
Liam Newman
9e8bbfd175 Merge pull request #712 from github-api/dependabot/maven/org.mockito-mockito-core-3.3.0
Bump mockito-core from 3.2.4 to 3.3.0
2020-02-24 07:23:34 -08:00
Liam Newman
3d11c96e23 Merge pull request #713 from github-api/oleg-nenashev-patch-1
Fix scm.url in pom.xml so that Dependabot can pick up changelogs
2020-02-24 07:23:10 -08:00
Oleg Nenashev
a670737ca5 Fix scm.url in pom.xml so that Dependabot can pick up changelogs 2020-02-24 10:10:30 +01:00
dependabot-preview[bot]
9fdd982e73 Bump mockito-core from 3.2.4 to 3.3.0
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.2.4 to 3.3.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.2.4...v3.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-24 06:44:28 +00:00
Liam Newman
8024918e08 [maven-release-plugin] prepare for next development iteration 2020-02-22 20:19:04 -08:00
Liam Newman
816c83c80a Merge branch 'master' into feature/delete_branch_automatically 2020-02-22 19:33:46 -08:00
sunghyo-jung
d34881aa25 Add updated mapping files 2020-02-17 18:43:59 +09:00
sunghyo-jung
b8ad48997b Rollback field name, add mapping files
`delete_branch_on_merge` is field of github repository,
So use it as same literal (ref. https://developer.github.com/v3/repos/)

Use `getRepository` instead of `getTempRepository` at GHRepositoryTest
2020-02-17 18:42:30 +09:00
sunghyo-jung
77754b7246 Merge branch 'feature/delete_branch_automatically' of https://github.com/nobe0716/github-api into feature/delete_branch_automatically 2020-02-17 17:05:19 +09:00
sunghyo-jung
6d5bf49a51 Apply CamelCase on field delete_branch_on_merge 2020-02-17 17:03:43 +09:00
Noah J
f53b4e959c Merge branch 'master' into feature/delete_branch_automatically 2020-02-14 01:44:39 +09:00
nobe0716
6716d156bb Apply changes 2020-02-14 01:44:04 +09:00
sunghyo-jung
d7bb171c1e Add automatic deletion of branches that merged by PR
Add method to Toggle `delete_branch_on_merge`
Locate new fields below to merge options
2020-02-12 19:02:31 +09:00
241 changed files with 5407 additions and 636 deletions

16
pom.xml
View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.107</version>
<version>1.108</version>
<name>GitHub API for Java</name>
<url>https://github-api.kohsuke.org/</url>
<description>GitHub API for Java</description>
@@ -10,8 +10,8 @@
<scm>
<connection>scm:git:git@github.com/github-api/${project.artifactId}.git</connection>
<developerConnection>scm:git:ssh://git@github.com/github-api/${project.artifactId}.git</developerConnection>
<url>https://${project.artifactId}.kohsuke.org/</url>
<tag>github-api-1.107</tag>
<url>https://github.com/github-api/github-api/</url>
<tag>github-api-1.108</tag>
</scm>
<distributionManagement>
@@ -42,7 +42,7 @@
<formatter-maven-plugin.goal>format</formatter-maven-plugin.goal>
<impsort-maven-plugin.goal>sort</impsort-maven-plugin.goal>
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
<jacoco.coverage.target.bundle.method>0.556</jacoco.coverage.target.bundle.method>
<jacoco.coverage.target.bundle.method>0.60</jacoco.coverage.target.bundle.method>
<jacoco.coverage.target.class.method>0.25</jacoco.coverage.target.class.method>
<!-- For non-ci builds we'd like the build to still complete if jacoco metrics aren't met. -->
<jacoco.haltOnFailure>false</jacoco.haltOnFailure>
@@ -146,14 +146,12 @@
<exclude>org.kohsuke.github.example.*</exclude>
<!-- No methods -->
<exclude>org.kohsuke.github.DeleteToken</exclude>
<exclude>org.kohsuke.github.Previews</exclude>
<!-- Deprecated -->
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
<exclude>org.kohsuke.github.EnforcementLevel</exclude>
<exclude>org.kohsuke.github.GHPerson.1</exclude>
<exclude>org.kohsuke.github.GHPerson.1.1</exclude>
<!-- These fail coverage on windows because tests are disabled -->
<exclude>org.kohsuke.github.GHAsset</exclude>
@@ -161,7 +159,6 @@
<exclude>org.kohsuke.github.GHRelease</exclude>
<!-- TODO: These still need test coverage -->
<exclude>org.kohsuke.github.GitHubClient.GHApiInfo</exclude>
<exclude>org.kohsuke.github.GHBranchProtection.RequiredSignatures</exclude>
<exclude>org.kohsuke.github.GHBranchProtectionBuilder.Restrictions</exclude>
<exclude>org.kohsuke.github.GHBranchProtection.Restrictions</exclude>
@@ -202,7 +199,6 @@
<exclude>org.kohsuke.github.GHTeam.Role</exclude>
<exclude>org.kohsuke.github.GHUserSearchBuilder.Sort</exclude>
<exclude>org.kohsuke.github.GHVerifiedKey</exclude>
<exclude>org.kohsuke.github.GitHubBuilder.1</exclude>
</excludes>
</rule>
</rules>
@@ -495,7 +491,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.2.4</version>
<version>3.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -507,7 +503,7 @@
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<version>2.26.0</version>
<version>2.26.2</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -7,6 +7,7 @@ import java.net.HttpURLConnection;
/**
* Pluggable strategy to determine what to do when the API abuse limit is hit.
*
* @author Kohsuke Kawaguchi
* @see GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler) GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler)
* @see <a href="https://developer.github.com/v3/#abuse-rate-limits">documentation</a>
* @see RateLimitHandler
@@ -31,6 +32,7 @@ public abstract class AbuseLimitHandler {
* @see <a href=
* "https://developer.github.com/v3/guides/best-practices-for-integrators/#dealing-with-abuse-rate-limits">Dealing
* with abuse rate limits</a>
*
*/
public abstract void onError(IOException e, HttpURLConnection uc) throws IOException;

View File

@@ -1,34 +0,0 @@
/*
* The MIT License
*
* Copyright (c) 2010, Kohsuke Kawaguchi
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
*/
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD",
justification = "Being constructed by JSON deserialization")
class DeleteToken {
public String delete_token;
}

View File

@@ -4,6 +4,8 @@ import java.util.Locale;
/**
* This was added during preview API period but it has changed since then.
*
* @author Kohsuke Kawaguchi
*/
@Deprecated
public enum EnforcementLevel {

View File

@@ -10,6 +10,7 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
/**
* A Github App.
*
* @author Paulo Miguel Almeida
* @see GitHub#getApp() GitHub#getApp()
*/
public class GHApp extends GHObject {

View File

@@ -10,6 +10,7 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
/**
* Creates a access token for a GitHub App Installation
*
* @author Paulo Miguel Almeida
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
* @see GHAppInstallation#createToken() GHAppInstallation#createToken()
*/

View File

@@ -12,6 +12,7 @@ import static org.kohsuke.github.Previews.GAMBIT;
/**
* A Github App Installation.
*
* @author Paulo Miguel Almeida
* @see GHApp#listInstallations() GHApp#listInstallations()
* @see GHApp#getInstallationById(long) GHApp#getInstallationById(long)
* @see GHApp#getInstallationByOrganization(String) GHApp#getInstallationByOrganization(String)

View File

@@ -11,6 +11,7 @@ import java.util.Map;
/**
* A Github App Installation Token.
*
* @author Paulo Miguel Almeida
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
*/
public class GHAppInstallationToken {

View File

@@ -9,6 +9,7 @@ import java.util.List;
/**
* Generated OAuth token
*
* @author janinko
* @see GitHub#createToken(Collection, String, String) GitHub#createToken(Collection, String, String)
* @see <a href="http://developer.github.com/v3/oauth/#create-a-new-authorization">API documentation</a>
*/

View File

@@ -8,6 +8,7 @@ import java.util.Base64;
/**
* The type GHBlob.
*
* @author Kanstantsin Shautsou
* @author Kohsuke Kawaguchi
* @see GHTreeEntry#asBlob() GHTreeEntry#asBlob()
* @see GHRepository#getBlob(String) GHRepository#getBlob(String)

View File

@@ -11,6 +11,8 @@ import java.util.Objects;
/**
* A branch in a repository.
*
* @author Yusuke Kokubo
*/
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",

View File

@@ -4,13 +4,13 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
/**
* Represents a check run.
*
* @see <a href="https://developer.github.com/v3/checks/runs/">documentation</a>
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHCheckRun extends GHObject {
@@ -21,7 +21,16 @@ public class GHCheckRun extends GHObject {
private String conclusion;
private String name;
private String headSha;
private String nodeId;
private String externalId;
private String startedAt;
private String completedAt;
private URL htmlUrl;
private URL detailsUrl;
private Output output;
private GHApp app;
private GHPullRequest[] pullRequests;
private GHCheckSuite checkSuite;
GHCheckRun wrap(GHRepository owner) {
this.owner = owner;
@@ -41,14 +50,30 @@ public class GHCheckRun extends GHObject {
return pullRequests;
}
/**
* Gets status of the check run. It can be one of "queue", "in_progress", or "completed"
*
* @return Status of the check run
*/
public String getStatus() {
return status;
}
/**
* Gets conclusion of a completed check run. It can be one of "success", "failure", "neutral", "cancelled",
* "time_out", or "action_required".
*
* @return Status of the check run
*/
public String getConclusion() {
return conclusion;
}
/**
* Gets the custom name of this check run.
*
* @return Name of the check run
*/
public String getName() {
return name;
}
@@ -62,6 +87,11 @@ public class GHCheckRun extends GHObject {
return headSha;
}
/**
* Gets the pull requests participated in this check run.
*
* @return Pull requests of this check run
*/
GHPullRequest[] getPullRequests() throws IOException {
if (pullRequests != null && pullRequests.length != 0) {
for (GHPullRequest singlePull : pullRequests) {
@@ -72,11 +102,145 @@ public class GHCheckRun extends GHObject {
}
/**
* @deprecated This object has no HTML URL.
* Gets the HTML URL: https://github.com/[owner]/[repo-name]/runs/[check-run-id], usually an GitHub Action page of
* the check run.
*
* @return HTML URL
*/
@Override
public URL getHtmlUrl() {
return null;
return htmlUrl;
}
/**
* Gets the global node id to access most objects in GitHub.
*
* @see <a href="https://developer.github.com/v4/guides/using-global-node-ids/">documentation</a>
* @return Global node id
*/
public String getNodeId() {
return nodeId;
}
/**
* Gets a reference for the check run on the integrator's system.
*
* @return Reference id
*/
public String getExternalId() {
return externalId;
}
/**
* Gets the details URL from which to find full details of the check run on the integrator's site.
*
* @return Details URL
*/
public URL getDetailsUrl() {
return detailsUrl;
}
/**
* Gets the start time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
*
* @return Timestamp of the start time
*/
public Date getStartedAt() {
return GitHubClient.parseDate(startedAt);
}
/**
* Gets the completed time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
*
* @return Timestamp of the completed time
*/
public Date getCompletedAt() {
return GitHubClient.parseDate(completedAt);
}
/**
* Gets the GitHub app this check run belongs to, included in response.
*
* @return GitHub App
*/
public GHApp getApp() {
return app;
}
/**
* Gets the check suite this check run belongs to
*
* @return Check suite
*/
public GHCheckSuite getCheckSuite() {
return checkSuite;
}
/**
* Gets an output for a check run.
*
* @return Output of a check run
*/
public Output getOutput() {
return output;
}
/**
* Represents an output in a check run to include summary and other results.
*
* @see <a href="https://developer.github.com/v3/checks/runs/#output-object">documentation</a>
*/
public static class Output {
private String title;
private String summary;
private String text;
private int annotationsCount;
private URL annotationsUrl;
/**
* Gets the title of check run.
*
* @return title of check run
*/
public String getTitle() {
return title;
}
/**
* Gets the summary of the check run, note that it supports Markdown.
*
* @return summary of check run
*/
public String getSummary() {
return summary;
}
/**
* Gets the details of the check run, note that it supports Markdown.
*
* @return Details of the check run
*/
public String getText() {
return text;
}
/**
* Gets the annotation count of a check run.
*
* @return annotation count of a check run
*/
public int getAnnotationsCount() {
return annotationsCount;
}
/**
* Gets the URL of annotations.
*
* @return URL of annotations
*/
public URL getAnnotationsUrl() {
return annotationsUrl;
}
}
}

View File

@@ -0,0 +1,239 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
/**
* Represents a check suite.
*
* @see <a href="https://developer.github.com/v3/checks/suites/">documentation</a>
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHCheckSuite extends GHObject {
GHRepository owner;
GitHub root;
private String nodeId;
private String headBranch;
private String headSha;
private String status;
private String conclusion;
private String before;
private String after;
private int latestCheckRunsCount;
private URL checkRunsUrl;
private HeadCommit headCommit;
private GHApp app;
private GHPullRequest[] pullRequests;
GHCheckSuite wrap(GHRepository owner) {
this.owner = owner;
this.root = owner.root;
return this;
}
GHCheckSuite wrap(GitHub root) {
this.root = root;
if (owner != null) {
owner.wrap(root);
}
return this;
}
GHPullRequest[] wrap() {
return pullRequests;
}
/**
* Gets the global node id to access most objects in GitHub.
*
* @see <a href="https://developer.github.com/v4/guides/using-global-node-ids/">documentation</a>
* @return global node id
*/
public String getNodeId() {
return nodeId;
}
/**
* The head branch name the changes are on.
*
* @return head branch name
*/
public String getHeadBranch() {
return headBranch;
}
/**
* Gets the HEAD SHA.
*
* @return sha for the HEAD commit
*/
public String getHeadSha() {
return headSha;
}
/**
* Gets status of the check suite. It can be one of request, in_progress, or completed.
*
* @return status of the check suite
*/
public String getStatus() {
return status;
}
/**
* Gets conclusion of a completed check suite. It can be one of success, failure, neutral, cancelled, time_out,
* action_required, or stale. The check suite will report the highest priority check run conclusion in the check
* suite's conclusion.
*
* @return conclusion of the check suite
*/
public String getConclusion() {
return conclusion;
}
/**
* The SHA of the most recent commit on ref before the push.
*
* @return sha of a commit
*/
public String getBefore() {
return before;
}
/**
* The SHA of the most recent commit on ref after the push.
*
* @return sha of a commit
*/
public String getAfter() {
return after;
}
/**
* The quantity of check runs that had run as part of the latest push.
*
* @return sha of the most recent commit
*/
public int getLatestCheckRunsCount() {
return latestCheckRunsCount;
}
/**
* The url used to list all the check runs belonged to this suite.
*
* @return url containing all check runs
*/
public URL getCheckRunsUrl() {
return checkRunsUrl;
}
/**
* The commit of current head.
*
* @return head commit
*/
public HeadCommit getHeadCommit() {
return headCommit;
}
/**
* Gets the GitHub app this check suite belongs to, included in response.
*
* @return GitHub App
*/
public GHApp getApp() {
return app;
}
/**
* Gets the pull requests participated in this check suite.
*
* @return Pull requests
*/
GHPullRequest[] getPullRequests() throws IOException {
if (pullRequests != null && pullRequests.length != 0) {
for (GHPullRequest singlePull : pullRequests) {
singlePull.refresh();
}
}
return pullRequests;
}
/**
* Check suite doesn't have a HTML URL.
*
* @return null
*/
@Override
public URL getHtmlUrl() {
return null;
}
public static class HeadCommit {
private String id;
private String treeId;
private String message;
private String timestamp;
private GitUser author;
private GitUser committer;
/**
* Gets id of the commit, used by {@link GHCheckSuite} when a {@link GHEvent#CHECK_SUITE} comes
*
* @return id of the commit
*/
public String getId() {
return id;
}
/**
* Gets id of the tree.
*
* @return id of the tree
*/
public String getTreeId() {
return treeId;
}
/**
* Gets message.
*
* @return commit message.
*/
public String getMessage() {
return message;
}
/**
* Gets timestamp of the commit.
*
* @return timestamp of the commit
*/
public Date getTimestamp() {
return GitHubClient.parseDate(timestamp);
}
/**
* Gets author.
*
* @return the author
*/
public GitUser getAuthor() {
return author;
}
/**
* Gets committer.
*
* @return the committer
*/
public GitUser getCommitter() {
return committer;
}
}
}

View File

@@ -2,6 +2,8 @@ package org.kohsuke.github;
/**
* How is an user associated with a repository?
*
* @author Kohsuke Kawaguchi
*/
public enum GHCommentAuthorAssociation {
/**

View File

@@ -14,6 +14,7 @@ import java.util.List;
/**
* A commit in a repository.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#getCommit(String) GHRepository#getCommit(String)
* @see GHCommitComment#getCommit() GHCommitComment#getCommit()
*/

View File

@@ -10,6 +10,7 @@ import static org.kohsuke.github.Previews.*;
/**
* A comment attached to a commit (or a specific line in a specific file of a commit.)
*
* @author Kohsuke Kawaguchi
* @see GHRepository#listCommitComments() GHRepository#listCommitComments()
* @see GHCommit#listComments() GHCommit#listComments()
* @see GHCommit#createComment(String, String, Integer, Integer) GHCommit#createComment(String, String, Integer,

View File

@@ -27,6 +27,8 @@ import java.io.IOException;
/**
* Identifies a commit in {@link GHPullRequest}.
*
* @author Kohsuke Kawaguchi
*/
public class GHCommitPointer {
private String ref, sha, label;

View File

@@ -15,6 +15,7 @@ import java.util.Date;
* }
* </pre>
*
* @author Kohsuke Kawaguchi
* @see GHRepository#queryCommits() GHRepository#queryCommits()
*/
public class GHCommitQueryBuilder {

View File

@@ -7,6 +7,7 @@ import java.io.IOException;
/**
* Search commits.
*
* @author Marc de Verdelhan
* @see GitHub#searchCommits() GitHub#searchCommits()
*/
@Preview

View File

@@ -3,6 +3,7 @@ package org.kohsuke.github;
/**
* Represents the state of commit
*
* @author Kohsuke Kawaguchi
* @see GHCommitStatus
*/
public enum GHCommitState {

View File

@@ -6,6 +6,7 @@ import java.net.URL;
/**
* Represents a status of a commit.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#getLastCommitStatus(String) GHRepository#getLastCommitStatus(String)
* @see GHCommit#getLastStatus() GHCommit#getLastStatus()
* @see GHRepository#createCommitStatus(String, GHCommitState, String, String) GHRepository#createCommitStatus(String,

View File

@@ -7,6 +7,8 @@ import java.net.URL;
/**
* The model user for comparing 2 commits in the GitHub API.
*
* @author Michael Clarke
*/
public class GHCompare {

View File

@@ -11,6 +11,7 @@ import java.util.Base64;
/**
* A Content of a repository.
*
* @author Alexandre COLLIGNON
* @see GHRepository#getFileContent(String) GHRepository#getFileContent(String)
*/
@SuppressWarnings({ "UnusedDeclaration" })
@@ -387,22 +388,6 @@ public class GHContent implements Refreshable {
return this;
}
/**
* Wrap gh content [ ].
*
* @param contents
* the contents
* @param repository
* the repository
* @return the gh content [ ]
*/
public static GHContent[] wrap(GHContent[] contents, GHRepository repository) {
for (GHContent unwrappedContent : contents) {
unwrappedContent.wrap(repository);
}
return contents;
}
/**
* Fully populate the data by retrieving missing data.
*

View File

@@ -10,6 +10,7 @@ import java.util.Base64;
* <p>
* Call various methods to build up parameters, then call {@link #commit()} to make the change effective.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#createContent() GHRepository#createContent()
*/
public final class GHContentBuilder {

View File

@@ -3,6 +3,7 @@ package org.kohsuke.github;
/**
* Search code for {@link GHContent}.
*
* @author Kohsuke Kawaguchi
* @see GitHub#searchContent() GitHub#searchContent()
*/
public class GHContentSearchBuilder extends GHSearchBuilder<GHContent> {

View File

@@ -3,6 +3,7 @@ package org.kohsuke.github;
/**
* {@link GHContent} with license information.
*
* @author Kohsuke Kawaguchi
* @see <a href="https://developer.github.com/v3/licenses/#get-a-repositorys-license">documentation</a>
* @see GHRepository#getLicense()
*/

View File

@@ -5,6 +5,8 @@ import java.net.URL;
/**
* Creates a repository
*
* @author Kohsuke Kawaguchi
*/
public class GHCreateRepositoryBuilder {
private final GitHub root;

View File

@@ -23,6 +23,7 @@ public class GHDeploymentStatusBuilder {
* the state
* @deprecated Use {@link GHDeployment#createStatus(GHDeploymentState)}
*/
@Deprecated
public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeploymentState state) {
this(repo, (long) deploymentId, state);
}

View File

@@ -2,6 +2,8 @@ package org.kohsuke.github;
/**
* Sort direction
*
* @author Kohsuke Kawaguchi
*/
public enum GHDirection {
ASC, DESC

View File

@@ -27,6 +27,8 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Represents an email of GitHub.
*
* @author Kelly Campbell
*/
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",

View File

@@ -5,6 +5,7 @@ import java.util.Locale;
/**
* Hook event type.
*
* @author Kohsuke Kawaguchi
* @see GHEventInfo
* @see <a href="https://developer.github.com/v3/activity/events/types/">Event type reference</a>
*/

View File

@@ -8,6 +8,8 @@ import java.util.Date;
/**
* Represents an event.
*
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHEventInfo {
@@ -142,7 +144,7 @@ public class GHEventInfo {
* if payload cannot be parsed
*/
public <T extends GHEventPayload> T getPayload(Class<T> type) throws IOException {
T v = GitHubClient.MAPPER.readValue(payload.traverse(), type);
T v = GitHubClient.getMappingObjectReader(root).readValue(payload.traverse(), type);
v.wrapUp(root);
return v;
}

View File

@@ -132,6 +132,7 @@ public abstract class GHEventPayload {
* @return the repository
*/
public GHRepository getRepository() {
repository.root = root;
return repository;
}
@@ -150,6 +151,48 @@ public abstract class GHEventPayload {
}
}
/**
* A check suite event has been requested, rerequested or completed.
*
* @see <a href="https://developer.github.com/v3/activity/events/types/#checkrunevent">authoritative source</a>
*/
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public static class CheckSuite extends GHEventPayload {
private String action;
private GHCheckSuite checkSuite;
private GHRepository repository;
/**
* Gets action.
*
* @return the action
*/
public String getAction() {
return action;
}
/**
* Gets the Check Suite object
*
* @return the Check Suite object
*/
public GHCheckSuite getCheckSuite() {
return checkSuite;
}
/**
* Gets repository.
*
* @return the repository
*/
public GHRepository getRepository() {
repository.root = root;
return repository;
}
}
/**
* A pull request status has changed.
*

View File

@@ -2,6 +2,8 @@ package org.kohsuke.github;
/**
* The type GHException.
*
* @author Kohsuke Kawaguchi
*/
public class GHException extends RuntimeException {
/**

View File

@@ -9,6 +9,8 @@ import javax.annotation.Nonnull;
/**
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
*
* @author Kanstantsin Shautsou
*/
public class GHFileNotFoundException extends FileNotFoundException {
protected Map<String, List<String>> responseHeaderFields;

View File

@@ -1,26 +1,29 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
* Gist
*
* @author Kohsuke Kawaguchi
* @see GHUser#listGists() GHUser#listGists()
* @see GitHub#getGist(String) GitHub#getGist(String)
* @see GitHub#createGist() GitHub#createGist()
* @see <a href="https://developer.github.com/v3/gists/">documentation</a>
*/
public class GHGist extends GHObject {
/* package almost final */ GHUser owner;
/* package almost final */ GitHub root;
final GHUser owner;
final GitHub root;
private String forks_url, commits_url, id, git_pull_url, git_push_url, html_url;
@@ -33,7 +36,19 @@ public class GHGist extends GHObject {
private String comments_url;
private Map<String, GHGistFile> files = new HashMap<String, GHGistFile>();
private final Map<String, GHGistFile> files;
@JsonCreator
private GHGist(@JacksonInject GitHub root,
@JsonProperty("owner") GHUser owner,
@JsonProperty("files") Map<String, GHGistFile> files) {
this.root = root;
for (Entry<String, GHGistFile> e : files.entrySet()) {
e.getValue().fileName = e.getKey();
}
this.files = Collections.unmodifiableMap(files);
this.owner = root.getUser(owner);
}
/**
* Gets owner.
@@ -43,7 +58,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public GHUser getOwner() throws IOException {
return root.intern(owner);
return owner;
}
/**
@@ -139,31 +154,7 @@ public class GHGist extends GHObject {
* @return the files
*/
public Map<String, GHGistFile> getFiles() {
return Collections.unmodifiableMap(files);
}
GHGist wrapUp(GHUser owner) {
this.owner = owner;
this.root = owner.root;
wrapUp();
return this;
}
/**
* Used when caller obtains {@link GHGist} without knowing its owner. A partially constructed owner object is
* interned.
*/
GHGist wrapUp(GitHub root) {
this.owner = root.getUser(owner);
this.root = root;
wrapUp();
return this;
}
private void wrapUp() {
for (Entry<String, GHGistFile> e : files.entrySet()) {
e.getValue().fileName = e.getKey();
}
return files;
}
String getApiTailUrl(String tail) {
@@ -213,7 +204,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public GHGist fork() throws IOException {
return root.createRequest().method("POST").withUrlPath(getApiTailUrl("forks")).fetch(GHGist.class).wrapUp(root);
return root.createRequest().method("POST").withUrlPath(getApiTailUrl("forks")).fetch(GHGist.class);
}
/**
@@ -222,9 +213,7 @@ public class GHGist extends GHObject {
* @return the paged iterable
*/
public PagedIterable<GHGist> listForks() {
return root.createRequest()
.withUrlPath(getApiTailUrl("forks"))
.toIterable(GHGist[].class, item -> item.wrapUp(root));
return root.createRequest().withUrlPath(getApiTailUrl("forks")).toIterable(GHGist[].class, null);
}
/**
@@ -263,10 +252,4 @@ public class GHGist extends GHObject {
public int hashCode() {
return id.hashCode();
}
GHGist wrap(GHUser owner) {
this.owner = owner;
this.root = owner.root;
return this;
}
}

View File

@@ -7,6 +7,7 @@ import java.util.LinkedHashMap;
/**
* Builder pattern for creating a new Gist.
*
* @author Kohsuke Kawaguchi
* @see GitHub#createGist() GitHub#createGist()
*/
public class GHGistBuilder {
@@ -72,6 +73,6 @@ public class GHGistBuilder {
*/
public GHGist create() throws IOException {
req.with("files", files);
return req.withUrlPath("/gists").fetch(GHGist.class).wrapUp(root);
return req.withUrlPath("/gists").fetch(GHGist.class);
}
}

View File

@@ -3,6 +3,7 @@ package org.kohsuke.github;
/**
* A file inside {@link GHGist}
*
* @author Kohsuke Kawaguchi
* @see GHGist#getFile(String) GHGist#getFile(String)
* @see GHGist#getFiles() GHGist#getFiles()
*/

View File

@@ -6,6 +6,8 @@ import java.util.LinkedHashMap;
/**
* Builder pattern for updating a Gist.
*
* @author Martin van Zijl
*/
public class GHGistUpdater {
private final GHGist base;
@@ -94,6 +96,6 @@ public class GHGistUpdater {
*/
public GHGist update() throws IOException {
builder.with("files", files);
return builder.method("PATCH").withUrlPath(base.getApiTailUrl("")).fetch(GHGist.class).wrap(base.owner);
return builder.method("PATCH").withUrlPath(base.getApiTailUrl("")).fetch(GHGist.class);
}
}

View File

@@ -12,6 +12,8 @@ import java.util.Map;
/**
* The type GHHook.
*
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")

View File

@@ -9,6 +9,8 @@ import javax.annotation.Nonnull;
/**
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
*
* @author Kanstantsin Shautsou
*/
public class GHIOException extends IOException {
protected Map<String, List<String>> responseHeaderFields;

View File

@@ -43,6 +43,7 @@ import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
/**
* Represents an issue on GitHub.
*
* @author Eric Maupin
* @author Kohsuke Kawaguchi
* @see GHRepository#getIssue(int) GHRepository#getIssue(int)
* @see GitHub#searchIssues() GitHub#searchIssues()
@@ -63,8 +64,7 @@ public class GHIssue extends GHObject implements Reactable {
protected int comments;
@SkipFromToString
protected String body;
// for backward compatibility with < 1.63, this collection needs to hold instances of Label, not GHLabel
protected List<Label> labels;
protected List<GHLabel> labels;
protected GHUser user;
protected String title, html_url;
protected GHIssue.PullRequest pull_request;
@@ -72,14 +72,6 @@ public class GHIssue extends GHObject implements Reactable {
protected GHUser closed_by;
protected boolean locked;
/**
* The type Label.
*
* @deprecated use {@link GHLabel}
*/
public static class Label extends GHLabel {
}
GHIssue wrap(GHRepository owner) {
this.owner = owner;
if (milestone != null)
@@ -100,12 +92,6 @@ public class GHIssue extends GHObject implements Reactable {
return this;
}
static GHIssue[] wrap(GHIssue[] issues, GHRepository owner) {
for (GHIssue i : issues)
i.wrap(owner);
return issues;
}
/**
* Repository to which the issue belongs.
*
@@ -178,7 +164,7 @@ public class GHIssue extends GHObject implements Reactable {
if (labels == null) {
return Collections.emptyList();
}
return Collections.<GHLabel>unmodifiableList(labels);
return Collections.unmodifiableList(labels);
}
/**
@@ -434,7 +420,7 @@ public class GHIssue extends GHObject implements Reactable {
* @see #listComments() #listComments()
*/
public List<GHIssueComment> getComments() throws IOException {
return listComments().asList();
return listComments().toList();
}
/**

View File

@@ -6,6 +6,8 @@ import java.util.List;
/**
* The type GHIssueBuilder.
*
* @author Kohsuke Kawaguchi
*/
public class GHIssueBuilder {
private final GHRepository repo;

View File

@@ -31,6 +31,7 @@ import static org.kohsuke.github.Previews.*;
/**
* Comment to the issue
*
* @author Kohsuke Kawaguchi
* @see GHIssue#comment(String) GHIssue#comment(String)
* @see GHIssue#listComments() GHIssue#listComments()
*/

View File

@@ -4,6 +4,8 @@ import java.util.Date;
/**
* The type GHIssueEvent.
*
* @author Martin van Zijl
*/
public class GHIssueEvent {
private GitHub root;

View File

@@ -3,6 +3,7 @@ package org.kohsuke.github;
/**
* Search issues.
*
* @author Kohsuke Kawaguchi
* @see GitHub#searchIssues() GitHub#searchIssues()
*/
public class GHIssueSearchBuilder extends GHSearchBuilder<GHIssue> {

View File

@@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* SSH public key.
*
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHKey {

View File

@@ -9,6 +9,7 @@ import java.util.Objects;
/**
* The type GHLabel.
*
* @author Kohsuke Kawaguchi
* @see GHIssue#getLabels() GHIssue#getLabels()
* @see GHRepository#listLabels() GHRepository#listLabels()
*/

View File

@@ -35,6 +35,7 @@ import java.util.List;
/**
* The GitHub Preview API's license information
*
* @author Duncan Dickinson
* @see GitHub#getLicense(String) GitHub#getLicense(String)
* @see GHRepository#getLicense() GHRepository#getLicense()
* @see <a href="https://developer.github.com/v3/licenses/">https://developer.github.com/v3/licenses/</a>

View File

@@ -5,6 +5,7 @@ import java.net.URL;
/**
* Base class for Github Marketplace Account.
*
* @author Paulo Miguel Almeida
* @see GitHub#getMyMarketplacePurchases()
* @see GHMarketplaceListAccountBuilder#createRequest()
*/

View File

@@ -5,6 +5,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* A Github Marketplace Account Plan.
*
* @author Paulo Miguel Almeida
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplaceAccountPlan extends GHMarketplaceAccount {

View File

@@ -7,6 +7,7 @@ import java.util.Locale;
/**
* GitHub Marketplace Account type.
*
* @author Paulo Miguel Almeida
* @see GHMarketplaceAccount
*/
public enum GHMarketplaceAccountType {

View File

@@ -5,6 +5,7 @@ import java.io.IOException;
/**
* Returns any accounts associated with a plan, including free plans
*
* @author Paulo Miguel Almeida
* @see GHMarketplacePlan#listAccounts()
*/
public class GHMarketplaceListAccountBuilder {

View File

@@ -7,6 +7,7 @@ import java.util.Date;
/**
* A Github Marketplace purchase pending change.
*
* @author Paulo Miguel Almeida
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplacePendingChange {

View File

@@ -8,6 +8,7 @@ import java.util.List;
/**
* A Github Marketplace plan.
*
* @author Paulo Miguel Almeida
* @see GitHub#listMarketplacePlans()
*/
public class GHMarketplacePlan {

View File

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
/**
* GitHub Marketplace plan pricing model.
*
* @author Paulo Miguel Almeida
* @see GHMarketplacePlan
*/
public enum GHMarketplacePriceModel {

View File

@@ -7,6 +7,7 @@ import java.util.Date;
/**
* A Github Marketplace purchase.
*
* @author Paulo Miguel Almeida
* @see GHMarketplaceListAccountBuilder#createRequest() GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplacePurchase {

View File

@@ -7,6 +7,7 @@ import java.util.Date;
/**
* Github Marketplace User Purchase
*
* @author Paulo Miguel Almeida
* @see GitHub#getMyMarketplacePurchases()
*/
public class GHMarketplaceUserPurchase {

View File

@@ -7,6 +7,7 @@ import java.util.Locale;
/**
* Represents a membership of a user in an organization.
*
* @author Kohsuke Kawaguchi
* @see GHMyself#listOrgMemberships() GHMyself#listOrgMemberships()
*/
public class GHMembership /* extends GHObject --- but it doesn't have id, created_at, etc. */ {
@@ -83,11 +84,6 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
return this;
}
static void wrap(GHMembership[] page, GitHub root) {
for (GHMembership m : page)
m.wrap(root);
}
/**
* Role of a user in an organization.
*/

View File

@@ -9,6 +9,7 @@ import java.util.List;
/**
* Class that wraps the list of GitHub's IP addresses.
*
* @author Paulo Miguel Almeida
* @see GitHub#getMeta() GitHub#getMeta()
* @see <a href="https://developer.github.com/v3/meta/#meta">Get Meta</a>
*/

View File

@@ -7,6 +7,8 @@ import java.util.Locale;
/**
* The type GHMilestone.
*
* @author Yusuke Kokubo
*/
public class GHMilestone extends GHObject {
GitHub root;

View File

@@ -2,6 +2,8 @@ package org.kohsuke.github;
/**
* The enum GHMilestoneState.
*
* @author Yusuke Kokubo
*/
public enum GHMilestoneState {
OPEN, CLOSED

View File

@@ -2,7 +2,6 @@ package org.kohsuke.github;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -12,6 +11,8 @@ import java.util.TreeMap;
/**
* Represents the account that's logging into GitHub.
*
* @author Kohsuke Kawaguchi
*/
public class GHMyself extends GHUser {
@@ -69,8 +70,7 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHEmail> getEmails2() throws IOException {
GHEmail[] addresses = root.createRequest().withUrlPath("/user/emails").fetchArray(GHEmail[].class);
return Collections.unmodifiableList(Arrays.asList(addresses));
return root.createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null).toList();
}
/**
@@ -84,8 +84,7 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHKey> getPublicKeys() throws IOException {
return Collections.unmodifiableList(
Arrays.asList(root.createRequest().withUrlPath("/user/keys").fetchArray(GHKey[].class)));
return root.createRequest().withUrlPath("/user/keys").toIterable(GHKey[].class, null).toList();
}
/**
@@ -99,8 +98,10 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHVerifiedKey> getPublicVerifiedKeys() throws IOException {
return Collections.unmodifiableList(Arrays.asList(
root.createRequest().withUrlPath("/users/" + getLogin() + "/keys").fetchArray(GHVerifiedKey[].class)));
return root.createRequest()
.withUrlPath("/users/" + getLogin() + "/keys")
.toIterable(GHVerifiedKey[].class, null)
.toList();
}
/**
@@ -113,7 +114,10 @@ public class GHMyself extends GHUser {
public GHPersonSet<GHOrganization> getAllOrganizations() throws IOException {
GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>();
Set<String> names = new HashSet<String>();
for (GHOrganization o : root.createRequest().withUrlPath("/user/orgs").fetchArray(GHOrganization[].class)) {
for (GHOrganization o : root.createRequest()
.withUrlPath("/user/orgs")
.toIterable(GHOrganization[].class, null)
.toArray()) {
if (names.add(o.getLogin())) // in case of rumoured duplicates in the data
orgs.add(root.getOrganization(o.getLogin()));
}
@@ -187,6 +191,7 @@ public class GHMyself extends GHUser {
* @return the paged iterable
* @deprecated Use {@link #listRepositories()}
*/
@Deprecated
public PagedIterable<GHRepository> listAllRepositories() {
return listRepositories();
}

View File

@@ -19,6 +19,7 @@ import java.util.NoSuchElementException;
* In the non-blocking mode, the iterator will only report the set of notifications initially retrieved from GitHub,
* then quit. This is useful for a batch application to process the current set of notifications.
*
* @author Kohsuke Kawaguchi
* @see GitHub#listNotifications() GitHub#listNotifications()
* @see GHRepository#listNotifications() GHRepository#listNotifications()
*/
@@ -181,7 +182,7 @@ public class GHNotificationStream implements Iterable<GHThread> {
Requester requester = req.withUrlPath(apiUrl);
GitHubResponse<GHThread[]> response = ((GitHubPageContentsIterable<GHThread>) requester
.toIterable(requester.client, GHThread[].class, null)).toResponse();
.toIterable(GHThread[].class, null)).toResponse();
threads = response.body();
if (threads == null) {
@@ -207,10 +208,6 @@ public class GHNotificationStream implements Iterable<GHThread> {
long seconds = Integer.parseInt(v);
return System.currentTimeMillis() + seconds * 1000;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}

View File

@@ -2,6 +2,8 @@ package org.kohsuke.github;
/**
* This exception is thrown when GitHub is requesting an OTP from the user
*
* @author Kevin Harrington mad.hephaestus@gmail.com
*/
public class GHOTPRequiredException extends GHIOException {
// ...

View File

@@ -1,5 +1,6 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
@@ -33,6 +34,19 @@ public abstract class GHObject {
GHObject() {
}
/**
* Called by Jackson
*
* @param responseInfo
* the {@link GitHubResponse.ResponseInfo} to get headers from.
*/
@JacksonInject
protected void setResponseHeaderFields(@CheckForNull GitHubResponse.ResponseInfo responseInfo) {
if (responseInfo != null) {
responseHeaderFields = responseInfo.headers();
}
}
/**
* Returns the HTTP response headers given along with the state of this object.
*

View File

@@ -14,6 +14,8 @@ import static org.kohsuke.github.Previews.INERTIA;
/**
* The type GHOrganization.
*
* @author Kohsuke Kawaguchi
*/
public class GHOrganization extends GHPerson {
GHOrganization wrapUp(GitHub root) {
@@ -38,6 +40,7 @@ public class GHOrganization extends GHPerson {
* the io exception
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
*/
@Deprecated
public GHRepository createRepository(String name,
String description,
String homepage,
@@ -67,6 +70,7 @@ public class GHOrganization extends GHPerson {
* the io exception
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
*/
@Deprecated
public GHRepository createRepository(String name,
String description,
String homepage,
@@ -253,7 +257,7 @@ public class GHOrganization extends GHPerson {
* @deprecated use {@link #listMembers()}
*/
public List<GHUser> getMembers() throws IOException {
return listMembers().asList();
return listMembers().toList();
}
/**
@@ -279,7 +283,7 @@ public class GHOrganization extends GHPerson {
}
private PagedIterable<GHUser> listMembers(String suffix) throws IOException {
return listMembers(suffix, null);
return listMembers(suffix, null, null);
}
/**
@@ -292,13 +296,28 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public PagedIterable<GHUser> listMembersWithFilter(String filter) throws IOException {
return listMembers("members", filter);
return listMembers("members", filter, null);
}
private PagedIterable<GHUser> listMembers(final String suffix, final String filter) throws IOException {
String filterParams = (filter == null) ? "" : ("?filter=" + filter);
/**
* List members with specified role paged iterable.
*
* @param role
* the role
* @return the paged iterable
* @throws IOException
* the io exception
*/
public PagedIterable<GHUser> listMembersWithRole(String role) throws IOException {
return listMembers("members", null, role);
}
private PagedIterable<GHUser> listMembers(final String suffix, final String filter, String role)
throws IOException {
return root.createRequest()
.withUrlPath(String.format("/orgs/%s/%s%s", login, suffix, filterParams))
.withUrlPath(String.format("/orgs/%s/%s", login, suffix))
.with("filter", filter)
.with("role", role)
.toIterable(GHUser[].class, item -> item.wrapUp(root));
}

View File

@@ -2,6 +2,8 @@ package org.kohsuke.github;
/**
* The enum GHPermissionType.
*
* @author Kohsuke Kawaguchi
*/
public enum GHPermissionType {
ADMIN, WRITE, READ, NONE

View File

@@ -2,8 +2,8 @@ package org.kohsuke.github;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
@@ -14,12 +14,14 @@ import java.util.TreeMap;
/**
* Common part of {@link GHUser} and {@link GHOrganization}.
*
* @author Kohsuke Kawaguchi
*/
public abstract class GHPerson extends GHObject {
/* package almost final */ GitHub root;
// core data fields that exist even for "small" user data (such as the user info in pull request)
protected String login, avatar_url, gravatar_id;
protected String login, avatar_url;
// other fields (that only show up in full data)
protected String location, blog, email, name, company, type;
@@ -114,29 +116,27 @@ public abstract class GHPerson extends GHObject {
*/
@Deprecated
public synchronized Iterable<List<GHRepository>> iterateRepositories(final int pageSize) {
return new Iterable<List<GHRepository>>() {
public Iterator<List<GHRepository>> iterator() {
final Iterator<GHRepository[]> pager = GitHubPageIterator.create(root.getClient(),
return () -> {
final PagedIterator<GHRepository> pager;
try {
GitHubPageIterator<GHRepository[]> iterator = GitHubPageIterator.create(root.getClient(),
GHRepository[].class,
root.createRequest().withUrlPath("users", login, "repos").withPageSize(pageSize));
return new Iterator<List<GHRepository>>() {
public boolean hasNext() {
return pager.hasNext();
}
public List<GHRepository> next() {
GHRepository[] batch = pager.next();
for (GHRepository r : batch)
r.root = root;
return Arrays.asList(batch);
}
public void remove() {
throw new UnsupportedOperationException();
}
};
root.createRequest().withUrlPath("users", login, "repos").build(),
pageSize);
pager = new PagedIterator<>(iterator, item -> item.wrap(root));
} catch (MalformedURLException e) {
throw new GHException("Unable to build GitHub API URL", e);
}
return new Iterator<List<GHRepository>>() {
public boolean hasNext() {
return pager.hasNext();
}
public List<GHRepository> next() {
return pager.nextPage();
}
};
};
}
@@ -175,22 +175,18 @@ public abstract class GHPerson extends GHObject {
* @return the gravatar id
* @deprecated No longer available in the v3 API.
*/
@Deprecated
public String getGravatarId() {
return gravatar_id;
return "";
}
/**
* Returns a string like 'https://secure.gravatar.com/avatar/0cb9832a01c22c083390f3c5dcb64105' that indicates the
* avatar image URL.
* Returns a string of the avatar image URL.
*
* @return the avatar url
*/
public String getAvatarUrl() {
if (avatar_url != null)
return avatar_url;
if (gravatar_id != null)
return "https://secure.gravatar.com/avatar/" + gravatar_id;
return null;
return avatar_url;
}
/**

View File

@@ -9,6 +9,7 @@ import java.util.HashSet;
*
* @param <T>
* the type parameter
* @author Kohsuke Kawaguchi
*/
public class GHPersonSet<T extends GHPerson> extends HashSet<T> {
private static final long serialVersionUID = 1L;

View File

@@ -33,6 +33,7 @@ import static org.kohsuke.github.Previews.INERTIA;
/**
* A GitHub project.
*
* @author Martin van Zijl
* @see <a href="https://developer.github.com/v3/projects/">Projects</a>
*/
public class GHProject extends GHObject {

View File

@@ -10,6 +10,8 @@ import static org.kohsuke.github.Previews.INERTIA;
/**
* The type GHProjectCard.
*
* @author Gunnar Skjold
*/
public class GHProjectCard extends GHObject {
private GitHub root;

View File

@@ -8,6 +8,8 @@ import static org.kohsuke.github.Previews.INERTIA;
/**
* The type GHProjectColumn.
*
* @author Gunnar Skjold
*/
public class GHProjectColumn extends GHObject {
protected GitHub root;

View File

@@ -41,6 +41,7 @@ import static org.kohsuke.github.Previews.SHADOW_CAT;
/**
* A pull request.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#getPullRequest(int) GHRepository#getPullRequest(int)
*/
@SuppressWarnings({ "UnusedDeclaration" })
@@ -452,6 +453,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* the io exception
* @deprecated Use {@link #createReview()}
*/
@Deprecated
public GHPullRequestReview createReview(String body,
@CheckForNull GHPullRequestReviewState event,
GHPullRequestReviewComment... comments) throws IOException {
@@ -472,6 +474,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* the io exception
* @deprecated Use {@link #createReview()}
*/
@Deprecated
public GHPullRequestReview createReview(String body,
@CheckForNull GHPullRequestReviewState event,
List<GHPullRequestReviewComment> comments) throws IOException {

View File

@@ -31,6 +31,7 @@ import java.net.URL;
/**
* Commit detail inside a {@link GHPullRequest}.
*
* @author Luca Milanesio
* @see GHPullRequest#listCommits() GHPullRequest#listCommits()
*/
@SuppressFBWarnings(

View File

@@ -28,6 +28,7 @@ import java.net.URL;
/**
* File detail inside a {@link GHPullRequest}.
*
* @author Julien Henry
* @see GHPullRequest#listFiles() GHPullRequest#listFiles()
*/
public class GHPullRequestFileDetail {

View File

@@ -5,6 +5,7 @@ import static org.kohsuke.github.Previews.SHADOW_CAT;
/**
* Lists up pull requests with some filtering and sorting.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#queryPullRequests() GHRepository#queryPullRequests()
*/
public class GHPullRequestQueryBuilder extends GHQueryBuilder<GHPullRequest> {

View File

@@ -145,6 +145,7 @@ public class GHPullRequestReview extends GHObject {
* @deprecated Former preview method that changed when it got public. Left here for backward compatibility. Use
* {@link #submit(String, GHPullRequestReviewEvent)}
*/
@Deprecated
public void submit(String body, GHPullRequestReviewState state) throws IOException {
submit(body, state.toEvent());
}

View File

@@ -7,6 +7,7 @@ import java.util.List;
/**
* Builds up a creation of new {@link GHPullRequestReview}.
*
* @author Kohsuke Kawaguchi
* @see GHPullRequest#createReview() GHPullRequest#createReview()
*/
public class GHPullRequestReviewBuilder {

View File

@@ -33,6 +33,7 @@ import static org.kohsuke.github.Previews.*;
/**
* Review comment to the pull request
*
* @author Julien Henry
* @see GHPullRequest#listReviewComments() GHPullRequest#listReviewComments()
* @see GHPullRequest#createReviewComment(String, String, String, int) GHPullRequest#createReviewComment(String, String,
* String, int)
@@ -59,6 +60,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
* @return the gh pull request review comment
* @deprecated You should be using {@link GHPullRequestReviewBuilder#comment(String, String, int)}
*/
@Deprecated
public static GHPullRequestReviewComment draft(String body, String path, int position) {
GHPullRequestReviewComment result = new GHPullRequestReviewComment();
result.body = body;

View File

@@ -5,6 +5,7 @@ package org.kohsuke.github;
*
* @param <T>
* the type parameter
* @author Kohsuke Kawaguchi
*/
public abstract class GHQueryBuilder<T> {
protected final GitHub root;

View File

@@ -1,5 +1,6 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -19,6 +20,8 @@ import static java.util.logging.Level.FINEST;
/**
* Rate limit.
*
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHRateLimit {
@@ -289,14 +292,11 @@ public class GHRateLimit {
/**
* The time at which the rate limit will reset. This value is calculated based on
* {@link #getResetEpochSeconds()} by calling {@link #recalculateResetDate}. 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.
* <p>
* Recalculated by calling {@link #recalculateResetDate}.
* </p>
* {@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.
*/
@Nonnull
private Date resetDate;
private final Date resetDate;
/**
* Instantiates a new Record.
@@ -308,7 +308,6 @@ public class GHRateLimit {
* @param resetEpochSeconds
* the reset epoch seconds
*/
@JsonCreator
public Record(@JsonProperty(value = "limit", required = true) int limit,
@JsonProperty(value = "remaining", required = true) int remaining,
@JsonProperty(value = "reset", required = true) long resetEpochSeconds) {
@@ -316,7 +315,7 @@ public class GHRateLimit {
}
/**
* Instantiates a new Record.
* Instantiates a new Record. Called by Jackson data binding or during header parsing.
*
* @param limit
* the limit
@@ -324,15 +323,22 @@ public class GHRateLimit {
* the remaining
* @param resetEpochSeconds
* the reset epoch seconds
* @param updatedAt
* the updated at
* @param responseInfo
* the response info
*/
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "Deprecated")
public Record(int limit, int remaining, long resetEpochSeconds, @CheckForNull String updatedAt) {
@JsonCreator
Record(@JsonProperty(value = "limit", required = true) int limit,
@JsonProperty(value = "remaining", required = true) int remaining,
@JsonProperty(value = "reset", required = true) long resetEpochSeconds,
@JacksonInject @CheckForNull GitHubResponse.ResponseInfo responseInfo) {
this.limit = limit;
this.remaining = remaining;
this.resetEpochSeconds = resetEpochSeconds;
this.resetDate = recalculateResetDate(updatedAt);
String updatedAt = null;
if (responseInfo != null) {
updatedAt = responseInfo.headerField("Date");
}
this.resetDate = calculateResetDate(updatedAt);
}
/**
@@ -362,7 +368,8 @@ public class GHRateLimit {
* a string date in RFC 1123
* @return reset date based on the passed date
*/
Date recalculateResetDate(@CheckForNull String updatedAt) {
@Nonnull
private Date calculateResetDate(@CheckForNull String updatedAt) {
long updatedAtEpochSeconds = createdAtEpochSeconds;
if (!StringUtils.isBlank(updatedAt)) {
try {
@@ -379,7 +386,7 @@ public class GHRateLimit {
// This may seem odd but it results in an accurate or slightly pessimistic reset date
// based on system time rather than assuming the system time synchronized with the server
long calculatedSecondsUntilReset = resetEpochSeconds - updatedAtEpochSeconds;
return resetDate = new Date((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000);
return new Date((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000);
}
/**

View File

@@ -8,6 +8,7 @@ import static org.kohsuke.github.Previews.*;
/**
* Reaction to issue, comment, PR, and so on.
*
* @author Kohsuke Kawaguchi
* @see Reactable
*/
@Preview

View File

@@ -7,6 +7,8 @@ import java.net.URL;
/**
* Provides information on a Git ref from GitHub.
*
* @author Michael Clarke
*/
public class GHRef {
/* package almost final */ GitHub root;
@@ -88,13 +90,6 @@ public class GHRef {
return this;
}
static GHRef[] wrap(GHRef[] in, GitHub root) {
for (GHRef r : in) {
r.wrap(root);
}
return in;
}
/**
* The type GHObject.
*/

View File

@@ -6,7 +6,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -72,6 +71,7 @@ public class GHRelease extends GHObject {
* the io exception
* @deprecated Use {@link #update()}
*/
@Deprecated
public GHRelease setDraft(boolean draft) throws IOException {
return update().draft(draft).update();
}
@@ -258,8 +258,9 @@ public class GHRelease extends GHObject {
public List<GHAsset> getAssets() throws IOException {
Requester builder = owner.root.createRequest();
GHAsset[] assets = builder.withUrlPath(getApiTailUrl("assets")).fetchArray(GHAsset[].class);
return Arrays.asList(GHAsset.wrap(assets, this));
return builder.withUrlPath(getApiTailUrl("assets"))
.toIterable(GHAsset[].class, item -> item.wrap(this))
.toList();
}
/**

View File

@@ -5,6 +5,7 @@ import java.io.IOException;
/**
* Modifies {@link GHRelease}.
*
* @author Kohsuke Kawaguchi
* @see GHRelease#update() GHRelease#update()
*/
public class GHReleaseUpdater {

View File

@@ -39,7 +39,6 @@ import java.io.Reader;
import java.net.URL;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -57,6 +56,8 @@ import static org.kohsuke.github.Previews.*;
/**
* A repository on GitHub.
*
* @author Kohsuke Kawaguchi
*/
@SuppressWarnings({ "UnusedDeclaration" })
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
@@ -81,6 +82,8 @@ public class GHRepository extends GHObject {
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;
@@ -116,6 +119,7 @@ public class GHRepository extends GHObject {
* the io exception
* @deprecated Use {@code getDeployment(id).listStatuses()}
*/
@Deprecated
public PagedIterable<GHDeploymentStatus> getDeploymentStatuses(final int id) throws IOException {
return getDeployment(id).listStatuses();
}
@@ -171,6 +175,7 @@ public class GHRepository extends GHObject {
* the io exception
* @deprecated Use {@code getDeployment(deploymentId).createStatus(ghDeploymentState)}
*/
@Deprecated
public GHDeploymentStatusBuilder createDeployStatus(int deploymentId, GHDeploymentState ghDeploymentState)
throws IOException {
return getDeployment(deploymentId).createStatus(ghDeploymentState);
@@ -216,16 +221,6 @@ public class GHRepository extends GHObject {
return clone_url;
}
/**
* Git http transport url string.
*
* @return the string
* @deprecated Typo of {@link #getHttpTransportUrl()}
*/
public String gitHttpTransportUrl() {
return clone_url;
}
/**
* Gets the Subversion URL to access this repository: https://github.com/rails/rails
*
@@ -358,7 +353,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public List<GHIssue> getIssues(GHIssueState state) throws IOException {
return listIssues(state).asList();
return listIssues(state).toList();
}
/**
@@ -376,8 +371,9 @@ public class GHRepository extends GHObject {
Requester requester = root.createRequest()
.with("state", state)
.with("milestone", milestone == null ? "none" : "" + milestone.getNumber());
return Arrays
.asList(GHIssue.wrap(requester.withUrlPath(getApiTailUrl("issues")).fetchArray(GHIssue[].class), this));
return requester.withUrlPath(getApiTailUrl("issues"))
.toIterable(GHIssue[].class, item -> item.wrap(this))
.toList();
}
/**
@@ -436,7 +432,7 @@ public class GHRepository extends GHObject {
* @deprecated use {@link #listReleases()}
*/
public List<GHRelease> getReleases() throws IOException {
return listReleases().asList();
return listReleases().toList();
}
/**
@@ -605,13 +601,34 @@ public class GHRepository extends GHObject {
return allow_rebase_merge;
}
/**
* Automatically deleting head branches when pull requests are merged
*
* @return the boolean
*/
public boolean isDeleteBranchOnMerge() {
return delete_branch_on_merge;
}
/**
* Returns the number of all forks of this repository. This not only counts direct forks, but also forks of forks,
* and so on.
*
* @return the forks
* @deprecated use {@link #getForksCount()} instead
*/
@Deprecated
public int getForks() {
return getForksCount();
}
/**
* Returns the number of all forks of this repository. This not only counts direct forks, but also forks of forks,
* and so on.
*
* @return the forks
*/
public int getForks() {
public int getForksCount() {
return forks_count;
}
@@ -655,8 +672,19 @@ public class GHRepository extends GHObject {
* Gets watchers.
*
* @return the watchers
* @deprecated use {@link #getWatchersCount()} instead
*/
@Deprecated
public int getWatchers() {
return getWatchersCount();
}
/**
* Gets the count of watchers.
*
* @return the watchers
*/
public int getWatchersCount() {
return watchers_count;
}
@@ -669,16 +697,6 @@ public class GHRepository extends GHObject {
return open_issues_count;
}
/**
* Gets network count.
*
* @return the network count
* @deprecated This no longer exists in the official API documentation. Use {@link #getForks()}
*/
public int getNetworkCount() {
return forks_count;
}
/**
* Gets subscribers count.
*
@@ -712,6 +730,7 @@ public class GHRepository extends GHObject {
* @return the master branch
* @deprecated Renamed to {@link #getDefaultBranch()}
*/
@Deprecated
public String getMasterBranch() {
return default_branch;
}
@@ -734,7 +753,7 @@ public class GHRepository extends GHObject {
*/
@WithBridgeMethods(Set.class)
public GHPersonSet<GHUser> getCollaborators() throws IOException {
return new GHPersonSet<GHUser>(listCollaborators().asList());
return new GHPersonSet<GHUser>(listCollaborators().toList());
}
/**
@@ -784,11 +803,14 @@ public class GHRepository extends GHObject {
* the io exception
*/
public Set<String> getCollaboratorNames() throws IOException {
Set<String> r = new HashSet<String>();
for (GHUser u : GHUser.wrap(
root.createRequest().withUrlPath(getApiTailUrl("collaborators")).fetchArray(GHUser[].class),
root))
Set<String> r = new HashSet<>();
// no initializer - we just want to the logins
PagedIterable<GHUser> users = root.createRequest()
.withUrlPath(getApiTailUrl("collaborators"))
.toIterable(GHUser[].class, null);
for (GHUser u : users.toArray()) {
r.add(u.login);
}
return r;
}
@@ -830,9 +852,11 @@ public class GHRepository extends GHObject {
* the io exception
*/
public Set<GHTeam> getTeams() throws IOException {
return Collections.unmodifiableSet(new HashSet<GHTeam>(Arrays.asList(
GHTeam.wrapUp(root.createRequest().withUrlPath(getApiTailUrl("teams")).fetchArray(GHTeam[].class),
root.getOrganization(getOwnerName())))));
GHOrganization org = root.getOrganization(getOwnerName());
return root.createRequest()
.withUrlPath(getApiTailUrl("teams"))
.toIterable(GHTeam[].class, item -> item.wrapUp(org))
.toSet();
}
/**
@@ -1084,6 +1108,18 @@ public class GHRepository extends GHObject {
edit("allow_rebase_merge", Boolean.toString(value));
}
/**
* After pull requests are merged, you can have head branches deleted automatically.
*
* @param value
* the value
* @throws IOException
* the io exception
*/
public void deleteBranchOnMerge(boolean value) throws IOException {
edit("delete_branch_on_merge", Boolean.toString(value));
}
/**
* Deletes this repository.
*
@@ -1238,7 +1274,7 @@ public class GHRepository extends GHObject {
* @see #listPullRequests(GHIssueState) #listPullRequests(GHIssueState)
*/
public List<GHPullRequest> getPullRequests(GHIssueState state) throws IOException {
return queryPullRequests().state(state).list().asList();
return queryPullRequests().state(state).list().toList();
}
/**
@@ -1249,6 +1285,7 @@ public class GHRepository extends GHObject {
* @return the paged iterable
* @deprecated Use {@link #queryPullRequests()}
*/
@Deprecated
public PagedIterable<GHPullRequest> listPullRequests(GHIssueState state) {
return queryPullRequests().state(state).list();
}
@@ -1449,9 +1486,7 @@ public class GHRepository extends GHObject {
* on failure communicating with GitHub
*/
public GHRef[] getRefs() throws IOException {
return GHRef.wrap(root.createRequest()
.withUrlPath(String.format("/repos/%s/%s/git/refs", getOwnerName(), name))
.fetchArray(GHRef[].class), root);
return listRefs().toArray();
}
/**
@@ -1476,9 +1511,7 @@ public class GHRepository extends GHObject {
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
*/
public GHRef[] getRefs(String refType) throws IOException {
return GHRef.wrap(root.createRequest()
.withUrlPath(String.format("/repos/%s/%s/git/refs/%s", getOwnerName(), name, refType))
.fetchArray(GHRef[].class), root);
return listRefs(refType).toArray();
}
/**
@@ -1736,7 +1769,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public GHCommitStatus getLastCommitStatus(String sha1) throws IOException {
List<GHCommitStatus> v = listCommitStatuses(sha1).asList();
List<GHCommitStatus> v = listCommitStatuses(sha1).toList();
return v.isEmpty() ? null : v.get(0);
}
@@ -1975,14 +2008,6 @@ public class GHRepository extends GHObject {
return createWebHook(url, null);
}
// this is no different from getPullRequests(OPEN)
// /**
// * Retrieves all the pull requests.
// */
// public List<GHPullRequest> getPullRequests() throws IOException {
// return root.retrieveWithAuth("/pulls/"+owner+'/'+name,JsonPullRequests.class).wrap(root);
// }
/**
* Returns a set that represents the post-commit hook URLs. The returned set is live, and changes made to them are
* reflected to GitHub.
@@ -1992,6 +2017,7 @@ public class GHRepository extends GHObject {
*/
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS",
justification = "It causes a performance degradation, but we have already exposed it to the API")
@Deprecated
public Set<URL> getPostCommitHooks() {
return postCommitHooks;
}
@@ -2005,7 +2031,7 @@ public class GHRepository extends GHObject {
private final Set<URL> postCommitHooks = new AbstractSet<URL>() {
private List<URL> getPostCommitHooks() {
try {
List<URL> r = new ArrayList<URL>();
List<URL> r = new ArrayList<>();
for (GHHook h : getHooks()) {
if (h.getName().equals("web")) {
r.add(new URL(h.getConfig().get("url")));
@@ -2071,8 +2097,10 @@ public class GHRepository extends GHObject {
*/
public Map<String, GHBranch> getBranches() throws IOException {
Map<String, GHBranch> r = new TreeMap<String, GHBranch>();
for (GHBranch p : root.createRequest().withUrlPath(getApiTailUrl("branches")).fetchArray(GHBranch[].class)) {
p.wrap(this);
for (GHBranch p : root.createRequest()
.withUrlPath(getApiTailUrl("branches"))
.toIterable(GHBranch[].class, item -> item.wrap(this))
.toArray()) {
r.put(p.getName(), p);
}
return r;
@@ -2203,11 +2231,10 @@ public class GHRepository extends GHObject {
}
String target = getApiTailUrl("contents/" + path);
GHContent[] files = requester.with("ref", ref).withUrlPath(target).fetchArray(GHContent[].class);
GHContent.wrap(files, this);
return Arrays.asList(files);
return requester.with("ref", ref)
.withUrlPath(target)
.toIterable(GHContent[].class, item -> item.wrap(this))
.toList();
}
/**
@@ -2361,11 +2388,10 @@ public class GHRepository extends GHObject {
* the io exception
*/
public List<GHDeployKey> getDeployKeys() throws IOException {
List<GHDeployKey> list = new ArrayList<GHDeployKey>(
Arrays.asList(root.createRequest().withUrlPath(getApiTailUrl("keys")).fetchArray(GHDeployKey[].class)));
for (GHDeployKey h : list)
h.wrap(this);
return list;
return root.createRequest()
.withUrlPath(getApiTailUrl("keys"))
.toIterable(GHDeployKey[].class, item -> item.wrap(this))
.toList();
}
/**

View File

@@ -3,6 +3,7 @@ package org.kohsuke.github;
/**
* Search repositories.
*
* @author Kohsuke Kawaguchi
* @see GitHub#searchRepositories() GitHub#searchRepositories()
*/
public class GHRepositorySearchBuilder extends GHSearchBuilder<GHRepository> {

View File

@@ -5,6 +5,7 @@ import java.util.Locale;
/**
* App installation repository selection.
*
* @author Paulo Miguel Almeida
* @see GHAppInstallation
*/
public enum GHRepositorySelection {

View File

@@ -12,6 +12,8 @@ import java.util.NoSuchElementException;
/**
* Statistics for a GitHub repository.
*
* @author Martin van Zijl
*/
public class GHRepositoryStatistics {

View File

@@ -6,13 +6,12 @@ import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
/**
* Base class for various search builders.
*
* @param <T>
* the type parameter
* @author Kohsuke Kawaguchi
*/
public abstract class GHSearchBuilder<T> extends GHQueryBuilder<T> {
protected final List<String> terms = new ArrayList<String>();
@@ -25,6 +24,7 @@ public abstract class GHSearchBuilder<T> extends GHQueryBuilder<T> {
GHSearchBuilder(GitHub root, Class<? extends SearchResult<T>> receiverType) {
super(root);
this.receiverType = receiverType;
req.withUrlPath(getApiUrl());
}
/**
@@ -47,20 +47,7 @@ public abstract class GHSearchBuilder<T> extends GHQueryBuilder<T> {
req.set("q", StringUtils.join(terms, " "));
try {
final GitHubRequest baseRequest = req.build();
return new PagedSearchIterable<T>(root) {
@Nonnull
public PagedIterator<T> _iterator(int pageSize) {
return new PagedIterator<T>(adapt(GitHubPageIterator.create(root.getClient(),
receiverType,
baseRequest.toBuilder().withUrlPath(getApiUrl()).withPageSize(pageSize)))) {
protected void wrapUp(T[] page) {
// PagedSearchIterable
// SearchResult.getItems() should do it
}
};
}
};
return new PagedSearchIterable<>(root, req.build(), receiverType);
} catch (MalformedURLException e) {
throw new GHException("", e);
}

View File

@@ -6,6 +6,8 @@ import java.util.Date;
/**
* A stargazer at a repository on GitHub.
*
* @author noctarius
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, justification = "JSON API")
public class GHStargazer {

View File

@@ -6,6 +6,7 @@ import java.util.Date;
/**
* Represents your subscribing to a repository / conversation thread..
*
* @author Kohsuke Kawaguchi
* @see GHRepository#getSubscription() GHRepository#getSubscription()
* @see GHThread#getSubscription() GHThread#getSubscription()
*/

View File

@@ -7,6 +7,7 @@ import java.util.Locale;
/**
* App installation target type.
*
* @author Paulo Miguel Almeida
* @see GHAppInstallation
*/
public enum GHTargetType {

View File

@@ -1,13 +1,14 @@
package org.kohsuke.github;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
/**
* A team in GitHub organization.
*
* @author Kohsuke Kawaguchi
*/
public class GHTeam implements Refreshable {
private String name;
@@ -52,13 +53,6 @@ public class GHTeam implements Refreshable {
return wrapUp(organization);
}
static GHTeam[] wrapUp(GHTeam[] teams, GHOrganization owner) {
for (GHTeam t : teams) {
t.wrapUp(owner);
}
return teams;
}
static GHTeam[] wrapUp(GHTeam[] teams, GHPullRequest owner) {
for (GHTeam t : teams) {
t.root = owner.root;
@@ -163,7 +157,7 @@ public class GHTeam implements Refreshable {
* the io exception
*/
public Set<GHUser> getMembers() throws IOException {
return Collections.unmodifiableSet(listMembers().asSet());
return listMembers().toSet();
}
/**

View File

@@ -10,6 +10,7 @@ import java.util.Date;
/**
* A conversation in the notification API.
*
* @author Kohsuke Kawaguchi
* @see <a href="https://developer.github.com/v3/activity/notifications/">documentation</a>
* @see GHNotificationStream
*/

View File

@@ -8,6 +8,7 @@ import java.util.List;
/**
* Provides information for Git Trees https://developer.github.com/v3/git/trees/
*
* @author Daniel Teixeira - https://github.com/ddtxra
* @see GHCommit#getTree() GHCommit#getTree()
* @see GHRepository#getTree(String) GHRepository#getTree(String)
* @see GHTreeEntry#asTree() GHTreeEntry#asTree()

View File

@@ -7,6 +7,7 @@ import java.net.URL;
/**
* Provides information for Git Trees https://developer.github.com/v3/git/trees/
*
* @author Daniel Teixeira - https://github.com/ddtxra
* @see GHTree
*/
public class GHTreeEntry {

View File

@@ -30,6 +30,8 @@ import java.util.*;
/**
* Represents an user of GitHub.
*
* @author Kohsuke Kawaguchi
*/
public class GHUser extends GHPerson {
@@ -41,8 +43,7 @@ public class GHUser extends GHPerson {
* the io exception
*/
public List<GHKey> getKeys() throws IOException {
return Collections.unmodifiableList(
Arrays.asList(root.createRequest().withUrlPath(getApiTailUrl("keys")).fetchArray(GHKey[].class)));
return root.createRequest().withUrlPath(getApiTailUrl("keys")).toIterable(GHKey[].class, null).toList();
}
/**
@@ -74,7 +75,7 @@ public class GHUser extends GHPerson {
*/
@WithBridgeMethods(Set.class)
public GHPersonSet<GHUser> getFollows() throws IOException {
return new GHPersonSet<GHUser>(listFollows().asList());
return new GHPersonSet<GHUser>(listFollows().toList());
}
/**
@@ -95,7 +96,7 @@ public class GHUser extends GHPerson {
*/
@WithBridgeMethods(Set.class)
public GHPersonSet<GHUser> getFollowers() throws IOException {
return new GHPersonSet<GHUser>(listFollowers().asList());
return new GHPersonSet<GHUser>(listFollowers().toList());
}
/**
@@ -191,7 +192,8 @@ public class GHUser extends GHPerson {
Set<String> names = new HashSet<String>();
for (GHOrganization o : root.createRequest()
.withUrlPath("/users/" + login + "/orgs")
.fetchArray(GHOrganization[].class)) {
.toIterable(GHOrganization[].class, null)
.toArray()) {
if (names.add(o.getLogin())) // I've seen some duplicates in the data
orgs.add(root.getOrganization(o.getLogin()));
}
@@ -217,7 +219,7 @@ public class GHUser extends GHPerson {
public PagedIterable<GHGist> listGists() throws IOException {
return root.createRequest()
.withUrlPath(String.format("/users/%s/gists", login))
.toIterable(GHGist[].class, item -> item.wrapUp(this));
.toIterable(GHGist[].class, null);
}
@Override

View File

@@ -3,6 +3,7 @@ package org.kohsuke.github;
/**
* Search users.
*
* @author Kohsuke Kawaguchi
* @see GitHub#searchUsers() GitHub#searchUsers()
*/
public class GHUserSearchBuilder extends GHSearchBuilder<GHUser> {

Some files were not shown because too many files have changed in this diff Show More