Compare commits

...

782 Commits

Author SHA1 Message Date
Liam Newman
349ef7a54c [maven-release-plugin] prepare release github-api-1.116 2020-08-12 18:47:42 -07:00
Liam Newman
94df5fc389 Merge pull request #923 from bitwiseman/feature/is-template
Added GHRepository.isTemplate() method
2020-08-12 18:43:07 -07:00
Liam Newman
906238a297 Add GHRepository.isTemplate() 2020-08-12 18:28:18 -07:00
Liam Newman
7963fa82b5 Ensure withPreview can be called multiple times 2020-08-12 18:27:48 -07:00
Liam Newman
1aba6012fb Centralize GHRepository read 2020-08-12 18:21:44 -07:00
Liam Newman
ff4324ac67 Merge pull request #897 from bonnie-young/add-create-repo-with-template-support
add create repo with template support
2020-08-12 08:43:17 -07:00
Yang Ting
11bc669e1d update code for create repository from template
Signed-off-by: Yang Ting <bonnie.young@maxwit.com>
2020-08-12 22:08:31 +08:00
Liam Newman
dcf26d58e4 Merge pull request #919 from bitwiseman/task/one-more-date
Fixed and streamlined date parsing
2020-08-07 16:42:49 -07:00
Liam Newman
4d46872c35 Fixed and streamlined date parsing
Fixes #917
2020-08-07 16:36:23 -07:00
Liam Newman
4f0d62f421 Merge pull request #920 from ewiegs4/deployment-payload
Support for object deployment payloads
2020-08-07 16:35:54 -07:00
Eddie Wiegers
f7ad1f517b formatting 2020-08-07 17:46:33 -05:00
Eddie Wiegers
345d6197f3 Support for object deployment payloads. 2020-08-07 17:36:28 -05:00
Liam Newman
bb4d44138a Merge branch 'master' into add-create-repo-with-template-support 2020-08-04 16:05:02 -07:00
Liam Newman
a8ef0cde53 Merge pull request #913 from hub4j/dependabot/maven/spotbugs.version-4.1.1
Chore(deps): Bump spotbugs.version from 4.0.6 to 4.1.1
2020-08-03 10:58:51 -07:00
dependabot[bot]
77dc009c95 Chore(deps): Bump spotbugs.version from 4.0.6 to 4.1.1
Bumps `spotbugs.version` from 4.0.6 to 4.1.1.

Updates `spotbugs` from 4.0.6 to 4.1.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.6...4.1.1)

Updates `spotbugs-annotations` from 4.0.6 to 4.1.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.6...4.1.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-08-03 02:00:46 +00:00
Liam Newman
aa298c93cc Merge pull request #911 from bitwiseman/task/workflow-run
Add GHEvent.WORKFLOW_RUN
2020-08-02 08:27:02 -07:00
Liam Newman
dfb0a5240e Merge pull request #909 from JKalash/jkalash/master
GHCheckRun.getPullRequests public
2020-07-31 16:06:17 -07:00
Liam Newman
9cfc3c22b5 Add GHEvent.WORKFLOW_RUN 2020-07-31 16:03:34 -07:00
Liam Newman
b177d98e29 Populate Check pull requests
Turns out there were quite a few bugs in this area (it was exposed publicly before. Some
tweaking was needed and updates to the tests to show this working as expected.
2020-07-31 15:57:17 -07:00
Joe
5405fb0370 return unmodifiable list 2020-07-30 21:48:42 +01:00
Joe
72a1c24b3b format 2020-07-30 21:43:37 +01:00
Joe
f146ae94ec return iterable 2020-07-30 21:41:16 +01:00
Joe
a0bbba748a check suite exposes pull requests 2020-07-30 20:10:44 +01:00
Joe
81bf818573 pullRequests returns iterable 2020-07-30 20:01:44 +01:00
Joe
d5913dc292 fix array exposure 2020-07-30 15:25:35 +01:00
Joe Kalash
e1e901b794 Merge branch 'master' into jkalash/master 2020-07-30 14:01:01 +01:00
Joe
2f2f26767e make getPullRequests public 2020-07-30 13:59:36 +01:00
Liam Newman
bffa78c1b8 Merge pull request #907 from hub4j/dependabot/maven/org.mockito-mockito-core-3.4.6
Chore(deps-dev): Bump mockito-core from 3.4.4 to 3.4.6
2020-07-29 20:11:55 -07:00
dependabot[bot]
c55719c67a Chore(deps-dev): Bump mockito-core from 3.4.4 to 3.4.6
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.4.4 to 3.4.6.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.4.4...v3.4.6)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-30 02:00:49 +00:00
Liam Newman
cb3b4a6642 Merge pull request #906 from JKalash/jkalash/master
Merge arbitrary branches
2020-07-28 16:37:40 -07:00
Liam Newman
92c141cee6 Add support for string head
Also support all changes already merged.
2020-07-28 12:57:31 -07:00
Liam Newman
fd1a1a1c23 Simplified tests 2020-07-28 11:22:07 -07:00
Joe
b835884b2e fix test 2020-07-28 14:37:50 +01:00
Joe
660763908d test refactor 2020-07-28 14:24:35 +01:00
Joe
fe8bdb755a Merge branches method 2020-07-28 12:41:31 +01:00
Liam Newman
67dc6d2d23 Merge pull request #904 from Javaru/add-missing-org-permissions
Added MAINTAIN and TRIAGE to GHOrganization.Permission enum
2020-07-27 21:27:27 -07:00
Mark Vedder
9c8d73cbe2 Merge branch 'master' into add-missing-org-permissions 2020-07-27 18:54:32 -04:00
Liam Newman
5db97d92dd Merge pull request #899 from gastaldi/set_milestone
PullRequest.setMilestone should use the Issue API
2020-07-27 14:18:05 -07:00
Liam Newman
ac470dddb5 Merge branch 'master' into add-create-repo-with-template-support 2020-07-27 14:14:16 -07:00
Liam Newman
43063fe8ce Minor tweaks 2020-07-27 14:12:15 -07:00
George Gastaldi
59e0046c1e Validate argument in GitHub.getRepository
This avoids the ArrayIndexOutOfBoundsException when the argument format is invalid
2020-07-27 17:47:56 -03:00
George Gastaldi
36ab05c265 PullRequest.setMilestone should use the Issue API 2020-07-27 17:47:56 -03:00
Liam Newman
2b2be05dae Merge pull request #900 from gastaldi/repo_fix
Fixes modifyCollaborators for multiple users
2020-07-27 13:23:06 -07:00
Liam Newman
fb1adbd1ef Make withUrlPath() overwrite instead of append
I had some ideas about having multiple calls to  apend to build up paths,
but it turns out that idea is pretty bad.  `with*()` methods should
overwrite when called for the same field.

If we want to create and , we can do that later.
2020-07-27 13:12:46 -07:00
Javaru
ab68a59b25 Added MAINTAIN and TRIAGE to GHOrganization.Permission enum 2020-07-27 15:50:32 -04:00
George Gastaldi
9c7de767e9 Fixes modifyCollaborators for multiple users
Fixes #868
2020-07-27 12:37:34 -07:00
George Gastaldi
8ba5cf7c2e Formatting tweaks and fixes 2020-07-27 12:31:09 -07:00
Bonnie Young
b194a19b98 Merge branch 'master' into add-create-repo-with-template-support 2020-07-21 00:32:52 +08:00
Liam Newman
1d344b016f Merge pull request #898 from hub4j/dependabot/maven/org.mockito-mockito-core-3.4.4
Chore(deps-dev): Bump mockito-core from 3.4.2 to 3.4.4
2020-07-20 00:35:58 -07:00
dependabot[bot]
474f3ef4ca Chore(deps-dev): Bump mockito-core from 3.4.2 to 3.4.4
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.4.2 to 3.4.4.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.4.2...v3.4.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-20 02:00:54 +00:00
Yang Ting
9830927020 add create repo with template support
Signed-off-by: Yang Ting <bonnie.young@maxwit.com>
2020-07-19 23:07:19 +08:00
Liam Newman
727932a442 Merge pull request #895 from jeetchoudhary/protection
GHBranch getProtection method to return correct number of reviewers #890
2020-07-17 12:27:05 -07:00
jeetchoudhary
cd92b51845 Merge branch 'master' into protection 2020-07-17 23:59:51 +05:30
Liam Newman
fe26d16411 Update test and data to verify getProtection() code path
The create and get code paths are different.  Both need testing.
2020-07-17 10:50:54 -07:00
Liam Newman
d68c66ce2b Merge pull request #893 from hub4j/dependabot/maven/org.mockito-mockito-core-3.4.2
Chore(deps-dev): Bump mockito-core from 3.4.0 to 3.4.2
2020-07-17 09:59:31 -07:00
Jitender kumar
e7bfbfb48f reformat class 2020-07-17 17:28:15 +05:30
jeetchoudhary
f2a88ae61c fixing getRequiredReviewers to return count #890 2020-07-17 16:55:51 +05:30
jeetchoudhary
e2113f6ee5 Update rest request for test case 2020-07-17 16:52:17 +05:30
dependabot[bot]
3867224024 Chore(deps-dev): Bump mockito-core from 3.4.0 to 3.4.2
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.4.0 to 3.4.2.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.4.0...v3.4.2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-17 02:01:30 +00:00
Liam Newman
9ee0bf43bc [maven-release-plugin] prepare for next development iteration 2020-07-16 15:16:56 -07:00
Liam Newman
2844542efa [maven-release-plugin] prepare release github-api-1.115 2020-07-16 15:16:47 -07:00
Liam Newman
e3fcae9392 Revert "Remove Java 15-ea"
This reverts commit c6ccfa91f3.
2020-07-15 15:32:46 -07:00
Liam Newman
c6ccfa91f3 Remove Java 15-ea
It is unclear exactly why this started failing but we're not interested figuring this out.
2020-07-15 15:19:06 -07:00
Liam Newman
b6fcee1cb9 Rollback to surefire 2.22.2 2020-07-15 15:14:16 -07:00
Liam Newman
9071befb04 Run slow or flaky tests in test phase 2020-07-15 15:05:26 -07:00
Liam Newman
bdd5fe98f3 Use file to specify slow-or-flaky-tests list 2020-07-15 15:00:03 -07:00
Liam Newman
a3d3e83a49 Move slow or flaky tests to separate surefire execution
This lets us have most tests run immediately and with no retries and then have slower tests that may be flaky run later with retries.
2020-07-15 14:45:32 -07:00
Liam Newman
08bde72028 Merge pull request #849 from alexanderkjall/add-support-for-child-teams
Added support for fetching what teams are part of this team.
2020-07-15 14:05:47 -07:00
Liam Newman
108a136368 Remove getChildTeams and add test for no children 2020-07-15 13:46:11 -07:00
Liam Newman
57d87ad6b1 Merge branch 'master' into add-support-for-child-teams 2020-07-15 13:28:32 -07:00
Liam Newman
0c22815ff7 Merge pull request #872 from MarcosCela/doc/org-level-resources
Add documentation for organization-level resources
2020-07-15 13:27:05 -07:00
Liam Newman
0ca792ecfd Merge pull request #830 from bitwiseman/task/rate-limit/full
Handle header and endpoint rate limit responses consistently
2020-07-15 12:42:11 -07:00
Liam Newman
987c34c69e Merge branch 'master' into task/rate-limit/full 2020-07-15 12:13:16 -07:00
Liam Newman
c1c02bc8ab Merge pull request #887 from hub4j/dependabot/maven/org.mockito-mockito-core-3.4.0
Chore(deps-dev): Bump mockito-core from 3.3.3 to 3.4.0
2020-07-14 12:02:54 -07:00
dependabot[bot]
4ee369f27c Chore(deps-dev): Bump mockito-core from 3.3.3 to 3.4.0
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.3.3 to 3.4.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.3.3...v3.4.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-13 15:52:33 +00:00
Liam Newman
c9012efdcb Merge pull request #886 from hub4j/dependabot/maven/net.revelc.code.formatter-formatter-maven-plugin-2.12.1
Chore(deps): Bump formatter-maven-plugin from 2.12.0 to 2.12.1
2020-07-13 08:51:51 -07:00
dependabot[bot]
41524fc67d Chore(deps): Bump formatter-maven-plugin from 2.12.0 to 2.12.1
Bumps [formatter-maven-plugin](https://github.com/revelc/formatter-maven-plugin) from 2.12.0 to 2.12.1.
- [Release notes](https://github.com/revelc/formatter-maven-plugin/releases)
- [Changelog](https://github.com/revelc/formatter-maven-plugin/blob/formatter-maven-plugin-2.12.1/CHANGELOG.md)
- [Commits](https://github.com/revelc/formatter-maven-plugin/compare/formatter-maven-plugin-2.12.0...formatter-maven-plugin-2.12.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-13 02:00:47 +00:00
Liam Newman
04ff61e981 Merge pull request #885 from XiongKezhi/add-missing-conclusion
Add the missing SKIPPED check run conclusion
2020-07-12 14:11:56 -07:00
Liam Newman
532468dc67 Update src/main/java/org/kohsuke/github/GHCheckRun.java 2020-07-12 13:41:57 -07:00
Kezhi Xiong
9c9a2dae47 Add JavaDoc for check run conclusion 2020-07-12 15:58:34 +08:00
Kezhi Xiong
c8a868b57f Add the missing SKIPPED check run conclusion 2020-07-12 15:54:09 +08:00
Liam Newman
4b3f81ee34 Clean up comments and javadoc 2020-07-10 10:51:20 -07:00
Liam Newman
afa170ba7c Add more tests for rate limit record selection 2020-07-10 09:01:29 -07:00
Liam Newman
46e3b2272e Clean up and reorganize changes
Changed GitHubRateLimitSpecifier to RateLimitTarget
Made RateLimitTarget public so it can be passed to GitHubBuilder
2020-07-10 09:01:29 -07:00
Liam Newman
52472e90ec Simplified rate limit record selection
Here we have another example of trying to do something clever when simplicity is the better choice.
Rather than trying to guess the rate limit record for a request based on the url path,
I added an enumeration which can be set on the request to say which rate limit record to applies.

This is simpler, safer, and faster than trying to guess the rate limit from the url path.
2020-07-10 09:01:29 -07:00
Liam Newman
4ef0d00846 Integrate full rate limit checking 2020-07-10 09:01:29 -07:00
Liam Newman
580f2537f2 Move GHRef readers to GHRef class 2020-07-09 15:00:40 -07:00
Liam Newman
3d9fd96026 Merge pull request #884 from bitwiseman/task/gitbucket
Workaround for GitBucket refs issue
2020-07-09 13:38:55 -07:00
Liam Newman
f449b92721 Workaround for GitBucket refs issue
The bug that caused this has been fixed by GitBucket but may not be released for some time.
It was a change to this library that broke them, so to be nice we're fully working around it here.

That said, the GET /refs endpoint is deprecated and will be going away at some point.
We will be making a breaking change in this area again in the next few months. We'll need to raise
it to GitBucket to make sure they handle it proproperly.
2020-07-09 09:50:29 -07:00
Liam Newman
3b0216b023 Merge pull request #877 from hub4j/dependabot/maven/com.github.tomakehurst-wiremock-jre8-standalone-2.27.1
Chore(deps-dev): Bump wiremock-jre8-standalone from 2.26.3 to 2.27.1
2020-07-07 12:40:23 -07:00
Liam Newman
98cf839737 Add new methods 2020-07-07 12:29:59 -07:00
dependabot[bot]
0bb0846505 Chore(deps-dev): Bump wiremock-jre8-standalone from 2.26.3 to 2.27.1
Bumps [wiremock-jre8-standalone](https://github.com/tomakehurst/wiremock) from 2.26.3 to 2.27.1.
- [Release notes](https://github.com/tomakehurst/wiremock/releases)
- [Commits](https://github.com/tomakehurst/wiremock/compare/2.26.3...2.27.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-07 19:23:07 +00:00
Liam Newman
70969400a3 Merge pull request #876 from jtnord/symlink-support
Add minimal symlink support via GHContent.getTarget()
2020-07-07 12:21:39 -07:00
Liam Newman
147e8d5d12 Merge branch 'master' into symlink-support 2020-07-07 11:38:14 -07:00
Liam Newman
cacc3e6edd Update formatter cache directory 2020-07-07 10:15:00 -07:00
Liam Newman
a284eca147 Shorten file paths for windows 2020-07-07 09:48:31 -07:00
James Nord
0d3ba9d7f0 formatting fixes 2020-07-07 13:29:33 +01:00
Liam Newman
be8064d642 Merge pull request #879 from hub4j/dependabot/maven/org.codehaus.mojo-animal-sniffer-maven-plugin-1.19
Chore(deps): Bump animal-sniffer-maven-plugin from 1.18 to 1.19
2020-07-06 10:15:33 -07:00
dependabot[bot]
e30dba742d Chore(deps): Bump animal-sniffer-maven-plugin from 1.18 to 1.19
Bumps [animal-sniffer-maven-plugin](https://github.com/mojohaus/animal-sniffer) from 1.18 to 1.19.
- [Release notes](https://github.com/mojohaus/animal-sniffer/releases)
- [Commits](https://github.com/mojohaus/animal-sniffer/compare/animal-sniffer-parent-1.18...animal-sniffer-parent-1.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-06 02:01:00 +00:00
James Nord
44b72ed647 Add initial symlink support.
this adds rudimentary symlink support (just enough to get a symlink).

still todo, howto handle GHRepository.getFileContent where the path
contains a symlink within the repository
2020-07-02 17:18:20 +01:00
Liam Newman
666bd77dac Merge pull request #874 from hub4j/bitwiseman-patch-1
Add "workflow_dispatch" to GHEvent
2020-07-02 08:52:31 -07:00
Liam Newman
0a6613e60d Add "workflow_dispatch" to GHEvent
This event is undocumented at this time, but this change will stop the deserialization errors.

Fixes #854
2020-07-01 15:57:33 -07:00
Liam Newman
62e186c123 Merge pull request #871 from hub4j/dependabot/maven/net.revelc.code.formatter-formatter-maven-plugin-2.12.0
Chore(deps): Bump formatter-maven-plugin from 2.11.0 to 2.12.0
2020-06-30 11:02:37 -07:00
Marcos.Cela
50dd8f5bcc add a new doc section "Working with organizations" with a simple example
Closes #812
2020-06-30 09:44:57 +02:00
Marcos Cela
d5fcac9c45 Merge pull request #1 from hub4j/master
Update base
2020-06-30 08:44:42 +02:00
dependabot[bot]
c2bed85190 Chore(deps): Bump formatter-maven-plugin from 2.11.0 to 2.12.0
Bumps [formatter-maven-plugin](https://github.com/revelc/formatter-maven-plugin) from 2.11.0 to 2.12.0.
- [Release notes](https://github.com/revelc/formatter-maven-plugin/releases)
- [Changelog](https://github.com/revelc/formatter-maven-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/revelc/formatter-maven-plugin/compare/formatter-maven-plugin-2.11.0...formatter-maven-plugin-2.12.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-06-30 02:00:52 +00:00
Liam Newman
183b463ef2 Merge branch 'master' into add-support-for-child-teams 2020-06-29 09:58:14 -07:00
Liam Newman
92fdac44a0 Merge pull request #869 from hub4j/dependabot/maven/org.apache.maven.plugins-maven-site-plugin-3.9.1
Chore(deps): Bump maven-site-plugin from 3.9.0 to 3.9.1
2020-06-29 09:57:00 -07:00
dependabot[bot]
12829ecc73 Chore(deps): Bump maven-site-plugin from 3.9.0 to 3.9.1
Bumps [maven-site-plugin](https://github.com/apache/maven-site-plugin) from 3.9.0 to 3.9.1.
- [Release notes](https://github.com/apache/maven-site-plugin/releases)
- [Commits](https://github.com/apache/maven-site-plugin/compare/maven-site-plugin-3.9.0...maven-site-plugin-3.9.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-06-25 02:00:46 +00:00
Alexander Kjäll
51319c3b26 use this.organization instead of providing the organization as a parameter 2020-06-24 07:30:59 +02:00
Liam Newman
8fd827040b Merge pull request #860 from hub4j/dependabot/github_actions/actions/cache-v2
Chore(deps): Bump actions/cache from v1 to v2
2020-06-23 09:24:06 -07:00
dependabot[bot]
5ec46eae0d Chore(deps): Bump actions/cache from v1 to v2
Bumps [actions/cache](https://github.com/actions/cache) from v1 to v2.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v1...b8204782bbb5f872091ecc5eb9cb7d004e35b1fa)

Signed-off-by: dependabot[bot] <support@github.com>
2020-06-23 14:59:54 +00:00
Liam Newman
32c03301be Merge pull request #853 from sullis/add-dependabot
add Dependabot
2020-06-23 07:59:26 -07:00
Liam Newman
df7f29b2ab Merge pull request #858 from hub4j/dependabot/maven/spotbugs.version-4.0.6
Chore(deps): Bump spotbugs.version from 4.0.4 to 4.0.6
2020-06-23 07:55:48 -07:00
dependabot-preview[bot]
e863113c36 Chore(deps): Bump spotbugs.version from 4.0.4 to 4.0.6
Bumps `spotbugs.version` from 4.0.4 to 4.0.6.

Updates `spotbugs` from 4.0.4 to 4.0.6
- [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.4...4.0.6)

Updates `spotbugs-annotations` from 4.0.4 to 4.0.6
- [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.4...4.0.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-23 06:40:11 +00:00
Liam Newman
8e2c1d7382 Merge pull request #851 from MarcosCela/fix/ghteambuilder-accept-long
GHTeamBuilder#parentTeamId now accepts a long instead of an int
2020-06-22 06:28:20 -07:00
Liam Newman
ab7b9cccba Merge branch 'master' into fix/ghteambuilder-accept-long 2020-06-22 06:18:54 -07:00
Liam Newman
81bf61a161 Merge pull request #857 from hub4j/dependabot/maven/com.github.spotbugs-spotbugs-maven-plugin-4.0.4
Chore(deps): Bump spotbugs-maven-plugin from 4.0.0 to 4.0.4
2020-06-22 06:14:39 -07:00
dependabot-preview[bot]
b40f008647 Chore(deps): Bump spotbugs-maven-plugin from 4.0.0 to 4.0.4
Bumps [spotbugs-maven-plugin](https://github.com/spotbugs/spotbugs-maven-plugin) from 4.0.0 to 4.0.4.
- [Release notes](https://github.com/spotbugs/spotbugs-maven-plugin/releases)
- [Commits](https://github.com/spotbugs/spotbugs-maven-plugin/compare/spotbugs-maven-plugin-4.0.0...spotbugs-maven-plugin-4.0.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-22 06:57:13 +00:00
Sean C. Sullivan
734e41702b add Dependabot
https://github.blog/2020-06-01-keep-all-your-packages-up-to-date-with-dependabot/
2020-06-20 07:10:28 -07:00
Alexander Kjäll
038dd20a91 added a unit test for fetching a child team 2020-06-19 08:27:25 +02:00
Marcos.Cela
1dd62b8550 add a simple test for GHTeamBuilder: create a team with a parent/child relation
Additionally, ensure that when creating the team and setting the parentTeamId
on the GHTeamBuilder, we receive it directly from a previously retrieved
GHTeam. This ensures that the return type of GHTeam#getId() is compatible
with GHTeamBuilder#parentTeamId()
2020-06-18 10:33:04 +02:00
Marcos.Cela
715deebe05 GHTeamBuilder#parentTeamId now accepts a long instead of an int
Closes #850
2020-06-17 12:15:29 +02:00
Alexander Kjäll
b3fe3d8590 Added support for fetching what teams are part of this team.
The call is to this endpoint https://developer.github.com/v3/teams/#list-child-teams-legacy
2020-06-17 09:38:17 +02:00
Liam Newman
f74c3ed3ea Merge pull request #848 from hub4j/dependabot/maven/org.kohsuke.stapler-stapler-1.260
Chore(deps-dev): Bump stapler from 1.259 to 1.260
2020-06-16 08:39:53 -07:00
Liam Newman
2c9aebeeed Merge pull request #847 from hub4j/timja-patch-1
Fix tag template in release drafter
2020-06-16 08:34:54 -07:00
dependabot-preview[bot]
7474f1e11f Chore(deps-dev): Bump stapler from 1.259 to 1.260
Bumps [stapler](https://github.com/stapler/stapler) from 1.259 to 1.260.
- [Release notes](https://github.com/stapler/stapler/releases)
- [Changelog](https://github.com/stapler/stapler/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stapler/stapler/compare/stapler-parent-1.259...stapler-parent-1.260)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-16 06:28:21 +00:00
Tim Jacomb
dba9c55b64 Fix tag template in release drafter 2020-06-16 07:16:52 +01:00
Liam Newman
b432364397 [maven-release-plugin] prepare for next development iteration 2020-06-10 20:02:26 -07:00
Liam Newman
696967bdd1 [maven-release-plugin] prepare release github-api-1.114 2020-06-10 20:02:18 -07:00
Liam Newman
b76889efc3 Merge pull request #845 from bitwiseman/task/redo-822
Modify getRef() changes to be compatible with older GHE versions
2020-06-10 20:00:44 -07:00
Liam Newman
e6a7b64ebe Merge branch 'master' into task/redo-822 2020-06-10 19:53:42 -07:00
Liam Newman
9daa0df311 Modify getRef() changes to be compatible with older GHE versions
Fixes #844
    Fixes #794
2020-06-10 19:47:23 -07:00
Liam Newman
612800bda5 Merge pull request #843 from bitwiseman/task/body-close
[JENKINS-62655] Ensure connection response stream is always closed
2020-06-10 17:30:12 -07:00
Liam Newman
a6bbb1dec9 Ensure connection response stream is always closed 2020-06-10 17:22:25 -07:00
Liam Newman
873c93ab64 Merge pull request #841 from hub4j/dependabot/maven/org.apache.bcel-bcel-6.5.0
Chore(deps): Bump bcel from 6.4.1 to 6.5.0
2020-06-10 08:59:00 -07:00
dependabot-preview[bot]
d15242e2d2 Chore(deps): Bump bcel from 6.4.1 to 6.5.0
Bumps bcel from 6.4.1 to 6.5.0.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-10 03:50:37 +00:00
Liam Newman
992d2b937c Merge pull request #840 from hub4j/dependabot/maven/spotbugs.version-4.0.4
Chore(deps): Bump spotbugs.version from 4.0.3 to 4.0.4
2020-06-09 20:49:24 -07:00
dependabot-preview[bot]
1e05ddad4b Chore(deps): Bump spotbugs.version from 4.0.3 to 4.0.4
Bumps `spotbugs.version` from 4.0.3 to 4.0.4.

Updates `spotbugs` from 4.0.3 to 4.0.4
- [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.3...4.0.4)

Updates `spotbugs-annotations` from 4.0.3 to 4.0.4
- [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.3...4.0.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-09 06:33:50 +00:00
Liam Newman
4f8a64610b [maven-release-plugin] prepare for next development iteration 2020-06-08 14:37:20 -07:00
Liam Newman
b82366218c [maven-release-plugin] prepare release github-api-1.113 2020-06-08 14:37:11 -07:00
Liam Newman
acbe1f4cb3 Update PULL_REQUEST_TEMPLATE.md 2020-06-08 13:25:56 -07:00
Liam Newman
4c5e018583 Merge pull request #838 from Chew/feature/new-profile-data
Add bio, hireable, and twitter_username fields to Person
2020-06-08 12:21:16 -07:00
Liam Newman
6c0380e85c Merge pull request #839 from bitwiseman/issue-828
Add GitHub Team Discussions as GHDiscussion
2020-06-08 12:18:46 -07:00
Liam Newman
fde48e604f Test coverage and javadoc fixes 2020-06-08 12:06:39 -07:00
Liam Newman
e83a4de5fb Merge branch 'master' into feature/new-profile-data 2020-06-08 10:33:29 -07:00
Liam Newman
927d2799dc Move url construction to single method 2020-06-08 10:12:15 -07:00
Liam Newman
1ad701fe5d Add convenience override of getId() 2020-06-08 09:59:43 -07:00
Liam Newman
086425d2da Tweaks for batch update 2020-06-08 09:59:43 -07:00
Charles Moulliard
beca54416a Merge branch 'master' into issue-828 2020-06-08 18:43:15 +02:00
Chew
c92f5c5713 Update test value and add new test for Twitter Username 2020-06-07 15:05:02 -05:00
Chew
dee4e6caff Add twitter_username to Person and bio and hireable to User 2020-06-07 00:55:44 -05:00
Liam Newman
dd5a39e72e Improve wiremock stub accuracy 2020-06-06 16:29:26 -07:00
Charles Moulliard
e5ed52165c Fix: Add missing @param for the delete() method 2020-06-04 18:26:14 +02:00
Charles Moulliard
9484f8e0f5 Chore: Add more methods to test CRUD operations on discusions 2020-06-04 18:19:41 +02:00
Charles Moulliard
947caffe0a Chore: Add method to get a discussion using a number/id 2020-06-04 17:27:15 +02:00
Charles Moulliard
870090e8df Chore: Remove javadoc Throwing the exception for the GHDiscussionbuilder - update method 2020-06-04 13:51:04 +02:00
Charles Moulliard
73f07f13c5 Chore: Remove javadoc Throwing the exception 2020-06-04 13:47:41 +02:00
Charles Moulliard
d1952bf591 Chore: Reformat method 2020-06-04 13:37:08 +02:00
Charles Moulliard
5a612e1332 Chore: Add try/catch block if we cannot find the discussion to be updated 2020-06-04 13:25:57 +02:00
Charles Moulliard
b00a9faea6 Fix: Add missing parameter 2020-06-04 12:58:07 +02:00
Charles Moulliard
74db42a703 Chore: Add method to update a discussion 2020-06-04 12:52:58 +02:00
Charles Moulliard
ddf625ca04 Chore: Add method to delete a discussion using its number. Add field number 2020-06-04 12:20:36 +02:00
Charles Moulliard
eca2f017d8 Fix: Add missing import statement for the Jackson Annotation. Use the correct htmlUrl field 2020-06-04 11:32:33 +02:00
Charles Moulliard
3190bde343 Fix: Add mising try/catch block to report the exeption when no discussions are found 2020-06-04 11:31:50 +02:00
Charles Moulliard
c6ebf42a47 Update src/main/java/org/kohsuke/github/GHTeam.java
Dont wrapUp using the team object

Co-authored-by: Liam Newman <bitwiseman@gmail.com>
2020-06-04 11:14:42 +02:00
Charles Moulliard
c116b60d12 Update src/main/java/org/kohsuke/github/GHDiscussion.java
Add doc link to github team discussion API

Co-authored-by: Liam Newman <bitwiseman@gmail.com>
2020-06-04 11:13:19 +02:00
Charles Moulliard
5d09e6d9ab Update src/main/java/org/kohsuke/github/GHDiscussion.java
Remove `this.root` as it is already set with the org

Co-authored-by: Liam Newman <bitwiseman@gmail.com>
2020-06-04 11:12:38 +02:00
Charles Moulliard
2613ce0ac9 Update src/main/java/org/kohsuke/github/GHDiscussion.java
Remove to set the field `root`

Co-authored-by: Liam Newman <bitwiseman@gmail.com>
2020-06-04 11:10:21 +02:00
Charles Moulliard
a88e9b28ea Update src/main/java/org/kohsuke/github/GHDiscussion.java
Change the visibility of the fields from protected to private. Add @JacksonInject annotation. Rename html_url to htmlUrl as needed by Jackson

Co-authored-by: Liam Newman <bitwiseman@gmail.com>
2020-06-04 11:09:24 +02:00
Charles Moulliard
f0a3c26ee6 Fix: Add the missing correct file to check the discussion created using wiremock 2020-06-04 10:44:26 +02:00
Charles Moulliard
84c87ecb32 Chore: Fixed the null org within the generated json file but we still get an error 404 2020-06-04 08:49:16 +02:00
Charles Moulliard
6573f44d41 Fix: As the name of the organization could be empty/null, then use getLogin to get the org name 2020-06-04 07:46:51 +02:00
Charles Moulliard
3cacbc552c Fix: Set the organisation name to avoid to populate a url request having /orgs/null 2020-06-04 07:30:44 +02:00
Charles Moulliard
343d623e02 chore: Push new resource files generated 2020-06-04 07:22:53 +02:00
Charles Moulliard
6b80bb2b11 chore: Remove deleted resources files 2020-06-04 07:00:14 +02:00
Charles Moulliard
56fe7452eb chore. Review test case. Add new wrapUp methods 2020-06-04 06:59:41 +02:00
Charles Moulliard
d3a66f6605 chore: Regenerate new testing files 2020-05-29 17:37:49 +02:00
Charles Moulliard
dd7b4712f1 fix: Add missing @throws IOException 2020-05-29 17:24:49 +02:00
Charles Moulliard
9df5871f6b chore: wrapUp Github instance 2020-05-29 17:20:54 +02:00
Charles Moulliard
29aab9e9f4 chore: Add missing classes and test case 2020-05-29 16:34:07 +02:00
Charles Moulliard
af67eb7f0b feat: add new APi for Discussion 2020-05-29 16:28:47 +02:00
Liam Newman
10482c0141 [maven-release-plugin] prepare for next development iteration 2020-05-28 07:48:53 -07:00
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
cda7607e1c [maven-release-plugin] prepare release github-api-1.107 2020-02-22 20:18:57 -08:00
Liam Newman
816c83c80a Merge branch 'master' into feature/delete_branch_automatically 2020-02-22 19:33:46 -08:00
Liam Newman
0c3c490d58 Merge pull request #707 from rdvdijk/add-rocket-eyes-reactions
Add support for rocket and eyes reactions.
2020-02-22 19:33:08 -08:00
Liam Newman
99da6fb66f Merge pull request #710 from avano/checks
CheckRun - Add ability to get the head sha + Implement GH Status Event
2020-02-22 19:17:06 -08:00
Liam Newman
fa2601386c Add tests for new reactions 2020-02-22 19:16:33 -08:00
Liam Newman
122833b0e3 Merge branch 'master' into checks 2020-02-22 18:48:50 -08:00
Liam Newman
8618dbf0d5 Merge pull request #709 from bitwiseman/issue/708
Fix for NullPointer in issue search results
2020-02-22 18:42:09 -08:00
Liam Newman
a0baf33459 Fix for NullPointer in issue search results
User reported #708 which made me realize that search tests were basically all disabled.
This terms on two basic search tests and also makes it so GHIssue can continue to work without
a GHRepository set on it.

Fixes #708
2020-02-22 17:01:12 -08:00
Andrej Vano
0ee66ea928 [Status] Add GHEventPayload.Status class 2020-02-22 18:14:03 +01:00
Andrej Vano
f68d4aaf5b [CheckRun] Add ability to access HEAD SHA 2020-02-22 18:10:27 +01:00
Liam Newman
888abc9e2a Removed extraneous author javadocs 2020-02-21 15:58:39 -08:00
Liam Newman
c8115b1c10 Remove shading 2020-02-21 15:58:39 -08:00
Liam Newman
137d4f591f Update maven-build.yml 2020-02-21 15:44:31 -08:00
Liam Newman
337d49770d Update maven-build.yml 2020-02-21 15:42:28 -08:00
Liam Newman
614c5578b0 Fix code coverage and GHRepositoryTraffic test 2020-02-21 15:35:45 -08:00
Liam Newman
d456e60800 Check code coverage on ubuntu 2020-02-21 13:17:31 -08:00
Liam Newman
064206fb9a Merge pull request #706 from bitwiseman/task/guard
Add basic rate limit checker
2020-02-21 13:06:51 -08:00
Liam Newman
a68fe3b39d More javadoc because words are hard 2020-02-21 12:04:25 -08:00
Liam Newman
1904c82941 PR feedback 2020-02-21 10:52:28 -08:00
Roel van Dijk
6fc9dd4b30 Add support for rocket and eyes reactions. 2020-02-21 10:59:17 +01:00
Liam Newman
158a31e924 Added javadocs and other cleanup
Whenever I submit a PR and then start looking at it as a reviewer, I immediately find a bunch of things that need changing.
2020-02-20 18:53:13 -08:00
Liam Newman
b70b924db4 Inital implmentation of RateLimitChecker
This is a stripped down rate limit checking implmentation that handles the infrastructure
of deciding how to get rate limit information and leaves it to other implementers to
decided what kind of checks they want to do and how long they want to wait.

The implmentation supports checkers that sleep less than the full time until the
rate limit is expected to reset, allowing for polling and notifying clients of why their query
is not returning.

A basic checker which sleeps until the rate limit is expected to reset is included as working example..
2020-02-20 16:03:46 -08:00
Liam Newman
9018d72e97 Merge pull request #697 from bitwiseman/tast/response-info
Refactor `Requester` into multiple smaller classes
2020-02-20 15:59:11 -08:00
Liam Newman
5c395138ed Merge pull request #705 from github-api/dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-5.6.1.202002131546-r
Bump org.eclipse.jgit from 5.6.0.201912101111-r to 5.6.1.202002131546-r
2020-02-19 16:01:40 -08:00
Liam Newman
af157adc1b Merge pull request #704 from github-api/dependabot/maven/com.squareup.okhttp3-okhttp-4.4.0
Bump okhttp from 4.3.1 to 4.4.0
2020-02-19 16:01:21 -08:00
Liam Newman
1db4fca9db Comment tweaks 2020-02-18 09:02:52 -08:00
dependabot-preview[bot]
013f475859 Bump org.eclipse.jgit from 5.6.0.201912101111-r to 5.6.1.202002131546-r
Bumps org.eclipse.jgit from 5.6.0.201912101111-r to 5.6.1.202002131546-r.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-18 06:36:30 +00:00
dependabot-preview[bot]
b5bc38fa52 Bump okhttp from 4.3.1 to 4.4.0
Bumps [okhttp](https://github.com/square/okhttp) from 4.3.1 to 4.4.0.
- [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.3.1...parent-4.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-18 06:36:08 +00:00
Liam Newman
bd0e0cdfa4 Revert synchronization in iterators
These were not synchronized before we should leave them fix this in a future change
2020-02-17 20:08:52 -08:00
Liam Newman
dade4c4cc4 Bump spotbugs to 4.0.0 2020-02-17 13:11:00 -08:00
Liam Newman
acc5a89dff Class clean up
We don't need two layers of PageIterator just to get the final response.
Also made iterators thread-safe.
And added more detailed comments.
2020-02-17 12:55:44 -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
Liam Newman
b7af635a9a Address PR feedback 2020-02-16 21:33:19 -08: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
Liam Newman
dc33e28452 Create GitHubHttpUrlConnectionClient to encapsulate interactions with HttpUrlConnection 2020-02-13 08:37:07 -08:00
Liam Newman
9da4781759 Update src/main/java/org/kohsuke/github/GitHub.java 2020-02-12 23:59:15 -08:00
Liam Newman
0c6959cb4a Merge remote-tracking branch 'github-api/master' into tast/response-info 2020-02-12 23:52:45 -08:00
Liam Newman
ff3136df70 Move a few static helpers to GitHubClient 2020-02-12 23:48:33 -08:00
Liam Newman
326c627221 Merge pull request #698 from github-api/dependabot/maven/org.apache.maven.plugins-maven-shade-plugin-3.2.2
Bump maven-shade-plugin from 3.2.1 to 3.2.2
2020-02-12 23:33:14 -08:00
dependabot-preview[bot]
075f382a8f Bump maven-shade-plugin from 3.2.1 to 3.2.2
Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.2.1 to 3.2.2.
- [Release notes](https://github.com/apache/maven-shade-plugin/releases)
- [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.2.1...maven-shade-plugin-3.2.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-13 07:29:11 +00:00
Liam Newman
dabb8fe49e Merge pull request #675 from jimmysombrero/collaborator-permissions
Added ability to specify permissions for collaborators
2020-02-12 23:28:00 -08:00
Liam Newman
90489e4392 JavaDocs and refactoring 2020-02-12 22:42:12 -08:00
Liam Newman
ad45a74f87 Further clean up of refactored classes 2020-02-12 22:42:12 -08:00
Liam Newman
60c045a713 Delete mocking test that is just too brittle to live 2020-02-12 22:42:12 -08:00
Liam Newman
f6c75e1f99 More refactoring 2020-02-12 22:42:12 -08:00
Liam Newman
dd9245f6f2 Progress commit on moving to Client/Request/Response refactor 2020-02-12 22:42:12 -08:00
Liam Newman
7310a70743 Disable two tests due to spurious mocking failures 2020-02-12 22:42:12 -08:00
Liam Newman
82276837ac Created Client/Request/Response classes 2020-02-12 22:42:12 -08:00
Liam Newman
bd68252b44 Test cleanup 2020-02-12 22:42:12 -08:00
Liam Newman
6b1258e33a Major rewrite of Requester 2020-02-12 22:42:12 -08:00
Liam Newman
0400032923 Merge branch 'master' into collaborator-permissions 2020-02-12 22:32:50 -08:00
Liam Newman
d9563322f1 Merge pull request #695 from github-api/dependabot/maven/org.kohsuke.stapler-stapler-1.259
Bump stapler from 1.258 to 1.259
2020-02-12 22:32:31 -08:00
Liam Newman
ab965969dd Merge branch 'master' into collaborator-permissions 2020-02-12 22:31:03 -08:00
Liam Newman
2f32e034d8 Merge pull request #694 from bitwiseman/task/fetch
Streamline fetch and retry process
2020-02-12 22:29:22 -08: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
dependabot-preview[bot]
1cf7931f43 Bump stapler from 1.258 to 1.259
Bumps [stapler](https://github.com/stapler/stapler) from 1.258 to 1.259.
- [Release notes](https://github.com/stapler/stapler/releases)
- [Changelog](https://github.com/stapler/stapler/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stapler/stapler/compare/stapler-parent-1.258...stapler-parent-1.259)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-11 06:30:12 +00:00
James Vaughn
edc697dd73 fixed javadoc isues 2020-02-07 21:27:00 -06:00
James Vaughn
54a059ff68 updated signatures for addCollaborators methods
updated javadoc comments for addCollaborators methods
combined both modifyCollaborators methods into one method
updated addColloaborators test to match new method signature
2020-02-07 21:13:23 -06:00
Liam Newman
289282e235 Move OTP detection earlier
Like other errors we've been waiting until later to catch, this one is detectable so
whe should do that before the downstream exception needs to be thrown.
2020-02-06 16:59:49 -08:00
Liam Newman
825c36c15e Tweaks for clarity 2020-02-06 14:11:16 -08:00
Liam Newman
1234c2e99e Add tests for rate limit 2020-02-06 13:33:29 -08:00
Liam Newman
b8fae1308d Streamline fetch and retry process 2020-02-06 08:01:17 -08:00
James Vaughn
dddcf624e6 finished suggested formatting changes 2020-02-05 21:30:52 -06:00
James Vaughn
b33fe9f7fe Merge branch 'collaborator-permissions' of https://github.com/jimmysombrero/github-api into collaborator-permissions 2020-02-04 21:10:39 -06:00
James Vaughn
5a799400a9 fixed minor formatting issues 2020-02-04 21:10:29 -06:00
Liam Newman
76919a819f Merge branch 'master' into collaborator-permissions 2020-02-03 12:46:17 -08:00
Liam Newman
9c30f846b2 Merge pull request #692 from github-api/dependabot/maven/com.github.tomakehurst-wiremock-jre8-standalone-2.26.0
Bump wiremock-jre8-standalone from 2.25.1 to 2.26.0
2020-02-03 12:45:46 -08:00
Liam Newman
9230f51988 Implement new methods on Options 2020-02-03 12:41:33 -08:00
dependabot-preview[bot]
712035dc9a Bump wiremock-jre8-standalone from 2.25.1 to 2.26.0
Bumps [wiremock-jre8-standalone](https://github.com/tomakehurst/wiremock) from 2.25.1 to 2.26.0.
- [Release notes](https://github.com/tomakehurst/wiremock/releases)
- [Commits](https://github.com/tomakehurst/wiremock/compare/2.25.1...2.26.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-03 12:34:01 -08:00
Liam Newman
32e5c5b4ad Merge pull request #693 from alexanderrtaylor/replaceAsserts
Replacing asserts with standard
2020-02-03 12:29:59 -08:00
Alex Taylor
134a6fab7e Merge branch 'master' into replaceAsserts 2020-02-03 14:47:11 -05:00
Alex Taylor
82e27cb962 Replacing asserts with standard
Beginning work to replace Asserts with assertThat to keep consistency
2020-02-03 11:43:16 -05:00
James Vaughn
8bcad7b3f9 Merge branch 'collaborator-permissions' of https://github.com/jimmysombrero/github-api into collaborator-permissions 2020-02-02 22:03:08 -06:00
James Vaughn
d767575f76 Added test for addCollaborators
Mark old addCollaborators methods depricated
2020-02-02 22:02:56 -06:00
jimmysombrero
7214c7d393 Merge branch 'master' into collaborator-permissions 2020-02-01 22:40:54 -06:00
James Vaughn
205e5ab03d Merge branch 'collaborator-permissions' of https://github.com/jimmysombrero/github-api into collaborator-permissions 2020-02-01 22:39:28 -06:00
James Vaughn
6576beae76 Added missing methods to keep the API from breaking
added tests for addCollaborators()
2020-02-01 22:39:14 -06:00
Liam Newman
001f8f1f50 Update PULL_REQUEST_TEMPLATE.md 2020-01-31 13:18:17 -08:00
Liam Newman
3b694a87ef Fix formatting 2020-01-31 13:17:16 -08:00
spierce
84dd06d769 [#690]Implement the ability to read total_private_repos for GHPerson 2020-01-31 13:44:43 -06:00
Liam Newman
c5cb16abfb Merge branch 'master' into collaborator-permissions 2020-01-31 08:32:35 -08:00
Liam Newman
79fb34324d Merge pull request #684 from alexanderrtaylor/assertThatIssues
Authentication and assertThat issues
2020-01-30 11:10:38 -08:00
Alex Taylor
303aef3548 Merge branch 'assertThatIssues' of https://github.com/alexanderrtaylor/github-api into assertThatIssues 2020-01-30 11:22:39 -05:00
Alex Taylor
fd278f8c32 Update AbstractGitHubWireMockTest.java
added return for Javadoc
2020-01-30 11:22:37 -05:00
Liam Newman
53041a4117 Merge branch 'master' into assertThatIssues 2020-01-29 18:32:47 -08:00
Liam Newman
9b3fe3b13a Merge pull request #687 from bitwiseman/task/windows-ci
Shorten file names for Windows
2020-01-29 18:06:48 -08:00
Liam Newman
5c6c5081e9 Improve naming of jobs 2020-01-29 18:00:30 -08:00
Liam Newman
e087ea0ac7 Split build jobs for clarity 2020-01-29 17:36:31 -08:00
Liam Newman
71c44dc805 Move CI to cache .m2 directory 2020-01-29 17:18:19 -08:00
Liam Newman
c5c8596664 Reduce output from connection retry 2020-01-29 17:04:24 -08:00
Liam Newman
92a86f4d1c No formatting checks on Windows CI build 2020-01-29 16:01:37 -08:00
Alex Taylor
8098b68b8e formatting changes
sorry forgot to run the formatting automation before committing the last
2020-01-29 16:56:49 -05:00
Alex Taylor
7356001723 Merge remote-tracking branch 'upstream/master' into assertThatIssues 2020-01-29 16:56:15 -05:00
Alex Taylor
aba60587ab Corrected massive change
Added back the extends Assert to the wiremock test base class so that I am not making a massive change and potentially  breaking inflight work people are doing
2020-01-29 16:49:33 -05:00
Liam Newman
936a6a04fb Reduce some code coverage bars on windows 2020-01-29 13:38:08 -08:00
Liam Newman
9675126298 Turn off some tests for windows 2020-01-29 13:30:01 -08:00
Liam Newman
6a5886ea1c Disable import sorting 2020-01-29 11:38:32 -08:00
Liam Newman
648c6a5a8f Shorten file names for Windows 2020-01-29 09:24:50 -08:00
Liam Newman
14b7bf4753 Add windows to CI matrix 2020-01-28 20:52:49 -08:00
jimmysombrero
0e310fa96a Merge branch 'master' into collaborator-permissions 2020-01-28 15:21:25 -06:00
Liam Newman
0f6c282c80 [maven-release-plugin] prepare for next development iteration 2020-01-27 19:07:15 -08:00
Liam Newman
ed3cd0c9c8 [maven-release-plugin] prepare release github-api-1.106 2020-01-27 19:07:07 -08:00
Liam Newman
398f029f6d Merge pull request #685 from bitwiseman/task/commons-io-2.4
Downgrade to commons-io 2.4
2020-01-27 19:04:24 -08:00
Liam Newman
ad9c2b917b Disable rate limit hanging test 2020-01-27 18:56:41 -08:00
Liam Newman
d0d65182c0 Downgrade to commons-io 2.4 for Jenkins compatibility 2020-01-27 18:43:56 -08:00
Alex Taylor
4c3a0d329b added Authentication Check
Added additional authentication checks on gitHubBeforeAfter so that cleanup is done with a user logged in
2020-01-27 15:24:28 -05:00
Alex Taylor
7c495c2177 Fixes after merge
Fixed some failing tests after merge
2020-01-27 14:45:02 -05:00
Alex Taylor
2f86a9e534 Merge remote-tracking branch 'upstream/master' into assertThatIssues 2020-01-27 14:37:46 -05:00
Alex Taylor
12c3a0b1fa Authentication and assertThat issues
Fixed some problems with tests trying to authenticate when you are not actually signed in. This hit rate API limiting which caused tests to hang/fail

Also fixed assertThat getting deprecated from junit
2020-01-27 14:29:46 -05:00
Liam Newman
14f3660f55 [maven-release-plugin] prepare for next development iteration 2020-01-27 00:03:48 -08:00
Liam Newman
5a8b032d74 [maven-release-plugin] prepare release github-api-1.105 2020-01-27 00:03:39 -08:00
Liam Newman
57c4613b1f Merge pull request #683 from timja/add-full-create-team-parameters
Add support for all create team parameters
2020-01-27 00:00:44 -08:00
Tim Jacomb
e008021a42 Merge branch 'add-full-create-team-parameters' of github.com:timja/github-api into add-full-create-team-parameters 2020-01-27 07:52:15 +00:00
Tim Jacomb
7e600c43ed Var-args instead of list 2020-01-27 07:52:08 +00:00
Tim Jacomb
963478e206 Merge branch 'master' into add-full-create-team-parameters 2020-01-27 07:46:14 +00:00
Tim Jacomb
0f32783488 Revert updatePrivacy 2020-01-27 07:40:16 +00:00
Liam Newman
756d470715 [maven-release-plugin] prepare for next development iteration 2020-01-26 23:33:20 -08:00
Liam Newman
2c47b7535b [maven-release-plugin] prepare release github-api-1.104 2020-01-26 23:33:11 -08:00
Tim Jacomb
4cc90b4929 Fix test 2020-01-27 07:31:19 +00:00
Tim Jacomb
32754ffcf5 Cleanup based on review 2020-01-27 07:24:01 +00:00
Tim Jacomb
64aae75680 Allow updating privacy status 2020-01-26 11:02:01 +00:00
Tim Jacomb
69d2160a0d Add support for all create team parameters 2020-01-25 20:07:56 +00:00
Liam Newman
99e326539e Merge pull request #680 from bitwiseman/issue/ssl
Handle SSLHandshakeException with connection retry
2020-01-24 21:47:20 -08:00
Liam Newman
1dde975cfe Handle SSLHandshakeException with connection retry 2020-01-24 21:24:55 -08:00
jimmysombrero
58c069ec5c Merge branch 'master' into collaborator-permissions 2020-01-24 18:26:54 -06:00
James Vaughn
7916600a7b updating local branch 2020-01-24 18:24:53 -06:00
James Vaughn
3e4f160c5d ran mvn clean install then the build commmand and build was successful 2020-01-24 18:23:59 -06:00
Liam Newman
aeb5e5f681 Merge pull request #674 from v1v/master
Retry when SocketException with some sleep
2020-01-24 14:43:29 -08:00
Liam Newman
1c2e491845 Minor improvement to statistics
Reading raw streams just to map them is not needed.
Using arrays instead of lists works fine.
2020-01-24 14:07:19 -08:00
Liam Newman
eb4000f26b Streamline retry code path 2020-01-24 12:32:04 -08:00
Liam Newman
74dd887c79 Merge branch 'master' into master 2020-01-23 22:22:42 -08:00
Liam Newman
764599a7d9 Move socket handling and add test 2020-01-23 20:54:13 -08:00
Liam Newman
ad683fee89 Merge branch 'master' into collaborator-permissions 2020-01-23 17:51:59 -08:00
Liam Newman
85a53fc68f Merge pull request #676 from alexanderrtaylor/issues-349
Issues 349
2020-01-23 17:49:39 -08:00
James Vaughn
3bf8baee85 format fixed and validation passed 2020-01-23 18:32:37 -06:00
Vaughn
8792213594 tried formatting the file once again. 2020-01-23 15:16:36 -06:00
Victor Martinez
d9ebc9455c UTs for the Timeout and Retry 2020-01-23 21:09:14 +00:00
Vaughn
9ab8bdfe4a formatted file 2020-01-23 14:45:24 -06:00
Victor Martinez
418ea9a19e As suggested in the code review, handle exceptions and setup the connection 2020-01-23 20:39:58 +00:00
Victor Martinez
20f04febf2 As suggested in the code review, make a configurable sleep 2020-01-23 20:36:00 +00:00
Alex Taylor
a65783201e updated the test files
Updated the test files and did a temp repo
2020-01-23 15:31:50 -05:00
Victor Martinez
a5f04d44a4 Fix javadoc warning 2020-01-23 20:29:55 +00:00
Victor Martinez
cbe1022f20 Support more generic Socket Exceptions
For instance: connection reset by peer
2020-01-23 20:28:57 +00:00
Vaughn
90301ae9ee Added ability to specify permissions for collaborators 2020-01-23 13:37:35 -06:00
Victor Martinez
4f38ab3640 Cosmetic change 2020-01-23 14:01:29 +00:00
Victor Martinez
fca179abab Retry if SocketException
See https://github.com/github-api/github-api/pull/373
2020-01-23 13:33:12 +00:00
Liam Newman
e426237c35 [maven-release-plugin] prepare for next development iteration 2020-01-22 11:57:10 -08:00
Liam Newman
3dae361d7b [maven-release-plugin] prepare release github-api-1.103 2020-01-22 11:56:59 -08:00
Liam Newman
967831388e Relocate shaded dependecies and generate separate shaded artifact 2020-01-22 09:59:10 -08:00
Liam Newman
f9794f20d4 Use Https 2020-01-21 17:22:58 -08:00
Liam Newman
f98efd6af0 Update site.xml 2020-01-21 16:56:44 -08:00
Liam Newman
69bf0641f8 Update site.xml
Closes #671
2020-01-21 16:55:46 -08:00
Liam Newman
5791843d16 [maven-release-plugin] prepare for next development iteration 2020-01-21 15:40:09 -08:00
Liam Newman
58d0a20074 [maven-release-plugin] prepare release github-api-1.102 2020-01-21 15:40:00 -08:00
Liam Newman
5884c7b3ba Re-enable jacoco during ci 2020-01-21 14:44:47 -08:00
Liam Newman
dd1da268a2 Additional checks and clean up to GHRateLimit and tests 2020-01-21 13:30:08 -08:00
Alex Taylor
473f3954c7 Update GHRepositoryTest.java
Added some parent tests as well
2020-01-21 15:56:07 -05:00
Alex Taylor
5aad5406a2 [WIP]Adding GHRepo tests 2020-01-21 14:35:29 -05:00
Liam Newman
98b606287d Add more validation to rate limit
Downstream tests are doing some strange Json.  Give better output when they do something invalid.
2020-01-18 23:33:44 -08:00
Liam Newman
9792fc0daa Fix missing version 2020-01-18 19:20:21 -08:00
Liam Newman
a9bb9302bc Move cached 404 retry to main code path 2020-01-18 18:53:31 -08:00
Liam Newman
30c70bc8d4 Merge pull request #651 from martinvanzijl/issue_500_create_tag_method
Add createTag() method to GHRepository
2020-01-18 14:02:39 -08:00
Liam Newman
0df48c37ac Merge branch 'master' into issue_500_create_tag_method 2020-01-17 22:43:07 -08:00
Liam Newman
ec31e94e7a Merge pull request #665 from bitwiseman/task/cache-error-test
Workaround for `If-Modified-Since` HTTP request header causing cache corruption
2020-01-17 22:42:09 -08:00
Liam Newman
ea631d0e88 Merge pull request #633 from bitwiseman/task/shade
Add shading of dependencies
2020-01-17 22:41:29 -08:00
Liam Newman
66a180346e Improve commenting of workaround 2020-01-17 17:52:50 -08:00
Liam Newman
63ee878789 Merge remote-tracking branch 'github-api/master' into task/cache-error-test 2020-01-17 17:27:12 -08:00
Liam Newman
3479e4f2fd Clean up and formatting 2020-01-17 17:05:45 -08:00
Liam Newman
54f4152f89 Template data files to make okhttp2 test runnable in CI
OkHttp2 doesn't invalidate caches sometimes when it probably should
2020-01-17 17:00:40 -08:00
Liam Newman
06334bf272 Template data files to make okhttp3 test runnable in CI 2020-01-17 16:58:54 -08:00
Liam Newman
839f096f39 Add caching error test for OkHttp 2020-01-17 15:57:14 -08:00
Liam Newman
f3b2fdc4fc Update test and resources using new workaround 2020-01-17 15:53:55 -08:00
Liam Newman
16d34f3268 Workaround for #669 - retry with cache overridden
This is much more reasonable way to address this issue.
When the Requester detects a 404 response with an ETag (only happpens when the server's 304
is bogus and would cause cache corruption), try the query again with new request header
that forces the server to not return 304 and return new data instead.

Ths solution is transparent to users of this library and autmatically fixes a situation that
was causing cache corruption. If GitHub ever fixes the issue and begins providing accurate
ETags to their 404 responses, this will result in two calls being made for each 404 response.
While that would be unfortunate, it would still be better than the current situation.
2020-01-17 15:53:55 -08:00
Liam Newman
61e8dd09d6 Revert "Workaround for #669 - remove If-Modified-Since header"
This reverts commit 90d7fea7aa.
2020-01-17 14:46:31 -08:00
Liam Newman
90d7fea7aa Workaround for #669 - remove If-Modified-Since header
This is a first cut at working round #669.  It is hacky as hell and I hate it.
2020-01-17 14:46:10 -08:00
Liam Newman
b9c8bf07ea Restore correct exception throwing for getArray 2020-01-15 19:42:42 -08:00
Liam Newman
a3ba07d45f Inline toIterable 2020-01-15 19:33:22 -08:00
Liam Newman
5a6a29cbb5 Add array and iterator tests 2020-01-15 19:31:30 -08:00
Liam Newman
72aedbb76c JENKINS-54126 - Repro of github caching error 2020-01-14 00:29:43 -08:00
Liam Newman
e7e3be6ea7 Merge pull request #662 from sullis/github-actions-checkout-v2
GitHub Actions checkout v2
2020-01-13 11:29:25 -08:00
Liam Newman
62e1b9eb01 Merge pull request #663 from sullis/jackson-2.10.2
jackson 2.10.2
2020-01-13 11:22:29 -08:00
Sean C. Sullivan
3fff92dc35 jackson 2.10.2 2020-01-12 16:09:57 -08:00
Sean C. Sullivan
352d77719e GitHub Actions checkout v2 2020-01-12 15:23:13 -08:00
Martin van Zijl
ff397dfa4d Correction per "mvn install site". 2020-01-11 13:03:41 +13:00
Martin van Zijl
34d64c0dff Added comment to JavaDoc as advised per GitHub Maven test. 2020-01-11 12:53:54 +13:00
Martin van Zijl
b5fdc2f956 Merge branch 'master' of https://github.com/kohsuke/github-api into issue_500_create_tag_method 2020-01-11 12:46:08 +13:00
Martin van Zijl
38602965db Merge branch 'issue_500_create_tag_method' of https://github.com/martinvanzijl/github-api into issue_500_create_tag_method 2020-01-11 12:31:28 +13:00
Martin van Zijl
df1ea62883 Removed wiremock files for old test case. 2020-01-11 12:24:12 +13:00
Martin van Zijl
afaff52888 Removed test from GHRepositoryTest and added to GHTagTest. 2020-01-11 12:23:41 +13:00
Liam Newman
5b7829c288 Merge branch 'master' into task/shade 2020-01-10 11:14:18 -08:00
Liam Newman
2462eb2c79 Merge pull request #652 from github-api/dependabot/maven/com.squareup.okio-okio-2.4.3
Bump okio from 2.4.2 to 2.4.3
2020-01-10 11:13:59 -08:00
Liam Newman
edc26b0a55 Fix site 2020-01-10 10:11:31 -08:00
Liam Newman
cc94e8b0ca Merge branch 'master' into dependabot/maven/com.squareup.okio-okio-2.4.3 2020-01-10 09:24:04 -08:00
Liam Newman
80f3a6e507 Merge pull request #659 from github-api/dependabot/maven/com.squareup.okhttp3-okhttp-4.3.1
Bump okhttp from 4.2.2 to 4.3.1
2020-01-10 09:23:03 -08:00
Liam Newman
5709be7ff7 Merge branch 'master' into issue_500_create_tag_method 2020-01-10 09:19:05 -08:00
Liam Newman
46fce8cf4b Merge branch 'master' into dependabot/maven/com.squareup.okio-okio-2.4.3 2020-01-10 09:18:51 -08:00
Liam Newman
e84049367e Merge branch 'master' into dependabot/maven/com.squareup.okhttp3-okhttp-4.3.1 2020-01-10 09:18:05 -08:00
Liam Newman
f213ead595 Move shade to ci and release profiles 2020-01-09 11:36:24 -08:00
Liam Newman
ba540b0725 Remove parent pom 2020-01-09 08:27:06 -08:00
Liam Newman
eb55691c89 Add shading of dependencies
Fixes #630
2020-01-09 08:26:49 -08:00
Liam Newman
dd508e7dea Rerecord GHTreeBuilder for test org 2020-01-08 19:44:23 -08:00
dependabot-preview[bot]
66357866c5 Bump okio from 2.4.2 to 2.4.3
Bumps [okio](https://github.com/square/okio) from 2.4.2 to 2.4.3.
- [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.2...parent-2.4.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-09 03:22:54 +00:00
dependabot-preview[bot]
6e3728b458 Bump okhttp from 4.2.2 to 4.3.1
Bumps [okhttp](https://github.com/square/okhttp) from 4.2.2 to 4.3.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.2.2...parent-4.3.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-09 03:22:54 +00:00
Liam Newman
31d4eef4b1 Merge pull request #642 from asthinasthi/create-tree-null-sha-field
Post only non-null values in request body for createTree
2020-01-08 19:21:43 -08:00
Liam Newman
f58f32a7a8 Merge branch 'master' into create-tree-null-sha-field 2020-01-08 17:36:36 -08:00
Liam Newman
28d8fb686a Merge pull request #653 from github-api/dependabot/maven/org.apache.maven.plugins-maven-source-plugin-3.2.1
Bump maven-source-plugin from 3.2.0 to 3.2.1
2020-01-07 11:26:07 -08:00
dependabot-preview[bot]
4c7fc2ef47 Bump maven-source-plugin from 3.2.0 to 3.2.1
Bumps [maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.2.0 to 3.2.1.
- [Release notes](https://github.com/apache/maven-source-plugin/releases)
- [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-3.2.0...maven-source-plugin-3.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-07 00:00:39 +00:00
Liam Newman
a3f99978c2 Merge pull request #657 from github-api/dependabot/maven/junit-junit-4.13
Bump junit from 4.12 to 4.13
2020-01-06 15:59:26 -08:00
Liam Newman
136b55d310 Merge pull request #650 from bitwiseman/issue/mime-base64-638
Do not MIME encode Base64 content for sending
2020-01-06 09:23:44 -08:00
dependabot-preview[bot]
617e90259b Bump junit from 4.12 to 4.13
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/master/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-02 06:36:48 +00:00
Martin van Zijl
959eb46162 Deleted unit test cleanup method.
This method failed in the automated GitHub build online with a null
pointer exception.

I tried to make it a @Before/@After method, but that fails on
my local PC.
2020-01-02 13:21:27 +13:00
Martin van Zijl
998bda9de7 Add createTag() method.
Fixes #500.
2019-12-23 05:43:48 +13:00
Liam Newman
37a2018fe3 Do not MIME encode Base64 content for sending
Fixes #638
2019-12-20 19:48:17 -08:00
Liam Newman
2c80e07c9d Merge branch 'master' into create-tree-null-sha-field 2019-12-19 19:11:09 -08:00
Liam Newman
a115f34766 Merge pull request #637 from PauloMigAlmeida/marketplace_endpoints_patch2
[Patch 2/2] :: Add support to Marketplace endpoints
2019-12-19 19:10:00 -08:00
Liam Newman
cd66c1e7c3 Add Accept header 2019-12-19 18:59:50 -08:00
Liam Newman
4f9975dc6d Merge remote-tracking branch 'github-api/master' into marketplace_endpoints_patch2 2019-12-19 18:44:48 -08:00
Liam Newman
9da487d962 Merge pull request #635 from PauloMigAlmeida/marketplace_endpoints
[Patch 1/2] :: Add support to Marketplace endpoints
2019-12-19 18:26:16 -08:00
Liam Newman
c7123b016b Update for Accept header 2019-12-19 18:21:09 -08:00
PauloMigAlmeida
efb13ddaf0 Fix errors caught during the build
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
3539b73c08 Implement changes requested for patch 1
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
2c084ef4d5 improve docs related to credentials requirements for some methods
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
754e66f4dd Additional tests for list accounts with a few parameters combinations
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
41b698f0a8 Add tests for listing GitHub marketplace accounts
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
de78da4fa6 Implement listing all GitHub Marketplace accounts given a plan
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
3d241d6fa1 formatting improvements
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
1d983a0090 Implement list marketplace plans
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:13 -08:00
Liam Newman
78fb860305 Merge pull request #648 from bitwiseman/task/accept-header
Enforce 'Accept' request header values
2019-12-19 18:04:55 -08:00
Liam Newman
c699a84f42 Enforce 'Accept' request header values
The 'Accept' header on requests can change what data is returned, so we need to
only match requests with the correct value.
2019-12-19 17:56:32 -08:00
PauloMigAlmeida
d8a178d93d Implement changes requested for patch 2
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 13:27:40 +13:00
PauloMigAlmeida
ada4243548 Merge branch 'marketplace_endpoints' of https://github.com/PauloMigAlmeida/github-api into marketplace_endpoints_patch2
 Conflicts:
	src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
	src/main/java/org/kohsuke/github/GHMarketplaceListAccountBuilder.java
	src/test/java/org/kohsuke/github/GHMarketplacePlanTest.java
2019-12-20 13:14:12 +13:00
PauloMigAlmeida
fa2e3aad6c Fix errors caught during the build
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 12:58:11 +13:00
PauloMigAlmeida
0cf457a46f Merge branch 'master' of https://github.com/kohsuke/github-api into marketplace_endpoints 2019-12-20 12:46:48 +13:00
PauloMigAlmeida
bb7b98d448 Merge remote-tracking branch 'origin/marketplace_endpoints' into marketplace_endpoints 2019-12-20 12:38:16 +13:00
PauloMigAlmeida
e8d90848f2 Implement changes requested for patch 1
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 12:37:59 +13:00
Liam Newman
7c791451ba Merge pull request #647 from halkeye/patch-1
Labels with description are not preview anymore
2019-12-19 13:57:07 -08:00
Liam Newman
16d8c2b221 Remove Symmetra preview 2019-12-19 13:50:18 -08:00
Gavin Mogan
dceecbef0a Labels with description are not preview anymore
https://developer.github.com/v3/issues/labels/#create-a-label
2019-12-19 13:50:07 -08:00
Liam Newman
3cbddf1de9 Merge pull request #646 from PauloMigAlmeida/issue_628
Implement App createToken with empty body
2019-12-19 13:47:22 -08:00
PauloMigAlmeida
650340fcb3 Fix example on the docs
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 01:47:39 +13:00
PauloMigAlmeida
ce5b893224 Add example on the docs
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 01:44:09 +13:00
PauloMigAlmeida
7869afa4ff Implement test for createToken method with no json property
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 01:09:34 +13:00
Paulo Miguel Almeida
9085606082 Fix GHObjectTest test broken on PR #644
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 00:08:23 +13:00
Paulo Miguel Almeida
1e3f646814 Refactor GHAppCreateTokenBuilder;
Add docs;

Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 00:05:31 +13:00
PauloMigAlmeida
933f0cb4b8 Merge branch 'master' of https://github.com/github-api/github-api into issue_628
 Conflicts:
	src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java
2019-12-19 22:59:44 +13:00
PauloMigAlmeida
7497761fcc Implement create token variation 2019-12-19 19:42:22 +13:00
Liam Newman
12b3d4ec7a Merge branch 'master' into marketplace_endpoints 2019-12-17 17:27:10 -08:00
Liam Newman
8fd5ed57c4 Merge pull request #644 from martinvanzijl/issue_126_add_type_and_site_admin_fields
Add type and site_admin fields to GHPerson
2019-12-17 17:23:54 -08:00
Liam Newman
7bc301bc70 Merge pull request #634 from bitwiseman/task/minimum-coverage
Task/minimum coverage
2019-12-17 17:23:30 -08:00
Liam Newman
30321d3a0e Update coverage excludes and bars 2019-12-17 17:16:23 -08:00
Liam Newman
511a0ae503 Exclude deprecated classes 2019-12-17 17:16:22 -08:00
Liam Newman
1057636666 Add wiremock data 2019-12-17 17:16:22 -08:00
Liam Newman
564b1d2a98 Enable event tests 2019-12-17 17:16:22 -08:00
Liam Newman
20cd0e2de2 Turn Traffic tests back on 2019-12-17 17:16:22 -08:00
Liam Newman
6bc617c488 Merge pull request #623 from bitwiseman/task/iterator
Move array population to single iterator code path
2019-12-17 15:01:12 -08:00
Liam Newman
049db83423 Merge remote-tracking branch 'github-api/master' into task/iterator 2019-12-17 14:35:37 -08:00
Liam Newman
52dd90e85d Additional tweaks to reduce the number of code paths 2019-12-17 14:15:38 -08:00
Liam Newman
305267d07f Rename methods for better clarity 2019-12-17 12:41:23 -08:00
Liam Newman
20369aa1b5 Merge pull request #622 from alexanderrtaylor/GHEventAddition
[JENKINS-57430] Added some new GH Event Types
2019-12-17 11:32:45 -08:00
Liam Newman
40f05e4dbb Clean up request method calls 2019-12-17 10:02:55 -08:00
Liam Newman
a23d19f208 Merge pull request #645 from github-api/dependabot/maven/org.mockito-mockito-core-3.2.4
Bump mockito-core from 3.2.0 to 3.2.4
2019-12-17 09:06:48 -08:00
dependabot-preview[bot]
cb1d1e8ed7 Bump mockito-core from 3.2.0 to 3.2.4
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.2.0 to 3.2.4.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.2.0...v3.2.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-17 06:37:39 +00:00
Alex Taylor
4f67f32719 Update src/main/java/org/kohsuke/github/GHCheckRun.java 2019-12-16 14:53:38 -05:00
Alex Taylor
a80b5b6abc Fixed the findbugs errors 2019-12-14 15:38:34 -05:00
Liam Newman
0be3d88872 Merge pull request #643 from github-api/dependabot/maven/com.squareup.okio-okio-2.4.2
Bump okio from 2.4.1 to 2.4.2
2019-12-13 19:42:09 +00:00
Liam Newman
48bb996350 Merge pull request #640 from github-api/dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-5.6.0.201912101111-r
Bump org.eclipse.jgit from 5.5.1.201910021850-r to 5.6.0.201912101111-r
2019-12-13 19:41:52 +00:00
Martin van Zijl
ee2dde4cd1 Add type and site_admin fields to GHPerson.
Helps with #126.
2019-12-14 07:24:23 +13:00
dependabot-preview[bot]
c10a31c933 Bump okio from 2.4.1 to 2.4.2
Bumps [okio](https://github.com/square/okio) from 2.4.1 to 2.4.2.
- [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/2.4.1...parent-2.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-12 06:33:01 +00:00
Anirudh Mathad
d6a846f58d Post only non-null values in request body for createTree 2019-12-11 15:25:24 -08:00
dependabot-preview[bot]
945873231d Bump org.eclipse.jgit from 5.5.1.201910021850-r to 5.6.0.201912101111-r
Bumps org.eclipse.jgit from 5.5.1.201910021850-r to 5.6.0.201912101111-r.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-11 06:36:08 +00:00
PauloMigAlmeida
5dc494978e Implement tests
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-10 13:21:52 +13:00
PauloMigAlmeida
c870ec10c0 Implement /user/marketplace_purchases endpoint
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-10 13:21:06 +13:00
PauloMigAlmeida
2085b8fd14 Split GHMarketplaceAccount.java into 2 pieces for re-utilisation purposes
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-10 13:19:19 +13:00
PauloMigAlmeida
e065b6435c improve docs related to credentials requirements for some methods
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-09 20:59:03 +13:00
PauloMigAlmeida
da5331ceb0 Additional tests for list accounts with a few parameters combinations
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-09 20:07:32 +13:00
PauloMigAlmeida
8f81982de4 Add tests for listing GitHub marketplace accounts
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-09 19:36:13 +13:00
PauloMigAlmeida
499b46ecf3 Implement listing all GitHub Marketplace accounts given a plan
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-09 15:53:46 +13:00
PauloMigAlmeida
a7d232e15f formatting improvements
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-08 20:26:37 +13:00
PauloMigAlmeida
8fdb394ec5 Implement list marketplace plans
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-08 20:13:54 +13:00
PauloMigAlmeida
7a1da64bf2 Merge branch 'master' of https://github.com/kohsuke/github-api 2019-12-08 15:42:54 +13:00
PauloMigAlmeida
95ae155fc0 Merge branch 'master' of https://github.com/PauloMigAlmeida/github-api 2019-12-08 15:42:34 +13:00
Liam Newman
d1507f2666 Merge pull request #631 from bitwiseman/task/base64
Remove dependency on apache commons-codec
2019-12-04 10:56:08 +00:00
Liam Newman
7e4f98d328 Remove dependency on apache commons-codec 2019-12-03 11:39:05 +00:00
Liam Newman
f9a956905e Merge pull request #629 from sullis/mockito-3.2.0
mockito 3.2.0
2019-11-30 13:20:54 -08:00
Sean C. Sullivan
e7d95f9da6 mockito 3.2.0 2019-11-29 13:33:54 -05:00
Alex Taylor
bc8f0aa223 Update GHEventPayload.java
updated to meet standards
2019-11-27 15:18:43 -05:00
Liam Newman
6f2ae94e12 Changelog for v1.101 2019-11-27 10:47:25 -08:00
Alex Taylor
8f787e9976 Added the Check Run event
Added the check run event and the objects used there along with a valid test
2019-11-27 13:30:45 -05:00
Liam Newman
321d8240a2 [maven-release-plugin] prepare for next development iteration 2019-11-27 10:27:31 -08:00
Liam Newman
d667b2f822 [maven-release-plugin] prepare release github-api-1.101 2019-11-27 10:27:24 -08:00
Liam Newman
d7f511363d Merge pull request #627 from alecharp/fix-cache-control-packagename
Fixed CacheControl package name
2019-11-27 10:14:12 -08:00
Adrien Lecharpentier
39e7c5c3de Fixed CacheControl package name
With okhttp 3, the package name changed. In the okhttp3.OkHttpConnector,
the incorrect class is loaded, creating a ClassNotFoundException at
runtime when okhttp3 only is loaded.
2019-11-27 18:30:06 +01:00
Liam Newman
60acd5c864 Update CHANGELOG.md 2019-11-26 19:08:00 -08:00
Liam Newman
b92cf6fd35 [maven-release-plugin] prepare for next development iteration 2019-11-26 17:53:42 -08:00
Liam Newman
0f9482864c Move url to separate method 2019-11-26 15:26:46 -08:00
Liam Newman
60700d59fe Force URI encoding for api paths starting with slash 2019-11-26 15:14:36 -08:00
Liam Newman
3296cef02d Change requester to GET by default 2019-11-25 18:15:21 -08:00
Liam Newman
1b55b5fa3c Move array population to single iterator code path
This remove a second code path throught pagination.
2019-11-25 18:15:21 -08:00
Alex Taylor
b2701f5ba4 [JENKINS-57430] Added some new GH Event Types
Added some new GH Event types so that it does not throw errors
2019-11-22 14:26:35 -05:00
PauloMigAlmeida
5d9a4b42a6 Merge branch 'master' of https://github.com/kohsuke/github-api 2019-11-14 15:56:42 +13:00
5151 changed files with 441184 additions and 281398 deletions

View File

@@ -7,4 +7,10 @@ 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 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.
# When creating a PR:
- [ ] Fill in the "Description" above.
- [ ] Enable "Allow edits from maintainers".

12
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
time: "02:00"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
time: "02:00"

View File

@@ -1,5 +1,5 @@
name-template: 'v$NEXT_PATCH_VERSION 🌈'
tag-template: 'v$NEXT_PATCH_VERSION'
tag-template: 'github-api-$NEXT_MINOR_VERSION'
categories:
- title: '🚀 Features'
labels:

View File

@@ -1,22 +1,72 @@
name: Java CI Build and Test
name: CI
on: [push, pull_request]
jobs:
build:
name: build-only (Java ${{ matrix.java }})
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '1.8.0', '11.0.x', '13.0.x' ]
java: [ 13 ]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Cached .m2
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Maven Install (skipTests)
run: mvn -B install -DskipTests -D enable-ci --file pom.xml
site:
name: site (Java ${{ matrix.java }})
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11 ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Maven Site
run: mvn -B site -D enable-ci --file pom.xml
test:
name: test (${{ matrix.os }}, Java ${{ matrix.java }})
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ ubuntu, windows ]
java: [ 8, 11, 13, 15-ea ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Maven Download all dependencies
run: mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline
- name: Maven Build
run: mvn -B install site -P ci --file pom.xml
- uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Maven Install without Code Coverage
if: matrix.os == 'windows'
run: mvn -B install --file pom.xml
- name: Maven Install with Code Coverage
if: matrix.os != 'windows'
run: mvn -B install -D enable-ci --file pom.xml

4
.gitignore vendored
View File

@@ -7,3 +7,7 @@ target
.project
.settings/
.DS_Store
dependency-reduced-pom.xml
.factorypath
.vscode/settings.json

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

438
pom.xml
View File

@@ -1,46 +1,49 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.kohsuke</groupId>
<artifactId>pom</artifactId>
<version>21</version>
<relativePath />
</parent>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.100</version>
<version>1.116</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.100</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.116</tag>
</scm>
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</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>3.1.12</spotbugs.version>
<spotbugs-maven-plugin.version>4.0.4</spotbugs-maven-plugin.version>
<spotbugs.version>4.1.1</spotbugs.version>
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
<hamcrest.version>2.2</hamcrest.version>
<okhttp3.version>4.2.2</okhttp3.version>
<okio.version>2.4.1</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>
<jacoco.coverage.target.class>.80</jacoco.coverage.target.class>
<jacoco.coverage.target.method>0.20</jacoco.coverage.target.method>
<jacoco.coverage.target.line>0.50</jacoco.coverage.target.line>
<jacoco.coverage.target.other>0.50</jacoco.coverage.target.other>
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
<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>
</properties>
@@ -57,6 +60,14 @@
<artifactId>maven-scm-manager-plexus</artifactId>
<version>1.11.2</version>
</extension>
<!-- Doing site publishing manually for now -->
<!--
<extension>
<groupId>org.kohsuke</groupId>
<artifactId>wagon-gitsite</artifactId>
<version>0.3.5</version>
</extension>
-->
</extensions>
<testResources>
<testResource>
@@ -68,19 +79,160 @@
</testResources>
<pluginManagement>
<plugins>
<!-- adds jacoco coverage -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<!-- SUREFIRE-1226 workaround -->
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>METHOD</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.bundle.method}</minimum>
</limit>
</limits>
</rule>
<rule>
<!--We end up with chatty logs, but it shows us which particular classes -->
<!--are lacking in coverage. If this is too much, just remove the -->
<!--<element>CLASS</element> tag below. -->
<element>CLASS</element>
<limits>
<limit>
<counter>METHOD</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.class.method}</minimum>
</limit>
</limits>
<excludes>
<!-- Code implemented externally -->
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory.**</exclude>
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory</exclude>
<!-- Sample only -->
<exclude>org.kohsuke.github.example.*</exclude>
<!-- No methods -->
<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>
<!-- These fail coverage on windows because tests are disabled -->
<exclude>org.kohsuke.github.GHAsset</exclude>
<exclude>org.kohsuke.github.GHReleaseBuilder</exclude>
<exclude>org.kohsuke.github.GHRelease</exclude>
<!-- TODO: These still need test coverage -->
<exclude>org.kohsuke.github.GHBranchProtection.RequiredSignatures</exclude>
<exclude>org.kohsuke.github.GHBranchProtectionBuilder.Restrictions</exclude>
<exclude>org.kohsuke.github.GHBranchProtection.Restrictions</exclude>
<exclude>org.kohsuke.github.GHCommentAuthorAssociation</exclude>
<exclude>org.kohsuke.github.GHCommitBuilder.UserInfo</exclude>
<exclude>org.kohsuke.github.GHCommitState</exclude>
<exclude>org.kohsuke.github.GHCompare.Commit</exclude>
<exclude>org.kohsuke.github.GHCompare.InnerCommit</exclude>
<exclude>org.kohsuke.github.GHCompare.Status</exclude>
<exclude>org.kohsuke.github.GHCompare.Tree</exclude>
<exclude>org.kohsuke.github.GHCompare.User</exclude>
<exclude>org.kohsuke.github.GHCompare</exclude>
<exclude>org.kohsuke.github.GHDeployKey</exclude>
<exclude>org.kohsuke.github.GHDeploymentStatusBuilder</exclude>
<exclude>org.kohsuke.github.GHDirection</exclude>
<exclude>org.kohsuke.github.GHEmail</exclude>
<exclude>org.kohsuke.github.GHEventPayload.Ping</exclude>
<exclude>org.kohsuke.github.GHEventPayload.Release</exclude>
<exclude>org.kohsuke.github.GHException</exclude>
<exclude>org.kohsuke.github.GHHook</exclude>
<exclude>org.kohsuke.github.GHHooks.OrgContext</exclude>
<exclude>org.kohsuke.github.GHInvitation</exclude>
<exclude>org.kohsuke.github.GHMilestoneState</exclude>
<exclude>org.kohsuke.github.GHOrgHook</exclude>
<exclude>org.kohsuke.github.GHProject.ProjectStateFilter</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Authorship</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Commit</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.CommitPointer</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Tree</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail</exclude>
<exclude>org.kohsuke.github.GHPullRequestFileDetail</exclude>
<exclude>org.kohsuke.github.GHPullRequestQueryBuilder.Sort</exclude>
<exclude>org.kohsuke.github.GHReleaseUpdater</exclude>
<exclude>org.kohsuke.github.GHRepository.ForkSort</exclude>
<exclude>org.kohsuke.github.GHRequestedAction</exclude>
<exclude>org.kohsuke.github.GHStargazer</exclude>
<exclude>org.kohsuke.github.GHTagObject</exclude>
<exclude>org.kohsuke.github.GHTeam.Role</exclude>
<exclude>org.kohsuke.github.GHUserSearchBuilder.Sort</exclude>
<exclude>org.kohsuke.github.GHVerifiedKey</exclude>
</excludes>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<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>
<doclint>all</doclint>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype-nexus-staging</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
@@ -89,7 +241,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version>
<version>3.9.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -102,15 +254,19 @@
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
</plugin>
<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>
<artifactId>bcel</artifactId>
<version>6.4.1</version>
<version>6.5.0</version>
</dependency>
</dependencies>
</plugin>
@@ -132,12 +288,31 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<executions>
<execution>
<id>default-test</id>
<configuration>
<excludesFile>src/test/resources/slow-or-flaky-tests.txt</excludesFile>
</configuration>
</execution>
<execution>
<id>slow-or-flaky-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<rerunFailingTestsCount>2</rerunFailingTestsCount>
<!-- There are some tests that take longer or are a little flaky. Run them here. -->
<includesFile>src/test/resources/slow-or-flaky-tests.txt</includesFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.18</version>
<version>1.19</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
@@ -170,7 +345,7 @@
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.11.0</version>
<version>2.12.1</version>
<executions>
<execution>
<goals>
@@ -178,6 +353,7 @@
</goals>
<configuration>
<configFile>src/main/resources/eclipse/formatter.xml</configFile>
<cachedir>${project.build.directory}/.cache</cachedir>
</configuration>
</execution>
</executions>
@@ -185,7 +361,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>
@@ -225,17 +401,6 @@
</dependency>
</dependencies>
</plugin>
<!-- Do not use gmaven plugin -->
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<goals>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
@@ -245,11 +410,6 @@
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
@@ -272,18 +432,18 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.1</version>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.infradna.tool</groupId>
@@ -291,6 +451,27 @@
<version>1.18</version>
<optional>true</optional>
</dependency>
<!-- for stapler-jetty -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<!-- for stapler-jetty -->
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.5</version>
<scope>test</scope>
</dependency>
<!-- for stapler-jetty -->
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler</artifactId>
<version>1.260</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-jetty</artifactId>
@@ -300,7 +481,7 @@
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.5.1.201910021850-r</version>
<version>5.7.0.202003110725-r</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -338,19 +519,19 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.1.0</version>
<version>3.4.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>${spotbugs.version}</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<version>2.25.1</version>
<version>2.27.1</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -374,119 +555,54 @@
</pluginRepositories>
<profiles>
<profile>
<id>ci</id>
<id>ci-non-windows</id>
<activation>
<property>
<name>enable-ci</name>
</property>
<os>
<family>!windows</family>
</os>
</activation>
<properties>
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
</properties>
<build>
</build>
</profile>
<profile>
<id>jacoco</id>
<id>ci-all</id>
<activation>
<property>
<name>enable-jacoco</name>
<name>enable-ci</name>
</property>
</activation>
<properties>
<jacoco.haltOnFailure>true</jacoco.haltOnFailure>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check</id>
<phase>install</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<!--We end up with chatty logs, but it shows us which particular classes -->
<!--are lacking in coverage. If this is too much, just remove the -->
<!--<element>CLASS</element> tag below. -->
<element>CLASS</element>
<limits>
<!-- These limits can be overridden, in the form of `0.50` for -->
<!-- 50%, as necessary. Using a property just puts it in one spot. -->
<!--
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.lines}</minimum>
</limit>
-->
<!--
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.other}</minimum>
</limit>
-->
<!--
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.other}</minimum>
</limit>
-->
<!--
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.other}</minimum>
</limit>
-->
<limit>
<counter>METHOD</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.method}</minimum>
</limit>
<!-- <limit>-->
<!-- <counter>CLASS</counter>-->
<!-- <value>COVEREDRATIO</value>-->
<!-- <minimum>${jacoco.coverage.target.class}</minimum>-->
<!-- </limit>-->
</limits>
<excludes>
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory.**</exclude>
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory</exclude>
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
<!--<exclude>io.jenkins.plugins.todeclarative.converter.api.*</exclude>-->
</excludes>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<properties>
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
</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>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
@@ -506,7 +622,26 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
@@ -514,6 +649,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>
@@ -540,4 +687,13 @@
<archive>https://groups.google.com/forum/#!forum/github-api</archive>
</mailingList>
</mailingLists>
<developers>
<developer>
<name>Kohsuke Kawaguchi</name>
<id>kohsuke</id>
<email>kk@kohsuke.org</email>
</developer>
</developers>
</project>

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

@@ -29,6 +29,10 @@ public abstract class AbuseLimitHandler {
* @throws IOException
* on failure
* @see <a href="https://developer.github.com/v3/#abuse-rate-limits">API documentation from GitHub</a>
* @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,35 +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;
/**
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD",
justification = "Being constructed by JSON deserialization")
class DeleteToken {
public String delete_token;
}

View File

@@ -39,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;
}
@@ -58,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;
}
@@ -77,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;
}
@@ -96,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;
}
@@ -115,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;
}
@@ -134,13 +144,15 @@ 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;
}
public URL getHtmlUrl() {
return GitHub.parseURL(htmlUrl);
return GitHubClient.parseURL(htmlUrl);
}
/**
@@ -157,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;
}
@@ -178,9 +192,10 @@ public class GHApp extends GHObject {
@Preview
@Deprecated
public PagedIterable<GHAppInstallation> listInstallations() {
return root.retrieve()
return root.createRequest()
.withPreview(MACHINE_MAN)
.asPagedIterable("/app/installations", GHAppInstallation[].class, item -> item.wrapUp(root));
.withUrlPath("/app/installations")
.toIterable(GHAppInstallation[].class, item -> item.wrapUp(root));
}
/**
@@ -198,9 +213,10 @@ public class GHApp extends GHObject {
@Preview
@Deprecated
public GHAppInstallation getInstallationById(long id) throws IOException {
return root.retrieve()
return root.createRequest()
.withPreview(MACHINE_MAN)
.to(String.format("/app/installations/%d", id), GHAppInstallation.class)
.withUrlPath(String.format("/app/installations/%d", id))
.fetch(GHAppInstallation.class)
.wrapUp(root);
}
@@ -220,9 +236,10 @@ public class GHApp extends GHObject {
@Preview
@Deprecated
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
return root.retrieve()
return root.createRequest()
.withPreview(MACHINE_MAN)
.to(String.format("/orgs/%s/installation", name), GHAppInstallation.class)
.withUrlPath(String.format("/orgs/%s/installation", name))
.fetch(GHAppInstallation.class)
.wrapUp(root);
}
@@ -244,9 +261,10 @@ public class GHApp extends GHObject {
@Preview
@Deprecated
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
return root.retrieve()
return root.createRequest()
.withPreview(MACHINE_MAN)
.to(String.format("/repos/%s/%s/installation", ownerName, repositoryName), GHAppInstallation.class)
.withUrlPath(String.format("/repos/%s/%s/installation", ownerName, repositoryName))
.fetch(GHAppInstallation.class)
.wrapUp(root);
}
@@ -265,9 +283,10 @@ public class GHApp extends GHObject {
@Preview
@Deprecated
public GHAppInstallation getInstallationByUser(String name) throws IOException {
return root.retrieve()
return root.createRequest()
.withPreview(MACHINE_MAN)
.to(String.format("/users/%s/installation", name), GHAppInstallation.class)
.withUrlPath(String.format("/users/%s/installation", name))
.fetch(GHAppInstallation.class)
.wrapUp(root);
}

View File

@@ -12,6 +12,7 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
*
* @author Paulo Miguel Almeida
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
* @see GHAppInstallation#createToken() GHAppInstallation#createToken()
*/
public class GHAppCreateTokenBuilder {
private final GitHub root;
@@ -20,11 +21,17 @@ public class GHAppCreateTokenBuilder {
@Preview
@Deprecated
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail) {
this.root = root;
this.apiUrlTail = apiUrlTail;
this.builder = new Requester(root);
withPermissions(builder, permissions);
this.builder = root.createRequest();
}
@Preview
@Deprecated
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
this(root, apiUrlTail);
permissions(permissions);
}
/**
@@ -43,6 +50,25 @@ public class GHAppCreateTokenBuilder {
return this;
}
/**
* Set the permissions granted to the access token. The permissions object includes the permission names and their
* access type.
*
* @param permissions
* Map containing the permission names and types.
* @return a GHAppCreateTokenBuilder
*/
@Preview
@Deprecated
public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permissions) {
Map<String, String> retMap = new HashMap<>();
for (Map.Entry<String, GHPermissionType> entry : permissions.entrySet()) {
retMap.put(entry.getKey(), GitHubRequest.transformEnum(entry.getValue()));
}
builder.with("permissions", retMap);
return this;
}
/**
* Creates an app token with all the parameters.
* <p>
@@ -57,16 +83,9 @@ public class GHAppCreateTokenBuilder {
public GHAppInstallationToken create() throws IOException {
return builder.method("POST")
.withPreview(MACHINE_MAN)
.to(apiUrlTail, GHAppInstallationToken.class)
.withUrlPath(apiUrlTail)
.fetch(GHAppInstallationToken.class)
.wrapUp(root);
}
private static Requester withPermissions(Requester builder, Map<String, GHPermissionType> value) {
Map<String, String> retMap = new HashMap<String, String>();
for (Map.Entry<String, GHPermissionType> entry : value.entrySet()) {
retMap.put(entry.getKey(), Requester.transformEnum(entry.getValue()));
}
return builder.with("permissions", retMap);
}
}

View File

@@ -42,7 +42,7 @@ public class GHAppInstallation extends GHObject {
private String htmlUrl;
public URL getHtmlUrl() {
return GitHub.parseURL(htmlUrl);
return GitHubClient.parseURL(htmlUrl);
}
/**
@@ -59,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;
}
@@ -78,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;
}
@@ -97,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;
}
@@ -116,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;
}
@@ -135,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;
}
@@ -154,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;
}
@@ -173,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;
}
@@ -192,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;
}
@@ -211,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;
}
@@ -230,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;
}
@@ -249,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;
}
@@ -271,7 +293,11 @@ public class GHAppInstallation extends GHObject {
@Preview
@Deprecated
public void deleteInstallation() throws IOException {
root.retrieve().method("DELETE").withPreview(GAMBIT).to(String.format("/app/installations/%d", id));
root.createRequest()
.method("DELETE")
.withPreview(GAMBIT)
.withUrlPath(String.format("/app/installations/%d", getId()))
.send();
}
/**
@@ -283,11 +309,29 @@ public class GHAppInstallation extends GHObject {
*
* @param permissions
* map of permissions for the created token
* @return a GHAppCreateTokenBuilder on error
* @return a GHAppCreateTokenBuilder instance
* @deprecated Use {@link GHAppInstallation#createToken()} instead.
*/
@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);
}
/**
* Starts a builder that creates a new App Installation Token.
*
* <p>
* You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
* finally create an access token.
*
* @return a GHAppCreateTokenBuilder instance
*/
@Preview
@Deprecated
public GHAppCreateTokenBuilder createToken() {
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", getId()));
}
}

View File

@@ -37,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;
}
@@ -56,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;
}
@@ -75,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;
}
@@ -94,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;
}
@@ -113,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;
}
@@ -127,7 +137,7 @@ public class GHAppInstallationToken {
*/
@WithBridgeMethods(value = String.class, adapterMethod = "expiresAtStr")
public Date getExpiresAt() throws IOException {
return GitHub.parseDate(expires_at);
return GitHubClient.parseDate(expires_at);
}
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getExpiresAt")

View File

@@ -135,7 +135,7 @@ public class GHAsset extends GHObject {
}
private void edit(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}
/**
@@ -145,11 +145,11 @@ public class GHAsset extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").to(getApiRoute());
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
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

@@ -96,7 +96,7 @@ public class GHAuthorization extends GHObject {
* @return the app url
*/
public URL getAppUrl() {
return GitHub.parseURL(app.url);
return GitHubClient.parseURL(app.url);
}
/**
@@ -112,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 GitHub.parseURL(url);
return getUrl();
}
/**
@@ -141,7 +143,7 @@ public class GHAuthorization extends GHObject {
* @return the note url
*/
public URL getNoteUrl() {
return GitHub.parseURL(note_url);
return GitHubClient.parseURL(note_url);
}
/**

View File

@@ -1,11 +1,9 @@
package org.kohsuke.github;
import org.apache.commons.codec.binary.Base64InputStream;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.Base64;
/**
* The type GHBlob.
@@ -26,7 +24,7 @@ public class GHBlob {
* @return API URL of this blob.
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -73,8 +71,9 @@ public class GHBlob {
public InputStream read() {
if (encoding.equals("base64")) {
try {
return new Base64InputStream(new ByteArrayInputStream(content.getBytes("US-ASCII")), false);
} catch (UnsupportedEncodingException e) {
Base64.Decoder decoder = Base64.getMimeDecoder();
return new ByteArrayInputStream(decoder.decode(content));
} catch (IllegalArgumentException e) {
throw new AssertionError(e); // US-ASCII is mandatory
}
}

View File

@@ -1,8 +1,7 @@
package org.kohsuke.github;
import org.apache.commons.codec.binary.Base64;
import java.io.IOException;
import java.util.Base64;
/**
* Builder pattern for creating a new blob. Based on https://developer.github.com/v3/git/blobs/#create-a-blob
@@ -13,7 +12,7 @@ public class GHBlobBuilder {
GHBlobBuilder(GHRepository repo) {
this.repo = repo;
req = new Requester(repo.root);
req = repo.root.createRequest();
}
/**
@@ -37,7 +36,7 @@ public class GHBlobBuilder {
* @return a GHBlobBuilder
*/
public GHBlobBuilder binaryContent(byte[] content) {
String base64Content = Base64.encodeBase64String(content);
String base64Content = Base64.getEncoder().encodeToString(content);
req.with("content", base64Content);
req.with("encoding", "base64");
return this;
@@ -55,6 +54,6 @@ public class GHBlobBuilder {
* if the blob cannot be created.
*/
public GHBlob create() throws IOException {
return req.method("POST").to(getApiTail(), GHBlob.class);
return req.method("POST").withUrlPath(getApiTail()).fetch(GHBlob.class);
}
}

View File

@@ -9,7 +9,7 @@ import java.net.URL;
import java.util.Collection;
import java.util.Objects;
import static org.kohsuke.github.Previews.*;
import javax.annotation.CheckForNull;
/**
* A branch in a repository.
@@ -92,7 +92,7 @@ public class GHBranch {
@Preview
@Deprecated
public URL getProtectionUrl() {
return GitHub.parseURL(protection_url);
return GitHubClient.parseURL(protection_url);
}
/**
@@ -103,7 +103,11 @@ public class GHBranch {
* the io exception
*/
public GHBranchProtection getProtection() throws IOException {
return root.retrieve().to(protection_url, GHBranchProtection.class).wrap(this);
return root.createRequest()
.withPreview(Previews.LUKE_CAGE)
.setRawUrlPath(protection_url)
.fetch(GHBranchProtection.class)
.wrap(this);
}
/**
@@ -122,7 +126,7 @@ public class GHBranch {
* if disabling protection fails
*/
public void disableProtection() throws IOException {
new Requester(root).method("DELETE").to(protection_url);
root.createRequest().method("DELETE").setRawUrlPath(protection_url).send();
}
/**
@@ -163,6 +167,59 @@ public class GHBranch {
}
}
/**
* Merge a branch into this branch.
*
* @param headBranch
* the branch whose head will be merged
*
* @param commitMessage
* the commit message
*
* @return the merge {@link GHCommit} created, or {@code null} if the base already contains the head (nothing to
* merge).
*
* @throws IOException
* if merging fails
*/
@CheckForNull
public GHCommit merge(GHBranch headBranch, String commitMessage) throws IOException {
return merge(headBranch.getName(), commitMessage);
}
/**
* Merge a ref into this branch.
*
* @param head
* the ref name that will be merged into this branch. Follows the usual ref naming rules, could be a
* branch name, tag, or commit sha.
*
* @param commitMessage
* the commit message
*
* @return the merge {@link GHCommit} created, or {@code null} if the base already contains the head (nothing to
* merge).
*
* @throws IOException
* if merging fails
*/
@CheckForNull
public GHCommit merge(String head, String commitMessage) throws IOException {
GHCommit result = root.createRequest()
.withUrlPath(owner.getApiTailUrl("merges"))
.method("POST")
.with("commit_message", commitMessage)
.with("base", this.name)
.with("head", head)
.fetch(GHCommit.class);
if (result != null) {
result.wrapUp(owner);
}
return result;
}
String getApiRoute() {
return owner.getApiTailUrl("/branches/" + name);
}

View File

@@ -10,6 +10,8 @@ import static org.kohsuke.github.Previews.ZZZAX;
/**
* The type GHBranchProtection.
*
* @see <a href="https://docs.github.com/en/rest/reference/repos#get-branch-protection">GitHub Branch Protection</a>
*/
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
@@ -44,7 +46,7 @@ public class GHBranchProtection {
@Preview
@Deprecated
public void enabledSignedCommits() throws IOException {
requester().method("POST").to(url + REQUIRE_SIGNATURES_URI, RequiredSignatures.class);
requester().method("POST").withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class);
}
/**
@@ -56,7 +58,7 @@ public class GHBranchProtection {
@Preview
@Deprecated
public void disableSignedCommits() throws IOException {
requester().method("DELETE").to(url + REQUIRE_SIGNATURES_URI);
requester().method("DELETE").withUrlPath(url + REQUIRE_SIGNATURES_URI).send();
}
/**
@@ -87,7 +89,7 @@ public class GHBranchProtection {
@Preview
@Deprecated
public boolean getRequiredSignatures() throws IOException {
return requester().method("GET").to(url + REQUIRE_SIGNATURES_URI, RequiredSignatures.class).enabled;
return requester().withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class).enabled;
}
/**
@@ -123,7 +125,7 @@ public class GHBranchProtection {
}
private Requester requester() {
return new Requester(root).withPreview(ZZZAX);
return root.createRequest().withPreview(ZZZAX);
}
/**

View File

@@ -93,7 +93,8 @@ public class GHBranchProtectionBuilder {
.withNullable("required_pull_request_reviews", prReviews)
.withNullable("restrictions", restrictions)
.withNullable("enforce_admins", enforceAdmins)
.to(branch.getProtectionUrl().toString(), GHBranchProtection.class)
.withUrlPath(branch.getProtectionUrl().toString())
.fetch(GHBranchProtection.class)
.wrap(branch);
}
@@ -352,7 +353,7 @@ public class GHBranchProtectionBuilder {
}
private Requester requester() {
return new Requester(branch.getRoot()).withPreview(LUKE_CAGE);
return branch.getRoot().createRequest().withPreview(LUKE_CAGE);
}
private static class Restrictions {

View File

@@ -0,0 +1,295 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
* Represents a check 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 {
@JsonProperty("repository")
GHRepository owner;
GitHub root;
private String status;
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;
wrap(owner.root);
return this;
}
GHCheckRun wrap(GitHub root) {
this.root = root;
if (owner != null) {
owner.wrap(root);
if (pullRequests != null && pullRequests.length != 0) {
for (GHPullRequest singlePull : pullRequests) {
singlePull.wrap(owner);
}
}
}
if (checkSuite != null) {
if (owner != null) {
checkSuite.wrap(owner);
} else {
checkSuite.wrap(root);
}
}
if (app != null) {
app.wrapUp(root);
}
return this;
}
GHPullRequest[] wrap() {
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;
}
/**
* Final conclusion of the check.
*
* From <a href="https://docs.github.com/en/rest/reference/checks#create-a-check-run--parameters">Check Run
* Parameters - <code>conclusion</code></a>.
*/
public static enum Conclusion {
SUCCESS, FAILURE, NEUTRAL, CANCELLED, TIMED_OUT, ACTION_REQUIRED, SKIPPED
}
/**
* Gets the custom name of this check run.
*
* @return Name of the check run
*/
public String getName() {
return name;
}
/**
* Gets the HEAD SHA.
*
* @return sha for the HEAD commit
*/
public String getHeadSha() {
return headSha;
}
/**
* Gets the pull requests participated in this check run.
*
* Note this field is only populated for events. When getting a {@link GHCheckRun} outside of an event, this is
* always empty.
*
* @return the list of {@link GHPullRequest}s for this check run. Only populated for events.
* @throws IOException
* the io exception
*/
public List<GHPullRequest> getPullRequests() throws IOException {
if (pullRequests != null && pullRequests.length != 0) {
for (GHPullRequest singlePull : pullRequests) {
// Only refresh if we haven't do so before
singlePull.refresh(singlePull.getTitle());
}
return Collections.unmodifiableList(Arrays.asList(pullRequests));
}
return Collections.emptyList();
}
/**
* 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 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,260 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
* Represents a check suite.
*
* @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 {
@JsonProperty("repository")
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.wrap(owner.root);
return this;
}
GHCheckSuite wrap(GitHub root) {
this.root = root;
if (owner != null) {
owner.wrap(root);
if (pullRequests != null && pullRequests.length != 0) {
for (GHPullRequest singlePull : pullRequests) {
singlePull.wrap(owner);
}
}
}
if (app != null) {
app.wrapUp(root);
}
return this;
}
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.
*
* Note this field is only populated for events. When getting a {@link GHCheckSuite} outside of an event, this is
* always empty.
*
* @return the list of {@link GHPullRequest}s for this check suite. Only populated for events.
* @throws IOException
* the io exception
*/
public List<GHPullRequest> getPullRequests() throws IOException {
if (pullRequests != null && pullRequests.length != 0) {
for (GHPullRequest singlePull : pullRequests) {
// Only refresh if we haven't do so before
singlePull.refresh(singlePull.getTitle());
}
return Collections.unmodifiableList(Arrays.asList(pullRequests));
}
return Collections.emptyList();
}
/**
* 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

@@ -39,6 +39,8 @@ public class GHCommit {
private int comment_count;
private GHVerification verification;
static class Tree {
String sha;
}
@@ -61,7 +63,7 @@ public class GHCommit {
* @return the authored date
*/
public Date getAuthoredDate() {
return GitHub.parseDate(author.date);
return GitHubClient.parseDate(author.date);
}
/**
@@ -80,7 +82,7 @@ public class GHCommit {
* @return the commit date
*/
public Date getCommitDate() {
return GitHub.parseDate(committer.date);
return GitHubClient.parseDate(committer.date);
}
/**
@@ -100,6 +102,15 @@ public class GHCommit {
public int getCommentCount() {
return comment_count;
}
/**
* Gets Verification Status.
*
* @return the Verification status
*/
public GHVerification getVerification() {
return verification;
}
}
/**
@@ -201,7 +212,7 @@ public class GHCommit {
* resolves to the actual content of the file.
*/
public URL getRawUrl() {
return GitHub.parseURL(raw_url);
return GitHubClient.parseURL(raw_url);
}
/**
@@ -212,7 +223,7 @@ public class GHCommit {
* that resolves to the HTML page that describes this file.
*/
public URL getBlobUrl() {
return GitHub.parseURL(blob_url);
return GitHubClient.parseURL(blob_url);
}
/**
@@ -326,7 +337,7 @@ public class GHCommit {
* "https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000"
*/
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -441,11 +452,10 @@ public class GHCommit {
* @return {@link PagedIterable} with all the commit comments in this repository.
*/
public PagedIterable<GHCommitComment> listComments() {
return owner.root.retrieve()
.asPagedIterable(
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
GHCommitComment[].class,
item -> item.wrap(owner));
return owner.root.createRequest()
.withUrlPath(
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha))
.toIterable(GHCommitComment[].class, item -> item.wrap(owner));
}
/**
@@ -466,12 +476,15 @@ public class GHCommit {
* if comment is not created
*/
public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException {
GHCommitComment r = new Requester(owner.root).with("body", body)
GHCommitComment r = owner.root.createRequest()
.method("POST")
.with("body", body)
.with("path", path)
.with("line", line)
.with("position", position)
.to(String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
GHCommitComment.class);
.withUrlPath(
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha))
.fetch(GHCommitComment.class);
return r.wrap(owner);
}
@@ -510,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.
*
@@ -518,7 +544,7 @@ public class GHCommit {
*/
void populate() throws IOException {
if (files == null && stats == null)
owner.root.retrieve().to(owner.getApiTailUrl("commits/" + sha), this);
owner.root.createRequest().withUrlPath(owner.getApiTailUrl("commits/" + sha)).fetchInto(this);
}
GHCommit wrapUp(GHRepository owner) {

View File

@@ -34,7 +34,7 @@ public class GHCommitBuilder {
GHCommitBuilder(GHRepository repo) {
this.repo = repo;
req = new Requester(repo.root);
req = repo.root.createRequest().method("POST");
}
/**
@@ -118,6 +118,6 @@ public class GHCommitBuilder {
*/
public GHCommit create() throws IOException {
req.with("parents", parents);
return req.method("POST").to(getApiTail(), GHCommit.class).wrapUp(repo);
return req.method("POST").withUrlPath(getApiTail()).fetch(GHCommit.class).wrapUp(repo);
}
}

View File

@@ -41,7 +41,7 @@ public class GHCommitComment extends GHObject implements Reactable {
* show this commit comment in a browser.
*/
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -113,25 +113,33 @@ public class GHCommitComment extends GHObject implements Reactable {
* the io exception
*/
public void update(String body) throws IOException {
new Requester(owner.root).with("body", body).method("PATCH").to(getApiTail(), GHCommitComment.class);
owner.root.createRequest()
.method("PATCH")
.with("body", body)
.withUrlPath(getApiTail())
.fetch(GHCommitComment.class);
this.body = body;
}
@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return owner.root.createRequest()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiTail() + "/reactions", GHReaction.class)
.withUrlPath(getApiTail() + "/reactions")
.fetch(GHReaction.class)
.wrap(owner.root);
}
@Preview
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.retrieve()
return owner.root.createRequest()
.withPreview(SQUIRREL_GIRL)
.asPagedIterable(getApiTail() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root));
.withUrlPath(getApiTail() + "/reactions")
.toIterable(GHReaction[].class, item -> item.wrap(owner.root));
}
/**
@@ -141,11 +149,11 @@ public class GHCommitComment extends GHObject implements Reactable {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiTail());
owner.root.createRequest().method("DELETE").withUrlPath(getApiTail()).send();
}
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

@@ -24,7 +24,7 @@ public class GHCommitQueryBuilder {
GHCommitQueryBuilder(GHRepository repo) {
this.repo = repo;
this.req = repo.root.retrieve(); // requester to build up
this.req = repo.root.createRequest(); // requester to build up
}
/**
@@ -83,7 +83,7 @@ public class GHCommitQueryBuilder {
* @return the gh commit query builder
*/
public GHCommitQueryBuilder since(Date dt) {
req.with("since", GitHub.printDate(dt));
req.with("since", GitHubClient.printDate(dt));
return this;
}
@@ -106,7 +106,7 @@ public class GHCommitQueryBuilder {
* @return the gh commit query builder
*/
public GHCommitQueryBuilder until(Date dt) {
req.with("until", GitHub.printDate(dt));
req.with("until", GitHubClient.printDate(dt));
return this;
}
@@ -127,6 +127,6 @@ public class GHCommitQueryBuilder {
* @return the paged iterable
*/
public PagedIterable<GHCommit> list() {
return req.asPagedIterable(repo.getApiTailUrl("commits"), GHCommit[].class, item -> item.wrapUp(repo));
return req.withUrlPath(repo.getApiTailUrl("commits")).toIterable(GHCommit[].class, item -> item.wrapUp(repo));
}
}

View File

@@ -259,7 +259,7 @@ public class GHCommitSearchBuilder extends GHSearchBuilder<GHCommit> {
if (StringUtils.isBlank(commitUrl)) {
return null;
}
int indexOfUsername = (GitHub.GITHUB_URL + "/repos/").length();
int indexOfUsername = (GitHubClient.GITHUB_URL + "/repos/").length();
String[] tokens = commitUrl.substring(indexOfUsername).split("/", 3);
return tokens[0] + '/' + tokens[1];
}

View File

@@ -27,7 +27,7 @@ public class GHCompare {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -36,7 +36,7 @@ public class GHCompare {
* @return the html url
*/
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -45,7 +45,7 @@ public class GHCompare {
* @return the permalink url
*/
public URL getPermalinkUrl() {
return GitHub.parseURL(permalink_url);
return GitHubClient.parseURL(permalink_url);
}
/**
@@ -54,7 +54,7 @@ public class GHCompare {
* @return the diff url
*/
public URL getDiffUrl() {
return GitHub.parseURL(diff_url);
return GitHubClient.parseURL(diff_url);
}
/**
@@ -63,7 +63,7 @@ public class GHCompare {
* @return the patch url
*/
public URL getPatchUrl() {
return GitHub.parseURL(patch_url);
return GitHubClient.parseURL(patch_url);
}
/**

View File

@@ -1,13 +1,12 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Base64InputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
/**
* A Content of a repository.
@@ -31,6 +30,7 @@ public class GHContent implements Refreshable {
private String sha;
private String name;
private String path;
private String target;
private String content;
private String url; // this is the API url
private String git_url; // this is the Blob url
@@ -100,6 +100,15 @@ public class GHContent implements Refreshable {
return path;
}
/**
* Gets target of a symlink. This will only be set if {@code "symlink".equals(getType())}
*
* @return the target
*/
public String getTarget() {
return target;
}
/**
* Retrieve the decoded content that is stored at this location.
*
@@ -114,7 +123,7 @@ public class GHContent implements Refreshable {
*/
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
public String getContent() throws IOException {
return new String(Base64.decodeBase64(getEncodedContent()));
return new String(Base64.getMimeDecoder().decode(getEncodedContent()));
}
/**
@@ -175,8 +184,9 @@ public class GHContent implements Refreshable {
refresh(content);
if (encoding.equals("base64")) {
try {
return new Base64InputStream(new ByteArrayInputStream(content.getBytes("US-ASCII")), false);
} catch (UnsupportedEncodingException e) {
Base64.Decoder decoder = Base64.getMimeDecoder();
return new ByteArrayInputStream(decoder.decode(content.getBytes(StandardCharsets.US_ASCII)));
} catch (IllegalArgumentException e) {
throw new AssertionError(e); // US-ASCII is mandatory
}
}
@@ -223,7 +233,7 @@ public class GHContent implements Refreshable {
* the io exception
*/
protected synchronized void populate() throws IOException {
root.retrieve().to(url, this);
root.createRequest().withUrlPath(url).fetchInto(this);
}
/**
@@ -237,7 +247,7 @@ public class GHContent implements Refreshable {
if (!isDirectory())
throw new IllegalStateException(path + " is not a directory");
return root.retrieve().asPagedIterable(url, GHContent[].class, item -> item.wrap(repository));
return root.createRequest().setRawUrlPath(url).toIterable(GHContent[].class, item -> item.wrap(repository));
}
/**
@@ -304,9 +314,11 @@ public class GHContent implements Refreshable {
*/
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch)
throws IOException {
String encodedContent = Base64.encodeBase64String(newContentBytes);
String encodedContent = Base64.getEncoder().encodeToString(newContentBytes);
Requester requester = new Requester(root).with("path", path)
Requester requester = root.createRequest()
.method("POST")
.with("path", path)
.with("message", commitMessage)
.with("sha", sha)
.with("content", encodedContent)
@@ -316,7 +328,8 @@ public class GHContent implements Refreshable {
requester.with("branch", branch);
}
GHContentUpdateResponse response = requester.to(getApiRoute(repository, path), GHContentUpdateResponse.class);
GHContentUpdateResponse response = requester.withUrlPath(getApiRoute(repository, path))
.fetch(GHContentUpdateResponse.class);
response.getContent().wrap(repository);
response.getCommit().wrapUp(repository);
@@ -350,7 +363,9 @@ public class GHContent implements Refreshable {
* the io exception
*/
public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException {
Requester requester = new Requester(root).with("path", path)
Requester requester = root.createRequest()
.method("POST")
.with("path", path)
.with("message", commitMessage)
.with("sha", sha)
.method("DELETE");
@@ -359,7 +374,8 @@ public class GHContent implements Refreshable {
requester.with("branch", branch);
}
GHContentUpdateResponse response = requester.to(getApiRoute(repository, path), GHContentUpdateResponse.class);
GHContentUpdateResponse response = requester.withUrlPath(getApiRoute(repository, path))
.fetch(GHContentUpdateResponse.class);
response.getCommit().wrapUp(repository);
return response;
@@ -382,22 +398,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.
*
@@ -405,6 +405,6 @@ public class GHContent implements Refreshable {
*/
@Override
public synchronized void refresh() throws IOException {
root.retrieve().to(url, this);
root.createRequest().setRawUrlPath(url).fetchInto(this);
}
}

View File

@@ -1,9 +1,8 @@
package org.kohsuke.github;
import org.apache.commons.codec.binary.Base64;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
/**
* Used to create/update content.
@@ -21,7 +20,7 @@ public final class GHContentBuilder {
GHContentBuilder(GHRepository repo) {
this.repo = repo;
this.req = new Requester(repo.root).method("PUT");
this.req = repo.root.createRequest().method("PUT");
}
/**
@@ -50,7 +49,7 @@ public final class GHContentBuilder {
}
/**
* Used when updating (but not creating a new content) to specify Thetblob SHA of the file being replaced.
* Used when updating (but not creating a new content) to specify the blob SHA of the file being replaced.
*
* @param sha
* the sha
@@ -69,7 +68,7 @@ public final class GHContentBuilder {
* @return the gh content builder
*/
public GHContentBuilder content(byte[] content) {
req.with("content", Base64.encodeBase64String(content));
req.with("content", Base64.getEncoder().encodeToString(content));
return this;
}
@@ -81,11 +80,7 @@ public final class GHContentBuilder {
* @return the gh content builder
*/
public GHContentBuilder content(String content) {
try {
return content(content.getBytes("UTF-8"));
} catch (UnsupportedEncodingException x) {
throw new AssertionError();
}
return content(content.getBytes(StandardCharsets.UTF_8));
}
/**
@@ -108,7 +103,8 @@ public final class GHContentBuilder {
* the io exception
*/
public GHContentUpdateResponse commit() throws IOException {
GHContentUpdateResponse response = req.to(GHContent.getApiRoute(repo, path), GHContentUpdateResponse.class);
GHContentUpdateResponse response = req.withUrlPath(GHContent.getApiRoute(repo, path))
.fetch(GHContentUpdateResponse.class);
response.getContent().wrap(repo);
response.getCommit().wrapUp(repo);

View File

@@ -3,6 +3,8 @@ package org.kohsuke.github;
import java.io.IOException;
import java.net.URL;
import static org.kohsuke.github.Previews.BAPTISE;
/**
* Creates a repository
*
@@ -11,12 +13,12 @@ import java.net.URL;
public class GHCreateRepositoryBuilder {
private final GitHub root;
protected final Requester builder;
private final String apiUrlTail;
private String apiUrlTail;
GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) {
this.root = root;
this.apiUrlTail = apiUrlTail;
this.builder = new Requester(root);
this.builder = root.createRequest();
this.builder.with("name", name);
}
@@ -79,6 +81,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
*
@@ -188,6 +202,51 @@ public class GHCreateRepositoryBuilder {
return this;
}
/**
* Specifies whether the repository is a template.
*
* @param enabled
* true if enabled
* @return a builder to continue with building
*/
@Preview
@Deprecated
public GHCreateRepositoryBuilder templateRepository(boolean enabled) {
this.builder.withPreview(BAPTISE);
this.builder.with("is_template", enabled);
return this;
}
/**
* Specifies the ownership of the repository.
*
* @param owner
* organization or personage
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder owner(String owner) {
this.builder.with("owner", owner);
return this;
}
/**
* Create repository from template repository.
*
* @param templateOwner
* template repository owner
* @param templateRepo
* template repository
* @return a builder to continue with building
* @see <a href="https://developer.github.com/v3/previews/">GitHub API Previews</a>
*/
@Preview
@Deprecated
public GHCreateRepositoryBuilder fromTemplateRepository(String templateOwner, String templateRepo) {
this.builder.withPreview(BAPTISE);
this.apiUrlTail = "/repos/" + templateOwner + "/" + templateRepo + "/generate";
return this;
}
/**
* Creates a repository with all the parameters.
*
@@ -196,7 +255,7 @@ public class GHCreateRepositoryBuilder {
* if repsitory cannot be created
*/
public GHRepository create() throws IOException {
return builder.method("POST").to(apiUrlTail, GHRepository.class).wrap(root);
return builder.method("POST").withUrlPath(apiUrlTail).fetch(GHRepository.class).wrap(root);
}
}

View File

@@ -82,7 +82,9 @@ public class GHDeployKey {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE")
.to(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id));
owner.root.createRequest()
.method("DELETE")
.withUrlPath(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id))
.send();
}
}

View File

@@ -2,6 +2,7 @@ package org.kohsuke.github;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
/**
* Represents a deployment
@@ -38,7 +39,7 @@ public class GHDeployment extends GHObject {
* @return the statuses url
*/
public URL getStatusesUrl() {
return GitHub.parseURL(statuses_url);
return GitHubClient.parseURL(statuses_url);
}
/**
@@ -47,7 +48,7 @@ public class GHDeployment extends GHObject {
* @return the repository url
*/
public URL getRepositoryUrl() {
return GitHub.parseURL(repository_url);
return GitHubClient.parseURL(repository_url);
}
/**
@@ -60,7 +61,8 @@ public class GHDeployment extends GHObject {
}
/**
* Gets payload.
* Gets payload. <b>NOTE:</b> only use this method if you can guarantee the payload will be a simple string,
* otherwise use {@link #getPayloadObject()}.
*
* @return the payload
*/
@@ -68,6 +70,25 @@ public class GHDeployment extends GHObject {
return (String) payload;
}
/**
* Gets payload. <b>NOTE:</b> only use this method if you can guarantee the payload will be a JSON object (Map),
* otherwise use {@link #getPayloadObject()}.
*
* @return the payload
*/
public Map<String, Object> getPayloadMap() {
return (Map<String, Object>) payload;
}
/**
* Gets payload without assuming its type. It could be a String or a Map.
*
* @return the payload
*/
public Object getPayloadObject() {
return payload;
}
/**
* Gets environment.
*
@@ -122,7 +143,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);
}
/**
@@ -131,7 +152,9 @@ public class GHDeployment extends GHObject {
* @return the paged iterable
*/
public PagedIterable<GHDeploymentStatus> listStatuses() {
return root.retrieve().asPagedIterable(statuses_url, GHDeploymentStatus[].class, item -> item.wrap(owner));
return root.createRequest()
.withUrlPath(statuses_url)
.toIterable(GHDeploymentStatus[].class, item -> item.wrap(owner));
}
}

View File

@@ -19,7 +19,7 @@ public class GHDeploymentBuilder {
*/
public GHDeploymentBuilder(GHRepository repo) {
this.repo = repo;
this.builder = new Requester(repo.root);
this.builder = repo.root.createRequest().method("POST");
}
/**
@@ -127,6 +127,6 @@ public class GHDeploymentBuilder {
* the io exception
*/
public GHDeployment create() throws IOException {
return builder.to(repo.getApiTailUrl("deployments"), GHDeployment.class).wrap(repo);
return builder.withUrlPath(repo.getApiTailUrl("deployments")).fetch(GHDeployment.class).wrap(repo);
}
}

View File

@@ -37,7 +37,7 @@ public class GHDeploymentStatus extends GHObject {
* @return the target url
*/
public URL getTargetUrl() {
return GitHub.parseURL(target_url);
return GitHubClient.parseURL(target_url);
}
/**
@@ -46,7 +46,7 @@ public class GHDeploymentStatus extends GHObject {
* @return the deployment url
*/
public URL getDeploymentUrl() {
return GitHub.parseURL(deployment_url);
return GitHubClient.parseURL(deployment_url);
}
/**
@@ -55,7 +55,7 @@ public class GHDeploymentStatus extends GHObject {
* @return the repository url
*/
public URL getRepositoryUrl() {
return GitHub.parseURL(repository_url);
return GitHubClient.parseURL(repository_url);
}
/**

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);
}
@@ -30,7 +31,7 @@ public class GHDeploymentStatusBuilder {
GHDeploymentStatusBuilder(GHRepository repo, long deploymentId, GHDeploymentState state) {
this.repo = repo;
this.deploymentId = deploymentId;
this.builder = new Requester(repo.root);
this.builder = repo.root.createRequest().method("POST");
this.builder.with("state", state);
}
@@ -66,7 +67,8 @@ public class GHDeploymentStatusBuilder {
* the io exception
*/
public GHDeploymentStatus create() throws IOException {
return builder.to(repo.getApiTailUrl("deployments/" + deploymentId + "/statuses"), GHDeploymentStatus.class)
return builder.withUrlPath(repo.getApiTailUrl("deployments/" + deploymentId + "/statuses"))
.fetch(GHDeploymentStatus.class)
.wrap(repo);
}
}

View File

@@ -0,0 +1,232 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.IOException;
import java.net.URL;
import java.util.Objects;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
/**
* A discussion in GitHub Team.
*
* @author Charles Moulliard
* @see <a href="https://developer.github.com/v3/teams/discussions">GitHub Team Discussions</a>
*/
public class GHDiscussion extends GHObject {
@JacksonInject
private GitHub root;
private GHTeam team;
private long number;
private String body, title, htmlUrl;
@JsonProperty(value = "private")
private boolean isPrivate;
@Override
public URL getHtmlUrl() throws IOException {
return GitHubClient.parseURL(htmlUrl);
}
GHDiscussion wrapUp(GHTeam team) {
this.team = team;
return this;
}
/**
* Get the team to which this discussion belongs.
*
* @return the team for this discussion
*/
@Nonnull
public GHTeam getTeam() {
return team;
}
/**
* Get the title of the discussion.
*
* @return the title
*/
public String getTitle() {
return title;
}
/**
* The description of this discussion.
*
* @return the body
*/
public String getBody() {
return body;
}
/**
* The number of this discussion.
*
* @return the number
*/
public long getNumber() {
return number;
}
/**
* The id number of this discussion. GitHub discussions have "number" instead of "id". This is provided for
* convenience.
*
* @return the id number for this discussion
* @see #getNumber()
*/
@Override
public long getId() {
return getNumber();
}
/**
* Whether the discussion is private to the team.
*
* @return {@code true} if discussion is private.
*/
public boolean isPrivate() {
return isPrivate;
}
/**
* Begins the creation of a new instance.
*
* Consumer must call {@link GHDiscussion.Creator#done()} to commit changes.
*
* @param team
* the team in which the discussion will be created.
* @return a {@link GHLabel.Creator}
* @throws IOException
* the io exception
*/
static GHDiscussion.Creator create(GHTeam team) throws IOException {
return new GHDiscussion.Creator(team);
}
static GHDiscussion read(GHTeam team, long discussionNumber) throws IOException {
return team.root.createRequest()
.setRawUrlPath(getRawUrlPath(team, discussionNumber))
.fetch(GHDiscussion.class)
.wrapUp(team);
}
static PagedIterable<GHDiscussion> readAll(GHTeam team) throws IOException {
return team.root.createRequest()
.setRawUrlPath(getRawUrlPath(team, null))
.toIterable(GHDiscussion[].class, item -> item.wrapUp(team));
}
/**
* Begins a batch update
*
* Consumer must call {@link GHDiscussion.Updater#done()} to commit changes.
*
* @return a {@link GHDiscussion.Updater}
*/
@Preview
@Deprecated
public GHDiscussion.Updater update() {
return new GHDiscussion.Updater(this);
}
/**
* Begins a single property update.
*
* @return a {@link GHDiscussion.Setter}
*/
@Preview
@Deprecated
public GHDiscussion.Setter set() {
return new GHDiscussion.Setter(this);
}
/**
* Delete the discussion
*
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
team.root.createRequest().method("DELETE").setRawUrlPath(getRawUrlPath(team, number)).send();
}
private static String getRawUrlPath(@Nonnull GHTeam team, @CheckForNull Long discussionNumber) {
return team.getUrl().toString() + "/discussions" + (discussionNumber == null ? "" : "/" + discussionNumber);
}
/**
* A {@link GHLabelBuilder} that updates a single property per request
*
* {@link #done()} is called automatically after the property is set.
*/
public static class Setter extends GHDiscussionBuilder<GHDiscussion> {
private Setter(@Nonnull GHDiscussion base) {
super(GHDiscussion.class, base.team, base);
requester.method("PATCH").setRawUrlPath(base.getUrl().toString());
}
}
/**
* A {@link GHLabelBuilder} that allows multiple properties to be updated per request.
*
* Consumer must call {@link #done()} to commit changes.
*/
public static class Updater extends GHDiscussionBuilder<Updater> {
private Updater(@Nonnull GHDiscussion base) {
super(GHDiscussion.Updater.class, base.team, base);
requester.method("PATCH").setRawUrlPath(base.getUrl().toString());
}
}
/**
* A {@link GHLabelBuilder} that creates a new {@link GHLabel}
*
* Consumer must call {@link #done()} to create the new instance.
*/
public static class Creator extends GHDiscussionBuilder<Creator> {
private Creator(@Nonnull GHTeam team) {
super(GHDiscussion.Creator.class, team, null);
requester.method("POST").setRawUrlPath(getRawUrlPath(team, null));
}
/**
* Sets whether this discussion is private to this team.
*
* @param value
* privacy of this discussion
* @return either a continuing builder or an updated {@link GHDiscussion}
* @throws IOException
* if there is an I/O Exception
*/
@Nonnull
public Creator private_(boolean value) throws IOException {
return with("private", value);
}
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GHDiscussion that = (GHDiscussion) o;
return number == that.number && Objects.equals(getUrl(), that.getUrl()) && Objects.equals(team, that.team)
&& Objects.equals(body, that.body) && Objects.equals(title, that.title);
}
@Override
public int hashCode() {
return Objects.hash(team, number, body, title);
}
}

View File

@@ -0,0 +1,80 @@
package org.kohsuke.github;
import java.io.IOException;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
/**
* Base class for creating or updating a discussion.
*
* @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 GHDiscussionBuilder<S> extends AbstractBuilder<GHDiscussion, S> {
private final GHTeam team;
/**
*
* @param intermediateReturnType
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If
* {@link S} the same as {@link GHDiscussion}, this builder will commit changes after each call to
* {@link #with(String, Object)}.
* @param team
* the GitHub team. Updates will be sent to the root of this team.
* @param baseInstance
* instance on which to base this builder. If {@code null} a new instance will be created.
*/
protected GHDiscussionBuilder(@Nonnull Class<S> intermediateReturnType,
@Nonnull GHTeam team,
@CheckForNull GHDiscussion baseInstance) {
super(GHDiscussion.class, intermediateReturnType, team.root, baseInstance);
this.team = team;
if (baseInstance != null) {
requester.with("title", baseInstance.getTitle());
requester.with("body", baseInstance.getBody());
}
}
/**
* Title for this discussion.
*
* @param value
* title of discussion
* @return either a continuing builder or an updated {@link GHDiscussion}
* @throws IOException
* if there is an I/O Exception
*/
@Nonnull
public S title(String value) throws IOException {
return with("title", value);
}
/**
* Body content for this discussion.
*
* @param value
* body of discussion*
* @return either a continuing builder or an updated {@link GHDiscussion}
* @throws IOException
* if there is an I/O Exception
*/
@Nonnull
public S body(String value) throws IOException {
return with("body", value);
}
/**
* {@inheritDoc}
*/
@Nonnull
@Override
public GHDiscussion done() throws IOException {
return super.done().wrapUp(team);
}
}

View File

@@ -10,50 +10,61 @@ import java.util.Locale;
* @see <a href="https://developer.github.com/v3/activity/events/types/">Event type reference</a>
*/
public enum GHEvent {
CHECK_RUN,
CHECK_SUITE,
COMMIT_COMMENT,
CONTENT_REFERENCE,
CREATE,
DELETE,
DEPLOY_KEY,
DEPLOYMENT,
DEPLOYMENT_STATUS,
DOWNLOAD,
FOLLOW,
FORK,
FORK_APPLY,
GITHUB_APP_AUTHORIZATION,
GIST,
GOLLUM,
INSTALLATION,
INSTALLATION_REPOSITORIES,
INTEGRATION_INSTALLATION_REPOSITORIES,
CHECK_SUITE,
ISSUE_COMMENT,
ISSUES,
LABEL,
MARKETPLACE_PURCHASE,
MEMBER,
MEMBERSHIP,
META,
MILESTONE,
ORGANIZATION,
ORG_BLOCK,
PACKAGE,
PAGE_BUILD,
PROJECT_CARD,
PROJECT_COLUMN,
PROJECT,
PING,
PUBLIC,
PULL_REQUEST,
PULL_REQUEST_REVIEW,
PULL_REQUEST_REVIEW_COMMENT,
PUSH,
REGISTRY_PACKAGE,
RELEASE,
REPOSITORY, // only
// valid
// for
// org
// hooks
REPOSITORY_DISPATCH, // only valid for org hooks
REPOSITORY,
REPOSITORY_IMPORT,
REPOSITORY_VULNERABILITY_ALERT,
SECURITY_ADVISORY,
STAR,
STATUS,
TEAM,
TEAM_ADD,
WATCH,
PING,
WORKFLOW_DISPATCH,
WORKFLOW_RUN,
/**
* Special event type that means "every possible event"
*/

View File

@@ -78,7 +78,7 @@ public class GHEventInfo {
* @return the created at
*/
public Date getCreatedAt() {
return GitHub.parseDate(created_at);
return GitHubClient.parseDate(created_at);
}
/**
@@ -144,7 +144,7 @@ public class GHEventInfo {
* if payload cannot be parsed
*/
public <T extends GHEventPayload> T getPayload(Class<T> type) throws IOException {
T v = GitHub.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;
@@ -47,6 +48,313 @@ public abstract class GHEventPayload {
}
}
// List of events that still need to be added:
// ContentReferenceEvent
// DeployKeyEvent DownloadEvent FollowEvent ForkApplyEvent GitHubAppAuthorizationEvent GistEvent GollumEvent
// InstallationEvent InstallationRepositoriesEvent IssuesEvent LabelEvent MarketplacePurchaseEvent MemberEvent
// MembershipEvent MetaEvent MilestoneEvent OrganizationEvent OrgBlockEvent PackageEvent PageBuildEvent
// ProjectCardEvent ProjectColumnEvent ProjectEvent RepositoryDispatchEvent RepositoryImportEvent
// RepositoryVulnerabilityAlertEvent SecurityAdvisoryEvent StarEvent StatusEvent TeamEvent TeamAddEvent WatchEvent
/**
* A check run event has been created, rerequested, completed, or has a requested_action.
*
* @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 CheckRun extends GHEventPayload {
private String action;
private int number;
private GHCheckRun checkRun;
private GHRequestedAction requestedAction;
private GHRepository repository;
/**
* Gets action.
*
* @return the action
*/
public String getAction() {
return action;
}
/**
* Gets number.
*
* @return the number
*/
public int getNumber() {
return number;
}
/**
* Sets Check Run object
*
* @param currentCheckRun
* the check run object
*/
public void setCheckRun(GHCheckRun currentCheckRun) {
this.checkRun = currentCheckRun;
}
/**
* Gets Check Run object
*
* @return the current checkRun object
*/
public GHCheckRun getCheckRun() {
return checkRun;
}
/**
* Sets the Requested Action object
*
* @param currentRequestedAction
* the current action
*/
public void setCheckRun(GHRequestedAction currentRequestedAction) {
this.requestedAction = currentRequestedAction;
}
/**
* Gets the Requested Action object
*
* @return the requested action
*/
public GHRequestedAction getRequestedAction() {
return requestedAction;
}
/**
* Gets repository.
*
* @return the repository
*/
public GHRepository getRepository() {
repository.root = root;
return repository;
}
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);
if (checkRun == null)
throw new IllegalStateException(
"Expected check_run payload, but got something else. Maybe we've got another type of event?");
if (repository != null) {
repository.wrap(root);
checkRun.wrap(repository);
} else {
checkRun.wrap(root);
}
}
}
/**
* 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.
*
@@ -1325,6 +1633,107 @@ public abstract class GHEventPayload {
organization.wrapUp(root);
}
}
}
/**
* A git commit status was changed.
*
* @see <a href="https://developer.github.com/v3/activity/events/types/#statusevent">authoritative source</a>
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization")
public static class Status extends GHEventPayload {
private String context;
private String description;
private GHCommitState state;
private GHCommit commit;
private GHRepository repository;
/**
* Gets the status content.
*
* @return status content
*/
public String getContext() {
return context;
}
/**
* Gets the status description.
*
* @return status description
*/
public String getDescription() {
return description;
}
/**
* Gets the status state.
*
* @return status state
*/
public GHCommitState getState() {
return state;
}
/**
* Sets the status stage.
*
* @param state
* status state
*/
public void setState(GHCommitState state) {
this.state = state;
}
/**
* Gets the commit associated with the status event.
*
* @return commit
*/
public GHCommit getCommit() {
return commit;
}
/**
* Sets the commit associated with the status event.
*
* @param commit
* commit
*/
public void setCommit(GHCommit commit) {
this.commit = commit;
}
/**
* Gets the repository associated with the status event.
*
* @return repository
*/
public GHRepository getRepository() {
return repository;
}
/**
* Sets the repository associated with the status event.
*
* @param repository
* repository
*/
public void setRepository(GHRepository repository) {
this.repository = repository;
}
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);
if (state == null) {
throw new IllegalStateException(
"Expected status payload, but got something else. Maybe we've got another type of event?");
}
if (repository != null) {
repository.wrap(root);
commit.wrapUp(repository);
}
}
}
}

View File

@@ -1,11 +1,11 @@
package org.kohsuke.github;
import java.io.FileNotFoundException;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
/**
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
@@ -24,11 +24,24 @@ public class GHFileNotFoundException extends FileNotFoundException {
/**
* Instantiates a new Gh file not found exception.
*
* @param s
* the s
* @param message
* the message
*/
public GHFileNotFoundException(String s) {
super(s);
public GHFileNotFoundException(String message) {
super(message);
}
/**
* Instantiates a new Gh file not found exception.
*
* @param message
* the message
* @param cause
* the cause
*/
public GHFileNotFoundException(String message, Throwable cause) {
super(message);
this.initCause(cause);
}
/**
@@ -41,8 +54,8 @@ public class GHFileNotFoundException extends FileNotFoundException {
return responseHeaderFields;
}
GHFileNotFoundException withResponseHeaderFields(HttpURLConnection urlConnection) {
this.responseHeaderFields = urlConnection.getHeaderFields();
GHFileNotFoundException withResponseHeaderFields(@Nonnull Map<String, List<String>> headerFields) {
this.responseHeaderFields = headerFields;
return this;
}
}

View File

@@ -1,12 +1,13 @@
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;
@@ -20,8 +21,9 @@ import java.util.Map.Entry;
* @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;
@@ -34,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.
@@ -44,7 +82,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public GHUser getOwner() throws IOException {
return root.intern(owner);
return owner;
}
/**
@@ -83,8 +121,13 @@ public class GHGist extends GHObject {
return git_push_url;
}
/**
* Get the html url.
*
* @return the github html url
*/
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -140,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) {
@@ -182,7 +201,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public void star() throws IOException {
new Requester(root).method("PUT").to(getApiTailUrl("star"));
root.createRequest().method("PUT").withUrlPath(getApiTailUrl("star")).send();
}
/**
@@ -192,7 +211,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public void unstar() throws IOException {
new Requester(root).method("DELETE").to(getApiTailUrl("star"));
root.createRequest().method("DELETE").withUrlPath(getApiTailUrl("star")).send();
}
/**
@@ -203,7 +222,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public boolean isStarred() throws IOException {
return root.retrieve().asHttpStatusCode(getApiTailUrl("star")) / 100 == 2;
return root.createRequest().withUrlPath(getApiTailUrl("star")).fetchHttpStatusCode() / 100 == 2;
}
/**
@@ -214,7 +233,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public GHGist fork() throws IOException {
return new Requester(root).to(getApiTailUrl("forks"), GHGist.class).wrapUp(root);
return root.createRequest().method("POST").withUrlPath(getApiTailUrl("forks")).fetch(GHGist.class);
}
/**
@@ -223,7 +242,7 @@ public class GHGist extends GHObject {
* @return the paged iterable
*/
public PagedIterable<GHGist> listForks() {
return root.retrieve().asPagedIterable(getApiTailUrl("forks"), GHGist[].class, item -> item.wrapUp(root));
return root.createRequest().withUrlPath(getApiTailUrl("forks")).toIterable(GHGist[].class, null);
}
/**
@@ -233,7 +252,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").to("/gists/" + id);
root.createRequest().method("DELETE").withUrlPath("/gists/" + id).send();
}
/**
@@ -262,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,6 +4,8 @@ import java.io.IOException;
import java.util.Collections;
import java.util.LinkedHashMap;
import javax.annotation.Nonnull;
/**
* Builder pattern for creating a new Gist.
*
@@ -23,7 +25,7 @@ public class GHGistBuilder {
*/
public GHGistBuilder(GitHub root) {
this.root = root;
req = new Requester(root);
req = root.createRequest().method("POST");
}
/**
@@ -59,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;
}
@@ -73,6 +75,6 @@ public class GHGistBuilder {
*/
public GHGist create() throws IOException {
req.with("files", files);
return req.to("/gists", GHGist.class).wrapUp(root);
return req.withUrlPath("/gists").fetch(GHGist.class);
}
}

View File

@@ -1,8 +1,11 @@
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.
@@ -12,11 +15,11 @@ import java.util.LinkedHashMap;
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;
this.builder = new Requester(base.root);
this.builder = base.root.createRequest();
files = new LinkedHashMap<>();
}
@@ -32,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.
@@ -54,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;
}
@@ -70,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;
}
@@ -96,6 +122,6 @@ public class GHGistUpdater {
*/
public GHGist update() throws IOException {
builder.with("files", files);
return builder.method("PATCH").to(base.getApiTailUrl(""), GHGist.class).wrap(base.owner);
return builder.method("PATCH").withUrlPath(base.getApiTailUrl("")).fetch(GHGist.class);
}
}

View File

@@ -74,7 +74,7 @@ public abstract class GHHook extends GHObject {
* @see <a href="https://developer.github.com/v3/repos/hooks/#ping-a-hook">Ping hook</a>
*/
public void ping() throws IOException {
new Requester(getRoot()).method("POST").to(getApiRoute() + "/pings");
getRoot().createRequest().method("POST").withUrlPath(getApiRoute() + "/pings").send();
}
/**
@@ -84,7 +84,7 @@ public abstract class GHHook extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(getRoot()).method("DELETE").to(getApiRoute());
getRoot().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
/**

View File

@@ -28,8 +28,10 @@ class GHHooks {
*/
public List<GHHook> getHooks() throws IOException {
GHHook[] hookArray = root.retrieve().to(collection(), collectionClass()); // jdk/eclipse bug requires this
// to be on separate line
GHHook[] hookArray = root.createRequest().withUrlPath(collection()).fetch(collectionClass()); // jdk/eclipse
// bug
// requires this
// to be on separate line
List<GHHook> list = new ArrayList<GHHook>(Arrays.asList(hookArray));
for (GHHook h : list)
wrap(h);
@@ -46,7 +48,7 @@ class GHHooks {
* the io exception
*/
public GHHook getHook(int id) throws IOException {
GHHook hook = root.retrieve().to(collection() + "/" + id, clazz());
GHHook hook = root.createRequest().withUrlPath(collection() + "/" + id).fetch(clazz());
return wrap(hook);
}
@@ -74,11 +76,14 @@ class GHHooks {
ea.add(e.symbol());
}
GHHook hook = new Requester(root).with("name", name)
GHHook hook = root.createRequest()
.method("POST")
.with("name", name)
.with("active", active)
.with("config", config)
.with("events", ea)
.to(collection(), clazz());
.withUrlPath(collection())
.fetch(clazz());
return wrap(hook);
}

View File

@@ -1,11 +1,11 @@
package org.kohsuke.github;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
/**
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
@@ -31,6 +31,20 @@ public class GHIOException extends IOException {
super(message);
}
/**
* Constructs a {@code GHIOException} with the specified detail message and cause.
*
* @param message
* The detail message (which is saved for later retrieval by the {@link #getMessage()} method)
*
* @param cause
* The cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
* permitted, and indicates that the cause is nonexistent or unknown.)
*/
public GHIOException(String message, Throwable cause) {
super(message, cause);
}
/**
* Gets response header fields.
*
@@ -41,8 +55,8 @@ public class GHIOException extends IOException {
return responseHeaderFields;
}
GHIOException withResponseHeaderFields(HttpURLConnection urlConnection) {
this.responseHeaderFields = urlConnection.getHeaderFields();
GHIOException withResponseHeaderFields(@Nonnull Map<String, List<String>> headerFields) {
this.responseHeaderFields = headerFields;
return this;
}
}

View File

@@ -36,7 +36,7 @@ public class GHInvitation extends GHObject {
* the io exception
*/
public void accept() throws IOException {
root.retrieve().method("PATCH").to("/user/repository_invitations/" + id);
root.createRequest().method("PATCH").withUrlPath("/user/repository_invitations/" + id).send();
}
/**
@@ -46,11 +46,11 @@ public class GHInvitation extends GHObject {
* the io exception
*/
public void decline() throws IOException {
root.retrieve().method("DELETE").to("/user/repository_invitations/" + id);
root.createRequest().method("DELETE").withUrlPath("/user/repository_invitations/" + id).send();
}
@Override
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
}

View File

@@ -26,6 +26,7 @@ package org.kohsuke.github;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.net.URL;
@@ -36,6 +37,7 @@ 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;
@@ -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.
*
@@ -137,7 +124,7 @@ public class GHIssue extends GHObject implements Reactable {
* The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100
*/
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -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);
}
/**
@@ -187,16 +174,18 @@ public class GHIssue extends GHObject implements Reactable {
* @return the closed at
*/
public Date getClosedAt() {
return GitHub.parseDate(closed_at);
return GitHubClient.parseDate(closed_at);
}
/**
* Gets api url.
*
* @return the api url
* @return API URL of this object.
* @deprecated use {@link #getUrl()}
*/
@Deprecated
public URL getApiURL() {
return GitHub.parseURL(url);
return getUrl();
}
/**
@@ -206,7 +195,7 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void lock() throws IOException {
new Requester(root).method("PUT").to(getApiRoute() + "/lock");
root.createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
}
/**
@@ -216,7 +205,7 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void unlock() throws IOException {
new Requester(root).method("PUT").to(getApiRoute() + "/lock");
root.createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
}
/**
@@ -230,17 +219,27 @@ public class GHIssue extends GHObject implements Reactable {
*/
@WithBridgeMethods(void.class)
public GHIssueComment comment(String message) throws IOException {
GHIssueComment r = new Requester(root).with("body", message)
.to(getIssuesApiRoute() + "/comments", GHIssueComment.class);
GHIssueComment r = root.createRequest()
.method("POST")
.with("body", message)
.withUrlPath(getIssuesApiRoute() + "/comments")
.fetch(GHIssueComment.class);
return r.wrapUp(this);
}
private void edit(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
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 {
new Requester(root).with(key, value).method("PATCH").to(getIssuesApiRoute());
root.createRequest().withNullable(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
}
/**
@@ -288,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) {
editIssue("milestone", null);
} else {
editIssue("milestone", milestone.getNumber());
}
}
/**
@@ -431,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();
}
/**
@@ -442,27 +445,30 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public PagedIterable<GHIssueComment> listComments() throws IOException {
return root.retrieve()
.asPagedIterable(getIssuesApiRoute() + "/comments",
GHIssueComment[].class,
item -> item.wrapUp(GHIssue.this));
return root.createRequest()
.withUrlPath(getIssuesApiRoute() + "/comments")
.toIterable(GHIssueComment[].class, item -> item.wrapUp(this));
}
@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return root.createRequest()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiRoute() + "/reactions", GHReaction.class)
.withUrlPath(getApiRoute() + "/reactions")
.fetch(GHReaction.class)
.wrap(root);
}
@Preview
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.retrieve()
return root.createRequest()
.withPreview(SQUIRREL_GIRL)
.asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root));
.withUrlPath(getApiRoute() + "/reactions")
.toIterable(GHReaction[].class, item -> item.wrap(root));
}
/**
@@ -486,10 +492,11 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void addAssignees(Collection<GHUser> assignees) throws IOException {
root.retrieve()
root.createRequest()
.method("POST")
.with(ASSIGNEES, getLogins(assignees))
.to(getIssuesApiRoute() + "/assignees", this);
.withUrlPath(getIssuesApiRoute() + "/assignees")
.fetchInto(this);
}
/**
@@ -513,7 +520,11 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void setAssignees(Collection<GHUser> assignees) throws IOException {
new Requester(root).with(ASSIGNEES, getLogins(assignees)).method("PATCH").to(getIssuesApiRoute());
root.createRequest()
.method("PATCH")
.with(ASSIGNEES, getLogins(assignees))
.withUrlPath(getIssuesApiRoute())
.send();
}
/**
@@ -537,11 +548,12 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void removeAssignees(Collection<GHUser> assignees) throws IOException {
root.retrieve()
root.createRequest()
.method("DELETE")
.with(ASSIGNEES, getLogins(assignees))
.inBody()
.to(getIssuesApiRoute() + "/assignees", this);
.withUrlPath(getIssuesApiRoute() + "/assignees")
.fetchInto(this);
}
/**
@@ -559,6 +571,11 @@ public class GHIssue extends GHObject implements Reactable {
* @return the issues api route
*/
protected String getIssuesApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
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;
}
@@ -665,7 +682,7 @@ public class GHIssue extends GHObject implements Reactable {
* @return the diff url
*/
public URL getDiffUrl() {
return GitHub.parseURL(diff_url);
return GitHubClient.parseURL(diff_url);
}
/**
@@ -674,7 +691,7 @@ public class GHIssue extends GHObject implements Reactable {
* @return the patch url
*/
public URL getPatchUrl() {
return GitHub.parseURL(patch_url);
return GitHubClient.parseURL(patch_url);
}
/**
@@ -683,7 +700,7 @@ public class GHIssue extends GHObject implements Reactable {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
}
@@ -703,9 +720,8 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public PagedIterable<GHIssueEvent> listEvents() throws IOException {
return root.retrieve()
.asPagedIterable(owner.getApiTailUrl(String.format("/issues/%s/events", number)),
GHIssueEvent[].class,
item -> item.wrapUp(GHIssue.this));
return root.createRequest()
.withUrlPath(owner.getApiTailUrl(String.format("/issues/%s/events", number)))
.toIterable(GHIssueEvent[].class, item -> item.wrapUp(this));
}
}

View File

@@ -17,7 +17,7 @@ public class GHIssueBuilder {
GHIssueBuilder(GHRepository repo, String title) {
this.repo = repo;
this.builder = new Requester(repo.root);
this.builder = repo.root.createRequest().method("POST");
builder.with("title", title);
}
@@ -95,7 +95,8 @@ public class GHIssueBuilder {
public GHIssue create() throws IOException {
return builder.with("labels", labels)
.with("assignees", assignees)
.to(repo.getApiTailUrl("issues"), GHIssue.class)
.withUrlPath(repo.getApiTailUrl("issues"))
.fetch(GHIssue.class)
.wrap(repo);
}
}

View File

@@ -87,7 +87,7 @@ public class GHIssueComment extends GHObject implements Reactable {
@Override
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -108,7 +108,11 @@ public class GHIssueComment extends GHObject implements Reactable {
* the io exception
*/
public void update(String body) throws IOException {
new Requester(owner.root).with("body", body).method("PATCH").to(getApiRoute(), GHIssueComment.class);
owner.root.createRequest()
.method("PATCH")
.with("body", body)
.withUrlPath(getApiRoute())
.fetch(GHIssueComment.class);
this.body = body;
}
@@ -119,28 +123,32 @@ public class GHIssueComment extends GHObject implements Reactable {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiRoute());
owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return owner.root.createRequest()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiRoute() + "/reactions", GHReaction.class)
.withUrlPath(getApiRoute() + "/reactions")
.fetch(GHReaction.class)
.wrap(owner.root);
}
@Preview
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.retrieve()
return owner.root.createRequest()
.withPreview(SQUIRREL_GIRL)
.asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root));
.withUrlPath(getApiRoute() + "/reactions")
.toIterable(GHReaction[].class, item -> item.wrap(owner.root));
}
private String getApiRoute() {
return "/repos/" + owner.getRepository().getOwnerName() + "/" + owner.getRepository().getName()
+ "/issues/comments/" + id;
+ "/issues/comments/" + getId();
}
}

View File

@@ -5,6 +5,8 @@ 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 {
@@ -18,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;
@@ -90,7 +95,7 @@ public class GHIssueEvent {
* @return the created at
*/
public Date getCreatedAt() {
return GitHub.parseDate(created_at);
return GitHubClient.parseDate(created_at);
}
/**
@@ -111,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

@@ -1,29 +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 static org.kohsuke.github.Previews.SYMMETRA;
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;
}
@@ -33,6 +60,7 @@ public class GHLabel {
*
* @return the name
*/
@Nonnull
public String getName() {
return name;
}
@@ -42,6 +70,7 @@ public class GHLabel {
*
* @return the color
*/
@Nonnull
public String getColor() {
return color;
}
@@ -51,27 +80,11 @@ public class GHLabel {
*
* @return the description
*/
@Preview
@Deprecated
@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.retrieve().method("DELETE").to(url);
}
/**
* Sets color.
*
@@ -79,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.retrieve()
.method("PATCH")
.withPreview(SYMMETRA)
.with("name", name)
.with("color", newColor)
.with("description", description)
.to(url);
set().color(newColor);
}
/**
@@ -97,27 +106,106 @@ public class GHLabel {
* Description of label
* @throws IOException
* the io exception
* @deprecated use {@link #set()} or {@link #update()} instead
*/
@Preview
@Deprecated
public void setDescription(String newDescription) throws IOException {
repo.root.retrieve()
.method("PATCH")
.withPreview(SYMMETRA)
.with("name", name)
.with("color", color)
.with("description", newDescription)
.to(url);
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)
@@ -126,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,13 +24,13 @@
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
@@ -78,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 GitHub.parseURL(url);
}
/**
* Featured licenses are bold in the new repository drop-down
*
@@ -100,7 +92,7 @@ public class GHLicense extends GHObject {
public URL getHtmlUrl() throws IOException {
populate();
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -199,7 +191,14 @@ public class GHLicense extends GHObject {
if (description != null)
return; // already populated
root.retrieve().to(url, 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
@@ -210,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

@@ -0,0 +1,88 @@
package org.kohsuke.github;
import java.net.URL;
/**
* Base class for Github Marketplace Account.
*
* @author Paulo Miguel Almeida
* @see GitHub#getMyMarketplacePurchases()
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplaceAccount {
protected GitHub root;
private String url;
private long id;
private String login;
private String email;
private String organizationBillingEmail;
private GHMarketplaceAccountType type;
/**
* Wrap up gh marketplace account.
*
* @param root
* the root
* @return an instance of the GHMarketplaceAccount class
*/
GHMarketplaceAccount wrapUp(GitHub root) {
this.root = root;
return this;
}
/**
* Gets url.
*
* @return the url
*/
public URL getUrl() {
return GitHubClient.parseURL(url);
}
/**
* Gets id.
*
* @return the id
*/
public long getId() {
return id;
}
/**
* Gets login.
*
* @return the login
*/
public String getLogin() {
return login;
}
/**
* Gets email.
*
* @return the email
*/
public String getEmail() {
return email;
}
/**
* Gets organization billing email.
*
* @return the organization billing email
*/
public String getOrganizationBillingEmail() {
return organizationBillingEmail;
}
/**
* Gets type.
*
* @return the type
*/
public GHMarketplaceAccountType getType() {
return type;
}
}

View File

@@ -0,0 +1,53 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* A Github Marketplace Account Plan.
*
* @author Paulo Miguel Almeida
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplaceAccountPlan extends GHMarketplaceAccount {
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplacePendingChange marketplacePendingChange;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplacePurchase marketplacePurchase;
/**
* Wrap up gh marketplace account.
*
* @param root
* the root
* @return an instance of the GHMarketplaceAccount class
*/
GHMarketplaceAccountPlan wrapUp(GitHub root) {
super.wrapUp(root);
if (this.marketplacePendingChange != null)
this.marketplacePendingChange.wrapUp(this.root);
if (this.marketplacePurchase != null)
this.marketplacePurchase.wrapUp(this.root);
return this;
}
/**
* Gets marketplace pending change.
*
* @return the marketplace pending change
*/
public GHMarketplacePendingChange getMarketplacePendingChange() {
return marketplacePendingChange;
}
/**
* Gets marketplace purchase.
*
* @return the marketplace purchase
*/
public GHMarketplacePurchase getMarketplacePurchase() {
return marketplacePurchase;
}
}

View File

@@ -0,0 +1,22 @@
package org.kohsuke.github;
import org.apache.commons.lang3.StringUtils;
import java.util.Locale;
/**
* GitHub Marketplace Account type.
*
* @author Paulo Miguel Almeida
* @see GHMarketplaceAccount
*/
public enum GHMarketplaceAccountType {
ORGANIZATION, USER;
/**
* Returns GitHub's internal representation of this event.
*/
String symbol() {
return StringUtils.capitalize(name().toLowerCase(Locale.ENGLISH));
}
}

View File

@@ -0,0 +1,71 @@
package org.kohsuke.github;
import java.io.IOException;
/**
* Returns any accounts associated with a plan, including free plans
*
* @author Paulo Miguel Almeida
* @see GHMarketplacePlan#listAccounts()
*/
public class GHMarketplaceListAccountBuilder {
private final GitHub root;
private final Requester builder;
private final long planId;
GHMarketplaceListAccountBuilder(GitHub root, long planId) {
this.root = root;
this.builder = root.createRequest();
this.planId = planId;
}
/**
* Sorts the GitHub accounts by the date they were created or last updated. Can be one of created or updated.
* <p>
* If omitted, the default sorting strategy will be "CREATED"
*
* @param sort
* the sort strategy
* @return a GHMarketplaceListAccountBuilder
*/
public GHMarketplaceListAccountBuilder sort(Sort sort) {
this.builder.with("sort", sort);
return this;
}
/**
* Orders the GitHub accounts results, Can be one of asc or desc. Ignored without the sort parameter.
*
* @param direction
* the order strategy
* @return a GHMarketplaceListAccountBuilder
*/
public GHMarketplaceListAccountBuilder direction(GHDirection direction) {
this.builder.with("direction", direction);
return this;
}
/**
* The enum Sort.
*/
public enum Sort {
CREATED, UPDATED
}
/**
* List any accounts associated with the plan specified on construction with all the order/sort parameters set.
* <p>
* GitHub Apps must use a JWT to access this endpoint.
* <p>
* OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
*
* @return a paged iterable instance of GHMarketplaceAccountPlan
* @throws IOException
* on error
*/
public PagedIterable<GHMarketplaceAccountPlan> createRequest() throws IOException {
return builder.withUrlPath(String.format("/marketplace_listing/plans/%d/accounts", this.planId))
.toIterable(GHMarketplaceAccountPlan[].class, item -> item.wrapUp(root));
}
}

View File

@@ -0,0 +1,74 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Date;
/**
* A Github Marketplace purchase pending change.
*
* @author Paulo Miguel Almeida
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplacePendingChange {
private GitHub root;
private long id;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private Long unitCount;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplacePlan plan;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private String effectiveDate;
/**
* Wrap up gh marketplace pending change.
*
* @param root
* the root
* @return an instance of the GHMarketplacePendingChange class
*/
GHMarketplacePendingChange wrapUp(GitHub root) {
this.root = root;
if (plan != null) { // sanity check
this.plan.wrapUp(this.root);
}
return this;
}
/**
* Gets id.
*
* @return the id
*/
public long getId() {
return id;
}
/**
* Gets unit count.
*
* @return the unit count
*/
public Long getUnitCount() {
return unitCount;
}
/**
* Gets plan.
*
* @return the plan
*/
public GHMarketplacePlan getPlan() {
return plan;
}
/**
* Gets effective date.
*
* @return the effective date
*/
public Date getEffectiveDate() {
return GitHubClient.parseDate(effectiveDate);
}
}

View File

@@ -0,0 +1,184 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.net.URL;
import java.util.List;
/**
* A Github Marketplace plan.
*
* @author Paulo Miguel Almeida
* @see GitHub#listMarketplacePlans()
*/
public class GHMarketplacePlan {
private GitHub root;
private String url;
private String accountsUrl;
private long id;
private long number;
private String name;
private String description;
private long monthlyPriceInCents;
private long yearlyPriceInCents;
private GHMarketplacePriceModel priceModel;
@JsonProperty("has_free_trial")
private boolean freeTrial; // JavaBeans Spec 1.01 section 8.3.2 forces us to have is<propertyName>
private String unitName;
private String state;
private List<String> bullets;
/**
* Wrap up gh marketplace plan.
*
* @param root
* the root
* @return an instance of the GHMarketplacePlan class
*/
GHMarketplacePlan wrapUp(GitHub root) {
this.root = root;
return this;
}
/**
* Gets url.
*
* @return the url
*/
public URL getUrl() {
return GitHubClient.parseURL(url);
}
/**
* Gets accounts url.
*
* @return the accounts url
*/
public String getAccountsUrl() {
return accountsUrl;
}
/**
* Gets id.
*
* @return the id
*/
public long getId() {
return id;
}
/**
* Gets number.
*
* @return the number
*/
public long getNumber() {
return number;
}
/**
* Gets name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Gets description.
*
* @return the description
*/
public String getDescription() {
return description;
}
/**
* Gets monthly price in cents.
*
* @return the monthly price in cents
*/
public long getMonthlyPriceInCents() {
return monthlyPriceInCents;
}
/**
* Gets yearly price in cents.
*
* @return the yearly price in cents
*/
public long getYearlyPriceInCents() {
return yearlyPriceInCents;
}
/**
* Gets price model.
*
* @return the price model
*/
public GHMarketplacePriceModel getPriceModel() {
return priceModel;
}
/**
* Is free trial boolean.
*
* @return the boolean
*/
public boolean isFreeTrial() {
return freeTrial;
}
/**
* Gets unit name.
*
* @return the unit name
*/
public String getUnitName() {
return unitName;
}
/**
* Gets state.
*
* @return the state
*/
public String getState() {
return state;
}
/**
* Gets bullets.
*
* @return the bullets
*/
public List<String> getBullets() {
return bullets;
}
/**
* Starts a builder that list any accounts associated with a plan, including free plans. For per-seat pricing, you
* see the list of accounts that have purchased the plan, including the number of seats purchased. When someone
* submits a plan change that won't be processed until the end of their billing cycle, you will also see the
* upcoming pending change.
*
* <p>
* You use the returned builder to set various properties, then call
* {@link GHMarketplaceListAccountBuilder#createRequest()} to finally list the accounts related to this plan.
*
* <p>
* GitHub Apps must use a JWT to access this endpoint.
* <p>
* OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
*
* @return a GHMarketplaceListAccountBuilder instance
* @see <a href=
* "https://developer.github.com/v3/apps/marketplace/#list-all-github-accounts-user-or-organization-on-a-specific-plan">List
* all GitHub accounts (user or organization) on a specific plan</a>
*/
public GHMarketplaceListAccountBuilder listAccounts() {
return new GHMarketplaceListAccountBuilder(root, this.id);
}
}

View File

@@ -0,0 +1,29 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* GitHub Marketplace plan pricing model.
*
* @author Paulo Miguel Almeida
* @see GHMarketplacePlan
*/
public enum GHMarketplacePriceModel {
FREE("free"), PER_UNIT("per-unit"), FLAT_RATE("flat-rate");
@JsonValue
private final String internalName;
GHMarketplacePriceModel(String internalName) {
this.internalName = internalName;
}
/**
* Returns GitHub's internal representation of this event.
*
* @return a string containing GitHub's internal representation of this event.
*/
public String symbol() {
return internalName;
}
}

View File

@@ -0,0 +1,102 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Date;
/**
* A Github Marketplace purchase.
*
* @author Paulo Miguel Almeida
* @see GHMarketplaceListAccountBuilder#createRequest() GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplacePurchase {
private GitHub root;
private String billingCycle;
private String nextBillingDate;
private boolean onFreeTrial;
private String freeTrialEndsOn;
private Long unitCount;
private String updatedAt;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplacePlan plan;
/**
* Wrap up gh marketplace purchase.
*
* @param root
* the root
* @return an instance of the GHMarketplacePurchase class
*/
GHMarketplacePurchase wrapUp(GitHub root) {
this.root = root;
if (plan != null) { // sanity check
this.plan.wrapUp(this.root);
}
return this;
}
/**
* Gets billing cycle.
*
* @return the billing cycle
*/
public String getBillingCycle() {
return billingCycle;
}
/**
* Gets next billing date.
*
* @return the next billing date
*/
public Date getNextBillingDate() {
return GitHubClient.parseDate(nextBillingDate);
}
/**
* Is on free trial boolean.
*
* @return the boolean
*/
public boolean isOnFreeTrial() {
return onFreeTrial;
}
/**
* Gets free trial ends on.
*
* @return the free trial ends on
*/
public Date getFreeTrialEndsOn() {
return GitHubClient.parseDate(freeTrialEndsOn);
}
/**
* Gets unit count.
*
* @return the unit count
*/
public Long getUnitCount() {
return unitCount;
}
/**
* Gets updated at.
*
* @return the updated at
*/
public Date getUpdatedAt() {
return GitHubClient.parseDate(updatedAt);
}
/**
* Gets plan.
*
* @return the plan
*/
public GHMarketplacePlan getPlan() {
return plan;
}
}

View File

@@ -0,0 +1,113 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Date;
/**
* Github Marketplace User Purchase
*
* @author Paulo Miguel Almeida
* @see GitHub#getMyMarketplacePurchases()
*/
public class GHMarketplaceUserPurchase {
protected GitHub root;
private String billingCycle;
private String nextBillingDate;
private boolean onFreeTrial;
private String freeTrialEndsOn;
private Long unitCount;
private String updatedAt;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplaceAccount account;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplacePlan plan;
/**
* Wrap up GHMarketplaceUserPurchase.
*
* @param root
* the root
* @return an instance of the GHMarketplaceUserPurchase class
*/
GHMarketplaceUserPurchase wrapUp(GitHub root) {
this.root = root;
if (this.account != null)
this.account.wrapUp(this.root);
if (this.plan != null)
this.plan.wrapUp(this.root);
return this;
}
/**
* Gets billing cycle.
*
* @return the billing cycle
*/
public String getBillingCycle() {
return billingCycle;
}
/**
* Gets next billing date.
*
* @return the next billing date
*/
public Date getNextBillingDate() {
return GitHubClient.parseDate(nextBillingDate);
}
/**
* Is on free trial boolean.
*
* @return the boolean
*/
public boolean isOnFreeTrial() {
return onFreeTrial;
}
/**
* Gets free trial ends on.
*
* @return the free trial ends on
*/
public Date getFreeTrialEndsOn() {
return GitHubClient.parseDate(freeTrialEndsOn);
}
/**
* Gets unit count.
*
* @return the unit count
*/
public Long getUnitCount() {
return unitCount;
}
/**
* Gets updated at.
*
* @return the updated at
*/
public Date getUpdatedAt() {
return GitHubClient.parseDate(updatedAt);
}
/**
* Gets account.
*
* @return the account
*/
public GHMarketplaceAccount getAccount() {
return account;
}
/**
* Gets plan.
*
* @return the plan
*/
public GHMarketplacePlan getPlan() {
return plan;
}
}

View File

@@ -25,7 +25,7 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -72,7 +72,7 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
* @see GHMyself#getMembership(GHOrganization) GHMyself#getMembership(GHOrganization)
*/
public void activate() throws IOException {
root.retrieve().method("PATCH").with("state", State.ACTIVE).to(url, this);
root.createRequest().method("PATCH").with("state", State.ACTIVE).withUrlPath(url).fetchInto(this);
}
GHMembership wrap(GitHub root) {
@@ -84,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

@@ -56,7 +56,7 @@ public class GHMilestone extends GHObject {
public Date getDueOn() {
if (due_on == null)
return null;
return GitHub.parseDate(due_on);
return GitHubClient.parseDate(due_on);
}
/**
@@ -67,7 +67,7 @@ public class GHMilestone extends GHObject {
* the io exception
*/
public Date getClosedAt() throws IOException {
return GitHub.parseDate(closed_at);
return GitHubClient.parseDate(closed_at);
}
/**
@@ -116,7 +116,7 @@ public class GHMilestone extends GHObject {
}
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -155,11 +155,11 @@ public class GHMilestone extends GHObject {
* the io exception
*/
public void delete() throws IOException {
root.retrieve().method("DELETE").to(getApiRoute());
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
private void edit(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}
/**
@@ -195,7 +195,7 @@ public class GHMilestone extends GHObject {
* the io exception
*/
public void setDueOn(Date dueOn) throws IOException {
edit("due_on", GitHub.printDate(dueOn));
edit("due_on", GitHubClient.printDate(dueOn));
}
/**

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;
@@ -71,8 +70,7 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHEmail> getEmails2() throws IOException {
GHEmail[] addresses = root.retrieve().to("/user/emails", GHEmail[].class);
return Collections.unmodifiableList(Arrays.asList(addresses));
return root.createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null).toList();
}
/**
@@ -86,7 +84,7 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHKey> getPublicKeys() throws IOException {
return Collections.unmodifiableList(Arrays.asList(root.retrieve().to("/user/keys", GHKey[].class)));
return root.createRequest().withUrlPath("/user/keys").toIterable(GHKey[].class, null).toList();
}
/**
@@ -100,8 +98,10 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHVerifiedKey> getPublicVerifiedKeys() throws IOException {
return Collections.unmodifiableList(
Arrays.asList(root.retrieve().to("/users/" + getLogin() + "/keys", GHVerifiedKey[].class)));
return root.createRequest()
.withUrlPath("/users/" + getLogin() + "/keys")
.toIterable(GHVerifiedKey[].class, null)
.toList();
}
/**
@@ -114,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.retrieve().to("/user/orgs", 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()));
}
@@ -175,9 +178,10 @@ public class GHMyself extends GHUser {
* @return the paged iterable
*/
public PagedIterable<GHRepository> listRepositories(final int pageSize, final RepositoryListFilter repoType) {
return root.retrieve()
return root.createRequest()
.with("type", repoType)
.asPagedIterable("/user/repos", GHRepository[].class, item -> item.wrap(root))
.withUrlPath("/user/repos")
.toIterable(GHRepository[].class, item -> item.wrap(root))
.withPageSize(pageSize);
}
@@ -187,6 +191,7 @@ public class GHMyself extends GHUser {
* @return the paged iterable
* @deprecated Use {@link #listRepositories()}
*/
@Deprecated
public PagedIterable<GHRepository> listAllRepositories() {
return listRepositories();
}
@@ -208,9 +213,10 @@ public class GHMyself extends GHUser {
* @return the paged iterable
*/
public PagedIterable<GHMembership> listOrgMemberships(final GHMembership.State state) {
return root.retrieve()
return root.createRequest()
.with("state", state)
.asPagedIterable("/user/memberships/orgs", GHMembership[].class, item -> item.wrap(root));
.withUrlPath("/user/memberships/orgs")
.toIterable(GHMembership[].class, item -> item.wrap(root));
}
/**
@@ -223,7 +229,10 @@ public class GHMyself extends GHUser {
* the io exception
*/
public GHMembership getMembership(GHOrganization o) throws IOException {
return root.retrieve().to("/user/memberships/orgs/" + o.getLogin(), GHMembership.class).wrap(root);
return root.createRequest()
.withUrlPath("/user/memberships/orgs/" + o.getLogin())
.fetch(GHMembership.class)
.wrap(root);
}
// public void addEmails(Collection<String> emails) throws IOException {

View File

@@ -79,7 +79,7 @@ public class GHNotificationStream implements Iterable<GHThread> {
* @return the gh notification stream
*/
public GHNotificationStream since(Date dt) {
since = GitHub.printDate(dt);
since = GitHubClient.printDate(dt);
return this;
}
@@ -101,7 +101,7 @@ public class GHNotificationStream implements Iterable<GHThread> {
*/
public Iterator<GHThread> iterator() {
// capture the configuration setting here
final Requester req = new Requester(root).method("GET")
final Requester req = root.createRequest()
.with("all", all)
.with("participating", participating)
.with("since", since);
@@ -180,7 +180,11 @@ public class GHNotificationStream implements Iterable<GHThread> {
req.setHeader("If-Modified-Since", lastModified);
threads = req.to(apiUrl, GHThread[].class);
Requester requester = req.withUrlPath(apiUrl);
GitHubResponse<GHThread[]> response = ((GitHubPageContentsIterable<GHThread>) requester
.toIterable(GHThread[].class, null)).toResponse();
threads = response.body();
if (threads == null) {
threads = EMPTY_ARRAY; // if unmodified, we get empty array
} else {
@@ -189,27 +193,21 @@ public class GHNotificationStream implements Iterable<GHThread> {
}
idx = threads.length - 1;
nextCheckTime = calcNextCheckTime();
lastModified = req.getResponseHeader("Last-Modified");
nextCheckTime = calcNextCheckTime(response);
lastModified = response.headerField("Last-Modified");
}
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}
private long calcNextCheckTime() {
String v = req.getResponseHeader("X-Poll-Interval");
private long calcNextCheckTime(GitHubResponse<GHThread[]> response) {
String v = response.headerField("X-Poll-Interval");
if (v == null)
v = "60";
long seconds = Integer.parseInt(v);
return System.currentTimeMillis() + seconds * 1000;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
@@ -232,10 +230,10 @@ public class GHNotificationStream implements Iterable<GHThread> {
* the io exception
*/
public void markAsRead(long timestamp) throws IOException {
final Requester req = new Requester(root).method("PUT");
final Requester req = root.createRequest();
if (timestamp >= 0)
req.with("last_read_at", GitHub.printDate(new Date(timestamp)));
req.asHttpStatusCode(apiUrl);
req.with("last_read_at", GitHubClient.printDate(new Date(timestamp)));
req.withUrlPath(apiUrl).fetchHttpStatusCode();
}
private static final GHThread[] EMPTY_ARRAY = new GHThread[0];

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 GitHub.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;
}
/**
@@ -75,7 +91,7 @@ public abstract class GHObject {
*/
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -96,7 +112,18 @@ public abstract class GHObject {
* on error
*/
public Date getUpdatedAt() throws IOException {
return GitHub.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

@@ -40,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,
@@ -69,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,
@@ -88,7 +90,7 @@ public class GHOrganization extends GHPerson {
*
* <p>
* You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()} to
* finally createa repository.
* finally create a repository.
*
* @param name
* the name
@@ -121,10 +123,43 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public PagedIterable<GHTeam> listTeams() throws IOException {
return root.retrieve()
.asPagedIterable(String.format("/orgs/%s/teams", login),
GHTeam[].class,
item -> item.wrapUp(GHOrganization.this));
return root.createRequest()
.withUrlPath(String.format("/orgs/%s/teams", login))
.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);
}
/**
@@ -146,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);
}
/**
@@ -183,10 +218,11 @@ public class GHOrganization extends GHPerson {
* "https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership">documentation</a>
*/
public void add(GHUser user, Role role) throws IOException {
root.retrieve()
root.createRequest()
.method("PUT")
.with("role", role.name().toLowerCase())
.to("/orgs/" + login + "/memberships/" + user.getLogin());
.withUrlPath("/orgs/" + login + "/memberships/" + user.getLogin())
.send();
}
/**
@@ -198,7 +234,7 @@ public class GHOrganization extends GHPerson {
*/
public boolean hasMember(GHUser user) {
try {
root.retrieve().to("/orgs/" + login + "/members/" + user.getLogin());
root.createRequest().withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();
return true;
} catch (IOException ignore) {
return false;
@@ -215,7 +251,7 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public void remove(GHUser user) throws IOException {
root.retrieve().method("DELETE").to("/orgs/" + login + "/members/" + user.getLogin());
root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();
}
/**
@@ -227,7 +263,7 @@ public class GHOrganization extends GHPerson {
*/
public boolean hasPublicMember(GHUser user) {
try {
root.retrieve().to("/orgs/" + login + "/public_members/" + user.getLogin());
root.createRequest().withUrlPath("/orgs/" + login + "/public_members/" + user.getLogin()).send();
return true;
} catch (IOException ignore) {
return false;
@@ -243,7 +279,7 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public void publicize(GHUser u) throws IOException {
root.retrieve().method("PUT").to("/orgs/" + login + "/public_members/" + u.getLogin(), null);
root.createRequest().method("PUT").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();
}
/**
@@ -255,7 +291,7 @@ public class GHOrganization extends GHPerson {
* @deprecated use {@link #listMembers()}
*/
public List<GHUser> getMembers() throws IOException {
return listMembers().asList();
return listMembers().toList();
}
/**
@@ -281,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);
}
/**
@@ -294,15 +330,29 @@ 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);
return root.retrieve()
.asPagedIterable(String.format("/orgs/%s/%s%s", login, suffix, filterParams),
GHUser[].class,
item -> item.wrapUp(root));
/**
* 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", login, suffix))
.with("filter", filter)
.with("role", role)
.toIterable(GHUser[].class, item -> item.wrapUp(root));
}
/**
@@ -314,7 +364,7 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public void conceal(GHUser u) throws IOException {
root.retrieve().method("DELETE").to("/orgs/" + login + "/public_members/" + u.getLogin(), null);
root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();
}
/**
@@ -327,10 +377,11 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public PagedIterable<GHProject> listProjects(final GHProject.ProjectStateFilter status) throws IOException {
return root.retrieve()
return root.createRequest()
.withPreview(INERTIA)
.with("state", status)
.asPagedIterable(String.format("/orgs/%s/projects", login), GHProject[].class, item -> item.wrap(root));
.withUrlPath(String.format("/orgs/%s/projects", login))
.toIterable(GHProject[].class, item -> item.wrap(root));
}
/**
@@ -356,12 +407,13 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public GHProject createProject(String name, String body) throws IOException {
return root.retrieve()
return root.createRequest()
.method("POST")
.withPreview(INERTIA)
.with("name", name)
.with("body", body)
.to(String.format("/orgs/%s/projects", login), GHProject.class)
.withUrlPath(String.format("/orgs/%s/projects", login))
.fetch(GHProject.class)
.wrap(root);
}
@@ -369,7 +421,7 @@ public class GHOrganization extends GHPerson {
* The enum Permission.
*/
public enum Permission {
ADMIN, PUSH, PULL
ADMIN, MAINTAIN, PUSH, TRIAGE, PULL
}
/**
@@ -385,17 +437,17 @@ public class GHOrganization extends GHPerson {
* @throws IOException
* the io exception
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
* {@link #createTeam(String, Collection)}
* {@link #createTeam(String)}
*/
@Deprecated
public GHTeam createTeam(String name, Permission p, Collection<GHRepository> repositories) throws IOException {
Requester post = new Requester(root).with("name", name).with("permission", p);
Requester post = root.createRequest().method("POST").with("name", name).with("permission", p);
List<String> repo_names = new ArrayList<String>();
for (GHRepository r : repositories) {
repo_names.add(login + "/" + r.getName());
}
post.with("repo_names", repo_names);
return post.method("POST").to("/orgs/" + login + "/teams", GHTeam.class).wrapUp(this);
return post.withUrlPath("/orgs/" + login + "/teams").fetch(GHTeam.class).wrapUp(this);
}
/**
@@ -411,7 +463,7 @@ public class GHOrganization extends GHPerson {
* @throws IOException
* the io exception
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
* {@link #createTeam(String, GHRepository...)}
* {@link #createTeam(String)}
*/
@Deprecated
public GHTeam createTeam(String name, Permission p, GHRepository... repositories) throws IOException {
@@ -428,15 +480,17 @@ public class GHOrganization extends GHPerson {
* @return the gh team
* @throws IOException
* the io exception
* @deprecated Use {@link #createTeam(String)} that uses a builder pattern to let you control every aspect.
*/
@Deprecated
public GHTeam createTeam(String name, Collection<GHRepository> repositories) throws IOException {
Requester post = new Requester(root).with("name", name);
Requester post = root.createRequest().method("POST").with("name", name);
List<String> repo_names = new ArrayList<String>();
for (GHRepository r : repositories) {
repo_names.add(login + "/" + r.getName());
}
post.with("repo_names", repo_names);
return post.method("POST").to("/orgs/" + login + "/teams", GHTeam.class).wrapUp(this);
return post.withUrlPath("/orgs/" + login + "/teams").fetch(GHTeam.class).wrapUp(this);
}
/**
@@ -449,11 +503,28 @@ public class GHOrganization extends GHPerson {
* @return the gh team
* @throws IOException
* the io exception
* @deprecated Use {@link #createTeam(String)} that uses a builder pattern to let you control every aspect.
*/
@Deprecated
public GHTeam createTeam(String name, GHRepository... repositories) throws IOException {
return createTeam(name, Arrays.asList(repositories));
}
/**
* Starts a builder that creates a new team.
*
* <p>
* You use the returned builder to set various properties, then call {@link GHTeamBuilder#create()} to finally
* create a team.
*
* @param name
* the name
* @return the gh create repository builder
*/
public GHTeamBuilder createTeam(String name) {
return new GHTeamBuilder(root, login, name);
}
/**
* List up repositories that has some open pull requests.
* <p>
@@ -495,10 +566,9 @@ public class GHOrganization extends GHPerson {
* Lists events performed by a user (this includes private events if the caller is authenticated.
*/
public PagedIterable<GHEventInfo> listEvents() throws IOException {
return root.retrieve()
.asPagedIterable(String.format("/orgs/%s/events", login),
GHEventInfo[].class,
item -> item.wrapUp(root));
return root.createRequest()
.withUrlPath(String.format("/orgs/%s/events", login))
.toIterable(GHEventInfo[].class, item -> item.wrapUp(root));
}
/**
@@ -511,8 +581,9 @@ public class GHOrganization extends GHPerson {
*/
@Override
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
return root.retrieve()
.asPagedIterable("/orgs/" + login + "/repos", GHRepository[].class, item -> item.wrap(root))
return root.createRequest()
.withUrlPath("/orgs/" + login + "/repos")
.toIterable(GHRepository[].class, item -> item.wrap(root))
.withPageSize(pageSize);
}

View File

@@ -2,13 +2,14 @@ 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;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.TreeMap;
/**
@@ -20,12 +21,16 @@ 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;
protected String location, blog, email, bio, name, company, type, twitter_username;
protected String html_url;
protected int followers, following, public_repos, public_gists;
protected boolean site_admin, hireable;
// other fields (that only show up in full data) that require privileged scope
protected Integer total_private_repos;
GHPerson wrapUp(GitHub root) {
this.root = root;
@@ -41,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.retrieve().to(url, this);
URL url = getUrl();
if (url != null) {
root.createRequest().setRawUrlPath(url.toString()).fetchInto(this);
}
}
/**
@@ -88,8 +96,9 @@ public abstract class GHPerson extends GHObject {
* @return the paged iterable
*/
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
return root.retrieve()
.asPagedIterable("/users/" + login + "/repos", GHRepository[].class, item -> item.wrap(root))
return root.createRequest()
.withUrlPath("/users/" + login + "/repos")
.toIterable(GHRepository[].class, item -> item.wrap(root))
.withPageSize(pageSize);
}
@@ -110,28 +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 = root.retrieve()
.asIterator("/users/" + login + "/repos", GHRepository[].class, 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();
}
};
return () -> {
final PagedIterator<GHRepository> pager;
try {
GitHubPageIterator<GHRepository[]> iterator = GitHubPageIterator.create(root.getClient(),
GHRepository[].class,
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();
}
};
};
}
@@ -146,7 +154,7 @@ public abstract class GHPerson extends GHObject {
*/
public GHRepository getRepository(String name) throws IOException {
try {
return root.retrieve().to("/repos/" + login + '/' + name, GHRepository.class).wrap(root);
return GHRepository.read(root, login, name);
} catch (FileNotFoundException e) {
return null;
}
@@ -167,22 +175,18 @@ public abstract class GHPerson extends GHObject {
* @return the gravatar id
* @deprecated No longer available in the v3 API.
*/
@Deprecated
public String getGravatarId() {
return gravatar_id;
return "";
}
/**
* Returns a string like 'https://secure.gravatar.com/avatar/0cb9832a01c22c083390f3c5dcb64105' that indicates the
* avatar image URL.
* Returns a string of the avatar image URL.
*
* @return the avatar url
*/
public String getAvatarUrl() {
if (avatar_url != null)
return avatar_url;
if (gravatar_id != null)
return "https://secure.gravatar.com/avatar/" + gravatar_id;
return null;
return avatar_url;
}
/**
@@ -230,6 +234,18 @@ public abstract class GHPerson extends GHObject {
return location;
}
/**
* Gets the Twitter Username of this user, like "GitHub"
*
* @return the Twitter username
* @throws IOException
* the io exception
*/
public String getTwitterUsername() throws IOException {
populate();
return twitter_username;
}
public Date getCreatedAt() throws IOException {
populate();
return super.getCreatedAt();
@@ -254,7 +270,7 @@ public abstract class GHPerson extends GHObject {
@Override
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -316,4 +332,40 @@ public abstract class GHPerson extends GHObject {
populate();
return followers;
}
/**
* Gets the type. This is either "User" or "Organization".
*
* @return the type
* @throws IOException
* the io exception
*/
public String getType() throws IOException {
populate();
return type;
}
/**
* Gets the site_admin field
*
* @return the site_admin field
* @throws IOException
* the io exception
*/
public boolean isSiteAdmin() throws IOException {
populate();
return site_admin;
}
/**
* Gets total private repo count.
*
* @return the total private repo count
* @throws IOException
* the io exception
*/
public Optional<Integer> getTotalPrivateRepoCount() throws IOException {
populate();
return Optional.ofNullable(total_private_repos);
}
}

View File

@@ -42,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;
@@ -51,7 +50,7 @@ public class GHProject extends GHObject {
@Override
public URL getHtmlUrl() throws IOException {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -74,11 +73,15 @@ public class GHProject extends GHObject {
if (owner == null) {
try {
if (owner_url.contains("/orgs/")) {
owner = root.retrieve().to(getOwnerUrl().getPath(), GHOrganization.class).wrapUp(root);
owner = root.createRequest()
.withUrlPath(getOwnerUrl().getPath())
.fetch(GHOrganization.class)
.wrapUp(root);
} else if (owner_url.contains("/users/")) {
owner = root.retrieve().to(getOwnerUrl().getPath(), GHUser.class).wrapUp(root);
owner = root.createRequest().withUrlPath(getOwnerUrl().getPath()).fetch(GHUser.class).wrapUp(root);
} else if (owner_url.contains("/repos/")) {
owner = root.retrieve().to(getOwnerUrl().getPath(), GHRepository.class).wrap(root);
String[] pathElements = getOwnerUrl().getPath().split("/");
owner = GHRepository.read(root, pathElements[1], pathElements[2]);
}
} catch (FileNotFoundException e) {
return null;
@@ -93,16 +96,18 @@ public class GHProject extends GHObject {
* @return the owner url
*/
public URL getOwnerUrl() {
return GitHub.parseURL(owner_url);
return GitHubClient.parseURL(owner_url);
}
/**
* Gets node id.
*
* @deprecated Use {@link GHObject#getNodeId()}
* @return the node id
*/
@Deprecated
public String getNode_id() {
return node_id;
return getNodeId();
}
/**
@@ -176,7 +181,7 @@ public class GHProject extends GHObject {
}
private void edit(String key, Object value) throws IOException {
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().method("PATCH").withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();
}
/**
@@ -185,7 +190,7 @@ public class GHProject extends GHObject {
* @return the api route
*/
protected String getApiRoute() {
return "/projects/" + id;
return "/projects/" + getId();
}
/**
@@ -270,7 +275,7 @@ public class GHProject extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute());
root.createRequest().withPreview(INERTIA).method("DELETE").withUrlPath(getApiRoute()).send();
}
/**
@@ -282,11 +287,10 @@ public class GHProject extends GHObject {
*/
public PagedIterable<GHProjectColumn> listColumns() throws IOException {
final GHProject project = this;
return root.retrieve()
return root.createRequest()
.withPreview(INERTIA)
.asPagedIterable(String.format("/projects/%d/columns", id),
GHProjectColumn[].class,
item -> item.wrap(project));
.withUrlPath(String.format("/projects/%d/columns", getId()))
.toIterable(GHProjectColumn[].class, item -> item.wrap(project));
}
/**
@@ -299,11 +303,12 @@ public class GHProject extends GHObject {
* the io exception
*/
public GHProjectColumn createColumn(String name) throws IOException {
return root.retrieve()
return root.createRequest()
.method("POST")
.withPreview(INERTIA)
.with("name", name)
.to(String.format("/projects/%d/columns", id), GHProjectColumn.class)
.withUrlPath(String.format("/projects/%d/columns", getId()))
.fetch(GHProjectColumn.class)
.wrap(this);
}
}

View File

@@ -72,7 +72,7 @@ public class GHProjectCard extends GHObject {
public GHProject getProject() throws IOException {
if (project == null) {
try {
project = root.retrieve().to(getProjectUrl().getPath(), GHProject.class).wrap(root);
project = root.createRequest().withUrlPath(getProjectUrl().getPath()).fetch(GHProject.class).wrap(root);
} catch (FileNotFoundException e) {
return null;
}
@@ -90,7 +90,10 @@ public class GHProjectCard extends GHObject {
public GHProjectColumn getColumn() throws IOException {
if (column == null) {
try {
column = root.retrieve().to(getColumnUrl().getPath(), GHProjectColumn.class).wrap(root);
column = root.createRequest()
.withUrlPath(getColumnUrl().getPath())
.fetch(GHProjectColumn.class)
.wrap(root);
} catch (FileNotFoundException e) {
return null;
}
@@ -110,9 +113,12 @@ public class GHProjectCard extends GHObject {
return null;
try {
if (content_url.contains("/pulls")) {
return root.retrieve().to(getContentUrl().getPath(), GHPullRequest.class).wrap(root);
return root.createRequest()
.withUrlPath(getContentUrl().getPath())
.fetch(GHPullRequest.class)
.wrap(root);
} else {
return root.retrieve().to(getContentUrl().getPath(), GHIssue.class).wrap(root);
return root.createRequest().withUrlPath(getContentUrl().getPath()).fetch(GHIssue.class).wrap(root);
}
} catch (FileNotFoundException e) {
return null;
@@ -143,7 +149,7 @@ public class GHProjectCard extends GHObject {
* @return the content url
*/
public URL getContentUrl() {
return GitHub.parseURL(content_url);
return GitHubClient.parseURL(content_url);
}
/**
@@ -152,7 +158,7 @@ public class GHProjectCard extends GHObject {
* @return the project url
*/
public URL getProjectUrl() {
return GitHub.parseURL(project_url);
return GitHubClient.parseURL(project_url);
}
/**
@@ -161,7 +167,7 @@ public class GHProjectCard extends GHObject {
* @return the column url
*/
public URL getColumnUrl() {
return GitHub.parseURL(column_url);
return GitHubClient.parseURL(column_url);
}
/**
@@ -198,7 +204,7 @@ public class GHProjectCard extends GHObject {
}
private void edit(String key, Object value) throws IOException {
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().method("PATCH").withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();
}
/**
@@ -207,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());
}
/**
@@ -217,6 +223,6 @@ public class GHProjectCard extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute());
root.createRequest().withPreview(INERTIA).method("DELETE").withUrlPath(getApiRoute()).send();
}
}

View File

@@ -67,7 +67,7 @@ public class GHProjectColumn extends GHObject {
public GHProject getProject() throws IOException {
if (project == null) {
try {
project = root.retrieve().to(getProjectUrl().getPath(), GHProject.class).wrap(root);
project = root.createRequest().withUrlPath(getProjectUrl().getPath()).fetch(GHProject.class).wrap(root);
} catch (FileNotFoundException e) {
return null;
}
@@ -90,7 +90,7 @@ public class GHProjectColumn extends GHObject {
* @return the project url
*/
public URL getProjectUrl() {
return GitHub.parseURL(project_url);
return GitHubClient.parseURL(project_url);
}
/**
@@ -106,7 +106,7 @@ public class GHProjectColumn extends GHObject {
}
private void edit(String key, Object value) throws IOException {
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().method("PATCH").withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();
}
/**
@@ -115,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());
}
/**
@@ -125,7 +125,7 @@ public class GHProjectColumn extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute());
root.createRequest().withPreview(INERTIA).method("DELETE").withUrlPath(getApiRoute()).send();
}
/**
@@ -137,11 +137,10 @@ public class GHProjectColumn extends GHObject {
*/
public PagedIterable<GHProjectCard> listCards() throws IOException {
final GHProjectColumn column = this;
return root.retrieve()
return root.createRequest()
.withPreview(INERTIA)
.asPagedIterable(String.format("/projects/columns/%d/cards", id),
GHProjectCard[].class,
item -> item.wrap(column));
.withUrlPath(String.format("/projects/columns/%d/cards", getId()))
.toIterable(GHProjectCard[].class, item -> item.wrap(column));
}
/**
@@ -154,11 +153,12 @@ public class GHProjectColumn extends GHObject {
* the io exception
*/
public GHProjectCard createCard(String note) throws IOException {
return root.retrieve()
return root.createRequest()
.method("POST")
.withPreview(INERTIA)
.with("note", note)
.to(String.format("/projects/columns/%d/cards", id), GHProjectCard.class)
.withUrlPath(String.format("/projects/columns/%d/cards", getId()))
.fetch(GHProjectCard.class)
.wrap(this);
}
@@ -172,12 +172,13 @@ public class GHProjectColumn extends GHObject {
* the io exception
*/
public GHProjectCard createCard(GHIssue issue) throws IOException {
return root.retrieve()
return root.createRequest()
.method("POST")
.withPreview(INERTIA)
.with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue")
.with("content_id", issue.getId())
.to(String.format("/projects/columns/%d/cards", id), GHProjectCard.class)
.withUrlPath(String.format("/projects/columns/%d/cards", getId()))
.fetch(GHProjectCard.class)
.wrap(this);
}
}

View File

@@ -23,6 +23,8 @@
*/
package org.kohsuke.github;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
@@ -31,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;
@@ -99,6 +102,12 @@ public class GHPullRequest extends GHIssue implements Refreshable {
@Override
protected String getApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
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;
}
@@ -108,7 +117,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the patch url
*/
public URL getPatchUrl() {
return GitHub.parseURL(patch_url);
return GitHubClient.parseURL(patch_url);
}
/**
@@ -117,7 +126,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the issue url
*/
public URL getIssueUrl() {
return GitHub.parseURL(issue_url);
return GitHubClient.parseURL(issue_url);
}
/**
@@ -156,7 +165,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the diff url
*/
public URL getDiffUrl() {
return GitHub.parseURL(diff_url);
return GitHubClient.parseURL(diff_url);
}
/**
@@ -165,7 +174,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the merged at
*/
public Date getMergedAt() {
return GitHub.parseDate(merged_at);
return GitHubClient.parseDate(merged_at);
}
@Override
@@ -381,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.retrieve().withPreview(SHADOW_CAT).to(url, this).wrapUp(owner);
URL url = getUrl();
if (url != null) {
root.createRequest().withPreview(SHADOW_CAT).setRawUrlPath(url.toString()).fetchInto(this).wrapUp(owner);
}
}
/**
@@ -393,8 +406,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the paged iterable
*/
public PagedIterable<GHPullRequestFileDetail> listFiles() {
return root.retrieve()
.asPagedIterable(String.format("%s/files", getApiRoute()), GHPullRequestFileDetail[].class, null);
return root.createRequest()
.withUrlPath(String.format("%s/files", getApiRoute()))
.toIterable(GHPullRequestFileDetail[].class, null);
}
/**
@@ -403,10 +417,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the paged iterable
*/
public PagedIterable<GHPullRequestReview> listReviews() {
return root.retrieve()
.asPagedIterable(String.format("%s/reviews", getApiRoute()),
GHPullRequestReview[].class,
item -> item.wrapUp(GHPullRequest.this));
return root.createRequest()
.withUrlPath(String.format("%s/reviews", getApiRoute()))
.toIterable(GHPullRequestReview[].class, item -> item.wrapUp(this));
}
/**
@@ -417,10 +430,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* the io exception
*/
public PagedIterable<GHPullRequestReviewComment> listReviewComments() throws IOException {
return root.retrieve()
.asPagedIterable(getApiRoute() + COMMENTS_ACTION,
GHPullRequestReviewComment[].class,
item -> item.wrapUp(GHPullRequest.this));
return root.createRequest()
.withUrlPath(getApiRoute() + COMMENTS_ACTION)
.toIterable(GHPullRequestReviewComment[].class, item -> item.wrapUp(this));
}
/**
@@ -429,10 +441,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the paged iterable
*/
public PagedIterable<GHPullRequestCommitDetail> listCommits() {
return root.retrieve()
.asPagedIterable(String.format("%s/commits", getApiRoute()),
GHPullRequestCommitDetail[].class,
item -> item.wrapUp(GHPullRequest.this));
return root.createRequest()
.withUrlPath(String.format("%s/commits", getApiRoute()))
.toIterable(GHPullRequestCommitDetail[].class, item -> item.wrapUp(this));
}
/**
@@ -449,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 {
@@ -469,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 {
@@ -505,12 +518,14 @@ public class GHPullRequest extends GHIssue implements Refreshable {
*/
public GHPullRequestReviewComment createReviewComment(String body, String sha, String path, int position)
throws IOException {
return new Requester(root).method("POST")
return root.createRequest()
.method("POST")
.with("body", body)
.with("commit_id", sha)
.with("path", path)
.with("position", position)
.to(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment.class)
.withUrlPath(getApiRoute() + COMMENTS_ACTION)
.fetch(GHPullRequestReviewComment.class)
.wrapUp(this);
}
@@ -523,9 +538,11 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* the io exception
*/
public void requestReviewers(List<GHUser> reviewers) throws IOException {
new Requester(root).method("POST")
root.createRequest()
.method("POST")
.with("reviewers", getLogins(reviewers))
.to(getApiRoute() + REQUEST_REVIEWERS);
.withUrlPath(getApiRoute() + REQUEST_REVIEWERS)
.send();
}
/**
@@ -541,7 +558,11 @@ public class GHPullRequest extends GHIssue implements Refreshable {
for (GHTeam team : teams) {
teamReviewers.add(team.getSlug());
}
new Requester(root).method("POST").with("team_reviewers", teamReviewers).to(getApiRoute() + REQUEST_REVIEWERS);
root.createRequest()
.method("POST")
.with("team_reviewers", teamReviewers)
.withUrlPath(getApiRoute() + REQUEST_REVIEWERS)
.send();
}
/**
@@ -589,11 +610,13 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* the io exception
*/
public void merge(String msg, String sha, MergeMethod method) throws IOException {
new Requester(root).method("PUT")
root.createRequest()
.method("PUT")
.with("commit_message", msg)
.with("sha", sha)
.with("merge_method", method)
.to(getApiRoute() + "/merge");
.withUrlPath(getApiRoute() + "/merge")
.send();
}
/**
@@ -605,7 +628,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
private void fetchIssue() throws IOException {
if (!fetchedIssueDetails) {
new Requester(root).method("GET").to(getIssuesApiRoute(), this);
root.createRequest().withUrlPath(getIssuesApiRoute()).fetchInto(this);
fetchedIssueDetails = true;
}
}

View File

@@ -75,7 +75,7 @@ public class GHPullRequestCommitDetail {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
}
@@ -125,7 +125,7 @@ public class GHPullRequestCommitDetail {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -161,7 +161,7 @@ public class GHPullRequestCommitDetail {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -170,7 +170,7 @@ public class GHPullRequestCommitDetail {
* @return the html url
*/
public URL getHtml_url() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -214,7 +214,7 @@ public class GHPullRequestCommitDetail {
* @return the api url
*/
public URL getApiUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -223,7 +223,7 @@ public class GHPullRequestCommitDetail {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -232,7 +232,7 @@ public class GHPullRequestCommitDetail {
* @return the comments url
*/
public URL getCommentsUrl() {
return GitHub.parseURL(comments_url);
return GitHubClient.parseURL(comments_url);
}
/**

View File

@@ -105,7 +105,7 @@ public class GHPullRequestFileDetail {
* @return the blob url
*/
public URL getBlobUrl() {
return GitHub.parseURL(blob_url);
return GitHubClient.parseURL(blob_url);
}
/**
@@ -114,7 +114,7 @@ public class GHPullRequestFileDetail {
* @return the raw url
*/
public URL getRawUrl() {
return GitHub.parseURL(raw_url);
return GitHubClient.parseURL(raw_url);
}
/**
@@ -123,7 +123,7 @@ public class GHPullRequestFileDetail {
* @return the contents url
*/
public URL getContentsUrl() {
return GitHub.parseURL(contents_url);
return GitHubClient.parseURL(contents_url);
}
/**

View File

@@ -89,6 +89,7 @@ public class GHPullRequestQueryBuilder extends GHQueryBuilder<GHPullRequest> {
@Override
public PagedIterable<GHPullRequest> list() {
return req.withPreview(SHADOW_CAT)
.asPagedIterable(repo.getApiTailUrl("pulls"), GHPullRequest[].class, item -> item.wrapUp(repo));
.withUrlPath(repo.getApiTailUrl("pulls"))
.toIterable(GHPullRequest[].class, item -> item.wrapUp(repo));
}
}

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();
}
/**
@@ -122,7 +122,7 @@ public class GHPullRequestReview extends GHObject {
* the io exception
*/
public Date getSubmittedAt() throws IOException {
return GitHub.parseDate(submitted_at);
return GitHubClient.parseDate(submitted_at);
}
/**
@@ -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());
}
@@ -160,10 +161,12 @@ public class GHPullRequestReview extends GHObject {
* the io exception
*/
public void submit(String body, GHPullRequestReviewEvent event) throws IOException {
new Requester(owner.root).method("POST")
owner.root.createRequest()
.method("POST")
.with("body", body)
.with("event", event.action())
.to(getApiRoute() + "/events", this);
.withUrlPath(getApiRoute() + "/events")
.fetchInto(this);
this.body = body;
this.state = event.toState();
}
@@ -175,7 +178,7 @@ public class GHPullRequestReview extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiRoute());
owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
/**
@@ -187,7 +190,11 @@ public class GHPullRequestReview extends GHObject {
* the io exception
*/
public void dismiss(String message) throws IOException {
new Requester(owner.root).method("PUT").with("message", message).to(getApiRoute() + "/dismissals");
owner.root.createRequest()
.method("PUT")
.with("message", message)
.withUrlPath(getApiRoute() + "/dismissals")
.send();
state = GHPullRequestReviewState.DISMISSED;
}
@@ -199,9 +206,8 @@ public class GHPullRequestReview extends GHObject {
* the io exception
*/
public PagedIterable<GHPullRequestReviewComment> listReviewComments() throws IOException {
return owner.root.retrieve()
.asPagedIterable(getApiRoute() + "/comments",
GHPullRequestReviewComment[].class,
item -> item.wrapUp(owner));
return owner.root.createRequest()
.withUrlPath(getApiRoute() + "/comments")
.toIterable(GHPullRequestReviewComment[].class, item -> item.wrapUp(owner));
}
}

View File

@@ -17,7 +17,7 @@ public class GHPullRequestReviewBuilder {
GHPullRequestReviewBuilder(GHPullRequest pr) {
this.pr = pr;
this.builder = new Requester(pr.root);
this.builder = pr.root.createRequest();
}
// public GHPullRequestReview createReview(@Nullable String commitId, String body, GHPullRequestReviewEvent event,
@@ -91,7 +91,8 @@ public class GHPullRequestReviewBuilder {
public GHPullRequestReview create() throws IOException {
return builder.method("POST")
.with("comments", comments)
.to(pr.getApiRoute() + "/reviews", GHPullRequestReview.class)
.withUrlPath(pr.getApiRoute() + "/reviews")
.fetch(GHPullRequestReview.class)
.wrapUp(pr);
}

View File

@@ -44,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;
@@ -60,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;
@@ -142,7 +144,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
@Override
public URL getHtmlUrl() {
return null;
return GitHubClient.parseURL(html_url);
}
/**
@@ -151,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();
}
/**
@@ -163,7 +165,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
* the io exception
*/
public void update(String body) throws IOException {
new Requester(owner.root).method("PATCH").with("body", body).to(getApiRoute(), this);
owner.root.createRequest().method("PATCH").with("body", body).withUrlPath(getApiRoute()).fetchInto(this);
this.body = body;
}
@@ -174,7 +176,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiRoute());
owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
/**
@@ -187,27 +189,33 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
* the io exception
*/
public GHPullRequestReviewComment reply(String body) throws IOException {
return new Requester(owner.root).method("POST")
return owner.root.createRequest()
.method("POST")
.with("body", body)
.with("in_reply_to", getId())
.to(getApiRoute() + "/comments", GHPullRequestReviewComment.class)
.withUrlPath(getApiRoute() + "/comments")
.fetch(GHPullRequestReviewComment.class)
.wrapUp(owner);
}
@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return owner.root.createRequest()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiRoute() + "/reactions", GHReaction.class)
.withUrlPath(getApiRoute() + "/reactions")
.fetch(GHReaction.class)
.wrap(owner.root);
}
@Preview
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.retrieve()
return owner.root.createRequest()
.withPreview(SQUIRREL_GIRL)
.asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root));
.withUrlPath(getApiRoute() + "/reactions")
.toIterable(GHReaction[].class, item -> item.wrap(owner.root));
}
}

View File

@@ -13,7 +13,7 @@ public abstract class GHQueryBuilder<T> {
GHQueryBuilder(GitHub root) {
this.root = root;
this.req = root.retrieve();
this.req = root.createRequest();
}
/**

View File

@@ -1,10 +1,12 @@
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;
import org.apache.commons.lang3.StringUtils;
import java.time.Duration;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
@@ -12,6 +14,7 @@ import java.util.Date;
import java.util.Objects;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import static java.util.logging.Level.FINEST;
@@ -27,7 +30,7 @@ public class GHRateLimit {
/**
* Remaining calls that can be made.
*
* @deprecated This value should never have been made public. Use {@link #getRemaining()}
* @deprecated This field should never have been made public. Use {@link #getRemaining()}
*/
@Deprecated
public int remaining;
@@ -35,15 +38,18 @@ public class GHRateLimit {
/**
* Allotted API call per hour.
*
* @deprecated This value should never have been made public. Use {@link #getLimit()}
* @deprecated This field should never have been made public. Use {@link #getLimit()}
*/
@Deprecated
public int limit;
/**
* The time at which the current rate limit window resets in UTC epoch seconds. NOTE: that means to
* The time at which the current rate limit window resets in UTC epoch seconds. WARNING: this field was implemented
* using {@link Date#Date(long)} which expects UTC epoch milliseconds, so this Date instance is meaningless as a
* date. To use this field in any meaningful way, it must be converted to a long using {@link Date#getTime()}
* multiplied by 1000.
*
* @deprecated This value should never have been made public. Use {@link #getResetDate()}
* @deprecated This field should never have been made public. Use {@link #getResetDate()}
*/
@Deprecated
public Date reset;
@@ -60,15 +66,58 @@ public class GHRateLimit {
@Nonnull
private final Record integrationManifest;
static GHRateLimit Unknown() {
return new GHRateLimit(new UnknownLimitRecord(),
new UnknownLimitRecord(),
new UnknownLimitRecord(),
new UnknownLimitRecord());
}
/**
* The default GHRateLimit provided to new {@link GitHubClient}s.
*
* Contains all expired records that will cause {@link GitHubClient#rateLimit(RateLimitTarget)} to refresh with new
* data when called.
*
* Private, but made internal for testing.
*/
@Nonnull
static final GHRateLimit DEFAULT = new GHRateLimit(UnknownLimitRecord.DEFAULT,
UnknownLimitRecord.DEFAULT,
UnknownLimitRecord.DEFAULT,
UnknownLimitRecord.DEFAULT);
static GHRateLimit fromHeaderRecord(Record header) {
return new GHRateLimit(header, new UnknownLimitRecord(), new UnknownLimitRecord(), new UnknownLimitRecord());
/**
* Creates a new {@link GHRateLimit} from a single record for the specified endpoint with place holders for other
* records.
*
* This is used to create {@link GHRateLimit} instances that can merged with other instances.
*
* @param record
* the rate limit record. Can be a regular {@link Record} constructed from header information or an
* {@link UnknownLimitRecord} placeholder.
* @param rateLimitTarget
* which rate limit record to fill
* @return a new {@link GHRateLimit} instance containing the supplied record
*/
@Nonnull
static GHRateLimit fromRecord(@Nonnull Record record, @Nonnull RateLimitTarget rateLimitTarget) {
if (rateLimitTarget == RateLimitTarget.CORE || rateLimitTarget == RateLimitTarget.NONE) {
return new GHRateLimit(record,
UnknownLimitRecord.DEFAULT,
UnknownLimitRecord.DEFAULT,
UnknownLimitRecord.DEFAULT);
} else if (rateLimitTarget == RateLimitTarget.SEARCH) {
return new GHRateLimit(UnknownLimitRecord.DEFAULT,
record,
UnknownLimitRecord.DEFAULT,
UnknownLimitRecord.DEFAULT);
} else if (rateLimitTarget == RateLimitTarget.GRAPHQL) {
return new GHRateLimit(UnknownLimitRecord.DEFAULT,
UnknownLimitRecord.DEFAULT,
record,
UnknownLimitRecord.DEFAULT);
} else if (rateLimitTarget == RateLimitTarget.INTEGRATION_MANIFEST) {
return new GHRateLimit(UnknownLimitRecord.DEFAULT,
UnknownLimitRecord.DEFAULT,
UnknownLimitRecord.DEFAULT,
record);
} else {
throw new IllegalArgumentException("Unknown rate limit target: " + rateLimitTarget.toString());
}
}
@JsonCreator
@@ -76,6 +125,12 @@ public class GHRateLimit {
@Nonnull @JsonProperty("search") Record search,
@Nonnull @JsonProperty("graphql") Record graphql,
@Nonnull @JsonProperty("integration_manifest") Record integrationManifest) {
// The Nonnull annotation is ignored by Jackson, we have to check manually
Objects.requireNonNull(core);
Objects.requireNonNull(search);
Objects.requireNonNull(graphql);
Objects.requireNonNull(integrationManifest);
this.core = core;
this.search = search;
this.graphql = graphql;
@@ -84,6 +139,7 @@ public class GHRateLimit {
// Deprecated fields
this.remaining = core.getRemaining();
this.limit = core.getLimit();
// This is wrong but is how this was implemented. Kept for backward compat.
this.reset = new Date(core.getResetEpochSeconds());
}
@@ -128,7 +184,7 @@ public class GHRateLimit {
}
/**
* Whether the rate limit reset date for this instance has passed.
* Whether the reset date for the Core API rate limit has passed.
*
* @return true if the rate limit reset date has passed. Otherwise false.
* @since 1.100
@@ -138,7 +194,7 @@ public class GHRateLimit {
}
/**
* The core object provides your rate limit status for all non-search-related resources in the REST API.
* The core object provides the rate limit status for all non-search-related resources in the REST API.
*
* @return a rate limit record
* @since 1.100
@@ -149,42 +205,43 @@ public class GHRateLimit {
}
/**
* The search object provides your rate limit status for the Search API. TODO: integrate with header limit updating.
* Issue #605.
* The search record provides the rate limit status for the Search API.
*
* @return a rate limit record
* @since 1.115
*/
@Nonnull
Record getSearch() {
public Record getSearch() {
return search;
}
/**
* The graphql object provides your rate limit status for the GraphQL API. TODO: integrate with header limit
* updating. Issue #605.
* The graphql record provides the rate limit status for the GraphQL API.
*
* @return a rate limit record
* @since 1.115
*/
@Nonnull
Record getGraphQL() {
public Record getGraphQL() {
return graphql;
}
/**
* The integration_manifest object provides your rate limit status for the GitHub App Manifest code conversion
* endpoint. TODO: integrate with header limit updating. Issue #605.
* The integration manifest record provides the rate limit status for the GitHub App Manifest code conversion
* endpoint.
*
* @return a rate limit record
* @since 1.115
*/
@Nonnull
Record getIntegrationManifest() {
public Record getIntegrationManifest() {
return integrationManifest;
}
@Override
public String toString() {
return "GHRateLimit {" + "core " + getCore().toString() + "search " + getSearch().toString() + "graphql "
+ getGraphQL().toString() + "integrationManifest " + getIntegrationManifest().toString() + '}';
return "GHRateLimit {" + "core " + getCore().toString() + ", search " + getSearch().toString() + ", graphql "
+ getGraphQL().toString() + ", integrationManifest " + getIntegrationManifest().toString() + "}";
}
@Override
@@ -206,23 +263,112 @@ public class GHRateLimit {
return Objects.hash(getCore(), getSearch(), getGraphQL(), getIntegrationManifest());
}
/**
* Merge a {@link GHRateLimit} with another one to create a new {@link GHRateLimit} keeping the latest
* {@link Record}s from each.
*
* @param newLimit
* {@link GHRateLimit} with potentially updated {@link Record}s.
* @return a merged {@link GHRateLimit} with the latest {@link Record}s from these two instances. If the merged
* instance is equal to the current instance, the current instance is returned.
*/
@Nonnull
GHRateLimit getMergedRateLimit(@Nonnull GHRateLimit newLimit) {
GHRateLimit merged = new GHRateLimit(getCore().currentOrUpdated(newLimit.getCore()),
getSearch().currentOrUpdated(newLimit.getSearch()),
getGraphQL().currentOrUpdated(newLimit.getGraphQL()),
getIntegrationManifest().currentOrUpdated(newLimit.getIntegrationManifest()));
if (merged.equals(this)) {
merged = this;
}
return merged;
}
/**
* Gets the specified {@link Record}.
*
* {@link RateLimitTarget#NONE} will return {@link UnknownLimitRecord#DEFAULT} to prevent any clients from
* accidentally waiting on that record to reset before continuing.
*
* @param rateLimitTarget
* the target rate limit record
* @return the target {@link Record} from this instance.
*/
@Nonnull
Record getRecord(@Nonnull RateLimitTarget rateLimitTarget) {
if (rateLimitTarget == RateLimitTarget.CORE) {
return getCore();
} else if (rateLimitTarget == RateLimitTarget.SEARCH) {
return getSearch();
} else if (rateLimitTarget == RateLimitTarget.GRAPHQL) {
return getGraphQL();
} else if (rateLimitTarget == RateLimitTarget.INTEGRATION_MANIFEST) {
return getIntegrationManifest();
} else if (rateLimitTarget == RateLimitTarget.NONE) {
return UnknownLimitRecord.DEFAULT;
} else {
throw new IllegalArgumentException("Unknown rate limit target: " + rateLimitTarget.toString());
}
}
/**
* A limit record used as a placeholder when the the actual limit is not known.
* <p>
* Has a large limit and long duration so that it will doesn't expire too often.
*
* @since 1.100
*/
public static class UnknownLimitRecord extends Record {
// One hour
private static final long unknownLimitResetSeconds = 60L * 60L;
private static final long defaultUnknownLimitResetSeconds = Duration.ofSeconds(30).getSeconds();
/**
* The number of seconds until a {@link UnknownLimitRecord} will expire.
*
* This is set to a somewhat short duration, rather than a long one. This avoids
* {@link {@link GitHubClient#rateLimit(RateLimitTarget)}} requesting rate limit updates continuously, but also
* avoids holding on to stale unknown records indefinitely.
*
* When merging {@link GHRateLimit} instances, {@link UnknownLimitRecord}s will be superseded by incoming
* regular {@link Record}s.
*
* @see GHRateLimit#getMergedRateLimit(GHRateLimit)
*/
static long unknownLimitResetSeconds = defaultUnknownLimitResetSeconds;
static final int unknownLimit = 1000000;
static final int unknownRemaining = 999999;
private UnknownLimitRecord() {
super(unknownLimit, unknownRemaining, System.currentTimeMillis() / 1000L + unknownLimitResetSeconds);
// The default UnknownLimitRecord is an expired record.
private static final UnknownLimitRecord DEFAULT = new UnknownLimitRecord(Long.MIN_VALUE);
// The starting current UnknownLimitRecord is an expired record.
private static UnknownLimitRecord current = DEFAULT;
/**
* Create a new unknown record that resets at the specified time.
*
* @param resetEpochSeconds
* the epoch second time when this record will expire.
*/
private UnknownLimitRecord(long resetEpochSeconds) {
super(unknownLimit, unknownRemaining, resetEpochSeconds);
}
static synchronized Record current() {
if (current.isExpired()) {
current = new UnknownLimitRecord(System.currentTimeMillis() / 1000L + unknownLimitResetSeconds);
}
return current;
}
/**
* Reset the current UnknownLimitRecord. For use during testing only.
*/
static synchronized void reset() {
current = DEFAULT;
unknownLimitResetSeconds = defaultUnknownLimitResetSeconds;
}
}
@@ -238,7 +384,7 @@ public class GHRateLimit {
private final int remaining;
/**
* Allotted API call per hour.
* Allotted API call per time period.
*/
private final int limit;
@@ -253,11 +399,14 @@ public class GHRateLimit {
private final long createdAtEpochSeconds = System.currentTimeMillis() / 1000;
/**
* The calculated time at which the rate limit will reset. Recalculated if {@link #recalculateResetDate} is
* called.
* The date at which the rate limit will reset, adjusted to local machine time if the local machine's clock not
* synchronized with to the same clock as the GitHub server.
*
* @see #calculateResetDate(String)
* @see #getResetDate()
*/
@Nonnull
private Date resetDate;
private final Date resetDate;
/**
* Instantiates a new Record.
@@ -269,15 +418,14 @@ public class GHRateLimit {
* @param resetEpochSeconds
* the reset epoch seconds
*/
@JsonCreator
public Record(@JsonProperty("limit") int limit,
@JsonProperty("remaining") int remaining,
@JsonProperty("reset") long resetEpochSeconds) {
public Record(@JsonProperty(value = "limit", required = true) int limit,
@JsonProperty(value = "remaining", required = true) int remaining,
@JsonProperty(value = "reset", required = true) long resetEpochSeconds) {
this(limit, remaining, resetEpochSeconds, null);
}
/**
* Instantiates a new Record.
* Instantiates a new Record. Called by Jackson data binding or during header parsing.
*
* @param limit
* the limit
@@ -285,26 +433,99 @@ 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, 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);
}
/**
* Recalculates the reset date using the server response date to calculate a time duration and then add that to
* the local created time for this record.
* Determine if the current {@link Record} is outdated compared to another. Rate Limit dates are only accurate
* to the second, so we look at other information in the record as well.
*
* {@link Record}s with earlier {@link #getResetEpochSeconds()} are replaced by those with later.
* {@link Record}s with the same {@link #getResetEpochSeconds()} are replaced by those with less remaining
* count.
*
* {@link UnknownLimitRecord}s compare with each other like regular {@link Record}s.
*
* {@link Record}s are replaced by {@link UnknownLimitRecord}s only when the current {@link Record} is expired
* and the {@link UnknownLimitRecord} is not. Otherwise Regular {@link Record}s are not replaced by
* {@link UnknownLimitRecord}s.
*
* Expiration is only considered after other checks, meaning expired records may sometimes be replaced by other
* expired records.
*
* @param other
* the other {@link Record}
* @return the {@link Record} that is most current
*/
Record currentOrUpdated(@Nonnull Record other) {
// This set of checks avoids most calls to isExpired()
// Depends on UnknownLimitRecord.current() to prevent continuous updating of GHRateLimit rateLimit()
if (getResetEpochSeconds() > other.getResetEpochSeconds()
|| (getResetEpochSeconds() == other.getResetEpochSeconds()
&& getRemaining() <= other.getRemaining())) {
// If the current record has a later reset
// or the current record has the same reset and fewer or same requests remaining
// Then it is most recent
return this;
} else if (!(other instanceof UnknownLimitRecord)) {
// If the above is not the case that means other has a later reset
// or the same resent and fewer requests remaining.
// If the other record is not an unknown record, the the other is more recent
return other;
} else if (this.isExpired() && !other.isExpired()) {
// The other is an unknown record.
// If the current record has expired and the other hasn't, return the other.
return other;
}
// If none of the above, the current record is most valid.
return this;
}
/**
* Recalculates the {@link #resetDate} relative to the local machine clock.
* <p>
* {@link RateLimitChecker}s and {@link RateLimitHandler}s use {@link #getResetDate()} to make decisions about
* how long to wait for until for the rate limit to reset. That means that {@link #getResetDate()} needs to be
* calculated based on the local machine clock.
* </p>
* <p>
* When we say that the clock on two machines is "synchronized", we mean that the UTC time returned from
* {@link System#currentTimeMillis()} on each machine is basically the same. For the purposes of rate limits an
* differences of up to a second can be ignored.
* </p>
* <p>
* When the clock on the local machine is synchronized to the same time as the clock on the GitHub server (via a
* time service for example), the {@link #resetDate} generated directly from {@link #resetEpochSeconds} will be
* accurate for the local machine as well.
* </p>
* <p>
* When the clock on the local machine is not synchronized with the server, the {@link #resetDate} must be
* recalculated relative to the local machine clock. This is done by taking the number of seconds between the
* response "Date" header and {@link #resetEpochSeconds} and then adding that to this record's
* {@link #createdAtEpochSeconds}.
*
* @param updatedAt
* a string date in RFC 1123
* @return reset date based on the passed date
*/
Date recalculateResetDate(String updatedAt) {
@Nonnull
private Date calculateResetDate(@CheckForNull String updatedAt) {
long updatedAtEpochSeconds = createdAtEpochSeconds;
if (!StringUtils.isBlank(updatedAt)) {
try {
@@ -319,9 +540,9 @@ public class GHRateLimit {
}
// This may seem odd but it results in an accurate or slightly pessimistic reset date
// based on system time rather than on the system being in sync with the server
// 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);
}
/**
@@ -345,14 +566,21 @@ public class GHRateLimit {
/**
* Gets the time in epoch seconds when the rate limit will reset.
*
* @return a long
* This is the raw value returned by the server. This value is not adjusted if local machine time is not
* synchronized with server time. If attempting to check when the rate limit will reset, use
* {@link #getResetDate()} or implement a {@link RateLimitChecker} instead.
*
* @return a long representing the time in epoch seconds when the rate limit will reset
* @see #getResetDate()
*/
public long getResetEpochSeconds() {
return resetEpochSeconds;
}
/**
* Whether the rate limit reset date indicated by this instance is in the
* Whether the rate limit reset date indicated by this instance is expired
*
* If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead.
*
* @return true if the rate limit reset date has passed. Otherwise false.
*/
@@ -361,7 +589,10 @@ public class GHRateLimit {
}
/**
* Returns the date at which the rate limit will reset.
* The date at which the rate limit will reset, adjusted to local machine time if the local machine's clock not
* synchronized with to the same clock as the GitHub server.
*
* If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead.
*
* @return the calculated date at which the rate limit has or will reset.
*/

View File

@@ -58,6 +58,6 @@ public class GHReaction extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").withPreview(SQUIRREL_GIRL).to("/reactions/" + id);
root.createRequest().method("DELETE").withPreview(SQUIRREL_GIRL).withUrlPath("/reactions/" + getId()).send();
}
}

View File

@@ -1,5 +1,6 @@
package org.kohsuke.github;
import com.fasterxml.jackson.databind.JsonMappingException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
@@ -31,7 +32,7 @@ public class GHRef {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -66,7 +67,13 @@ public class GHRef {
* the io exception
*/
public void updateTo(String sha, Boolean force) throws IOException {
new Requester(root).with("sha", sha).with("force", force).method("PATCH").to(url, GHRef.class).wrap(root);
root.createRequest()
.method("PATCH")
.with("sha", sha)
.with("force", force)
.withUrlPath(url)
.fetch(GHRef.class)
.wrap(root);
}
/**
@@ -76,7 +83,7 @@ public class GHRef {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").to(url);
root.createRequest().method("DELETE").withUrlPath(url).send();
}
GHRef wrap(GitHub root) {
@@ -84,11 +91,76 @@ public class GHRef {
return this;
}
static GHRef[] wrap(GHRef[] in, GitHub root) {
for (GHRef r : in) {
r.wrap(root);
/**
* Retrive a ref of the given type for the current GitHub repository.
*
* @param repository
* the repository to read from
* @param refName
* eg: heads/branch
* @return refs matching the request type
* @throws IOException
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
*/
static GHRef read(GHRepository repository, String refName) throws IOException {
// Also accept e.g. "refs/heads/branch" for consistency with createRef().
if (refName.startsWith("refs/")) {
refName = refName.replaceFirst("refs/", "");
}
return in;
// We would expect this to use `git/ref/%s` but some versions of GHE seem to not support it
// Instead use `git/refs/%s` and check the result actually matches the ref
GHRef result = null;
try {
result = repository.root.createRequest()
.withUrlPath(repository.getApiTailUrl(String.format("git/refs/%s", refName)))
.fetch(GHRef.class)
.wrap(repository.root);
} catch (IOException e) {
// If the parse exception is due to the above returning an array instead of a single ref
// that means the individual ref did not exist. Handled by result check below.
// Otherwise, rethrow.
if (!(e.getCause() instanceof JsonMappingException)) {
throw e;
}
}
// Verify that the ref returned is the one requested
// Used .endsWith(refName) instead of .equals("refs/" + refName) to workaround a GitBucket
// issue where the "ref" field omits the "refs/" prefix. "endsWith()" is functionally
// the same for this scenario - the server refs matching is prefix-based, so
// a ref that ends with the correct string will always be the correct one.
if (result == null || !result.getRef().endsWith(refName)) {
throw new GHFileNotFoundException(String.format("git/refs/%s", refName)
+ " {\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/git/refs/#get-a-reference\"}");
}
return result;
}
/**
* Retrieves all refs of the given type for the current GitHub repository.
*
* @param repository
* the repository to read from
* @param refType
* the type of reg to search for e.g. <code>tags</code> or <code>commits</code>
* @return paged iterable of all refs of the specified type
* @throws IOException
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
*/
static PagedIterable<GHRef> readMatching(GHRepository repository, String refType) throws IOException {
if (refType.startsWith("refs/")) {
refType = refType.replaceFirst("refs/", "");
}
String url = repository.getApiTailUrl(String.format("git/refs/%s", refType));
// if no types, do not end with slash just to be safe.
if (refType.equals("")) {
url = url.substring(0, url.length() - 1);
}
return repository.root.createRequest()
.withUrlPath(url)
.toIterable(GHRef[].class, item -> item.wrap(repository.root));
}
/**
@@ -125,7 +197,7 @@ public class GHRef {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
}
}

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,12 +71,13 @@ 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();
}
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -240,12 +240,12 @@ public class GHRelease extends GHObject {
* the io exception
*/
public GHAsset uploadAsset(String filename, InputStream stream, String contentType) throws IOException {
Requester builder = new Requester(owner.root);
Requester builder = owner.root.createRequest().method("POST");
String url = getUploadUrl();
// strip the helpful garbage from the url
url = url.substring(0, url.indexOf('{'));
url += "?name=" + URLEncoder.encode(filename, "UTF-8");
return builder.contentType(contentType).with(stream).to(url, GHAsset.class).wrap(this);
return builder.contentType(contentType).with(stream).withUrlPath(url).fetch(GHAsset.class).wrap(this);
}
/**
@@ -256,10 +256,11 @@ public class GHRelease extends GHObject {
* the io exception
*/
public List<GHAsset> getAssets() throws IOException {
Requester builder = new Requester(owner.root);
Requester builder = owner.root.createRequest();
GHAsset[] assets = builder.method("GET").to(getApiTailUrl("assets"), 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 {
new Requester(root).method("DELETE").to(owner.getApiTailUrl("releases/" + id));
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

@@ -21,7 +21,7 @@ public class GHReleaseBuilder {
*/
public GHReleaseBuilder(GHRepository ghRepository, String tag) {
this.repo = ghRepository;
this.builder = new Requester(repo.root);
this.builder = repo.root.createRequest().method("POST");
builder.with("tag_name", tag);
}
@@ -95,6 +95,6 @@ public class GHReleaseBuilder {
* the io exception
*/
public GHRelease create() throws IOException {
return builder.to(repo.getApiTailUrl("releases"), GHRelease.class).wrap(repo);
return builder.withUrlPath(repo.getApiTailUrl("releases")).fetch(GHRelease.class).wrap(repo);
}
}

View File

@@ -14,7 +14,7 @@ public class GHReleaseUpdater {
GHReleaseUpdater(GHRelease base) {
this.base = base;
this.builder = new Requester(base.root);
this.builder = base.root.createRequest();
}
/**
@@ -100,7 +100,8 @@ public class GHReleaseUpdater {
*/
public GHRelease update() throws IOException {
return builder.method("PATCH")
.to(base.owner.getApiTailUrl("releases/" + base.id), GHRelease.class)
.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());
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,13 @@
package org.kohsuke.github;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
@@ -87,8 +86,9 @@ public class GHRepositoryStatistics {
* This gets the actual statistics from the server. Returns null if they are still being cached.
*/
private PagedIterable<ContributorStats> getContributorStatsImpl() throws IOException {
return root.retrieve()
.asPagedIterable(getApiTailUrl("contributors"), ContributorStats[].class, item -> item.wrapUp(root));
return root.createRequest()
.withUrlPath(getApiTailUrl("contributors"))
.toIterable(ContributorStats[].class, item -> item.wrapUp(root));
}
/**
@@ -243,8 +243,9 @@ public class GHRepositoryStatistics {
* the io exception
*/
public PagedIterable<CommitActivity> getCommitActivity() throws IOException {
return root.retrieve()
.asPagedIterable(getApiTailUrl("commit_activity"), CommitActivity[].class, item -> item.wrapUp(root));
return root.createRequest()
.withUrlPath(getApiTailUrl("commit_activity"))
.toIterable(CommitActivity[].class, item -> item.wrapUp(root));
}
/**
@@ -315,24 +316,12 @@ public class GHRepositoryStatistics {
* the io exception
*/
public List<CodeFrequency> getCodeFrequency() throws IOException {
// Map to ArrayLists first, since there are no field names in the
// returned JSON.
try {
InputStream stream = root.retrieve().asStream(getApiTailUrl("code_frequency"));
CodeFrequency[] list = root.createRequest()
.withUrlPath(getApiTailUrl("code_frequency"))
.fetch(CodeFrequency[].class);
ObjectMapper mapper = new ObjectMapper();
TypeReference<ArrayList<ArrayList<Integer>>> typeRef = new TypeReference<ArrayList<ArrayList<Integer>>>() {
};
ArrayList<ArrayList<Integer>> list = mapper.readValue(stream, typeRef);
// Convert to proper objects.
ArrayList<CodeFrequency> returnList = new ArrayList<CodeFrequency>();
for (ArrayList<Integer> item : list) {
CodeFrequency cf = new CodeFrequency(item);
returnList.add(cf);
}
return returnList;
return Arrays.asList(list);
} catch (MismatchedInputException e) {
// This sometimes happens when retrieving code frequency statistics
// for a repository for the first time. It is probably still being
@@ -345,11 +334,13 @@ public class GHRepositoryStatistics {
* The type CodeFrequency.
*/
public static class CodeFrequency {
private int week;
private int additions;
private int deletions;
private CodeFrequency(ArrayList<Integer> item) {
private final int week;
private final int additions;
private final int deletions;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
private CodeFrequency(List<Integer> item) {
week = item.get(0);
additions = item.get(1);
deletions = item.get(2);
@@ -400,7 +391,7 @@ public class GHRepositoryStatistics {
* the io exception
*/
public Participation getParticipation() throws IOException {
return root.retrieve().to(getApiTailUrl("participation"), Participation.class);
return root.createRequest().withUrlPath(getApiTailUrl("participation")).fetch(Participation.class);
}
/**
@@ -431,7 +422,7 @@ public class GHRepositoryStatistics {
* @return The list of commit counts for everyone combined, for the last 52 weeks.
*/
public List<Integer> getAllCommits() {
return all;
return Collections.unmodifiableList(all);
}
/**
@@ -440,7 +431,7 @@ public class GHRepositoryStatistics {
* @return The list of commit counts for the owner, for the last 52 weeks.
*/
public List<Integer> getOwnerCommits() {
return owner;
return Collections.unmodifiableList(owner);
}
Participation wrapUp(GitHub root) {
@@ -458,34 +449,23 @@ public class GHRepositoryStatistics {
* the io exception
*/
public List<PunchCardItem> getPunchCard() throws IOException {
// Map to ArrayLists first, since there are no field names in the
// returned JSON.
InputStream stream = root.retrieve().asStream(getApiTailUrl("punch_card"));
ObjectMapper mapper = new ObjectMapper();
TypeReference<ArrayList<ArrayList<Integer>>> typeRef = new TypeReference<ArrayList<ArrayList<Integer>>>() {
};
ArrayList<ArrayList<Integer>> list = mapper.readValue(stream, typeRef);
// Convert to proper objects.
ArrayList<PunchCardItem> returnList = new ArrayList<PunchCardItem>();
for (ArrayList<Integer> item : list) {
PunchCardItem pci = new PunchCardItem(item);
returnList.add(pci);
}
return returnList;
PunchCardItem[] list = root.createRequest()
.withUrlPath(getApiTailUrl("punch_card"))
.fetch(PunchCardItem[].class);
return Arrays.asList(list);
}
/**
* The type PunchCardItem.
*/
public static class PunchCardItem {
private int dayOfWeek;
private int hourOfDay;
private int numberOfCommits;
private PunchCardItem(ArrayList<Integer> item) {
private final int dayOfWeek;
private final int hourOfDay;
private final int numberOfCommits;
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
private PunchCardItem(List<Integer> item) {
dayOfWeek = item.get(0);
hourOfDay = item.get(1);
numberOfCommits = item.get(2);

View File

@@ -47,7 +47,7 @@ public abstract class GHRepositoryTraffic implements TrafficInfo {
* @return the timestamp
*/
public Date getTimestamp() {
return GitHub.parseDate(timestamp);
return GitHubClient.parseDate(timestamp);
}
public int getCount() {

View File

@@ -0,0 +1,49 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URL;
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHRequestedAction extends GHObject {
private GHRepository owner;
private GitHub root;
private String identifier;
private String label;
private String description;
GHRequestedAction wrap(GHRepository owner) {
this.owner = owner;
wrap(owner.root);
return this;
}
GHRequestedAction wrap(GitHub root) {
this.root = root;
if (owner != null) {
owner.wrap(root);
}
return this;
}
String getIdentifier() {
return identifier;
}
String getLabel() {
return label;
}
String getDescription() {
return description;
}
/**
* @deprecated This object has no HTML URL.
*/
@Override
public URL getHtmlUrl() {
return null;
}
}

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