Compare commits

..

355 Commits

Author SHA1 Message Date
Liam Newman
f28f966040 [maven-release-plugin] prepare release github-api-1.128 2021-04-21 11:05:43 -07:00
Liam Newman
0e9cc90d31 Merge pull request #1125 from gsmet/remove-jdk-16-workaround
Remove now unnecessary JDK 16 specific workaround
2021-04-21 08:11:51 -07:00
Guillaume Smet
02e02d39b0 Remove now unnecessary JDK 16 specific workaround
Now that we are not using reflection anymore to push unsupported HTTP
methods, we can remove this workaround.
2021-04-21 13:29:33 +02:00
Liam Newman
f6e8a2c7c6 Merge pull request #1123 from bitwiseman/task/assertThat
Move to using assertThat() exclusively
2021-04-20 13:59:24 -07:00
Liam Newman
76bea5174f Merge branch 'main' into task/assertThat 2021-04-20 13:43:04 -07:00
Liam Newman
2be27d1a41 Update maven-build.yml 2021-04-20 13:42:48 -07:00
Liam Newman
cd1454ac03 More assertThat matchers 2021-04-20 12:34:01 -07:00
Liam Newman
b550910f4c Streamline assertThat calls using appropriate matchers 2021-04-20 12:16:55 -07:00
Liam Newman
d13e490be2 Enforce use of assertThat
Assert.assert* methods other than assertThat() produce less clear tests.
This change enforces using assertThat() for all verifications.
While more verbose they are generally more consistent and easier to understand.
2021-04-20 00:46:43 -07:00
Liam Newman
3d451526ef Deprecate all asserts other than assertThat 2021-04-19 19:09:47 -07:00
Liam Newman
bd38897d48 Do not inherit from Assert 2021-04-19 15:58:33 -07:00
Liam Newman
63ccbaf064 Merge pull request #1116 from hub4j/dependabot/maven/spotbugs.version-4.2.3
Chore(deps): Bump spotbugs.version from 4.2.2 to 4.2.3
2021-04-19 13:44:18 -07:00
Liam Newman
2beb806b8a Merge pull request #1120 from hub4j/dependabot/maven/com.fasterxml.jackson.core-jackson-databind-2.12.3
Chore(deps): Bump jackson-databind from 2.12.1 to 2.12.3
2021-04-19 13:44:02 -07:00
dependabot[bot]
552ba6693e Chore(deps): Bump spotbugs.version from 4.2.2 to 4.2.3
Bumps `spotbugs.version` from 4.2.2 to 4.2.3.

Updates `spotbugs` from 4.2.2 to 4.2.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.2.2...4.2.3)

Updates `spotbugs-annotations` from 4.2.2 to 4.2.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.2.2...4.2.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 20:42:57 +00:00
dependabot[bot]
2452add4d7 Chore(deps): Bump jackson-databind from 2.12.1 to 2.12.3
Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.12.1 to 2.12.3.
- [Release notes](https://github.com/FasterXML/jackson/releases)
- [Commits](https://github.com/FasterXML/jackson/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 20:42:56 +00:00
Liam Newman
0dc931ceed Merge pull request #1115 from hub4j/dependabot/github_actions/actions/cache-v2.1.5
Chore(deps): Bump actions/cache from v2.1.4 to v2.1.5
2021-04-19 13:42:48 -07:00
Liam Newman
1dfedc6a58 Merge pull request #1117 from hub4j/dependabot/maven/com.diffplug.spotless-spotless-maven-plugin-2.10.1
Chore(deps): Bump spotless-maven-plugin from 2.9.0 to 2.10.1
2021-04-19 13:42:32 -07:00
dependabot[bot]
e33046a624 Chore(deps): Bump actions/cache from v2.1.4 to v2.1.5
Bumps [actions/cache](https://github.com/actions/cache) from v2.1.4 to v2.1.5.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.4...1a9e2138d905efd099035b49d8b7a3888c653ca8)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 20:42:30 +00:00
dependabot[bot]
002b3f03da Chore(deps): Bump spotless-maven-plugin from 2.9.0 to 2.10.1
Bumps [spotless-maven-plugin](https://github.com/diffplug/project) from 2.9.0 to 2.10.1.
- [Release notes](https://github.com/diffplug/project/releases)
- [Commits](https://github.com/diffplug/project/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 20:42:26 +00:00
Liam Newman
fd1817d111 Merge pull request #1122 from hub4j/dependabot/maven/org.mockito-mockito-core-3.9.0
Chore(deps-dev): Bump mockito-core from 3.8.0 to 3.9.0
2021-04-19 13:42:20 -07:00
Liam Newman
7526b46f9d Merge pull request #1121 from hub4j/dependabot/maven/org.kohsuke.stapler-stapler-1.263
Chore(deps-dev): Bump stapler from 1.262 to 1.263
2021-04-19 13:42:07 -07:00
dependabot[bot]
169fd18a54 Chore(deps-dev): Bump mockito-core from 3.8.0 to 3.9.0
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.8.0 to 3.9.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.8.0...v3.9.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 20:41:49 +00:00
Liam Newman
0708812456 Merge pull request #1113 from hub4j/dependabot/maven/com.github.spotbugs-spotbugs-maven-plugin-4.2.3
Chore(deps): Bump spotbugs-maven-plugin from 4.2.0 to 4.2.3
2021-04-19 13:41:26 -07:00
dependabot[bot]
7d86070ac8 Chore(deps-dev): Bump stapler from 1.262 to 1.263
Bumps [stapler](https://github.com/stapler/stapler) from 1.262 to 1.263.
- [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.262...stapler-parent-1.263)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 20:41:24 +00:00
dependabot[bot]
713b85f9de Chore(deps): Bump spotbugs-maven-plugin from 4.2.0 to 4.2.3
Bumps [spotbugs-maven-plugin](https://github.com/spotbugs/spotbugs-maven-plugin) from 4.2.0 to 4.2.3.
- [Release notes](https://github.com/spotbugs/spotbugs-maven-plugin/releases)
- [Commits](https://github.com/spotbugs/spotbugs-maven-plugin/compare/spotbugs-maven-plugin-4.2.0...spotbugs-maven-plugin-4.2.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 20:41:20 +00:00
Liam Newman
4fef5bb1fc Merge pull request #1112 from hub4j/dependabot/github_actions/codecov/codecov-action-v1.4.0
Chore(deps): Bump codecov/codecov-action from v1.3.2 to v1.4.0
2021-04-19 13:41:14 -07:00
Liam Newman
f3eadcddb6 Merge pull request #1111 from hub4j/dependabot/maven/com.tngtech.archunit-archunit-0.18.0
Chore(deps-dev): Bump archunit from 0.17.0 to 0.18.0
2021-04-19 13:41:02 -07:00
Liam Newman
237171727d Merge pull request #1118 from hub4j/dependabot/maven/org.kohsuke-wordnet-random-name-1.5
Chore(deps-dev): Bump wordnet-random-name from 1.3 to 1.5
2021-04-19 13:40:40 -07:00
Liam Newman
31212d33ae Merge pull request #1119 from bitwiseman/task/main
Switch to 'main' as default branch
2021-04-19 13:40:13 -07:00
Liam Newman
8af66133d2 Switch to 'main' as default branch 2021-04-19 13:27:44 -07:00
dependabot[bot]
9578e027b1 Chore(deps-dev): Bump wordnet-random-name from 1.3 to 1.5
Bumps [wordnet-random-name](https://github.com/kohsuke/wordnet-random-name) from 1.3 to 1.5.
- [Release notes](https://github.com/kohsuke/wordnet-random-name/releases)
- [Commits](https://github.com/kohsuke/wordnet-random-name/compare/wordnet-random-name-1.3...wordnet-random-name-1.5)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 20:10:36 +00:00
dependabot[bot]
2c75b42b4e Chore(deps): Bump codecov/codecov-action from v1.3.2 to v1.4.0
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from v1.3.2 to v1.4.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v1.3.2...0e28ff86a50029a44d10df6ed4c308711925a6a8)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 20:10:13 +00:00
dependabot[bot]
7854b30a76 Chore(deps-dev): Bump archunit from 0.17.0 to 0.18.0
Bumps [archunit](https://github.com/TNG/ArchUnit) from 0.17.0 to 0.18.0.
- [Release notes](https://github.com/TNG/ArchUnit/releases)
- [Commits](https://github.com/TNG/ArchUnit/compare/v0.17.0...v0.18.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 20:10:09 +00:00
Liam Newman
cf2571858c Merge pull request #1107 from akashRindhe/feat/1076
(refactor) Rename gitHubBeforeAfter to nonRecordingGitHub #1076
2021-04-19 10:08:35 -07:00
Akash Rindhe
092815747a (refactor) Rename gitHubBeforeAfter to nonRecordingGitHub #1076
[#1076]
2021-04-18 18:41:10 +08:00
Liam Newman
649d7ed87f Merge pull request #1106 from bitwiseman/issue/1103
GHRepository#listLanguages returns correct Map type
2021-04-16 16:04:57 -07:00
Liam Newman
684560ef67 GHRepository#listLanguages returns correct Map type
This is a less than perfect solution, but it is sufficient to solve the current issue
without risking further side-effects.

Fixes #1103
2021-04-16 14:25:28 -07:00
Liam Newman
adf054ba5d Merge pull request #1105 from akashRindhe/feature/1050
GHIssue.addLabels and removeLabels() should return List<GHLabel> not void [#1050]
2021-04-16 13:10:04 -07:00
Liam Newman
dcdfee67cd Cover more code paths using existing test 2021-04-16 13:00:42 -07:00
Akash Rindhe
9d7209ec62 Merge branch 'master' into feature/1050 2021-04-17 00:23:46 +08:00
Akash Rindhe
b97e8a2c38 (feat) Return GHLabel list instead of void on GHIssue#removeLabel(s) #1050
Includes BridgeMethod annotation to keep binary compatibility
(https://github.com/hub4j/github-api/issues/1050)
2021-04-17 00:22:52 +08:00
Akash Rindhe
8bd3f391da (feat) Return GHLabel list instead of void on GHIssue#addLabels #1050
Includes BridgeMethod annotation to keep binary compatibility
(https://github.com/hub4j/github-api/issues/1050)
2021-04-17 00:06:50 +08:00
Liam Newman
5d0dbf6e2f Merge pull request #1101 from breandan/breandan-patch
Add sort and order parameters to GHContentSearchBuilder
2021-04-15 23:26:47 -07:00
Liam Newman
38f3595552 Streamline code paths 2021-04-15 15:29:50 -07:00
Liam Newman
b72e7fa2ee Add BEST_MATCH and expand test 2021-04-15 14:49:23 -07:00
breandan
659b32f5ec update test data 2021-04-15 16:49:24 -04:00
breandan
d0c326bbf5 apply spotless formatting 2021-04-15 16:42:15 -04:00
breandan
4a5aceb1f9 add content and order parameters to GHContentSearchBuilder as per #1088 2021-04-15 16:29:23 -04:00
Liam Newman
884248930e Merge pull request #1096 from gsmet/add-event-schedule
Add SCHEDULE to GHEvent and add UNKNOWN handling to GHEvent
2021-04-14 15:58:52 -07:00
Liam Newman
530d524366 Merge pull request #1095 from gsmet/no-log-on-cancel
Log 202 message at the FINE level
2021-04-14 15:04:38 -07:00
Guillaume Smet
5957da3d6d Log 202 message at the FINE level 2021-04-14 18:43:52 +02:00
Guillaume Smet
6efe428f57 Log a warning when we have an unknown enum value
Can be useful to catch values we should add instead of simply ignoring
them.
2021-04-14 18:36:36 +02:00
Guillaume Smet
25b9a2ce33 Return GHEvent.UNKNOWN in GHEventInfo.getType() if unknown 2021-04-14 18:36:13 +02:00
Guillaume Smet
0ce78016cc Be more permissive about GHEvent parsing 2021-04-14 16:31:57 +02:00
Guillaume Smet
696dd90b23 Add SCHEDULE to GHEvent
This is a valid event for scheduled workflow runs.
2021-04-14 16:26:43 +02:00
Liam Newman
e66a72387e Merge pull request #1093 from bitwiseman/task/codecov
Ignore ObsoleteUrlFactory
2021-04-12 15:52:58 -07:00
Liam Newman
874ce23dd7 Improve coverage of GitHubClient 2021-04-12 15:19:48 -07:00
Liam Newman
7479cac9a7 Ignore more 2021-04-12 14:21:19 -07:00
Liam Newman
064ce1b0bc Test again 2021-04-12 14:12:26 -07:00
Liam Newman
941573af49 One more attempt to ignore obsolete code 2021-04-12 14:00:18 -07:00
Liam Newman
2f9ff32176 Update and rename .github/codecov.yml to codecov.yml 2021-04-12 11:49:38 -07:00
Liam Newman
b84d5a7c39 Ignore ObsoleteUrlFactory 2021-04-12 11:41:09 -07:00
Liam Newman
bd19f23b3f Merge pull request #1087 from gsmet/label-payload
Add label payload
2021-04-12 10:00:18 -07:00
Liam Newman
ee047ea9b5 Merge pull request #1092 from gsmet/attach-check-runs
Properly wrap the check runs with the repository when listing them
2021-04-12 10:00:01 -07:00
Liam Newman
601f18016a Merge branch 'master' into attach-check-runs 2021-04-12 09:42:56 -07:00
Liam Newman
93abb0ed36 Merge branch 'master' into label-payload 2021-04-12 09:42:11 -07:00
Liam Newman
6453e585a9 Merge pull request #1091 from hub4j/bitwiseman-patch-2
Use codecov.io to report coverage
2021-04-12 09:41:14 -07:00
Liam Newman
3a1ed5a5b7 Create codecov.yml 2021-04-12 09:28:21 -07:00
Liam Newman
c5b45523d6 Update pom.xml 2021-04-12 09:28:04 -07:00
Guillaume Smet
bf082f2a46 Properly wrap the check runs with the repository when listing them 2021-04-12 18:15:23 +02:00
Liam Newman
672febd88b Update pom.xml 2021-04-12 09:07:48 -07:00
Liam Newman
927843ea83 Exclude some files from coverage entirely 2021-04-12 08:54:38 -07:00
Liam Newman
8fac7d317e Use codecov.io to report coverage 2021-04-12 08:34:18 -07:00
Guillaume Smet
626574ae36 Add missing javadoc for GHEventPayload.WorkflowRun 2021-04-10 12:55:05 +02:00
Guillaume Smet
8c9eb3393b Add label payload 2021-04-10 12:55:05 +02:00
Liam Newman
0c4728f46a Create codeql-analysis.yml 2021-04-09 09:52:10 -07:00
Liam Newman
837526ce5d Merge pull request #1083 from bitwiseman/issue/754
Replace reflection with X-HTTP-Method-Override
2021-04-09 09:49:10 -07:00
Liam Newman
afcfa906b8 Merge branch 'master' into issue/754 2021-04-09 09:06:07 -07:00
Liam Newman
8b3f50d4d3 [maven-release-plugin] prepare for next development iteration 2021-04-09 01:26:09 -07:00
Liam Newman
9022455d85 [maven-release-plugin] prepare release github-api-1.127 2021-04-09 01:25:56 -07:00
Liam Newman
8e20f4d9f5 Replace reflection with X-HTTP-Method-Override
Fixes #754
2021-04-08 14:36:40 -07:00
Liam Newman
7c8a7ff26e Merge pull request #1079 from gsmet/fix-jacoco-java16
Fix JaCoCo execution when we have additional Surefire options
2021-04-05 14:11:01 -07:00
Liam Newman
064d6944f3 Merge pull request #1081 from gsmet/workflow-jobs
Add support for workflow jobs
2021-04-05 14:10:28 -07:00
Liam Newman
b8b3cf9c80 Merge branch 'master' into fix-jacoco-java16 2021-04-05 13:08:53 -07:00
Liam Newman
18e7138812 Update src/main/java/org/kohsuke/github/GHWorkflowRun.java 2021-04-05 13:07:40 -07:00
Liam Newman
bfb3b94478 Update src/main/java/org/kohsuke/github/GHWorkflowRun.java 2021-04-05 13:07:32 -07:00
Liam Newman
6167d196d9 Remove enable-ci from build-only job
`enable-ci` doesn't make sense with `skipTests`.  
The point of this job is get quick results.
2021-04-05 10:13:14 -07:00
Liam Newman
43ed7c7ac7 Add verification that jacoco.exec exists after run 2021-04-05 09:58:55 -07:00
Guillaume Smet
fc98e72569 Rename GHWorkflowRunJob to GHWorkflowJob 2021-04-05 18:26:16 +02:00
Guillaume Smet
258acf79f6 Small adjustments to the API exposed to get jobs 2021-04-05 17:43:55 +02:00
Guillaume Smet
b509076d6f Add ability to get jobs and download logs from jobs 2021-04-05 15:32:46 +02:00
Guillaume Smet
f57ea4c4e9 Fix some infelicities in GHWorkflowRun javadoc 2021-04-05 15:31:30 +02:00
Liam Newman
578fe085ce Merge pull request #1074 from nvahren/repository-visibility
Add support for repository visibility
2021-04-04 23:31:53 -07:00
Liam Newman
2553a79b02 Update maven-build.yml 2021-04-04 22:53:25 -07:00
Guillaume Smet
4770316898 Fix JaCoCo execution when we have additional Surefire options
Typically on Java 16.
2021-04-04 15:21:53 +02:00
Nathan Vahrenberg
99f192d33c import nebula 2021-04-04 06:15:47 -05:00
Liam Newman
fc3bac0e77 Clean before building 2021-04-04 06:07:25 -05:00
Liam Newman
ad2990b1b6 Remove bridge method 2021-04-04 06:07:25 -05:00
nv035674
fab848a0d3 review comments 2021-04-04 06:07:25 -05:00
nv035674
4a2244e661 self review 2021-04-04 06:07:25 -05:00
nv035674
bab5399327 update existing test data 2021-04-04 06:07:25 -05:00
nv035674
52705ac695 revert testing version 2021-04-04 06:07:25 -05:00
nv035674
73d2e1db5c Add support for repository visibility 2021-04-04 06:07:25 -05:00
Liam Newman
83aa9d04ef Merge pull request #1078 from gsmet/expose-repository-workflows-artifacts
Expose repository for artifacts, workflows and workflow runs
2021-04-03 16:33:08 -07:00
Guillaume Smet
97652c6803 Expose repository for artifacts, workflows and workflow runs 2021-04-03 20:54:31 +02:00
Guillaume Smet
f40daf8488 Add some missing javadoc in the newly added GHArtifact 2021-04-03 20:45:52 +02:00
Liam Newman
3e6a5bc718 Merge pull request #1070 from hub4j/dependabot/maven/spotbugs.version-4.2.2
Chore(deps): Bump spotbugs.version from 4.2.1 to 4.2.2
2021-04-02 14:14:05 -07:00
Liam Newman
78ffe5a759 Merge pull request #1075 from gsmet/more-workflows
Add support for artifacts and logs of workflow runs
2021-04-02 14:13:43 -07:00
Guillaume Smet
9abfdc805b Add support for artifacts and logs of workflow runs 2021-04-02 22:53:08 +02:00
dependabot[bot]
9e47a2b8c6 Chore(deps): Bump spotbugs.version from 4.2.1 to 4.2.2
Bumps `spotbugs.version` from 4.2.1 to 4.2.2.

Updates `spotbugs` from 4.2.1 to 4.2.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.2.1...4.2.2)

Updates `spotbugs-annotations` from 4.2.1 to 4.2.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.2.1...4.2.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 19:55:54 +00:00
Liam Newman
feba6ed8b6 Merge pull request #1072 from hub4j/dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-5.11.0.202103091610-r
Chore(deps-dev): Bump org.eclipse.jgit from 5.10.0.202012080955-r to 5.11.0.202103091610-r
2021-04-01 12:55:05 -07:00
Liam Newman
acab40b704 Merge pull request #1073 from hub4j/dependabot/maven/org.mockito-mockito-core-3.8.0
Chore(deps-dev): Bump mockito-core from 3.7.7 to 3.8.0
2021-04-01 12:54:51 -07:00
Liam Newman
435272065f Merge pull request #1069 from hub4j/dependabot/maven/com.diffplug.spotless-spotless-maven-plugin-2.9.0
Chore(deps): Bump spotless-maven-plugin from 2.8.1 to 2.9.0
2021-04-01 12:54:37 -07:00
dependabot[bot]
c5c04672fc Chore(deps-dev): Bump mockito-core from 3.7.7 to 3.8.0
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.7.7 to 3.8.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.7.7...v3.8.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 02:00:51 +00:00
dependabot[bot]
5eef764cba Chore(deps-dev): Bump org.eclipse.jgit
Bumps org.eclipse.jgit from 5.10.0.202012080955-r to 5.11.0.202103091610-r.

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 02:00:41 +00:00
dependabot[bot]
2682e0a1e2 Chore(deps): Bump spotless-maven-plugin from 2.8.1 to 2.9.0
Bumps [spotless-maven-plugin](https://github.com/diffplug/project) from 2.8.1 to 2.9.0.
- [Release notes](https://github.com/diffplug/project/releases)
- [Commits](https://github.com/diffplug/project/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 02:00:30 +00:00
Liam Newman
a68d16d5de [maven-release-plugin] prepare for next development iteration 2021-03-30 11:52:44 -07:00
Liam Newman
304ab10cf9 [maven-release-plugin] prepare release github-api-1.126 2021-03-30 11:52:06 -07:00
Liam Newman
dc46341432 Revert "[maven-release-plugin] prepare release github-api-1.126"
This reverts commit 99aea9296e.
2021-03-30 11:51:11 -07:00
Liam Newman
99aea9296e [maven-release-plugin] prepare release github-api-1.126 2021-03-30 11:45:11 -07:00
Liam Newman
b0693037f3 Merge pull request #1067 from gsmet/proper-workflow-list-test
Fix GHRepository#listWorkflows() and add a test
2021-03-30 11:42:20 -07:00
Guillaume Smet
c19cfd98d1 Fix GHRepository#listWorkflows() and add a test 2021-03-30 19:56:52 +02:00
Liam Newman
cdc0e2ad6b [maven-release-plugin] prepare for next development iteration 2021-03-25 12:44:21 -07:00
Liam Newman
6606b5c7d1 [maven-release-plugin] prepare release github-api-1.125 2021-03-25 12:44:06 -07:00
Liam Newman
551dbf2a06 Merge pull request #1064 from gsmet/workflow-runs
Implement GHWorkflow, GHWorkflowRun and associated payloads
2021-03-25 12:20:46 -07:00
Guillaume Smet
d734237788 Add some assertions for GHWorkflow dispatch tests 2021-03-25 11:37:13 +01:00
Guillaume Smet
47e2a5aea1 Rearchitecture GHWorkflowRunTest
We don't record the polling requests and we avoid any polling when not
recording.
2021-03-25 11:00:17 +01:00
Guillaume Smet
57cdc308e8 Adjust EnumUtils method name and add javadoc 2021-03-24 21:32:10 +01:00
Guillaume Smet
8919c5f8c7 Implement GHEventPayload.WorkflowRun and GHEventPayload.WorkflowDispatch
Fixes #1037
2021-03-24 10:38:24 +01:00
Guillaume Smet
b8f00bc699 Adjust GHCheckRun so that status and conclusion are returned as enums
Provide bridge methods for compatibility.
2021-03-23 15:35:58 +01:00
Guillaume Smet
042038f480 Implement GHWorkflow and GHWorkflowRun
Most of the actions are implemented but not all.
Looks like a good first step.
2021-03-23 15:35:39 +01:00
Guillaume Smet
fb03e749bd Only execute slow-or-flaky-test if -Dtest= is not defined 2021-03-22 16:10:44 +01:00
Liam Newman
e522239832 [maven-release-plugin] prepare for next development iteration 2021-03-19 13:48:47 -07:00
Liam Newman
ae69324196 [maven-release-plugin] prepare release github-api-1.124 2021-03-19 13:48:39 -07:00
Liam Newman
5194c2d9bc Merge pull request #1061 from gsmet/remove-add-label-payload
Implement getLabel() and getChanges() for GHEventPayload.Issue
2021-03-19 13:45:12 -07:00
Liam Newman
daf5c5eb98 Merge branch 'master' into remove-add-label-payload 2021-03-19 13:23:36 -07:00
Liam Newman
a7b4c97020 Merge pull request #1062 from gsmet/add-missing-label-info
Add the missing fields for GHLabel
2021-03-19 13:17:31 -07:00
Liam Newman
420d5d06f3 Merge branch 'master' into add-missing-label-info 2021-03-19 12:54:22 -07:00
Liam Newman
a7cd052b7c Merge pull request #1063 from gsmet/update-ci-jdks
Fix CI issues
2021-03-19 12:54:05 -07:00
Guillaume Smet
6e1b943823 Disable tests messing with the environment for Java 16+
It might be possible to make them work again but it will require some
more advanced surgery.
2021-03-19 18:22:39 +01:00
Guillaume Smet
8a3559ada5 Open java.net to unnamed modules
This is needed to inject the unsupported HTTP verb. I don't know really
if we will be able to find a better option than that...
2021-03-19 18:22:39 +01:00
Guillaume Smet
ea3cbd4c71 Pass appropriate MAVEN_OPTS for JDK 11+
They are required by spotless starting JDK 16+
2021-03-19 18:22:39 +01:00
Guillaume Smet
34a1f9d6e4 Disable fail-fast for matrix builds 2021-03-19 16:49:35 +01:00
Guillaume Smet
629bd510c1 Update JDKs used by CI to the latest versions 2021-03-19 16:49:33 +01:00
Guillaume Smet
40937a5cc6 Add the missing fields for GHLabel
Fixes #1059
2021-03-19 14:56:05 +01:00
Guillaume Smet
8509957102 Implement getChanges() for GHEventPayload.Issue 2021-03-19 13:39:26 +01:00
Guillaume Smet
b0aea0c575 Expose getLabel() for GHEventPayload.Issue
It was exposed on pull requests but not issues.
2021-03-19 13:11:38 +01:00
Liam Newman
1f7f646bec Merge pull request #1054 from gsmet/fix-add-remove-labels-concurrency
Fix concurrency issues with GHIssue addLabels and removeLabels
2021-03-15 10:56:45 -07:00
Liam Newman
a59ee6a82d Add removeLabel() that throws when label missing 2021-03-12 17:56:34 -08:00
Guillaume Smet
1fefc77582 Fix concurrency issues with GHIssue addLabels and removeLabels
Fixes #1049
2021-03-10 14:03:20 +01:00
Liam Newman
199eee4e25 Merge pull request #1055 from gsmet/update-contributing
Adjust wording used to create the token and give a bit more guidance
2021-03-09 18:45:38 -08:00
Guillaume Smet
854df5321b Adjust wording used to create the token and give a bit more guidance 2021-03-09 16:20:55 +01:00
Liam Newman
bd509070ac Merge pull request #1052 from bitwiseman/task/test-void-bridge
Test that void bridge methods are created
2021-03-05 11:34:10 -08:00
Liam Newman
a8c7c97d06 Test that void bridge methods are created 2021-03-05 11:16:06 -08:00
Liam Newman
6d86cfb4f6 Merge pull request #1047 from hub4j/dependabot/maven/junit-junit-4.13.2
Chore(deps-dev): Bump junit from 4.13.1 to 4.13.2
2021-03-01 09:20:28 -08:00
dependabot[bot]
fb3e956502 Chore(deps-dev): Bump junit from 4.13.1 to 4.13.2
Bumps [junit](https://github.com/junit-team/junit4) from 4.13.1 to 4.13.2.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.13.1.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.13.1...r4.13.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-01 17:19:55 +00:00
Liam Newman
9b0dbe6f34 Merge pull request #1044 from hub4j/dependabot/maven/org.codehaus.mojo-animal-sniffer-maven-plugin-1.20
Chore(deps): Bump animal-sniffer-maven-plugin from 1.19 to 1.20
2021-03-01 09:19:28 -08:00
dependabot[bot]
c10c7237a7 Chore(deps): Bump animal-sniffer-maven-plugin from 1.19 to 1.20
Bumps [animal-sniffer-maven-plugin](https://github.com/mojohaus/animal-sniffer) from 1.19 to 1.20.
- [Release notes](https://github.com/mojohaus/animal-sniffer/releases)
- [Commits](https://github.com/mojohaus/animal-sniffer/compare/animal-sniffer-parent-1.19...animal-sniffer-parent-1.20)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-01 17:19:16 +00:00
Liam Newman
36612fe97f Merge pull request #1045 from hub4j/dependabot/maven/spotbugs.version-4.2.1
Chore(deps): Bump spotbugs.version from 4.1.3 to 4.2.1
2021-03-01 09:18:58 -08:00
Liam Newman
18e2056a10 Merge pull request #1042 from hub4j/dependabot/maven/com.tngtech.archunit-archunit-0.17.0
Chore(deps-dev): Bump archunit from 0.16.0 to 0.17.0
2021-03-01 09:18:32 -08:00
Liam Newman
8c8f1451d4 Merge pull request #1043 from hub4j/dependabot/github_actions/actions/cache-v2.1.4
Chore(deps): Bump actions/cache from v2 to v2.1.4
2021-03-01 09:18:14 -08:00
dependabot[bot]
be67f1d9e2 Chore(deps): Bump spotbugs.version from 4.1.3 to 4.2.1
Bumps `spotbugs.version` from 4.1.3 to 4.2.1.

Updates `spotbugs` from 4.1.3 to 4.2.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.1.3...4.2.1)

Updates `spotbugs-annotations` from 4.1.3 to 4.2.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.1.3...4.2.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-01 02:00:31 +00:00
dependabot[bot]
90bc250269 Chore(deps): Bump actions/cache from v2 to v2.1.4
Bumps [actions/cache](https://github.com/actions/cache) from v2 to v2.1.4.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2...26968a09c0ea4f3e233fdddbafd1166051a095f6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-01 02:00:20 +00:00
dependabot[bot]
1bd178654f Chore(deps-dev): Bump archunit from 0.16.0 to 0.17.0
Bumps [archunit](https://github.com/TNG/ArchUnit) from 0.16.0 to 0.17.0.
- [Release notes](https://github.com/TNG/ArchUnit/releases)
- [Commits](https://github.com/TNG/ArchUnit/compare/v0.16.0...v0.17.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-01 02:00:18 +00:00
Liam Newman
f22bf160f9 [maven-release-plugin] prepare for next development iteration 2021-02-26 15:20:10 -08:00
Liam Newman
4261c42949 [maven-release-plugin] prepare release github-api-1.123 2021-02-26 15:20:00 -08:00
Liam Newman
40cfb85a8e Merge pull request #1041 from bitwiseman/task/eol
Only run spotless:check as part of the lifecyle
2021-02-26 15:18:19 -08:00
Liam Newman
f08299b134 Only run spotless:check as part of the lifecyle
Users can run spotless:apply as they see fit.
2021-02-26 14:51:53 -08:00
Liam Newman
a04ab45abc Merge pull request #1040 from bitwiseman/bugfix/reposity-id-type
Fix the type of the id parameter of Github#getRepositoryById
2021-02-26 14:27:41 -08:00
Liam Newman
0647df2d2b Add tests for getRepositoryById 2021-02-26 13:02:12 -08:00
Liam Newman
d4cc3af1e9 Merge pull request #967 from chids/download-repository-archives
Add support for downloading zip and tar archives of repositories.
2021-02-26 12:48:42 -08:00
Liam Newman
936ab499ce Formatting 2021-02-26 12:08:14 -08:00
Liam Newman
453f475b4e Merge pull request #1029 from hub4j/dependabot/maven/com.fasterxml.jackson.core-jackson-databind-2.12.1
Chore(deps): Bump jackson-databind from 2.10.2 to 2.12.1
2021-02-26 11:59:24 -08:00
Liam Newman
bda3855b86 Merge pull request #1039 from bitwiseman/task/jwt
Allow for time skew in JWT authentication
2021-02-26 11:52:22 -08:00
Liam Newman
772a6c112b Remove consumers, use FunctionThrows 2021-02-26 11:12:51 -08:00
Liam Newman
9b4134cada Allow for time skew in JWT authentication 2021-02-26 10:51:07 -08:00
Liam Newman
ed9f54006d Merge branch 'master' into dependabot/maven/com.fasterxml.jackson.core-jackson-databind-2.12.1 2021-02-25 02:04:36 -08:00
Liam Newman
3b1f176544 Merge remote-tracking branch 'upstream/master' into download-repository-archives 2021-02-11 17:12:11 -08:00
Liam Newman
d2732bcf54 Merge pull request #1033 from uhafner/missing-text-in-extra-annotations
Make sure that `output.text` is set in each checks call
2021-02-08 03:16:24 -08:00
M. Abdullah Onus
a1461f401a Update src/main/java/org/kohsuke/github/GitHub.java
Co-authored-by: Liam Newman <bitwiseman@gmail.com>
2021-02-06 20:13:33 +03:00
Ulli Hafner
f9fd30275c Make sure that output.text is set in each checks call.
If a GitHub checks contains more than 50 annotations, then the
check is split into several calls. This fix makes sure that all
additional calls will not only copy the properties `title` and
`summary` but also the previously missing property `text`.
2021-02-04 19:47:49 +01:00
Liam Newman
eeea14dab4 Merge pull request #1028 from hub4j/dependabot/maven/com.tngtech.archunit-archunit-0.16.0
Chore(deps-dev): Bump archunit from 0.15.0 to 0.16.0
2021-02-01 14:26:20 -08:00
dependabot[bot]
1df807a198 Chore(deps-dev): Bump archunit from 0.15.0 to 0.16.0
Bumps [archunit](https://github.com/TNG/ArchUnit) from 0.15.0 to 0.16.0.
- [Release notes](https://github.com/TNG/ArchUnit/releases)
- [Commits](https://github.com/TNG/ArchUnit/compare/v0.15.0...v0.16.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-01 21:27:56 +00:00
Liam Newman
0848287069 Merge pull request #1027 from hub4j/dependabot/maven/org.mockito-mockito-core-3.7.7
Chore(deps-dev): Bump mockito-core from 3.6.28 to 3.7.7
2021-02-01 13:27:25 -08:00
dependabot[bot]
334b37a256 Chore(deps-dev): Bump mockito-core from 3.6.28 to 3.7.7
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.6.28 to 3.7.7.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.6.28...v3.7.7)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-01 21:27:13 +00:00
Liam Newman
8776a3b672 Merge pull request #1031 from hub4j/dependabot/maven/com.diffplug.spotless-spotless-maven-plugin-2.7.0
Chore(deps): Bump spotless-maven-plugin from 2.6.1 to 2.7.0
2021-02-01 13:26:34 -08:00
Liam Newman
657550f767 Merge pull request #1030 from hub4j/dependabot/maven/com.github.spotbugs-spotbugs-maven-plugin-4.2.0
Chore(deps): Bump spotbugs-maven-plugin from 4.1.4 to 4.2.0
2021-02-01 13:26:16 -08:00
dependabot[bot]
45a0114f75 Chore(deps): Bump spotless-maven-plugin from 2.6.1 to 2.7.0
Bumps [spotless-maven-plugin](https://github.com/diffplug/project) from 2.6.1 to 2.7.0.
- [Release notes](https://github.com/diffplug/project/releases)
- [Commits](https://github.com/diffplug/project/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-01 02:01:26 +00:00
dependabot[bot]
a8ddd3e12a Chore(deps): Bump spotbugs-maven-plugin from 4.1.4 to 4.2.0
Bumps [spotbugs-maven-plugin](https://github.com/spotbugs/spotbugs-maven-plugin) from 4.1.4 to 4.2.0.
- [Release notes](https://github.com/spotbugs/spotbugs-maven-plugin/releases)
- [Commits](https://github.com/spotbugs/spotbugs-maven-plugin/compare/spotbugs-maven-plugin-4.1.4...spotbugs-maven-plugin-4.2.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-01 02:00:31 +00:00
dependabot[bot]
b668396151 Chore(deps): Bump jackson-databind from 2.10.2 to 2.12.1
Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.10.2 to 2.12.1.
- [Release notes](https://github.com/FasterXML/jackson/releases)
- [Commits](https://github.com/FasterXML/jackson/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-01 02:00:29 +00:00
Liam Newman
9e7c33369c Merge pull request #1026 from jordiolivares/feature/timestamp-support
Add timestamp field support for the commits sent by GHEventPayload.Push
2021-01-28 18:00:48 -08:00
Jordi Olivares Provencio
8943ca6d1a Reformat the JavaDoc 2021-01-28 22:36:24 +01:00
Jordi Olivares Provencio
b3460c1f9d Add timestamp field support for the commits sent by GHEventPayload.Push 2021-01-28 22:34:09 +01:00
Liam Newman
5166c9265f Merge pull request #1022 from bitwiseman/task/enum-coverage
Code Coverage update
2021-01-25 12:24:24 -08:00
Liam Newman
35c8cfa01d Push method code coverage bar to 50 percent
This change adds or update a swath of tests to push method code coverage numbers up.
Yes, method coverage is not super meaningful, but it is one metric that we can use to
ensure at least minimal coverage of this library.

Almost no product changes in here.
2021-01-25 12:08:57 -08:00
Liam Newman
8e6dbf3772 [maven-release-plugin] prepare for next development iteration 2021-01-14 20:14:08 -08:00
Liam Newman
cb381dfa06 [maven-release-plugin] prepare release github-api-1.122 2021-01-14 20:13:57 -08:00
Liam Newman
80124e3b85 Merge pull request #1021 from bitwiseman/jwt-string
Allow JWT from string
2021-01-14 20:09:21 -08:00
Liam Newman
7aae27e36f Allow JWT from string 2021-01-14 14:25:51 -08:00
Liam Newman
b212956fbb [maven-release-plugin] prepare for next development iteration 2021-01-14 13:19:41 -08:00
Liam Newman
d033355e84 [maven-release-plugin] prepare release github-api-1.121 2021-01-14 13:19:31 -08:00
Liam Newman
59d7a117d0 [maven-release-plugin] prepare for next development iteration 2021-01-14 10:51:52 -08:00
Liam Newman
dfbb38c5f1 [maven-release-plugin] prepare release github-api-1.120 2021-01-14 10:51:41 -08:00
Liam Newman
3f9954144a Merge pull request #945 from MarcosCela/feat/credential-provider-refresh
Feat/credential provider refresh
2021-01-14 10:37:30 -08:00
Liam Newman
1b84efdbfa Add GitHub.DependentAuthorizationProvider
Rather than exposing an unsafe wrapper for GitHub instances, I added a base class
that can be extended by anyone wanting to implement an authorization provider
that needs a GitHub instance to generate it's authorization string.
2021-01-14 10:32:25 -08:00
Liam Newman
c33e78a7dc Create authorization package 2021-01-14 09:23:17 -08:00
Marcos.Cela
747c759bbb fix code violations again 2021-01-08 10:10:44 +01:00
Marcos.Cela
e0a709676e fix format violations 2021-01-08 09:56:05 +01:00
Marcos.Cela
a96275c286 tests for JWTTokenProvider, verifying the "Authentication" header
This test basically ensures that the requests made with a
JWTTokenProvider follow a valid Authentication pattern,
verifying that the header "conforms" to a valid JWT token
More information on JWT tokens can be found at:

- https://jwt.io/introduction/
2021-01-08 09:52:50 +01:00
Marcos.Cela
ca7c809feb remove unused field MINUTES_10 from JWTTokenProvider 2021-01-08 08:21:35 +01:00
Marcos Cela López
a8a0bcb7db Merge branch 'master' into feat/credential-provider-refresh 2021-01-07 12:03:27 +01:00
Marcos.Cela
0e2bf23830 add CODE_SCANNING_ALERT to GHEvent enum 2021-01-07 11:32:33 +01:00
Marcos.Cela
44a8b797fb fix: JWTTokenProvider has an incorrect value for the returned authorization header
more info:
https://docs.github.com/en/free-pro-team@latest/developers/apps/authenticating-with-github-apps#authenticating-as-a-github-app
2021-01-07 11:23:22 +01:00
Marcos.Cela
cdede298a9 rename OrgInstallationAuthorizationProvider to OrgAppInstallationAuthorizationProvider 2021-01-07 09:53:19 +01:00
Marcos.Cela
f6ac4d3559 rename: credential provider -> authorization provider
This includes renames in comments, related methods,
javadocs and fields/variables.
2021-01-07 09:46:30 +01:00
Liam Newman
7e1531dbca [maven-release-plugin] prepare for next development iteration 2021-01-05 17:27:23 -08:00
Liam Newman
9aeb422157 [maven-release-plugin] prepare release github-api-1.119 2021-01-05 17:27:08 -08:00
Liam Newman
fba0f8cf8e Merge pull request #1015 from seregamorph/feature/mock-previews
Fix mocking Previews
2021-01-05 17:23:55 -08:00
seregamorph
0f4a5227e1 internal package 2021-01-05 23:03:49 +03:00
seregamorph
d16a752b43 Fix mocking Previews 2021-01-05 18:50:24 +03:00
Liam Newman
4d9aed90d6 Merge branch 'master' into download-repository-archives 2021-01-04 09:24:25 -08:00
Liam Newman
4bec27fd49 [maven-release-plugin] prepare for next development iteration 2021-01-04 01:48:27 -08:00
Liam Newman
be3bd74bb7 [maven-release-plugin] prepare release github-api-1.118 2021-01-04 01:48:16 -08:00
Liam Newman
f1720b7bbc Move archive readers to use new functional interfaces 2021-01-04 01:32:36 -08:00
Liam Newman
7a79a18d8f Add functional interfaces 2021-01-04 01:30:59 -08:00
Liam Newman
472034c950 Add codeload and fix redirects 2021-01-04 01:27:47 -08:00
Liam Newman
0b14cee817 Merge pull request #1011 from hub4j/dependabot/maven/org.kohsuke.stapler-stapler-1.262
Chore(deps-dev): Bump stapler from 1.260 to 1.262
2021-01-03 23:43:02 -08:00
M. Abdullah Onus
b50ab56f9e Fix linting 2021-01-03 15:52:06 +03:00
M. Abdullah Onus
26d30663c4 Add deprecated not to Github#getRepositoryById 2021-01-03 15:44:28 +03:00
M. Abdullah Onus
ffecc390eb Fix the type of the id parameter of Github#getRepositoryById 2021-01-03 15:35:00 +03:00
dependabot[bot]
252ca04084 Chore(deps-dev): Bump stapler from 1.260 to 1.262
Bumps [stapler](https://github.com/stapler/stapler) from 1.260 to 1.262.
- [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.260...stapler-parent-1.262)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-01 02:00:35 +00:00
Liam Newman
aae5c56a31 Merge remote-tracking branch 'upstream/master' into download-repository-archives 2020-12-31 09:55:28 -08:00
Liam Newman
6670446037 Reenable GitHubBuilder tests 2020-12-31 09:49:51 -08:00
Liam Newman
bd39b07bb5 Fix javadoc issues 2020-12-30 14:07:37 -08:00
Liam Newman
a9438b6121 Move tests to use JWTTokenProvider 2020-12-30 10:46:45 -08:00
Liam Newman
f546cf4521 Use only credential providers internally to track credentials
Removes extra fields from GitHubClient.
2020-12-30 09:52:30 -08:00
Liam Newman
43efa78750 Post-merge fixes 2020-12-29 09:29:30 -08:00
Liam Newman
9e3de43802 Merge remote-tracking branch 'upstream/master' into feat/credential-provider-refresh 2020-12-29 09:19:09 -08:00
Liam Newman
dc615e432e Merge pull request #985 from lower-case/bugfix-883
Fixes null commit date
2020-12-28 22:06:47 -08:00
Liam Newman
cf9caa6af5 Update test to check values 2020-12-28 22:00:44 -08:00
Liam Newman
15f748358d Merge remote-tracking branch 'upstream/master' into bugfix-883 2020-12-28 20:02:24 -08:00
Liam Newman
b30d648623 Merge pull request #939 from jgangemi/jae/bulk-update
- bulk update of repository options
2020-12-28 19:54:44 -08:00
Liam Newman
33d70560b8 Deprecate templateRepository() for isTemplate() 2020-12-28 18:44:30 -08:00
Liam Newman
865a49d2e8 Update GHRepository method to use Setter
It appears that the correct way to pass these booleans is as booleans not as strings.

Fixes #765
2020-12-28 18:07:32 -08:00
Liam Newman
4fca68c25c Add GHRepository.Setter 2020-12-28 17:03:36 -08:00
Liam Newman
f131a0c1c2 Formatting fixes 2020-12-28 16:26:23 -08:00
Liam Newman
cd4368fa79 Merge remote-tracking branch 'upstream/master' into jae/bulk-update 2020-12-28 16:25:31 -08:00
Liam Newman
4ec4b160b0 Update contributing.md for more clarity 2020-12-28 16:18:04 -08:00
Liam Newman
a585b4957f Merge pull request #1004 from bitwiseman/object-base
Make root field transient in all classes
2020-12-28 16:05:48 -08:00
Liam Newman
e6b02b3bed Merge branch 'master' into object-base 2020-12-28 15:48:41 -08:00
Liam Newman
1ef0ec0432 Update src/main/java/org/kohsuke/github/GitHub.java
Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com>
2020-12-28 15:47:28 -08:00
Liam Newman
2e87bd86a1 Merge pull request #1006 from hub4j/dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-5.10.0.202012080955-r
Chore(deps-dev): Bump org.eclipse.jgit from 5.9.0.202009080501-r to 5.10.0.202012080955-r
2020-12-28 15:46:53 -08:00
Liam Newman
0228a0d023 Merge pull request #1010 from hub4j/dependabot/maven/org.slf4j-slf4j-simple-1.7.30
Chore(deps-dev): Bump slf4j-simple from 1.7.2 to 1.7.30
2020-12-28 15:46:33 -08:00
dependabot[bot]
6365f3749d Chore(deps-dev): Bump slf4j-simple from 1.7.2 to 1.7.30
Bumps [slf4j-simple](https://github.com/qos-ch/slf4j) from 1.7.2 to 1.7.30.
- [Release notes](https://github.com/qos-ch/slf4j/releases)
- [Commits](https://github.com/qos-ch/slf4j/compare/v_1.7.2...v_1.7.30)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-28 23:45:31 +00:00
dependabot[bot]
25c18130f9 Chore(deps-dev): Bump org.eclipse.jgit
Bumps org.eclipse.jgit from 5.9.0.202009080501-r to 5.10.0.202012080955-r.

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-28 23:45:30 +00:00
Liam Newman
436c19634d Merge pull request #1009 from hub4j/dependabot/maven/com.github.spotbugs-spotbugs-maven-plugin-4.1.4
Chore(deps): Bump spotbugs-maven-plugin from 4.0.4 to 4.1.4
2020-12-28 15:45:13 -08:00
Liam Newman
1a6facc685 Merge pull request #1008 from hub4j/dependabot/maven/com.tngtech.archunit-archunit-0.15.0
Chore(deps-dev): Bump archunit from 0.14.1 to 0.15.0
2020-12-28 15:44:45 -08:00
Liam Newman
bd0093c8ea Change reader and writer to no longer deprecated
While still no recommended, these methods are more recommended than
users creating their own.  These will continue to work even when
internals change, whereas user configured readers or writers may not.
2020-12-28 12:39:21 -08:00
Liam Newman
e150280010 Merge remote-tracking branch 'upstream/master' into object-base 2020-12-28 10:52:16 -08:00
dependabot[bot]
827fd5e472 Chore(deps): Bump spotbugs-maven-plugin from 4.0.4 to 4.1.4
Bumps [spotbugs-maven-plugin](https://github.com/spotbugs/spotbugs-maven-plugin) from 4.0.4 to 4.1.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.4...spotbugs-maven-plugin-4.1.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-28 18:51:35 +00:00
dependabot[bot]
f89fbc67b9 Chore(deps-dev): Bump archunit from 0.14.1 to 0.15.0
Bumps [archunit](https://github.com/TNG/ArchUnit) from 0.14.1 to 0.15.0.
- [Release notes](https://github.com/TNG/ArchUnit/releases)
- [Commits](https://github.com/TNG/ArchUnit/compare/v0.14.1...v0.15.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-28 18:51:35 +00:00
Liam Newman
c567a88892 Merge pull request #1005 from bitwiseman/task/spotless
Switch to using spotless plugin for formatting
2020-12-28 10:51:06 -08:00
Liam Newman
6a39d7fca5 Trim whitespace and end with newline 2020-12-23 17:13:27 -08:00
Liam Newman
a15e67f065 Switch formatting to spotless
This is change includes minimal changes required to make the switch
2020-12-23 17:13:27 -08:00
Liam Newman
7a1bce9578 Merge branch 'master' into object-base 2020-12-22 09:17:52 -08:00
Liam Newman
f2b4de7943 Merge branch 'master' into jae/bulk-update 2020-12-22 08:32:12 -08:00
Liam Newman
b3ff4ac6d9 Merge pull request #984 from gsmet/okhttp-close-responsebody
Close Okhttp ResponseBody instances when closing the InputStream
2020-12-21 10:20:50 -08:00
Liam Newman
1c56e7fab5 Add missing argument 2020-12-21 09:28:44 -08:00
Liam Newman
70ba4df385 Make root field transient in all classes 2020-12-18 14:58:12 -08:00
Liam Newman
8062c705e8 Merge branch 'master' into jae/bulk-update 2020-12-17 15:12:19 -08:00
Liam Newman
fafb23c1a6 Merge pull request #1002 from marcoferrer/add-sdk-beta-annotation
Implement BetaApi annotation for hub4j sdk
2020-12-17 12:57:01 -08:00
Marco Ferrer
4e7ac7030c Add beta api annotation to project 2020-12-16 16:39:48 -05:00
Liam Newman
4803daca5a Merge branch 'master' into okhttp-close-responsebody 2020-12-15 16:21:08 -08:00
Liam Newman
facfc61316 Merge branch 'master' into jae/bulk-update 2020-12-15 16:08:41 -08:00
Liam Newman
e3e495bfb1 Merge pull request #1001 from marcoferrer/preview-enum-and-cleanup
Implement static typing for previews and clean up usage declarations
2020-12-15 15:39:06 -08:00
Liam Newman
e007284d2f Merge branch 'master' into preview-enum-and-cleanup 2020-12-15 15:20:30 -08:00
Liam Newman
1da8416ebd Merge pull request #983 from marcoferrer/add-preview-arch-rules
Add arch test for preview API usage
2020-12-15 15:20:05 -08:00
Marco Ferrer
79b49a469c Clean up preview declarations 2020-12-15 14:39:00 -05:00
Marco Ferrer
5888efcaef Merge branch 'master' into add-preview-arch-rules 2020-12-15 12:41:51 -05:00
Marco Ferrer
459d1b4f56 update arch tests to add enum checks 2020-12-15 12:41:02 -05:00
Liam Newman
9151102bda Merge pull request #998 from bitwiseman/obsolete-okhttp
Deprecate OkHttp 2.x connector
2020-12-12 16:49:13 -08:00
Liam Newman
3819984add Merge pull request #999 from tginiotis-at-work/targeturl-for-status
"target_url" for the payload of the status event
2020-12-12 16:48:16 -08:00
Tadas Giniotis
3b58fbc186 test "target_url" 2020-12-12 23:53:40 +02:00
Tadas Giniotis
55e589b3d9 add the "target_url" field for "status" events 2020-12-12 23:46:03 +02:00
Liam Newman
e64d64d8d8 Deprecate OkHttp 2.x connector
OkHttp 2.x is unsupported.  OkHttpUrlFactory contains bugs and limiations which will not
be fixed and also cannot be mitigated by this library.  Users should move to OkHttp3.

Closes #997
2020-12-11 17:17:08 -08:00
Jae Gangemi
37c2d9135b - bulk update of repository options 2020-12-11 16:56:26 -07:00
Liam Newman
30c96221bd Make wiremock less noisy with slf4j simple logger during tests 2020-12-11 13:54:47 -08:00
Liam Newman
bf7305e3f8 Merge pull request #990 from hub4j/dependabot/maven/org.apache.maven.plugins-maven-project-info-reports-plugin-3.1.1
Chore(deps): Bump maven-project-info-reports-plugin from 3.1.0 to 3.1.1
2020-12-09 08:54:55 -08:00
Liam Newman
3b12a229c3 Merge branch 'master' into dependabot/maven/org.apache.maven.plugins-maven-project-info-reports-plugin-3.1.1 2020-12-04 14:41:12 -08:00
Liam Newman
5726ceb8dc Merge branch 'master' into okhttp-close-responsebody 2020-12-03 16:55:48 -08:00
Liam Newman
c06c06624d Merge pull request #981 from eSentire/AffiliationFilter
Add affiliation filter for collaborators
2020-12-03 16:54:02 -08:00
Rob Rodrigues
ad40d7071e Streamline per feedback 2020-12-02 11:41:13 -08:00
Rob Rodrigues
f55a39eb90 Merge branch 'master' into AffiliationFilter 2020-12-01 20:08:54 -08:00
Rob Rodrigues
c3869bee31 Reverted changes which added filter unnecessarily, cleanup, add test cache, enable test 2020-12-01 19:50:24 -08:00
dependabot[bot]
6eac15df0f Chore(deps): Bump maven-project-info-reports-plugin from 3.1.0 to 3.1.1
Bumps [maven-project-info-reports-plugin](https://github.com/apache/maven-project-info-reports-plugin) from 3.1.0 to 3.1.1.
- [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.1.0...maven-project-info-reports-plugin-3.1.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-01 18:21:10 +00:00
Liam Newman
6f5d3c32c3 Spotbugs 4.1.3 2020-12-01 10:07:46 -08:00
Liam Newman
68ef40e4d0 Merge branch 'master' into bugfix-883 2020-12-01 09:11:23 -08:00
Liam Newman
4046bc4f72 Merge pull request #991 from hub4j/dependabot/maven/org.mockito-mockito-core-3.6.28
Chore(deps-dev): Bump mockito-core from 3.6.0 to 3.6.28
2020-12-01 08:49:54 -08:00
dependabot[bot]
1b8d131915 Chore(deps-dev): Bump mockito-core from 3.6.0 to 3.6.28
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.6.0 to 3.6.28.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.6.0...v3.6.28)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-01 02:00:23 +00:00
Guillaume Smet
f5ad332d28 Properly close ResponseBody when closing the InputStream
ResponseBody objects from Okhttp needs to be closed and, right now, we
just close the InputStream which is not sufficient.

I noticed that because I saw some warnings about leaked ResponseBody
instances in my logs.
2020-11-29 21:56:11 +01:00
Lovekesh Garg
938603ff60 Fixes null commit date 2020-11-28 17:20:28 +05:30
Rob Rodrigues
17af78f2bb Merge branch 'master' into AffiliationFilter 2020-11-25 13:10:09 -08:00
Marco Ferrer
7588267743 Add arch test for preview API usage 2020-11-25 13:16:04 -05:00
Liam Newman
ed4f9c8176 Merge pull request #960 from marcoferrer/update-deployments-api
Implement deployment API support for ant-man and flash previews
2020-11-25 06:37:36 -08:00
Liam Newman
bbb46e88b0 Merge branch 'master' into update-deployments-api 2020-11-25 06:18:07 -08:00
Rob Rodrigues
3db7aac0d8 Merge branch 'master' into AffiliationFilter 2020-11-24 12:52:48 -08:00
Liam Newman
fdbbd2e563 [maven-release-plugin] prepare for next development iteration 2020-11-24 11:13:29 -08:00
Marco Ferrer
da2aaff9e5 Merge branch 'master' into update-deployments-api 2020-11-24 11:37:36 -05:00
Marco Ferrer
4bba692170 Merge branch 'master' into update-deployments-api 2020-11-23 17:20:40 -05:00
Marco Ferrer
59b61cd8be add deprecated to logUrl field 2020-11-23 17:19:57 -05:00
Marco Ferrer
247b013e16 add deprecated annotations to preview usage 2020-11-23 15:51:57 -05:00
Rob Rodrigues
3c56f1f076 Merge branch 'master' into AffiliationFilter 2020-11-19 15:57:36 -08:00
Rob Rodrigues
7fee1fcc74 Add affiliation filter for collaborators 2020-11-18 17:58:51 -08:00
Liam Newman
d7931777bc Merge branch 'master' into download-repository-archives 2020-11-05 08:38:31 -08:00
Mårten Gustafson
bb48d55bd4 Add support for downloading zip and tar archives of repositories. 2020-10-20 21:45:27 +02:00
Marcos.Cela
610b02968e exlude org.kohsuke.github.extras.auth.* from code coverage
This is a package for examples/extra implementations
2020-10-05 13:57:52 +02:00
Marcos.Cela
a7112c42df linting: JWTTokenProvider.java 2020-10-05 13:48:37 +02:00
Marcos.Cela
8a474a3b00 add: example for Org Installation token on extras package 2020-10-05 13:39:30 +02:00
Marcos.Cela
59e18d155e add dependencies for jwt token generation
These dependencies are marked as "provided" because they are only
used in the extras package
2020-10-05 13:39:01 +02:00
Marco Ferrer
12ca5d8063 update deployment wiremocks 2020-10-02 17:40:47 -04:00
Marco Ferrer
c959e0a928 update accept header in wiremocks 2020-10-02 17:37:21 -04:00
Marco Ferrer
89a08b021d formatting 2020-10-02 17:14:28 -04:00
Marco Ferrer
04b553cdec update deployment status checks 2020-10-02 17:12:10 -04:00
Marco Ferrer
15e9ee30ee formatting 2020-10-02 16:52:23 -04:00
Marco Ferrer
a0d650a86c update deployment tests to read new fields 2020-10-02 16:47:01 -04:00
Marco Ferrer
1a6ad48e08 formatting 2020-10-02 16:35:46 -04:00
Marco Ferrer
7c82eeb018 Support deployment api previews ant-man and flash 2020-10-02 15:57:52 -04:00
Marco Ferrer
b188e74ee0 Add new const for flash preview 2020-10-02 14:16:50 -04:00
Marcos.Cela
ff790eeefb formatting of OrgInstallationCredentialProvider.java 2020-09-30 16:48:54 +02:00
Marcos.Cela
97e918da03 remove unused JWTTokenProvider (we are now using a github client) 2020-09-30 16:39:41 +02:00
Marcos.Cela
4f30998873 OrgInstallationCredentialProvider now receives a pre-configured client
This is required to pass integration tests. In terms of functionality,
the user should be able to provide a client with the given token provider.
It additionally increases control (e.g: usage of proxies)

Add tests
2020-09-29 16:13:23 +02:00
Marcos.Cela
a0fc478a28 remove final modifier from credentialProvider (required for tests) 2020-09-29 16:12:06 +02:00
Marcos.Cela
bb03fd1968 use Date#after instead of compareTo 2020-09-28 16:11:16 +02:00
Marcos.Cela
0c65f74662 formatting 2020-09-28 14:45:00 +02:00
Marcos.Cela
29ac2bd4f5 return a correctly formatted token 2020-09-28 14:24:01 +02:00
Marcos.Cela
0d8b4f32e8 document oauthAccessToken 2020-09-28 13:48:56 +02:00
Marcos.Cela
83db7f24eb document CredentialProvider @throws 2020-09-28 13:48:26 +02:00
Marcos.Cela
5f9976a193 formatting for OrgInstallationCredentialProvider 2020-09-28 13:37:59 +02:00
Marcos.Cela
9480ef485b withCredentialProvider is now public 2020-09-28 13:34:14 +02:00
Marcos.Cela
a9b7432584 formatting 2020-09-28 13:28:13 +02:00
Marcos.Cela
6d7081910f add OrgInstallationCredentialProvider and JWTTokenProvider
The JWTTokenProvider implementation is left to the end user,
otherwise we would need to include specific libraries, at least
as far as I am aware.
The OrgInstallationCredentialProvider will give a token,
refreshing when necessary and using the JWTTokenProvider
that the user needs to provide to request new tokens
2020-09-28 13:17:46 +02:00
Marcos.Cela
aa96089ab4 remove @see to external docs 2020-09-28 13:01:55 +02:00
Marcos.Cela
58ae681417 reduce visibilitof GitHubBuilder#withCredentialProvider 2020-09-28 12:59:21 +02:00
Marcos.Cela
c038e0af5e typo it'ts -> it's 2020-09-28 12:51:54 +02:00
Marcos.Cela
4f9976c0cb add GitHubBuilder#withCredentialProvider
With this we also need to check for exceptions when calling
"/user", because now we don't know what kind of credentials
are coming from the provider, and we could be requesting
a "/user" when the type of credentials is not supported
2020-09-28 12:40:44 +02:00
Marcos.Cela
e308e5ed57 use static utility methods instead of building logic in the constructor 2020-09-28 12:26:56 +02:00
Marcos.Cela
7b1b1ca994 ensure that isAnonymous() correctly handles IOException 2020-09-28 12:18:22 +02:00
Marcos.Cela
551be49a1a utility methods on ImmutableCredentialProvider
These methods let us build the most-used cases
for static credentials that will never change:
- JWT credentials
- Token-based credentials
- Basic Auth credentials
2020-09-28 10:43:43 +02:00
Marcos.Cela
a3888e6902 add CredentialProvider#ANONYMOUS class and field
This is basically an implementation of a CredentialProvider
that will always authenticate anonymously
2020-09-28 10:09:54 +02:00
Marcos Cela López
43bb6a0dd8 Merge branch 'master' into feat/credential-provider-refresh 2020-09-28 10:02:16 +02:00
Marcos Cela López
05863acbcd Merge branch 'master' into feat/credential-provider-refresh 2020-09-25 12:05:31 +02:00
Marcos.Cela
0e4cd06137 GitHubClient uses CredentialProvider, instead of encodedAuthorization (string) 2020-09-25 12:02:14 +02:00
Marcos.Cela
85d2d974e7 add ImmutableCredentialProvider
This is basically a class that will hold an authorization
string, returning the same value all the time
2020-09-25 12:01:33 +02:00
Marcos.Cela
3f021f9552 lint CredentialProvider 2020-09-25 10:56:07 +02:00
Marcos.Cela
4688870984 add CredentialProvider interface 2020-09-24 09:01:52 +02:00
1536 changed files with 107315 additions and 9584 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.java text eol=lf

View File

@@ -1,16 +1,16 @@
# Description
** Describe your change here**
# Description
<!-- Describe your change here -->
# Before submitting a PR:
We love getting PRs, but we hate asking people for the same basic changes every time.
We love getting PRs, but we hate asking people for the same basic changes every time.
- [ ] Push your changes to a branch other than `master`. Create your PR from that branch.
- [ ] Push your changes to a branch other than `main`. 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 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".
- [ ] Fill in the "Description" above.
- [ ] Enable "Allow edits from maintainers".

67
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ main, gh-pages ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '20 0 * * 6'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View File

@@ -2,14 +2,18 @@ name: CI
on: [push, pull_request]
# this is required by spotless for JDK 16+
env:
JAVA_11_PLUS_MAVEN_OPTS: "--add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
jobs:
build:
name: build-only (Java ${{ matrix.java }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ 13 ]
java: [ 16 ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
@@ -17,18 +21,21 @@ jobs:
with:
java-version: ${{ matrix.java }}
- name: Cached .m2
uses: actions/cache@v2
uses: actions/cache@v2.1.5
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
env:
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
run: mvn -B install -DskipTests --file pom.xml
site:
name: site (Java ${{ matrix.java }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ 8, 11 ]
steps:
@@ -37,7 +44,7 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- uses: actions/cache@v2
- uses: actions/cache@v2.1.5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -49,24 +56,40 @@ jobs:
name: test (${{ matrix.os }}, Java ${{ matrix.java }})
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows ]
java: [ 8, 11, 13, 15-ea ]
java: [ 8, 11, 16 ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- uses: actions/cache@v2
- uses: actions/cache@v2.1.5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# JDK 8
- name: Maven Install without Code Coverage
if: matrix.os == 'windows'
if: matrix.os == 'windows' && matrix.java == '8'
run: mvn -B install --file pom.xml
- name: Maven Install with Code Coverage
if: matrix.os != 'windows'
if: matrix.os != 'windows' && matrix.java == '8'
run: mvn -B install -D enable-ci --file pom.xml
- name: Codecov Report
if: matrix.os != 'windows' && matrix.java == '8'
uses: codecov/codecov-action@v1.4.1
# JDK 11+
- name: Maven Install without Code Coverage
if: matrix.os == 'windows' && matrix.java != '8'
env:
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
run: mvn -B install --file pom.xml
- name: Maven Install with Code Coverage
if: matrix.os != 'windows' && matrix.java != '8'
env:
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
run: mvn -B install -D enable-ci --file pom.xml

View File

@@ -14,10 +14,14 @@ Example:
This the default behavior.
Example for a single test case:
`mvn install -Dtest=WireMockStatusReporterTest#user_whenProxying_AuthCorrectlyConfigured`
### Setting up credential
1. Create an OAuth token on github.com
1. Create a "Personal access token" on https://github.com/ (`Settings` > `Developer settings` > `Personal access tokens`)
2. Set the GITHUB_OAUTH environment variable to the value of that token
3. Set the system property `test.github.useProxy` (usually like "-Dtest.github.useProxy" as a Java VM option)
@@ -27,21 +31,37 @@ This the default behavior.
`WireMockStatusReporterTest: GitHub proxying and user auth correctly configured for user login: <your login>`
Whenever you run tests with `-Dtest.github.useProxy`, they will try to get data from local files but will fallback to proxying to github if not found.
Whenever you run tests with `-Dtest.github.useProxy`, they will try to get data from local files but will fallback to proxying to GitHub if not found.
### Writing a new test
Once you have credentials setup, you add new test classes and test methods as you would normally.
Keep `useProxy` enabled and iterate on your tests as needed. Remember, while proxying your tests are interacting with GitHub - you will need to clean up your state between runs.
When you are ready to create a snapshot of your test data,
run your test with `test.github.takeSnapshot` ("-Dtest.github.takeSnapshot" as a Java VM option). For example:
#### Running tests using GitHub test proxy
`mvn install -Dtest.github.takeSnapshot -Dtest=YourTestClassName`
Keep `useProxy` enabled and iterate on your tests as needed. With `useProxy` enabled your tests will interact with
GitHub - you will need to clean up your server-state between runs. This can be done manually to start with.
Once your test code is somewhat stable, use `getNonRecordingGitHub()` to get a `GitHub` instance for test setup and cleanup.
Interactions with that `GitHub` instance will not be recorded as part of the test, keeping the test data files to a minimum.
The above command would create snapshot WireMock data files under the path `src/test/resources/org/kohsuhke/github/YourTestClassName/wiremock`.
Each method would get a separate director that would hold the data files for that test method.
#### Running tests against your personal GitHub user account
By default, test helper methods such as `getTempRepository()` target the `hub4j-test-org` GitHub organization.
Please request access to this org to record your tests before submitting a PR. This helps keep the project stable and nimble.
Until you have access (or if you don't want access), you can set the following additional system property to target
your personal github account.
`mvn install -Dtest.github.org=false -Dtest=YourTestClassName`
#### Taking a snapshot
When you are ready to create a snapshot of your test data, run your test with `test.github.takeSnapshot` ("-Dtest.github.takeSnapshot" as
a Java VM option). For example:
`mvn install -Dtest.github.takeSnapshot -Dtest.github.org=false -Dtest=YourTestClassName`
The above command will create snapshot WireMock data files under the path `src/test/resources/org/kohsuhke/github/YourTestClassName/wiremock`.
Each method will get a separate directory that will hold the data files for that test method.
Add all files including the generated data to your commit and submit a PR.

View File

@@ -2,7 +2,7 @@
[![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/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)
![CI](https://github.com/hub4j/github-api/workflows/CI/badge.svg?branch=main)

7
codecov.yml Normal file
View File

@@ -0,0 +1,7 @@
ignore:
- "**/extras/okhttp3/ObsoleteUrlFactory**"
- "**/extras/OkHttpConnector"
- "**/extras/OkHttp3Connector"
- "**/example/**"
- "**/github/EnforcementLevel"

235
pom.xml
View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.117</version>
<version>1.128</version>
<name>GitHub API for Java</name>
<url>https://github-api.kohsuke.org/</url>
<description>GitHub API for Java</description>
@@ -11,7 +11,7 @@
<connection>scm:git:git@github.com/hub4j/${project.artifactId}.git</connection>
<developerConnection>scm:git:ssh://git@github.com/hub4j/${project.artifactId}.git</developerConnection>
<url>https://github.com/hub4j/github-api/</url>
<tag>github-api-1.117</tag>
<tag>github-api-1.128</tag>
</scm>
<distributionManagement>
@@ -33,19 +33,21 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spotbugs-maven-plugin.version>4.0.4</spotbugs-maven-plugin.version>
<spotbugs.version>4.1.2</spotbugs.version>
<spotbugs-maven-plugin.version>4.2.3</spotbugs-maven-plugin.version>
<spotbugs.version>4.2.3</spotbugs.version>
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
<hamcrest.version>2.2</hamcrest.version>
<okhttp3.version>4.4.1</okhttp3.version>
<okio.version>2.5.0</okio.version>
<formatter-maven-plugin.goal>format</formatter-maven-plugin.goal>
<impsort-maven-plugin.goal>sort</impsort-maven-plugin.goal>
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
<jacoco.coverage.target.bundle.method>0.60</jacoco.coverage.target.bundle.method>
<jacoco.coverage.target.class.method>0.25</jacoco.coverage.target.class.method>
<jacoco.coverage.target.bundle.method>0.70</jacoco.coverage.target.bundle.method>
<jacoco.coverage.target.class.method>0.50</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>
<jjwt.suite.version>0.11.2</jjwt.suite.version>
<jacoco.surefire.argLine />
<surefire.argLine />
</properties>
<build>
@@ -106,6 +108,9 @@
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacoco.surefire.argLine</propertyName>
</configuration>
</execution>
<!-- attached to Maven test phase -->
<execution>
@@ -153,59 +158,41 @@
<!-- Sample only -->
<exclude>org.kohsuke.github.example.*</exclude>
<!-- No methods -->
<exclude>org.kohsuke.github.Previews</exclude>
<!-- Deprecated -->
<exclude>org.kohsuke.github.extras.OkHttpConnector</exclude>
<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: Some coverage, but more needed -->
<exclude>org.kohsuke.github.GHPullRequestReviewBuilder.DraftReviewComment</exclude>
<exclude>org.kohsuke.github.GHIssue.PullRequest</exclude>
<exclude>org.kohsuke.github.GHCommitSearchBuilder</exclude>
<exclude>org.kohsuke.github.GHRepositorySearchBuilder</exclude>
<exclude>org.kohsuke.github.GHUserSearchBuilder</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>
@@ -261,7 +248,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<dependencies>
<dependency>
<groupId>org.apache.bcel</groupId>
@@ -293,18 +280,7 @@
<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>
<argLine>@{jacoco.surefire.argLine} ${surefire.argLine}</argLine>
</configuration>
</execution>
</executions>
@@ -312,7 +288,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.19</version>
<version>1.20</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
@@ -343,37 +319,35 @@
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.12.1</version>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.10.1</version>
<executions>
<execution>
<id>spotless-check</id>
<!-- runs in verify phase by default -->
<goals>
<goal>${formatter-maven-plugin.goal}</goal>
<!-- can be disabled using -Dspotless.check.skip=true -->
<goal>check</goal>
</goals>
<configuration>
<configFile>src/main/resources/eclipse/formatter.xml</configFile>
<cachedir>${project.build.directory}/.cache</cachedir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>1.4.1</version>
<configuration>
<groups>*,java.,javax.</groups>
<removeUnused>true</removeUnused>
<staticAfter>true</staticAfter>
<java>
<eclipse>
<file>${basedir}/src/build/eclipse/formatter.xml</file>
</eclipse>
<importOrder>
<file>${basedir}/src/build/eclipse/eclipse.importorder</file>
</importOrder>
<removeUnusedImports />
<trimTrailingWhitespace />
<endWithNewline />
</java>
</configuration>
<executions>
<execution>
<goals>
<goal>${impsort-maven-plugin.goal}</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
@@ -410,6 +384,12 @@
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit</artifactId>
<version>0.18.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
@@ -432,13 +412,19 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.2</version>
<version>2.12.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
@@ -469,7 +455,7 @@
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler</artifactId>
<version>1.260</version>
<version>1.263</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -481,26 +467,26 @@
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.9.0.202009080501-r</version>
<version>5.11.0.202103091610-r</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.2</version>
<scope>test</scope>
<version>${jjwt.suite.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.2</version>
<scope>test</scope>
<version>${jjwt.suite.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.2</version>
<scope>test</scope>
<version>${jjwt.suite.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
@@ -531,13 +517,13 @@
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>wordnet-random-name</artifactId>
<version>1.3</version>
<version>1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.6.0</version>
<version>3.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -561,7 +547,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.2</version>
<version>1.7.30</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -578,6 +564,38 @@
</pluginRepository>
</pluginRepositories>
<profiles>
<!-- only enable slow-or-flaky-test if -Dtest= is not present -->
<profile>
<id>slow-or-flaky-test</id>
<activation>
<property>
<name>!test</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<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>
<argLine>@{jacoco.surefire.argLine} ${surefire.argLine}</argLine>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ci-non-windows</id>
<activation>
@@ -589,8 +607,8 @@
</os>
</activation>
<properties>
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
<!-- Only fail code coverage on non-windows machines -->
<jacoco.haltOnFailure>true</jacoco.haltOnFailure>
</properties>
</profile>
<profile>
@@ -600,24 +618,55 @@
<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>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<executions>
<execution>
<id>spotless-check</id>
<!-- In CI, run check early in the build -->
<phase>process-sources</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-jacoco-exist</id>
<phase>verify</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireFilesExist>
<files>
<file>${project.build.directory}/jacoco.exec</file>
</files>
</requireFilesExist>
</rules>
<fail>true</fail>
</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>

View File

@@ -0,0 +1,6 @@
#Organize Import Order
# Import this file in Window -> Preferences -> Java -> Code Style -> Organize Imports -> Import...
0=
1=java
2=javax
3=\#

View File

@@ -12,14 +12,14 @@ import javax.annotation.Nonnull;
* <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);
@@ -38,7 +38,7 @@ import javax.annotation.Nonnull;
* 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> {
abstract class AbstractBuilder<R, S> extends GitHubInteractiveObject {
@Nonnull
private final Class<R> returnType;
@@ -75,6 +75,7 @@ abstract class AbstractBuilder<R, S> {
@Nonnull Class<S> intermediateReturnType,
@Nonnull GitHub root,
@CheckForNull R baseInstance) {
super(root);
this.requester = root.createRequest();
this.returnType = finalReturnType;
this.commitChangesImmediately = returnType.equals(intermediateReturnType);
@@ -97,7 +98,7 @@ abstract class AbstractBuilder<R, S> {
* if there is an I/O Exception
*/
@Nonnull
@Preview
@BetaApi
@Deprecated
public R done() throws IOException {
R result;
@@ -127,7 +128,7 @@ abstract class AbstractBuilder<R, S> {
* if an I/O error occurs
*/
@Nonnull
@Preview
@BetaApi
@Deprecated
protected S with(@Nonnull String name, Object value) throws IOException {
requester.with(name, value);
@@ -148,7 +149,7 @@ abstract class AbstractBuilder<R, S> {
* if an I/O error occurs
*/
@Nonnull
@Preview
@BetaApi
@Deprecated
protected S continueOrDone() throws IOException {
// This little bit of roughness in this base class means all inheriting builders get to create Updater and

View File

@@ -0,0 +1,18 @@
package org.kohsuke.github;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Indicates that the method/class/etc marked is a beta implementation of an sdk feature.
* <p>
* These APIs are subject to change and not a part of the backward compatibility commitment. Always used in conjunction
* with 'deprecated' to raise awareness to clients.
* </p>
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface BetaApi {
}

View File

@@ -5,7 +5,7 @@ import java.net.URL;
import java.util.List;
import java.util.Map;
import static org.kohsuke.github.Previews.MACHINE_MAN;
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
/**
* A Github App.
@@ -15,7 +15,6 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
*/
public class GHApp extends GHObject {
private GitHub root;
private GHUser owner;
private String name;
private String description;
@@ -189,7 +188,7 @@ public class GHApp extends GHObject {
* @return a list of App installations
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
*/
@Preview
@Preview(MACHINE_MAN)
@Deprecated
public PagedIterable<GHAppInstallation> listInstallations() {
return root.createRequest()
@@ -210,7 +209,7 @@ public class GHApp extends GHObject {
* on error
* @see <a href="https://developer.github.com/v3/apps/#get-an-installation">Get an installation</a>
*/
@Preview
@Preview(MACHINE_MAN)
@Deprecated
public GHAppInstallation getInstallationById(long id) throws IOException {
return root.createRequest()
@@ -233,7 +232,7 @@ public class GHApp extends GHObject {
* @see <a href="https://developer.github.com/v3/apps/#get-an-organization-installation">Get an organization
* installation</a>
*/
@Preview
@Preview(MACHINE_MAN)
@Deprecated
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
return root.createRequest()
@@ -258,7 +257,7 @@ public class GHApp extends GHObject {
* @see <a href="https://developer.github.com/v3/apps/#get-a-repository-installation">Get a repository
* installation</a>
*/
@Preview
@Preview(MACHINE_MAN)
@Deprecated
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
return root.createRequest()
@@ -280,7 +279,7 @@ public class GHApp extends GHObject {
* on error
* @see <a href="https://developer.github.com/v3/apps/#get-a-user-installation">Get a user installation</a>
*/
@Preview
@Preview(MACHINE_MAN)
@Deprecated
public GHAppInstallation getInstallationByUser(String name) throws IOException {
return root.createRequest()

View File

@@ -5,7 +5,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.kohsuke.github.Previews.MACHINE_MAN;
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
/**
* Creates a access token for a GitHub App Installation
@@ -14,12 +14,11 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
* @see GHAppInstallation#createToken() GHAppInstallation#createToken()
*/
public class GHAppCreateTokenBuilder {
private final GitHub root;
public class GHAppCreateTokenBuilder extends GitHubInteractiveObject {
protected final Requester builder;
private final String apiUrlTail;
@Preview
@BetaApi
@Deprecated
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail) {
this.root = root;
@@ -27,7 +26,7 @@ public class GHAppCreateTokenBuilder {
this.builder = root.createRequest();
}
@Preview
@BetaApi
@Deprecated
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
this(root, apiUrlTail);
@@ -43,7 +42,7 @@ public class GHAppCreateTokenBuilder {
* Array containing the repositories Ids
* @return a GHAppCreateTokenBuilder
*/
@Preview
@BetaApi
@Deprecated
public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
this.builder.with("repository_ids", repositoryIds);
@@ -58,7 +57,7 @@ public class GHAppCreateTokenBuilder {
* Map containing the permission names and types.
* @return a GHAppCreateTokenBuilder
*/
@Preview
@BetaApi
@Deprecated
public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permissions) {
Map<String, String> retMap = new HashMap<>();
@@ -78,7 +77,7 @@ public class GHAppCreateTokenBuilder {
* @throws IOException
* on error
*/
@Preview
@Preview(MACHINE_MAN)
@Deprecated
public GHAppInstallationToken create() throws IOException {
return builder.method("POST")

View File

@@ -8,8 +8,8 @@ import java.net.URL;
import java.util.List;
import java.util.Map;
import static org.kohsuke.github.Previews.GAMBIT;
import static org.kohsuke.github.Previews.MACHINE_MAN;
import static org.kohsuke.github.internal.Previews.GAMBIT;
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
/**
* A Github App Installation.
@@ -22,7 +22,6 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
* @see GHApp#getInstallationByUser(String) GHApp#getInstallationByUser(String)
*/
public class GHAppInstallation extends GHObject {
private GitHub root;
private GHUser account;
@JsonProperty("access_tokens_url")
@@ -124,7 +123,7 @@ public class GHAppInstallation extends GHObject {
*
* @return the paged iterable
*/
@Preview
@Preview(MACHINE_MAN)
@Deprecated
public PagedSearchIterable<GHRepository> listRepositories() {
GitHubRequest request;
@@ -322,7 +321,7 @@ public class GHAppInstallation extends GHObject {
* on error
* @see <a href="https://developer.github.com/v3/apps/#delete-an-installation">Delete an installation</a>
*/
@Preview
@Preview(GAMBIT)
@Deprecated
public void deleteInstallation() throws IOException {
root.createRequest()
@@ -344,7 +343,7 @@ public class GHAppInstallation extends GHObject {
* @return a GHAppCreateTokenBuilder instance
* @deprecated Use {@link GHAppInstallation#createToken()} instead.
*/
@Preview
@BetaApi
@Deprecated
public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permissions) {
return new GHAppCreateTokenBuilder(root,
@@ -361,7 +360,7 @@ public class GHAppInstallation extends GHObject {
*
* @return a GHAppCreateTokenBuilder instance
*/
@Preview
@BetaApi
@Deprecated
public GHAppCreateTokenBuilder createToken() {
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", getId()));

View File

@@ -14,9 +14,7 @@ import java.util.Map;
* @author Paulo Miguel Almeida
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
*/
public class GHAppInstallationToken {
private GitHub root;
public class GHAppInstallationToken extends GitHubInteractiveObject {
private String token;
protected String expires_at;
private Map<String, String> permissions;

View File

@@ -0,0 +1,140 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.function.InputStreamFunction;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
import java.util.Objects;
import static java.util.Objects.requireNonNull;
/**
* An artifact from a workflow run.
*
* @author Guillaume Smet
*/
public class GHArtifact extends GHObject {
// Not provided by the API.
@JsonIgnore
private GHRepository owner;
private String name;
private long sizeInBytes;
private String archiveDownloadUrl;
private boolean expired;
private String expiresAt;
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Gets the size of the artifact in bytes.
*
* @return the size
*/
public long getSizeInBytes() {
return sizeInBytes;
}
/**
* Gets the archive download URL.
*
* @return the archive download URL
*/
public URL getArchiveDownloadUrl() {
return GitHubClient.parseURL(archiveDownloadUrl);
}
/**
* If this artifact has expired.
*
* @return if the artifact has expired
*/
public boolean isExpired() {
return expired;
}
/**
* Gets the date at which this artifact will expire.
*
* @return the date of expiration
*/
public Date getExpiresAt() {
return GitHubClient.parseDate(expiresAt);
}
/**
* Repository to which the artifact belongs.
*
* @return the repository
*/
public GHRepository getRepository() {
return owner;
}
/**
* @deprecated This object has no HTML URL.
*/
@Override
public URL getHtmlUrl() throws IOException {
return null;
}
/**
* Deletes the artifact.
*
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).fetchHttpStatusCode();
}
/**
* Downloads the artifact.
*
* @param <T>
* the type of result
* @param streamFunction
* The {@link InputStreamFunction} that will process the stream
* @throws IOException
* The IO exception.
* @return the result of reading the stream.
*/
public <T> T download(InputStreamFunction<T> streamFunction) throws IOException {
requireNonNull(streamFunction, "Stream function must not be null");
return root.createRequest().method("GET").withUrlPath(getApiRoute(), "zip").fetchStream(streamFunction);
}
private String getApiRoute() {
if (owner == null) {
// Workflow runs 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() + "/actions/artifacts/" + getId();
}
GHArtifact wrapUp(GHRepository owner) {
this.owner = owner;
return wrapUp(owner.root);
}
GHArtifact wrapUp(GitHub root) {
this.root = root;
if (owner != null)
owner.wrap(root);
return this;
}
}

View File

@@ -0,0 +1,49 @@
package org.kohsuke.github;
import java.net.MalformedURLException;
import java.util.Iterator;
import javax.annotation.Nonnull;
/**
* Iterable for artifacts listing.
*/
class GHArtifactsIterable extends PagedIterable<GHArtifact> {
private final transient GHRepository owner;
private final GitHubRequest request;
private GHArtifactsPage result;
public GHArtifactsIterable(GHRepository owner, GitHubRequest.Builder<?> requestBuilder) {
this.owner = owner;
try {
this.request = requestBuilder.build();
} catch (MalformedURLException e) {
throw new GHException("Malformed URL", e);
}
}
@Nonnull
@Override
public PagedIterator<GHArtifact> _iterator(int pageSize) {
return new PagedIterator<>(
adapt(GitHubPageIterator.create(owner.getRoot().getClient(), GHArtifactsPage.class, request, pageSize)),
null);
}
protected Iterator<GHArtifact[]> adapt(final Iterator<GHArtifactsPage> base) {
return new Iterator<GHArtifact[]>() {
public boolean hasNext() {
return base.hasNext();
}
public GHArtifact[] next() {
GHArtifactsPage v = base.next();
if (result == null) {
result = v;
}
return v.getArtifacts(owner);
}
};
}
}

View File

@@ -0,0 +1,20 @@
package org.kohsuke.github;
/**
* Represents the one page of artifacts result when listing artifacts.
*/
class GHArtifactsPage {
private int total_count;
private GHArtifact[] artifacts;
public int getTotalCount() {
return total_count;
}
GHArtifact[] getArtifacts(GHRepository owner) {
for (GHArtifact artifact : artifacts) {
artifact.wrapUp(owner);
}
return artifacts;
}
}

View File

@@ -9,7 +9,6 @@ import java.net.URL;
* @see GHRelease#getAssets() GHRelease#getAssets()
*/
public class GHAsset extends GHObject {
GitHub root;
GHRepository owner;
private String name;
private String label;

View File

@@ -33,7 +33,6 @@ public class GHAuthorization extends GHObject {
public static final String WRITE_KEY = "write:public_key";
public static final String ADMIN_KEY = "admin:public_key";
private GitHub root;
private List<String> scopes;
private String token;
private String token_last_eight;

View File

@@ -3,6 +3,7 @@ package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.kohsuke.github.internal.Previews;
import java.io.IOException;
import java.net.URL;
@@ -20,8 +21,7 @@ import javax.annotation.CheckForNull;
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHBranch {
private GitHub root;
public class GHBranch extends GitHubInteractiveObject {
private GHRepository owner;
private String name;
@@ -78,7 +78,7 @@ public class GHBranch {
*
* @return true if the push to this branch is restricted via branch protection.
*/
@Preview
@Preview(Previews.LUKE_CAGE)
@Deprecated
public boolean isProtected() {
return protection;
@@ -89,7 +89,7 @@ public class GHBranch {
*
* @return API URL that deals with the protection of this branch.
*/
@Preview
@Preview(Previews.LUKE_CAGE)
@Deprecated
public URL getProtectionUrl() {
return GitHubClient.parseURL(protection_url);
@@ -102,6 +102,8 @@ public class GHBranch {
* @throws IOException
* the io exception
*/
@Preview(Previews.LUKE_CAGE)
@Deprecated
public GHBranchProtection getProtection() throws IOException {
return root.createRequest()
.withPreview(Previews.LUKE_CAGE)
@@ -135,7 +137,7 @@ public class GHBranch {
* @return GHBranchProtectionBuilder for enabling protection
* @see GHCommitStatus#getContext() GHCommitStatus#getContext()
*/
@Preview
@Preview(Previews.LUKE_CAGE)
@Deprecated
public GHBranchProtectionBuilder enableProtection() {
return new GHBranchProtectionBuilder(this);

View File

@@ -6,7 +6,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.util.Collection;
import static org.kohsuke.github.Previews.ZZZAX;
import static org.kohsuke.github.internal.Previews.ZZZAX;
/**
* The type GHBranchProtection.
@@ -17,14 +17,12 @@ import static org.kohsuke.github.Previews.ZZZAX;
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHBranchProtection {
public class GHBranchProtection extends GitHubInteractiveObject {
private static final String REQUIRE_SIGNATURES_URI = "/required_signatures";
@JsonProperty
private EnforceAdmins enforceAdmins;
private GitHub root;
@JsonProperty("required_pull_request_reviews")
private RequiredReviews requiredReviews;
@@ -43,7 +41,7 @@ public class GHBranchProtection {
* @throws IOException
* the io exception
*/
@Preview
@Preview(ZZZAX)
@Deprecated
public void enabledSignedCommits() throws IOException {
requester().method("POST").withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class);
@@ -55,7 +53,7 @@ public class GHBranchProtection {
* @throws IOException
* the io exception
*/
@Preview
@Preview(ZZZAX)
@Deprecated
public void disableSignedCommits() throws IOException {
requester().method("DELETE").withUrlPath(url + REQUIRE_SIGNATURES_URI).send();
@@ -86,7 +84,7 @@ public class GHBranchProtection {
* @throws IOException
* the io exception
*/
@Preview
@Preview(ZZZAX)
@Deprecated
public boolean getRequiredSignatures() throws IOException {
return requester().withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class).enabled;

View File

@@ -12,7 +12,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.kohsuke.github.Previews.*;
import static org.kohsuke.github.internal.Previews.LUKE_CAGE;
/**
* Builder to configure the branch protection settings.

View File

@@ -1,8 +1,13 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.kohsuke.github.GHWorkflowRun.Conclusion;
import org.kohsuke.github.GHWorkflowRun.Status;
import org.kohsuke.github.internal.EnumUtils;
import org.kohsuke.github.internal.Previews;
import java.io.IOException;
import java.net.URL;
@@ -10,6 +15,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* Represents a check run.
@@ -22,7 +28,6 @@ public class GHCheckRun extends GHObject {
@JsonProperty("repository")
GHRepository owner;
GitHub root;
private String status;
private String conclusion;
@@ -80,12 +85,27 @@ public class GHCheckRun extends GHObject {
* @return Status of the check run
* @see Status
*/
public String getStatus() {
@WithBridgeMethods(value = String.class, adapterMethod = "statusAsStr")
public Status getStatus() {
return Status.from(status);
}
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getStatus")
private Object statusAsStr(Status status, Class type) {
return status;
}
public static enum Status {
QUEUED, IN_PROGRESS, COMPLETED
QUEUED, IN_PROGRESS, COMPLETED, UNKNOWN;
public static Status from(String value) {
return EnumUtils.getNullableEnumOrDefault(Status.class, value, Status.UNKNOWN);
}
@Override
public String toString() {
return name().toLowerCase(Locale.ROOT);
}
}
/**
@@ -94,7 +114,13 @@ public class GHCheckRun extends GHObject {
* @return Status of the check run
* @see Conclusion
*/
public String getConclusion() {
@WithBridgeMethods(value = String.class, adapterMethod = "conclusionAsStr")
public Conclusion getConclusion() {
return Conclusion.from(conclusion);
}
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getConclusion")
private Object conclusionAsStr(Conclusion conclusion, Class type) {
return conclusion;
}
@@ -105,7 +131,16 @@ public class GHCheckRun extends GHObject {
* Parameters - <code>conclusion</code></a>.
*/
public static enum Conclusion {
SUCCESS, FAILURE, NEUTRAL, CANCELLED, TIMED_OUT, ACTION_REQUIRED, SKIPPED
ACTION_REQUIRED, CANCELLED, FAILURE, NEUTRAL, SUCCESS, SKIPPED, STALE, TIMED_OUT, UNKNOWN;
public static Conclusion from(String value) {
return EnumUtils.getNullableEnumOrDefault(Conclusion.class, value, Conclusion.UNKNOWN);
}
@Override
public String toString() {
return name().toLowerCase(Locale.ROOT);
}
}
/**
@@ -295,10 +330,10 @@ public class GHCheckRun extends GHObject {
/**
* Updates this check run.
*
*
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
*/
@Preview
@Preview(Previews.ANTIOPE)
@Deprecated
public @NonNull GHCheckRunBuilder update() {
return new GHCheckRunBuilder(owner, getId());

View File

@@ -28,6 +28,7 @@ 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 org.kohsuke.github.internal.Previews;
import java.io.IOException;
import java.util.Collections;
@@ -46,7 +47,7 @@ import java.util.Locale;
* @see <a href="https://developer.github.com/v3/checks/runs/#update-a-check-run">documentation</a>
*/
@SuppressFBWarnings(value = "URF_UNREAD_FIELD", justification = "Jackson serializes these even without a getter")
@Preview
@Preview(Previews.ANTIOPE)
@Deprecated
public final class GHCheckRunBuilder {
@@ -151,7 +152,7 @@ public final class GHCheckRunBuilder {
}
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);
Output output2 = new Output(output.title, output.summary).withText(output.text);
int i = Math.min(extraAnnotations.size(), MAX_ANNOTATIONS);
output2.annotations = extraAnnotations.subList(0, i);
extraAnnotations = extraAnnotations.subList(i, extraAnnotations.size());

View File

@@ -8,13 +8,13 @@ import javax.annotation.Nonnull;
* Iterable for check-runs listing.
*/
class GHCheckRunsIterable extends PagedIterable<GHCheckRun> {
private GitHub root;
private final GHRepository owner;
private final GitHubRequest request;
private GHCheckRunsPage result;
public GHCheckRunsIterable(GitHub root, GitHubRequest request) {
this.root = root;
public GHCheckRunsIterable(GHRepository owner, GitHubRequest request) {
this.owner = owner;
this.request = request;
}
@@ -22,7 +22,7 @@ class GHCheckRunsIterable extends PagedIterable<GHCheckRun> {
@Override
public PagedIterator<GHCheckRun> _iterator(int pageSize) {
return new PagedIterator<>(
adapt(GitHubPageIterator.create(root.getClient(), GHCheckRunsPage.class, request, pageSize)),
adapt(GitHubPageIterator.create(owner.getRoot().getClient(), GHCheckRunsPage.class, request, pageSize)),
null);
}
@@ -37,7 +37,7 @@ class GHCheckRunsIterable extends PagedIterable<GHCheckRun> {
if (result == null) {
result = v;
}
return v.getCheckRuns(root);
return v.getCheckRuns(owner);
}
};
}

View File

@@ -11,9 +11,9 @@ class GHCheckRunsPage {
return total_count;
}
GHCheckRun[] getCheckRuns(GitHub root) {
GHCheckRun[] getCheckRuns(GHRepository owner) {
for (GHCheckRun check_run : check_runs) {
check_run.wrap(root);
check_run.wrap(owner);
}
return check_runs;
}

View File

@@ -21,7 +21,6 @@ public class GHCheckSuite extends GHObject {
@JsonProperty("repository")
GHRepository owner;
GitHub root;
private String nodeId;
private String headBranch;

View File

@@ -11,7 +11,8 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import static org.kohsuke.github.Previews.GROOT;
import static org.kohsuke.github.internal.Previews.ANTIOPE;
import static org.kohsuke.github.internal.Previews.GROOT;
/**
* A commit in a repository.
@@ -65,7 +66,7 @@ public class GHCommit {
* @return the authored date
*/
public Date getAuthoredDate() {
return GitHubClient.parseDate(author.date);
return author.getDate();
}
/**
@@ -84,7 +85,7 @@ public class GHCommit {
* @return the commit date
*/
public Date getCommitDate() {
return GitHubClient.parseDate(committer.date);
return committer.getDate();
}
/**
@@ -121,7 +122,6 @@ public class GHCommit {
* @deprecated Use {@link GitUser} instead.
*/
public static class GHAuthor extends GitUser {
private String date;
}
/**
@@ -453,7 +453,7 @@ public class GHCommit {
*
* @return {@link PagedIterable} with the pull requests which contain this commit
*/
@Preview
@Preview(GROOT)
@Deprecated
public PagedIterable<GHPullRequest> listPullRequests() {
return owner.root.createRequest()
@@ -469,7 +469,7 @@ public class GHCommit {
* @throws IOException
* the io exception
*/
@Preview
@Preview(GROOT)
@Deprecated
public PagedIterable<GHBranch> listBranchesWhereHead() throws IOException {
return owner.root.createRequest()
@@ -565,7 +565,7 @@ public class GHCommit {
* @throws IOException
* on error
*/
@Preview
@Preview(ANTIOPE)
@Deprecated
public PagedIterable<GHCheckRun> getCheckRuns() throws IOException {
return owner.getCheckRuns(sha);
@@ -573,7 +573,7 @@ public class GHCommit {
/**
* Some of the fields are not always filled in when this object is retrieved as a part of another API call.
*
*
* @throws IOException
* on error
*/

View File

@@ -5,7 +5,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
import static org.kohsuke.github.Previews.*;
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
/**
* A comment attached to a commit (or a specific line in a specific file of a commit.)
@@ -121,7 +121,7 @@ public class GHCommitComment extends GHObject implements Reactable {
this.body = body;
}
@Preview
@Preview(SQUIRREL_GIRL)
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return owner.root.createRequest()
@@ -133,7 +133,7 @@ public class GHCommitComment extends GHObject implements Reactable {
.wrap(owner.root);
}
@Preview
@Preview(SQUIRREL_GIRL)
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.createRequest()

View File

@@ -1,6 +1,7 @@
package org.kohsuke.github;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.internal.Previews;
import java.io.IOException;
@@ -10,7 +11,7 @@ import java.io.IOException;
* @author Marc de Verdelhan
* @see GitHub#searchCommits() GitHub#searchCommits()
*/
@Preview
@Preview(Previews.CLOAK)
@Deprecated
public class GHCommitSearchBuilder extends GHSearchBuilder<GHCommit> {
GHCommitSearchBuilder(GitHub root) {

View File

@@ -18,8 +18,6 @@ public class GHCommitStatus extends GHObject {
String context;
GHUser creator;
private GitHub root;
GHCommitStatus wrapUp(GitHub root) {
if (creator != null)
creator.wrapUp(root);

View File

@@ -15,15 +15,13 @@ import java.util.Base64;
* @see GHRepository#getFileContent(String) GHRepository#getFileContent(String)
*/
@SuppressWarnings({ "UnusedDeclaration" })
public class GHContent implements Refreshable {
public class GHContent extends GitHubInteractiveObject implements Refreshable {
/*
* In normal use of this class, repository field is set via wrap(), but in the code search API, there's a nested
* 'repository' field that gets populated from JSON.
*/
private GHRepository repository;
private GitHub root;
private String type;
private String encoding;
private long size;
@@ -102,7 +100,7 @@ public class GHContent implements Refreshable {
/**
* Gets target of a symlink. This will only be set if {@code "symlink".equals(getType())}
*
*
* @return the target
*/
public String getTarget() {

View File

@@ -118,6 +118,41 @@ public class GHContentSearchBuilder extends GHSearchBuilder<GHContent> {
return q("repo:" + v);
}
/**
* Order gh content search builder.
*
* @param v
* the v
* @return the gh content search builder
*/
public GHContentSearchBuilder order(GHDirection v) {
req.with("order", v);
return this;
}
/**
* Sort gh content search builder.
*
* @param sort
* the sort
* @return the gh content search builder
*/
public GHContentSearchBuilder sort(GHContentSearchBuilder.Sort sort) {
if (Sort.BEST_MATCH.equals(sort)) {
req.remove("sort");
} else {
req.with("sort", sort);
}
return this;
}
/**
* The enum Sort.
*/
public enum Sort {
BEST_MATCH, INDEXED
}
private static class ContentSearchResult extends SearchResult<GHContent> {
private GHContent[] items;

View File

@@ -1,168 +1,25 @@
package org.kohsuke.github;
import java.io.IOException;
import java.net.URL;
import static org.kohsuke.github.Previews.BAPTISE;
import static org.kohsuke.github.internal.Previews.BAPTISTE;
/**
* Creates a repository
*
* @author Kohsuke Kawaguchi
*/
public class GHCreateRepositoryBuilder {
private final GitHub root;
protected final Requester builder;
private String apiUrlTail;
public class GHCreateRepositoryBuilder extends GHRepositoryBuilder<GHCreateRepositoryBuilder> {
GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) {
this.root = root;
this.apiUrlTail = apiUrlTail;
this.builder = root.createRequest();
this.builder.with("name", name);
}
public GHCreateRepositoryBuilder(String name, GitHub root, String apiTail) {
super(GHCreateRepositoryBuilder.class, root, null);
requester.method("POST").withUrlPath(apiTail);
/**
* Description for repository
*
* @param description
* description of repository
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder description(String description) {
this.builder.with("description", description);
return this;
}
/**
* Homepage for repository
*
* @param homepage
* homepage of repository
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder homepage(URL homepage) {
return homepage(homepage.toExternalForm());
}
/**
* Homepage for repository
*
* @param homepage
* homepage of repository
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder homepage(String homepage) {
this.builder.with("homepage", homepage);
return this;
}
/**
* Creates a private repository
*
* @param enabled
* private if true
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder private_(boolean enabled) {
this.builder.with("private", enabled);
return this;
}
/**
* Enables issue tracker
*
* @param enabled
* true if enabled
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder issues(boolean enabled) {
this.builder.with("has_issues", enabled);
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
*
* @param enabled
* true if enabled
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder wiki(boolean enabled) {
this.builder.with("has_wiki", enabled);
return this;
}
/**
* Enables downloads
*
* @param enabled
* true if enabled
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder downloads(boolean enabled) {
this.builder.with("has_downloads", enabled);
return this;
}
/**
* If true, create an initial commit with empty README.
*
* @param enabled
* true if enabled
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder autoInit(boolean enabled) {
this.builder.with("auto_init", enabled);
return this;
}
/**
* Allow or disallow squash-merging pull requests.
*
* @param enabled
* true if enabled
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder allowSquashMerge(boolean enabled) {
this.builder.with("allow_squash_merge", enabled);
return this;
}
/**
* Allow or disallow merging pull requests with a merge commit.
*
* @param enabled
* true if enabled
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder allowMergeCommit(boolean enabled) {
this.builder.with("allow_merge_commit", enabled);
return this;
}
/**
* Allow or disallow rebase-merging pull requests.
*
* @param enabled
* true if enabled
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder allowRebaseMerge(boolean enabled) {
this.builder.with("allow_rebase_merge", enabled);
return this;
try {
name(name);
} catch (IOException e) {
// not going to happen here
}
}
/**
@@ -171,10 +28,11 @@ public class GHCreateRepositoryBuilder {
* @param language
* template to base the ignore file on
* @return a builder to continue with building See https://developer.github.com/v3/repos/#create
* @throws IOException
* In case of any networking error or error from the server.
*/
public GHCreateRepositoryBuilder gitignoreTemplate(String language) {
this.builder.with("gitignore_template", language);
return this;
public GHCreateRepositoryBuilder gitignoreTemplate(String language) throws IOException {
return with("gitignore_template", language);
}
/**
@@ -183,10 +41,24 @@ public class GHCreateRepositoryBuilder {
* @param license
* template to base the license file on
* @return a builder to continue with building See https://developer.github.com/v3/repos/#create
* @throws IOException
* In case of any networking error or error from the server.
*/
public GHCreateRepositoryBuilder licenseTemplate(String license) {
this.builder.with("license_template", license);
return this;
public GHCreateRepositoryBuilder licenseTemplate(String license) throws IOException {
return with("license_template", license);
}
/**
* If true, create an initial commit with empty README.
*
* @param enabled
* true if enabled
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
*/
public GHCreateRepositoryBuilder autoInit(boolean enabled) throws IOException {
return with("auto_init", enabled);
}
/**
@@ -195,10 +67,12 @@ public class GHCreateRepositoryBuilder {
* @param team
* team to grant access to
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
*/
public GHCreateRepositoryBuilder team(GHTeam team) {
public GHCreateRepositoryBuilder team(GHTeam team) throws IOException {
if (team != null)
this.builder.with("team_id", team.getId());
return with("team_id", team.getId());
return this;
}
@@ -208,13 +82,13 @@ public class GHCreateRepositoryBuilder {
* @param enabled
* true if enabled
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
* @deprecated Use {@link #isTemplate(boolean)} method instead
*/
@Preview
@Deprecated
public GHCreateRepositoryBuilder templateRepository(boolean enabled) {
this.builder.withPreview(BAPTISE);
this.builder.with("is_template", enabled);
return this;
public GHCreateRepositoryBuilder templateRepository(boolean enabled) throws IOException {
return isTemplate(enabled);
}
/**
@@ -223,14 +97,15 @@ public class GHCreateRepositoryBuilder {
* @param owner
* organization or personage
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
*/
public GHCreateRepositoryBuilder owner(String owner) {
this.builder.with("owner", owner);
return this;
public GHCreateRepositoryBuilder owner(String owner) throws IOException {
return with("owner", owner);
}
/**
* Create repository from template repository.
* Create repository from template repository
*
* @param templateOwner
* template repository owner
@@ -239,11 +114,10 @@ public class GHCreateRepositoryBuilder {
* @return a builder to continue with building
* @see <a href="https://developer.github.com/v3/previews/">GitHub API Previews</a>
*/
@Preview
@Preview(BAPTISTE)
@Deprecated
public GHCreateRepositoryBuilder fromTemplateRepository(String templateOwner, String templateRepo) {
this.builder.withPreview(BAPTISE);
this.apiUrlTail = "/repos/" + templateOwner + "/" + templateRepo + "/generate";
requester.withPreview(BAPTISTE).withUrlPath("/repos/" + templateOwner + "/" + templateRepo + "/generate");
return this;
}
@@ -252,10 +126,9 @@ public class GHCreateRepositoryBuilder {
*
* @return the gh repository
* @throws IOException
* if repsitory cannot be created
* if repository cannot be created
*/
public GHRepository create() throws IOException {
return builder.method("POST").withUrlPath(apiUrlTail).fetch(GHRepository.class).wrap(root);
return done();
}
}

View File

@@ -1,5 +1,7 @@
package org.kohsuke.github;
import org.kohsuke.github.internal.Previews;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
@@ -14,7 +16,6 @@ import java.util.Map;
*/
public class GHDeployment extends GHObject {
private GHRepository owner;
private GitHub root;
protected String sha;
protected String ref;
protected String task;
@@ -24,6 +25,9 @@ public class GHDeployment extends GHObject {
protected String statuses_url;
protected String repository_url;
protected GHUser creator;
protected String original_environment;
protected boolean transient_environment;
protected boolean production_environment;
GHDeployment wrap(GHRepository owner) {
this.owner = owner;
@@ -82,13 +86,26 @@ public class GHDeployment extends GHObject {
/**
* Gets payload without assuming its type. It could be a String or a Map.
*
*
* @return the payload
*/
public Object getPayloadObject() {
return payload;
}
/**
* The environment defined when the deployment was first created.
*
* @deprecated until preview feature has graduated to stable
*
* @return the original deployment environment
*/
@Deprecated
@Preview(Previews.FLASH)
public String getOriginalEnvironment() {
return original_environment;
}
/**
* Gets environment.
*
@@ -98,6 +115,33 @@ public class GHDeployment extends GHObject {
return environment;
}
/**
* Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
* future.
*
* @deprecated until preview feature has graduated to stable
*
* @return the environment is transient
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public boolean isTransientEnvironment() {
return transient_environment;
}
/**
* Specifies if the given environment is one that end-users directly interact with.
*
* @deprecated until preview feature has graduated to stable
*
* @return the environment is used by end-users directly
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public boolean isProductionEnvironment() {
return production_environment;
}
/**
* Gets creator.
*
@@ -154,6 +198,8 @@ public class GHDeployment extends GHObject {
public PagedIterable<GHDeploymentStatus> listStatuses() {
return root.createRequest()
.withUrlPath(statuses_url)
.withPreview(Previews.ANT_MAN)
.withPreview(Previews.FLASH)
.toIterable(GHDeploymentStatus[].class, item -> item.wrap(owner));
}

View File

@@ -1,5 +1,7 @@
package org.kohsuke.github;
import org.kohsuke.github.internal.Previews;
import java.io.IOException;
import java.util.List;
@@ -19,7 +21,10 @@ public class GHDeploymentBuilder {
*/
public GHDeploymentBuilder(GHRepository repo) {
this.repo = repo;
this.builder = repo.root.createRequest().method("POST");
this.builder = repo.root.createRequest()
.withPreview(Previews.ANT_MAN)
.withPreview(Previews.FLASH)
.method("POST");
}
/**
@@ -40,6 +45,7 @@ public class GHDeploymentBuilder {
*
* @param branch
* the branch
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder ref(String branch) {
@@ -52,6 +58,7 @@ public class GHDeploymentBuilder {
*
* @param task
* the task
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder task(String task) {
@@ -64,6 +71,7 @@ public class GHDeploymentBuilder {
*
* @param autoMerge
* the auto merge
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder autoMerge(boolean autoMerge) {
@@ -76,6 +84,7 @@ public class GHDeploymentBuilder {
*
* @param requiredContexts
* the required contexts
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder requiredContexts(List<String> requiredContexts) {
@@ -88,6 +97,7 @@ public class GHDeploymentBuilder {
*
* @param payload
* the payload
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder payload(String payload) {
@@ -100,6 +110,7 @@ public class GHDeploymentBuilder {
*
* @param environment
* the environment
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder environment(String environment) {
@@ -107,11 +118,47 @@ public class GHDeploymentBuilder {
return this;
}
/**
* Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
* future.
*
* @deprecated until preview feature has graduated to stable
*
* @param transientEnvironment
* the environment is transient
*
* @return the gh deployment builder
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public GHDeploymentBuilder transientEnvironment(boolean transientEnvironment) {
builder.with("transient_environment", transientEnvironment);
return this;
}
/**
* Specifies if the given environment is one that end-users directly interact with.
*
* @deprecated until preview feature has graduated to stable
*
* @param productionEnvironment
* the environment is used by end-users directly
*
* @return the gh deployment builder
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public GHDeploymentBuilder productionEnvironment(boolean productionEnvironment) {
builder.with("production_environment", productionEnvironment);
return this;
}
/**
* Description gh deployment builder.
*
* @param description
* the description
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder description(String description) {
@@ -123,6 +170,7 @@ public class GHDeploymentBuilder {
* Create gh deployment.
*
* @return the gh deployment
*
* @throws IOException
* the io exception
*/

View File

@@ -1,8 +1,40 @@
package org.kohsuke.github;
import org.kohsuke.github.internal.Previews;
/**
* Represents the state of deployment
*/
public enum GHDeploymentState {
PENDING, SUCCESS, ERROR, FAILURE
PENDING,
SUCCESS,
ERROR,
FAILURE,
/**
* The state of the deployment currently reflects it's in progress.
*
* @deprecated until preview feature has graduated to stable
*/
@Deprecated
@Preview(Previews.FLASH)
IN_PROGRESS,
/**
* The state of the deployment currently reflects it's queued up for processing.
*
* @deprecated until preview feature has graduated to stable
*/
@Deprecated
@Preview(Previews.FLASH)
QUEUED,
/**
* The state of the deployment currently reflects it's no longer active.
*
* @deprecated until preview feature has graduated to stable
*/
@Deprecated
@Preview(Previews.ANT_MAN)
INACTIVE
}

View File

@@ -1,5 +1,7 @@
package org.kohsuke.github;
import org.kohsuke.github.internal.Previews;
import java.net.URL;
import java.util.Locale;
@@ -8,19 +10,21 @@ import java.util.Locale;
*/
public class GHDeploymentStatus extends GHObject {
private GHRepository owner;
private GitHub root;
protected GHUser creator;
protected String state;
protected String description;
protected String target_url;
protected String log_url;
protected String deployment_url;
protected String repository_url;
protected String environment_url;
/**
* Wrap gh deployment status.
*
* @param owner
* the owner
*
* @return the gh deployment status
*/
public GHDeploymentStatus wrap(GHRepository owner) {
@@ -34,12 +38,30 @@ public class GHDeploymentStatus extends GHObject {
/**
* Gets target url.
*
* @deprecated Target url is deprecated in favor of {@link #getLogUrl() getLogUrl}
*
* @return the target url
*/
@Deprecated
public URL getTargetUrl() {
return GitHubClient.parseURL(target_url);
}
/**
* Gets target url.
* <p>
* This method replaces {@link #getTargetUrl() getTargetUrl}}.
*
* @deprecated until preview feature has graduated to stable
*
* @return the target url
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public URL getLogUrl() {
return GitHubClient.parseURL(log_url);
}
/**
* Gets deployment url.
*
@@ -49,6 +71,19 @@ public class GHDeploymentStatus extends GHObject {
return GitHubClient.parseURL(deployment_url);
}
/**
* Gets deployment environment url.
*
* @deprecated until preview feature has graduated to stable
*
* @return the deployment environment url
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public URL getEnvironmentUrl() {
return GitHubClient.parseURL(environment_url);
}
/**
* Gets repository url.
*

View File

@@ -1,5 +1,7 @@
package org.kohsuke.github;
import org.kohsuke.github.internal.Previews;
import java.io.IOException;
/**
@@ -21,6 +23,7 @@ public class GHDeploymentStatusBuilder {
* the deployment id
* @param state
* the state
*
* @deprecated Use {@link GHDeployment#createStatus(GHDeploymentState)}
*/
@Deprecated
@@ -31,15 +34,38 @@ public class GHDeploymentStatusBuilder {
GHDeploymentStatusBuilder(GHRepository repo, long deploymentId, GHDeploymentState state) {
this.repo = repo;
this.deploymentId = deploymentId;
this.builder = repo.root.createRequest().method("POST");
this.builder = repo.root.createRequest()
.withPreview(Previews.ANT_MAN)
.withPreview(Previews.FLASH)
.method("POST");
this.builder.with("state", state);
}
/**
* Add an inactive status to all prior non-transient, non-production environment deployments with the same
* repository and environment name as the created status's deployment.
*
* @deprecated until preview feature has graduated to stable
*
* @param autoInactive
* Add inactive status flag
*
* @return the gh deployment status builder
*/
@Deprecated
@Preview({ Previews.ANT_MAN, Previews.FLASH })
public GHDeploymentStatusBuilder autoInactive(boolean autoInactive) {
this.builder.with("auto_inactive", autoInactive);
return this;
}
/**
* Description gh deployment status builder.
*
* @param description
* the description
*
* @return the gh deployment status builder
*/
public GHDeploymentStatusBuilder description(String description) {
@@ -47,13 +73,70 @@ public class GHDeploymentStatusBuilder {
return this;
}
/**
* Name for the target deployment environment, which can be changed when setting a deploy status.
*
* @deprecated until preview feature has graduated to stable
*
* @param environment
* the environment name
*
* @return the gh deployment status builder
*/
@Deprecated
@Preview(Previews.FLASH)
public GHDeploymentStatusBuilder environment(String environment) {
this.builder.with("environment", environment);
return this;
}
/**
* The URL for accessing the environment
*
* @deprecated until preview feature has graduated to stable
*
* @param environmentUrl
* the environment url
*
* @return the gh deployment status builder
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public GHDeploymentStatusBuilder environmentUrl(String environmentUrl) {
this.builder.with("environment_url", environmentUrl);
return this;
}
/**
* The full URL of the deployment's output.
* <p>
* This method replaces {@link #targetUrl(String) targetUrl}.
*
* @deprecated until preview feature has graduated to stable
*
* @param logUrl
* the deployment output url
*
* @return the gh deployment status builder
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public GHDeploymentStatusBuilder logUrl(String logUrl) {
this.builder.with("log_url", logUrl);
return this;
}
/**
* Target url gh deployment status builder.
*
* @deprecated Target url is deprecated in favor of {@link #logUrl(String) logUrl}
*
* @param targetUrl
* the target url
*
* @return the gh deployment status builder
*/
@Deprecated
public GHDeploymentStatusBuilder targetUrl(String targetUrl) {
this.builder.with("target_url", targetUrl);
return this;
@@ -63,6 +146,7 @@ public class GHDeploymentStatusBuilder {
* Create gh deployment status.
*
* @return the gh deployment status
*
* @throws IOException
* the io exception
*/

View File

@@ -1,7 +1,7 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.kohsuke.github.internal.Previews;
import java.io.IOException;
import java.net.URL;
@@ -18,8 +18,6 @@ import javax.annotation.Nonnull;
*/
public class GHDiscussion extends GHObject {
@JacksonInject
private GitHub root;
private GHTeam team;
private long number;
private String body, title, htmlUrl;
@@ -130,7 +128,7 @@ public class GHDiscussion extends GHObject {
*
* @return a {@link GHDiscussion.Updater}
*/
@Preview
@Preview(Previews.SQUIRREL_GIRL)
@Deprecated
public GHDiscussion.Updater update() {
return new GHDiscussion.Updater(this);
@@ -141,7 +139,7 @@ public class GHDiscussion extends GHObject {
*
* @return a {@link GHDiscussion.Setter}
*/
@Preview
@Preview(Previews.SQUIRREL_GIRL)
@Deprecated
public GHDiscussion.Setter set() {
return new GHDiscussion.Setter(this);

View File

@@ -12,6 +12,7 @@ import java.util.Locale;
public enum GHEvent {
CHECK_RUN,
CHECK_SUITE,
CODE_SCANNING_ALERT,
COMMIT_COMMENT,
CONTENT_REFERENCE,
CREATE,
@@ -56,6 +57,7 @@ public enum GHEvent {
REPOSITORY,
REPOSITORY_IMPORT,
REPOSITORY_VULNERABILITY_ALERT,
SCHEDULE,
SECURITY_ADVISORY,
STAR,
STATUS,
@@ -65,6 +67,11 @@ public enum GHEvent {
WORKFLOW_DISPATCH,
WORKFLOW_RUN,
/**
* Special event type that means we haven't found an enum value corresponding to the event.
*/
UNKNOWN,
/**
* Special event type that means "every possible event"
*/

View File

@@ -12,9 +12,7 @@ import java.util.Date;
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHEventInfo {
private GitHub root;
public class GHEventInfo extends GitHubInteractiveObject {
// we don't want to expose Jackson dependency to the user. This needs databinding
private ObjectNode payload;
@@ -55,7 +53,7 @@ public class GHEventInfo {
if (e.name().replace("_", "").equalsIgnoreCase(t))
return e;
}
return null; // unknown event type
return GHEvent.UNKNOWN;
}
GHEventInfo wrapUp(GitHub root) {

View File

@@ -5,7 +5,9 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.io.Reader;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* Base type for types used in databinding of the event payload.
@@ -17,9 +19,7 @@ import java.util.List;
*/
@SuppressWarnings("UnusedDeclaration")
@SuppressFBWarnings("UWF_UNWRITTEN_FIELD")
public class GHEventPayload {
protected GitHub root;
public class GHEventPayload extends GitHubInteractiveObject {
// https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads#webhook-payload-object-common-properties
// Webhook payload object common properties: action, sender, repository, organization, installation
private String action;
@@ -382,9 +382,9 @@ public class GHEventPayload {
}
/**
* Gets label.
* Gets the added or removed label for labeled/unlabeled events.
*
* @return the label
* @return label the added or removed label
*/
public GHLabel getLabel() {
return label;
@@ -521,6 +521,10 @@ public class GHEventPayload {
public static class Issue extends GHEventPayload {
private GHIssue issue;
private GHLabel label;
private GHIssueChanges changes;
/**
* Gets issue.
*
@@ -540,6 +544,24 @@ public class GHEventPayload {
this.issue = issue;
}
/**
* Gets the added or removed label for labeled/unlabeled events.
*
* @return label the added or removed label
*/
public GHLabel getLabel() {
return label;
}
/**
* Get changes (for action="edited")
*
* @return changes
*/
public GHIssueChanges getChanges() {
return changes;
}
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);
@@ -689,9 +711,11 @@ public class GHEventPayload {
}
/**
* Gets master branch.
* Gets default branch.
*
* @return the master branch
* Name is an artifact of when "master" was the most common default.
*
* @return the default branch
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization")
public String getMasterBranch() {
@@ -937,7 +961,7 @@ public class GHEventPayload {
}
/**
* The full Git ref that was pushed. Example: “refs/heads/master
* The full Git ref that was pushed. Example: “refs/heads/main
*
* @return the ref
*/
@@ -1069,7 +1093,7 @@ public class GHEventPayload {
public static class PushCommit {
private GitUser author;
private GitUser committer;
private String url, sha, message;
private String url, sha, message, timestamp;
private boolean distinct;
private List<String> added, removed, modified;
@@ -1158,6 +1182,15 @@ public class GHEventPayload {
public List<String> getModified() {
return modified;
}
/**
* Obtains the timestamp of the commit
*
* @return the timestamp
*/
public Date getTimestamp() {
return GitHubClient.parseDate(timestamp);
}
}
}
@@ -1216,19 +1249,29 @@ public class GHEventPayload {
private String description;
private GHCommitState state;
private GHCommit commit;
private String targetUrl;
/**
* Gets the status content.
*
*
* @return status content
*/
public String getContext() {
return context;
}
/**
* The optional link added to the status.
*
* @return a url
*/
public String getTargetUrl() {
return targetUrl;
}
/**
* Gets the status description.
*
*
* @return status description
*/
public String getDescription() {
@@ -1237,7 +1280,7 @@ public class GHEventPayload {
/**
* Gets the status state.
*
*
* @return status state
*/
public GHCommitState getState() {
@@ -1246,7 +1289,7 @@ public class GHEventPayload {
/**
* Sets the status stage.
*
*
* @param state
* status state
*/
@@ -1256,7 +1299,7 @@ public class GHEventPayload {
/**
* Gets the commit associated with the status event.
*
*
* @return commit
*/
public GHCommit getCommit() {
@@ -1265,7 +1308,7 @@ public class GHEventPayload {
/**
* Sets the commit associated with the status event.
*
*
* @param commit
* commit
*/
@@ -1286,4 +1329,125 @@ public class GHEventPayload {
}
}
}
/**
* Occurs when someone triggered a workflow run or sends a POST request to the "Create a workflow dispatch event"
* endpoint.
*
* @see <a href=
* "https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#workflow_dispatch">
* workflow dispatch event</a>
* @see <a href=
* "https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch">Events that
* trigger workflows</a>
*/
public static class WorkflowDispatch extends GHEventPayload {
private Map<String, Object> inputs;
private String ref;
private String workflow;
/**
* Gets the map of input parameters passed to the workflow.
*
* @return the map of input parameters
*/
public Map<String, Object> getInputs() {
return inputs;
}
/**
* Gets the ref of the branch (e.g. refs/heads/main)
*
* @return the ref of the branch
*/
public String getRef() {
return ref;
}
/**
* Gets the path of the workflow file (e.g. .github/workflows/hello-world-workflow.yml).
*
* @return the path of the workflow file
*/
public String getWorkflow() {
return workflow;
}
}
/**
* A workflow run was requested or completed.
*
* @see <a href=
* "https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#workflow_run">
* workflow run event</a>
* @see <a href="https://docs.github.com/en/rest/reference/actions#workflow-runs">Actions Workflow Runs</a>
*/
public static class WorkflowRun extends GHEventPayload {
private GHWorkflowRun workflowRun;
private GHWorkflow workflow;
/**
* Gets the workflow run.
*
* @return the workflow run
*/
public GHWorkflowRun getWorkflowRun() {
return workflowRun;
}
/**
* Gets the associated workflow.
*
* @return the associated workflow
*/
public GHWorkflow getWorkflow() {
return workflow;
}
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);
if (workflowRun == null || workflow == null) {
throw new IllegalStateException(
"Expected workflow and workflow_run payload, but got something else. Maybe we've got another type of event?");
}
GHRepository repository = getRepository();
if (repository == null) {
throw new IllegalStateException("Repository must not be null");
}
workflowRun.wrapUp(repository);
workflow.wrapUp(repository);
}
}
/**
* A label was created, edited or deleted.
*
* @see <a href= "https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#label">
* label event</a>
*/
public static class Label extends GHEventPayload {
private GHLabel label;
private GHLabelChanges changes;
/**
* Gets the label.
*
* @return the label
*/
public GHLabel getLabel() {
return label;
}
/**
* Gets changes (for action="edited")
*
* @return changes
*/
public GHLabelChanges getChanges() {
return changes;
}
}
}

View File

@@ -23,7 +23,6 @@ import java.util.Map.Entry;
public class GHGist extends GHObject {
final GHUser owner;
final GitHub root;
private String forks_url, commits_url, id, git_pull_url, git_push_url, html_url;
@@ -123,7 +122,7 @@ public class GHGist extends GHObject {
/**
* Get the html url.
*
*
* @return the github html url
*/
public URL getHtmlUrl() {

View File

@@ -13,7 +13,6 @@ import javax.annotation.Nonnull;
* @see GitHub#createGist() GitHub#createGist()
*/
public class GHGistBuilder {
private final GitHub root;
private final Requester req;
private final LinkedHashMap<String, Object> files = new LinkedHashMap<String, Object>();
@@ -24,7 +23,6 @@ public class GHGistBuilder {
* the root
*/
public GHGistBuilder(GitHub root) {
this.root = root;
req = root.createRequest().method("POST");
}

View File

@@ -12,8 +12,7 @@ import java.util.Map;
* functionality
*/
class GHHooks {
static abstract class Context {
private final GitHub root;
static abstract class Context extends GitHubInteractiveObject {
private Context(GitHub root) {
this.root = root;

View File

@@ -16,7 +16,6 @@ import java.net.URL;
"UUF_UNUSED_FIELD" },
justification = "JSON API")
public class GHInvitation extends GHObject {
/* package almost final */ GitHub root;
private int id;
private GHRepository repository;

View File

@@ -39,7 +39,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Objects;
import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
/**
* Represents an issue on GitHub.
@@ -53,7 +53,6 @@ import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
public class GHIssue extends GHObject implements Reactable {
private static final String ASSIGNEES = "assignees";
GitHub root;
GHRepository owner;
// API v3
@@ -313,7 +312,7 @@ public class GHIssue extends GHObject implements Reactable {
}
/**
* Sets labels.
* Sets labels on the target to a specific list.
*
* @param labels
* the labels
@@ -327,100 +326,137 @@ public class GHIssue extends GHObject implements Reactable {
/**
* Adds labels to the issue.
*
* Labels that are already present on the target are ignored.
*
* @return the complete list of labels including the new additions
* @param names
* Names of the label
* @throws IOException
* the io exception
*/
public void addLabels(String... names) throws IOException {
_addLabels(Arrays.asList(names));
@WithBridgeMethods(void.class)
public List<GHLabel> addLabels(String... names) throws IOException {
return _addLabels(Arrays.asList(names));
}
/**
* Add labels.
*
* Labels that are already present on the target are ignored.
*
* @return the complete list of labels including the new additions
* @param labels
* the labels
* @throws IOException
* the io exception
*/
public void addLabels(GHLabel... labels) throws IOException {
addLabels(Arrays.asList(labels));
@WithBridgeMethods(void.class)
public List<GHLabel> addLabels(GHLabel... labels) throws IOException {
return addLabels(Arrays.asList(labels));
}
/**
* Add labels.
*
* Labels that are already present on the target are ignored.
*
* @return the complete list of labels including the new additions
* @param labels
* the labels
* @throws IOException
* the io exception
*/
public void addLabels(Collection<GHLabel> labels) throws IOException {
_addLabels(GHLabel.toNames(labels));
@WithBridgeMethods(void.class)
public List<GHLabel> addLabels(Collection<GHLabel> labels) throws IOException {
return _addLabels(GHLabel.toNames(labels));
}
private void _addLabels(Collection<String> names) throws IOException {
List<String> newLabels = new ArrayList<String>();
for (GHLabel label : getLabels()) {
newLabels.add(label.getName());
}
for (String name : names) {
if (!newLabels.contains(name)) {
newLabels.add(name);
}
}
setLabels(newLabels.toArray(new String[0]));
private List<GHLabel> _addLabels(Collection<String> names) throws IOException {
return Arrays.asList(root.createRequest()
.with("labels", names)
.method("POST")
.withUrlPath(getIssuesApiRoute() + "/labels")
.fetch(GHLabel[].class));
}
/**
* Remove a given label by name from this issue.
* Remove a single label.
*
* Attempting to remove a label that is not present throws {@link GHFileNotFoundException}.
*
* @return the remaining list of labels
* @param name
* the name
* @throws IOException
* the io exception, throws {@link GHFileNotFoundException} if label was not present.
*/
@WithBridgeMethods(void.class)
public List<GHLabel> removeLabel(String name) throws IOException {
return Arrays.asList(root.createRequest()
.method("DELETE")
.withUrlPath(getIssuesApiRoute() + "/labels", name)
.fetch(GHLabel[].class));
}
/**
* Remove a collection of labels.
*
* Attempting to remove labels that are not present on the target are ignored.
*
* @return the remaining list of labels
* @param names
* the names
* @throws IOException
* the io exception
*/
public void removeLabels(String... names) throws IOException {
_removeLabels(Arrays.asList(names));
@WithBridgeMethods(void.class)
public List<GHLabel> removeLabels(String... names) throws IOException {
return _removeLabels(Arrays.asList(names));
}
/**
* Remove labels.
* Remove a collection of labels.
*
* Attempting to remove labels that are not present on the target are ignored.
*
* @return the remaining list of labels
* @param labels
* the labels
* @throws IOException
* the io exception
* @see #removeLabels(String...) #removeLabels(String...)
*/
public void removeLabels(GHLabel... labels) throws IOException {
removeLabels(Arrays.asList(labels));
@WithBridgeMethods(void.class)
public List<GHLabel> removeLabels(GHLabel... labels) throws IOException {
return removeLabels(Arrays.asList(labels));
}
/**
* Remove labels.
* Remove a collection of labels.
*
* Attempting to remove labels that are not present on the target are ignored.
*
* @return the remaining list of labels
* @param labels
* the labels
* @throws IOException
* the io exception
*/
public void removeLabels(Collection<GHLabel> labels) throws IOException {
_removeLabels(GHLabel.toNames(labels));
@WithBridgeMethods(void.class)
public List<GHLabel> removeLabels(Collection<GHLabel> labels) throws IOException {
return _removeLabels(GHLabel.toNames(labels));
}
private void _removeLabels(Collection<String> names) throws IOException {
List<String> newLabels = new ArrayList<String>();
for (GHLabel l : getLabels()) {
if (!names.contains(l.getName())) {
newLabels.add(l.getName());
private List<GHLabel> _removeLabels(Collection<String> names) throws IOException {
List<GHLabel> remainingLabels = Collections.emptyList();
for (String name : names) {
try {
remainingLabels = removeLabel(name);
} catch (GHFileNotFoundException e) {
// when trying to remove multiple labels, we ignore already removed
}
}
setLabels(newLabels.toArray(new String[0]));
return remainingLabels;
}
/**
@@ -448,7 +484,7 @@ public class GHIssue extends GHObject implements Reactable {
.toIterable(GHIssueComment[].class, item -> item.wrapUp(this));
}
@Preview
@Preview(SQUIRREL_GIRL)
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return root.createRequest()
@@ -460,7 +496,7 @@ public class GHIssue extends GHObject implements Reactable {
.wrap(root);
}
@Preview
@Preview(SQUIRREL_GIRL)
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return root.createRequest()

View File

@@ -0,0 +1,49 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Wrapper to define changed fields on issues action="edited"
*
* @see GHEventPayload.Issue
*/
@SuppressFBWarnings("UWF_UNWRITTEN_FIELD")
public class GHIssueChanges {
private GHFrom title;
private GHFrom body;
/**
* Old issue title.
*
* @return old issue title (or null if not changed)
*/
public GHFrom getTitle() {
return title;
}
/**
* Old issue body.
*
* @return old issue body (or null if not changed)
*/
public GHFrom getBody() {
return body;
}
/**
* Wrapper for changed values.
*/
public static class GHFrom {
private String from;
/**
* Previous value that was changed.
*
* @return previous value
*/
public String getFrom() {
return from;
}
}
}

View File

@@ -26,7 +26,7 @@ package org.kohsuke.github;
import java.io.IOException;
import java.net.URL;
import static org.kohsuke.github.Previews.*;
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
/**
* Comment to the issue
@@ -126,7 +126,7 @@ public class GHIssueComment extends GHObject implements Reactable {
owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
@Preview
@Preview(SQUIRREL_GIRL)
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return owner.root.createRequest()
@@ -138,7 +138,7 @@ public class GHIssueComment extends GHObject implements Reactable {
.wrap(owner.root);
}
@Preview
@Preview(SQUIRREL_GIRL)
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.createRequest()

View File

@@ -9,9 +9,7 @@ import java.util.Date;
*
* @author Martin van Zijl
*/
public class GHIssueEvent {
private GitHub root;
public class GHIssueEvent extends GitHubInteractiveObject {
private long id;
private String node_id;
private String url;

View File

@@ -31,4 +31,4 @@ package org.kohsuke.github;
*/
public enum GHIssueState {
OPEN, CLOSED, ALL
}
}

View File

@@ -9,9 +9,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHKey {
/* package almost final */ GitHub root;
public class GHKey extends GitHubInteractiveObject {
protected String url, key, title;
protected boolean verified;
protected int id;

View File

@@ -2,6 +2,7 @@ package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.IOException;
import java.util.ArrayList;
@@ -20,7 +21,12 @@ import javax.annotation.Nonnull;
* @see GHIssue#getLabels() GHIssue#getLabels()
* @see GHRepository#listLabels() GHRepository#listLabels()
*/
public class GHLabel {
public class GHLabel extends GitHubInteractiveObject {
private long id;
private String nodeId;
@JsonProperty("default")
private boolean default_;
@Nonnull
private String url, name, color;
@@ -28,9 +34,6 @@ public class GHLabel {
@CheckForNull
private String description;
@Nonnull
private final GitHub root;
@JsonCreator
private GHLabel(@JacksonInject @Nonnull GitHub root) {
this.root = root;
@@ -45,6 +48,24 @@ public class GHLabel {
return Objects.requireNonNull(root);
}
/**
* Gets id.
*
* @return the id
*/
public long getId() {
return id;
}
/**
* Gets node id.
*
* @return the node id.
*/
public String getNodeId() {
return nodeId;
}
/**
* Gets url.
*
@@ -85,6 +106,15 @@ public class GHLabel {
return description;
}
/**
* If the label is one of the default labels created by GitHub automatically.
*
* @return true if the label is a default one
*/
public boolean isDefault() {
return default_;
}
/**
* Sets color.
*
@@ -132,7 +162,7 @@ public class GHLabel {
* @throws IOException
* the io exception
*/
@Preview
@BetaApi
@Deprecated
static Creator create(GHRepository repository) throws IOException {
return new Creator(repository);
@@ -179,7 +209,7 @@ public class GHLabel {
*
* @return a {@link Updater}
*/
@Preview
@BetaApi
@Deprecated
public Updater update() {
return new Updater(this);
@@ -187,10 +217,10 @@ public class GHLabel {
/**
* Begins a single property update.
*
*
* @return a {@link Setter}
*/
@Preview
@BetaApi
@Deprecated
public Setter set() {
return new Setter(this);
@@ -227,7 +257,7 @@ public class GHLabel {
*
* {@link #done()} is called automatically after the property is set.
*/
@Preview
@BetaApi
@Deprecated
public static class Setter extends GHLabelBuilder<GHLabel> {
private Setter(@Nonnull GHLabel base) {
@@ -241,7 +271,7 @@ public class GHLabel {
*
* Consumer must call {@link #done()} to commit changes.
*/
@Preview
@BetaApi
@Deprecated
public static class Updater extends GHLabelBuilder<Updater> {
private Updater(@Nonnull GHLabel base) {
@@ -255,7 +285,7 @@ public class GHLabel {
*
* Consumer must call {@link #done()} to create the new instance.
*/
@Preview
@BetaApi
@Deprecated
public static class Creator extends GHLabelBuilder<Creator> {
private Creator(@Nonnull GHRepository repository) {

View File

@@ -38,21 +38,21 @@ class GHLabelBuilder<S> extends AbstractBuilder<GHLabel, S> {
}
@Nonnull
@Preview
@BetaApi
@Deprecated
public S name(String value) throws IOException {
return with("name", value);
}
@Nonnull
@Preview
@BetaApi
@Deprecated
public S color(String value) throws IOException {
return with("color", value);
}
@Nonnull
@Preview
@BetaApi
@Deprecated
public S description(String value) throws IOException {
return with("description", value);

View File

@@ -0,0 +1,49 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Wrapper to define changed fields on label action="edited"
*
* @see GHEventPayload.Label
*/
@SuppressFBWarnings("UWF_UNWRITTEN_FIELD")
public class GHLabelChanges {
private GHFrom name;
private GHFrom color;
/**
* Old label name.
*
* @return old label name (or null if not changed)
*/
public GHFrom getName() {
return name;
}
/**
* Old label color.
*
* @return old label color (or null if not changed)
*/
public GHFrom getColor() {
return color;
}
/**
* Wrapper for changed values.
*/
public static class GHFrom {
private String from;
/**
* Previous value that was changed.
*
* @return previous value
*/
public String getFrom() {
return from;
}
}
}

View File

@@ -44,9 +44,6 @@ import java.util.Objects;
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public class GHLicense extends GHObject {
@SuppressFBWarnings("IS2_INCONSISTENT_SYNC")
// root is set before the object is returned to the app
/* package almost final */ GitHub root;
// these fields are always present, even in the short form
protected String key, name;

View File

@@ -9,9 +9,7 @@ import java.net.URL;
* @see GitHub#getMyMarketplacePurchases()
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplaceAccount {
protected GitHub root;
public class GHMarketplaceAccount extends GitHubInteractiveObject {
private String url;
private long id;
private String login;

View File

@@ -8,8 +8,7 @@ import java.io.IOException;
* @author Paulo Miguel Almeida
* @see GHMarketplacePlan#listAccounts()
*/
public class GHMarketplaceListAccountBuilder {
private final GitHub root;
public class GHMarketplaceListAccountBuilder extends GitHubInteractiveObject {
private final Requester builder;
private final long planId;

View File

@@ -10,8 +10,7 @@ import java.util.Date;
* @author Paulo Miguel Almeida
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplacePendingChange {
private GitHub root;
public class GHMarketplacePendingChange extends GitHubInteractiveObject {
private long id;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private Long unitCount;

View File

@@ -11,9 +11,7 @@ import java.util.List;
* @author Paulo Miguel Almeida
* @see GitHub#listMarketplacePlans()
*/
public class GHMarketplacePlan {
private GitHub root;
public class GHMarketplacePlan extends GitHubInteractiveObject {
private String url;
private String accountsUrl;
private long id;

View File

@@ -10,9 +10,8 @@ import java.util.Date;
* @author Paulo Miguel Almeida
* @see GHMarketplaceListAccountBuilder#createRequest() GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplacePurchase {
public class GHMarketplacePurchase extends GitHubInteractiveObject {
private GitHub root;
private String billingCycle;
private String nextBillingDate;
private boolean onFreeTrial;

View File

@@ -10,8 +10,7 @@ import java.util.Date;
* @author Paulo Miguel Almeida
* @see GitHub#getMyMarketplacePurchases()
*/
public class GHMarketplaceUserPurchase {
protected GitHub root;
public class GHMarketplaceUserPurchase extends GitHubInteractiveObject {
private String billingCycle;
private String nextBillingDate;
private boolean onFreeTrial;

View File

@@ -10,9 +10,7 @@ import java.util.Locale;
* @author Kohsuke Kawaguchi
* @see GHMyself#listOrgMemberships() GHMyself#listOrgMemberships()
*/
public class GHMembership /* extends GHObject --- but it doesn't have id, created_at, etc. */ {
GitHub root;
public class GHMembership extends GitHubInteractiveObject {
String url;
String state;
String role;

View File

@@ -11,7 +11,6 @@ import java.util.Locale;
* @author Yusuke Kokubo
*/
public class GHMilestone extends GHObject {
GitHub root;
GHRepository owner;
GHUser creator;

View File

@@ -7,4 +7,4 @@ package org.kohsuke.github;
*/
public enum GHMilestoneState {
OPEN, CLOSED
}
}

View File

@@ -23,9 +23,7 @@ import java.util.NoSuchElementException;
* @see GitHub#listNotifications() GitHub#listNotifications()
* @see GHRepository#listNotifications() GHRepository#listNotifications()
*/
public class GHNotificationStream implements Iterable<GHThread> {
private final GitHub root;
public class GHNotificationStream extends GitHubInteractiveObject implements Iterable<GHThread> {
private Boolean all, participating;
private String since;
private String apiUrl;

View File

@@ -20,7 +20,7 @@ import javax.annotation.CheckForNull;
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public abstract class GHObject {
public abstract class GHObject extends GitHubInteractiveObject {
/**
* Capture response HTTP headers on the state object.
*/
@@ -38,7 +38,7 @@ public abstract class GHObject {
/**
* Called by Jackson
*
*
* @param responseInfo
* the {@link GitHubResponse.ResponseInfo} to get headers from.
*/

View File

@@ -10,7 +10,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import static org.kohsuke.github.Previews.INERTIA;
import static org.kohsuke.github.internal.Previews.INERTIA;
/**
* The type GHOrganization.
@@ -97,7 +97,7 @@ public class GHOrganization extends GHPerson {
* @return the gh create repository builder
*/
public GHCreateRepositoryBuilder createRepository(String name) {
return new GHCreateRepositoryBuilder(root, "/orgs/" + login + "/repos", name);
return new GHCreateRepositoryBuilder(name, root, "/orgs/" + login + "/repos");
}
/**
@@ -181,7 +181,7 @@ 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

View File

@@ -28,7 +28,7 @@ import java.util.Locale;
/**
* Permission for a user in a repository.
*
*
* @see <a href="https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level">API</a>
*/
class GHPermission {

View File

@@ -18,7 +18,6 @@ import java.util.TreeMap;
* @author Kohsuke Kawaguchi
*/
public abstract class GHPerson extends GHObject {
/* package almost final */ GitHub root;
// core data fields that exist even for "small" user data (such as the user info in pull request)
protected String login, avatar_url;
@@ -236,7 +235,7 @@ public abstract class GHPerson extends GHObject {
/**
* Gets the Twitter Username of this user, like "GitHub"
*
*
* @return the Twitter username
* @throws IOException
* the io exception

View File

@@ -28,7 +28,7 @@ import java.io.IOException;
import java.net.URL;
import java.util.Locale;
import static org.kohsuke.github.Previews.INERTIA;
import static org.kohsuke.github.internal.Previews.INERTIA;
/**
* A GitHub project.
@@ -37,7 +37,6 @@ import static org.kohsuke.github.Previews.INERTIA;
* @see <a href="https://developer.github.com/v3/projects/">Projects</a>
*/
public class GHProject extends GHObject {
protected GitHub root;
protected GHObject owner;
private String owner_url;
@@ -311,4 +310,4 @@ public class GHProject extends GHObject {
.fetch(GHProjectColumn.class)
.wrap(this);
}
}
}

View File

@@ -6,7 +6,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import static org.kohsuke.github.Previews.INERTIA;
import static org.kohsuke.github.internal.Previews.INERTIA;
/**
* The type GHProjectCard.
@@ -14,7 +14,6 @@ import static org.kohsuke.github.Previews.INERTIA;
* @author Gunnar Skjold
*/
public class GHProjectCard extends GHObject {
private GitHub root;
private GHProject project;
private GHProjectColumn column;

View File

@@ -4,7 +4,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import static org.kohsuke.github.Previews.INERTIA;
import static org.kohsuke.github.internal.Previews.INERTIA;
/**
* The type GHProjectColumn.
@@ -12,7 +12,6 @@ import static org.kohsuke.github.Previews.INERTIA;
* @author Gunnar Skjold
*/
public class GHProjectColumn extends GHObject {
protected GitHub root;
protected GHProject project;
private String name;

View File

@@ -36,8 +36,8 @@ import java.util.Objects;
import javax.annotation.CheckForNull;
import static org.kohsuke.github.Previews.LYDIAN;
import static org.kohsuke.github.Previews.SHADOW_CAT;
import static org.kohsuke.github.internal.Previews.LYDIAN;
import static org.kohsuke.github.internal.Previews.SHADOW_CAT;
/**
* A pull request.
@@ -576,7 +576,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @throws IOException
* the io exception
*/
@Preview
@Preview(LYDIAN)
@Deprecated
public void updateBranch() throws IOException {
root.createRequest()

View File

@@ -1,6 +1,6 @@
package org.kohsuke.github;
import static org.kohsuke.github.Previews.SHADOW_CAT;
import static org.kohsuke.github.internal.Previews.SHADOW_CAT;
/**
* Lists up pull requests with some filtering and sorting.

View File

@@ -28,7 +28,7 @@ import java.net.URL;
import javax.annotation.CheckForNull;
import static org.kohsuke.github.Previews.*;
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
/**
* Review comment to the pull request
@@ -153,7 +153,20 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
* @return the api route
*/
protected String getApiRoute() {
return "/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + getId();
return getApiRoute(false);
}
/**
* Gets api route.
*
* @param includePullNumber
* if true, includes the owning pull request's number in the route.
*
* @return the api route
*/
protected String getApiRoute(boolean includePullNumber) {
return "/repos/" + owner.getRepository().getFullName() + "/pulls"
+ (includePullNumber ? "/" + owner.getNumber() : "") + "/comments/" + getId();
}
/**
@@ -192,13 +205,12 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
return owner.root.createRequest()
.method("POST")
.with("body", body)
.with("in_reply_to", getId())
.withUrlPath(getApiRoute() + "/comments")
.withUrlPath(getApiRoute(true) + "/replies")
.fetch(GHPullRequestReviewComment.class)
.wrapUp(owner);
}
@Preview
@Preview(SQUIRREL_GIRL)
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return owner.root.createRequest()
@@ -210,7 +222,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
.wrap(owner.root);
}
@Preview
@Preview(SQUIRREL_GIRL)
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.createRequest()

View File

@@ -7,8 +7,7 @@ package org.kohsuke.github;
* the type parameter
* @author Kohsuke Kawaguchi
*/
public abstract class GHQueryBuilder<T> {
protected final GitHub root;
public abstract class GHQueryBuilder<T> extends GitHubInteractiveObject {
protected final Requester req;
GHQueryBuilder(GitHub root) {

View File

@@ -266,7 +266,7 @@ public class GHRateLimit {
/**
* 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
@@ -458,7 +458,7 @@ public class GHRateLimit {
* {@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

View File

@@ -3,7 +3,7 @@ package org.kohsuke.github;
import java.io.IOException;
import java.net.URL;
import static org.kohsuke.github.Previews.*;
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
/**
* Reaction to issue, comment, PR, and so on.
@@ -11,10 +11,9 @@ import static org.kohsuke.github.Previews.*;
* @author Kohsuke Kawaguchi
* @see Reactable
*/
@Preview
@Preview(SQUIRREL_GIRL)
@Deprecated
public class GHReaction extends GHObject {
private GitHub root;
private GHUser user;
private ReactionContent content;

View File

@@ -11,9 +11,7 @@ import java.net.URL;
*
* @author Michael Clarke
*/
public class GHRef {
/* package almost final */ GitHub root;
public class GHRef extends GitHubInteractiveObject {
private String ref, url;
private GHObject object;

View File

@@ -19,7 +19,6 @@ import static java.lang.String.*;
* @see GHRepository#createRelease(String) GHRepository#createRelease(String)
*/
public class GHRelease extends GHObject {
GitHub root;
GHRepository owner;
private String html_url;
@@ -260,7 +259,6 @@ public class GHRelease extends GHObject {
* existing logic in place for backwards compatibility.
*/
@Deprecated
@Preview
public List<GHAsset> assets() {
return assets;
}

View File

@@ -41,7 +41,7 @@ public class GHReleaseBuilder {
* Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA.
*
* @param commitish
* Defaults to the repositorys default branch (usually "master"). Unused if the Git tag already exists.
* Defaults to the repositorys default branch (usually "main"). Unused if the Git tag already exists.
* @return the gh release builder
*/
public GHReleaseBuilder commitish(String commitish) {

View File

@@ -45,7 +45,7 @@ public class GHReleaseUpdater {
* Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA.
*
* @param commitish
* Defaults to the repositorys default branch (usually "master"). Unused if the Git tag already exists.
* Defaults to the repositorys default branch (usually "main"). Unused if the Git tag already exists.
* @return the gh release updater
*/
public GHReleaseUpdater commitish(String commitish) {

View File

@@ -30,6 +30,8 @@ import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.function.InputStreamFunction;
import org.kohsuke.github.internal.EnumUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -48,14 +50,24 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.WeakHashMap;
import static java.util.Arrays.*;
import static org.kohsuke.github.Previews.*;
import javax.annotation.Nonnull;
import static java.util.Arrays.asList;
import static java.util.Objects.requireNonNull;
import static org.kohsuke.github.internal.Previews.ANTIOPE;
import static org.kohsuke.github.internal.Previews.ANT_MAN;
import static org.kohsuke.github.internal.Previews.BAPTISTE;
import static org.kohsuke.github.internal.Previews.FLASH;
import static org.kohsuke.github.internal.Previews.INERTIA;
import static org.kohsuke.github.internal.Previews.MERCY;
import static org.kohsuke.github.internal.Previews.NEBULA;
import static org.kohsuke.github.internal.Previews.SHADOW_CAT;
/**
* A repository on GitHub.
@@ -66,7 +78,6 @@ import static org.kohsuke.github.Previews.*;
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public class GHRepository extends GHObject {
/* package almost final */ transient GitHub root;
private String nodeId, description, homepage, name, full_name;
@@ -96,6 +107,8 @@ public class GHRepository extends GHObject {
@JsonProperty("private")
private boolean _private;
private String visibility;
private int forks_count, stargazers_count, watchers_count, size, open_issues_count, subscribers_count;
private String pushed_at;
@@ -163,6 +176,8 @@ public class GHRepository extends GHObject {
.with("task", task)
.with("environment", environment)
.withUrlPath(getApiTailUrl("deployments"))
.withPreview(ANT_MAN)
.withPreview(FLASH)
.toIterable(GHDeployment[].class, item -> item.wrap(this));
}
@@ -178,6 +193,8 @@ public class GHRepository extends GHObject {
public GHDeployment getDeployment(long id) throws IOException {
return root.createRequest()
.withUrlPath(getApiTailUrl("deployments/" + id))
.withPreview(ANT_MAN)
.withPreview(FLASH)
.fetch(GHDeployment.class)
.wrap(this);
}
@@ -444,7 +461,7 @@ public class GHRepository extends GHObject {
* Creates a named ref, such as tag, branch, etc.
*
* @param name
* The name of the fully qualified reference (ie: refs/heads/master). If it doesn't start with 'refs' and
* The name of the fully qualified reference (ie: refs/heads/main). If it doesn't start with 'refs' and
* have at least two slashes, it will be rejected.
* @param sha
* The SHA1 value to set this reference to
@@ -561,7 +578,15 @@ public class GHRepository extends GHObject {
* the io exception
*/
public Map<String, Long> listLanguages() throws IOException {
return root.createRequest().withUrlPath(getApiTailUrl("languages")).fetch(HashMap.class);
HashMap<String, Long> result = new HashMap<>();
root.createRequest().withUrlPath(getApiTailUrl("languages")).fetch(HashMap.class).forEach((key, value) -> {
Long addValue = -1L;
if (value instanceof Integer) {
addValue = Long.valueOf((Integer) value);
}
result.put(key.toString(), addValue);
});
return result;
}
/**
@@ -698,13 +723,48 @@ public class GHRepository extends GHObject {
return _private;
}
/**
* Visibility of a repository.
*/
public enum Visibility {
PUBLIC, INTERNAL, PRIVATE, UNKNOWN;
public static Visibility from(String value) {
return EnumUtils.getNullableEnumOrDefault(Visibility.class, value, Visibility.UNKNOWN);
}
@Override
public String toString() {
return name().toLowerCase(Locale.ROOT);
}
}
/**
* Gets the visibility of the repository.
*
* @return the visibility
*/
@Deprecated
@Preview(NEBULA)
public Visibility getVisibility() {
if (visibility == null) {
try {
populate();
} catch (final IOException e) {
// Convert this to a runtime exception to avoid messy method signature
throw new GHException("Could not populate the visibility of the repository", e);
}
}
return Visibility.from(visibility);
}
/**
* Is template boolean.
*
* @return the boolean
*/
@Deprecated
@Preview
@Preview(BAPTISTE)
public boolean isTemplate() {
// isTemplate is still in preview, we do not want to retrieve it unless needed.
if (isTemplate == null) {
@@ -788,16 +848,18 @@ public class GHRepository extends GHObject {
/**
* Returns the primary branch you'll configure in the "Admin &gt; Options" config page.
*
* @return This field is null until the user explicitly configures the master branch.
* @return This field is null until the user explicitly configures the default branch.
*/
public String getDefaultBranch() {
return default_branch;
}
/**
* Gets master branch.
* Gets default branch.
*
* @return the master branch
* Name is an artifact of when "master" was the most common default.
*
* @return the default branch
* @deprecated Renamed to {@link #getDefaultBranch()}
*/
@Deprecated
@@ -814,6 +876,13 @@ public class GHRepository extends GHObject {
return size;
}
/**
* Affiliation of a repository collaborator
*/
public enum CollaboratorAffiliation {
ALL, DIRECT, OUTSIDE
}
/**
* Gets the collaborators on this repository. This set always appear to include the owner.
*
@@ -837,6 +906,19 @@ public class GHRepository extends GHObject {
return listUsers("collaborators");
}
/**
* Lists up the collaborators on this repository.
*
* @param affiliation
* Filter users by affiliation
* @return Users paged iterable
* @throws IOException
* the io exception
*/
public PagedIterable<GHUser> listCollaborators(CollaboratorAffiliation affiliation) throws IOException {
return listUsers(root.createRequest().with("affiliation", affiliation), "collaborators");
}
/**
* Lists all
* <a href="https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users/">the
@@ -884,6 +966,29 @@ public class GHRepository extends GHObject {
return r;
}
/**
* Gets the names of the collaborators on this repository. This method deviates from the principle of this library
* but it works a lot faster than {@link #getCollaborators()}.
*
* @param affiliation
* Filter users by affiliation
* @return the collaborator names
* @throws IOException
* the io exception
*/
public Set<String> getCollaboratorNames(CollaboratorAffiliation affiliation) throws IOException {
Set<String> r = new HashSet<>();
// no initializer - we just want to the logins
PagedIterable<GHUser> users = root.createRequest()
.withUrlPath(getApiTailUrl("collaborators"))
.with("affiliation", affiliation)
.toIterable(GHUser[].class, null);
for (GHUser u : users.toArray()) {
r.add(u.login);
}
return r;
}
/**
* Obtain permission for a given user in this repository.
*
@@ -1039,14 +1144,6 @@ public class GHRepository extends GHObject {
.send();
}
private void edit(String key, String value) throws IOException {
Requester requester = root.createRequest();
if (!key.equals("name")) {
requester.with("name", name); // even when we don't change the name, we need to send it in
}
requester.with(key, value).method("PATCH").withUrlPath(getApiTailUrl("")).send();
}
/**
* Enables or disables the issue tracker for this repository.
*
@@ -1056,7 +1153,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void enableIssueTracker(boolean v) throws IOException {
edit("has_issues", String.valueOf(v));
set().issues(v);
}
/**
@@ -1068,7 +1165,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void enableProjects(boolean v) throws IOException {
edit("has_projects", String.valueOf(v));
set().projects(v);
}
/**
@@ -1080,7 +1177,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void enableWiki(boolean v) throws IOException {
edit("has_wiki", String.valueOf(v));
set().wiki(v);
}
/**
@@ -1092,7 +1189,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void enableDownloads(boolean v) throws IOException {
edit("has_downloads", String.valueOf(v));
set().downloads(v);
}
/**
@@ -1104,7 +1201,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void renameTo(String name) throws IOException {
edit("name", name);
set().name(name);
}
/**
@@ -1116,7 +1213,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void setDescription(String value) throws IOException {
edit("description", value);
set().description(value);
}
/**
@@ -1128,7 +1225,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void setHomepage(String value) throws IOException {
edit("homepage", value);
set().homepage(value);
}
/**
@@ -1140,7 +1237,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void setDefaultBranch(String value) throws IOException {
edit("default_branch", value);
set().defaultBranch(value);
}
/**
@@ -1152,7 +1249,27 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void setPrivate(boolean value) throws IOException {
edit("private", Boolean.toString(value));
set().private_(value);
}
/**
* Sets visibility.
*
* @param value
* the value
* @throws IOException
* the io exception
*/
@Deprecated
@Preview(NEBULA)
public void setVisibility(final Visibility value) throws IOException {
root.createRequest()
.method("PATCH")
.withPreview(NEBULA)
.with("name", name)
.with("visibility", value)
.withUrlPath(getApiTailUrl(""))
.send();
}
/**
@@ -1164,7 +1281,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void allowSquashMerge(boolean value) throws IOException {
edit("allow_squash_merge", Boolean.toString(value));
set().allowSquashMerge(value);
}
/**
@@ -1176,7 +1293,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void allowMergeCommit(boolean value) throws IOException {
edit("allow_merge_commit", Boolean.toString(value));
set().allowMergeCommit(value);
}
/**
@@ -1188,7 +1305,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void allowRebaseMerge(boolean value) throws IOException {
edit("allow_rebase_merge", Boolean.toString(value));
set().allowRebaseMerge(value);
}
/**
@@ -1200,7 +1317,7 @@ public class GHRepository extends GHObject {
* the io exception
*/
public void deleteBranchOnMerge(boolean value) throws IOException {
edit("delete_branch_on_merge", Boolean.toString(value));
set().deleteBranchOnMerge(value);
}
/**
@@ -1237,12 +1354,30 @@ public class GHRepository extends GHObject {
* In case of any networking error or error from the server.
*/
public void archive() throws IOException {
edit("archived", "true");
// Generall would not update this record,
// but do so here since this will result in any other update actions failing
set().archive();
// Generally would not update this record,
// but doing so here since this will result in any other update actions failing
archived = true;
}
/**
* Creates a builder that can be used to bulk update repository settings.
*
* @return the repository updater
*/
public Updater update() {
return new Updater(this);
}
/**
* Creates a builder that can be used to bulk update repository settings.
*
* @return the repository updater
*/
public Setter set() {
return new Setter(this);
}
/**
* Sort orders for listing forks
*/
@@ -1642,7 +1777,7 @@ public class GHRepository extends GHObject {
* Retrive a tree of the given type for the current GitHub repository.
*
* @param sha
* sha number or branch name ex: "master"
* sha number or branch name ex: "main"
* @return refs matching the request type
* @throws IOException
* on failure communicating with GitHub, potentially due to an invalid tree type being requested
@@ -1666,7 +1801,7 @@ public class GHRepository extends GHObject {
* https://developer.github.com/v3/git/trees/#get-a-tree-recursively
*
* @param sha
* sha number or branch name ex: "master"
* sha number or branch name ex: "main"
* @param recursive
* use 1
* @return the tree recursive
@@ -1724,7 +1859,7 @@ public class GHRepository extends GHObject {
return root.createRequest()
.withHeader("Accept", "application/vnd.github.v3.raw")
.withUrlPath(target)
.fetchStream();
.fetchStream(Requester::copyInputStream);
}
/**
@@ -1878,14 +2013,14 @@ public class GHRepository extends GHObject {
* @see <a href="https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref">List check runs
* for a specific ref</a>
*/
@Preview
@Preview(ANTIOPE)
@Deprecated
public PagedIterable<GHCheckRun> getCheckRuns(String ref) throws IOException {
GitHubRequest request = root.createRequest()
.withUrlPath(String.format("/repos/%s/%s/commits/%s/check-runs", getOwnerName(), name, ref))
.withPreview(ANTIOPE)
.build();
return new GHCheckRunsIterable(root, request);
return new GHCheckRunsIterable(this, request);
}
/**
@@ -1952,7 +2087,7 @@ public class GHRepository extends GHObject {
* the commit hash
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
*/
@Preview
@Preview(ANTIOPE)
@Deprecated
public @NonNull GHCheckRunBuilder createCheckRun(@NonNull String name, @NonNull String headSHA) {
return new GHCheckRunBuilder(this, name, headSHA);
@@ -1965,7 +2100,7 @@ public class GHRepository extends GHObject {
* the existing checkId
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
*/
@Preview
@Preview(BAPTISTE)
@Deprecated
public @NonNull GHCheckRunBuilder updateCheckRun(long checkId) {
return new GHCheckRunBuilder(this, checkId);
@@ -2088,9 +2223,11 @@ public class GHRepository extends GHObject {
}
private PagedIterable<GHUser> listUsers(final String suffix) {
return root.createRequest()
.withUrlPath(getApiTailUrl(suffix))
.toIterable(GHUser[].class, item -> item.wrapUp(root));
return listUsers(root.createRequest(), suffix);
}
private PagedIterable<GHUser> listUsers(Requester requester, final String suffix) {
return requester.withUrlPath(getApiTailUrl(suffix)).toIterable(GHUser[].class, item -> item.wrapUp(root));
}
/**
@@ -2153,7 +2290,12 @@ public class GHRepository extends GHObject {
justification = "It causes a performance degradation, but we have already exposed it to the API")
@Deprecated
public Set<URL> getPostCommitHooks() {
return postCommitHooks;
synchronized (this) {
if (postCommitHooks == null) {
postCommitHooks = setupPostCommitHooks();
}
return postCommitHooks;
}
}
/**
@@ -2162,57 +2304,63 @@ public class GHRepository extends GHObject {
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS",
justification = "It causes a performance degradation, but we have already exposed it to the API")
@SkipFromToString
private final Set<URL> postCommitHooks = new AbstractSet<URL>() {
private List<URL> getPostCommitHooks() {
try {
List<URL> r = new ArrayList<>();
for (GHHook h : getHooks()) {
if (h.getName().equals("web")) {
r.add(new URL(h.getConfig().get("url")));
private /* final */ transient Set<URL> postCommitHooks;
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS",
justification = "It causes a performance degradation, but we have already exposed it to the API")
private Set<URL> setupPostCommitHooks() {
return new AbstractSet<URL>() {
private List<URL> getPostCommitHooks() {
try {
List<URL> r = new ArrayList<>();
for (GHHook h : getHooks()) {
if (h.getName().equals("web")) {
r.add(new URL(h.getConfig().get("url")));
}
}
return r;
} catch (IOException e) {
throw new GHException("Failed to retrieve post-commit hooks", e);
}
return r;
} catch (IOException e) {
throw new GHException("Failed to retrieve post-commit hooks", e);
}
}
@Override
public Iterator<URL> iterator() {
return getPostCommitHooks().iterator();
}
@Override
public int size() {
return getPostCommitHooks().size();
}
@Override
public boolean add(URL url) {
try {
createWebHook(url);
return true;
} catch (IOException e) {
throw new GHException("Failed to update post-commit hooks", e);
@Override
public Iterator<URL> iterator() {
return getPostCommitHooks().iterator();
}
}
@Override
public boolean remove(Object url) {
try {
String _url = ((URL) url).toExternalForm();
for (GHHook h : getHooks()) {
if (h.getName().equals("web") && h.getConfig().get("url").equals(_url)) {
h.delete();
return true;
@Override
public int size() {
return getPostCommitHooks().size();
}
@Override
public boolean add(URL url) {
try {
createWebHook(url);
return true;
} catch (IOException e) {
throw new GHException("Failed to update post-commit hooks", e);
}
}
@Override
public boolean remove(Object url) {
try {
String _url = ((URL) url).toExternalForm();
for (GHHook h : getHooks()) {
if (h.getName().equals("web") && h.getConfig().get("url").equals(_url)) {
h.delete();
return true;
}
}
return false;
} catch (IOException e) {
throw new GHException("Failed to update post-commit hooks", e);
}
return false;
} catch (IOException e) {
throw new GHException("Failed to update post-commit hooks", e);
}
}
};
};
}
GHRepository wrap(GitHub root) {
this.root = root;
@@ -2738,7 +2886,7 @@ public class GHRepository extends GHObject {
.with("mode", mode == null ? null : mode.toString())
.with("context", getFullName())
.withUrlPath("/markdown")
.fetchStream(),
.fetchStream(Requester::copyInputStream),
"UTF-8");
}
@@ -2826,6 +2974,110 @@ public class GHRepository extends GHObject {
.wrapUp(root);
}
/**
* Lists all the workflows of this repository.
*
* @return the paged iterable
*/
public PagedIterable<GHWorkflow> listWorkflows() {
return new GHWorkflowsIterable(this);
}
/**
* Gets a workflow by id.
*
* @param id
* the id of the workflow run
* @return the workflow run
* @throws IOException
* the io exception
*/
public GHWorkflow getWorkflow(long id) throws IOException {
return getWorkflow(String.valueOf(id));
}
/**
* Gets a workflow by name of the file.
*
* @param nameOrId
* either the name of the file (e.g. my-workflow.yml) or the id as a string
* @return the workflow run
* @throws IOException
* the io exception
*/
public GHWorkflow getWorkflow(String nameOrId) throws IOException {
return root.createRequest()
.withUrlPath(getApiTailUrl("actions/workflows"), nameOrId)
.fetch(GHWorkflow.class)
.wrapUp(this);
}
/**
* Retrieves workflow runs.
*
* @return the workflow run query builder
*/
public GHWorkflowRunQueryBuilder queryWorkflowRuns() {
return new GHWorkflowRunQueryBuilder(this);
}
/**
* Gets a workflow run.
*
* @param id
* the id of the workflow run
* @return the workflow run
* @throws IOException
* the io exception
*/
public GHWorkflowRun getWorkflowRun(long id) throws IOException {
return root.createRequest()
.withUrlPath(getApiTailUrl("actions/runs"), String.valueOf(id))
.fetch(GHWorkflowRun.class)
.wrapUp(this);
}
/**
* Lists all the artifacts of this repository.
*
* @return the paged iterable
*/
public PagedIterable<GHArtifact> listArtifacts() {
return new GHArtifactsIterable(this, root.createRequest().withUrlPath(getApiTailUrl("actions/artifacts")));
}
/**
* Gets an artifact by id.
*
* @param id
* the id of the artifact
* @return the artifact
* @throws IOException
* the io exception
*/
public GHArtifact getArtifact(long id) throws IOException {
return root.createRequest()
.withUrlPath(getApiTailUrl("actions/artifacts"), String.valueOf(id))
.fetch(GHArtifact.class)
.wrapUp(this);
}
/**
* Gets a job from a workflow run by id.
*
* @param id
* the id of the job
* @return the job
* @throws IOException
* the io exception
*/
public GHWorkflowJob getWorkflowJob(long id) throws IOException {
return root.createRequest()
.withUrlPath(getApiTailUrl("/actions/jobs/"), String.valueOf(id))
.fetch(GHWorkflowJob.class)
.wrapUp(this);
}
// Only used within listTopics().
private static class Topics {
public List<String> names;
@@ -2892,6 +3144,52 @@ public class GHRepository extends GHObject {
.wrap(this);
}
/**
* Streams a zip archive of the repository, optionally at a given <code>ref</code>.
*
* @param <T>
* the type of result
* @param streamFunction
* The {@link InputStreamFunction} that will process the stream
* @param ref
* if <code>null</code> the repository's default branch, usually <code>main</code>,
* @throws IOException
* The IO exception.
* @return the result of reading the stream.
*/
public <T> T readZip(InputStreamFunction<T> streamFunction, String ref) throws IOException {
return downloadArchive("zip", ref, streamFunction);
}
/**
* Streams a tar archive of the repository, optionally at a given <code>ref</code>.
*
* @param <T>
* the type of result
* @param streamFunction
* The {@link InputStreamFunction} that will process the stream
* @param ref
* if <code>null</code> the repository's default branch, usually <code>main</code>,
* @throws IOException
* The IO exception.
* @return the result of reading the stream.
*/
public <T> T readTar(InputStreamFunction<T> streamFunction, String ref) throws IOException {
return downloadArchive("tar", ref, streamFunction);
}
private <T> T downloadArchive(@Nonnull String type,
@CheckForNull String ref,
@Nonnull InputStreamFunction<T> streamFunction) throws IOException {
requireNonNull(streamFunction, "Sink must not be null");
String tailUrl = getApiTailUrl(type + "ball");
if (ref != null) {
tailUrl += "/" + ref;
}
final Requester builder = root.createRequest().method("GET").withUrlPath(tailUrl);
return builder.fetchStream(streamFunction);
}
/**
* Populate this object.
*
@@ -2903,20 +3201,66 @@ public class GHRepository extends GHObject {
return; // can't populate if the root is offline
}
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
final URL url = requireNonNull(getUrl(), "Missing instance URL!");
try {
// IMPORTANT: the url for repository records is does not reliably point to the API url.
// IMPORTANT: the url for repository records does not reliably point to the API url.
// There is bug in Push event payloads that returns the wrong url.
// All other occurrences of "url" take the form "https://api.github.com/...".
// For Push event repository records, they take the form "https://github.com/{fullName}".
root.createRequest().withPreview(BAPTISE).setRawUrlPath(url.toString()).fetchInto(this).wrap(root);
root.createRequest()
.withPreview(BAPTISTE)
.withPreview(NEBULA)
.setRawUrlPath(url.toString())
.fetchInto(this)
.wrap(root);
} catch (HttpException e) {
if (e.getCause() instanceof JsonParseException) {
root.createRequest().withPreview(BAPTISE).withUrlPath("/repos/" + full_name).fetchInto(this).wrap(root);
root.createRequest()
.withPreview(BAPTISTE)
.withPreview(NEBULA)
.withUrlPath("/repos/" + full_name)
.fetchInto(this)
.wrap(root);
} else {
throw e;
}
}
}
/**
* A {@link GHRepositoryBuilder} that allows multiple properties to be updated per request.
*
* Consumer must call {@link #done()} to commit changes.
*/
@BetaApi
@Deprecated
public static class Updater extends GHRepositoryBuilder<Updater> {
protected Updater(@Nonnull GHRepository repository) {
super(Updater.class, repository.root, null);
// even when we don't change the name, we need to send it in
// this requirement may be out-of-date, but we do not want to break it
requester.with("name", repository.name);
requester.method("PATCH").withUrlPath(repository.getApiTailUrl(""));
}
}
/**
* A {@link GHRepositoryBuilder} that allows multiple properties to be updated per request.
*
* Consumer must call {@link #done()} to commit changes.
*/
@BetaApi
@Deprecated
public static class Setter extends GHRepositoryBuilder<GHRepository> {
protected Setter(@Nonnull GHRepository repository) {
super(GHRepository.class, repository.root, null);
// even when we don't change the name, we need to send it in
// this requirement may be out-of-date, but we do not want to break it
requester.with("name", repository.name);
requester.method("PATCH").withUrlPath(repository.getApiTailUrl(""));
}
}
}

View File

@@ -0,0 +1,252 @@
package org.kohsuke.github;
import org.kohsuke.github.GHRepository.Visibility;
import java.io.IOException;
import java.net.URL;
import static org.kohsuke.github.internal.Previews.BAPTISTE;
import static org.kohsuke.github.internal.Previews.NEBULA;
abstract class GHRepositoryBuilder<S> extends AbstractBuilder<GHRepository, S> {
protected GHRepositoryBuilder(Class<S> intermediateReturnType, GitHub root, GHRepository baseInstance) {
super(GHRepository.class, intermediateReturnType, root, baseInstance);
}
/**
* Allow or disallow squash-merging pull requests.
*
* @param enabled
* true if enabled
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S allowSquashMerge(boolean enabled) throws IOException {
return with("allow_squash_merge", enabled);
}
/**
* Allow or disallow merging pull requests with a merge commit.
*
* @param enabled
* true if enabled
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S allowMergeCommit(boolean enabled) throws IOException {
return with("allow_merge_commit", enabled);
}
/**
* Allow or disallow rebase-merging pull requests.
*
* @param enabled
* true if enabled
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S allowRebaseMerge(boolean enabled) throws IOException {
return with("allow_rebase_merge", enabled);
}
/**
* After pull requests are merged, you can have head branches deleted automatically.
*
* @param enabled
* true if enabled
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S deleteBranchOnMerge(boolean enabled) throws IOException {
return with("delete_branch_on_merge", enabled);
}
/**
* Default repository branch
*
* @param branch
* branch name
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S defaultBranch(String branch) throws IOException {
return with("default_branch", branch);
}
/**
* Description for repository
*
* @param description
* description of repository
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S description(String description) throws IOException {
return with("description", description);
}
/**
* Homepage for repository
*
* @param homepage
* homepage of repository
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S homepage(URL homepage) throws IOException {
return homepage(homepage.toExternalForm());
}
/**
* Homepage for repository
*
* @param homepage
* homepage of repository
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S homepage(String homepage) throws IOException {
return with("homepage", homepage);
}
/**
* Sets the repository to private
*
* @param enabled
* private if true
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S private_(boolean enabled) throws IOException {
return with("private", enabled);
}
/**
* Sets the repository visibility
*
* @param visibility
* visibility of repository
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
*/
public S visibility(final Visibility visibility) throws IOException {
requester.withPreview(NEBULA);
return with("visibility", visibility);
}
/**
* Enables issue tracker
*
* @param enabled
* true if enabled
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S issues(boolean enabled) throws IOException {
return with("has_issues", enabled);
}
/**
* Enables projects
*
* @param enabled
* true if enabled
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S projects(boolean enabled) throws IOException {
return with("has_projects", enabled);
}
/**
* Enables wiki
*
* @param enabled
* true if enabled
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
*/
public S wiki(boolean enabled) throws IOException {
return with("has_wiki", enabled);
}
/**
* Enables downloads
*
* @param enabled
* true if enabled
*
* @return a builder to continue with building
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public S downloads(boolean enabled) throws IOException {
return with("has_downloads", enabled);
}
/**
* Specifies whether the repository is a template.
*
* @param enabled
* true if enabled
* @return a builder to continue with building
* @throws IOException
* In case of any networking error or error from the server.
*/
@Preview(BAPTISTE)
@Deprecated
public S isTemplate(boolean enabled) throws IOException {
requester.withPreview(BAPTISTE);
return with("is_template", enabled);
}
@Override
public GHRepository done() throws IOException {
return super.done().wrap(this.root);
}
S archive() throws IOException {
return with("archived", true);
}
S name(String name) throws IOException {
return with("name", name);
}
}

View File

@@ -16,10 +16,9 @@ import java.util.NoSuchElementException;
*
* @author Martin van Zijl
*/
public class GHRepositoryStatistics {
public class GHRepositoryStatistics extends GitHubInteractiveObject {
private final GHRepository repo;
private final GitHub root;
private static final int MAX_WAIT_ITERATIONS = 3;
private static final int WAIT_SLEEP_INTERVAL = 5000;
@@ -60,7 +59,7 @@ public class GHRepositoryStatistics {
* @throws InterruptedException
* the interrupted exception
*/
@Preview
@BetaApi
@Deprecated
@SuppressWarnings("SleepWhileInLoop")
@SuppressFBWarnings(value = { "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" }, justification = "JSON API")
@@ -99,7 +98,6 @@ public class GHRepositoryStatistics {
"URF_UNREAD_FIELD" },
justification = "JSON API")
public static class ContributorStats extends GHObject {
/* package almost final */ private GitHub root;
private GHUser author;
private int total;
private List<Week> weeks;
@@ -255,7 +253,6 @@ public class GHRepositoryStatistics {
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public static class CommitActivity extends GHObject {
/* package almost final */ private GitHub root;
private List<Integer> days;
private int total;
private long week;
@@ -398,7 +395,6 @@ public class GHRepositoryStatistics {
* The type Participation.
*/
public static class Participation extends GHObject {
/* package almost final */ private GitHub root;
private List<Integer> all;
private List<Integer> owner;

View File

@@ -8,7 +8,6 @@ import java.net.URL;
justification = "JSON API")
public class GHRequestedAction extends GHObject {
private GHRepository owner;
private GitHub root;
private String identifier;
private String label;
private String description;
@@ -46,4 +45,4 @@ public class GHRequestedAction extends GHObject {
return null;
}
}
}

View File

@@ -10,11 +10,10 @@ import java.util.Date;
* @see GHRepository#getSubscription() GHRepository#getSubscription()
* @see GHThread#getSubscription() GHThread#getSubscription()
*/
public class GHSubscription {
public class GHSubscription extends GitHubInteractiveObject {
private String created_at, url, repository_url, reason;
private boolean subscribed, ignored;
private GitHub root;
private GHRepository repo;
/**

View File

@@ -9,9 +9,8 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public class GHTag {
public class GHTag extends GitHubInteractiveObject {
private GHRepository owner;
private GitHub root;
private String name;
private GHCommit commit;

View File

@@ -9,9 +9,8 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public class GHTagObject {
public class GHTagObject extends GitHubInteractiveObject {
private GHRepository owner;
private GitHub root;
private String tag;
private String sha;

View File

@@ -24,8 +24,6 @@ public class GHTeam extends GHObject implements Refreshable {
private GHOrganization organization; // populated by GET /user/teams where Teams+Orgs are returned together
protected /* final */ GitHub root;
public enum Privacy {
SECRET, // only visible to organization owners and members of this team.
CLOSED // visible to all members of this organization.

View File

@@ -7,9 +7,7 @@ import java.io.IOException;
*
* https://developer.github.com/v3/teams/#create-team
*/
public class GHTeamBuilder {
private final GitHub root;
public class GHTeamBuilder extends GitHubInteractiveObject {
protected final Requester builder;
private final String orgName;

View File

@@ -17,7 +17,6 @@ import java.util.Date;
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public class GHThread extends GHObject {
private GitHub root;
private GHRepository repository;
private Subject subject;
private String reason;

View File

@@ -0,0 +1,158 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
/**
* A workflow.
*
* @author Guillaume Smet
* @see GHRepository#getWorkflow(long)
*/
public class GHWorkflow extends GHObject {
// Not provided by the API.
@JsonIgnore
private GHRepository owner;
private String name;
private String path;
private String state;
private String htmlUrl;
private String badgeUrl;
/**
* The name of the workflow.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* The path of the workflow e.g. .github/workflows/blank.yaml
*
* @return the path
*/
public String getPath() {
return path;
}
/**
* The state of the workflow.
*
* @return the state
*/
public String getState() {
return state;
}
@Override
public URL getHtmlUrl() throws IOException {
return GitHubClient.parseURL(htmlUrl);
}
/**
* Repository to which the workflow belongs.
*
* @return the repository
*/
public GHRepository getRepository() {
return owner;
}
/**
* The badge URL, like https://github.com/octo-org/octo-repo/workflows/CI/badge.svg
*
* @return the badge url
*/
public URL getBadgeUrl() {
return GitHubClient.parseURL(badgeUrl);
}
/**
* Disable the workflow.
*
* @throws IOException
* the io exception
*/
public void disable() throws IOException {
root.createRequest().method("PUT").withUrlPath(getApiRoute(), "disable").fetchHttpStatusCode();
}
/**
* Enable the workflow.
*
* @throws IOException
* the io exception
*/
public void enable() throws IOException {
root.createRequest().method("PUT").withUrlPath(getApiRoute(), "enable").fetchHttpStatusCode();
}
/**
* Create a workflow dispatch event which triggers a manual workflow run.
*
* @param ref
* the git reference for the workflow. The reference can be a branch or tag name.
* @throws IOException
* the io exception
*/
public void dispatch(String ref) throws IOException {
dispatch(ref, Collections.emptyMap());
}
/**
* Create a workflow dispatch event which triggers a manual workflow run.
*
* @param ref
* the git reference for the workflow. The reference can be a branch or tag name.
* @param inputs
* input keys and values configured in the workflow file. The maximum number of properties is 10. Any
* default properties configured in the workflow file will be used when inputs are omitted.
* @throws IOException
* the io exception
*/
public void dispatch(String ref, Map<String, Object> inputs) throws IOException {
Requester requester = root.createRequest()
.method("POST")
.withUrlPath(getApiRoute(), "dispatches")
.with("ref", ref);
if (!inputs.isEmpty()) {
requester.with("inputs", inputs);
}
requester.fetchHttpStatusCode();
}
private String getApiRoute() {
if (owner == null) {
// Workflow runs 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() + "/actions/workflows/" + getId();
}
GHWorkflow wrapUp(GHRepository owner) {
this.owner = owner;
return wrapUp(owner.root);
}
GHWorkflow wrapUp(GitHub root) {
this.root = root;
if (owner != null)
owner.wrap(root);
return this;
}
}

View File

@@ -0,0 +1,256 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.GHWorkflowRun.Conclusion;
import org.kohsuke.github.GHWorkflowRun.Status;
import org.kohsuke.github.function.InputStreamFunction;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import static java.util.Objects.requireNonNull;
/**
* A workflow run job.
*
* @author Guillaume Smet
*/
public class GHWorkflowJob extends GHObject {
// Not provided by the API.
@JsonIgnore
private GHRepository owner;
private String name;
private String headSha;
private String startedAt;
private String completedAt;
private String status;
private String conclusion;
private long runId;
private String htmlUrl;
private String checkRunUrl;
private List<Step> steps = new ArrayList<>();
/**
* The name of the job.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Gets the HEAD SHA.
*
* @return sha for the HEAD commit
*/
public String getHeadSha() {
return headSha;
}
/**
* When was this job started?
*
* @return start date
*/
public Date getStartedAt() {
return GitHubClient.parseDate(startedAt);
}
/**
* When was this job completed?
*
* @return completion date
*/
public Date getCompletedAt() {
return GitHubClient.parseDate(completedAt);
}
/**
* Gets status of the job.
* <p>
* Can be {@code UNKNOWN} if the value returned by GitHub is unknown from the API.
*
* @return status of the job
*/
public Status getStatus() {
return Status.from(status);
}
/**
* Gets the conclusion of the job.
* <p>
* Can be {@code UNKNOWN} if the value returned by GitHub is unknown from the API.
*
* @return conclusion of the job
*/
public Conclusion getConclusion() {
return Conclusion.from(conclusion);
}
/**
* The run id.
*
* @return the run id
*/
public long getRunId() {
return runId;
}
@Override
public URL getHtmlUrl() {
return GitHubClient.parseURL(htmlUrl);
}
/**
* The check run URL.
*
* @return the check run url
*/
public URL getCheckRunUrl() {
return GitHubClient.parseURL(checkRunUrl);
}
/**
* Gets the execution steps of this job.
*
* @return the execution steps
*/
public List<Step> getSteps() {
return steps;
}
/**
* Repository to which the job belongs.
*
* @return the repository
*/
public GHRepository getRepository() {
return owner;
}
/**
* Downloads the logs.
* <p>
* The logs are returned as a text file.
*
* @param <T>
* the type of result
* @param streamFunction
* The {@link InputStreamFunction} that will process the stream
* @throws IOException
* The IO exception.
* @return the result of reading the stream.
*/
public <T> T downloadLogs(InputStreamFunction<T> streamFunction) throws IOException {
requireNonNull(streamFunction, "Stream function must not be null");
return root.createRequest().method("GET").withUrlPath(getApiRoute(), "logs").fetchStream(streamFunction);
}
private String getApiRoute() {
if (owner == null) {
// Workflow runs 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() + "/actions/jobs/" + getId();
}
GHWorkflowJob wrapUp(GHRepository owner) {
this.owner = owner;
return wrapUp(owner.root);
}
GHWorkflowJob wrapUp(GitHub root) {
this.root = root;
if (owner != null) {
owner.wrap(root);
}
return this;
}
public static class Step {
private String name;
private int number;
private String startedAt;
private String completedAt;
private String status;
private String conclusion;
/**
* Gets the name of the step.
*
* @return name
*/
public String getName() {
return name;
}
/**
* Gets the sequential number of the step.
*
* @return number
*/
public int getNumber() {
return number;
}
/**
* When was this step started?
*
* @return start date
*/
public Date getStartedAt() {
return GitHubClient.parseDate(startedAt);
}
/**
* When was this step completed?
*
* @return completion date
*/
public Date getCompletedAt() {
return GitHubClient.parseDate(completedAt);
}
/**
* Gets status of the step.
* <p>
* Can be {@code UNKNOWN} if the value returned by GitHub is unknown from the API.
*
* @return status of the step
*/
public Status getStatus() {
return Status.from(status);
}
/**
* Gets the conclusion of the step.
* <p>
* Can be {@code UNKNOWN} if the value returned by GitHub is unknown from the API.
*
* @return conclusion of the step
*/
public Conclusion getConclusion() {
return Conclusion.from(conclusion);
}
}
}

View File

@@ -0,0 +1,47 @@
package org.kohsuke.github;
import java.net.MalformedURLException;
/**
* Lists up jobs of a workflow run with some filtering.
*
* @author Guillaume Smet
*/
public class GHWorkflowJobQueryBuilder extends GHQueryBuilder<GHWorkflowJob> {
private final GHRepository repo;
GHWorkflowJobQueryBuilder(GHWorkflowRun workflowRun) {
super(workflowRun.getRepository().root);
this.repo = workflowRun.getRepository();
req.withUrlPath(repo.getApiTailUrl("actions/runs"), String.valueOf(workflowRun.getId()), "jobs");
}
/**
* Apply a filter to only return the jobs of the most recent execution of the workflow run.
*
* @return the workflow run job query builder
*/
public GHWorkflowJobQueryBuilder latest() {
req.with("filter", "latest");
return this;
}
/**
* Apply a filter to return jobs from all executions of this workflow run.
*
* @return the workflow run job run query builder
*/
public GHWorkflowJobQueryBuilder all() {
req.with("filter", "all");
return this;
}
@Override
public PagedIterable<GHWorkflowJob> list() {
try {
return new GHWorkflowJobsIterable(repo, req.build());
} catch (MalformedURLException e) {
throw new GHException(e.getMessage(), e);
}
}
}

View File

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

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