mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-11 08:21:23 +00:00
Compare commits
648 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb381dfa06 | ||
|
|
80124e3b85 | ||
|
|
7aae27e36f | ||
|
|
b212956fbb | ||
|
|
d033355e84 | ||
|
|
59d7a117d0 | ||
|
|
dfbb38c5f1 | ||
|
|
3f9954144a | ||
|
|
1b84efdbfa | ||
|
|
c33e78a7dc | ||
|
|
747c759bbb | ||
|
|
e0a709676e | ||
|
|
a96275c286 | ||
|
|
ca7c809feb | ||
|
|
a8a0bcb7db | ||
|
|
0e2bf23830 | ||
|
|
44a8b797fb | ||
|
|
cdede298a9 | ||
|
|
f6ac4d3559 | ||
|
|
7e1531dbca | ||
|
|
9aeb422157 | ||
|
|
fba0f8cf8e | ||
|
|
0f4a5227e1 | ||
|
|
d16a752b43 | ||
|
|
4bec27fd49 | ||
|
|
be3bd74bb7 | ||
|
|
0b14cee817 | ||
|
|
252ca04084 | ||
|
|
6670446037 | ||
|
|
bd39b07bb5 | ||
|
|
a9438b6121 | ||
|
|
f546cf4521 | ||
|
|
43efa78750 | ||
|
|
9e3de43802 | ||
|
|
dc615e432e | ||
|
|
cf9caa6af5 | ||
|
|
15f748358d | ||
|
|
b30d648623 | ||
|
|
33d70560b8 | ||
|
|
865a49d2e8 | ||
|
|
4fca68c25c | ||
|
|
f131a0c1c2 | ||
|
|
cd4368fa79 | ||
|
|
4ec4b160b0 | ||
|
|
a585b4957f | ||
|
|
e6b02b3bed | ||
|
|
1ef0ec0432 | ||
|
|
2e87bd86a1 | ||
|
|
0228a0d023 | ||
|
|
6365f3749d | ||
|
|
25c18130f9 | ||
|
|
436c19634d | ||
|
|
1a6facc685 | ||
|
|
bd0093c8ea | ||
|
|
e150280010 | ||
|
|
827fd5e472 | ||
|
|
f89fbc67b9 | ||
|
|
c567a88892 | ||
|
|
6a39d7fca5 | ||
|
|
a15e67f065 | ||
|
|
7a1bce9578 | ||
|
|
f2b4de7943 | ||
|
|
b3ff4ac6d9 | ||
|
|
1c56e7fab5 | ||
|
|
70ba4df385 | ||
|
|
8062c705e8 | ||
|
|
fafb23c1a6 | ||
|
|
4e7ac7030c | ||
|
|
4803daca5a | ||
|
|
facfc61316 | ||
|
|
e3e495bfb1 | ||
|
|
e007284d2f | ||
|
|
1da8416ebd | ||
|
|
79b49a469c | ||
|
|
5888efcaef | ||
|
|
459d1b4f56 | ||
|
|
9151102bda | ||
|
|
3819984add | ||
|
|
3b58fbc186 | ||
|
|
55e589b3d9 | ||
|
|
e64d64d8d8 | ||
|
|
37c2d9135b | ||
|
|
30c96221bd | ||
|
|
bf7305e3f8 | ||
|
|
3b12a229c3 | ||
|
|
5726ceb8dc | ||
|
|
c06c06624d | ||
|
|
ad40d7071e | ||
|
|
f55a39eb90 | ||
|
|
c3869bee31 | ||
|
|
6eac15df0f | ||
|
|
6f5d3c32c3 | ||
|
|
68ef40e4d0 | ||
|
|
4046bc4f72 | ||
|
|
1b8d131915 | ||
|
|
f5ad332d28 | ||
|
|
938603ff60 | ||
|
|
17af78f2bb | ||
|
|
7588267743 | ||
|
|
ed4f9c8176 | ||
|
|
bbb46e88b0 | ||
|
|
3db7aac0d8 | ||
|
|
fdbbd2e563 | ||
|
|
e92f1321d4 | ||
|
|
da2aaff9e5 | ||
|
|
208904b634 | ||
|
|
a433bcda2e | ||
|
|
4bba692170 | ||
|
|
59b61cd8be | ||
|
|
247b013e16 | ||
|
|
77baafa643 | ||
|
|
3c56f1f076 | ||
|
|
224d8c7cb4 | ||
|
|
0feb520549 | ||
|
|
ca365b12f6 | ||
|
|
bde6ad9a06 | ||
|
|
4953f4500d | ||
|
|
7fee1fcc74 | ||
|
|
4415ac8fd2 | ||
|
|
8c81e48a31 | ||
|
|
9ad0329c56 | ||
|
|
78f533bbfc | ||
|
|
79c7dd9ecf | ||
|
|
5d796d1f79 | ||
|
|
68a82be6c4 | ||
|
|
2676ef2b73 | ||
|
|
04b283c539 | ||
|
|
98b067937a | ||
|
|
8ababb60bf | ||
|
|
b51d655f77 | ||
|
|
74496d32da | ||
|
|
316e278be1 | ||
|
|
d881bf6504 | ||
|
|
c74fbbe1fd | ||
|
|
929d9fb7bd | ||
|
|
5d069d0531 | ||
|
|
dd9e6dc5d3 | ||
|
|
d22c77c41d | ||
|
|
3a11b7ccbf | ||
|
|
9d161b28bb | ||
|
|
9b16a1caa0 | ||
|
|
9a918e3bac | ||
|
|
d4c5c6a1e0 | ||
|
|
63fda3555c | ||
|
|
6a2381c06b | ||
|
|
e9c0a16c26 | ||
|
|
2101a67ac1 | ||
|
|
ddac568aaa | ||
|
|
262ae9f635 | ||
|
|
381502fb80 | ||
|
|
92fb441eb2 | ||
|
|
29e08037a8 | ||
|
|
84cc6d9315 | ||
|
|
b8d5a1c732 | ||
|
|
0197ab9661 | ||
|
|
b7915e61a6 | ||
|
|
586db99450 | ||
|
|
5377d0dd18 | ||
|
|
c5d3a7d573 | ||
|
|
8267050f06 | ||
|
|
610b02968e | ||
|
|
a7112c42df | ||
|
|
8a474a3b00 | ||
|
|
59e18d155e | ||
|
|
12ca5d8063 | ||
|
|
c959e0a928 | ||
|
|
89a08b021d | ||
|
|
04b553cdec | ||
|
|
15e9ee30ee | ||
|
|
a0d650a86c | ||
|
|
1a6ad48e08 | ||
|
|
7c82eeb018 | ||
|
|
b188e74ee0 | ||
|
|
c21bd5765a | ||
|
|
b78c37a695 | ||
|
|
2f151d45c3 | ||
|
|
3ebe3afdbd | ||
|
|
f4845df6c0 | ||
|
|
272b87f04d | ||
|
|
ff790eeefb | ||
|
|
97e918da03 | ||
|
|
4f30998873 | ||
|
|
a0fc478a28 | ||
|
|
bb03fd1968 | ||
|
|
0c65f74662 | ||
|
|
29ac2bd4f5 | ||
|
|
0d8b4f32e8 | ||
|
|
83db7f24eb | ||
|
|
5f9976a193 | ||
|
|
9480ef485b | ||
|
|
a9b7432584 | ||
|
|
6d7081910f | ||
|
|
aa96089ab4 | ||
|
|
58ae681417 | ||
|
|
c038e0af5e | ||
|
|
4f9976c0cb | ||
|
|
e308e5ed57 | ||
|
|
7b1b1ca994 | ||
|
|
551be49a1a | ||
|
|
a3888e6902 | ||
|
|
43bb6a0dd8 | ||
|
|
6e3f754366 | ||
|
|
6360112432 | ||
|
|
f1ca0b5417 | ||
|
|
0894c8007c | ||
|
|
05863acbcd | ||
|
|
0e4cd06137 | ||
|
|
85d2d974e7 | ||
|
|
3f021f9552 | ||
|
|
0456f10709 | ||
|
|
b7d03f7463 | ||
|
|
07a392c2a7 | ||
|
|
5b69de770f | ||
|
|
4688870984 | ||
|
|
bf67069768 | ||
|
|
91764c1c74 | ||
|
|
8b2a3e1221 | ||
|
|
def2f0b37d | ||
|
|
5d7479a3dd | ||
|
|
ceb2d35f9f | ||
|
|
fc38dba59a | ||
|
|
75b383d398 | ||
|
|
ee2d9491fb | ||
|
|
bf86a7c75a | ||
|
|
70f6d129e2 | ||
|
|
a4ac2aa99a | ||
|
|
ae3b6fbe6b | ||
|
|
e357fca963 | ||
|
|
c84cc89805 | ||
|
|
181238cd50 | ||
|
|
214c24c736 | ||
|
|
cf51ce8f26 | ||
|
|
2b7ed40d01 | ||
|
|
349ef7a54c | ||
|
|
94df5fc389 | ||
|
|
906238a297 | ||
|
|
7963fa82b5 | ||
|
|
1aba6012fb | ||
|
|
ff4324ac67 | ||
|
|
11bc669e1d | ||
|
|
dcf26d58e4 | ||
|
|
4d46872c35 | ||
|
|
4f0d62f421 | ||
|
|
f7ad1f517b | ||
|
|
345d6197f3 | ||
|
|
bb4d44138a | ||
|
|
a8ef0cde53 | ||
|
|
77dc009c95 | ||
|
|
aa298c93cc | ||
|
|
dfb0a5240e | ||
|
|
9cfc3c22b5 | ||
|
|
b177d98e29 | ||
|
|
5405fb0370 | ||
|
|
72a1c24b3b | ||
|
|
f146ae94ec | ||
|
|
a0bbba748a | ||
|
|
81bf818573 | ||
|
|
d5913dc292 | ||
|
|
e1e901b794 | ||
|
|
2f2f26767e | ||
|
|
bffa78c1b8 | ||
|
|
c55719c67a | ||
|
|
cb3b4a6642 | ||
|
|
92c141cee6 | ||
|
|
fd1a1a1c23 | ||
|
|
b835884b2e | ||
|
|
660763908d | ||
|
|
fe8bdb755a | ||
|
|
67dc6d2d23 | ||
|
|
9c8d73cbe2 | ||
|
|
5db97d92dd | ||
|
|
ac470dddb5 | ||
|
|
43063fe8ce | ||
|
|
59e0046c1e | ||
|
|
36ab05c265 | ||
|
|
2b2be05dae | ||
|
|
fb1adbd1ef | ||
|
|
ab68a59b25 | ||
|
|
9c7de767e9 | ||
|
|
8ba5cf7c2e | ||
|
|
b194a19b98 | ||
|
|
1d344b016f | ||
|
|
474f3ef4ca | ||
|
|
9830927020 | ||
|
|
727932a442 | ||
|
|
cd92b51845 | ||
|
|
fe26d16411 | ||
|
|
d68c66ce2b | ||
|
|
e7bfbfb48f | ||
|
|
f2a88ae61c | ||
|
|
e2113f6ee5 | ||
|
|
3867224024 | ||
|
|
9ee0bf43bc | ||
|
|
2844542efa | ||
|
|
e3fcae9392 | ||
|
|
c6ccfa91f3 | ||
|
|
b6fcee1cb9 | ||
|
|
9071befb04 | ||
|
|
bdd5fe98f3 | ||
|
|
a3d3e83a49 | ||
|
|
08bde72028 | ||
|
|
108a136368 | ||
|
|
57d87ad6b1 | ||
|
|
0c22815ff7 | ||
|
|
0ca792ecfd | ||
|
|
987c34c69e | ||
|
|
c1c02bc8ab | ||
|
|
4ee369f27c | ||
|
|
c9012efdcb | ||
|
|
41524fc67d | ||
|
|
04ff61e981 | ||
|
|
532468dc67 | ||
|
|
9c9a2dae47 | ||
|
|
c8a868b57f | ||
|
|
4b3f81ee34 | ||
|
|
afa170ba7c | ||
|
|
46e3b2272e | ||
|
|
52472e90ec | ||
|
|
4ef0d00846 | ||
|
|
580f2537f2 | ||
|
|
3d9fd96026 | ||
|
|
f449b92721 | ||
|
|
3b0216b023 | ||
|
|
98cf839737 | ||
|
|
0bb0846505 | ||
|
|
70969400a3 | ||
|
|
147e8d5d12 | ||
|
|
cacc3e6edd | ||
|
|
a284eca147 | ||
|
|
0d3ba9d7f0 | ||
|
|
be8064d642 | ||
|
|
e30dba742d | ||
|
|
44b72ed647 | ||
|
|
666bd77dac | ||
|
|
0a6613e60d | ||
|
|
62e186c123 | ||
|
|
50dd8f5bcc | ||
|
|
d5fcac9c45 | ||
|
|
c2bed85190 | ||
|
|
183b463ef2 | ||
|
|
92fdac44a0 | ||
|
|
12829ecc73 | ||
|
|
51319c3b26 | ||
|
|
8fd827040b | ||
|
|
5ec46eae0d | ||
|
|
32c03301be | ||
|
|
df7f29b2ab | ||
|
|
e863113c36 | ||
|
|
8e2c1d7382 | ||
|
|
ab7b9cccba | ||
|
|
81bf61a161 | ||
|
|
b40f008647 | ||
|
|
734e41702b | ||
|
|
038dd20a91 | ||
|
|
1dd62b8550 | ||
|
|
715deebe05 | ||
|
|
b3fe3d8590 | ||
|
|
f74c3ed3ea | ||
|
|
2c9aebeeed | ||
|
|
7474f1e11f | ||
|
|
dba9c55b64 | ||
|
|
b432364397 | ||
|
|
696967bdd1 | ||
|
|
b76889efc3 | ||
|
|
e6a7b64ebe | ||
|
|
9daa0df311 | ||
|
|
612800bda5 | ||
|
|
a6bbb1dec9 | ||
|
|
873c93ab64 | ||
|
|
d15242e2d2 | ||
|
|
992d2b937c | ||
|
|
1e05ddad4b | ||
|
|
4f8a64610b | ||
|
|
b82366218c | ||
|
|
acbe1f4cb3 | ||
|
|
4c5e018583 | ||
|
|
6c0380e85c | ||
|
|
fde48e604f | ||
|
|
e83a4de5fb | ||
|
|
927d2799dc | ||
|
|
1ad701fe5d | ||
|
|
086425d2da | ||
|
|
beca54416a | ||
|
|
c92f5c5713 | ||
|
|
dee4e6caff | ||
|
|
dd5a39e72e | ||
|
|
e5ed52165c | ||
|
|
9484f8e0f5 | ||
|
|
947caffe0a | ||
|
|
870090e8df | ||
|
|
73f07f13c5 | ||
|
|
d1952bf591 | ||
|
|
5a612e1332 | ||
|
|
b00a9faea6 | ||
|
|
74db42a703 | ||
|
|
ddf625ca04 | ||
|
|
eca2f017d8 | ||
|
|
3190bde343 | ||
|
|
c6ebf42a47 | ||
|
|
c116b60d12 | ||
|
|
5d09e6d9ab | ||
|
|
2613ce0ac9 | ||
|
|
a88e9b28ea | ||
|
|
f0a3c26ee6 | ||
|
|
84c87ecb32 | ||
|
|
6573f44d41 | ||
|
|
3cacbc552c | ||
|
|
343d623e02 | ||
|
|
6b80bb2b11 | ||
|
|
56fe7452eb | ||
|
|
d3a66f6605 | ||
|
|
dd7b4712f1 | ||
|
|
9df5871f6b | ||
|
|
29aab9e9f4 | ||
|
|
af67eb7f0b | ||
|
|
10482c0141 | ||
|
|
a7a792251a | ||
|
|
aec2308144 | ||
|
|
0741b8aa6a | ||
|
|
3082622394 | ||
|
|
965c9cb0af | ||
|
|
495a46e2d8 | ||
|
|
05bda1192e | ||
|
|
6058af0ca1 | ||
|
|
1eb8bf9719 | ||
|
|
afc02faeda | ||
|
|
66f22de90f | ||
|
|
2949a2e0ff | ||
|
|
ba12efea9d | ||
|
|
e1180a12fb | ||
|
|
1393706f13 | ||
|
|
6f994f31f7 | ||
|
|
38aa99a063 | ||
|
|
85c44b3529 | ||
|
|
e1a2768de5 | ||
|
|
e1c9b27203 | ||
|
|
969f6ef826 | ||
|
|
7abc4d4e76 | ||
|
|
ac97147c1f | ||
|
|
dbd20fe396 | ||
|
|
44e57c9c4b | ||
|
|
488e5e531f | ||
|
|
42a6a8d770 | ||
|
|
f8e877ea05 | ||
|
|
65d6fc7272 | ||
|
|
63ce8e461b | ||
|
|
fbf4c48461 | ||
|
|
81a55db644 | ||
|
|
4d4edfa181 | ||
|
|
6f9182f1f6 | ||
|
|
fa600c03e2 | ||
|
|
4a53301e9f | ||
|
|
676984b3d5 | ||
|
|
e6d7f7248b | ||
|
|
50903b5c4a | ||
|
|
01e399fb91 | ||
|
|
911aeb7af0 | ||
|
|
7e5cd9abbc | ||
|
|
115527a21a | ||
|
|
eff4f4f601 | ||
|
|
16e0099a0d | ||
|
|
2c8c678275 | ||
|
|
3b51e87fbf | ||
|
|
6c6eef5e2b | ||
|
|
6e5910f44c | ||
|
|
a967189bc6 | ||
|
|
7069176cf6 | ||
|
|
44dcbe773d | ||
|
|
ca76975461 | ||
|
|
83122ac99e | ||
|
|
c3e9458555 | ||
|
|
057ba38873 | ||
|
|
81d7d6236b | ||
|
|
191dd49653 | ||
|
|
21e9dd6f51 | ||
|
|
cc2d14acc6 | ||
|
|
87f37e9f1c | ||
|
|
d536a9f874 | ||
|
|
b45f353fa9 | ||
|
|
a3073ec14e | ||
|
|
f77eb33029 | ||
|
|
c1c919097a | ||
|
|
e05348463c | ||
|
|
fdcf74eaf2 | ||
|
|
6d57a3e3b9 | ||
|
|
1f449c866e | ||
|
|
e12deccd24 | ||
|
|
3184ebb5ee | ||
|
|
4a35ed2b35 | ||
|
|
5c9474d1c8 | ||
|
|
2321dc50c5 | ||
|
|
4efd2e8184 | ||
|
|
e30e153bfa | ||
|
|
2724211535 | ||
|
|
81068de0f1 | ||
|
|
7d842175f7 | ||
|
|
e0aee9f361 | ||
|
|
df576e2738 | ||
|
|
bb1356b25d | ||
|
|
1b67960da4 | ||
|
|
d76718e8b2 | ||
|
|
76c51922f1 | ||
|
|
f95e89a136 | ||
|
|
2dff60a23c | ||
|
|
95f83d1a29 | ||
|
|
b875ccecc1 | ||
|
|
e4c3802f16 | ||
|
|
081e485f4f | ||
|
|
4adf88da19 | ||
|
|
31e2b1b8d3 | ||
|
|
bd28abd343 | ||
|
|
955690b124 | ||
|
|
fa6f06ae15 | ||
|
|
263de140c5 | ||
|
|
ed85d06d69 | ||
|
|
4ff0870df8 | ||
|
|
410bac2040 | ||
|
|
38b1e367b1 | ||
|
|
3cddffa37f | ||
|
|
ea7a1a7175 | ||
|
|
36b5601588 | ||
|
|
7fc68f2969 | ||
|
|
c5ee07add4 | ||
|
|
32ff315b6b | ||
|
|
f919346f8f | ||
|
|
279df00404 | ||
|
|
bfd4b17fa0 | ||
|
|
5fe2817164 | ||
|
|
b337bb39bc | ||
|
|
65ae41c5f1 | ||
|
|
796c644c4a | ||
|
|
bfd9023a27 | ||
|
|
c9cdf5d03e | ||
|
|
f60bb41ad9 | ||
|
|
c333903b4a | ||
|
|
dd55e8a22c | ||
|
|
3ab9381d0a | ||
|
|
58f1fe0671 | ||
|
|
82b9c05d0f | ||
|
|
7c9397f7f6 | ||
|
|
6214b6a3ff | ||
|
|
883c8cc4c8 | ||
|
|
8d47c72913 | ||
|
|
89a6664e45 | ||
|
|
30d792d6e1 | ||
|
|
3745bf3157 | ||
|
|
a7fda3e50d | ||
|
|
7f07204fef | ||
|
|
8b51a44b7c | ||
|
|
c499c73dcc | ||
|
|
c01f3f5e8a | ||
|
|
2aef35655f | ||
|
|
7ddf1f5830 | ||
|
|
b2c513ea42 | ||
|
|
4c30f94355 | ||
|
|
e911e86c4c | ||
|
|
ca640b3f64 | ||
|
|
b4c4a05f3b | ||
|
|
fd3c36a259 | ||
|
|
d8274ac2d4 | ||
|
|
9c7479f953 | ||
|
|
b5dc3c4366 | ||
|
|
26b8082155 | ||
|
|
418df15f7b | ||
|
|
31ed0125b8 | ||
|
|
494318b879 | ||
|
|
f554ddc372 | ||
|
|
03de12c221 | ||
|
|
6c41f22b57 | ||
|
|
7ae96388e3 | ||
|
|
e8b4de00d2 | ||
|
|
cd7963b30d | ||
|
|
0dc44cffcf | ||
|
|
7a650132c5 | ||
|
|
c7fb390c38 | ||
|
|
572ff9df19 | ||
|
|
b715e0cef7 | ||
|
|
36ab2a889f | ||
|
|
a78d2f28d7 | ||
|
|
7d5a39ed89 | ||
|
|
772272ff36 | ||
|
|
2ab4eafee9 | ||
|
|
b15e0d4c45 | ||
|
|
b8180314d8 | ||
|
|
fcb8d03a0f | ||
|
|
09ec89bc2e | ||
|
|
863ad0f486 | ||
|
|
79a1bb3571 | ||
|
|
9f1d7323c7 | ||
|
|
64a82f4785 | ||
|
|
f37e4bd76e | ||
|
|
98ef2cc640 | ||
|
|
134222fd69 | ||
|
|
0cb2371517 | ||
|
|
b7de4359fd | ||
|
|
2607d6a107 | ||
|
|
db46b1ce13 | ||
|
|
d7b08d5207 | ||
|
|
29fbba832c | ||
|
|
fd621a442a | ||
|
|
a1a73568ae | ||
|
|
3daccbd6ec | ||
|
|
293deadb48 | ||
|
|
452b56c47b | ||
|
|
5cb6bfa633 | ||
|
|
0515cee6f3 | ||
|
|
4247112539 | ||
|
|
8d3374f574 | ||
|
|
26833e5f7c | ||
|
|
6752b46f67 | ||
|
|
b9429ffcaa | ||
|
|
10827c7e21 | ||
|
|
23cb4a34a4 | ||
|
|
adfd09565f | ||
|
|
78b9ff49d4 | ||
|
|
fca425d25e | ||
|
|
1a4238156c | ||
|
|
f6210cc014 | ||
|
|
6c8b466e59 | ||
|
|
2aebe97f9f | ||
|
|
157724bff8 | ||
|
|
6cbb1a0bee | ||
|
|
960a13dd38 | ||
|
|
9213f80435 | ||
|
|
bccae94c7a | ||
|
|
d71f77ce06 | ||
|
|
2787f3dc71 | ||
|
|
fb00baab5b | ||
|
|
9e22155d31 | ||
|
|
963373435d | ||
|
|
377987fa92 | ||
|
|
0b6980639e | ||
|
|
4f1cc9f94f | ||
|
|
6e5434a0ec | ||
|
|
3244f7c38f | ||
|
|
f27b676e89 | ||
|
|
4f2a80a4a3 | ||
|
|
a51bc27829 | ||
|
|
4fd321c93d | ||
|
|
bbd62bdef5 | ||
|
|
4bb1d78939 | ||
|
|
53c37ef413 | ||
|
|
a6511b6c5a | ||
|
|
829e96a2d0 | ||
|
|
2e25f37433 | ||
|
|
fbf6c73226 | ||
|
|
aab54e3f23 | ||
|
|
a6eff7fbfb |
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -7,4 +7,10 @@ We love getting PRs, but we hate asking people for the same basic changes every
|
||||
- [ ] Push your changes to a branch other than `master`. Create your PR from that branch.
|
||||
- [ ] Add JavaDocs and other comments
|
||||
- [ ] Write tests that run and pass in CI. See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to capture snapshot data.
|
||||
- [ ] Run `mvn -D enable-ci clean install site` locally. This may reformat your code, commit those changes. If this command doesn't succeed, your change will not pass CI.
|
||||
- [ ] Run `mvn clean compile` locally. This may reformat your code, commit those changes.
|
||||
- [ ] Run `mvn -D enable-ci clean install site` locally. If this command doesn't succeed, your change will not pass CI.
|
||||
|
||||
# When creating a PR:
|
||||
|
||||
- [ ] Fill in the "Description" above.
|
||||
- [ ] Enable "Allow edits from maintainers".
|
||||
|
||||
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "maven"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
time: "02:00"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
time: "02:00"
|
||||
5
.github/release-drafter.yml
vendored
5
.github/release-drafter.yml
vendored
@@ -1,5 +1,6 @@
|
||||
name-template: 'v$NEXT_PATCH_VERSION 🌈'
|
||||
tag-template: 'v$NEXT_PATCH_VERSION'
|
||||
name-template: 'v$NEXT_MINOR_VERSION 🌈'
|
||||
tag-template: 'github-api-$NEXT_MINOR_VERSION'
|
||||
version-template: '$MAJOR.$MINOR'
|
||||
categories:
|
||||
- title: '🚀 Features'
|
||||
labels:
|
||||
|
||||
12
.github/workflows/maven-build.yml
vendored
12
.github/workflows/maven-build.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: [ 11 ]
|
||||
java: [ 13 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
- name: Cached .m2
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
@@ -30,14 +30,14 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: [ 11 ]
|
||||
java: [ 8, 11 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
- uses: actions/cache@v1
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
@@ -51,14 +51,14 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ubuntu, windows ]
|
||||
java: [ 8, 11, 13 ]
|
||||
java: [ 8, 11, 13, 15-ea ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
- uses: actions/cache@v1
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
|
||||
1326
CHANGELOG.md
1326
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,10 @@ Example:
|
||||
|
||||
This the default behavior.
|
||||
|
||||
Example for a single test case:
|
||||
|
||||
`mvn install -Dtest=WireMockStatusReporterTest#user_whenProxying_AuthCorrectlyConfigured`
|
||||
|
||||
|
||||
### Setting up credential
|
||||
|
||||
@@ -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 `getGitHubBeforeAfter()` 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.
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# Java API for GitHub
|
||||
|
||||
[](https://mvnrepository.com/artifact/org.kohsuke/github-api)
|
||||
[](https://gitter.im/github-api/github-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://gitter.im/hub4j/github-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||

|
||||
|
||||
|
||||
|
||||
See https://github-api.kohsuke.org/ for more details
|
||||
|
||||
171
pom.xml
171
pom.xml
@@ -2,16 +2,16 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.kohsuke</groupId>
|
||||
<artifactId>github-api</artifactId>
|
||||
<version>1.108</version>
|
||||
<version>1.122</version>
|
||||
<name>GitHub API for Java</name>
|
||||
<url>https://github-api.kohsuke.org/</url>
|
||||
<description>GitHub API for Java</description>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com/github-api/${project.artifactId}.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/github-api/${project.artifactId}.git</developerConnection>
|
||||
<url>https://github.com/github-api/github-api/</url>
|
||||
<tag>github-api-1.108</tag>
|
||||
<connection>scm:git:git@github.com/hub4j/${project.artifactId}.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/hub4j/${project.artifactId}.git</developerConnection>
|
||||
<url>https://github.com/hub4j/github-api/</url>
|
||||
<tag>github-api-1.122</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
@@ -27,25 +27,25 @@
|
||||
</repository>
|
||||
<site>
|
||||
<id>github-pages</id>
|
||||
<url>gitsite:git@github.com/github-api/${project.artifactId}.git</url>
|
||||
<url>gitsite:git@github.com/hub4j/${project.artifactId}.git</url>
|
||||
</site>
|
||||
</distributionManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spotbugs-maven-plugin.version>3.1.12.2</spotbugs-maven-plugin.version>
|
||||
<spotbugs.version>4.0.0</spotbugs.version>
|
||||
<spotbugs-maven-plugin.version>4.1.4</spotbugs-maven-plugin.version>
|
||||
<spotbugs.version>4.1.3</spotbugs.version>
|
||||
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
|
||||
<hamcrest.version>2.2</hamcrest.version>
|
||||
<okhttp3.version>4.4.0</okhttp3.version>
|
||||
<okio.version>2.4.3</okio.version>
|
||||
<formatter-maven-plugin.goal>format</formatter-maven-plugin.goal>
|
||||
<impsort-maven-plugin.goal>sort</impsort-maven-plugin.goal>
|
||||
<okhttp3.version>4.4.1</okhttp3.version>
|
||||
<okio.version>2.5.0</okio.version>
|
||||
<spotless-maven-plugin.goal>apply</spotless-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>
|
||||
<!-- 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>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@@ -79,6 +79,14 @@
|
||||
</testResources>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<configuration>
|
||||
<!-- SUREFIRE-1226 workaround -->
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
@@ -92,7 +100,7 @@
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.5</version>
|
||||
<version>0.8.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -146,7 +154,7 @@
|
||||
<exclude>org.kohsuke.github.example.*</exclude>
|
||||
|
||||
<!-- No methods -->
|
||||
<exclude>org.kohsuke.github.Previews</exclude>
|
||||
<exclude>org.kohsuke.github.internal.Previews</exclude>
|
||||
|
||||
<!-- Deprecated -->
|
||||
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
|
||||
@@ -209,7 +217,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<failOnWarnings>true</failOnWarnings>
|
||||
@@ -233,7 +241,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.8.2</version>
|
||||
<version>3.9.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -253,12 +261,12 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.1</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.bcel</groupId>
|
||||
<artifactId>bcel</artifactId>
|
||||
<version>6.4.1</version>
|
||||
<version>6.5.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
@@ -280,12 +288,31 @@
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-test</id>
|
||||
<configuration>
|
||||
<excludesFile>src/test/resources/slow-or-flaky-tests.txt</excludesFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>slow-or-flaky-test</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rerunFailingTestsCount>2</rerunFailingTestsCount>
|
||||
<!-- There are some tests that take longer or are a little flaky. Run them here. -->
|
||||
<includesFile>src/test/resources/slow-or-flaky-tests.txt</includesFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>animal-sniffer-maven-plugin</artifactId>
|
||||
<version>1.18</version>
|
||||
<version>1.19</version>
|
||||
<configuration>
|
||||
<signature>
|
||||
<groupId>org.codehaus.mojo.signature</groupId>
|
||||
@@ -316,36 +343,34 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.revelc.code.formatter</groupId>
|
||||
<artifactId>formatter-maven-plugin</artifactId>
|
||||
<version>2.11.0</version>
|
||||
<groupId>com.diffplug.spotless</groupId>
|
||||
<artifactId>spotless-maven-plugin</artifactId>
|
||||
<version>2.6.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>spotless-check</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>${formatter-maven-plugin.goal}</goal>
|
||||
<goal>${spotless-maven-plugin.goal}</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<configFile>src/main/resources/eclipse/formatter.xml</configFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.revelc.code</groupId>
|
||||
<artifactId>impsort-maven-plugin</artifactId>
|
||||
<version>1.3.2</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>
|
||||
@@ -382,6 +407,12 @@
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tngtech.archunit</groupId>
|
||||
<artifactId>archunit</artifactId>
|
||||
<version>0.15.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest</artifactId>
|
||||
@@ -404,7 +435,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13</version>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -441,7 +472,7 @@
|
||||
<dependency>
|
||||
<groupId>org.kohsuke.stapler</groupId>
|
||||
<artifactId>stapler</artifactId>
|
||||
<version>1.259</version>
|
||||
<version>1.262</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -453,9 +484,27 @@
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jgit</groupId>
|
||||
<artifactId>org.eclipse.jgit</artifactId>
|
||||
<version>5.6.1.202002131546-r</version>
|
||||
<version>5.10.0.202012080955-r</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-api</artifactId>
|
||||
<version>${jjwt.suite.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-impl</artifactId>
|
||||
<version>${jjwt.suite.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>${jjwt.suite.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okio</groupId>
|
||||
<artifactId>okio</artifactId>
|
||||
@@ -491,7 +540,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<version>3.6.28</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -503,7 +552,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock-jre8-standalone</artifactId>
|
||||
<version>2.26.2</version>
|
||||
<version>2.27.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -512,6 +561,12 @@
|
||||
<version>2.8.6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.30</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
@@ -537,8 +592,7 @@
|
||||
</os>
|
||||
</activation>
|
||||
<properties>
|
||||
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
|
||||
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
|
||||
<spotless-maven-plugin.goal>check</spotless-maven-plugin.goal>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
@@ -563,11 +617,14 @@
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<properties>
|
||||
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
|
||||
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
|
||||
<spotless-maven-plugin.goal>check</spotless-maven-plugin.goal>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
@@ -617,6 +674,18 @@
|
||||
</profiles>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<!-- select non-aggregate reports -->
|
||||
<report>report</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
|
||||
6
src/build/eclipse/eclipse.importorder
Normal file
6
src/build/eclipse/eclipse.importorder
Normal 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=\#
|
||||
166
src/main/java/org/kohsuke/github/AbstractBuilder.java
Normal file
166
src/main/java/org/kohsuke/github/AbstractBuilder.java
Normal file
@@ -0,0 +1,166 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* An abstract data object builder/updater.
|
||||
*
|
||||
* This class can be use to make a Builder that supports both batch and single property changes.
|
||||
* <p>
|
||||
* Batching looks like this:
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* update().someName(value).otherName(value).done()
|
||||
* </pre>
|
||||
* <p>
|
||||
* Single changes look like this:
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* set().someName(value);
|
||||
* set().otherName(value);
|
||||
* </pre>
|
||||
* <p>
|
||||
* If {@link S} is the same as {@link R}, {@link #with(String, Object)} will commit changes after the first value change
|
||||
* and return a {@link R} from {@link #done()}.
|
||||
* </p>
|
||||
* <p>
|
||||
* If {@link S} is not the same as {@link R}, {@link #with(String, Object)} will batch together multiple changes and let
|
||||
* the user call {@link #done()} when they are ready.
|
||||
*
|
||||
* @param <R>
|
||||
* Final return type built by this builder returned when {@link #done()}} is called.
|
||||
* @param <S>
|
||||
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S}
|
||||
* the same as {@link R}, this builder will commit changes after each call to {@link #with(String, Object)}.
|
||||
*/
|
||||
abstract class AbstractBuilder<R, S> extends GitHubInteractiveObject {
|
||||
|
||||
@Nonnull
|
||||
private final Class<R> returnType;
|
||||
|
||||
private final boolean commitChangesImmediately;
|
||||
|
||||
@CheckForNull
|
||||
private final R baseInstance;
|
||||
|
||||
@Nonnull
|
||||
protected final Requester requester;
|
||||
|
||||
// TODO: Not sure how update-in-place behavior should be controlled
|
||||
// However, it certainly can be controlled dynamically down to the instance level or inherited for all children of
|
||||
// some
|
||||
// connection.
|
||||
protected boolean updateInPlace;
|
||||
|
||||
/**
|
||||
* Creates a builder.
|
||||
*
|
||||
* @param root
|
||||
* the GitHub instance to connect to.
|
||||
* @param intermediateReturnType
|
||||
* the intermediate return type of type {@link S} returned by calls to {@link #with(String, Object)}.
|
||||
* Must either be equal to {@code builtReturnType} or this instance must be castable to this class. If
|
||||
* not, the constructor will throw {@link IllegalArgumentException}.
|
||||
* @param finalReturnType
|
||||
* the final return type for built by this builder returned when {@link #done()}} is called.
|
||||
* @param baseInstance
|
||||
* optional instance on which to base this builder.
|
||||
*/
|
||||
protected AbstractBuilder(@Nonnull Class<R> finalReturnType,
|
||||
@Nonnull Class<S> intermediateReturnType,
|
||||
@Nonnull GitHub root,
|
||||
@CheckForNull R baseInstance) {
|
||||
super(root);
|
||||
this.requester = root.createRequest();
|
||||
this.returnType = finalReturnType;
|
||||
this.commitChangesImmediately = returnType.equals(intermediateReturnType);
|
||||
if (!commitChangesImmediately && !intermediateReturnType.isInstance(this)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Argument \"intermediateReturnType\": This instance must be castable to intermediateReturnType or finalReturnType must be equal to intermediateReturnType.");
|
||||
}
|
||||
|
||||
this.baseInstance = baseInstance;
|
||||
this.updateInPlace = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes an update, committing changes.
|
||||
*
|
||||
* This method may update-in-place or not. Either way it returns the resulting instance.
|
||||
*
|
||||
* @return an instance with updated current data
|
||||
* @throws IOException
|
||||
* if there is an I/O Exception
|
||||
*/
|
||||
@Nonnull
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public R done() throws IOException {
|
||||
R result;
|
||||
if (updateInPlace && baseInstance != null) {
|
||||
result = requester.fetchInto(baseInstance);
|
||||
} else {
|
||||
result = requester.fetch(returnType);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a value to a name for this builder.
|
||||
*
|
||||
* If {@link S} is the same as {@link R}, this method will commit changes after the first value change and return a
|
||||
* {@link R} from {@link #done()}.
|
||||
*
|
||||
* If {@link S} is not the same as {@link R}, this method will return an {@link S} and letting the caller batch
|
||||
* together multiple changes and call {@link #done()} when they are ready.
|
||||
*
|
||||
* @param name
|
||||
* the name of the field
|
||||
* @param value
|
||||
* the value of the field
|
||||
* @return either a continuing builder or an updated data record
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
*/
|
||||
@Nonnull
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
protected S with(@Nonnull String name, Object value) throws IOException {
|
||||
requester.with(name, value);
|
||||
return continueOrDone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Chooses whether to return a continuing builder or an updated data record
|
||||
*
|
||||
* If {@link S} is the same as {@link R}, this method will commit changes after the first value change and return a
|
||||
* {@link R} from {@link #done()}.
|
||||
*
|
||||
* If {@link S} is not the same as {@link R}, this method will return an {@link S} and letting the caller batch
|
||||
* together multiple changes and call {@link #done()} when they are ready.
|
||||
*
|
||||
* @return either a continuing builder or an updated data record
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
*/
|
||||
@Nonnull
|
||||
@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
|
||||
// Setter classes from almost identical code. Creator can often be implemented with significant code reuse as
|
||||
// well.
|
||||
if (commitChangesImmediately) {
|
||||
// These casts look strange and risky, but they they're actually guaranteed safe due to the return path
|
||||
// being based on the previous comparison of class instances passed to the constructor.
|
||||
return (S) done();
|
||||
} else {
|
||||
return (S) this;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/main/java/org/kohsuke/github/BetaApi.java
Normal file
18
src/main/java/org/kohsuke/github/BetaApi.java
Normal 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 {
|
||||
}
|
||||
@@ -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;
|
||||
@@ -39,7 +38,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param owner
|
||||
* the owner
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setOwner(GHUser owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
@@ -58,7 +59,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -77,7 +80,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param description
|
||||
* the description
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
@@ -96,7 +101,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param externalUrl
|
||||
* the external url
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setExternalUrl(String externalUrl) {
|
||||
this.externalUrl = externalUrl;
|
||||
}
|
||||
@@ -115,7 +122,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param events
|
||||
* the events
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setEvents(List<GHEvent> events) {
|
||||
this.events = events;
|
||||
}
|
||||
@@ -134,7 +143,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param installationsCount
|
||||
* the installations count
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setInstallationsCount(long installationsCount) {
|
||||
this.installationsCount = installationsCount;
|
||||
}
|
||||
@@ -157,7 +168,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param permissions
|
||||
* the permissions
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPermissions(Map<String, String> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
@@ -175,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()
|
||||
@@ -196,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()
|
||||
@@ -219,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()
|
||||
@@ -244,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()
|
||||
@@ -266,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()
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -3,11 +3,13 @@ package org.kohsuke.github;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.kohsuke.github.Previews.GAMBIT;
|
||||
import static org.kohsuke.github.internal.Previews.GAMBIT;
|
||||
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||
|
||||
/**
|
||||
* A Github App Installation.
|
||||
@@ -20,7 +22,6 @@ import static org.kohsuke.github.Previews.GAMBIT;
|
||||
* @see GHApp#getInstallationByUser(String) GHApp#getInstallationByUser(String)
|
||||
*/
|
||||
public class GHAppInstallation extends GHObject {
|
||||
private GitHub root;
|
||||
private GHUser account;
|
||||
|
||||
@JsonProperty("access_tokens_url")
|
||||
@@ -59,7 +60,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRoot(GitHub root) {
|
||||
this.root = root;
|
||||
}
|
||||
@@ -78,7 +81,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param account
|
||||
* the account
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAccount(GHUser account) {
|
||||
this.account = account;
|
||||
}
|
||||
@@ -97,7 +102,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param accessTokenUrl
|
||||
* the access token url
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAccessTokenUrl(String accessTokenUrl) {
|
||||
this.accessTokenUrl = accessTokenUrl;
|
||||
}
|
||||
@@ -111,12 +118,44 @@ public class GHAppInstallation extends GHObject {
|
||||
return repositoriesUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* List repositories that this app installation can access.
|
||||
*
|
||||
* @return the paged iterable
|
||||
*/
|
||||
@Preview(MACHINE_MAN)
|
||||
@Deprecated
|
||||
public PagedSearchIterable<GHRepository> listRepositories() {
|
||||
GitHubRequest request;
|
||||
|
||||
try {
|
||||
request = root.createRequest().withPreview(MACHINE_MAN).withUrlPath("/installation/repositories").build();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new GHException("", e);
|
||||
}
|
||||
|
||||
return new PagedSearchIterable<>(root, request, GHAppInstallationRepositoryResult.class);
|
||||
}
|
||||
|
||||
private static class GHAppInstallationRepositoryResult extends SearchResult<GHRepository> {
|
||||
private GHRepository[] repositories;
|
||||
|
||||
@Override
|
||||
GHRepository[] getItems(GitHub root) {
|
||||
for (GHRepository item : repositories)
|
||||
item.wrap(root);
|
||||
return repositories;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repositories url.
|
||||
*
|
||||
* @param repositoriesUrl
|
||||
* the repositories url
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRepositoriesUrl(String repositoriesUrl) {
|
||||
this.repositoriesUrl = repositoriesUrl;
|
||||
}
|
||||
@@ -135,7 +174,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param appId
|
||||
* the app id
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAppId(long appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
@@ -154,7 +195,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param targetId
|
||||
* the target id
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTargetId(long targetId) {
|
||||
this.targetId = targetId;
|
||||
}
|
||||
@@ -173,7 +216,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param targetType
|
||||
* the target type
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTargetType(GHTargetType targetType) {
|
||||
this.targetType = targetType;
|
||||
}
|
||||
@@ -192,7 +237,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param permissions
|
||||
* the permissions
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPermissions(Map<String, GHPermissionType> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
@@ -211,7 +258,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param events
|
||||
* the events
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setEvents(List<GHEvent> events) {
|
||||
this.events = events;
|
||||
}
|
||||
@@ -230,7 +279,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param singleFileName
|
||||
* the single file name
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSingleFileName(String singleFileName) {
|
||||
this.singleFileName = singleFileName;
|
||||
}
|
||||
@@ -249,7 +300,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param repositorySelection
|
||||
* the repository selection
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRepositorySelection(GHRepositorySelection repositorySelection) {
|
||||
this.repositorySelection = repositorySelection;
|
||||
}
|
||||
@@ -268,13 +321,13 @@ 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()
|
||||
.method("DELETE")
|
||||
.withPreview(GAMBIT)
|
||||
.withUrlPath(String.format("/app/installations/%d", id))
|
||||
.withUrlPath(String.format("/app/installations/%d", getId()))
|
||||
.send();
|
||||
}
|
||||
|
||||
@@ -290,10 +343,12 @@ 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, String.format("/app/installations/%d/access_tokens", id), permissions);
|
||||
return new GHAppCreateTokenBuilder(root,
|
||||
String.format("/app/installations/%d/access_tokens", getId()),
|
||||
permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,9 +360,9 @@ 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", id));
|
||||
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -37,7 +35,9 @@ public class GHAppInstallationToken {
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRoot(GitHub root) {
|
||||
this.root = root;
|
||||
}
|
||||
@@ -56,7 +56,9 @@ public class GHAppInstallationToken {
|
||||
*
|
||||
* @param permissions
|
||||
* the permissions
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPermissions(Map<String, String> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
@@ -75,7 +77,9 @@ public class GHAppInstallationToken {
|
||||
*
|
||||
* @param token
|
||||
* the token
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
@@ -94,7 +98,9 @@ public class GHAppInstallationToken {
|
||||
*
|
||||
* @param repositories
|
||||
* the repositories
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRepositories(List<GHRepository> repositories) {
|
||||
this.repositories = repositories;
|
||||
}
|
||||
@@ -113,7 +119,9 @@ public class GHAppInstallationToken {
|
||||
*
|
||||
* @param repositorySelection
|
||||
* the repository selection
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRepositorySelection(GHRepositorySelection repositorySelection) {
|
||||
this.repositorySelection = repositorySelection;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -149,7 +148,7 @@ public class GHAsset extends GHObject {
|
||||
}
|
||||
|
||||
private String getApiRoute() {
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + id;
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + getId();
|
||||
}
|
||||
|
||||
GHAsset wrap(GHRelease release) {
|
||||
|
||||
@@ -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;
|
||||
@@ -112,10 +111,12 @@ public class GHAuthorization extends GHObject {
|
||||
* Gets api url.
|
||||
*
|
||||
* @return the api url
|
||||
* @deprecated use {@link #getUrl()}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library API, cannot be changed")
|
||||
public URL getApiURL() {
|
||||
return GitHubClient.parseURL(url);
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,12 +3,15 @@ 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;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
/**
|
||||
* A branch in a repository.
|
||||
*
|
||||
@@ -18,8 +21,7 @@ import java.util.Objects;
|
||||
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;
|
||||
@@ -76,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;
|
||||
@@ -87,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);
|
||||
@@ -100,8 +102,14 @@ public class GHBranch {
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Preview(Previews.LUKE_CAGE)
|
||||
@Deprecated
|
||||
public GHBranchProtection getProtection() throws IOException {
|
||||
return root.createRequest().withUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this);
|
||||
return root.createRequest()
|
||||
.withPreview(Previews.LUKE_CAGE)
|
||||
.setRawUrlPath(protection_url)
|
||||
.fetch(GHBranchProtection.class)
|
||||
.wrap(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +128,7 @@ public class GHBranch {
|
||||
* if disabling protection fails
|
||||
*/
|
||||
public void disableProtection() throws IOException {
|
||||
root.createRequest().method("DELETE").withUrlPath(protection_url).send();
|
||||
root.createRequest().method("DELETE").setRawUrlPath(protection_url).send();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,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);
|
||||
@@ -161,6 +169,59 @@ public class GHBranch {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge a branch into this branch.
|
||||
*
|
||||
* @param headBranch
|
||||
* the branch whose head will be merged
|
||||
*
|
||||
* @param commitMessage
|
||||
* the commit message
|
||||
*
|
||||
* @return the merge {@link GHCommit} created, or {@code null} if the base already contains the head (nothing to
|
||||
* merge).
|
||||
*
|
||||
* @throws IOException
|
||||
* if merging fails
|
||||
*/
|
||||
@CheckForNull
|
||||
public GHCommit merge(GHBranch headBranch, String commitMessage) throws IOException {
|
||||
return merge(headBranch.getName(), commitMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge a ref into this branch.
|
||||
*
|
||||
* @param head
|
||||
* the ref name that will be merged into this branch. Follows the usual ref naming rules, could be a
|
||||
* branch name, tag, or commit sha.
|
||||
*
|
||||
* @param commitMessage
|
||||
* the commit message
|
||||
*
|
||||
* @return the merge {@link GHCommit} created, or {@code null} if the base already contains the head (nothing to
|
||||
* merge).
|
||||
*
|
||||
* @throws IOException
|
||||
* if merging fails
|
||||
*/
|
||||
@CheckForNull
|
||||
public GHCommit merge(String head, String commitMessage) throws IOException {
|
||||
GHCommit result = root.createRequest()
|
||||
.withUrlPath(owner.getApiTailUrl("merges"))
|
||||
.method("POST")
|
||||
.with("commit_message", commitMessage)
|
||||
.with("base", this.name)
|
||||
.with("head", head)
|
||||
.fetch(GHCommit.class);
|
||||
|
||||
if (result != null) {
|
||||
result.wrapUp(owner);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String getApiRoute() {
|
||||
return owner.getApiTailUrl("/branches/" + name);
|
||||
}
|
||||
|
||||
@@ -6,23 +6,23 @@ 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.
|
||||
*
|
||||
* @see <a href="https://docs.github.com/en/rest/reference/repos#get-branch-protection">GitHub Branch Protection</a>
|
||||
*/
|
||||
@SuppressFBWarnings(
|
||||
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||
"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;
|
||||
|
||||
@@ -41,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);
|
||||
@@ -53,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();
|
||||
@@ -84,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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
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.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a check run.
|
||||
@@ -14,8 +20,9 @@ import java.util.Date;
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHCheckRun extends GHObject {
|
||||
|
||||
@JsonProperty("repository")
|
||||
GHRepository owner;
|
||||
GitHub root;
|
||||
|
||||
private String status;
|
||||
private String conclusion;
|
||||
@@ -34,7 +41,7 @@ public class GHCheckRun extends GHObject {
|
||||
|
||||
GHCheckRun wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
wrap(owner.root);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -42,7 +49,24 @@ public class GHCheckRun extends GHObject {
|
||||
this.root = root;
|
||||
if (owner != null) {
|
||||
owner.wrap(root);
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.wrap(owner);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (checkSuite != null) {
|
||||
if (owner != null) {
|
||||
checkSuite.wrap(owner);
|
||||
} else {
|
||||
checkSuite.wrap(root);
|
||||
}
|
||||
}
|
||||
if (app != null) {
|
||||
app.wrapUp(root);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -51,24 +75,39 @@ public class GHCheckRun extends GHObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets status of the check run. It can be one of "queue", "in_progress", or "completed"
|
||||
* Gets status of the check run.
|
||||
*
|
||||
* @return Status of the check run
|
||||
* @see Status
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public static enum Status {
|
||||
QUEUED, IN_PROGRESS, COMPLETED
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets conclusion of a completed check run. It can be one of "success", "failure", "neutral", "cancelled",
|
||||
* "time_out", or "action_required".
|
||||
* Gets conclusion of a completed check run.
|
||||
*
|
||||
* @return Status of the check run
|
||||
* @see Conclusion
|
||||
*/
|
||||
public String getConclusion() {
|
||||
return conclusion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Final conclusion of the check.
|
||||
*
|
||||
* From <a href="https://docs.github.com/en/rest/reference/checks#create-a-check-run--parameters">Check Run
|
||||
* Parameters - <code>conclusion</code></a>.
|
||||
*/
|
||||
public static enum Conclusion {
|
||||
SUCCESS, FAILURE, NEUTRAL, CANCELLED, TIMED_OUT, ACTION_REQUIRED, SKIPPED
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom name of this check run.
|
||||
*
|
||||
@@ -90,15 +129,22 @@ public class GHCheckRun extends GHObject {
|
||||
/**
|
||||
* Gets the pull requests participated in this check run.
|
||||
*
|
||||
* @return Pull requests of this check run
|
||||
* Note this field is only populated for events. When getting a {@link GHCheckRun} outside of an event, this is
|
||||
* always empty.
|
||||
*
|
||||
* @return the list of {@link GHPullRequest}s for this check run. Only populated for events.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
GHPullRequest[] getPullRequests() throws IOException {
|
||||
public List<GHPullRequest> getPullRequests() throws IOException {
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.refresh();
|
||||
// Only refresh if we haven't do so before
|
||||
singlePull.refresh(singlePull.getTitle());
|
||||
}
|
||||
return Collections.unmodifiableList(Arrays.asList(pullRequests));
|
||||
}
|
||||
return pullRequests;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,4 +289,19 @@ public class GHCheckRun extends GHObject {
|
||||
}
|
||||
}
|
||||
|
||||
public static enum AnnotationLevel {
|
||||
NOTICE, WARNING, FAILURE
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates this check run.
|
||||
*
|
||||
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
|
||||
*/
|
||||
@Preview(Previews.ANTIOPE)
|
||||
@Deprecated
|
||||
public @NonNull GHCheckRunBuilder update() {
|
||||
return new GHCheckRunBuilder(owner, getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
307
src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
Normal file
307
src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
Normal file
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2020 CloudBees, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import edu.umd.cs.findbugs.annotations.CheckForNull;
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Drafts or updates a check run.
|
||||
*
|
||||
* @see GHCheckRun
|
||||
* @see GHRepository#createCheckRun
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#create-a-check-run">documentation</a>
|
||||
* @see GHCheckRun#update()
|
||||
* @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(Previews.ANTIOPE)
|
||||
@Deprecated
|
||||
public final class GHCheckRunBuilder {
|
||||
|
||||
protected final GHRepository repo;
|
||||
protected final Requester requester;
|
||||
private Output output;
|
||||
private List<Action> actions;
|
||||
|
||||
private GHCheckRunBuilder(GHRepository repo, Requester requester) {
|
||||
this.repo = repo;
|
||||
this.requester = requester;
|
||||
}
|
||||
|
||||
GHCheckRunBuilder(GHRepository repo, String name, String headSHA) {
|
||||
this(repo,
|
||||
repo.root.createRequest()
|
||||
.withPreview(Previews.ANTIOPE)
|
||||
.method("POST")
|
||||
.with("name", name)
|
||||
.with("head_sha", headSHA)
|
||||
.withUrlPath(repo.getApiTailUrl("check-runs")));
|
||||
}
|
||||
|
||||
GHCheckRunBuilder(GHRepository repo, long checkId) {
|
||||
this(repo,
|
||||
repo.root.createRequest()
|
||||
.withPreview(Previews.ANTIOPE)
|
||||
.method("PATCH")
|
||||
.withUrlPath(repo.getApiTailUrl("check-runs/" + checkId)));
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withDetailsURL(@CheckForNull String detailsURL) {
|
||||
requester.with("details_url", detailsURL);
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withExternalID(@CheckForNull String externalID) {
|
||||
requester.with("external_id", externalID);
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withStatus(@CheckForNull GHCheckRun.Status status) {
|
||||
if (status != null) {
|
||||
// Do *not* use the overload taking Enum, as that s/_/-/g which would be wrong here.
|
||||
requester.with("status", status.toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withConclusion(@CheckForNull GHCheckRun.Conclusion conclusion) {
|
||||
if (conclusion != null) {
|
||||
requester.with("conclusion", conclusion.toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Date startedAt) {
|
||||
if (startedAt != null) {
|
||||
requester.with("started_at", GitHubClient.printDate(startedAt));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Date completedAt) {
|
||||
if (completedAt != null) {
|
||||
requester.with("completed_at", GitHubClient.printDate(completedAt));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder add(@NonNull Output output) {
|
||||
if (this.output != null) {
|
||||
throw new IllegalStateException("cannot add Output twice");
|
||||
}
|
||||
this.output = output;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder add(@NonNull Action action) {
|
||||
if (actions == null) {
|
||||
actions = new LinkedList<>();
|
||||
}
|
||||
actions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
private static final int MAX_ANNOTATIONS = 50;
|
||||
/**
|
||||
* Actually creates the check run. (If more than fifty annotations were requested, this is done in batches.)
|
||||
*
|
||||
* @return the resulting run
|
||||
* @throws IOException
|
||||
* for the usual reasons
|
||||
*/
|
||||
public @NonNull GHCheckRun create() throws IOException {
|
||||
List<Annotation> extraAnnotations;
|
||||
if (output != null && output.annotations != null && output.annotations.size() > MAX_ANNOTATIONS) {
|
||||
extraAnnotations = output.annotations.subList(MAX_ANNOTATIONS, output.annotations.size());
|
||||
output.annotations = output.annotations.subList(0, MAX_ANNOTATIONS);
|
||||
} else {
|
||||
extraAnnotations = Collections.emptyList();
|
||||
}
|
||||
GHCheckRun run = requester.with("output", output).with("actions", actions).fetch(GHCheckRun.class).wrap(repo);
|
||||
while (!extraAnnotations.isEmpty()) {
|
||||
Output output2 = new Output(output.title, output.summary);
|
||||
int i = Math.min(extraAnnotations.size(), MAX_ANNOTATIONS);
|
||||
output2.annotations = extraAnnotations.subList(0, i);
|
||||
extraAnnotations = extraAnnotations.subList(i, extraAnnotations.size());
|
||||
run = repo.root.createRequest()
|
||||
.withPreview(Previews.ANTIOPE)
|
||||
.method("PATCH")
|
||||
.with("output", output2)
|
||||
.withUrlPath(repo.getApiTailUrl("check-runs/" + run.getId()))
|
||||
.fetch(GHCheckRun.class)
|
||||
.wrap(repo);
|
||||
}
|
||||
return run;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#output-object">documentation</a>
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static final class Output {
|
||||
|
||||
private final String title;
|
||||
private final String summary;
|
||||
private String text;
|
||||
private List<Annotation> annotations;
|
||||
private List<Image> images;
|
||||
|
||||
public Output(@NonNull String title, @NonNull String summary) {
|
||||
this.title = title;
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public @NonNull Output withText(@CheckForNull String text) {
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Output add(@NonNull Annotation annotation) {
|
||||
if (annotations == null) {
|
||||
annotations = new LinkedList<>();
|
||||
}
|
||||
annotations.add(annotation);
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Output add(@NonNull Image image) {
|
||||
if (images == null) {
|
||||
images = new LinkedList<>();
|
||||
}
|
||||
images.add(image);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#annotations-object">documentation</a>
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static final class Annotation {
|
||||
|
||||
private final String path;
|
||||
private final int start_line;
|
||||
private final int end_line;
|
||||
private final String annotation_level;
|
||||
private final String message;
|
||||
private Integer start_column;
|
||||
private Integer end_column;
|
||||
private String title;
|
||||
private String raw_details;
|
||||
|
||||
public Annotation(@NonNull String path,
|
||||
int line,
|
||||
@NonNull GHCheckRun.AnnotationLevel annotationLevel,
|
||||
@NonNull String message) {
|
||||
this(path, line, line, annotationLevel, message);
|
||||
}
|
||||
|
||||
public Annotation(@NonNull String path,
|
||||
int startLine,
|
||||
int endLine,
|
||||
@NonNull GHCheckRun.AnnotationLevel annotationLevel,
|
||||
@NonNull String message) {
|
||||
this.path = path;
|
||||
start_line = startLine;
|
||||
end_line = endLine;
|
||||
annotation_level = annotationLevel.toString().toLowerCase(Locale.ROOT);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public @NonNull Annotation withStartColumn(@CheckForNull Integer startColumn) {
|
||||
start_column = startColumn;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Annotation withEndColumn(@CheckForNull Integer endColumn) {
|
||||
end_column = endColumn;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Annotation withTitle(@CheckForNull String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Annotation withRawDetails(@CheckForNull String rawDetails) {
|
||||
raw_details = rawDetails;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#images-object">documentation</a>
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static final class Image {
|
||||
|
||||
private final String alt;
|
||||
private final String image_url;
|
||||
private String caption;
|
||||
|
||||
public Image(@NonNull String alt, @NonNull String imageURL) {
|
||||
this.alt = alt;
|
||||
image_url = imageURL;
|
||||
}
|
||||
|
||||
public @NonNull Image withCaption(@CheckForNull String caption) {
|
||||
this.caption = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#actions-object">documentation</a>
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static final class Action {
|
||||
|
||||
private final String label;
|
||||
private final String description;
|
||||
private final String identifier;
|
||||
|
||||
public Action(@NonNull String label, @NonNull String description, @NonNull String identifier) {
|
||||
this.label = label;
|
||||
this.description = description;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
44
src/main/java/org/kohsuke/github/GHCheckRunsIterable.java
Normal file
44
src/main/java/org/kohsuke/github/GHCheckRunsIterable.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Iterable for check-runs listing.
|
||||
*/
|
||||
class GHCheckRunsIterable extends PagedIterable<GHCheckRun> {
|
||||
private final transient GitHub root;
|
||||
private final GitHubRequest request;
|
||||
|
||||
private GHCheckRunsPage result;
|
||||
|
||||
public GHCheckRunsIterable(GitHub root, GitHubRequest request) {
|
||||
this.root = root;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PagedIterator<GHCheckRun> _iterator(int pageSize) {
|
||||
return new PagedIterator<>(
|
||||
adapt(GitHubPageIterator.create(root.getClient(), GHCheckRunsPage.class, request, pageSize)),
|
||||
null);
|
||||
}
|
||||
|
||||
protected Iterator<GHCheckRun[]> adapt(final Iterator<GHCheckRunsPage> base) {
|
||||
return new Iterator<GHCheckRun[]>() {
|
||||
public boolean hasNext() {
|
||||
return base.hasNext();
|
||||
}
|
||||
|
||||
public GHCheckRun[] next() {
|
||||
GHCheckRunsPage v = base.next();
|
||||
if (result == null) {
|
||||
result = v;
|
||||
}
|
||||
return v.getCheckRuns(root);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
20
src/main/java/org/kohsuke/github/GHCheckRunsPage.java
Normal file
20
src/main/java/org/kohsuke/github/GHCheckRunsPage.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
/**
|
||||
* Represents the one page of check-runs result when listing check-runs.
|
||||
*/
|
||||
class GHCheckRunsPage {
|
||||
private int total_count;
|
||||
private GHCheckRun[] check_runs;
|
||||
|
||||
public int getTotalCount() {
|
||||
return total_count;
|
||||
}
|
||||
|
||||
GHCheckRun[] getCheckRuns(GitHub root) {
|
||||
for (GHCheckRun check_run : check_runs) {
|
||||
check_run.wrap(root);
|
||||
}
|
||||
return check_runs;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a check suite.
|
||||
@@ -14,8 +18,9 @@ import java.util.Date;
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHCheckSuite extends GHObject {
|
||||
|
||||
@JsonProperty("repository")
|
||||
GHRepository owner;
|
||||
GitHub root;
|
||||
|
||||
private String nodeId;
|
||||
private String headBranch;
|
||||
@@ -32,7 +37,7 @@ public class GHCheckSuite extends GHObject {
|
||||
|
||||
GHCheckSuite wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
this.wrap(owner.root);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -40,6 +45,14 @@ public class GHCheckSuite extends GHObject {
|
||||
this.root = root;
|
||||
if (owner != null) {
|
||||
owner.wrap(root);
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.wrap(owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (app != null) {
|
||||
app.wrapUp(root);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -153,15 +166,22 @@ public class GHCheckSuite extends GHObject {
|
||||
/**
|
||||
* Gets the pull requests participated in this check suite.
|
||||
*
|
||||
* @return Pull requests
|
||||
* Note this field is only populated for events. When getting a {@link GHCheckSuite} outside of an event, this is
|
||||
* always empty.
|
||||
*
|
||||
* @return the list of {@link GHPullRequest}s for this check suite. Only populated for events.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
GHPullRequest[] getPullRequests() throws IOException {
|
||||
public List<GHPullRequest> getPullRequests() throws IOException {
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.refresh();
|
||||
// Only refresh if we haven't do so before
|
||||
singlePull.refresh(singlePull.getTitle());
|
||||
}
|
||||
return Collections.unmodifiableList(Arrays.asList(pullRequests));
|
||||
}
|
||||
return pullRequests;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,9 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.kohsuke.github.internal.Previews.ANTIOPE;
|
||||
import static org.kohsuke.github.internal.Previews.GROOT;
|
||||
|
||||
/**
|
||||
* A commit in a repository.
|
||||
*
|
||||
@@ -39,6 +42,8 @@ public class GHCommit {
|
||||
|
||||
private int comment_count;
|
||||
|
||||
private GHVerification verification;
|
||||
|
||||
static class Tree {
|
||||
String sha;
|
||||
}
|
||||
@@ -61,7 +66,7 @@ public class GHCommit {
|
||||
* @return the authored date
|
||||
*/
|
||||
public Date getAuthoredDate() {
|
||||
return GitHubClient.parseDate(author.date);
|
||||
return author.getDate();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +85,7 @@ public class GHCommit {
|
||||
* @return the commit date
|
||||
*/
|
||||
public Date getCommitDate() {
|
||||
return GitHubClient.parseDate(committer.date);
|
||||
return committer.getDate();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,6 +105,15 @@ public class GHCommit {
|
||||
public int getCommentCount() {
|
||||
return comment_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Verification Status.
|
||||
*
|
||||
* @return the Verification status
|
||||
*/
|
||||
public GHVerification getVerification() {
|
||||
return verification;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +122,6 @@ public class GHCommit {
|
||||
* @deprecated Use {@link GitUser} instead.
|
||||
*/
|
||||
public static class GHAuthor extends GitUser {
|
||||
private String date;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -435,6 +448,39 @@ public class GHCommit {
|
||||
return owner.root.getUser(author.login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of pull requests which contain this commit.
|
||||
*
|
||||
* @return {@link PagedIterable} with the pull requests which contain this commit
|
||||
*/
|
||||
@Preview(GROOT)
|
||||
@Deprecated
|
||||
public PagedIterable<GHPullRequest> listPullRequests() {
|
||||
return owner.root.createRequest()
|
||||
.withPreview(GROOT)
|
||||
.withUrlPath(String.format("/repos/%s/%s/commits/%s/pulls", owner.getOwnerName(), owner.getName(), sha))
|
||||
.toIterable(GHPullRequest[].class, item -> item.wrapUp(owner));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of branches where this commit is the head commit.
|
||||
*
|
||||
* @return {@link PagedIterable} with the branches where the commit is the head commit
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Preview(GROOT)
|
||||
@Deprecated
|
||||
public PagedIterable<GHBranch> listBranchesWhereHead() throws IOException {
|
||||
return owner.root.createRequest()
|
||||
.withPreview(GROOT)
|
||||
.withUrlPath(String.format("/repos/%s/%s/commits/%s/branches-where-head",
|
||||
owner.getOwnerName(),
|
||||
owner.getName(),
|
||||
sha))
|
||||
.toIterable(GHBranch[].class, item -> item.wrap(owner));
|
||||
}
|
||||
|
||||
/**
|
||||
* List comments paged iterable.
|
||||
*
|
||||
@@ -512,9 +558,22 @@ public class GHCommit {
|
||||
return owner.getLastCommitStatus(sha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets check-runs for given sha.
|
||||
*
|
||||
* @return check runs for given sha.
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
@Preview(ANTIOPE)
|
||||
@Deprecated
|
||||
public PagedIterable<GHCheckRun> getCheckRuns() throws IOException {
|
||||
return owner.getCheckRuns(sha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some of the fields are not always filled in when this object is retrieved as a part of another API call.
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
|
||||
@@ -89,6 +89,19 @@ public class GHCommitBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the PGP signature of this commit.
|
||||
*
|
||||
* @param signature
|
||||
* the signature calculated from the commit
|
||||
*
|
||||
* @return the gh commit builder
|
||||
*/
|
||||
public GHCommitBuilder withSignature(String signature) {
|
||||
req.with("signature", signature);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the committer of this commit.
|
||||
*
|
||||
|
||||
@@ -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()
|
||||
@@ -153,7 +153,7 @@ public class GHCommitComment extends GHObject implements Reactable {
|
||||
}
|
||||
|
||||
private String getApiTail() {
|
||||
return String.format("/repos/%s/%s/comments/%s", owner.getOwnerName(), owner.getName(), id);
|
||||
return String.format("/repos/%s/%s/comments/%s", owner.getOwnerName(), owner.getName(), getId());
|
||||
}
|
||||
|
||||
GHCommitComment wrap(GHRepository owner) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -15,21 +15,20 @@ 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;
|
||||
private String sha;
|
||||
private String name;
|
||||
private String path;
|
||||
private String target;
|
||||
private String content;
|
||||
private String url; // this is the API url
|
||||
private String git_url; // this is the Blob url
|
||||
@@ -99,6 +98,15 @@ public class GHContent implements Refreshable {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets target of a symlink. This will only be set if {@code "symlink".equals(getType())}
|
||||
*
|
||||
* @return the target
|
||||
*/
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the decoded content that is stored at this location.
|
||||
*
|
||||
|
||||
@@ -1,154 +1,25 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
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 final 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 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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,10 +67,57 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @deprecated Use {@link #isTemplate(boolean)} method instead
|
||||
*/
|
||||
@Deprecated
|
||||
public GHCreateRepositoryBuilder templateRepository(boolean enabled) throws IOException {
|
||||
return isTemplate(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the ownership of the repository.
|
||||
*
|
||||
* @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) throws IOException {
|
||||
return with("owner", owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create repository from template repository
|
||||
*
|
||||
* @param templateOwner
|
||||
* template repository owner
|
||||
* @param templateRepo
|
||||
* template repository
|
||||
* @return a builder to continue with building
|
||||
* @see <a href="https://developer.github.com/v3/previews/">GitHub API Previews</a>
|
||||
*/
|
||||
@Preview(BAPTISTE)
|
||||
@Deprecated
|
||||
public GHCreateRepositoryBuilder fromTemplateRepository(String templateOwner, String templateRepo) {
|
||||
requester.withPreview(BAPTISTE).withUrlPath("/repos/" + templateOwner + "/" + templateRepo + "/generate");
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -193,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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents a deployment
|
||||
@@ -13,7 +16,6 @@ import java.net.URL;
|
||||
*/
|
||||
public class GHDeployment extends GHObject {
|
||||
private GHRepository owner;
|
||||
private GitHub root;
|
||||
protected String sha;
|
||||
protected String ref;
|
||||
protected String task;
|
||||
@@ -23,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;
|
||||
@@ -60,7 +65,8 @@ public class GHDeployment extends GHObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets payload.
|
||||
* Gets payload. <b>NOTE:</b> only use this method if you can guarantee the payload will be a simple string,
|
||||
* otherwise use {@link #getPayloadObject()}.
|
||||
*
|
||||
* @return the payload
|
||||
*/
|
||||
@@ -68,6 +74,38 @@ public class GHDeployment extends GHObject {
|
||||
return (String) payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets payload. <b>NOTE:</b> only use this method if you can guarantee the payload will be a JSON object (Map),
|
||||
* otherwise use {@link #getPayloadObject()}.
|
||||
*
|
||||
* @return the payload
|
||||
*/
|
||||
public Map<String, Object> getPayloadMap() {
|
||||
return (Map<String, Object>) payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets payload without assuming its type. It could be a String or a Map.
|
||||
*
|
||||
* @return the payload
|
||||
*/
|
||||
public Object getPayloadObject() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -77,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.
|
||||
*
|
||||
@@ -122,7 +187,7 @@ public class GHDeployment extends GHObject {
|
||||
* @return the gh deployment status builder
|
||||
*/
|
||||
public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
|
||||
return new GHDeploymentStatusBuilder(owner, id, state);
|
||||
return new GHDeploymentStatusBuilder(owner, getId(), state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
230
src/main/java/org/kohsuke/github/GHDiscussion.java
Normal file
230
src/main/java/org/kohsuke/github/GHDiscussion.java
Normal file
@@ -0,0 +1,230 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* A discussion in GitHub Team.
|
||||
*
|
||||
* @author Charles Moulliard
|
||||
* @see <a href="https://developer.github.com/v3/teams/discussions">GitHub Team Discussions</a>
|
||||
*/
|
||||
public class GHDiscussion extends GHObject {
|
||||
|
||||
private GHTeam team;
|
||||
private long number;
|
||||
private String body, title, htmlUrl;
|
||||
|
||||
@JsonProperty(value = "private")
|
||||
private boolean isPrivate;
|
||||
|
||||
@Override
|
||||
public URL getHtmlUrl() throws IOException {
|
||||
return GitHubClient.parseURL(htmlUrl);
|
||||
}
|
||||
|
||||
GHDiscussion wrapUp(GHTeam team) {
|
||||
this.team = team;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the team to which this discussion belongs.
|
||||
*
|
||||
* @return the team for this discussion
|
||||
*/
|
||||
@Nonnull
|
||||
public GHTeam getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title of the discussion.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of this discussion.
|
||||
*
|
||||
* @return the body
|
||||
*/
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of this discussion.
|
||||
*
|
||||
* @return the number
|
||||
*/
|
||||
public long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id number of this discussion. GitHub discussions have "number" instead of "id". This is provided for
|
||||
* convenience.
|
||||
*
|
||||
* @return the id number for this discussion
|
||||
* @see #getNumber()
|
||||
*/
|
||||
@Override
|
||||
public long getId() {
|
||||
return getNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the discussion is private to the team.
|
||||
*
|
||||
* @return {@code true} if discussion is private.
|
||||
*/
|
||||
public boolean isPrivate() {
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins the creation of a new instance.
|
||||
*
|
||||
* Consumer must call {@link GHDiscussion.Creator#done()} to commit changes.
|
||||
*
|
||||
* @param team
|
||||
* the team in which the discussion will be created.
|
||||
* @return a {@link GHLabel.Creator}
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
static GHDiscussion.Creator create(GHTeam team) throws IOException {
|
||||
return new GHDiscussion.Creator(team);
|
||||
}
|
||||
|
||||
static GHDiscussion read(GHTeam team, long discussionNumber) throws IOException {
|
||||
return team.root.createRequest()
|
||||
.setRawUrlPath(getRawUrlPath(team, discussionNumber))
|
||||
.fetch(GHDiscussion.class)
|
||||
.wrapUp(team);
|
||||
}
|
||||
|
||||
static PagedIterable<GHDiscussion> readAll(GHTeam team) throws IOException {
|
||||
return team.root.createRequest()
|
||||
.setRawUrlPath(getRawUrlPath(team, null))
|
||||
.toIterable(GHDiscussion[].class, item -> item.wrapUp(team));
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins a batch update
|
||||
*
|
||||
* Consumer must call {@link GHDiscussion.Updater#done()} to commit changes.
|
||||
*
|
||||
* @return a {@link GHDiscussion.Updater}
|
||||
*/
|
||||
@Preview(Previews.SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public GHDiscussion.Updater update() {
|
||||
return new GHDiscussion.Updater(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins a single property update.
|
||||
*
|
||||
* @return a {@link GHDiscussion.Setter}
|
||||
*/
|
||||
@Preview(Previews.SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public GHDiscussion.Setter set() {
|
||||
return new GHDiscussion.Setter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the discussion
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
team.root.createRequest().method("DELETE").setRawUrlPath(getRawUrlPath(team, number)).send();
|
||||
}
|
||||
|
||||
private static String getRawUrlPath(@Nonnull GHTeam team, @CheckForNull Long discussionNumber) {
|
||||
return team.getUrl().toString() + "/discussions" + (discussionNumber == null ? "" : "/" + discussionNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link GHLabelBuilder} that updates a single property per request
|
||||
*
|
||||
* {@link #done()} is called automatically after the property is set.
|
||||
*/
|
||||
public static class Setter extends GHDiscussionBuilder<GHDiscussion> {
|
||||
private Setter(@Nonnull GHDiscussion base) {
|
||||
super(GHDiscussion.class, base.team, base);
|
||||
requester.method("PATCH").setRawUrlPath(base.getUrl().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link GHLabelBuilder} that allows multiple properties to be updated per request.
|
||||
*
|
||||
* Consumer must call {@link #done()} to commit changes.
|
||||
*/
|
||||
public static class Updater extends GHDiscussionBuilder<Updater> {
|
||||
private Updater(@Nonnull GHDiscussion base) {
|
||||
super(GHDiscussion.Updater.class, base.team, base);
|
||||
requester.method("PATCH").setRawUrlPath(base.getUrl().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link GHLabelBuilder} that creates a new {@link GHLabel}
|
||||
*
|
||||
* Consumer must call {@link #done()} to create the new instance.
|
||||
*/
|
||||
public static class Creator extends GHDiscussionBuilder<Creator> {
|
||||
|
||||
private Creator(@Nonnull GHTeam team) {
|
||||
super(GHDiscussion.Creator.class, team, null);
|
||||
requester.method("POST").setRawUrlPath(getRawUrlPath(team, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this discussion is private to this team.
|
||||
*
|
||||
* @param value
|
||||
* privacy of this discussion
|
||||
* @return either a continuing builder or an updated {@link GHDiscussion}
|
||||
* @throws IOException
|
||||
* if there is an I/O Exception
|
||||
*/
|
||||
@Nonnull
|
||||
public Creator private_(boolean value) throws IOException {
|
||||
return with("private", value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
GHDiscussion that = (GHDiscussion) o;
|
||||
return number == that.number && Objects.equals(getUrl(), that.getUrl()) && Objects.equals(team, that.team)
|
||||
&& Objects.equals(body, that.body) && Objects.equals(title, that.title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(team, number, body, title);
|
||||
}
|
||||
}
|
||||
80
src/main/java/org/kohsuke/github/GHDiscussionBuilder.java
Normal file
80
src/main/java/org/kohsuke/github/GHDiscussionBuilder.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Base class for creating or updating a discussion.
|
||||
*
|
||||
* @param <S>
|
||||
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S}
|
||||
* the same as {@link GHLabel}, this builder will commit changes after each call to
|
||||
* {@link #with(String, Object)}.
|
||||
*/
|
||||
class GHDiscussionBuilder<S> extends AbstractBuilder<GHDiscussion, S> {
|
||||
|
||||
private final GHTeam team;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param intermediateReturnType
|
||||
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If
|
||||
* {@link S} the same as {@link GHDiscussion}, this builder will commit changes after each call to
|
||||
* {@link #with(String, Object)}.
|
||||
* @param team
|
||||
* the GitHub team. Updates will be sent to the root of this team.
|
||||
* @param baseInstance
|
||||
* instance on which to base this builder. If {@code null} a new instance will be created.
|
||||
*/
|
||||
protected GHDiscussionBuilder(@Nonnull Class<S> intermediateReturnType,
|
||||
@Nonnull GHTeam team,
|
||||
@CheckForNull GHDiscussion baseInstance) {
|
||||
super(GHDiscussion.class, intermediateReturnType, team.root, baseInstance);
|
||||
|
||||
this.team = team;
|
||||
|
||||
if (baseInstance != null) {
|
||||
requester.with("title", baseInstance.getTitle());
|
||||
requester.with("body", baseInstance.getBody());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Title for this discussion.
|
||||
*
|
||||
* @param value
|
||||
* title of discussion
|
||||
* @return either a continuing builder or an updated {@link GHDiscussion}
|
||||
* @throws IOException
|
||||
* if there is an I/O Exception
|
||||
*/
|
||||
@Nonnull
|
||||
public S title(String value) throws IOException {
|
||||
return with("title", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Body content for this discussion.
|
||||
*
|
||||
* @param value
|
||||
* body of discussion*
|
||||
* @return either a continuing builder or an updated {@link GHDiscussion}
|
||||
* @throws IOException
|
||||
* if there is an I/O Exception
|
||||
*/
|
||||
@Nonnull
|
||||
public S body(String value) throws IOException {
|
||||
return with("body", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Nonnull
|
||||
@Override
|
||||
public GHDiscussion done() throws IOException {
|
||||
return super.done().wrapUp(team);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import java.util.Locale;
|
||||
public enum GHEvent {
|
||||
CHECK_RUN,
|
||||
CHECK_SUITE,
|
||||
CODE_SCANNING_ALERT,
|
||||
COMMIT_COMMENT,
|
||||
CONTENT_REFERENCE,
|
||||
CREATE,
|
||||
@@ -50,6 +51,7 @@ public enum GHEvent {
|
||||
PULL_REQUEST_REVIEW,
|
||||
PULL_REQUEST_REVIEW_COMMENT,
|
||||
PUSH,
|
||||
REGISTRY_PACKAGE,
|
||||
RELEASE,
|
||||
REPOSITORY_DISPATCH, // only valid for org hooks
|
||||
REPOSITORY,
|
||||
@@ -61,6 +63,8 @@ public enum GHEvent {
|
||||
TEAM,
|
||||
TEAM_ADD,
|
||||
WATCH,
|
||||
WORKFLOW_DISPATCH,
|
||||
WORKFLOW_RUN,
|
||||
|
||||
/**
|
||||
* Special event type that means "every possible event"
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
@@ -50,6 +49,30 @@ public class GHGist extends GHObject {
|
||||
this.owner = root.getUser(owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlike most other GitHub objects, the id for Gists can be non-numeric, such as "aa5a315d61ae9438b18d". If the id
|
||||
* is numeric, this method will get it. If id is not numeric, this will throw a runtime
|
||||
* {@link NumberFormatException}.
|
||||
*
|
||||
* @return id of the Gist.
|
||||
* @deprecated Use {@link #getGistId()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getId() {
|
||||
return Long.parseLong(getGistId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id for this Gist. Unlike most other GitHub objects, the id for Gists can be non-numeric, such as
|
||||
* "aa5a315d61ae9438b18d". This should be used instead of {@link #getId()}.
|
||||
*
|
||||
* @return id of this Gist
|
||||
*/
|
||||
public String getGistId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets owner.
|
||||
*
|
||||
@@ -97,6 +120,11 @@ public class GHGist extends GHObject {
|
||||
return git_push_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the html url.
|
||||
*
|
||||
* @return the github html url
|
||||
*/
|
||||
public URL getHtmlUrl() {
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Builder pattern for creating a new Gist.
|
||||
*
|
||||
@@ -11,7 +13,6 @@ import java.util.LinkedHashMap;
|
||||
* @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>();
|
||||
|
||||
@@ -22,7 +23,6 @@ public class GHGistBuilder {
|
||||
* the root
|
||||
*/
|
||||
public GHGistBuilder(GitHub root) {
|
||||
this.root = root;
|
||||
req = root.createRequest().method("POST");
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class GHGistBuilder {
|
||||
* the content
|
||||
* @return Adds a new file.
|
||||
*/
|
||||
public GHGistBuilder file(String fileName, String content) {
|
||||
public GHGistBuilder file(@Nonnull String fileName, @Nonnull String content) {
|
||||
files.put(fileName, Collections.singletonMap("content", content));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Builder pattern for updating a Gist.
|
||||
@@ -12,7 +15,7 @@ import java.util.LinkedHashMap;
|
||||
public class GHGistUpdater {
|
||||
private final GHGist base;
|
||||
private final Requester builder;
|
||||
LinkedHashMap<String, Object> files;
|
||||
LinkedHashMap<String, Map<String, String>> files;
|
||||
|
||||
GHGistUpdater(GHGist base) {
|
||||
this.base = base;
|
||||
@@ -32,16 +35,15 @@ public class GHGistUpdater {
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGistUpdater addFile(String fileName, String content) throws IOException {
|
||||
public GHGistUpdater addFile(@Nonnull String fileName, @Nonnull String content) throws IOException {
|
||||
updateFile(fileName, content);
|
||||
return this;
|
||||
}
|
||||
|
||||
// // This method does not work.
|
||||
// public GHGistUpdater deleteFile(String fileName) throws IOException {
|
||||
// files.put(fileName, Collections.singletonMap("filename", null));
|
||||
// return this;
|
||||
// }
|
||||
public GHGistUpdater deleteFile(@Nonnull String fileName) throws IOException {
|
||||
files.put(fileName, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename file gh gist updater.
|
||||
@@ -54,8 +56,9 @@ public class GHGistUpdater {
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGistUpdater renameFile(String fileName, String newFileName) throws IOException {
|
||||
files.put(fileName, Collections.singletonMap("filename", newFileName));
|
||||
public GHGistUpdater renameFile(@Nonnull String fileName, @Nonnull String newFileName) throws IOException {
|
||||
Map<String, String> file = files.computeIfAbsent(fileName, d -> new HashMap<>());
|
||||
file.put("filename", newFileName);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -70,8 +73,31 @@ public class GHGistUpdater {
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGistUpdater updateFile(String fileName, String content) throws IOException {
|
||||
files.put(fileName, Collections.singletonMap("content", content));
|
||||
public GHGistUpdater updateFile(@Nonnull String fileName, @Nonnull String content) throws IOException {
|
||||
Map<String, String> file = files.computeIfAbsent(fileName, d -> new HashMap<>());
|
||||
file.put("content", content);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update file name and content
|
||||
*
|
||||
* @param fileName
|
||||
* the file name
|
||||
* @param newFileName
|
||||
* the new file name
|
||||
* @param content
|
||||
* the content
|
||||
* @return the gh gist updater
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGistUpdater updateFile(@Nonnull String fileName, @Nonnull String newFileName, @Nonnull String content)
|
||||
throws IOException {
|
||||
Map<String, String> file = files.computeIfAbsent(fileName, d -> new HashMap<>());
|
||||
file.put("content", content);
|
||||
file.put("filename", newFileName);
|
||||
files.put(fileName, file);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -37,8 +37,9 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
|
||||
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||
|
||||
/**
|
||||
* Represents an issue on GitHub.
|
||||
@@ -52,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
|
||||
@@ -157,10 +157,8 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
* Gets labels.
|
||||
*
|
||||
* @return the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public Collection<GHLabel> getLabels() throws IOException {
|
||||
public Collection<GHLabel> getLabels() {
|
||||
if (labels == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -179,10 +177,12 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
/**
|
||||
* Gets api url.
|
||||
*
|
||||
* @return the api url
|
||||
* @return API URL of this object.
|
||||
* @deprecated use {@link #getUrl()}
|
||||
*/
|
||||
@Deprecated
|
||||
public URL getApiURL() {
|
||||
return GitHubClient.parseURL(url);
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,8 +228,15 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Identical to edit(), but allows null for the value.
|
||||
*/
|
||||
private void editNullable(String key, Object value) throws IOException {
|
||||
root.createRequest().withNullable(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
|
||||
}
|
||||
|
||||
private void editIssue(String key, Object value) throws IOException {
|
||||
root.createRequest().with(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
|
||||
root.createRequest().withNullable(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,15 +284,19 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets milestone.
|
||||
* Sets the milestone for this issue.
|
||||
*
|
||||
* @param milestone
|
||||
* the milestone
|
||||
* The milestone to assign this issue to. Use null to remove the milestone for this issue.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* The io exception
|
||||
*/
|
||||
public void setMilestone(GHMilestone milestone) throws IOException {
|
||||
edit("milestone", milestone.getNumber());
|
||||
if (milestone == null) {
|
||||
editIssue("milestone", null);
|
||||
} else {
|
||||
editIssue("milestone", milestone.getNumber());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,7 +447,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()
|
||||
@@ -448,7 +459,7 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
.wrap(root);
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public PagedIterable<GHReaction> listReactions() {
|
||||
return root.createRequest()
|
||||
@@ -559,7 +570,8 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
protected String getIssuesApiRoute() {
|
||||
if (owner == null) {
|
||||
// Issues returned from search to do not have an owner. Attempt to use url.
|
||||
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
|
||||
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
|
||||
return StringUtils.prependIfMissing(url.toString().replace(root.getApiUrl(), ""), "/");
|
||||
}
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
@@ -149,6 +149,6 @@ public class GHIssueComment extends GHObject implements Reactable {
|
||||
|
||||
private String getApiRoute() {
|
||||
return "/repos/" + owner.getRepository().getOwnerName() + "/" + owner.getRepository().getName()
|
||||
+ "/issues/comments/" + id;
|
||||
+ "/issues/comments/" + getId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.Date;
|
||||
/**
|
||||
* The type GHIssueEvent.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/issues/events/">Github documentation for issue events</a>
|
||||
*
|
||||
* @author Martin van Zijl
|
||||
*/
|
||||
public class GHIssueEvent {
|
||||
private GitHub root;
|
||||
|
||||
public class GHIssueEvent extends GitHubInteractiveObject {
|
||||
private long id;
|
||||
private String node_id;
|
||||
private String url;
|
||||
@@ -18,6 +18,9 @@ public class GHIssueEvent {
|
||||
private String commit_id;
|
||||
private String commit_url;
|
||||
private String created_at;
|
||||
private GHMilestone milestone;
|
||||
private GHLabel label;
|
||||
private GHUser assignee;
|
||||
|
||||
private GHIssue issue;
|
||||
|
||||
@@ -111,6 +114,36 @@ public class GHIssueEvent {
|
||||
return issue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link GHMilestone} that this issue was added to or removed from. Only present for events "milestoned"
|
||||
* and "demilestoned", <code>null</code> otherwise.
|
||||
*
|
||||
* @return the milestone
|
||||
*/
|
||||
public GHMilestone getMilestone() {
|
||||
return milestone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link GHLabel} that was added to or removed from the issue. Only present for events "labeled" and
|
||||
* "unlabeled", <code>null</code> otherwise.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public GHLabel getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link GHUser} that was assigned or unassigned from the issue. Only present for events "assigned" and
|
||||
* "unassigned", <code>null</code> otherwise.
|
||||
*
|
||||
* @return the user
|
||||
*/
|
||||
public GHUser getAssignee() {
|
||||
return assignee;
|
||||
}
|
||||
|
||||
GHIssueEvent wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
|
||||
@@ -31,4 +31,4 @@ package org.kohsuke.github;
|
||||
*/
|
||||
public enum GHIssueState {
|
||||
OPEN, CLOSED, ALL
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,27 +1,53 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* The type GHLabel.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see <a href="https://developer.github.com/v3/issues/labels/">Labels</a>
|
||||
* @see GHIssue#getLabels() GHIssue#getLabels()
|
||||
* @see GHRepository#listLabels() GHRepository#listLabels()
|
||||
*/
|
||||
public class GHLabel {
|
||||
private String url, name, color, description;
|
||||
private GHRepository repo;
|
||||
public class GHLabel extends GitHubInteractiveObject {
|
||||
|
||||
@Nonnull
|
||||
private String url, name, color;
|
||||
|
||||
@CheckForNull
|
||||
private String description;
|
||||
|
||||
@JsonCreator
|
||||
private GHLabel(@JacksonInject @Nonnull GitHub root) {
|
||||
this.root = root;
|
||||
url = "";
|
||||
name = "";
|
||||
color = "";
|
||||
description = null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
GitHub getApiRoot() {
|
||||
return Objects.requireNonNull(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
@Nonnull
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
@@ -31,6 +57,7 @@ public class GHLabel {
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
@Nonnull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -40,6 +67,7 @@ public class GHLabel {
|
||||
*
|
||||
* @return the color
|
||||
*/
|
||||
@Nonnull
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
@@ -49,25 +77,11 @@ public class GHLabel {
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
@CheckForNull
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
GHLabel wrapUp(GHRepository repo) {
|
||||
this.repo = repo;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
repo.root.createRequest().method("DELETE").setRawUrlPath(url).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets color.
|
||||
*
|
||||
@@ -75,15 +89,11 @@ public class GHLabel {
|
||||
* 6-letter hex color code, like "f29513"
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated use {@link #set()} or {@link #update()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setColor(String newColor) throws IOException {
|
||||
repo.root.createRequest()
|
||||
.method("PATCH")
|
||||
.with("name", name)
|
||||
.with("color", newColor)
|
||||
.with("description", description)
|
||||
.setRawUrlPath(url)
|
||||
.send();
|
||||
set().color(newColor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,25 +103,106 @@ public class GHLabel {
|
||||
* Description of label
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated use {@link #set()} or {@link #update()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setDescription(String newDescription) throws IOException {
|
||||
repo.root.createRequest()
|
||||
.method("PATCH")
|
||||
.with("name", name)
|
||||
.with("color", color)
|
||||
.with("description", newDescription)
|
||||
.setRawUrlPath(url)
|
||||
.send();
|
||||
set().description(newDescription);
|
||||
}
|
||||
|
||||
static Collection<String> toNames(Collection<GHLabel> labels) {
|
||||
List<String> r = new ArrayList<String>();
|
||||
List<String> r = new ArrayList<>();
|
||||
for (GHLabel l : labels) {
|
||||
r.add(l.getName());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins the creation of a new instance.
|
||||
*
|
||||
* Consumer must call {@link Creator#done()} to commit changes.
|
||||
*
|
||||
* @param repository
|
||||
* the repository in which the label will be created.
|
||||
* @return a {@link Creator}
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
static Creator create(GHRepository repository) throws IOException {
|
||||
return new Creator(repository);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a label from a repository.
|
||||
*
|
||||
* @param repository
|
||||
* the repository to read from
|
||||
* @param name
|
||||
* the name of the label
|
||||
* @return a label
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
static GHLabel read(@Nonnull GHRepository repository, @Nonnull String name) throws IOException {
|
||||
return repository.root.createRequest()
|
||||
.withUrlPath(repository.getApiTailUrl("labels"), name)
|
||||
.fetch(GHLabel.class);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads all labels from a repository.
|
||||
*
|
||||
* @param repository
|
||||
* the repository to read from
|
||||
* @return iterable of all labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
static PagedIterable<GHLabel> readAll(@Nonnull final GHRepository repository) throws IOException {
|
||||
return repository.root.createRequest()
|
||||
.withUrlPath(repository.getApiTailUrl("labels"))
|
||||
.toIterable(GHLabel[].class, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins a batch update
|
||||
*
|
||||
* Consumer must call {@link Updater#done()} to commit changes.
|
||||
*
|
||||
* @return a {@link Updater}
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public Updater update() {
|
||||
return new Updater(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins a single property update.
|
||||
*
|
||||
* @return a {@link Setter}
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public Setter set() {
|
||||
return new Setter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete this label from the repository.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
root.createRequest().method("DELETE").setRawUrlPath(getUrl()).send();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o)
|
||||
@@ -120,11 +211,54 @@ public class GHLabel {
|
||||
return false;
|
||||
final GHLabel ghLabel = (GHLabel) o;
|
||||
return Objects.equals(url, ghLabel.url) && Objects.equals(name, ghLabel.name)
|
||||
&& Objects.equals(color, ghLabel.color) && Objects.equals(repo, ghLabel.repo);
|
||||
&& Objects.equals(color, ghLabel.color) && Objects.equals(description, ghLabel.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(url, name, color, repo);
|
||||
return Objects.hash(url, name, color, description);
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link GHLabelBuilder} that updates a single property per request
|
||||
*
|
||||
* {@link #done()} is called automatically after the property is set.
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public static class Setter extends GHLabelBuilder<GHLabel> {
|
||||
private Setter(@Nonnull GHLabel base) {
|
||||
super(GHLabel.class, base.getApiRoot(), base);
|
||||
requester.method("PATCH").setRawUrlPath(base.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link GHLabelBuilder} that allows multiple properties to be updated per request.
|
||||
*
|
||||
* Consumer must call {@link #done()} to commit changes.
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public static class Updater extends GHLabelBuilder<Updater> {
|
||||
private Updater(@Nonnull GHLabel base) {
|
||||
super(Updater.class, base.getApiRoot(), base);
|
||||
requester.method("PATCH").setRawUrlPath(base.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link GHLabelBuilder} that creates a new {@link GHLabel}
|
||||
*
|
||||
* Consumer must call {@link #done()} to create the new instance.
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public static class Creator extends GHLabelBuilder<Creator> {
|
||||
private Creator(@Nonnull GHRepository repository) {
|
||||
super(Creator.class, repository.root, null);
|
||||
requester.method("POST").withUrlPath(repository.getApiTailUrl("labels"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
60
src/main/java/org/kohsuke/github/GHLabelBuilder.java
Normal file
60
src/main/java/org/kohsuke/github/GHLabelBuilder.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param <S>
|
||||
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S}
|
||||
* the same as {@link GHLabel}, this builder will commit changes after each call to
|
||||
* {@link #with(String, Object)}.
|
||||
*/
|
||||
class GHLabelBuilder<S> extends AbstractBuilder<GHLabel, S> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param intermediateReturnType
|
||||
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If
|
||||
* {@link S} the same as {@link GHLabel}, this builder will commit changes after each call to
|
||||
* {@link #with(String, Object)}.
|
||||
* @param root
|
||||
* the GitHub instance to which updates will be sent
|
||||
* @param baseInstance
|
||||
* instance on which to base this builder. If {@code null} a new instance will be created.
|
||||
*/
|
||||
protected GHLabelBuilder(@Nonnull Class<S> intermediateReturnType,
|
||||
@Nonnull GitHub root,
|
||||
@CheckForNull GHLabel baseInstance) {
|
||||
super(GHLabel.class, intermediateReturnType, root, baseInstance);
|
||||
|
||||
if (baseInstance != null) {
|
||||
requester.with("name", baseInstance.getName());
|
||||
requester.with("color", baseInstance.getColor());
|
||||
requester.with("description", baseInstance.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public S name(String value) throws IOException {
|
||||
return with("name", value);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public S color(String value) throws IOException {
|
||||
return with("color", value);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public S description(String value) throws IOException {
|
||||
return with("description", value);
|
||||
}
|
||||
}
|
||||
@@ -24,13 +24,13 @@
|
||||
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The GitHub Preview API's license information
|
||||
@@ -44,9 +44,6 @@ import java.util.List;
|
||||
@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;
|
||||
@@ -78,14 +75,6 @@ public class GHLicense extends GHObject {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return API URL of this object.
|
||||
*/
|
||||
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
||||
public URL getUrl() {
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Featured licenses are bold in the new repository drop-down
|
||||
*
|
||||
@@ -199,7 +188,14 @@ public class GHLicense extends GHObject {
|
||||
if (description != null)
|
||||
return; // already populated
|
||||
|
||||
root.createRequest().withUrlPath(url).fetchInto(this);
|
||||
if (root == null || root.isOffline()) {
|
||||
return; // cannot populate, will have to live with what we have
|
||||
}
|
||||
|
||||
URL url = getUrl();
|
||||
if (url != null) {
|
||||
root.createRequest().setRawUrlPath(url.toString()).fetchInto(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,12 +206,12 @@ public class GHLicense extends GHObject {
|
||||
return false;
|
||||
|
||||
GHLicense that = (GHLicense) o;
|
||||
return this.url.equals(that.url);
|
||||
return Objects.equals(getUrl(), that.getUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return url.hashCode();
|
||||
return Objects.hashCode(getUrl());
|
||||
}
|
||||
|
||||
GHLicense wrap(GitHub root) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -11,7 +11,6 @@ import java.util.Locale;
|
||||
* @author Yusuke Kokubo
|
||||
*/
|
||||
public class GHMilestone extends GHObject {
|
||||
GitHub root;
|
||||
GHRepository owner;
|
||||
|
||||
GHUser creator;
|
||||
|
||||
@@ -7,4 +7,4 @@ package org.kohsuke.github;
|
||||
*/
|
||||
public enum GHMilestoneState {
|
||||
OPEN, CLOSED
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -20,23 +20,25 @@ 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.
|
||||
*/
|
||||
protected Map<String, List<String>> responseHeaderFields;
|
||||
protected transient Map<String, List<String>> responseHeaderFields;
|
||||
|
||||
protected String url;
|
||||
protected long id;
|
||||
protected String created_at;
|
||||
protected String updated_at;
|
||||
private String url;
|
||||
|
||||
private long id;
|
||||
private String nodeId;
|
||||
private String createdAt;
|
||||
private String updatedAt;
|
||||
|
||||
GHObject() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by Jackson
|
||||
*
|
||||
*
|
||||
* @param responseInfo
|
||||
* the {@link GitHubResponse.ResponseInfo} to get headers from.
|
||||
*/
|
||||
@@ -74,12 +76,12 @@ public abstract class GHObject {
|
||||
*/
|
||||
@WithBridgeMethods(value = String.class, adapterMethod = "createdAtStr")
|
||||
public Date getCreatedAt() throws IOException {
|
||||
return GitHubClient.parseDate(created_at);
|
||||
return GitHubClient.parseDate(createdAt);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getCreatedAt")
|
||||
private Object createdAtStr(Date id, Class type) {
|
||||
return created_at;
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +112,18 @@ public abstract class GHObject {
|
||||
* on error
|
||||
*/
|
||||
public Date getUpdatedAt() throws IOException {
|
||||
return GitHubClient.parseDate(updated_at);
|
||||
return GitHubClient.parseDate(updatedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Global node_id from Github object.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v4/guides/using-global-node-ids/">Using Global Node IDs</a>
|
||||
*
|
||||
* @return Global Node ID.
|
||||
*/
|
||||
public String getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,6 @@ class GHOrgHook extends GHHook {
|
||||
|
||||
@Override
|
||||
String getApiRoute() {
|
||||
return String.format("/orgs/%s/hooks/%d", organization.getLogin(), id);
|
||||
return String.format("/orgs/%s/hooks/%d", organization.getLogin(), getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,6 +128,40 @@ public class GHOrganization extends GHPerson {
|
||||
.toIterable(GHTeam[].class, item -> item.wrapUp(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single team by ID.
|
||||
*
|
||||
* @param teamId
|
||||
* id of the team that we want to query for
|
||||
* @return the team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*
|
||||
* @deprecated Use {@link GHOrganization#getTeam(long)}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHTeam getTeam(int teamId) throws IOException {
|
||||
return getTeam((long) teamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single team by ID.
|
||||
*
|
||||
* @param teamId
|
||||
* id of the team that we want to query for
|
||||
* @return the team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*
|
||||
* @see <a href= "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
|
||||
*/
|
||||
public GHTeam getTeam(long teamId) throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/organizations/%d/team/%d", getId(), teamId))
|
||||
.fetch(GHTeam.class)
|
||||
.wrapUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a team that has the given name in its {@link GHTeam#getName()}
|
||||
*
|
||||
@@ -153,13 +187,13 @@ public class GHOrganization extends GHPerson {
|
||||
* @return the team by slug
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see <a href= "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
|
||||
*/
|
||||
public GHTeam getTeamBySlug(String slug) throws IOException {
|
||||
for (GHTeam t : listTeams()) {
|
||||
if (t.getSlug().equals(slug))
|
||||
return t;
|
||||
}
|
||||
return null;
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/orgs/%s/teams/%s", login, slug))
|
||||
.fetch(GHTeam.class)
|
||||
.wrapUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,7 +421,7 @@ public class GHOrganization extends GHPerson {
|
||||
* The enum Permission.
|
||||
*/
|
||||
public enum Permission {
|
||||
ADMIN, PUSH, PULL
|
||||
ADMIN, MAINTAIN, PUSH, TRIAGE, PULL
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -18,16 +18,15 @@ 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;
|
||||
|
||||
// other fields (that only show up in full data)
|
||||
protected String location, blog, email, name, company, type;
|
||||
protected String location, blog, email, bio, name, company, type, twitter_username;
|
||||
protected String html_url;
|
||||
protected int followers, following, public_repos, public_gists;
|
||||
protected boolean site_admin;
|
||||
protected boolean site_admin, hireable;
|
||||
|
||||
// other fields (that only show up in full data) that require privileged scope
|
||||
protected Integer total_private_repos;
|
||||
@@ -46,13 +45,16 @@ public abstract class GHPerson extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
protected synchronized void populate() throws IOException {
|
||||
if (created_at != null) {
|
||||
if (super.getCreatedAt() != null) {
|
||||
return; // already populated
|
||||
}
|
||||
if (root == null || root.isOffline()) {
|
||||
return; // cannot populate, will have to live with what we have
|
||||
}
|
||||
root.createRequest().withUrlPath(url).fetchInto(this);
|
||||
URL url = getUrl();
|
||||
if (url != null) {
|
||||
root.createRequest().setRawUrlPath(url.toString()).fetchInto(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,10 +153,7 @@ public abstract class GHPerson extends GHObject {
|
||||
*/
|
||||
public GHRepository getRepository(String name) throws IOException {
|
||||
try {
|
||||
return root.createRequest()
|
||||
.withUrlPath("/repos/" + login + '/' + name)
|
||||
.fetch(GHRepository.class)
|
||||
.wrap(root);
|
||||
return GHRepository.read(root, login, name);
|
||||
} catch (FileNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -234,6 +233,18 @@ public abstract class GHPerson extends GHObject {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Twitter Username of this user, like "GitHub"
|
||||
*
|
||||
* @return the Twitter username
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public String getTwitterUsername() throws IOException {
|
||||
populate();
|
||||
return twitter_username;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() throws IOException {
|
||||
populate();
|
||||
return super.getCreatedAt();
|
||||
|
||||
@@ -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,12 +37,10 @@ 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;
|
||||
private String html_url;
|
||||
private String node_id;
|
||||
private String name;
|
||||
private String body;
|
||||
private int number;
|
||||
@@ -81,10 +79,8 @@ public class GHProject extends GHObject {
|
||||
} else if (owner_url.contains("/users/")) {
|
||||
owner = root.createRequest().withUrlPath(getOwnerUrl().getPath()).fetch(GHUser.class).wrapUp(root);
|
||||
} else if (owner_url.contains("/repos/")) {
|
||||
owner = root.createRequest()
|
||||
.withUrlPath(getOwnerUrl().getPath())
|
||||
.fetch(GHRepository.class)
|
||||
.wrap(root);
|
||||
String[] pathElements = getOwnerUrl().getPath().split("/");
|
||||
owner = GHRepository.read(root, pathElements[1], pathElements[2]);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
return null;
|
||||
@@ -105,10 +101,12 @@ public class GHProject extends GHObject {
|
||||
/**
|
||||
* Gets node id.
|
||||
*
|
||||
* @deprecated Use {@link GHObject#getNodeId()}
|
||||
* @return the node id
|
||||
*/
|
||||
@Deprecated
|
||||
public String getNode_id() {
|
||||
return node_id;
|
||||
return getNodeId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,7 +189,7 @@ public class GHProject extends GHObject {
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return "/projects/" + id;
|
||||
return "/projects/" + getId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,7 +288,7 @@ public class GHProject extends GHObject {
|
||||
final GHProject project = this;
|
||||
return root.createRequest()
|
||||
.withPreview(INERTIA)
|
||||
.withUrlPath(String.format("/projects/%d/columns", id))
|
||||
.withUrlPath(String.format("/projects/%d/columns", getId()))
|
||||
.toIterable(GHProjectColumn[].class, item -> item.wrap(project));
|
||||
}
|
||||
|
||||
@@ -308,8 +306,8 @@ public class GHProject extends GHObject {
|
||||
.method("POST")
|
||||
.withPreview(INERTIA)
|
||||
.with("name", name)
|
||||
.withUrlPath(String.format("/projects/%d/columns", id))
|
||||
.withUrlPath(String.format("/projects/%d/columns", getId()))
|
||||
.fetch(GHProjectColumn.class)
|
||||
.wrap(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -213,7 +212,7 @@ public class GHProjectCard extends GHObject {
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return String.format("/projects/columns/cards/%d", id);
|
||||
return String.format("/projects/columns/cards/%d", getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
@@ -115,7 +114,7 @@ public class GHProjectColumn extends GHObject {
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return String.format("/projects/columns/%d", id);
|
||||
return String.format("/projects/columns/%d", getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +138,7 @@ public class GHProjectColumn extends GHObject {
|
||||
final GHProjectColumn column = this;
|
||||
return root.createRequest()
|
||||
.withPreview(INERTIA)
|
||||
.withUrlPath(String.format("/projects/columns/%d/cards", id))
|
||||
.withUrlPath(String.format("/projects/columns/%d/cards", getId()))
|
||||
.toIterable(GHProjectCard[].class, item -> item.wrap(column));
|
||||
}
|
||||
|
||||
@@ -157,7 +156,7 @@ public class GHProjectColumn extends GHObject {
|
||||
.method("POST")
|
||||
.withPreview(INERTIA)
|
||||
.with("note", note)
|
||||
.withUrlPath(String.format("/projects/columns/%d/cards", id))
|
||||
.withUrlPath(String.format("/projects/columns/%d/cards", getId()))
|
||||
.fetch(GHProjectCard.class)
|
||||
.wrap(this);
|
||||
}
|
||||
@@ -177,7 +176,7 @@ public class GHProjectColumn extends GHObject {
|
||||
.withPreview(INERTIA)
|
||||
.with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue")
|
||||
.with("content_id", issue.getId())
|
||||
.withUrlPath(String.format("/projects/columns/%d/cards", id))
|
||||
.withUrlPath(String.format("/projects/columns/%d/cards", getId()))
|
||||
.fetch(GHProjectCard.class)
|
||||
.wrap(this);
|
||||
}
|
||||
|
||||
@@ -29,14 +29,15 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
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.
|
||||
@@ -71,13 +72,6 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
private GHUser[] requested_reviewers;
|
||||
private GHTeam[] requested_teams;
|
||||
|
||||
/**
|
||||
* GitHub doesn't return some properties of {@link GHIssue} when requesting the GET on the 'pulls' API route as
|
||||
* opposed to 'issues' API route. This flag remembers whether we made the GET call on the 'issues' route on this
|
||||
* object to fill in those missing details
|
||||
*/
|
||||
private transient boolean fetchedIssueDetails;
|
||||
|
||||
GHPullRequest wrapUp(GHRepository owner) {
|
||||
this.wrap(owner);
|
||||
return wrapUp(owner.root);
|
||||
@@ -103,7 +97,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
protected String getApiRoute() {
|
||||
if (owner == null) {
|
||||
// Issues returned from search to do not have an owner. Attempt to use url.
|
||||
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
|
||||
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
|
||||
return StringUtils.prependIfMissing(url.toString().replace(root.getApiUrl(), ""), "/");
|
||||
|
||||
}
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/pulls/" + number;
|
||||
}
|
||||
@@ -174,12 +170,6 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
return GitHubClient.parseDate(merged_at);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<GHLabel> getLabels() throws IOException {
|
||||
fetchIssue();
|
||||
return super.getLabels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GHUser getClosedBy() {
|
||||
return null;
|
||||
@@ -387,10 +377,14 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
* Repopulates this object.
|
||||
*/
|
||||
public void refresh() throws IOException {
|
||||
if (root.isOffline()) {
|
||||
if (root == null || root.isOffline()) {
|
||||
return; // cannot populate, will have to live with what we have
|
||||
}
|
||||
root.createRequest().withPreview(SHADOW_CAT).withUrlPath(url).fetchInto(this).wrapUp(owner);
|
||||
|
||||
URL url = getUrl();
|
||||
if (url != null) {
|
||||
root.createRequest().withPreview(SHADOW_CAT).setRawUrlPath(url.toString()).fetchInto(this).wrapUp(owner);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -558,6 +552,41 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the base branch on the pull request
|
||||
*
|
||||
* @param newBaseBranch
|
||||
* the name of the new base branch
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @return the updated pull request
|
||||
*/
|
||||
public GHPullRequest setBaseBranch(String newBaseBranch) throws IOException {
|
||||
return root.createRequest()
|
||||
.method("PATCH")
|
||||
.with("base", newBaseBranch)
|
||||
.withUrlPath(getApiRoute())
|
||||
.fetch(GHPullRequest.class)
|
||||
.wrapUp(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the branch. The same as pressing the button in the web GUI.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Preview(LYDIAN)
|
||||
@Deprecated
|
||||
public void updateBranch() throws IOException {
|
||||
root.createRequest()
|
||||
.withPreview(LYDIAN)
|
||||
.method("PUT")
|
||||
.with("expected_head_sha", head.getSha())
|
||||
.withUrlPath(getApiRoute() + "/update-branch")
|
||||
.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge this pull request.
|
||||
* <p>
|
||||
@@ -619,10 +648,4 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
MERGE, SQUASH, REBASE
|
||||
}
|
||||
|
||||
private void fetchIssue() throws IOException {
|
||||
if (!fetchedIssueDetails) {
|
||||
root.createRequest().withUrlPath(getIssuesApiRoute()).fetchInto(this);
|
||||
fetchedIssueDetails = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
86
src/main/java/org/kohsuke/github/GHPullRequestChanges.java
Normal file
86
src/main/java/org/kohsuke/github/GHPullRequestChanges.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
/**
|
||||
* Wrapper to define changed fields on pull_request action="edited"
|
||||
*
|
||||
* @see GHEventPayload.PullRequest
|
||||
*/
|
||||
@SuppressFBWarnings("UWF_UNWRITTEN_FIELD")
|
||||
public class GHPullRequestChanges {
|
||||
|
||||
private GHCommitPointer base;
|
||||
private GHFrom title;
|
||||
private GHFrom body;
|
||||
|
||||
/**
|
||||
* Old target branch for pull request.
|
||||
*
|
||||
* @return old target branch info (or null if not changed)
|
||||
*/
|
||||
public GHCommitPointer getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Old pull request title.
|
||||
*
|
||||
* @return old pull request title (or null if not changed)
|
||||
*/
|
||||
public GHFrom getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Old pull request body.
|
||||
*
|
||||
* @return old pull request body (or null if not changed)
|
||||
*/
|
||||
public GHFrom getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.kohsuke.github.GHCommitPointer
|
||||
*/
|
||||
public static class GHCommitPointer {
|
||||
private GHFrom ref;
|
||||
private GHFrom sha;
|
||||
|
||||
/**
|
||||
* Named ref to the commit. This (from value) appears to be a "short ref" that doesn't include "refs/heads/"
|
||||
* portion.
|
||||
*
|
||||
* @return the ref
|
||||
*/
|
||||
public GHFrom getRef() {
|
||||
return ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA1 of the commit.
|
||||
*
|
||||
* @return sha
|
||||
*/
|
||||
public GHFrom getSha() {
|
||||
return sha;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for changed values.
|
||||
*/
|
||||
public static class GHFrom {
|
||||
private String from;
|
||||
|
||||
/**
|
||||
* Previous value that was changed.
|
||||
*
|
||||
* @return previous value
|
||||
*/
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -46,6 +46,7 @@ public class GHPullRequestReview extends GHObject {
|
||||
private String commit_id;
|
||||
private GHPullRequestReviewState state;
|
||||
private String submitted_at;
|
||||
private String html_url;
|
||||
|
||||
GHPullRequestReview wrapUp(GHPullRequest owner) {
|
||||
this.owner = owner;
|
||||
@@ -102,7 +103,7 @@ public class GHPullRequestReview extends GHObject {
|
||||
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return null;
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +112,7 @@ public class GHPullRequestReview extends GHObject {
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return owner.getApiRoute() + "/reviews/" + id;
|
||||
return owner.getApiRoute() + "/reviews/" + getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
@@ -44,6 +44,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
|
||||
private String body;
|
||||
private GHUser user;
|
||||
private String path;
|
||||
private String html_url;
|
||||
private int position = -1;
|
||||
private int original_position = -1;
|
||||
private long in_reply_to_id = -1L;
|
||||
@@ -143,7 +144,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
|
||||
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return null;
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +153,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return "/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + id;
|
||||
return "/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + getId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,7 +198,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
|
||||
.wrapUp(owner);
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public GHReaction createReaction(ReactionContent content) throws IOException {
|
||||
return owner.root.createRequest()
|
||||
@@ -209,7 +210,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
|
||||
.wrap(owner.root);
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public PagedIterable<GHReaction> listReactions() {
|
||||
return owner.root.createRequest()
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
@@ -29,7 +30,7 @@ public class GHRateLimit {
|
||||
/**
|
||||
* Remaining calls that can be made.
|
||||
*
|
||||
* @deprecated This value should never have been made public. Use {@link #getRemaining()}
|
||||
* @deprecated This field should never have been made public. Use {@link #getRemaining()}
|
||||
*/
|
||||
@Deprecated
|
||||
public int remaining;
|
||||
@@ -37,7 +38,7 @@ public class GHRateLimit {
|
||||
/**
|
||||
* Allotted API call per hour.
|
||||
*
|
||||
* @deprecated This value should never have been made public. Use {@link #getLimit()}
|
||||
* @deprecated This field should never have been made public. Use {@link #getLimit()}
|
||||
*/
|
||||
@Deprecated
|
||||
public int limit;
|
||||
@@ -48,7 +49,7 @@ public class GHRateLimit {
|
||||
* date. To use this field in any meaningful way, it must be converted to a long using {@link Date#getTime()}
|
||||
* multiplied by 1000.
|
||||
*
|
||||
* @deprecated This value should never have been made public. Use {@link #getResetDate()}
|
||||
* @deprecated This field should never have been made public. Use {@link #getResetDate()}
|
||||
*/
|
||||
@Deprecated
|
||||
public Date reset;
|
||||
@@ -65,17 +66,58 @@ public class GHRateLimit {
|
||||
@Nonnull
|
||||
private final Record integrationManifest;
|
||||
|
||||
/**
|
||||
* The default GHRateLimit provided to new {@link GitHubClient}s.
|
||||
*
|
||||
* Contains all expired records that will cause {@link GitHubClient#rateLimit(RateLimitTarget)} to refresh with new
|
||||
* data when called.
|
||||
*
|
||||
* Private, but made internal for testing.
|
||||
*/
|
||||
@Nonnull
|
||||
static GHRateLimit Unknown() {
|
||||
return new GHRateLimit(new UnknownLimitRecord(),
|
||||
new UnknownLimitRecord(),
|
||||
new UnknownLimitRecord(),
|
||||
new UnknownLimitRecord());
|
||||
}
|
||||
static final GHRateLimit DEFAULT = new GHRateLimit(UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT);
|
||||
|
||||
/**
|
||||
* Creates a new {@link GHRateLimit} from a single record for the specified endpoint with place holders for other
|
||||
* records.
|
||||
*
|
||||
* This is used to create {@link GHRateLimit} instances that can merged with other instances.
|
||||
*
|
||||
* @param record
|
||||
* the rate limit record. Can be a regular {@link Record} constructed from header information or an
|
||||
* {@link UnknownLimitRecord} placeholder.
|
||||
* @param rateLimitTarget
|
||||
* which rate limit record to fill
|
||||
* @return a new {@link GHRateLimit} instance containing the supplied record
|
||||
*/
|
||||
@Nonnull
|
||||
static GHRateLimit fromHeaderRecord(Record header) {
|
||||
return new GHRateLimit(header, new UnknownLimitRecord(), new UnknownLimitRecord(), new UnknownLimitRecord());
|
||||
static GHRateLimit fromRecord(@Nonnull Record record, @Nonnull RateLimitTarget rateLimitTarget) {
|
||||
if (rateLimitTarget == RateLimitTarget.CORE || rateLimitTarget == RateLimitTarget.NONE) {
|
||||
return new GHRateLimit(record,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT);
|
||||
} else if (rateLimitTarget == RateLimitTarget.SEARCH) {
|
||||
return new GHRateLimit(UnknownLimitRecord.DEFAULT,
|
||||
record,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT);
|
||||
} else if (rateLimitTarget == RateLimitTarget.GRAPHQL) {
|
||||
return new GHRateLimit(UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
record,
|
||||
UnknownLimitRecord.DEFAULT);
|
||||
} else if (rateLimitTarget == RateLimitTarget.INTEGRATION_MANIFEST) {
|
||||
return new GHRateLimit(UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
UnknownLimitRecord.DEFAULT,
|
||||
record);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown rate limit target: " + rateLimitTarget.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
@@ -142,7 +184,7 @@ public class GHRateLimit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the rate limit reset date for this instance has passed.
|
||||
* Whether the reset date for the Core API rate limit has passed.
|
||||
*
|
||||
* @return true if the rate limit reset date has passed. Otherwise false.
|
||||
* @since 1.100
|
||||
@@ -152,7 +194,7 @@ public class GHRateLimit {
|
||||
}
|
||||
|
||||
/**
|
||||
* The core object provides your rate limit status for all non-search-related resources in the REST API.
|
||||
* The core object provides the rate limit status for all non-search-related resources in the REST API.
|
||||
*
|
||||
* @return a rate limit record
|
||||
* @since 1.100
|
||||
@@ -163,42 +205,43 @@ public class GHRateLimit {
|
||||
}
|
||||
|
||||
/**
|
||||
* The search object provides your rate limit status for the Search API. TODO: integrate with header limit updating.
|
||||
* Issue #605.
|
||||
* The search record provides the rate limit status for the Search API.
|
||||
*
|
||||
* @return a rate limit record
|
||||
* @since 1.115
|
||||
*/
|
||||
@Nonnull
|
||||
Record getSearch() {
|
||||
public Record getSearch() {
|
||||
return search;
|
||||
}
|
||||
|
||||
/**
|
||||
* The graphql object provides your rate limit status for the GraphQL API. TODO: integrate with header limit
|
||||
* updating. Issue #605.
|
||||
* The graphql record provides the rate limit status for the GraphQL API.
|
||||
*
|
||||
* @return a rate limit record
|
||||
* @since 1.115
|
||||
*/
|
||||
@Nonnull
|
||||
Record getGraphQL() {
|
||||
public Record getGraphQL() {
|
||||
return graphql;
|
||||
}
|
||||
|
||||
/**
|
||||
* The integration_manifest object provides your rate limit status for the GitHub App Manifest code conversion
|
||||
* endpoint. TODO: integrate with header limit updating. Issue #605.
|
||||
* The integration manifest record provides the rate limit status for the GitHub App Manifest code conversion
|
||||
* endpoint.
|
||||
*
|
||||
* @return a rate limit record
|
||||
* @since 1.115
|
||||
*/
|
||||
@Nonnull
|
||||
Record getIntegrationManifest() {
|
||||
public Record getIntegrationManifest() {
|
||||
return integrationManifest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GHRateLimit {" + "core " + getCore().toString() + "search " + getSearch().toString() + "graphql "
|
||||
+ getGraphQL().toString() + "integrationManifest " + getIntegrationManifest().toString() + '}';
|
||||
return "GHRateLimit {" + "core " + getCore().toString() + ", search " + getSearch().toString() + ", graphql "
|
||||
+ getGraphQL().toString() + ", integrationManifest " + getIntegrationManifest().toString() + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,44 +264,111 @@ public class GHRateLimit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the appropriate {@link Record} for a particular url path.
|
||||
* Merge a {@link GHRateLimit} with another one to create a new {@link GHRateLimit} keeping the latest
|
||||
* {@link Record}s from each.
|
||||
*
|
||||
* @param urlPath
|
||||
* the url path of the request
|
||||
* @return the {@link Record} for a url path.
|
||||
* @param newLimit
|
||||
* {@link GHRateLimit} with potentially updated {@link Record}s.
|
||||
* @return a merged {@link GHRateLimit} with the latest {@link Record}s from these two instances. If the merged
|
||||
* instance is equal to the current instance, the current instance is returned.
|
||||
*/
|
||||
@Nonnull
|
||||
Record getRecordForUrlPath(@Nonnull String urlPath) {
|
||||
if (urlPath.equals("/rate_limit")) {
|
||||
return new UnknownLimitRecord();
|
||||
} else if (urlPath.startsWith("/search")) {
|
||||
return getSearch();
|
||||
} else if (urlPath.startsWith("/graphql")) {
|
||||
return getGraphQL();
|
||||
} else if (urlPath.startsWith("/app-manifests")) {
|
||||
return getIntegrationManifest();
|
||||
} else {
|
||||
GHRateLimit getMergedRateLimit(@Nonnull GHRateLimit newLimit) {
|
||||
|
||||
GHRateLimit merged = new GHRateLimit(getCore().currentOrUpdated(newLimit.getCore()),
|
||||
getSearch().currentOrUpdated(newLimit.getSearch()),
|
||||
getGraphQL().currentOrUpdated(newLimit.getGraphQL()),
|
||||
getIntegrationManifest().currentOrUpdated(newLimit.getIntegrationManifest()));
|
||||
|
||||
if (merged.equals(this)) {
|
||||
merged = this;
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the specified {@link Record}.
|
||||
*
|
||||
* {@link RateLimitTarget#NONE} will return {@link UnknownLimitRecord#DEFAULT} to prevent any clients from
|
||||
* accidentally waiting on that record to reset before continuing.
|
||||
*
|
||||
* @param rateLimitTarget
|
||||
* the target rate limit record
|
||||
* @return the target {@link Record} from this instance.
|
||||
*/
|
||||
@Nonnull
|
||||
Record getRecord(@Nonnull RateLimitTarget rateLimitTarget) {
|
||||
if (rateLimitTarget == RateLimitTarget.CORE) {
|
||||
return getCore();
|
||||
} else if (rateLimitTarget == RateLimitTarget.SEARCH) {
|
||||
return getSearch();
|
||||
} else if (rateLimitTarget == RateLimitTarget.GRAPHQL) {
|
||||
return getGraphQL();
|
||||
} else if (rateLimitTarget == RateLimitTarget.INTEGRATION_MANIFEST) {
|
||||
return getIntegrationManifest();
|
||||
} else if (rateLimitTarget == RateLimitTarget.NONE) {
|
||||
return UnknownLimitRecord.DEFAULT;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown rate limit target: " + rateLimitTarget.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A limit record used as a placeholder when the the actual limit is not known.
|
||||
* <p>
|
||||
* Has a large limit and long duration so that it will doesn't expire too often.
|
||||
*
|
||||
* @since 1.100
|
||||
*/
|
||||
public static class UnknownLimitRecord extends Record {
|
||||
|
||||
// One hour
|
||||
private static final long unknownLimitResetSeconds = 60L * 60L;
|
||||
private static final long defaultUnknownLimitResetSeconds = Duration.ofSeconds(30).getSeconds();
|
||||
|
||||
/**
|
||||
* The number of seconds until a {@link UnknownLimitRecord} will expire.
|
||||
*
|
||||
* This is set to a somewhat short duration, rather than a long one. This avoids
|
||||
* {@link {@link GitHubClient#rateLimit(RateLimitTarget)}} requesting rate limit updates continuously, but also
|
||||
* avoids holding on to stale unknown records indefinitely.
|
||||
*
|
||||
* When merging {@link GHRateLimit} instances, {@link UnknownLimitRecord}s will be superseded by incoming
|
||||
* regular {@link Record}s.
|
||||
*
|
||||
* @see GHRateLimit#getMergedRateLimit(GHRateLimit)
|
||||
*/
|
||||
static long unknownLimitResetSeconds = defaultUnknownLimitResetSeconds;
|
||||
|
||||
static final int unknownLimit = 1000000;
|
||||
static final int unknownRemaining = 999999;
|
||||
|
||||
private UnknownLimitRecord() {
|
||||
super(unknownLimit, unknownRemaining, System.currentTimeMillis() / 1000L + unknownLimitResetSeconds);
|
||||
// The default UnknownLimitRecord is an expired record.
|
||||
private static final UnknownLimitRecord DEFAULT = new UnknownLimitRecord(Long.MIN_VALUE);
|
||||
|
||||
// The starting current UnknownLimitRecord is an expired record.
|
||||
private static UnknownLimitRecord current = DEFAULT;
|
||||
|
||||
/**
|
||||
* Create a new unknown record that resets at the specified time.
|
||||
*
|
||||
* @param resetEpochSeconds
|
||||
* the epoch second time when this record will expire.
|
||||
*/
|
||||
private UnknownLimitRecord(long resetEpochSeconds) {
|
||||
super(unknownLimit, unknownRemaining, resetEpochSeconds);
|
||||
}
|
||||
|
||||
static synchronized Record current() {
|
||||
if (current.isExpired()) {
|
||||
current = new UnknownLimitRecord(System.currentTimeMillis() / 1000L + unknownLimitResetSeconds);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the current UnknownLimitRecord. For use during testing only.
|
||||
*/
|
||||
static synchronized void reset() {
|
||||
current = DEFAULT;
|
||||
unknownLimitResetSeconds = defaultUnknownLimitResetSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,14 +384,12 @@ public class GHRateLimit {
|
||||
private final int remaining;
|
||||
|
||||
/**
|
||||
* Allotted API call per hour.
|
||||
* Allotted API call per time period.
|
||||
*/
|
||||
private final int limit;
|
||||
|
||||
/**
|
||||
* The time at which the current rate limit window resets in UTC epoch seconds.
|
||||
*
|
||||
* This is the raw value returned by the server.
|
||||
*/
|
||||
private final long resetEpochSeconds;
|
||||
|
||||
@@ -291,9 +399,11 @@ public class GHRateLimit {
|
||||
private final long createdAtEpochSeconds = System.currentTimeMillis() / 1000;
|
||||
|
||||
/**
|
||||
* The time at which the rate limit will reset. This value is calculated based on
|
||||
* {@link #getResetEpochSeconds()} by calling {@link #calculateResetDate}. If the clock on the local machine not
|
||||
* synchronized with the server clock, this time value will be adjusted to match the local machine's clock.
|
||||
* The date at which the rate limit will reset, adjusted to local machine time if the local machine's clock not
|
||||
* synchronized with to the same clock as the GitHub server.
|
||||
*
|
||||
* @see #calculateResetDate(String)
|
||||
* @see #getResetDate()
|
||||
*/
|
||||
@Nonnull
|
||||
private final Date resetDate;
|
||||
@@ -341,12 +451,58 @@ public class GHRateLimit {
|
||||
this.resetDate = calculateResetDate(updatedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current {@link Record} is outdated compared to another. Rate Limit dates are only accurate
|
||||
* to the second, so we look at other information in the record as well.
|
||||
*
|
||||
* {@link Record}s with earlier {@link #getResetEpochSeconds()} are replaced by those with later.
|
||||
* {@link Record}s with the same {@link #getResetEpochSeconds()} are replaced by those with less remaining
|
||||
* count.
|
||||
*
|
||||
* {@link UnknownLimitRecord}s compare with each other like regular {@link Record}s.
|
||||
*
|
||||
* {@link Record}s are replaced by {@link UnknownLimitRecord}s only when the current {@link Record} is expired
|
||||
* and the {@link UnknownLimitRecord} is not. Otherwise Regular {@link Record}s are not replaced by
|
||||
* {@link UnknownLimitRecord}s.
|
||||
*
|
||||
* Expiration is only considered after other checks, meaning expired records may sometimes be replaced by other
|
||||
* expired records.
|
||||
*
|
||||
* @param other
|
||||
* the other {@link Record}
|
||||
* @return the {@link Record} that is most current
|
||||
*/
|
||||
Record currentOrUpdated(@Nonnull Record other) {
|
||||
// This set of checks avoids most calls to isExpired()
|
||||
// Depends on UnknownLimitRecord.current() to prevent continuous updating of GHRateLimit rateLimit()
|
||||
if (getResetEpochSeconds() > other.getResetEpochSeconds()
|
||||
|| (getResetEpochSeconds() == other.getResetEpochSeconds()
|
||||
&& getRemaining() <= other.getRemaining())) {
|
||||
// If the current record has a later reset
|
||||
// or the current record has the same reset and fewer or same requests remaining
|
||||
// Then it is most recent
|
||||
return this;
|
||||
} else if (!(other instanceof UnknownLimitRecord)) {
|
||||
// If the above is not the case that means other has a later reset
|
||||
// or the same resent and fewer requests remaining.
|
||||
// If the other record is not an unknown record, the the other is more recent
|
||||
return other;
|
||||
} else if (this.isExpired() && !other.isExpired()) {
|
||||
// The other is an unknown record.
|
||||
// If the current record has expired and the other hasn't, return the other.
|
||||
return other;
|
||||
}
|
||||
|
||||
// If none of the above, the current record is most valid.
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculates the {@link #resetDate} relative to the local machine clock.
|
||||
* <p>
|
||||
* {@link RateLimitChecker}s and {@link RateLimitHandler}s use {@link #getResetDate()} to make decisions about
|
||||
* how long to wait for until for the rate limit to reset. That means that {@link #getResetDate()} needs to be
|
||||
* accurate to the local machine.
|
||||
* calculated based on the local machine clock.
|
||||
* </p>
|
||||
* <p>
|
||||
* When we say that the clock on two machines is "synchronized", we mean that the UTC time returned from
|
||||
@@ -415,7 +571,7 @@ public class GHRateLimit {
|
||||
* {@link #getResetDate()} or implement a {@link RateLimitChecker} instead.
|
||||
*
|
||||
* @return a long representing the time in epoch seconds when the rate limit will reset
|
||||
* @see #getResetDate() #getResetDate()
|
||||
* @see #getResetDate()
|
||||
*/
|
||||
public long getResetEpochSeconds() {
|
||||
return resetEpochSeconds;
|
||||
@@ -424,6 +580,8 @@ public class GHRateLimit {
|
||||
/**
|
||||
* Whether the rate limit reset date indicated by this instance is expired
|
||||
*
|
||||
* If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead.
|
||||
*
|
||||
* @return true if the rate limit reset date has passed. Otherwise false.
|
||||
*/
|
||||
public boolean isExpired() {
|
||||
@@ -431,8 +589,8 @@ public class GHRateLimit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date at which the rate limit will reset, adjusted to local machine time if the local machine's
|
||||
* clock not synchronized with to the same clock as the GitHub server.
|
||||
* The date at which the rate limit will reset, adjusted to local machine time if the local machine's clock not
|
||||
* synchronized with to the same clock as the GitHub server.
|
||||
*
|
||||
* If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
@@ -58,6 +57,6 @@ public class GHReaction extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
root.createRequest().method("DELETE").withPreview(SQUIRREL_GIRL).withUrlPath("/reactions/" + id).send();
|
||||
root.createRequest().method("DELETE").withPreview(SQUIRREL_GIRL).withUrlPath("/reactions/" + getId()).send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -10,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;
|
||||
|
||||
@@ -90,6 +89,78 @@ public class GHRef {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrive a ref of the given type for the current GitHub repository.
|
||||
*
|
||||
* @param repository
|
||||
* the repository to read from
|
||||
* @param refName
|
||||
* eg: heads/branch
|
||||
* @return refs matching the request type
|
||||
* @throws IOException
|
||||
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
|
||||
*/
|
||||
static GHRef read(GHRepository repository, String refName) throws IOException {
|
||||
// Also accept e.g. "refs/heads/branch" for consistency with createRef().
|
||||
if (refName.startsWith("refs/")) {
|
||||
refName = refName.replaceFirst("refs/", "");
|
||||
}
|
||||
|
||||
// We would expect this to use `git/ref/%s` but some versions of GHE seem to not support it
|
||||
// Instead use `git/refs/%s` and check the result actually matches the ref
|
||||
GHRef result = null;
|
||||
try {
|
||||
result = repository.root.createRequest()
|
||||
.withUrlPath(repository.getApiTailUrl(String.format("git/refs/%s", refName)))
|
||||
.fetch(GHRef.class)
|
||||
.wrap(repository.root);
|
||||
} catch (IOException e) {
|
||||
// If the parse exception is due to the above returning an array instead of a single ref
|
||||
// that means the individual ref did not exist. Handled by result check below.
|
||||
// Otherwise, rethrow.
|
||||
if (!(e.getCause() instanceof JsonMappingException)) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that the ref returned is the one requested
|
||||
// Used .endsWith(refName) instead of .equals("refs/" + refName) to workaround a GitBucket
|
||||
// issue where the "ref" field omits the "refs/" prefix. "endsWith()" is functionally
|
||||
// the same for this scenario - the server refs matching is prefix-based, so
|
||||
// a ref that ends with the correct string will always be the correct one.
|
||||
if (result == null || !result.getRef().endsWith(refName)) {
|
||||
throw new GHFileNotFoundException(String.format("git/refs/%s", refName)
|
||||
+ " {\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/git/refs/#get-a-reference\"}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all refs of the given type for the current GitHub repository.
|
||||
*
|
||||
* @param repository
|
||||
* the repository to read from
|
||||
* @param refType
|
||||
* the type of reg to search for e.g. <code>tags</code> or <code>commits</code>
|
||||
* @return paged iterable of all refs of the specified type
|
||||
* @throws IOException
|
||||
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
|
||||
*/
|
||||
static PagedIterable<GHRef> readMatching(GHRepository repository, String refType) throws IOException {
|
||||
if (refType.startsWith("refs/")) {
|
||||
refType = refType.replaceFirst("refs/", "");
|
||||
}
|
||||
|
||||
String url = repository.getApiTailUrl(String.format("git/refs/%s", refType));
|
||||
// if no types, do not end with slash just to be safe.
|
||||
if (refType.equals("")) {
|
||||
url = url.substring(0, url.length() - 1);
|
||||
}
|
||||
return repository.root.createRequest()
|
||||
.withUrlPath(url)
|
||||
.toIterable(GHRef[].class, item -> item.wrap(repository.root));
|
||||
}
|
||||
|
||||
/**
|
||||
* The type GHObject.
|
||||
*/
|
||||
|
||||
@@ -15,14 +15,15 @@ import static java.lang.String.*;
|
||||
* Release in a github repository.
|
||||
*
|
||||
* @see GHRepository#getReleases() GHRepository#getReleases()
|
||||
* @see GHRepository#listReleases() () GHRepository#listReleases()
|
||||
* @see GHRepository#createRelease(String) GHRepository#createRelease(String)
|
||||
*/
|
||||
public class GHRelease extends GHObject {
|
||||
GitHub root;
|
||||
GHRepository owner;
|
||||
|
||||
private String html_url;
|
||||
private String assets_url;
|
||||
private List<GHAsset> assets;
|
||||
private String upload_url;
|
||||
private String tag_name;
|
||||
private String target_commitish;
|
||||
@@ -249,18 +250,44 @@ public class GHRelease extends GHObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets assets.
|
||||
* Get the cached assets.
|
||||
*
|
||||
* @return the assets
|
||||
*
|
||||
* @deprecated This should be the default behavior of {@link #getAssets()} in a future release. This method is
|
||||
* introduced in addition to enable a transition to using cached asset information while keeping the
|
||||
* existing logic in place for backwards compatibility.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<GHAsset> assets() {
|
||||
return assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-fetch the assets of this release.
|
||||
*
|
||||
* @return the assets
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated The behavior of this method will change in a future release. It will then provide cached assets as
|
||||
* provided by {@link #assets()}. Use {@link #listAssets()} instead to fetch up-to-date information of
|
||||
* assets.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<GHAsset> getAssets() throws IOException {
|
||||
return listAssets().toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-fetch the assets of this release.
|
||||
*
|
||||
* @return the assets
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHAsset> getAssets() throws IOException {
|
||||
public PagedIterable<GHAsset> listAssets() throws IOException {
|
||||
Requester builder = owner.root.createRequest();
|
||||
|
||||
return builder.withUrlPath(getApiTailUrl("assets"))
|
||||
.toIterable(GHAsset[].class, item -> item.wrap(this))
|
||||
.toList();
|
||||
return builder.withUrlPath(getApiTailUrl("assets")).toIterable(GHAsset[].class, item -> item.wrap(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +297,7 @@ public class GHRelease extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
root.createRequest().method("DELETE").withUrlPath(owner.getApiTailUrl("releases/" + id)).send();
|
||||
root.createRequest().method("DELETE").withUrlPath(owner.getApiTailUrl("releases/" + getId())).send();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,6 +310,6 @@ public class GHRelease extends GHObject {
|
||||
}
|
||||
|
||||
private String getApiTailUrl(String end) {
|
||||
return owner.getApiTailUrl(format("releases/%s/%s", id, end));
|
||||
return owner.getApiTailUrl(format("releases/%s/%s", getId(), end));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class GHReleaseUpdater {
|
||||
*/
|
||||
public GHRelease update() throws IOException {
|
||||
return builder.method("PATCH")
|
||||
.withUrlPath(base.owner.getApiTailUrl("releases/" + base.id))
|
||||
.withUrlPath(base.owner.getApiTailUrl("releases/" + base.getId()))
|
||||
.fetch(GHRelease.class)
|
||||
.wrap(base.owner);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,6 @@ class GHRepoHook extends GHHook {
|
||||
|
||||
@Override
|
||||
String getApiRoute() {
|
||||
return String.format("/repos/%s/%s/hooks/%d", repository.getOwnerName(), repository.getName(), id);
|
||||
return String.format("/repos/%s/%s/hooks/%d", repository.getOwnerName(), repository.getName(), getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import edu.umd.cs.findbugs.annotations.CheckForNull;
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
@@ -45,14 +46,24 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static org.kohsuke.github.Previews.*;
|
||||
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.SHADOW_CAT;
|
||||
|
||||
/**
|
||||
* A repository on GitHub.
|
||||
@@ -63,10 +74,11 @@ 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 */ GitHub root;
|
||||
|
||||
private String description, homepage, name, full_name;
|
||||
private String nodeId, description, homepage, name, full_name;
|
||||
|
||||
private String html_url; // this is the UI
|
||||
|
||||
/*
|
||||
* The license information makes use of the preview API.
|
||||
*
|
||||
@@ -75,22 +87,30 @@ public class GHRepository extends GHObject {
|
||||
private GHLicense license;
|
||||
|
||||
private String git_url, ssh_url, clone_url, svn_url, mirror_url;
|
||||
|
||||
private GHUser owner; // not fully populated. beware.
|
||||
private boolean has_issues, has_wiki, fork, has_downloads, has_pages, archived;
|
||||
|
||||
private boolean has_issues, has_wiki, fork, has_downloads, has_pages, archived, has_projects;
|
||||
|
||||
private boolean allow_squash_merge;
|
||||
|
||||
private boolean allow_merge_commit;
|
||||
|
||||
private boolean allow_rebase_merge;
|
||||
|
||||
private boolean delete_branch_on_merge;
|
||||
|
||||
@JsonProperty("private")
|
||||
private boolean _private;
|
||||
|
||||
private int forks_count, stargazers_count, watchers_count, size, open_issues_count, subscribers_count;
|
||||
|
||||
private String pushed_at;
|
||||
|
||||
private Map<Integer, GHMilestone> milestones = new WeakHashMap<Integer, GHMilestone>();
|
||||
|
||||
private String default_branch, language;
|
||||
|
||||
private Map<String, GHCommit> commits = new WeakHashMap<String, GHCommit>();
|
||||
|
||||
@SkipFromToString
|
||||
@@ -98,6 +118,12 @@ public class GHRepository extends GHObject {
|
||||
|
||||
private GHRepository source, parent;
|
||||
|
||||
private Boolean isTemplate;
|
||||
|
||||
static GHRepository read(GitHub root, String owner, String name) throws IOException {
|
||||
return root.createRequest().withUrlPath("/repos/" + owner + '/' + name).fetch(GHRepository.class).wrap(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create deployment gh deployment builder.
|
||||
*
|
||||
@@ -144,6 +170,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));
|
||||
}
|
||||
|
||||
@@ -159,6 +187,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);
|
||||
}
|
||||
@@ -185,6 +215,15 @@ public class GHRepository extends GHObject {
|
||||
boolean pull, push, admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets node id
|
||||
*
|
||||
* @return the node id
|
||||
*/
|
||||
public String getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets description.
|
||||
*
|
||||
@@ -221,6 +260,17 @@ public class GHRepository extends GHObject {
|
||||
return clone_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Git http transport url string.
|
||||
*
|
||||
* @return the string
|
||||
* @deprecated Typo of {@link #getHttpTransportUrl()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String gitHttpTransportUrl() {
|
||||
return clone_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Subversion URL to access this repository: https://github.com/rails/rails
|
||||
*
|
||||
@@ -547,6 +597,15 @@ public class GHRepository extends GHObject {
|
||||
return has_issues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has projects boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean hasProjects() {
|
||||
return has_projects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has wiki boolean.
|
||||
*
|
||||
@@ -650,6 +709,28 @@ public class GHRepository extends GHObject {
|
||||
return _private;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is template boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
@Deprecated
|
||||
@Preview(BAPTISTE)
|
||||
public boolean isTemplate() {
|
||||
// isTemplate is still in preview, we do not want to retrieve it unless needed.
|
||||
if (isTemplate == null) {
|
||||
try {
|
||||
populate();
|
||||
} catch (IOException e) {
|
||||
// Convert this to a runtime exception to avoid messy method signature
|
||||
throw new GHException("Could not populate the template setting of the repository", e);
|
||||
}
|
||||
// if this somehow is not populated, set it to false;
|
||||
isTemplate = Boolean.TRUE.equals(isTemplate);
|
||||
}
|
||||
return isTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has downloads boolean.
|
||||
*
|
||||
@@ -744,6 +825,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.
|
||||
*
|
||||
@@ -767,6 +855,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
|
||||
@@ -814,6 +915,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.
|
||||
*
|
||||
@@ -939,12 +1063,12 @@ public class GHRepository extends GHObject {
|
||||
@NonNull String method,
|
||||
@CheckForNull GHOrganization.Permission permission) throws IOException {
|
||||
Requester requester = root.createRequest().method(method);
|
||||
|
||||
if (permission != null) {
|
||||
requester = requester.with("permission", permission).inBody();
|
||||
}
|
||||
|
||||
for (GHUser user : users) {
|
||||
// Make sure that the users collection doesn't have any duplicates
|
||||
for (GHUser user : new LinkedHashSet<GHUser>(users)) {
|
||||
requester.withUrlPath(getApiTailUrl("collaborators/" + user.getLogin())).send();
|
||||
}
|
||||
}
|
||||
@@ -969,13 +1093,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.
|
||||
*
|
||||
@@ -985,7 +1102,19 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public void enableIssueTracker(boolean v) throws IOException {
|
||||
edit("has_issues", String.valueOf(v));
|
||||
set().issues(v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables projects for this repository.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void enableProjects(boolean v) throws IOException {
|
||||
set().projects(v);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -997,7 +1126,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1009,7 +1138,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1021,7 +1150,7 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public void renameTo(String name) throws IOException {
|
||||
edit("name", name);
|
||||
set().name(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1033,7 +1162,7 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public void setDescription(String value) throws IOException {
|
||||
edit("description", value);
|
||||
set().description(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1045,7 +1174,7 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public void setHomepage(String value) throws IOException {
|
||||
edit("homepage", value);
|
||||
set().homepage(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1057,7 +1186,7 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public void setDefaultBranch(String value) throws IOException {
|
||||
edit("default_branch", value);
|
||||
set().defaultBranch(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1069,7 +1198,7 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public void setPrivate(boolean value) throws IOException {
|
||||
edit("private", Boolean.toString(value));
|
||||
set().private_(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1081,7 +1210,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1093,7 +1222,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1105,7 +1234,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1117,7 +1246,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1154,12 +1283,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
|
||||
*/
|
||||
@@ -1205,8 +1352,9 @@ public class GHRepository extends GHObject {
|
||||
// this API is asynchronous. we need to wait for a bit
|
||||
for (int i = 0; i < 10; i++) {
|
||||
GHRepository r = root.getMyself().getRepository(name);
|
||||
if (r != null)
|
||||
if (r != null) {
|
||||
return r;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
@@ -1235,8 +1383,9 @@ public class GHRepository extends GHObject {
|
||||
// this API is asynchronous. we need to wait for a bit
|
||||
for (int i = 0; i < 10; i++) {
|
||||
GHRepository r = org.getRepository(name);
|
||||
if (r != null)
|
||||
if (r != null) {
|
||||
return r;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
@@ -1497,8 +1646,7 @@ public class GHRepository extends GHObject {
|
||||
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
|
||||
*/
|
||||
public PagedIterable<GHRef> listRefs() throws IOException {
|
||||
final String url = String.format("/repos/%s/%s/git/refs", getOwnerName(), name);
|
||||
return root.createRequest().withUrlPath(url).toIterable(GHRef[].class, item -> item.wrap(root));
|
||||
return listRefs("");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1524,8 +1672,7 @@ public class GHRepository extends GHObject {
|
||||
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
|
||||
*/
|
||||
public PagedIterable<GHRef> listRefs(String refType) throws IOException {
|
||||
final String url = String.format("/repos/%s/%s/git/refs/%s", getOwnerName(), name, refType);
|
||||
return root.createRequest().withUrlPath(url).toIterable(GHRef[].class, item -> item.wrap(root));
|
||||
return GHRef.readMatching(this, refType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1538,10 +1685,7 @@ public class GHRepository extends GHObject {
|
||||
* on failure communicating with GitHub, potentially due to an invalid ref type being requested
|
||||
*/
|
||||
public GHRef getRef(String refName) throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(getApiTailUrl(String.format("git/refs/%s", refName)))
|
||||
.fetch(GHRef.class)
|
||||
.wrap(root);
|
||||
return GHRef.read(this, refName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1708,6 +1852,20 @@ public class GHRepository extends GHObject {
|
||||
.toIterable(GHCommitComment[].class, item -> item.wrap(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all comments on a specific commit.
|
||||
*
|
||||
* @param commitSha
|
||||
* the hash of the commit
|
||||
*
|
||||
* @return the paged iterable
|
||||
*/
|
||||
public PagedIterable<GHCommitComment> listCommitComments(String commitSha) {
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/repos/%s/%s/commits/%s/comments", getOwnerName(), name, commitSha))
|
||||
.toIterable(GHCommitComment[].class, item -> item.wrap(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the basic license details for the repository.
|
||||
* <p>
|
||||
@@ -1745,7 +1903,7 @@ public class GHRepository extends GHObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* /** Lists all the commit statues attached to the given commit, newer ones first.
|
||||
* /** Lists all the commit statuses attached to the given commit, newer ones first.
|
||||
*
|
||||
* @param sha1
|
||||
* the sha 1
|
||||
@@ -1773,6 +1931,27 @@ public class GHRepository extends GHObject {
|
||||
return v.isEmpty() ? null : v.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets check runs for given ref.
|
||||
*
|
||||
* @param ref
|
||||
* ref
|
||||
* @return check runs for given ref
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref">List check runs
|
||||
* for a specific ref</a>
|
||||
*/
|
||||
@Preview(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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a commit status
|
||||
*
|
||||
@@ -1828,6 +2007,34 @@ public class GHRepository extends GHObject {
|
||||
return createCommitStatus(sha1, state, targetUrl, description, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a check run for a commit.
|
||||
*
|
||||
* @param name
|
||||
* an identifier for the run
|
||||
* @param headSHA
|
||||
* the commit hash
|
||||
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
|
||||
*/
|
||||
@Preview(ANTIOPE)
|
||||
@Deprecated
|
||||
public @NonNull GHCheckRunBuilder createCheckRun(@NonNull String name, @NonNull String headSHA) {
|
||||
return new GHCheckRunBuilder(this, name, headSHA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing check run.
|
||||
*
|
||||
* @param checkId
|
||||
* the existing checkId
|
||||
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
|
||||
*/
|
||||
@Preview(BAPTISTE)
|
||||
@Deprecated
|
||||
public @NonNull GHCheckRunBuilder updateCheckRun(long checkId) {
|
||||
return new GHCheckRunBuilder(this, checkId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists repository events.
|
||||
*
|
||||
@@ -1851,9 +2058,7 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHLabel> listLabels() throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(getApiTailUrl("labels"))
|
||||
.toIterable(GHLabel[].class, item -> item.wrapUp(this));
|
||||
return GHLabel.readAll(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1866,7 +2071,7 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public GHLabel getLabel(String name) throws IOException {
|
||||
return root.createRequest().withUrlPath(getApiTailUrl("labels/" + name)).fetch(GHLabel.class).wrapUp(this);
|
||||
return GHLabel.read(this, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1881,7 +2086,7 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public GHLabel createLabel(String name, String color) throws IOException {
|
||||
return createLabel(name, color, "");
|
||||
return GHLabel.create(this).name(name).color(color).description("").done();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1898,14 +2103,7 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public GHLabel createLabel(String name, String color, String description) throws IOException {
|
||||
return root.createRequest()
|
||||
.method("POST")
|
||||
.with("name", name)
|
||||
.with("color", color)
|
||||
.with("description", description)
|
||||
.withUrlPath(getApiTailUrl("labels"))
|
||||
.fetch(GHLabel.class)
|
||||
.wrapUp(this);
|
||||
return GHLabel.create(this).name(name).color(color).description(description).done();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1954,9 +2152,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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2019,7 +2219,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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2028,63 +2233,75 @@ 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;
|
||||
if (root.isOffline()) {
|
||||
if (root.isOffline() && owner != null) {
|
||||
owner.wrapUp(root);
|
||||
}
|
||||
if (source != null) {
|
||||
source.wrap(root);
|
||||
}
|
||||
if (parent != null) {
|
||||
parent.wrap(root);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -2404,10 +2621,13 @@ public class GHRepository extends GHObject {
|
||||
* @see #getParent() #getParent()
|
||||
*/
|
||||
public GHRepository getSource() throws IOException {
|
||||
if (source == null)
|
||||
if (fork && source == null) {
|
||||
populate();
|
||||
}
|
||||
if (source == null) {
|
||||
return null;
|
||||
if (source.root == null)
|
||||
source = root.getRepository(source.getFullName());
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
@@ -2422,10 +2642,13 @@ public class GHRepository extends GHObject {
|
||||
* @see #getSource() #getSource()
|
||||
*/
|
||||
public GHRepository getParent() throws IOException {
|
||||
if (parent == null)
|
||||
if (fork && parent == null) {
|
||||
populate();
|
||||
}
|
||||
|
||||
if (parent == null) {
|
||||
return null;
|
||||
if (parent.root == null)
|
||||
parent = root.getRepository(parent.getFullName());
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
@@ -2644,8 +2867,9 @@ public class GHRepository extends GHObject {
|
||||
}
|
||||
|
||||
String getApiTailUrl(String tail) {
|
||||
if (tail.length() > 0 && !tail.startsWith("/"))
|
||||
if (tail.length() > 0 && !tail.startsWith("/")) {
|
||||
tail = '/' + tail;
|
||||
}
|
||||
return "/repos/" + getOwnerName() + "/" + name + tail;
|
||||
}
|
||||
|
||||
@@ -2744,4 +2968,72 @@ public class GHRepository extends GHObject {
|
||||
.fetch(GHTagObject.class)
|
||||
.wrap(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate this object.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* The IO exception
|
||||
*/
|
||||
void populate() throws IOException {
|
||||
if (root.isOffline()) {
|
||||
return; // can't populate if the root is offline
|
||||
}
|
||||
|
||||
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
|
||||
|
||||
try {
|
||||
// IMPORTANT: the url for repository records 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(BAPTISTE).setRawUrlPath(url.toString()).fetchInto(this).wrap(root);
|
||||
} catch (HttpException e) {
|
||||
if (e.getCause() instanceof JsonParseException) {
|
||||
root.createRequest()
|
||||
.withPreview(BAPTISTE)
|
||||
.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(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
235
src/main/java/org/kohsuke/github/GHRepositoryBuilder.java
Normal file
235
src/main/java/org/kohsuke/github/GHRepositoryBuilder.java
Normal file
@@ -0,0 +1,235 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.kohsuke.github.internal.Previews.BAPTISTE;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
@@ -15,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;
|
||||
@@ -59,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")
|
||||
@@ -98,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;
|
||||
@@ -254,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;
|
||||
@@ -315,21 +313,12 @@ public class GHRepositoryStatistics {
|
||||
* the io exception
|
||||
*/
|
||||
public List<CodeFrequency> getCodeFrequency() throws IOException {
|
||||
// Map to arrays first, since there are no field names in the
|
||||
// returned JSON.
|
||||
try {
|
||||
Integer[][] list = root.createRequest()
|
||||
CodeFrequency[] list = root.createRequest()
|
||||
.withUrlPath(getApiTailUrl("code_frequency"))
|
||||
.fetch(Integer[][].class);
|
||||
.fetch(CodeFrequency[].class);
|
||||
|
||||
// Convert to proper objects.
|
||||
List<CodeFrequency> returnList = new ArrayList<>();
|
||||
for (Integer[] item : list) {
|
||||
CodeFrequency cf = new CodeFrequency(Arrays.asList(item));
|
||||
returnList.add(cf);
|
||||
}
|
||||
|
||||
return returnList;
|
||||
return Arrays.asList(list);
|
||||
} catch (MismatchedInputException e) {
|
||||
// This sometimes happens when retrieving code frequency statistics
|
||||
// for a repository for the first time. It is probably still being
|
||||
@@ -342,10 +331,12 @@ public class GHRepositoryStatistics {
|
||||
* The type CodeFrequency.
|
||||
*/
|
||||
public static class CodeFrequency {
|
||||
private int week;
|
||||
private int additions;
|
||||
private int deletions;
|
||||
|
||||
private final int week;
|
||||
private final int additions;
|
||||
private final int deletions;
|
||||
|
||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||
private CodeFrequency(List<Integer> item) {
|
||||
week = item.get(0);
|
||||
additions = item.get(1);
|
||||
@@ -404,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;
|
||||
|
||||
@@ -428,7 +418,7 @@ public class GHRepositoryStatistics {
|
||||
* @return The list of commit counts for everyone combined, for the last 52 weeks.
|
||||
*/
|
||||
public List<Integer> getAllCommits() {
|
||||
return all;
|
||||
return Collections.unmodifiableList(all);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,7 +427,7 @@ public class GHRepositoryStatistics {
|
||||
* @return The list of commit counts for the owner, for the last 52 weeks.
|
||||
*/
|
||||
public List<Integer> getOwnerCommits() {
|
||||
return owner;
|
||||
return Collections.unmodifiableList(owner);
|
||||
}
|
||||
|
||||
Participation wrapUp(GitHub root) {
|
||||
@@ -455,28 +445,22 @@ public class GHRepositoryStatistics {
|
||||
* the io exception
|
||||
*/
|
||||
public List<PunchCardItem> getPunchCard() throws IOException {
|
||||
// Map to ArrayLists first, since there are no field names in the
|
||||
// returned JSON.
|
||||
Integer[][] list = root.createRequest().withUrlPath(getApiTailUrl("punch_card")).fetch(Integer[][].class);
|
||||
|
||||
// Convert to proper objects.
|
||||
ArrayList<PunchCardItem> returnList = new ArrayList<>();
|
||||
for (Integer[] item : list) {
|
||||
PunchCardItem pci = new PunchCardItem(Arrays.asList(item));
|
||||
returnList.add(pci);
|
||||
}
|
||||
|
||||
return returnList;
|
||||
PunchCardItem[] list = root.createRequest()
|
||||
.withUrlPath(getApiTailUrl("punch_card"))
|
||||
.fetch(PunchCardItem[].class);
|
||||
return Arrays.asList(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* The type PunchCardItem.
|
||||
*/
|
||||
public static class PunchCardItem {
|
||||
private int dayOfWeek;
|
||||
private int hourOfDay;
|
||||
private int numberOfCommits;
|
||||
|
||||
private final int dayOfWeek;
|
||||
private final int hourOfDay;
|
||||
private final int numberOfCommits;
|
||||
|
||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||
private PunchCardItem(List<Integer> item) {
|
||||
dayOfWeek = item.get(0);
|
||||
hourOfDay = item.get(1);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public abstract class GHSearchBuilder<T> extends GHQueryBuilder<T> {
|
||||
super(root);
|
||||
this.receiverType = receiverType;
|
||||
req.withUrlPath(getApiUrl());
|
||||
req.rateLimit(RateLimitTarget.SEARCH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -19,6 +18,7 @@ public class GHTagObject {
|
||||
private String message;
|
||||
private GitUser tagger;
|
||||
private GHRef.GHObject object;
|
||||
private GHVerification verification;
|
||||
|
||||
GHTagObject wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
@@ -97,4 +97,13 @@ public class GHTagObject {
|
||||
public GHRef.GHObject getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Verification Status.
|
||||
*
|
||||
* @return the Verification status
|
||||
*/
|
||||
public GHVerification getVerification() {
|
||||
return verification;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* A team in GitHub organization.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class GHTeam implements Refreshable {
|
||||
public class GHTeam extends GHObject implements Refreshable {
|
||||
private String html_url;
|
||||
private String name;
|
||||
private String permission;
|
||||
private String slug;
|
||||
private String description;
|
||||
private Privacy privacy;
|
||||
|
||||
private int id;
|
||||
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.
|
||||
@@ -130,12 +132,49 @@ public class GHTeam implements Refreshable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets id.
|
||||
* Retrieves the discussions.
|
||||
*
|
||||
* @return the id
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
@Nonnull
|
||||
public PagedIterable<GHDiscussion> listDiscussions() throws IOException {
|
||||
return GHDiscussion.readAll(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* List members with specified role paged iterable.
|
||||
*
|
||||
* @param role
|
||||
* the role
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHUser> listMembers(String role) throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(api("/members"))
|
||||
.with("role", role)
|
||||
.toIterable(GHUser[].class, item -> item.wrapUp(root));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single discussion by ID.
|
||||
*
|
||||
* @param discussionNumber
|
||||
* id of the discussion that we want to query for
|
||||
* @return the discussion
|
||||
* @throws java.io.FileNotFoundException
|
||||
* if the discussion does not exist
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*
|
||||
* @see <a href= "https://developer.github.com/v3/teams/discussions/#get-a-discussion">documentation</a>
|
||||
*/
|
||||
@Nonnull
|
||||
public GHDiscussion getDiscussion(long discussionNumber) throws IOException {
|
||||
return GHDiscussion.read(this, discussionNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +185,20 @@ public class GHTeam implements Refreshable {
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHUser> listMembers() throws IOException {
|
||||
return root.createRequest().withUrlPath(api("/members")).toIterable(GHUser[].class, item -> item.wrapUp(root));
|
||||
return listMembers("all");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the teams that are children of this team.
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHTeam> listChildTeams() throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(api("/teams"))
|
||||
.toIterable(GHTeam[].class, item -> item.wrapUp(this.organization));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +221,7 @@ public class GHTeam implements Refreshable {
|
||||
*/
|
||||
public boolean hasMember(GHUser user) {
|
||||
try {
|
||||
root.createRequest().withUrlPath("/teams/" + id + "/members/" + user.getLogin()).send();
|
||||
root.createRequest().withUrlPath("/teams/" + getId() + "/members/" + user.getLogin()).send();
|
||||
return true;
|
||||
} catch (IOException ignore) {
|
||||
return false;
|
||||
@@ -302,7 +354,22 @@ public class GHTeam implements Refreshable {
|
||||
}
|
||||
|
||||
private String api(String tail) {
|
||||
return "/teams/" + id + tail;
|
||||
return "/teams/" + getId() + tail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins the creation of a new instance.
|
||||
*
|
||||
* Consumer must call {@link GHDiscussion.Creator#done()} to commit changes.
|
||||
*
|
||||
* @param title
|
||||
* title of the discussion to be created
|
||||
* @return a {@link GHDiscussion.Creator}
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHDiscussion.Creator createDiscussion(String title) throws IOException {
|
||||
return GHDiscussion.create(this).title(title);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,4 +388,28 @@ public class GHTeam implements Refreshable {
|
||||
public void refresh() throws IOException {
|
||||
root.createRequest().withUrlPath(api("")).fetchInto(this).wrapUp(root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
GHTeam ghTeam = (GHTeam) o;
|
||||
return Objects.equals(name, ghTeam.name) && Objects.equals(getUrl(), ghTeam.getUrl())
|
||||
&& Objects.equals(permission, ghTeam.permission) && Objects.equals(slug, ghTeam.slug)
|
||||
&& Objects.equals(description, ghTeam.description) && privacy == ghTeam.privacy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, getUrl(), permission, slug, description, privacy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -75,7 +73,7 @@ public class GHTeamBuilder {
|
||||
* parentTeamId of team
|
||||
* @return a builder to continue with building
|
||||
*/
|
||||
public GHTeamBuilder parentTeamId(int parentTeamId) {
|
||||
public GHTeamBuilder parentTeamId(long parentTeamId) {
|
||||
this.builder.with("parent_team_id", parentTeamId);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -173,6 +173,19 @@ public class GHUser extends GHPerson {
|
||||
return org.hasPublicMember(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this user is marked as hireable, false otherwise
|
||||
*
|
||||
* @return if the user is marked as hireable
|
||||
*/
|
||||
public boolean isHireable() {
|
||||
return hireable;
|
||||
}
|
||||
|
||||
public String getBio() {
|
||||
return bio;
|
||||
}
|
||||
|
||||
static GHUser[] wrap(GHUser[] users, GitHub root) {
|
||||
for (GHUser f : users)
|
||||
f.root = root;
|
||||
|
||||
82
src/main/java/org/kohsuke/github/GHVerification.java
Normal file
82
src/main/java/org/kohsuke/github/GHVerification.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
/**
|
||||
* The commit/tag can be signed by user. This object holds the verification status. Whether the Commit/Tag is signed or
|
||||
* not.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/git/tags/#signature-verification-object">tags signature
|
||||
* verificatiion</a>
|
||||
* @see <a href="https://developer.github.com/v3/git/commits/#signature-verification-object">commits signature
|
||||
* verificatiion</a>
|
||||
*
|
||||
* @author Sourabh Sarvotham Parkala
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHVerification {
|
||||
private String signature, payload;
|
||||
private boolean verified;
|
||||
private Reason reason;
|
||||
|
||||
/**
|
||||
* Indicates whether GitHub considers the signature in this commit to be verified.
|
||||
*
|
||||
* @return true if the signature is valid else returns false.
|
||||
*/
|
||||
public boolean isVerified() {
|
||||
return verified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets reason for verification value.
|
||||
*
|
||||
* @return return reason of type {@link Reason}, such as "valid" or "unsigned". The possible values can be found in
|
||||
* {@link Reason}}
|
||||
*/
|
||||
public Reason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets signature used for the verification.
|
||||
*
|
||||
* @return null if not signed else encoded signature.
|
||||
*/
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the payload that was signed.
|
||||
*
|
||||
* @return null if not signed else encoded signature.
|
||||
*/
|
||||
public String getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* The possible values for reason in verification object from github.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/repos/commits/#signature-verification-object">List of possible
|
||||
* reason values</a>
|
||||
* @author Sourabh Sarvotham Parkala
|
||||
*/
|
||||
public enum Reason {
|
||||
EXPIRED_KEY,
|
||||
NOT_SIGNING_KEY,
|
||||
GPGVERIFY_ERROR,
|
||||
GPGVERIFY_UNAVAILABLE,
|
||||
UNSIGNED,
|
||||
UNKNOWN_SIGNATURE_TYPE,
|
||||
NO_USER,
|
||||
UNVERIFIED_EMAIL,
|
||||
BAD_EMAIL,
|
||||
UNKNOWN_KEY,
|
||||
MALFORMED_SIGNATURE,
|
||||
INVALID,
|
||||
VALID
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,11 @@
|
||||
*/
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import org.kohsuke.github.authorization.AuthorizationProvider;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@@ -35,8 +39,8 @@ import java.util.logging.Logger;
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static org.kohsuke.github.Previews.INERTIA;
|
||||
import static org.kohsuke.github.Previews.MACHINE_MAN;
|
||||
import static org.kohsuke.github.internal.Previews.INERTIA;
|
||||
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||
|
||||
/**
|
||||
* Root of the GitHub API.
|
||||
@@ -91,39 +95,112 @@ public class GitHub {
|
||||
* "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has <code>/api/v3</code> in the URL. For
|
||||
* historical reasons, this parameter still accepts the bare domain name, but that's considered
|
||||
* deprecated. Password is also considered deprecated as it is no longer required for api usage.
|
||||
* @param login
|
||||
* The user ID on GitHub that you are logging in as. Can be omitted if the OAuth token is provided or if
|
||||
* logging in anonymously. Specifying this would save one API call.
|
||||
* @param oauthAccessToken
|
||||
* Secret OAuth token.
|
||||
* @param password
|
||||
* User's password. Always used in conjunction with the {@code login} parameter
|
||||
* @param connector
|
||||
* HttpConnector to use. Pass null to use default connector.
|
||||
* a connector
|
||||
* @param rateLimitHandler
|
||||
* rateLimitHandler
|
||||
* @param abuseLimitHandler
|
||||
* abuseLimitHandler
|
||||
* @param rateLimitChecker
|
||||
* rateLimitChecker
|
||||
* @param authorizationProvider
|
||||
* a authorization provider
|
||||
*/
|
||||
GitHub(String apiUrl,
|
||||
String login,
|
||||
String oauthAccessToken,
|
||||
String jwtToken,
|
||||
String password,
|
||||
HttpConnector connector,
|
||||
RateLimitHandler rateLimitHandler,
|
||||
AbuseLimitHandler abuseLimitHandler,
|
||||
GitHubRateLimitChecker rateLimitChecker) throws IOException {
|
||||
GitHubRateLimitChecker rateLimitChecker,
|
||||
AuthorizationProvider authorizationProvider) throws IOException {
|
||||
if (authorizationProvider instanceof DependentAuthorizationProvider) {
|
||||
((DependentAuthorizationProvider) authorizationProvider).bind(this);
|
||||
}
|
||||
|
||||
this.client = new GitHubHttpUrlConnectionClient(apiUrl,
|
||||
login,
|
||||
oauthAccessToken,
|
||||
jwtToken,
|
||||
password,
|
||||
connector,
|
||||
rateLimitHandler,
|
||||
abuseLimitHandler,
|
||||
rateLimitChecker,
|
||||
(myself) -> setMyself(myself));
|
||||
(myself) -> setMyself(myself),
|
||||
authorizationProvider);
|
||||
users = new ConcurrentHashMap<>();
|
||||
orgs = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
private GitHub(GitHubClient client) {
|
||||
this.client = client;
|
||||
users = new ConcurrentHashMap<>();
|
||||
orgs = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public static abstract class DependentAuthorizationProvider implements AuthorizationProvider {
|
||||
|
||||
private GitHub baseGitHub;
|
||||
private GitHub gitHub;
|
||||
private final AuthorizationProvider authorizationProvider;
|
||||
|
||||
/**
|
||||
* An AuthorizationProvider that requires an authenticated GitHub instance to provide its authorization.
|
||||
*
|
||||
* @param authorizationProvider
|
||||
* A authorization provider to be used when refreshing this authorization provider.
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
protected DependentAuthorizationProvider(AuthorizationProvider authorizationProvider) {
|
||||
this.authorizationProvider = authorizationProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds this authorization provider to a github instance.
|
||||
*
|
||||
* Only needs to be implemented by dynamic credentials providers that use a github instance in order to refresh.
|
||||
*
|
||||
* @param github
|
||||
* The github instance to be used for refreshing dynamic credentials
|
||||
*/
|
||||
synchronized void bind(GitHub github) {
|
||||
if (baseGitHub != null) {
|
||||
throw new IllegalStateException("Already bound to another GitHub instance.");
|
||||
}
|
||||
this.baseGitHub = github;
|
||||
}
|
||||
|
||||
protected synchronized final GitHub gitHub() {
|
||||
if (gitHub == null) {
|
||||
gitHub = new GitHub.AuthorizationRefreshGitHubWrapper(this.baseGitHub, authorizationProvider);
|
||||
}
|
||||
return gitHub;
|
||||
}
|
||||
}
|
||||
|
||||
private static class AuthorizationRefreshGitHubWrapper extends GitHub {
|
||||
|
||||
private final AuthorizationProvider authorizationProvider;
|
||||
|
||||
AuthorizationRefreshGitHubWrapper(GitHub github, AuthorizationProvider authorizationProvider) {
|
||||
super(github.client);
|
||||
this.authorizationProvider = authorizationProvider;
|
||||
|
||||
// no dependent authorization providers nest like this currently, but they might in future
|
||||
if (authorizationProvider instanceof DependentAuthorizationProvider) {
|
||||
((DependentAuthorizationProvider) authorizationProvider).bind(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
Requester createRequest() {
|
||||
try {
|
||||
// Override
|
||||
return super.createRequest().setHeader("Authorization", authorizationProvider.getEncodedAuthorization())
|
||||
.rateLimit(RateLimitTarget.NONE);
|
||||
} catch (IOException e) {
|
||||
throw new GHException("Failed to create requester to refresh credentials", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the credential from "~/.github" or from the System Environment Properties.
|
||||
*
|
||||
@@ -371,12 +448,20 @@ public class GitHub {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current rate limit.
|
||||
* Gets the current full rate limit information from the server.
|
||||
*
|
||||
* For some versions of GitHub Enterprise, the {@code /rate_limit} endpoint returns a {@code 404 Not Found}. In that
|
||||
* case, the most recent {@link GHRateLimit} information will be returned, including rate limit information returned
|
||||
* in the response header for this request in if was present.
|
||||
*
|
||||
* For most use cases it would be better to implement a {@link RateLimitChecker} and add it via
|
||||
* {@link GitHubBuilder#withRateLimitChecker(RateLimitChecker)}.
|
||||
*
|
||||
* @return the rate limit
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Nonnull
|
||||
public GHRateLimit getRateLimit() throws IOException {
|
||||
return client.getRateLimit();
|
||||
}
|
||||
@@ -386,8 +471,11 @@ public class GitHub {
|
||||
* GitHub Enterprise) or if no requests have been made.
|
||||
*
|
||||
* @return the most recently observed rate limit data or {@code null}.
|
||||
* @deprecated implement a {@link RateLimitChecker} and add it via
|
||||
* {@link GitHubBuilder#withRateLimitChecker(RateLimitChecker)}.
|
||||
*/
|
||||
@CheckForNull
|
||||
@Nonnull
|
||||
@Deprecated
|
||||
public GHRateLimit lastRateLimit() {
|
||||
return client.lastRateLimit();
|
||||
}
|
||||
@@ -398,10 +486,13 @@ public class GitHub {
|
||||
* @return the current rate limit data.
|
||||
* @throws IOException
|
||||
* if we couldn't get the current rate limit data.
|
||||
* @deprecated implement a {@link RateLimitChecker} and add it via
|
||||
* {@link GitHubBuilder#withRateLimitChecker(RateLimitChecker)}.
|
||||
*/
|
||||
@Nonnull
|
||||
@Deprecated
|
||||
public GHRateLimit rateLimit() throws IOException {
|
||||
return client.rateLimit();
|
||||
return client.rateLimit(RateLimitTarget.CORE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,7 +502,7 @@ public class GitHub {
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@WithBridgeMethods(GHUser.class)
|
||||
@WithBridgeMethods(value = GHUser.class)
|
||||
public GHMyself getMyself() throws IOException {
|
||||
client.requireCredential();
|
||||
synchronized (this) {
|
||||
@@ -516,7 +607,7 @@ public class GitHub {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the repository object from 'user/reponame' string that GitHub calls as "repository name"
|
||||
* Gets the repository object from 'owner/repo' string that GitHub calls as "repository name"
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
@@ -527,9 +618,10 @@ public class GitHub {
|
||||
*/
|
||||
public GHRepository getRepository(String name) throws IOException {
|
||||
String[] tokens = name.split("/");
|
||||
return createRequest().withUrlPath("/repos/" + tokens[0] + '/' + tokens[1])
|
||||
.fetch(GHRepository.class)
|
||||
.wrap(this);
|
||||
if (tokens.length < 2) {
|
||||
throw new IllegalArgumentException("Repository name must be in format owner/repo");
|
||||
}
|
||||
return GHRepository.read(this, tokens[0], tokens[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -724,7 +816,11 @@ public class GitHub {
|
||||
* @return the team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*
|
||||
* @deprecated Use {@link GHOrganization#getTeam(long)}
|
||||
* @see <a href= "https://developer.github.com/v3/teams/#get-team-legacy">deprecation notice</a>
|
||||
*/
|
||||
@Deprecated
|
||||
public GHTeam getTeam(int id) throws IOException {
|
||||
return createRequest().withUrlPath("/teams/" + id).fetch(GHTeam.class).wrapUp(this);
|
||||
}
|
||||
@@ -824,7 +920,7 @@ public class GitHub {
|
||||
* @return the gh create repository builder
|
||||
*/
|
||||
public GHCreateRepositoryBuilder createRepository(String name) {
|
||||
return new GHCreateRepositoryBuilder(this, "/user/repos", name);
|
||||
return new GHCreateRepositoryBuilder(name, this, "/user/repos");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -992,7 +1088,7 @@ public class GitHub {
|
||||
* @see <a href="https://developer.github.com/v3/apps/#get-the-authenticated-github-app">Get the authenticated
|
||||
* GitHub App</a>
|
||||
*/
|
||||
@Preview
|
||||
@Preview(MACHINE_MAN)
|
||||
@Deprecated
|
||||
public GHApp getApp() throws IOException {
|
||||
return createRequest().withPreview(MACHINE_MAN).withUrlPath("/app").fetch(GHApp.class).wrapUp(this);
|
||||
@@ -1087,7 +1183,7 @@ public class GitHub {
|
||||
*
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
@Preview
|
||||
@Preview(Previews.CLOAK)
|
||||
@Deprecated
|
||||
public GHCommitSearchBuilder searchCommits() {
|
||||
return new GHCommitSearchBuilder(this);
|
||||
@@ -1186,6 +1282,40 @@ public class GitHub {
|
||||
"UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link ObjectWriter} that can be used to convert data objects in this library to JSON.
|
||||
*
|
||||
* If you must convert data object in this library to JSON, the {@link ObjectWriter} returned by this method is the
|
||||
* only supported way of doing so. This {@link ObjectWriter} can be used to convert any library data object to JSON
|
||||
* without throwing an exception.
|
||||
*
|
||||
* WARNING: While the JSON generated is generally expected to be stable, it is not part of the API of this library
|
||||
* and may change without warning. Use with extreme caution.
|
||||
*
|
||||
* @return an {@link ObjectWriter} instance that can be further configured.
|
||||
*/
|
||||
@Nonnull
|
||||
public static ObjectWriter getMappingObjectWriter() {
|
||||
return GitHubClient.getMappingObjectWriter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link ObjectReader} that can be used to convert JSON into library data objects.
|
||||
*
|
||||
* If you must manually create library data objects from JSON, the {@link ObjectReader} returned by this method is
|
||||
* the only supported way of doing so.
|
||||
*
|
||||
* WARNING: Objects generated from this method have limited functionality. They will not throw when being crated
|
||||
* from valid JSON matching the expected object, but they are not guaranteed to be usable beyond that. Use with
|
||||
* extreme caution.
|
||||
*
|
||||
* @return an {@link ObjectReader} instance that can be further configured.
|
||||
*/
|
||||
@Nonnull
|
||||
public static ObjectReader getMappingObjectReader() {
|
||||
return GitHubClient.getMappingObjectReader(GitHub.offline());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
GitHubClient getClient() {
|
||||
return client;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user