Compare commits

...

303 Commits

Author SHA1 Message Date
Liam Newman
a7a792251a [maven-release-plugin] prepare release github-api-1.112 2020-05-28 07:48:45 -07:00
Liam Newman
aec2308144 Merge pull request #831 from hub4j/dependabot/maven/org.apache.maven.plugins-maven-project-info-reports-plugin-3.1.0
Bump maven-project-info-reports-plugin from 3.0.0 to 3.1.0
2020-05-28 07:34:56 -07:00
dependabot-preview[bot]
0741b8aa6a Bump maven-project-info-reports-plugin from 3.0.0 to 3.1.0
Bumps [maven-project-info-reports-plugin](https://github.com/apache/maven-project-info-reports-plugin) from 3.0.0 to 3.1.0.
- [Release notes](https://github.com/apache/maven-project-info-reports-plugin/releases)
- [Commits](https://github.com/apache/maven-project-info-reports-plugin/compare/maven-project-info-reports-plugin-3.0.0...maven-project-info-reports-plugin-3.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-28 06:40:32 +00:00
Liam Newman
3082622394 Merge pull request #822 from bitwiseman/issue/794
Fixed getRef() to use git/ref endpoint instead of git/refs
2020-05-21 11:02:43 -07:00
Liam Newman
965c9cb0af Fixed getRef() to use git/ref endpoint instead of git/refs
Fixes #794
2020-05-21 10:41:36 -07:00
Liam Newman
495a46e2d8 Merge pull request #823 from bitwiseman/task/cleanup-more
Code cleanup for GHObject and GHRepositoryStatistics
2020-05-21 07:51:51 -07:00
Liam Newman
05bda1192e Merge branch 'master' into task/cleanup-more 2020-05-20 21:00:31 -07:00
Liam Newman
6058af0ca1 Merge pull request #821 from bitwiseman/issue/805
Populate Source and Parent if needed
2020-05-20 20:59:21 -07:00
Liam Newman
1eb8bf9719 Reduce round trips and cleanup test data 2020-05-20 19:13:37 -07:00
Liam Newman
afc02faeda Clean up GHObject field access 2020-05-20 19:11:48 -07:00
Liam Newman
66f22de90f Populate Source and Parent if needed
NOTE: this also addresses a bug in push events where the repository url is incorrect
2020-05-20 13:22:09 -07:00
Liam Newman
2949a2e0ff Clean up GHRepositoryStatistics constructors 2020-05-19 17:25:58 -07:00
Liam Newman
ba12efea9d Merge pull request #820 from bitwiseman/issue/800
Prevent NPE when accessing description for GHLicense
2020-05-19 17:25:14 -07:00
Liam Newman
e1180a12fb Merge pull request #817 from bitwiseman/issue/802
Consider header rate limit information for getRateLimit()
2020-05-19 17:08:25 -07:00
Liam Newman
1393706f13 Prevent NPE when accessing description for license
When license can be identified, the description will be null.  So will the url.
Tht means that url cannot be converted to string.

Fixes #800 .
2020-05-19 17:06:59 -07:00
Liam Newman
6f994f31f7 Update src/main/java/org/kohsuke/github/GitHubClient.java 2020-05-19 14:25:16 -07:00
Liam Newman
38aa99a063 Consider header rate limit information for getRateLimit()
Fixes #802
2020-05-18 13:56:10 -07:00
Liam Newman
85c44b3529 Merge pull request #809 from pzygielo/imports
Remove unused imports
2020-05-16 13:50:23 -07:00
Liam Newman
e1a2768de5 Merge pull request #810 from pzygielo/equals
Use .equals to compare Strings
2020-05-16 13:49:54 -07:00
Liam Newman
e1c9b27203 Merge pull request #811 from pzygielo/close
Be nice and close Closeable
2020-05-16 13:49:14 -07:00
Piotrek Żygieło
969f6ef826 Use .equals to compare Strings 2020-05-16 11:55:21 +02:00
Piotrek Żygieło
7abc4d4e76 Be nice and close Closeable 2020-05-16 11:49:02 +02:00
Piotrek Żygieło
ac97147c1f Remove unused imports 2020-05-16 09:58:20 +02:00
Liam Newman
dbd20fe396 Merge pull request #804 from springernature/master
fix to #803
2020-05-13 09:12:20 -07:00
Liam Newman
44e57c9c4b Merge pull request #808 from hub4j/dependabot/maven/spotbugs.version-4.0.3
Bump spotbugs.version from 4.0.2 to 4.0.3
2020-05-13 09:07:37 -07:00
Stefan Reisner
488e5e531f updated GHContentIntegrationTest.java
dummy commit
2020-05-13 12:39:10 +02:00
dependabot-preview[bot]
42a6a8d770 Bump spotbugs.version from 4.0.2 to 4.0.3
Bumps `spotbugs.version` from 4.0.2 to 4.0.3.

Updates `spotbugs` from 4.0.2 to 4.0.3
- [Release notes](https://github.com/spotbugs/spotbugs/releases)
- [Changelog](https://github.com/spotbugs/spotbugs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/spotbugs/spotbugs/compare/4.0.2...4.0.3)

Updates `spotbugs-annotations` from 4.0.2 to 4.0.3
- [Release notes](https://github.com/spotbugs/spotbugs/releases)
- [Changelog](https://github.com/spotbugs/spotbugs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/spotbugs/spotbugs/compare/4.0.2...4.0.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-13 06:52:27 +00:00
Liam Newman
f8e877ea05 Merge pull request #806 from bitwiseman/task/rename
Rename organization to hub4j
2020-05-12 08:52:06 -07:00
Stefan Reisner
65d6fc7272 updated GHContentIntegrationTest.java
dummy commit
2020-05-12 12:06:44 +02:00
Dr. Stefan Reisner
63ce8e461b Update src/test/java/org/kohsuke/github/GHContentIntegrationTest.java
Co-authored-by: Liam Newman <bitwiseman@gmail.com>
2020-05-12 09:59:53 +02:00
Stefan Reisner
fbf4c48461 updated GHContentIntegrationTest.java, src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/**
adapting to new org hub4-test-org (was github-api-test-org)
2020-05-11 16:33:29 +02:00
Stefan Reisner
81a55db644 updated src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileWithNoneAsciiPath/** 2020-05-11 15:29:02 +02:00
Stefan Reisner
4d4edfa181 updated GHContentIntegrationTest.java
adapting testGetFileContentWithNonAsciiPath to shortened file path
2020-05-11 08:01:32 +02:00
Liam Newman
6f9182f1f6 Rename organization to hub4j
Fixes #801
2020-05-08 15:17:14 -07:00
Stefan Reisner
fa600c03e2 updated GHContentIntegrationTest.java
sorting imports
2020-05-06 17:33:11 +02:00
Dr. Stefan Reisner
4a53301e9f Merge branch 'master' into master 2020-05-06 17:26:06 +02:00
Stefan Reisner
676984b3d5 added src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContentWithNonAsciiPath/** 2020-05-06 16:58:42 +02:00
Stefan Reisner
e6d7f7248b updated GitHubRequest.java
using URI.toASCIIString() instead of URI.toString() in urlPathEncode()
2020-05-06 16:54:21 +02:00
Stefan Reisner
50903b5c4a updated GHContentIntegrationTest.java 2020-05-06 16:53:23 +02:00
Liam Newman
01e399fb91 Add Java 15 early access to CI
Switch canary compile to Java 13.
2020-05-01 10:55:42 -07:00
Liam Newman
911aeb7af0 Merge pull request #796 from github-api/dependabot/maven/net.revelc.code-impsort-maven-plugin-1.4.1
Bump impsort-maven-plugin from 1.3.2 to 1.4.1
2020-04-27 14:21:34 -07:00
Liam Newman
7e5cd9abbc Merge branch 'master' into dependabot/maven/net.revelc.code-impsort-maven-plugin-1.4.1 2020-04-27 14:12:08 -07:00
Liam Newman
115527a21a Merge pull request #792 from bitwiseman/issue/682
Fix Gist getId() and deleteFile(), add getGistId()
2020-04-27 13:37:34 -07:00
Liam Newman
eff4f4f601 Merge branch 'master' into issue/682 2020-04-27 13:20:35 -07:00
Liam Newman
16e0099a0d Add deleteFile() to GHGist
Related to #466 and #484
2020-04-27 10:44:25 -07:00
Liam Newman
2c8c678275 Merge pull request #770 from sladyn98/change_url_methods
Change withURLPath to setRawURLPath
2020-04-27 09:54:14 -07:00
Liam Newman
3b51e87fbf Merge branch 'master' into change_url_methods 2020-04-27 09:48:23 -07:00
Liam Newman
6c6eef5e2b Merge pull request #795 from bitwiseman/task/check-raw-url
Check that raw url starts with 'http'
2020-04-27 09:47:24 -07:00
Liam Newman
6e5910f44c Check that raw url starts with 'http' 2020-04-27 09:41:43 -07:00
dependabot-preview[bot]
a967189bc6 Bump impsort-maven-plugin from 1.3.2 to 1.4.1
Bumps [impsort-maven-plugin](https://github.com/revelc/impsort-maven-plugin) from 1.3.2 to 1.4.1.
- [Release notes](https://github.com/revelc/impsort-maven-plugin/releases)
- [Commits](https://github.com/revelc/impsort-maven-plugin/compare/impsort-maven-plugin-1.3.2...impsort-maven-plugin-1.4.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-27 06:59:29 +00:00
Sladyn
7069176cf6 Apply suggestions from code review
Co-Authored-By: Liam Newman <bitwiseman@gmail.com>
2020-04-27 10:49:57 +05:30
Liam Newman
44dcbe773d Fix Gist getId() and add getGistId()
Fixes #682
2020-04-25 20:16:58 -07:00
Liam Newman
ca76975461 Record Disable test 2020-04-23 11:13:51 -07:00
Liam Newman
83122ac99e Take new snapshot of testGetProtection() 2020-04-23 11:13:51 -07:00
Sladyn Nunes
c3e9458555 Additional modifications to test 2020-04-23 11:13:51 -07:00
Sladyn Nunes
057ba38873 Added getProtectionTest 2020-04-23 11:13:50 -07:00
Sladyn Nunes
81d7d6236b Add resource files 2020-04-23 11:13:50 -07:00
Sladyn Nunes
191dd49653 added test and modified url 2020-04-23 11:13:50 -07:00
Sladyn Nunes
21e9dd6f51 Change withURLPath to setRawURLPath 2020-04-23 11:13:50 -07:00
Liam Newman
cc2d14acc6 Merge pull request #791 from ingwarsw/global_node_id
Add global node_id to GHObject + GHTeam extends GHObject
2020-04-22 13:15:13 -07:00
Liam Newman
87f37e9f1c Formatting and improved bridge method tests 2020-04-22 09:40:19 -07:00
Karol Lassak
d536a9f874 Merge branch 'master' into global_node_id 2020-04-19 11:41:17 +02:00
Karol Lassak
b45f353fa9 Fix tests + add deprecation to one of methods 2020-04-19 11:38:36 +02:00
Karol Lassak
a3073ec14e Fix formatting 2020-04-19 11:19:48 +02:00
Karol Lassak
f77eb33029 Add deprecated method 2020-04-19 11:18:29 +02:00
Liam Newman
c1c919097a Merge pull request #790 from chids/reintroduce-proxy-test-confirmation
Reintroduce the confirmation message for the Github proxy setup
2020-04-18 15:07:41 -07:00
Karol Lassak
e05348463c Fix javadoc 2020-04-18 14:32:51 +02:00
Karol Lassak
fdcf74eaf2 Add global node_id to GHObject + GHTeam extends GHObject 2020-04-18 14:23:06 +02:00
Mårten Gustafson
6d57a3e3b9 Reintroduce the confirmation message for the Github proxy setup
which is referenced from the contribution guidlines.
2020-04-17 15:17:19 +02:00
Liam Newman
1f449c866e Merge pull request #781 from bitwiseman/task/app-set-dep
Deprecate set methods that should not be public
2020-04-16 11:49:09 -07:00
Liam Newman
e12deccd24 Merge pull request #782 from chids/support-issue-event-attributes
Support issue event attributes
2020-04-16 11:36:42 -07:00
Mårten Gustafson
3184ebb5ee Link to Github docs for issue events. 2020-04-16 09:28:38 +02:00
Liam Newman
4a35ed2b35 Merge branch 'master' into support-issue-event-attributes 2020-04-16 00:02:42 -07:00
Liam Newman
5c9474d1c8 [maven-release-plugin] prepare for next development iteration 2020-04-15 23:48:24 -07:00
Liam Newman
2321dc50c5 [maven-release-plugin] prepare release github-api-1.111 2020-04-15 23:48:15 -07:00
Liam Newman
4efd2e8184 Merge pull request #786 from github-api/dependabot/maven/spotbugs.version-4.0.2
Bump spotbugs.version from 4.0.1 to 4.0.2
2020-04-15 23:43:50 -07:00
dependabot-preview[bot]
e30e153bfa Bump spotbugs.version from 4.0.1 to 4.0.2
Bumps `spotbugs.version` from 4.0.1 to 4.0.2.

Updates `spotbugs` from 4.0.1 to 4.0.2
- [Release notes](https://github.com/spotbugs/spotbugs/releases)
- [Changelog](https://github.com/spotbugs/spotbugs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/spotbugs/spotbugs/compare/4.0.1...4.0.2)

Updates `spotbugs-annotations` from 4.0.1 to 4.0.2
- [Release notes](https://github.com/spotbugs/spotbugs/releases)
- [Changelog](https://github.com/spotbugs/spotbugs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/spotbugs/spotbugs/compare/4.0.1...4.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-16 06:38:59 +00:00
Mårten Gustafson
2724211535 Merge branch 'master' into support-issue-event-attributes 2020-04-16 08:30:51 +02:00
Mårten Gustafson
81068de0f1 Revert "WireMockStatusReporterTest doesn't print to stdout as of"
This reverts commit d76718e8b2.
2020-04-16 08:26:03 +02:00
Liam Newman
7d842175f7 Merge pull request #783 from bitwiseman/issue/760
Expose MappingReader and MappingWriter
2020-04-15 16:58:01 -07:00
Liam Newman
e0aee9f361 Expose MappingReader and MappingWriter
Jenkins Blue Ocean made interesting design choices relating github-api interactions.

They mostly reused the existing API and OM, but in a few places they chose to
implement their own object mapping independent of this project. This is fine
as long as nothing in this project ever changes, including internals such
as ObjectMapper configuration or behavior.

Recent release have made changes to those internals which break assumptions made
in Blue Ocean.

This change exposes this project's MappingReader and MappingWriter to allow
for a fix to Blue Ocean requiring only minimal changes.

This doesn't prevent future changes from breaking Blue Ocean but at least makes
them much less likely.

Fixes #780
2020-04-15 16:39:59 -07:00
Mårten Gustafson
df576e2738 Expose and test per issue event attributes for milestone, label and
assignment events.
2020-04-14 11:47:44 +02:00
Mårten Gustafson
bb1356b25d Add Wiremock recordings for issue events. 2020-04-14 11:24:44 +02:00
Liam Newman
1b67960da4 Deprecate set methods that should not be public 2020-04-13 13:41:28 -07:00
Mårten Gustafson
d76718e8b2 WireMockStatusReporterTest doesn't print to stdout as of
061e8bb662.
2020-04-13 10:30:08 +02:00
Liam Newman
76c51922f1 [maven-release-plugin] prepare for next development iteration 2020-04-06 09:43:50 -07:00
Liam Newman
f95e89a136 [maven-release-plugin] prepare release github-api-1.110 2020-04-06 09:43:41 -07:00
Liam Newman
2dff60a23c Merge pull request #777 from bitwiseman/issue/775
Reverse removal of misnamed gitHttpTransportUrl
2020-04-06 09:38:47 -07:00
Liam Newman
95f83d1a29 Merge pull request #774 from martinvanzijl/issue_518_allow_getref_with_prefix
Allow "refs/" prefix in parameter to GHRepository.getRef()
2020-04-06 09:33:39 -07:00
Liam Newman
b875ccecc1 Reverse removal of misnamed gitHttpTransportUrl 2020-04-06 09:31:50 -07:00
Martin van Zijl
e4c3802f16 Revert accidental changes to addCollaborators test files. 2020-04-07 04:11:11 +12:00
Liam Newman
081e485f4f Merge pull request #773 from martinvanzijl/issue_444_unset_milestone
Add ability to unset the milestone of an issue
2020-04-05 12:57:10 -07:00
Liam Newman
4adf88da19 Merge pull request #767 from XiongKezhi/installation-repository-event
Installation repository event
2020-04-05 12:45:56 -07:00
Liam Newman
31e2b1b8d3 Merge branch 'master' into issue_444_unset_milestone 2020-04-05 12:41:02 -07:00
Martin van Zijl
bd28abd343 Allow "refs/" prefix in parameter to GHRepository.getRef().
Fixes #518.
2020-04-06 04:43:26 +12:00
August
955690b124 Rename refreash to populate and add node_id for GHRepository 2020-04-05 19:09:02 +08:00
Martin van Zijl
fa6f06ae15 Add ability to unset the milestone of an issue.
Fixes #444.
2020-04-05 16:16:04 +12:00
August
263de140c5 Removed InstallationRepository 2020-04-04 22:49:52 +08:00
Kezhi Xiong
ed85d06d69 Merge branch 'master' into installation-repository-event 2020-04-04 22:33:18 +08:00
August
4ff0870df8 Refresh repositories while warp up installation event 2020-04-04 22:30:05 +08:00
Liam Newman
410bac2040 [maven-release-plugin] prepare for next development iteration 2020-04-01 14:31:22 -07:00
Liam Newman
38b1e367b1 [maven-release-plugin] prepare release github-api-1.109 2020-04-01 14:31:14 -07:00
Liam Newman
3cddffa37f Merge pull request #768 from bitwiseman/task/jacoco-report
Add Jacoco report to site
2020-04-01 14:27:23 -07:00
Liam Newman
ea7a1a7175 More GHRateLimit test stabilization 2020-04-01 14:22:17 -07:00
Liam Newman
36b5601588 Add Jacoco report to site 2020-04-01 14:03:44 -07:00
Liam Newman
7fc68f2969 Merge branch 'master' into installation-repository-event 2020-04-01 12:29:13 -07:00
Liam Newman
c5ee07add4 Merge pull request #741 from sladyn98/add_has_projects
Add has_projects field to github repository
2020-04-01 08:33:59 -07:00
August
32ff315b6b Resolve spotbugs and format code 2020-04-01 16:58:02 +08:00
August
f919346f8f Add installation and installtion repositories event 2020-04-01 16:08:21 +08:00
Liam Newman
279df00404 Add checks for hasProjects() 2020-03-31 14:54:16 -07:00
Liam Newman
bfd4b17fa0 Merge remote-tracking branch 'upstream/master' into add_has_projects 2020-03-31 13:33:36 -07:00
Liam Newman
5fe2817164 Merge pull request #764 from bitwiseman/issue/valid_creds
Change credential check to use rate limit
2020-03-31 12:37:16 -07:00
Liam Newman
b337bb39bc Update PULL_REQUEST_TEMPLATE.md 2020-03-31 10:05:16 -07:00
Liam Newman
65ae41c5f1 Fix tests for isCredentialsValid 2020-03-31 09:36:26 -07:00
Liam Newman
796c644c4a Change credential check to use rate limit
Fixes #582
2020-03-31 08:28:57 -07:00
Liam Newman
bfd9023a27 Merge pull request #762 from bitwiseman/task/insensitive
Http header field names must be case-insensitive
2020-03-31 07:28:44 -07:00
Liam Newman
c9cdf5d03e Make rate limit tests tolerant of one second timing differences
Fixes #760
2020-03-30 19:55:19 -07:00
Liam Newman
f60bb41ad9 Move tests around for clarity 2020-03-30 19:15:00 -07:00
Liam Newman
c333903b4a Http header field names must be case-insensitive
GitHub has started changing their headers from capitalized words to all lowercase.
A recent change made the header fields querying case-senstive which broke gzip content detection.
This was not caught by tests because recorded files remain unchanged.
It is also possible that WireMock is auto-capitalizing.

This fixes the case-sensitivity issue and also extends that funcionality to anyone consuming the
headers generated by ResponseInfo.

Fixes #751
2020-03-30 17:31:42 -07:00
Liam Newman
dd55e8a22c Merge pull request #753 from jglick/createCheckRun
GHRepository.createCheckRun
2020-03-30 13:46:31 -07:00
Jesse Glick
3ab9381d0a createCheckRunErrMissingConclusion 2020-03-30 15:06:01 -04:00
Jesse Glick
58f1fe0671 createPendingCheckRun 2020-03-30 14:58:58 -04:00
Jesse Glick
82b9c05d0f Strengthened test a bit 2020-03-30 14:49:37 -04:00
Jesse Glick
7c9397f7f6 Switched from fluent style with .done() to accessible constructors 2020-03-30 14:46:56 -04:00
Jesse Glick
6214b6a3ff Regenerated WireMock metadata 2020-03-30 14:26:23 -04:00
Jesse Glick
883c8cc4c8 Merge branch 'master' of github.com:github-api/github-api into createCheckRun 2020-03-30 14:20:05 -04:00
Liam Newman
8d47c72913 Merge pull request #758 from XiongKezhi/add-check-suite-warp-up
Add wrapUp() for GHEventPayload.CheckSuite
2020-03-30 09:01:19 -07:00
Jesse Glick
89a6664e45 More links to GH docs from Javadoc 2020-03-27 14:07:40 -04:00
Jesse Glick
30d792d6e1 Remove ‘Draft’ from nested data class names 2020-03-27 14:04:42 -04:00
Liam Newman
3745bf3157 Merge branch 'master' into add_has_projects 2020-03-27 07:53:07 -07:00
Kezhi Xiong
a7fda3e50d Merge branch 'master' into add-check-suite-warp-up 2020-03-27 17:05:14 +08:00
XiongKezhi
7f07204fef Add warpUp() for GHEventPayload.CheckSuite 2020-03-27 16:57:06 +08:00
Jesse Glick
8b51a44b7c Merge branch 'createCheckRun' of github.com:jglick/github-api into createCheckRun 2020-03-26 19:10:29 -04:00
Jesse Glick
c499c73dcc Merge branch 'master' of github.com:github-api/github-api into createCheckRun 2020-03-26 19:09:13 -04:00
Jesse Glick
c01f3f5e8a NPE when there are no annotations 2020-03-26 19:07:35 -04:00
Liam Newman
2aef35655f Merge pull request #756 from bitwiseman/task/shorter
Shorten generated  test resource paths
2020-03-26 15:52:08 -07:00
Liam Newman
7ddf1f5830 Shorten generated test resource paths 2020-03-26 14:58:54 -07:00
Liam Newman
b2c513ea42 Merge branch 'master' into createCheckRun 2020-03-26 14:10:29 -07:00
Liam Newman
4c30f94355 Add Java 8 Site to CI 2020-03-26 14:06:46 -07:00
Liam Newman
e911e86c4c Merge pull request #755 from jglick/javadoc
#724 broke the site goal from .github/PULL_REQUEST_TEMPLATE.md
2020-03-26 13:57:51 -07:00
Liam Newman
ca640b3f64 Merge pull request #738 from sourabhsparkala/sign_verification
Get commit or tag signature verified flag
2020-03-26 13:56:03 -07:00
Jesse Glick
b4c4a05f3b Moving enums inside GHCheckRun 2020-03-26 16:44:01 -04:00
Jesse Glick
fd3c36a259 IMHO treating Javadoc warnings as fatal makes sources less legible and does not improve API comprehension at all 2020-03-26 16:33:57 -04:00
Jesse Glick
d8274ac2d4 Merge branch 'javadoc' into createCheckRun 2020-03-26 16:26:52 -04:00
Jesse Glick
9c7479f953 #724 broke the site goal from .github/PULL_REQUEST_TEMPLATE.md 2020-03-26 16:25:32 -04:00
Jesse Glick
b5dc3c4366 Added some Javadoc. 2020-03-26 16:22:04 -04:00
Jesse Glick
26b8082155 Handle >50 annotations 2020-03-26 16:14:39 -04:00
Liam Newman
418df15f7b Merge branch 'master' into sign_verification 2020-03-26 10:23:16 -07:00
Liam Newman
31ed0125b8 Shorten test paths for windows 2020-03-26 10:09:01 -07:00
Liam Newman
494318b879 Change method name to isVerified 2020-03-26 09:49:03 -07:00
Liam Newman
f554ddc372 Capitalize and Move GHVerification.Reason enum 2020-03-26 09:45:20 -07:00
Jesse Glick
03de12c221 SpotBugs 2020-03-25 20:03:18 -04:00
Jesse Glick
6c41f22b57 Coverage of DraftImage 2020-03-25 19:59:42 -04:00
Jesse Glick
7ae96388e3 Merge branch 'master' of github.com:github-api/github-api into createCheckRun 2020-03-25 19:21:46 -04:00
Jesse Glick
e8b4de00d2 WireMock coverage 2020-03-25 19:18:11 -04:00
Jesse Glick
cd7963b30d Acc to 7a650132c5/src/main/java/org/kohsuke/github/GitHubBuilder.java (L221) it is GITHUB_LOGIN not GITHUB_USER 2020-03-25 17:52:32 -04:00
Liam Newman
0dc44cffcf Merge branch 'master' into add_has_projects 2020-03-25 11:57:44 -07:00
Liam Newman
7a650132c5 Merge pull request #724 from bitwiseman/task/builder-updater
Add Builder/Creator/Updater for GHLabel
2020-03-25 11:56:41 -07:00
Jesse Glick
c7fb390c38 Introduced enums 2020-03-25 13:40:00 -04:00
Jesse Glick
572ff9df19 I guess nullability annotations can be omitted from internal members 2020-03-25 13:20:33 -04:00
Jesse Glick
b715e0cef7 Reformatted 2020-03-25 13:18:11 -04:00
Jesse Glick
36ab2a889f Redesigned using a fluent builder idiom 2020-03-25 13:14:06 -04:00
D067452
a78d2f28d7 Get commit or tag signature verified flag
This fixes #737

- A new entity GHVerification.java has been added which would be reflecting Verification flag
- Updating GHCommit.java and GHTagObject.java with GHVerification
- Altering few test cases AppTest.java and GHTagTest.java to verify if the Verification entity is being picked up
- A separate test class SignatureVerificationTest.java with the associated wiremock test resources
- Adding a new enum GHReason.java
- Updating tests to check the GHReason implementation, GHReasonTest.java with the associated wiremock test resources
2020-03-25 17:19:56 +01:00
Jesse Glick
7d5a39ed89 GHRepository.createCheckRun 2020-03-24 23:51:38 -04:00
Liam Newman
772272ff36 Re-record test for GHLabel 2020-03-24 12:32:13 -07:00
Liam Newman
2ab4eafee9 Tweaks and cleanup 2020-03-23 17:40:01 -07:00
Liam Newman
b15e0d4c45 Cleanup and tweaks 2020-03-23 17:40:01 -07:00
Liam Newman
b8180314d8 Change to Preview for new builder pattern 2020-03-23 17:40:01 -07:00
Liam Newman
fcb8d03a0f Ensure that Description is part of GHLabel comparision 2020-03-23 17:40:01 -07:00
Liam Newman
09ec89bc2e Remove Repository member from GHLabel
It turns out GHLabel instances do not need a reference to their repo, just to root.
2020-03-23 17:40:01 -07:00
Liam Newman
863ad0f486 Clarify behavior 2020-03-23 17:40:01 -07:00
Liam Newman
79a1bb3571 Update src/test/java/org/kohsuke/github/AppTest.java 2020-03-23 17:40:01 -07:00
Liam Newman
9f1d7323c7 Reverted getter changes to highlight the more important set/update changes 2020-03-23 17:40:01 -07:00
Liam Newman
64a82f4785 Clean up proposed API changes 2020-03-23 17:40:01 -07:00
Liam Newman
f37e4bd76e Private fields 2020-03-23 17:40:01 -07:00
Liam Newman
98ef2cc640 Update-in-place and safer single or batch calculation 2020-03-23 17:40:01 -07:00
Liam Newman
134222fd69 Minor cleanups 2020-03-23 17:40:01 -07:00
Liam Newman
0cb2371517 Third alternative proposal
This removes the  from the fields.  Functionally the behavior is unchanged but
it is no longer guaranteed at compile time.  This simplifies streamlines the code slightly,
but at the cost of only being able to assert immutability rather than know it.

However, as we move to using this structure through more of the library, this is may be a better choice.
There are so many places where the GitHub API itself returns partial records or updates them dynamically.
Trying to claim immutability where it doesn't exist is not great either.
2020-03-23 17:40:01 -07:00
Liam Newman
b7de4359fd Alternative proposal
The guts of this version are a bit ugly but they result reasonable API code without a ton of extra
code needed.
2020-03-23 17:40:01 -07:00
Liam Newman
2607d6a107 Make GHLabel example of proposed API design 2020-03-23 17:40:01 -07:00
Liam Newman
db46b1ce13 Merge pull request #752 from github-api/dependabot/maven/com.squareup.okio-okio-2.5.0
Bump okio from 2.4.3 to 2.5.0
2020-03-23 14:44:12 -07:00
dependabot-preview[bot]
d7b08d5207 Bump okio from 2.4.3 to 2.5.0
Bumps [okio](https://github.com/square/okio) from 2.4.3 to 2.5.0.
- [Release notes](https://github.com/square/okio/releases)
- [Changelog](https://github.com/square/okio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okio/compare/parent-2.4.3...parent-2.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-23 06:54:29 +00:00
Sladyn
29fbba832c Merge branch 'master' into add_has_projects 2020-03-21 23:03:10 +05:30
Liam Newman
fd621a442a Merge pull request #742 from sladyn98/addHtmlURL
Retrieve html_url from Pull Request Review Comment
2020-03-20 12:33:34 -07:00
Liam Newman
a1a73568ae Merge branch 'master' into addHtmlURL 2020-03-20 11:41:23 -07:00
Liam Newman
3daccbd6ec Merge pull request #740 from avano/list-checkruns-for-ref
[CheckRuns] Add method for listing checkruns for given ref
2020-03-20 11:39:40 -07:00
Liam Newman
293deadb48 Merge branch 'master' into addHtmlURL 2020-03-20 08:42:47 -07:00
Andrej Vano
452b56c47b [GHEvent] Add new enum for registry_package event 2020-03-20 11:47:04 +01:00
Andrej Vano
5cb6bfa633 [CheckRuns] Add method for listing checkruns for given ref 2020-03-20 11:47:04 +01:00
Sladyn Nunes
0515cee6f3 Merge branch 'addHtmlURL' of https://github.com/sladyn98/github-api into addHtmlURL 2020-03-20 11:57:58 +05:30
Sladyn Nunes
4247112539 Adjust format 2020-03-20 11:56:22 +05:30
Sladyn Nunes
8d3374f574 Added test 2020-03-20 11:27:29 +05:30
Liam Newman
26833e5f7c Merge branch 'master' into add_has_projects 2020-03-19 12:15:34 -07:00
Liam Newman
6752b46f67 Merge pull request #750 from github-api/dependabot/maven/spotbugs.version-4.0.1
Bump spotbugs.version from 4.0.0 to 4.0.1
2020-03-19 10:30:48 -07:00
dependabot-preview[bot]
b9429ffcaa Bump spotbugs.version from 4.0.0 to 4.0.1
Bumps `spotbugs.version` from 4.0.0 to 4.0.1.

Updates `spotbugs` from 4.0.0 to 4.0.1
- [Release notes](https://github.com/spotbugs/spotbugs/releases)
- [Changelog](https://github.com/spotbugs/spotbugs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/spotbugs/spotbugs/compare/4.0.0...4.0.1)

Updates `spotbugs-annotations` from 4.0.0 to 4.0.1
- [Release notes](https://github.com/spotbugs/spotbugs/releases)
- [Changelog](https://github.com/spotbugs/spotbugs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/spotbugs/spotbugs/compare/4.0.0...4.0.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-19 06:35:16 +00:00
Liam Newman
10827c7e21 Merge branch 'master' into addHtmlURL 2020-03-18 08:43:43 -07:00
Liam Newman
23cb4a34a4 Merge branch 'master' into add_has_projects 2020-03-18 08:43:20 -07:00
Liam Newman
adfd09565f Merge pull request #733 from ingwarsw/add_get_team_by_slug
Make getTeambySlug faster
2020-03-17 15:23:14 -07:00
Karol Lassak
78b9ff49d4 Fix tests 2020-03-17 22:36:54 +01:00
Karol Lassak
fca425d25e Add test for old getteam method 2020-03-17 22:34:13 +01:00
Karol Lassak
1a4238156c Fix javadocs 2020-03-17 11:34:31 +01:00
Karol Lassak
f6210cc014 Change variable name to something meningfull 2020-03-17 11:21:58 +01:00
Karol Lassak
6c8b466e59 Add mocks for tests 2020-03-17 11:18:50 +01:00
Karol Lassak
2aebe97f9f Add/restore test for getTeam 2020-03-17 11:18:33 +01:00
Karol Lassak
157724bff8 Fix rest of tests 2020-03-17 10:20:42 +01:00
Karol Lassak
6cbb1a0bee Fix tests partially 2020-03-17 10:13:43 +01:00
Karol Lassak
960a13dd38 Merge branch 'master' into add_get_team_by_slug 2020-03-17 09:08:34 +01:00
Karol Lassak
9213f80435 Add comment to deprecation
Co-Authored-By: Liam Newman <bitwiseman@gmail.com>
2020-03-17 09:07:37 +01:00
Liam Newman
bccae94c7a Merge pull request #734 from github-api/dependabot/maven/org.apache.maven.plugins-maven-site-plugin-3.9.0
Bump maven-site-plugin from 3.8.2 to 3.9.0
2020-03-16 12:57:09 -07:00
Liam Newman
d71f77ce06 Merge pull request #746 from github-api/dependabot/maven/com.github.spotbugs-spotbugs-maven-plugin-4.0.0
Bump spotbugs-maven-plugin from 3.1.12.2 to 4.0.0
2020-03-16 12:56:54 -07:00
Liam Newman
2787f3dc71 Merge pull request #730 from github-api/dependabot/maven/com.squareup.okhttp3-okhttp-4.4.1
Bump okhttp from 4.4.0 to 4.4.1
2020-03-16 12:56:40 -07:00
dependabot-preview[bot]
fb00baab5b Bump maven-site-plugin from 3.8.2 to 3.9.0
Bumps [maven-site-plugin](https://github.com/apache/maven-site-plugin) from 3.8.2 to 3.9.0.
- [Release notes](https://github.com/apache/maven-site-plugin/releases)
- [Commits](https://github.com/apache/maven-site-plugin/compare/maven-site-plugin-3.8.2...maven-site-plugin-3.9.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-16 19:29:36 +00:00
dependabot-preview[bot]
9e22155d31 Bump okhttp from 4.4.0 to 4.4.1
Bumps [okhttp](https://github.com/square/okhttp) from 4.4.0 to 4.4.1.
- [Release notes](https://github.com/square/okhttp/releases)
- [Changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okhttp/compare/parent-4.4.0...parent-4.4.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-16 19:29:35 +00:00
dependabot-preview[bot]
963373435d Bump spotbugs-maven-plugin from 3.1.12.2 to 4.0.0
Bumps [spotbugs-maven-plugin](https://github.com/spotbugs/spotbugs-maven-plugin) from 3.1.12.2 to 4.0.0.
- [Release notes](https://github.com/spotbugs/spotbugs-maven-plugin/releases)
- [Commits](https://github.com/spotbugs/spotbugs-maven-plugin/compare/spotbugs-maven-plugin-3.1.12.2...spotbugs-maven-plugin-4.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-16 19:29:30 +00:00
Liam Newman
377987fa92 Merge pull request #747 from sladyn98/add_ci_status_badge
Added github CI status badge
2020-03-16 12:28:18 -07:00
Liam Newman
0b6980639e Merge pull request #745 from github-api/dependabot/maven/org.mockito-mockito-core-3.3.3
Bump mockito-core from 3.3.1 to 3.3.3
2020-03-16 12:26:26 -07:00
Liam Newman
4f1cc9f94f Merge pull request #744 from github-api/dependabot/maven/org.apache.maven.plugins-maven-javadoc-plugin-3.2.0
Bump maven-javadoc-plugin from 3.1.1 to 3.2.0
2020-03-16 12:26:12 -07:00
dependabot-preview[bot]
6e5434a0ec Bump mockito-core from 3.3.1 to 3.3.3
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.3.1 to 3.3.3.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.3.1...v3.3.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-16 19:25:57 +00:00
dependabot-preview[bot]
3244f7c38f Bump maven-javadoc-plugin from 3.1.1 to 3.2.0
Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.1.1 to 3.2.0.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.1.1...maven-javadoc-plugin-3.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-16 19:25:56 +00:00
Liam Newman
f27b676e89 Merge pull request #743 from github-api/dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-5.7.0.202003110725-r
Bump org.eclipse.jgit from 5.6.1.202002131546-r to 5.7.0.202003110725-r
2020-03-16 12:25:03 -07:00
Liam Newman
4f2a80a4a3 Merge pull request #732 from github-api/dependabot/maven/com.github.tomakehurst-wiremock-jre8-standalone-2.26.3
Bump wiremock-jre8-standalone from 2.26.2 to 2.26.3
2020-03-16 12:24:43 -07:00
Sladyn
a51bc27829 Merge branch 'master' into add_ci_status_badge 2020-03-16 23:35:17 +05:30
Sladyn Nunes
4fd321c93d Added github CI status badge 2020-03-16 23:32:23 +05:30
dependabot-preview[bot]
bbd62bdef5 Bump org.eclipse.jgit from 5.6.1.202002131546-r to 5.7.0.202003110725-r
Bumps org.eclipse.jgit from 5.6.1.202002131546-r to 5.7.0.202003110725-r.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-16 06:40:34 +00:00
Sladyn
4bb1d78939 Merge branch 'master' into addHtmlURL 2020-03-15 18:41:22 +05:30
Sladyn Nunes
53c37ef413 Retrieve html_url from PRReviewComment 2020-03-15 18:30:29 +05:30
Sladyn
a6511b6c5a Merge branch 'master' into add_has_projects 2020-03-15 17:30:45 +05:30
Sladyn Nunes
829e96a2d0 Add has_projects field to github repository 2020-03-15 14:44:52 +05:30
Karol Lassak
2e25f37433 Format code 2020-03-09 16:39:22 +01:00
Karol Lassak
fbf6c73226 Make getTeambySlug fast enought 2020-03-09 16:04:01 +01:00
dependabot-preview[bot]
aab54e3f23 Bump wiremock-jre8-standalone from 2.26.2 to 2.26.3
Bumps [wiremock-jre8-standalone](https://github.com/tomakehurst/wiremock) from 2.26.2 to 2.26.3.
- [Release notes](https://github.com/tomakehurst/wiremock/releases)
- [Commits](https://github.com/tomakehurst/wiremock/compare/2.26.2...2.26.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-09 06:47:44 +00:00
Liam Newman
a6eff7fbfb [maven-release-plugin] prepare for next development iteration 2020-03-04 16:54:50 -08:00
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
5481 changed files with 397689 additions and 367351 deletions

View File

@@ -7,4 +7,6 @@ We love getting PRs, but we hate asking people for the same basic changes every
- [ ] Push your changes to a branch other than `master`. Create your PR from that branch.
- [ ] Add JavaDocs and other comments
- [ ] Write tests that run and pass in CI. See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to capture snapshot data.
- [ ] Run `mvn -D enable-ci clean install site` locally. This may reformat your code, commit those changes. If this command doesn't succeed, your change will not pass CI.
- [ ] Run `mvn clean compile` locally. This may reformat your code, commit those changes.
- [ ] Run `mvn -D enable-ci clean install site` locally. If this command doesn't succeed, your change will not pass CI.

View File

@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11 ]
java: [ 13 ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
@@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11 ]
java: [ 8, 11 ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
@@ -51,7 +51,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu, windows ]
java: [ 8, 11, 13 ]
java: [ 8, 11, 13, 15-ea ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,9 @@
# Java API for GitHub
[![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/org.kohsuke/github-api?server=https%3A%2F%2Foss.sonatype.org)](https://mvnrepository.com/artifact/org.kohsuke/github-api)
[![Join the chat at https://gitter.im/github-api/github-api](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/github-api/github-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join the chat at https://gitter.im/hub4j/github-api](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/hub4j/github-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![CI](https://github.com/hub4j/github-api/workflows/CI/badge.svg?branch=master)
See https://github-api.kohsuke.org/ for more details

60
pom.xml
View File

@@ -2,16 +2,16 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.107</version>
<version>1.112</version>
<name>GitHub API for Java</name>
<url>https://github-api.kohsuke.org/</url>
<description>GitHub API for Java</description>
<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>
<connection>scm:git:git@github.com/hub4j/${project.artifactId}.git</connection>
<developerConnection>scm:git:ssh://git@github.com/hub4j/${project.artifactId}.git</developerConnection>
<url>https://github.com/hub4j/github-api/</url>
<tag>github-api-1.112</tag>
</scm>
<distributionManagement>
@@ -27,22 +27,22 @@
</repository>
<site>
<id>github-pages</id>
<url>gitsite:git@github.com/github-api/${project.artifactId}.git</url>
<url>gitsite:git@github.com/hub4j/${project.artifactId}.git</url>
</site>
</distributionManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spotbugs-maven-plugin.version>3.1.12.2</spotbugs-maven-plugin.version>
<spotbugs.version>4.0.0</spotbugs.version>
<spotbugs-maven-plugin.version>4.0.0</spotbugs-maven-plugin.version>
<spotbugs.version>4.0.3</spotbugs.version>
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
<hamcrest.version>2.2</hamcrest.version>
<okhttp3.version>4.4.0</okhttp3.version>
<okio.version>2.4.3</okio.version>
<okhttp3.version>4.4.1</okhttp3.version>
<okio.version>2.5.0</okio.version>
<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>
@@ -213,7 +209,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
<configuration>
<source>8</source>
<failOnWarnings>true</failOnWarnings>
@@ -237,7 +233,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version>
<version>3.9.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -257,7 +253,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
<dependencies>
<dependency>
<groupId>org.apache.bcel</groupId>
@@ -285,6 +281,10 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<!-- SUREFIRE-1226 workaround -->
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -337,7 +337,7 @@
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>1.3.2</version>
<version>1.4.1</version>
<configuration>
<groups>*,java.,javax.</groups>
<removeUnused>true</removeUnused>
@@ -457,7 +457,7 @@
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.6.1.202002131546-r</version>
<version>5.7.0.202003110725-r</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -495,7 +495,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.2.4</version>
<version>3.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -507,7 +507,7 @@
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<version>2.26.0</version>
<version>2.26.3</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -572,6 +572,10 @@
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
@@ -621,6 +625,18 @@
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<!-- select non-aggregate reports -->
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>

View File

@@ -0,0 +1,165 @@
package org.kohsuke.github;
import java.io.IOException;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
/**
* An abstract data object builder/updater.
*
* This class can be use to make a Builder that supports both batch and single property changes.
* <p>
* Batching looks like this:
* </p>
*
* <pre>
* update().someName(value).otherName(value).done()
* </pre>
* <p>
* Single changes look like this:
* </p>
*
* <pre>
* set().someName(value);
* set().otherName(value);
* </pre>
* <p>
* If {@link S} is the same as {@link R}, {@link #with(String, Object)} will commit changes after the first value change
* and return a {@link R} from {@link #done()}.
* </p>
* <p>
* If {@link S} is not the same as {@link R}, {@link #with(String, Object)} will batch together multiple changes and let
* the user call {@link #done()} when they are ready.
*
* @param <R>
* Final return type built by this builder returned when {@link #done()}} is called.
* @param <S>
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S}
* the same as {@link R}, this builder will commit changes after each call to {@link #with(String, Object)}.
*/
abstract class AbstractBuilder<R, S> {
@Nonnull
private final Class<R> returnType;
private final boolean commitChangesImmediately;
@CheckForNull
private final R baseInstance;
@Nonnull
protected final Requester requester;
// TODO: Not sure how update-in-place behavior should be controlled
// However, it certainly can be controlled dynamically down to the instance level or inherited for all children of
// some
// connection.
protected boolean updateInPlace;
/**
* Creates a builder.
*
* @param root
* the GitHub instance to connect to.
* @param intermediateReturnType
* the intermediate return type of type {@link S} returned by calls to {@link #with(String, Object)}.
* Must either be equal to {@code builtReturnType} or this instance must be castable to this class. If
* not, the constructor will throw {@link IllegalArgumentException}.
* @param finalReturnType
* the final return type for built by this builder returned when {@link #done()}} is called.
* @param baseInstance
* optional instance on which to base this builder.
*/
protected AbstractBuilder(@Nonnull Class<R> finalReturnType,
@Nonnull Class<S> intermediateReturnType,
@Nonnull GitHub root,
@CheckForNull R baseInstance) {
this.requester = root.createRequest();
this.returnType = finalReturnType;
this.commitChangesImmediately = returnType.equals(intermediateReturnType);
if (!commitChangesImmediately && !intermediateReturnType.isInstance(this)) {
throw new IllegalArgumentException(
"Argument \"intermediateReturnType\": This instance must be castable to intermediateReturnType or finalReturnType must be equal to intermediateReturnType.");
}
this.baseInstance = baseInstance;
this.updateInPlace = false;
}
/**
* Finishes an update, committing changes.
*
* This method may update-in-place or not. Either way it returns the resulting instance.
*
* @return an instance with updated current data
* @throws IOException
* if there is an I/O Exception
*/
@Nonnull
@Preview
@Deprecated
public R done() throws IOException {
R result;
if (updateInPlace && baseInstance != null) {
result = requester.fetchInto(baseInstance);
} else {
result = requester.fetch(returnType);
}
return result;
}
/**
* Applies a value to a name for this builder.
*
* If {@link S} is the same as {@link R}, this method will commit changes after the first value change and return a
* {@link R} from {@link #done()}.
*
* If {@link S} is not the same as {@link R}, this method will return an {@link S} and letting the caller batch
* together multiple changes and call {@link #done()} when they are ready.
*
* @param name
* the name of the field
* @param value
* the value of the field
* @return either a continuing builder or an updated data record
* @throws IOException
* if an I/O error occurs
*/
@Nonnull
@Preview
@Deprecated
protected S with(@Nonnull String name, Object value) throws IOException {
requester.with(name, value);
return continueOrDone();
}
/**
* Chooses whether to return a continuing builder or an updated data record
*
* If {@link S} is the same as {@link R}, this method will commit changes after the first value change and return a
* {@link R} from {@link #done()}.
*
* If {@link S} is not the same as {@link R}, this method will return an {@link S} and letting the caller batch
* together multiple changes and call {@link #done()} when they are ready.
*
* @return either a continuing builder or an updated data record
* @throws IOException
* if an I/O error occurs
*/
@Nonnull
@Preview
@Deprecated
protected S continueOrDone() throws IOException {
// This little bit of roughness in this base class means all inheriting builders get to create Updater and
// Setter classes from almost identical code. Creator can often be implemented with significant code reuse as
// well.
if (commitChangesImmediately) {
// These casts look strange and risky, but they they're actually guaranteed safe due to the return path
// being based on the previous comparison of class instances passed to the constructor.
return (S) done();
} else {
return (S) this;
}
}
}

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 {
@@ -38,7 +39,9 @@ public class GHApp extends GHObject {
*
* @param owner
* the owner
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setOwner(GHUser owner) {
this.owner = owner;
}
@@ -57,7 +60,9 @@ public class GHApp extends GHObject {
*
* @param name
* the name
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setName(String name) {
this.name = name;
}
@@ -76,7 +81,9 @@ public class GHApp extends GHObject {
*
* @param description
* the description
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setDescription(String description) {
this.description = description;
}
@@ -95,7 +102,9 @@ public class GHApp extends GHObject {
*
* @param externalUrl
* the external url
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setExternalUrl(String externalUrl) {
this.externalUrl = externalUrl;
}
@@ -114,7 +123,9 @@ public class GHApp extends GHObject {
*
* @param events
* the events
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setEvents(List<GHEvent> events) {
this.events = events;
}
@@ -133,7 +144,9 @@ public class GHApp extends GHObject {
*
* @param installationsCount
* the installations count
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setInstallationsCount(long installationsCount) {
this.installationsCount = installationsCount;
}
@@ -156,7 +169,9 @@ public class GHApp extends GHObject {
*
* @param permissions
* the permissions
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setPermissions(Map<String, String> permissions) {
this.permissions = permissions;
}

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)
@@ -58,7 +59,9 @@ public class GHAppInstallation extends GHObject {
*
* @param root
* the root
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setRoot(GitHub root) {
this.root = root;
}
@@ -77,7 +80,9 @@ public class GHAppInstallation extends GHObject {
*
* @param account
* the account
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setAccount(GHUser account) {
this.account = account;
}
@@ -96,7 +101,9 @@ public class GHAppInstallation extends GHObject {
*
* @param accessTokenUrl
* the access token url
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setAccessTokenUrl(String accessTokenUrl) {
this.accessTokenUrl = accessTokenUrl;
}
@@ -115,7 +122,9 @@ public class GHAppInstallation extends GHObject {
*
* @param repositoriesUrl
* the repositories url
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setRepositoriesUrl(String repositoriesUrl) {
this.repositoriesUrl = repositoriesUrl;
}
@@ -134,7 +143,9 @@ public class GHAppInstallation extends GHObject {
*
* @param appId
* the app id
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setAppId(long appId) {
this.appId = appId;
}
@@ -153,7 +164,9 @@ public class GHAppInstallation extends GHObject {
*
* @param targetId
* the target id
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setTargetId(long targetId) {
this.targetId = targetId;
}
@@ -172,7 +185,9 @@ public class GHAppInstallation extends GHObject {
*
* @param targetType
* the target type
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setTargetType(GHTargetType targetType) {
this.targetType = targetType;
}
@@ -191,7 +206,9 @@ public class GHAppInstallation extends GHObject {
*
* @param permissions
* the permissions
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setPermissions(Map<String, GHPermissionType> permissions) {
this.permissions = permissions;
}
@@ -210,7 +227,9 @@ public class GHAppInstallation extends GHObject {
*
* @param events
* the events
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setEvents(List<GHEvent> events) {
this.events = events;
}
@@ -229,7 +248,9 @@ public class GHAppInstallation extends GHObject {
*
* @param singleFileName
* the single file name
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setSingleFileName(String singleFileName) {
this.singleFileName = singleFileName;
}
@@ -248,7 +269,9 @@ public class GHAppInstallation extends GHObject {
*
* @param repositorySelection
* the repository selection
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setRepositorySelection(GHRepositorySelection repositorySelection) {
this.repositorySelection = repositorySelection;
}
@@ -273,7 +296,7 @@ public class GHAppInstallation extends GHObject {
root.createRequest()
.method("DELETE")
.withPreview(GAMBIT)
.withUrlPath(String.format("/app/installations/%d", id))
.withUrlPath(String.format("/app/installations/%d", getId()))
.send();
}
@@ -292,7 +315,9 @@ public class GHAppInstallation extends GHObject {
@Preview
@Deprecated
public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permissions) {
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", id), permissions);
return new GHAppCreateTokenBuilder(root,
String.format("/app/installations/%d/access_tokens", getId()),
permissions);
}
/**
@@ -307,6 +332,6 @@ public class GHAppInstallation extends GHObject {
@Preview
@Deprecated
public GHAppCreateTokenBuilder createToken() {
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", id));
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", getId()));
}
}

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 {
@@ -36,7 +37,9 @@ public class GHAppInstallationToken {
*
* @param root
* the root
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setRoot(GitHub root) {
this.root = root;
}
@@ -55,7 +58,9 @@ public class GHAppInstallationToken {
*
* @param permissions
* the permissions
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setPermissions(Map<String, String> permissions) {
this.permissions = permissions;
}
@@ -74,7 +79,9 @@ public class GHAppInstallationToken {
*
* @param token
* the token
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setToken(String token) {
this.token = token;
}
@@ -93,7 +100,9 @@ public class GHAppInstallationToken {
*
* @param repositories
* the repositories
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setRepositories(List<GHRepository> repositories) {
this.repositories = repositories;
}
@@ -112,7 +121,9 @@ public class GHAppInstallationToken {
*
* @param repositorySelection
* the repository selection
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
*/
@Deprecated
public void setRepositorySelection(GHRepositorySelection repositorySelection) {
this.repositorySelection = repositorySelection;
}

View File

@@ -149,7 +149,7 @@ public class GHAsset extends GHObject {
}
private String getApiRoute() {
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + id;
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + getId();
}
GHAsset wrap(GHRelease release) {

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>
*/
@@ -111,10 +112,12 @@ public class GHAuthorization extends GHObject {
* Gets api url.
*
* @return the api url
* @deprecated use {@link #getUrl()}
*/
@Deprecated
@SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library API, cannot be changed")
public URL getApiURL() {
return GitHubClient.parseURL(url);
return getUrl();
}
/**

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",
@@ -99,7 +101,7 @@ public class GHBranch {
* the io exception
*/
public GHBranchProtection getProtection() throws IOException {
return root.createRequest().withUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this);
return root.createRequest().setRawUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this);
}
/**
@@ -118,7 +120,7 @@ public class GHBranch {
* if disabling protection fails
*/
public void disableProtection() throws IOException {
root.createRequest().method("DELETE").withUrlPath(protection_url).send();
root.createRequest().method("DELETE").setRawUrlPath(protection_url).send();
}
/**

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,39 @@ public class GHCheckRun extends GHObject {
return pullRequests;
}
/**
* Gets status of the check run.
*
* @return Status of the check run
* @see Status
*/
public String getStatus() {
return status;
}
public static enum Status {
QUEUED, IN_PROGRESS, COMPLETED
}
/**
* Gets conclusion of a completed check run.
*
* @return Status of the check run
* @see Conclusion
*/
public String getConclusion() {
return conclusion;
}
public static enum Conclusion {
SUCCESS, FAILURE, NEUTRAL, CANCELLED, TIMED_OUT, ACTION_REQUIRED
}
/**
* Gets the custom name of this check run.
*
* @return Name of the check run
*/
public String getName() {
return name;
}
@@ -62,6 +96,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 +111,149 @@ 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;
}
}
public static enum AnnotationLevel {
NOTICE, WARNING, FAILURE
}
}

View File

@@ -0,0 +1,291 @@
/*
* The MIT License
*
* Copyright 2020 CloudBees, Inc.
*
* 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 com.fasterxml.jackson.annotation.JsonInclude;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
/**
* Drafts a check run.
*
* @see GHCheckRun
* @see GHRepository#createCheckRun
* @see <a href="https://developer.github.com/v3/checks/runs/#create-a-check-run">documentation</a>
*/
@SuppressFBWarnings(value = "URF_UNREAD_FIELD", justification = "Jackson serializes these even without a getter")
@Preview
@Deprecated
public final class GHCheckRunBuilder {
private final GHRepository repo;
private final Requester requester;
private Output output;
private List<Action> actions;
GHCheckRunBuilder(GHRepository repo, String name, String headSHA) {
this.repo = repo;
requester = repo.root.createRequest()
.withPreview(Previews.ANTIOPE)
.method("POST")
.with("name", name)
.with("head_sha", headSHA)
.withUrlPath(repo.getApiTailUrl("check-runs"));
}
public @NonNull GHCheckRunBuilder withDetailsURL(@CheckForNull String detailsURL) {
requester.with("details_url", detailsURL);
return this;
}
public @NonNull GHCheckRunBuilder withExternalID(@CheckForNull String externalID) {
requester.with("external_id", externalID);
return this;
}
public @NonNull GHCheckRunBuilder withStatus(@CheckForNull GHCheckRun.Status status) {
if (status != null) {
// Do *not* use the overload taking Enum, as that s/_/-/g which would be wrong here.
requester.with("status", status.toString().toLowerCase(Locale.ROOT));
}
return this;
}
public @NonNull GHCheckRunBuilder withConclusion(@CheckForNull GHCheckRun.Conclusion conclusion) {
if (conclusion != null) {
requester.with("conclusion", conclusion.toString().toLowerCase(Locale.ROOT));
}
return this;
}
public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Date startedAt) {
if (startedAt != null) {
requester.with("started_at", GitHubClient.printDate(startedAt));
}
return this;
}
public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Date completedAt) {
if (completedAt != null) {
requester.with("completed_at", GitHubClient.printDate(completedAt));
}
return this;
}
public @NonNull GHCheckRunBuilder add(@NonNull Output output) {
if (this.output != null) {
throw new IllegalStateException("cannot add Output twice");
}
this.output = output;
return this;
}
public @NonNull GHCheckRunBuilder add(@NonNull Action action) {
if (actions == null) {
actions = new LinkedList<>();
}
actions.add(action);
return this;
}
private static final int MAX_ANNOTATIONS = 50;
/**
* Actually creates the check run. (If more than fifty annotations were requested, this is done in batches.)
*
* @return the resulting run
* @throws IOException
* for the usual reasons
*/
public @NonNull GHCheckRun create() throws IOException {
List<Annotation> extraAnnotations;
if (output != null && output.annotations != null && output.annotations.size() > MAX_ANNOTATIONS) {
extraAnnotations = output.annotations.subList(MAX_ANNOTATIONS, output.annotations.size());
output.annotations = output.annotations.subList(0, MAX_ANNOTATIONS);
} else {
extraAnnotations = Collections.emptyList();
}
GHCheckRun run = requester.with("output", output).with("actions", actions).fetch(GHCheckRun.class).wrap(repo);
while (!extraAnnotations.isEmpty()) {
Output output2 = new Output(output.title, output.summary);
int i = Math.min(extraAnnotations.size(), MAX_ANNOTATIONS);
output2.annotations = extraAnnotations.subList(0, i);
extraAnnotations = extraAnnotations.subList(i, extraAnnotations.size());
run = repo.root.createRequest()
.withPreview(Previews.ANTIOPE)
.method("PATCH")
.with("output", output2)
.withUrlPath(repo.getApiTailUrl("check-runs/" + run.getId()))
.fetch(GHCheckRun.class)
.wrap(repo);
}
return run;
}
/**
* @see <a href="https://developer.github.com/v3/checks/runs/#output-object">documentation</a>
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class Output {
private final String title;
private final String summary;
private String text;
private List<Annotation> annotations;
private List<Image> images;
public Output(@NonNull String title, @NonNull String summary) {
this.title = title;
this.summary = summary;
}
public @NonNull Output withText(@CheckForNull String text) {
this.text = text;
return this;
}
public @NonNull Output add(@NonNull Annotation annotation) {
if (annotations == null) {
annotations = new LinkedList<>();
}
annotations.add(annotation);
return this;
}
public @NonNull Output add(@NonNull Image image) {
if (images == null) {
images = new LinkedList<>();
}
images.add(image);
return this;
}
}
/**
* @see <a href="https://developer.github.com/v3/checks/runs/#annotations-object">documentation</a>
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class Annotation {
private final String path;
private final int start_line;
private final int end_line;
private final String annotation_level;
private final String message;
private Integer start_column;
private Integer end_column;
private String title;
private String raw_details;
public Annotation(@NonNull String path,
int line,
@NonNull GHCheckRun.AnnotationLevel annotationLevel,
@NonNull String message) {
this(path, line, line, annotationLevel, message);
}
public Annotation(@NonNull String path,
int startLine,
int endLine,
@NonNull GHCheckRun.AnnotationLevel annotationLevel,
@NonNull String message) {
this.path = path;
start_line = startLine;
end_line = endLine;
annotation_level = annotationLevel.toString().toLowerCase(Locale.ROOT);
this.message = message;
}
public @NonNull Annotation withStartColumn(@CheckForNull Integer startColumn) {
start_column = startColumn;
return this;
}
public @NonNull Annotation withEndColumn(@CheckForNull Integer endColumn) {
end_column = endColumn;
return this;
}
public @NonNull Annotation withTitle(@CheckForNull String title) {
this.title = title;
return this;
}
public @NonNull Annotation withRawDetails(@CheckForNull String rawDetails) {
raw_details = rawDetails;
return this;
}
}
/**
* @see <a href="https://developer.github.com/v3/checks/runs/#images-object">documentation</a>
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class Image {
private final String alt;
private final String image_url;
private String caption;
public Image(@NonNull String alt, @NonNull String imageURL) {
this.alt = alt;
image_url = imageURL;
}
public @NonNull Image withCaption(@CheckForNull String caption) {
this.caption = caption;
return this;
}
}
/**
* @see <a href="https://developer.github.com/v3/checks/runs/#actions-object">documentation</a>
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class Action {
private final String label;
private final String description;
private final String identifier;
public Action(@NonNull String label, @NonNull String description, @NonNull String identifier) {
this.label = label;
this.description = description;
this.identifier = identifier;
}
}
}

View File

@@ -0,0 +1,44 @@
package org.kohsuke.github;
import java.util.Iterator;
import javax.annotation.Nonnull;
/**
* Iterable for check-runs listing.
*/
class GHCheckRunsIterable extends PagedIterable<GHCheckRun> {
private GitHub root;
private final GitHubRequest request;
private GHCheckRunsPage result;
public GHCheckRunsIterable(GitHub root, GitHubRequest request) {
this.root = root;
this.request = request;
}
@Nonnull
@Override
public PagedIterator<GHCheckRun> _iterator(int pageSize) {
return new PagedIterator<>(
adapt(GitHubPageIterator.create(root.getClient(), GHCheckRunsPage.class, request, pageSize)),
null);
}
protected Iterator<GHCheckRun[]> adapt(final Iterator<GHCheckRunsPage> base) {
return new Iterator<GHCheckRun[]>() {
public boolean hasNext() {
return base.hasNext();
}
public GHCheckRun[] next() {
GHCheckRunsPage v = base.next();
if (result == null) {
result = v;
}
return v.getCheckRuns(root);
}
};
}
}

View File

@@ -0,0 +1,20 @@
package org.kohsuke.github;
/**
* Represents the one page of check-runs result when listing check-runs.
*/
class GHCheckRunsPage {
private int total_count;
private GHCheckRun[] check_runs;
public int getTotalCount() {
return total_count;
}
GHCheckRun[] getCheckRuns(GitHub root) {
for (GHCheckRun check_run : check_runs) {
check_run.wrap(root);
}
return check_runs;
}
}

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()
*/
@@ -38,6 +39,8 @@ public class GHCommit {
private int comment_count;
private GHVerification verification;
static class Tree {
String sha;
}
@@ -99,6 +102,15 @@ public class GHCommit {
public int getCommentCount() {
return comment_count;
}
/**
* Gets Verification Status.
*
* @return the Verification status
*/
public GHVerification getVerification() {
return verification;
}
}
/**
@@ -511,6 +523,19 @@ public class GHCommit {
return owner.getLastCommitStatus(sha);
}
/**
* Gets check-runs for given sha.
*
* @return check runs for given sha.
* @throws IOException
* on error
*/
@Preview
@Deprecated
public PagedIterable<GHCheckRun> getCheckRuns() throws IOException {
return owner.getCheckRuns(sha);
}
/**
* Some of the fields are not always filled in when this object is retrieved as a part of another API call.
*

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,
@@ -152,7 +153,7 @@ public class GHCommitComment extends GHObject implements Reactable {
}
private String getApiTail() {
return String.format("/repos/%s/%s/comments/%s", owner.getOwnerName(), owner.getName(), id);
return String.format("/repos/%s/%s/comments/%s", owner.getOwnerName(), owner.getName(), getId());
}
GHCommitComment wrap(GHRepository owner) {

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;
@@ -77,6 +79,18 @@ public class GHCreateRepositoryBuilder {
return this;
}
/**
* Enables projects
*
* @param enabled
* true if enabled
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder projects(boolean enabled) {
this.builder.with("has_projects", enabled);
return this;
}
/**
* Enables wiki
*

View File

@@ -122,7 +122,7 @@ public class GHDeployment extends GHObject {
* @return the gh deployment status builder
*/
public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
return new GHDeploymentStatusBuilder(owner, id, state);
return new GHDeploymentStatusBuilder(owner, getId(), state);
}
/**

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>
*/
@@ -49,6 +50,7 @@ public enum GHEvent {
PULL_REQUEST_REVIEW,
PULL_REQUEST_REVIEW_COMMENT,
PUSH,
REGISTRY_PACKAGE,
RELEASE,
REPOSITORY_DISPATCH, // only valid for org hooks
REPOSITORY,

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

@@ -3,6 +3,7 @@ package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonSetter;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.io.Reader;
import java.util.List;
@@ -48,7 +49,7 @@ public abstract class GHEventPayload {
}
// List of events that still need to be added:
// CheckRunEvent CheckSuiteEvent ContentReferenceEvent
// ContentReferenceEvent
// DeployKeyEvent DownloadEvent FollowEvent ForkApplyEvent GitHubAppAuthorizationEvent GistEvent GollumEvent
// InstallationEvent InstallationRepositoriesEvent IssuesEvent LabelEvent MarketplacePurchaseEvent MemberEvent
// MembershipEvent MetaEvent MilestoneEvent OrganizationEvent OrgBlockEvent PackageEvent PageBuildEvent
@@ -132,6 +133,7 @@ public abstract class GHEventPayload {
* @return the repository
*/
public GHRepository getRepository() {
repository.root = root;
return repository;
}
@@ -150,6 +152,209 @@ 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;
}
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);
if (checkSuite == null)
throw new IllegalStateException(
"Expected check_suite payload, but got something else. Maybe we've got another type of event?");
if (repository != null) {
repository.wrap(root);
checkSuite.wrap(repository);
} else {
checkSuite.wrap(root);
}
}
}
/**
* An installation has been installed, uninstalled, or its permissions have been changed.
*
* @see <a href="https://developer.github.com/v3/activity/events/types/#installationevent">authoritative source</a>
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
public static class Installation extends GHEventPayload {
private String action;
private GHAppInstallation installation;
private List<GHRepository> repositories;
/**
* Gets action
*
* @return the action
*/
public String getAction() {
return action;
}
/**
* Gets installation
*
* @return the installation
*/
public GHAppInstallation getInstallation() {
return installation;
}
/**
* Gets repositories
*
* @return the repositories
*/
public List<GHRepository> getRepositories() {
return repositories;
};
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);
if (installation == null)
throw new IllegalStateException(
"Expected check_suite payload, but got something else. Maybe we've got another type of event?");
else
installation.wrapUp(root);
if (repositories != null && !repositories.isEmpty()) {
try {
for (GHRepository singleRepo : repositories) { // warp each of the repository
singleRepo.wrap(root);
singleRepo.populate();
}
} catch (IOException e) {
throw new GHException("Failed to refresh repositories", e);
}
}
}
}
/**
* A repository has been added or removed from an installation.
*
* @see <a href="https://developer.github.com/v3/activity/events/types/#installationrepositoriesevent">authoritative
* source</a>
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
public static class InstallationRepositories extends GHEventPayload {
private String action;
private GHAppInstallation installation;
private String repositorySelection;
private List<GHRepository> repositoriesAdded;
private List<GHRepository> repositoriesRemoved;
/**
* Gets action
*
* @return the action
*/
public String getAction() {
return action;
}
/**
* Gets installation
*
* @return the installation
*/
public GHAppInstallation getInstallation() {
return installation;
}
/**
* Gets installation selection
*
* @return the installation selection
*/
public String getRepositorySelection() {
return repositorySelection;
}
/**
* Gets repositories added
*
* @return the repositories
*/
public List<GHRepository> getRepositoriesAdded() {
return repositoriesAdded;
}
/**
* Gets repositories removed
*
* @return the repositories
*/
public List<GHRepository> getRepositoriesRemoved() {
return repositoriesRemoved;
}
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);
if (installation == null)
throw new IllegalStateException(
"Expected check_suite payload, but got something else. Maybe we've got another type of event?");
else
installation.wrapUp(root);
List<GHRepository> repositories;
if ("added".equals(action))
repositories = repositoriesAdded;
else // action == "removed"
repositories = repositoriesRemoved;
if (repositories != null && !repositories.isEmpty()) {
try {
for (GHRepository singleRepo : repositories) { // warp each of the repository
singleRepo.wrap(root);
singleRepo.populate();
}
} catch (IOException e) {
throw new GHException("Failed to refresh repositories", e);
}
}
}
}
/**
* 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,43 @@ 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);
}
/**
* Unlike most other GitHub objects, the id for Gists can be non-numeric, such as "aa5a315d61ae9438b18d". If the id
* is numeric, this method will get it. If id is not numeric, this will throw a runtime
* {@link NumberFormatException}.
*
* @return id of the Gist.
* @deprecated Use {@link #getGistId()} instead.
*/
@Deprecated
@Override
public long getId() {
return Long.parseLong(getGistId());
}
/**
* Gets the id for this Gist. Unlike most other GitHub objects, the id for Gists can be non-numeric, such as
* "aa5a315d61ae9438b18d". This should be used instead of {@link #getId()}.
*
* @return id of this Gist
*/
public String getGistId() {
return this.id;
}
/**
* Gets owner.
@@ -43,7 +82,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public GHUser getOwner() throws IOException {
return root.intern(owner);
return owner;
}
/**
@@ -82,6 +121,11 @@ public class GHGist extends GHObject {
return git_push_url;
}
/**
* Get the html url.
*
* @return the github html url
*/
public URL getHtmlUrl() {
return GitHubClient.parseURL(html_url);
}
@@ -139,31 +183,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 +233,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 +242,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 +281,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

@@ -4,9 +4,12 @@ import java.io.IOException;
import java.util.Collections;
import java.util.LinkedHashMap;
import javax.annotation.Nonnull;
/**
* Builder pattern for creating a new Gist.
*
* @author Kohsuke Kawaguchi
* @see GitHub#createGist() GitHub#createGist()
*/
public class GHGistBuilder {
@@ -58,7 +61,7 @@ public class GHGistBuilder {
* the content
* @return Adds a new file.
*/
public GHGistBuilder file(String fileName, String content) {
public GHGistBuilder file(@Nonnull String fileName, @Nonnull String content) {
files.put(fileName, Collections.singletonMap("content", content));
return this;
}
@@ -72,6 +75,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

@@ -1,16 +1,21 @@
package org.kohsuke.github;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.annotation.Nonnull;
/**
* Builder pattern for updating a Gist.
*
* @author Martin van Zijl
*/
public class GHGistUpdater {
private final GHGist base;
private final Requester builder;
LinkedHashMap<String, Object> files;
LinkedHashMap<String, Map<String, String>> files;
GHGistUpdater(GHGist base) {
this.base = base;
@@ -30,16 +35,15 @@ public class GHGistUpdater {
* @throws IOException
* the io exception
*/
public GHGistUpdater addFile(String fileName, String content) throws IOException {
public GHGistUpdater addFile(@Nonnull String fileName, @Nonnull String content) throws IOException {
updateFile(fileName, content);
return this;
}
// // This method does not work.
// public GHGistUpdater deleteFile(String fileName) throws IOException {
// files.put(fileName, Collections.singletonMap("filename", null));
// return this;
// }
public GHGistUpdater deleteFile(@Nonnull String fileName) throws IOException {
files.put(fileName, null);
return this;
}
/**
* Rename file gh gist updater.
@@ -52,8 +56,9 @@ public class GHGistUpdater {
* @throws IOException
* the io exception
*/
public GHGistUpdater renameFile(String fileName, String newFileName) throws IOException {
files.put(fileName, Collections.singletonMap("filename", newFileName));
public GHGistUpdater renameFile(@Nonnull String fileName, @Nonnull String newFileName) throws IOException {
Map<String, String> file = files.computeIfAbsent(fileName, d -> new HashMap<>());
file.put("filename", newFileName);
return this;
}
@@ -68,8 +73,31 @@ public class GHGistUpdater {
* @throws IOException
* the io exception
*/
public GHGistUpdater updateFile(String fileName, String content) throws IOException {
files.put(fileName, Collections.singletonMap("content", content));
public GHGistUpdater updateFile(@Nonnull String fileName, @Nonnull String content) throws IOException {
Map<String, String> file = files.computeIfAbsent(fileName, d -> new HashMap<>());
file.put("content", content);
return this;
}
/**
* Update file name and content
*
* @param fileName
* the file name
* @param newFileName
* the new file name
* @param content
* the content
* @return the gh gist updater
* @throws IOException
* the io exception
*/
public GHGistUpdater updateFile(@Nonnull String fileName, @Nonnull String newFileName, @Nonnull String content)
throws IOException {
Map<String, String> file = files.computeIfAbsent(fileName, d -> new HashMap<>());
file.put("content", content);
file.put("filename", newFileName);
files.put(fileName, file);
return this;
}
@@ -94,6 +122,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

@@ -37,12 +37,14 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
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 +65,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 +73,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 +93,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 +165,7 @@ public class GHIssue extends GHObject implements Reactable {
if (labels == null) {
return Collections.emptyList();
}
return Collections.<GHLabel>unmodifiableList(labels);
return Collections.unmodifiableList(labels);
}
/**
@@ -193,10 +180,12 @@ public class GHIssue extends GHObject implements Reactable {
/**
* Gets api url.
*
* @return the api url
* @return API URL of this object.
* @deprecated use {@link #getUrl()}
*/
@Deprecated
public URL getApiURL() {
return GitHubClient.parseURL(url);
return getUrl();
}
/**
@@ -242,6 +231,13 @@ public class GHIssue extends GHObject implements Reactable {
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}
/**
* Identical to edit(), but allows null for the value.
*/
private void editNullable(String key, Object value) throws IOException {
root.createRequest().withNullable(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}
private void editIssue(String key, Object value) throws IOException {
root.createRequest().with(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
}
@@ -291,15 +287,19 @@ public class GHIssue extends GHObject implements Reactable {
}
/**
* Sets milestone.
* Sets the milestone for this issue.
*
* @param milestone
* the milestone
* The milestone to assign this issue to. Use null to remove the milestone for this issue.
* @throws IOException
* the io exception
* The io exception
*/
public void setMilestone(GHMilestone milestone) throws IOException {
edit("milestone", milestone.getNumber());
if (milestone == null) {
editNullable("milestone", null);
} else {
edit("milestone", milestone.getNumber());
}
}
/**
@@ -434,7 +434,7 @@ public class GHIssue extends GHObject implements Reactable {
* @see #listComments() #listComments()
*/
public List<GHIssueComment> getComments() throws IOException {
return listComments().asList();
return listComments().toList();
}
/**
@@ -573,7 +573,8 @@ public class GHIssue extends GHObject implements Reactable {
protected String getIssuesApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
return StringUtils.prependIfMissing(url.toString().replace(root.getApiUrl(), ""), "/");
}
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number;
}

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()
*/
@@ -148,6 +149,6 @@ public class GHIssueComment extends GHObject implements Reactable {
private String getApiRoute() {
return "/repos/" + owner.getRepository().getOwnerName() + "/" + owner.getRepository().getName()
+ "/issues/comments/" + id;
+ "/issues/comments/" + getId();
}
}

View File

@@ -4,6 +4,10 @@ import java.util.Date;
/**
* The type GHIssueEvent.
*
* @see <a href="https://developer.github.com/v3/issues/events/">Github documentation for issue events</a>
*
* @author Martin van Zijl
*/
public class GHIssueEvent {
private GitHub root;
@@ -16,6 +20,9 @@ public class GHIssueEvent {
private String commit_id;
private String commit_url;
private String created_at;
private GHMilestone milestone;
private GHLabel label;
private GHUser assignee;
private GHIssue issue;
@@ -109,6 +116,36 @@ public class GHIssueEvent {
return issue;
}
/**
* Get the {@link GHMilestone} that this issue was added to or removed from. Only present for events "milestoned"
* and "demilestoned", <code>null</code> otherwise.
*
* @return the milestone
*/
public GHMilestone getMilestone() {
return milestone;
}
/**
* Get the {@link GHLabel} that was added to or removed from the issue. Only present for events "labeled" and
* "unlabeled", <code>null</code> otherwise.
*
* @return the label
*/
public GHLabel getLabel() {
return label;
}
/**
* Get the {@link GHUser} that was assigned or unassigned from the issue. Only present for events "assigned" and
* "unassigned", <code>null</code> otherwise.
*
* @return the user
*/
public GHUser getAssignee() {
return assignee;
}
GHIssueEvent wrapUp(GitHub root) {
this.root = root;
return this;

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

@@ -1,26 +1,56 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
/**
* The type GHLabel.
*
* @author Kohsuke Kawaguchi
* @see <a href="https://developer.github.com/v3/issues/labels/">Labels</a>
* @see GHIssue#getLabels() GHIssue#getLabels()
* @see GHRepository#listLabels() GHRepository#listLabels()
*/
public class GHLabel {
private String url, name, color, description;
private GHRepository repo;
@Nonnull
private String url, name, color;
@CheckForNull
private String description;
@Nonnull
private final GitHub root;
@JsonCreator
private GHLabel(@JacksonInject @Nonnull GitHub root) {
this.root = root;
url = "";
name = "";
color = "";
description = null;
}
@Nonnull
GitHub getApiRoot() {
return Objects.requireNonNull(root);
}
/**
* Gets url.
*
* @return the url
*/
@Nonnull
public String getUrl() {
return url;
}
@@ -30,6 +60,7 @@ public class GHLabel {
*
* @return the name
*/
@Nonnull
public String getName() {
return name;
}
@@ -39,6 +70,7 @@ public class GHLabel {
*
* @return the color
*/
@Nonnull
public String getColor() {
return color;
}
@@ -48,25 +80,11 @@ public class GHLabel {
*
* @return the description
*/
@CheckForNull
public String getDescription() {
return description;
}
GHLabel wrapUp(GHRepository repo) {
this.repo = repo;
return this;
}
/**
* Delete.
*
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
repo.root.createRequest().method("DELETE").setRawUrlPath(url).send();
}
/**
* Sets color.
*
@@ -74,15 +92,11 @@ public class GHLabel {
* 6-letter hex color code, like "f29513"
* @throws IOException
* the io exception
* @deprecated use {@link #set()} or {@link #update()} instead
*/
@Deprecated
public void setColor(String newColor) throws IOException {
repo.root.createRequest()
.method("PATCH")
.with("name", name)
.with("color", newColor)
.with("description", description)
.setRawUrlPath(url)
.send();
set().color(newColor);
}
/**
@@ -92,25 +106,106 @@ public class GHLabel {
* Description of label
* @throws IOException
* the io exception
* @deprecated use {@link #set()} or {@link #update()} instead
*/
@Deprecated
public void setDescription(String newDescription) throws IOException {
repo.root.createRequest()
.method("PATCH")
.with("name", name)
.with("color", color)
.with("description", newDescription)
.setRawUrlPath(url)
.send();
set().description(newDescription);
}
static Collection<String> toNames(Collection<GHLabel> labels) {
List<String> r = new ArrayList<String>();
List<String> r = new ArrayList<>();
for (GHLabel l : labels) {
r.add(l.getName());
}
return r;
}
/**
* Begins the creation of a new instance.
*
* Consumer must call {@link Creator#done()} to commit changes.
*
* @param repository
* the repository in which the label will be created.
* @return a {@link Creator}
* @throws IOException
* the io exception
*/
@Preview
@Deprecated
static Creator create(GHRepository repository) throws IOException {
return new Creator(repository);
}
/**
* Reads a label from a repository.
*
* @param repository
* the repository to read from
* @param name
* the name of the label
* @return a label
* @throws IOException
* the io exception
*/
static GHLabel read(@Nonnull GHRepository repository, @Nonnull String name) throws IOException {
return repository.root.createRequest()
.withUrlPath(repository.getApiTailUrl("labels"), name)
.fetch(GHLabel.class);
}
/**
* Reads all labels from a repository.
*
* @param repository
* the repository to read from
* @return iterable of all labels
* @throws IOException
* the io exception
*/
static PagedIterable<GHLabel> readAll(@Nonnull final GHRepository repository) throws IOException {
return repository.root.createRequest()
.withUrlPath(repository.getApiTailUrl("labels"))
.toIterable(GHLabel[].class, null);
}
/**
* Begins a batch update
*
* Consumer must call {@link Updater#done()} to commit changes.
*
* @return a {@link Updater}
*/
@Preview
@Deprecated
public Updater update() {
return new Updater(this);
}
/**
* Begins a single property update.
*
* @return a {@link Setter}
*/
@Preview
@Deprecated
public Setter set() {
return new Setter(this);
}
/**
* Delete this label from the repository.
*
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
root.createRequest().method("DELETE").setRawUrlPath(getUrl()).send();
}
@Override
public boolean equals(final Object o) {
if (this == o)
@@ -119,11 +214,54 @@ public class GHLabel {
return false;
final GHLabel ghLabel = (GHLabel) o;
return Objects.equals(url, ghLabel.url) && Objects.equals(name, ghLabel.name)
&& Objects.equals(color, ghLabel.color) && Objects.equals(repo, ghLabel.repo);
&& Objects.equals(color, ghLabel.color) && Objects.equals(description, ghLabel.description);
}
@Override
public int hashCode() {
return Objects.hash(url, name, color, repo);
return Objects.hash(url, name, color, description);
}
/**
* A {@link GHLabelBuilder} that updates a single property per request
*
* {@link #done()} is called automatically after the property is set.
*/
@Preview
@Deprecated
public static class Setter extends GHLabelBuilder<GHLabel> {
private Setter(@Nonnull GHLabel base) {
super(GHLabel.class, base.getApiRoot(), base);
requester.method("PATCH").setRawUrlPath(base.getUrl());
}
}
/**
* A {@link GHLabelBuilder} that allows multiple properties to be updated per request.
*
* Consumer must call {@link #done()} to commit changes.
*/
@Preview
@Deprecated
public static class Updater extends GHLabelBuilder<Updater> {
private Updater(@Nonnull GHLabel base) {
super(Updater.class, base.getApiRoot(), base);
requester.method("PATCH").setRawUrlPath(base.getUrl());
}
}
/**
* A {@link GHLabelBuilder} that creates a new {@link GHLabel}
*
* Consumer must call {@link #done()} to create the new instance.
*/
@Preview
@Deprecated
public static class Creator extends GHLabelBuilder<Creator> {
private Creator(@Nonnull GHRepository repository) {
super(Creator.class, repository.root, null);
requester.method("POST").withUrlPath(repository.getApiTailUrl("labels"));
}
}
}

View File

@@ -0,0 +1,60 @@
package org.kohsuke.github;
import java.io.IOException;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
/**
*
* @param <S>
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S}
* the same as {@link GHLabel}, this builder will commit changes after each call to
* {@link #with(String, Object)}.
*/
class GHLabelBuilder<S> extends AbstractBuilder<GHLabel, S> {
/**
*
* @param intermediateReturnType
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If
* {@link S} the same as {@link GHLabel}, this builder will commit changes after each call to
* {@link #with(String, Object)}.
* @param root
* the GitHub instance to which updates will be sent
* @param baseInstance
* instance on which to base this builder. If {@code null} a new instance will be created.
*/
protected GHLabelBuilder(@Nonnull Class<S> intermediateReturnType,
@Nonnull GitHub root,
@CheckForNull GHLabel baseInstance) {
super(GHLabel.class, intermediateReturnType, root, baseInstance);
if (baseInstance != null) {
requester.with("name", baseInstance.getName());
requester.with("color", baseInstance.getColor());
requester.with("description", baseInstance.getDescription());
}
}
@Nonnull
@Preview
@Deprecated
public S name(String value) throws IOException {
return with("name", value);
}
@Nonnull
@Preview
@Deprecated
public S color(String value) throws IOException {
return with("color", value);
}
@Nonnull
@Preview
@Deprecated
public S description(String value) throws IOException {
return with("description", value);
}
}

View File

@@ -24,17 +24,18 @@
package org.kohsuke.github;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 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>
@@ -77,14 +78,6 @@ public class GHLicense extends GHObject {
return name;
}
/**
* @return API URL of this object.
*/
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
public URL getUrl() {
return GitHubClient.parseURL(url);
}
/**
* Featured licenses are bold in the new repository drop-down
*
@@ -198,7 +191,14 @@ public class GHLicense extends GHObject {
if (description != null)
return; // already populated
root.createRequest().withUrlPath(url).fetchInto(this);
if (root == null || root.isOffline()) {
return; // cannot populate, will have to live with what we have
}
URL url = getUrl();
if (url != null) {
root.createRequest().setRawUrlPath(url.toString()).fetchInto(this);
}
}
@Override
@@ -209,12 +209,12 @@ public class GHLicense extends GHObject {
return false;
GHLicense that = (GHLicense) o;
return this.url.equals(that.url);
return Objects.equals(getUrl(), that.getUrl());
}
@Override
public int hashCode() {
return url.hashCode();
return Objects.hashCode(getUrl());
}
GHLicense wrap(GitHub root) {

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;
@@ -23,16 +24,31 @@ public abstract class GHObject {
/**
* Capture response HTTP headers on the state object.
*/
protected Map<String, List<String>> responseHeaderFields;
protected transient Map<String, List<String>> responseHeaderFields;
protected String url;
protected long id;
protected String created_at;
protected String updated_at;
private String url;
private long id;
private String nodeId;
private String createdAt;
private String updatedAt;
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.
*
@@ -60,12 +76,12 @@ public abstract class GHObject {
*/
@WithBridgeMethods(value = String.class, adapterMethod = "createdAtStr")
public Date getCreatedAt() throws IOException {
return GitHubClient.parseDate(created_at);
return GitHubClient.parseDate(createdAt);
}
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getCreatedAt")
private Object createdAtStr(Date id, Class type) {
return created_at;
return createdAt;
}
/**
@@ -96,7 +112,18 @@ public abstract class GHObject {
* on error
*/
public Date getUpdatedAt() throws IOException {
return GitHubClient.parseDate(updated_at);
return GitHubClient.parseDate(updatedAt);
}
/**
* Get Global node_id from Github object.
*
* @see <a href="https://developer.github.com/v4/guides/using-global-node-ids/">Using Global Node IDs</a>
*
* @return Global Node ID.
*/
public String getNodeId() {
return nodeId;
}
/**

View File

@@ -22,6 +22,6 @@ class GHOrgHook extends GHHook {
@Override
String getApiRoute() {
return String.format("/orgs/%s/hooks/%d", organization.getLogin(), id);
return String.format("/orgs/%s/hooks/%d", organization.getLogin(), getId());
}
}

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,
@@ -124,6 +128,40 @@ public class GHOrganization extends GHPerson {
.toIterable(GHTeam[].class, item -> item.wrapUp(this));
}
/**
* Gets a single team by ID.
*
* @param teamId
* id of the team that we want to query for
* @return the team
* @throws IOException
* the io exception
*
* @deprecated Use {@link GHOrganization#getTeam(long)}
*/
@Deprecated
public GHTeam getTeam(int teamId) throws IOException {
return getTeam((long) teamId);
}
/**
* Gets a single team by ID.
*
* @param teamId
* id of the team that we want to query for
* @return the team
* @throws IOException
* the io exception
*
* @see <a href= "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
*/
public GHTeam getTeam(long teamId) throws IOException {
return root.createRequest()
.withUrlPath(String.format("/organizations/%d/team/%d", getId(), teamId))
.fetch(GHTeam.class)
.wrapUp(this);
}
/**
* Finds a team that has the given name in its {@link GHTeam#getName()}
*
@@ -143,19 +181,19 @@ public class GHOrganization extends GHPerson {
/**
* Finds a team that has the given slug in its {@link GHTeam#getSlug()}
*
*
* @param slug
* the slug
* @return the team by slug
* @throws IOException
* the io exception
* @see <a href= "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
*/
public GHTeam getTeamBySlug(String slug) throws IOException {
for (GHTeam t : listTeams()) {
if (t.getSlug().equals(slug))
return t;
}
return null;
return root.createRequest()
.withUrlPath(String.format("/orgs/%s/teams/%s", login, slug))
.fetch(GHTeam.class)
.wrapUp(this);
}
/**
@@ -253,7 +291,7 @@ public class GHOrganization extends GHPerson {
* @deprecated use {@link #listMembers()}
*/
public List<GHUser> getMembers() throws IOException {
return listMembers().asList();
return listMembers().toList();
}
/**
@@ -279,7 +317,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 +330,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;
@@ -44,13 +46,16 @@ public abstract class GHPerson extends GHObject {
* the io exception
*/
protected synchronized void populate() throws IOException {
if (created_at != null) {
if (super.getCreatedAt() != null) {
return; // already populated
}
if (root == null || root.isOffline()) {
return; // cannot populate, will have to live with what we have
}
root.createRequest().withUrlPath(url).fetchInto(this);
URL url = getUrl();
if (url != null) {
root.createRequest().setRawUrlPath(url.toString()).fetchInto(this);
}
}
/**
@@ -114,29 +119,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 +178,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 {
@@ -41,7 +42,6 @@ public class GHProject extends GHObject {
private String owner_url;
private String html_url;
private String node_id;
private String name;
private String body;
private int number;
@@ -104,10 +104,12 @@ public class GHProject extends GHObject {
/**
* Gets node id.
*
* @deprecated Use {@link GHObject#getNodeId()}
* @return the node id
*/
@Deprecated
public String getNode_id() {
return node_id;
return getNodeId();
}
/**
@@ -190,7 +192,7 @@ public class GHProject extends GHObject {
* @return the api route
*/
protected String getApiRoute() {
return "/projects/" + id;
return "/projects/" + getId();
}
/**
@@ -289,7 +291,7 @@ public class GHProject extends GHObject {
final GHProject project = this;
return root.createRequest()
.withPreview(INERTIA)
.withUrlPath(String.format("/projects/%d/columns", id))
.withUrlPath(String.format("/projects/%d/columns", getId()))
.toIterable(GHProjectColumn[].class, item -> item.wrap(project));
}
@@ -307,7 +309,7 @@ public class GHProject extends GHObject {
.method("POST")
.withPreview(INERTIA)
.with("name", name)
.withUrlPath(String.format("/projects/%d/columns", id))
.withUrlPath(String.format("/projects/%d/columns", getId()))
.fetch(GHProjectColumn.class)
.wrap(this);
}

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;
@@ -211,7 +213,7 @@ public class GHProjectCard extends GHObject {
* @return the api route
*/
protected String getApiRoute() {
return String.format("/projects/columns/cards/%d", id);
return String.format("/projects/columns/cards/%d", getId());
}
/**

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;
@@ -113,7 +115,7 @@ public class GHProjectColumn extends GHObject {
* @return the api route
*/
protected String getApiRoute() {
return String.format("/projects/columns/%d", id);
return String.format("/projects/columns/%d", getId());
}
/**
@@ -137,7 +139,7 @@ public class GHProjectColumn extends GHObject {
final GHProjectColumn column = this;
return root.createRequest()
.withPreview(INERTIA)
.withUrlPath(String.format("/projects/columns/%d/cards", id))
.withUrlPath(String.format("/projects/columns/%d/cards", getId()))
.toIterable(GHProjectCard[].class, item -> item.wrap(column));
}
@@ -155,7 +157,7 @@ public class GHProjectColumn extends GHObject {
.method("POST")
.withPreview(INERTIA)
.with("note", note)
.withUrlPath(String.format("/projects/columns/%d/cards", id))
.withUrlPath(String.format("/projects/columns/%d/cards", getId()))
.fetch(GHProjectCard.class)
.wrap(this);
}
@@ -175,7 +177,7 @@ public class GHProjectColumn extends GHObject {
.withPreview(INERTIA)
.with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue")
.with("content_id", issue.getId())
.withUrlPath(String.format("/projects/columns/%d/cards", id))
.withUrlPath(String.format("/projects/columns/%d/cards", getId()))
.fetch(GHProjectCard.class)
.wrap(this);
}

View File

@@ -33,6 +33,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckForNull;
@@ -41,6 +42,7 @@ import static org.kohsuke.github.Previews.SHADOW_CAT;
/**
* A pull request.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#getPullRequest(int) GHRepository#getPullRequest(int)
*/
@SuppressWarnings({ "UnusedDeclaration" })
@@ -102,7 +104,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
protected String getApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
return StringUtils.prependIfMissing(url.toString().replace(root.getApiUrl(), ""), "/");
}
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/pulls/" + number;
}
@@ -386,10 +390,14 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* Repopulates this object.
*/
public void refresh() throws IOException {
if (root.isOffline()) {
if (root == null || root.isOffline()) {
return; // cannot populate, will have to live with what we have
}
root.createRequest().withPreview(SHADOW_CAT).withUrlPath(url).fetchInto(this).wrapUp(owner);
URL url = getUrl();
if (url != null) {
root.createRequest().withPreview(SHADOW_CAT).setRawUrlPath(url.toString()).fetchInto(this).wrapUp(owner);
}
}
/**
@@ -452,6 +460,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 +481,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

@@ -111,7 +111,7 @@ public class GHPullRequestReview extends GHObject {
* @return the api route
*/
protected String getApiRoute() {
return owner.getApiRoute() + "/reviews/" + id;
return owner.getApiRoute() + "/reviews/" + getId();
}
/**
@@ -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)
@@ -43,6 +44,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
private String body;
private GHUser user;
private String path;
private String html_url;
private int position = -1;
private int original_position = -1;
private long in_reply_to_id = -1L;
@@ -59,6 +61,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;
@@ -141,7 +144,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
@Override
public URL getHtmlUrl() {
return null;
return GitHubClient.parseURL(html_url);
}
/**
@@ -150,7 +153,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
* @return the api route
*/
protected String getApiRoute() {
return "/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + id;
return "/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + getId();
}
/**

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
@@ -57,6 +58,6 @@ public class GHReaction extends GHObject {
* the io exception
*/
public void delete() throws IOException {
root.createRequest().method("DELETE").withPreview(SQUIRREL_GIRL).withUrlPath("/reactions/" + id).send();
root.createRequest().method("DELETE").withPreview(SQUIRREL_GIRL).withUrlPath("/reactions/" + getId()).send();
}
}

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();
}
/**
@@ -269,7 +270,7 @@ public class GHRelease extends GHObject {
* the io exception
*/
public void delete() throws IOException {
root.createRequest().method("DELETE").withUrlPath(owner.getApiTailUrl("releases/" + id)).send();
root.createRequest().method("DELETE").withUrlPath(owner.getApiTailUrl("releases/" + getId())).send();
}
/**
@@ -282,6 +283,6 @@ public class GHRelease extends GHObject {
}
private String getApiTailUrl(String end) {
return owner.getApiTailUrl(format("releases/%s/%s", id, end));
return owner.getApiTailUrl(format("releases/%s/%s", getId(), end));
}
}

View File

@@ -5,6 +5,7 @@ import java.io.IOException;
/**
* Modifies {@link GHRelease}.
*
* @author Kohsuke Kawaguchi
* @see GHRelease#update() GHRelease#update()
*/
public class GHReleaseUpdater {
@@ -99,7 +100,7 @@ public class GHReleaseUpdater {
*/
public GHRelease update() throws IOException {
return builder.method("PATCH")
.withUrlPath(base.owner.getApiTailUrl("releases/" + base.id))
.withUrlPath(base.owner.getApiTailUrl("releases/" + base.getId()))
.fetch(GHRelease.class)
.wrap(base.owner);
}

View File

@@ -18,6 +18,6 @@ class GHRepoHook extends GHHook {
@Override
String getApiRoute() {
return String.format("/repos/%s/%s/hooks/%d", repository.getOwnerName(), repository.getName(), id);
return String.format("/repos/%s/%s/hooks/%d", repository.getOwnerName(), repository.getName(), getId());
}
}

View File

@@ -24,6 +24,7 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonParseException;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
@@ -39,7 +40,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;
@@ -48,6 +48,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.WeakHashMap;
@@ -57,14 +58,16 @@ 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" },
justification = "JSON API")
public class GHRepository extends GHObject {
/* package almost final */ GitHub root;
/* package almost final */ transient GitHub root;
private String description, homepage, name, full_name;
private String nodeId, description, homepage, name, full_name;
private String html_url; // this is the UI
/*
* The license information makes use of the preview API.
@@ -75,12 +78,14 @@ public class GHRepository extends GHObject {
private String git_url, ssh_url, clone_url, svn_url, mirror_url;
private GHUser owner; // not fully populated. beware.
private boolean has_issues, has_wiki, fork, has_downloads, has_pages, archived;
private boolean has_issues, has_wiki, fork, has_downloads, has_pages, archived, has_projects;
private boolean allow_squash_merge;
private boolean allow_merge_commit;
private boolean allow_rebase_merge;
private boolean delete_branch_on_merge;
@JsonProperty("private")
private boolean _private;
private int forks_count, stargazers_count, watchers_count, size, open_issues_count, subscribers_count;
@@ -116,6 +121,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 +177,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);
@@ -180,6 +187,15 @@ public class GHRepository extends GHObject {
boolean pull, push, admin;
}
/**
* Gets node id
*
* @return the node id
*/
public String getNodeId() {
return nodeId;
}
/**
* Gets description.
*
@@ -222,6 +238,7 @@ public class GHRepository extends GHObject {
* @return the string
* @deprecated Typo of {@link #getHttpTransportUrl()}
*/
@Deprecated
public String gitHttpTransportUrl() {
return clone_url;
}
@@ -358,7 +375,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 +393,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 +454,7 @@ public class GHRepository extends GHObject {
* @deprecated use {@link #listReleases()}
*/
public List<GHRelease> getReleases() throws IOException {
return listReleases().asList();
return listReleases().toList();
}
/**
@@ -551,6 +569,15 @@ public class GHRepository extends GHObject {
return has_issues;
}
/**
* Has projects boolean.
*
* @return the boolean
*/
public boolean hasProjects() {
return has_projects;
}
/**
* Has wiki boolean.
*
@@ -605,13 +632,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 +703,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 +728,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 +761,7 @@ public class GHRepository extends GHObject {
* @return the master branch
* @deprecated Renamed to {@link #getDefaultBranch()}
*/
@Deprecated
public String getMasterBranch() {
return default_branch;
}
@@ -734,7 +784,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 +834,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 +883,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();
}
/**
@@ -964,6 +1019,18 @@ public class GHRepository extends GHObject {
edit("has_issues", String.valueOf(v));
}
/**
* Enables or disables projects for this repository.
*
* @param v
* the v
* @throws IOException
* the io exception
*/
public void enableProjects(boolean v) throws IOException {
edit("has_projects", String.valueOf(v));
}
/**
* Enables or disables Wiki for this repository.
*
@@ -1084,6 +1151,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 +1317,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 +1328,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 +1529,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 +1554,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();
}
/**
@@ -1491,6 +1567,9 @@ public class GHRepository extends GHObject {
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
*/
public PagedIterable<GHRef> listRefs(String refType) throws IOException {
if (refType.startsWith("refs/")) {
refType = refType.replaceFirst("refs/", "");
}
final String url = String.format("/repos/%s/%s/git/refs/%s", getOwnerName(), name, refType);
return root.createRequest().withUrlPath(url).toIterable(GHRef[].class, item -> item.wrap(root));
}
@@ -1505,8 +1584,13 @@ public class GHRepository extends GHObject {
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
*/
public GHRef getRef(String refName) throws IOException {
// Also accept e.g. "refs/heads/branch" for consistency with createRef().
if (refName.startsWith("refs/")) {
refName = refName.replaceFirst("refs/", "");
}
return root.createRequest()
.withUrlPath(getApiTailUrl(String.format("git/refs/%s", refName)))
.withUrlPath(getApiTailUrl(String.format("git/ref/%s", refName)))
.fetch(GHRef.class)
.wrap(root);
}
@@ -1712,7 +1796,7 @@ public class GHRepository extends GHObject {
}
/**
* /** Lists all the commit statues attached to the given commit, newer ones first.
* /** Lists all the commit statuses attached to the given commit, newer ones first.
*
* @param sha1
* the sha 1
@@ -1736,10 +1820,31 @@ 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);
}
/**
* Gets check runs for given ref.
*
* @param ref
* ref
* @return check runs for given ref
* @throws IOException
* the io exception
* @see <a href="https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref">List check runs
* for a specific ref</a>
*/
@Preview
@Deprecated
public PagedIterable<GHCheckRun> getCheckRuns(String ref) throws IOException {
GitHubRequest request = root.createRequest()
.withUrlPath(String.format("/repos/%s/%s/commits/%s/check-runs", getOwnerName(), name, ref))
.withPreview(ANTIOPE)
.build();
return new GHCheckRunsIterable(root, request);
}
/**
* Creates a commit status
*
@@ -1795,6 +1900,21 @@ public class GHRepository extends GHObject {
return createCommitStatus(sha1, state, targetUrl, description, null);
}
/**
* Creates a check run for a commit.
*
* @param name
* an identifier for the run
* @param headSHA
* the commit hash
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
*/
@Preview
@Deprecated
public @NonNull GHCheckRunBuilder createCheckRun(@NonNull String name, @NonNull String headSHA) {
return new GHCheckRunBuilder(this, name, headSHA);
}
/**
* Lists repository events.
*
@@ -1818,9 +1938,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public PagedIterable<GHLabel> listLabels() throws IOException {
return root.createRequest()
.withUrlPath(getApiTailUrl("labels"))
.toIterable(GHLabel[].class, item -> item.wrapUp(this));
return GHLabel.readAll(this);
}
/**
@@ -1833,7 +1951,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public GHLabel getLabel(String name) throws IOException {
return root.createRequest().withUrlPath(getApiTailUrl("labels/" + name)).fetch(GHLabel.class).wrapUp(this);
return GHLabel.read(this, name);
}
/**
@@ -1848,7 +1966,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public GHLabel createLabel(String name, String color) throws IOException {
return createLabel(name, color, "");
return GHLabel.create(this).name(name).color(color).description("").done();
}
/**
@@ -1865,14 +1983,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public GHLabel createLabel(String name, String color, String description) throws IOException {
return root.createRequest()
.method("POST")
.with("name", name)
.with("color", color)
.with("description", description)
.withUrlPath(getApiTailUrl("labels"))
.fetch(GHLabel.class)
.wrapUp(this);
return GHLabel.create(this).name(name).color(color).description(description).done();
}
/**
@@ -1975,14 +2086,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 +2095,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 +2109,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")));
@@ -2056,9 +2160,15 @@ public class GHRepository extends GHObject {
GHRepository wrap(GitHub root) {
this.root = root;
if (root.isOffline()) {
if (root.isOffline() && owner != null) {
owner.wrapUp(root);
}
if (source != null) {
source.wrap(root);
}
if (parent != null) {
parent.wrap(root);
}
return this;
}
@@ -2071,8 +2181,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 +2315,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 +2472,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();
}
/**
@@ -2378,10 +2488,13 @@ public class GHRepository extends GHObject {
* @see #getParent() #getParent()
*/
public GHRepository getSource() throws IOException {
if (source == null)
if (fork && source == null) {
populate();
}
if (source == null) {
return null;
if (source.root == null)
source = root.getRepository(source.getFullName());
}
return source;
}
@@ -2396,10 +2509,13 @@ public class GHRepository extends GHObject {
* @see #getSource() #getSource()
*/
public GHRepository getParent() throws IOException {
if (parent == null)
if (fork && parent == null) {
populate();
}
if (parent == null) {
return null;
if (parent.root == null)
parent = root.getRepository(parent.getFullName());
}
return parent;
}
@@ -2718,4 +2834,31 @@ public class GHRepository extends GHObject {
.fetch(GHTagObject.class)
.wrap(this);
}
/**
* Populate this object.
*
* @throws java.io.IOException
* The IO exception
*/
void populate() throws IOException {
if (root.isOffline())
return; // can't populate if the root is offline
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
try {
// IMPORTANT: the url for repository records is does not reliably point to the API url.
// There is bug in Push event payloads that returns the wrong url.
// All other occurrences of "url" take the form "https://api.github.com/...".
// For Push event repository records, they take the form "https://github.com/{fullName}".
root.createRequest().setRawUrlPath(url.toString()).fetchInto(this).wrap(root);
} catch (HttpException e) {
if (e.getCause() instanceof JsonParseException) {
root.createRequest().withUrlPath("/repos/" + full_name).fetchInto(this).wrap(root);
} else {
throw e;
}
}
}
}

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