mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-11 08:21:23 +00:00
Compare commits
1632 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
d5667d2473 | ||
|
|
a42305dd59 | ||
|
|
c22a718d14 | ||
|
|
d0b23c79e2 | ||
|
|
76da04afd8 | ||
|
|
768f60709f | ||
|
|
8cd3acd318 | ||
|
|
ce7cfc0648 | ||
|
|
8b6cf55473 | ||
|
|
75d95d844c | ||
|
|
f54bfd3fb5 | ||
|
|
f8a8ee9b9d | ||
|
|
16faaae199 | ||
|
|
375417527b | ||
|
|
10b01ca6b3 | ||
|
|
f9006af04c | ||
|
|
57f947576e | ||
|
|
5a8f8c345b | ||
|
|
e96067e3c8 | ||
|
|
2242174515 | ||
|
|
73179c118b | ||
|
|
5b575134fc | ||
|
|
c11c06b896 | ||
|
|
ba8d2a251f | ||
|
|
c9589b73f4 | ||
|
|
32f4425100 | ||
|
|
05e81484f1 | ||
|
|
10cc79f737 | ||
|
|
957d9b180d | ||
|
|
883204fc43 | ||
|
|
6d3904fbbd | ||
|
|
56a51f18e7 | ||
|
|
307508b7a0 | ||
|
|
66fce79427 | ||
|
|
5e5708d8d4 | ||
|
|
944d92bbb4 | ||
|
|
0155d5aa39 | ||
|
|
fe4f45c2b0 | ||
|
|
1b63a58e63 | ||
|
|
46a141db9c | ||
|
|
66de06956c | ||
|
|
713dd62bd1 | ||
|
|
5ac65aafad | ||
|
|
4aef92e6fe | ||
|
|
a1b0e771e5 | ||
|
|
5baeac4706 | ||
|
|
87aa9bd673 | ||
|
|
2ec5ca56d5 | ||
|
|
b5c7f83ec8 | ||
|
|
eb3ebdbf52 | ||
|
|
c60698ff7e | ||
|
|
f8c2cda257 | ||
|
|
48f6c195e0 | ||
|
|
804fa60317 | ||
|
|
d77b99d3d4 | ||
|
|
006f1271d6 | ||
|
|
0d14514712 | ||
|
|
f25e5f9488 | ||
|
|
9e8bbfd175 | ||
|
|
3d11c96e23 | ||
|
|
a670737ca5 | ||
|
|
9fdd982e73 | ||
|
|
8024918e08 | ||
|
|
cda7607e1c | ||
|
|
816c83c80a | ||
|
|
0c3c490d58 | ||
|
|
99da6fb66f | ||
|
|
fa2601386c | ||
|
|
122833b0e3 | ||
|
|
8618dbf0d5 | ||
|
|
a0baf33459 | ||
|
|
0ee66ea928 | ||
|
|
f68d4aaf5b | ||
|
|
888abc9e2a | ||
|
|
c8115b1c10 | ||
|
|
137d4f591f | ||
|
|
337d49770d | ||
|
|
614c5578b0 | ||
|
|
d456e60800 | ||
|
|
064206fb9a | ||
|
|
a68fe3b39d | ||
|
|
1904c82941 | ||
|
|
6fc9dd4b30 | ||
|
|
158a31e924 | ||
|
|
b70b924db4 | ||
|
|
9018d72e97 | ||
|
|
5c395138ed | ||
|
|
af157adc1b | ||
|
|
1db4fca9db | ||
|
|
013f475859 | ||
|
|
b5bc38fa52 | ||
|
|
bd0e0cdfa4 | ||
|
|
dade4c4cc4 | ||
|
|
acc5a89dff | ||
|
|
d34881aa25 | ||
|
|
b8ad48997b | ||
|
|
77754b7246 | ||
|
|
6d5bf49a51 | ||
|
|
b7af635a9a | ||
|
|
f53b4e959c | ||
|
|
6716d156bb | ||
|
|
dc33e28452 | ||
|
|
9da4781759 | ||
|
|
0c6959cb4a | ||
|
|
ff3136df70 | ||
|
|
326c627221 | ||
|
|
075f382a8f | ||
|
|
dabb8fe49e | ||
|
|
90489e4392 | ||
|
|
ad45a74f87 | ||
|
|
60c045a713 | ||
|
|
f6c75e1f99 | ||
|
|
dd9245f6f2 | ||
|
|
7310a70743 | ||
|
|
82276837ac | ||
|
|
bd68252b44 | ||
|
|
6b1258e33a | ||
|
|
0400032923 | ||
|
|
d9563322f1 | ||
|
|
ab965969dd | ||
|
|
2f32e034d8 | ||
|
|
d7bb171c1e | ||
|
|
1cf7931f43 | ||
|
|
edc697dd73 | ||
|
|
54a059ff68 | ||
|
|
289282e235 | ||
|
|
825c36c15e | ||
|
|
1234c2e99e | ||
|
|
b8fae1308d | ||
|
|
dddcf624e6 | ||
|
|
b33fe9f7fe | ||
|
|
5a799400a9 | ||
|
|
76919a819f | ||
|
|
9c30f846b2 | ||
|
|
9230f51988 | ||
|
|
712035dc9a | ||
|
|
32e5c5b4ad | ||
|
|
134a6fab7e | ||
|
|
82e27cb962 | ||
|
|
8bcad7b3f9 | ||
|
|
d767575f76 | ||
|
|
7214c7d393 | ||
|
|
205e5ab03d | ||
|
|
6576beae76 | ||
|
|
001f8f1f50 | ||
|
|
3b694a87ef | ||
|
|
84dd06d769 | ||
|
|
c5cb16abfb | ||
|
|
79fb34324d | ||
|
|
303aef3548 | ||
|
|
fd278f8c32 | ||
|
|
53041a4117 | ||
|
|
9b3fe3b13a | ||
|
|
5c6c5081e9 | ||
|
|
e087ea0ac7 | ||
|
|
71c44dc805 | ||
|
|
c5c8596664 | ||
|
|
92a86f4d1c | ||
|
|
8098b68b8e | ||
|
|
7356001723 | ||
|
|
aba60587ab | ||
|
|
936a6a04fb | ||
|
|
9675126298 | ||
|
|
6a5886ea1c | ||
|
|
648c6a5a8f | ||
|
|
14b7bf4753 | ||
|
|
0e310fa96a | ||
|
|
0f6c282c80 | ||
|
|
ed3cd0c9c8 | ||
|
|
398f029f6d | ||
|
|
ad9c2b917b | ||
|
|
d0d65182c0 | ||
|
|
4c3a0d329b | ||
|
|
7c495c2177 | ||
|
|
2f86a9e534 | ||
|
|
12c3a0b1fa | ||
|
|
14f3660f55 | ||
|
|
5a8b032d74 | ||
|
|
57c4613b1f | ||
|
|
e008021a42 | ||
|
|
7e600c43ed | ||
|
|
963478e206 | ||
|
|
0f32783488 | ||
|
|
756d470715 | ||
|
|
2c47b7535b | ||
|
|
4cc90b4929 | ||
|
|
32754ffcf5 | ||
|
|
64aae75680 | ||
|
|
69d2160a0d | ||
|
|
99e326539e | ||
|
|
1dde975cfe | ||
|
|
58c069ec5c | ||
|
|
7916600a7b | ||
|
|
3e4f160c5d | ||
|
|
aeb5e5f681 | ||
|
|
1c2e491845 | ||
|
|
eb4000f26b | ||
|
|
74dd887c79 | ||
|
|
764599a7d9 | ||
|
|
ad683fee89 | ||
|
|
85a53fc68f | ||
|
|
3bf8baee85 | ||
|
|
8792213594 | ||
|
|
d9ebc9455c | ||
|
|
9ab8bdfe4a | ||
|
|
418ea9a19e | ||
|
|
20f04febf2 | ||
|
|
a65783201e | ||
|
|
a5f04d44a4 | ||
|
|
cbe1022f20 | ||
|
|
90301ae9ee | ||
|
|
4f38ab3640 | ||
|
|
fca179abab | ||
|
|
e426237c35 | ||
|
|
3dae361d7b | ||
|
|
967831388e | ||
|
|
f9794f20d4 | ||
|
|
f98efd6af0 | ||
|
|
69bf0641f8 | ||
|
|
5791843d16 | ||
|
|
58d0a20074 | ||
|
|
5884c7b3ba | ||
|
|
dd1da268a2 | ||
|
|
473f3954c7 | ||
|
|
5aad5406a2 | ||
|
|
98b606287d | ||
|
|
9792fc0daa | ||
|
|
a9bb9302bc | ||
|
|
30c70bc8d4 | ||
|
|
0df48c37ac | ||
|
|
ec31e94e7a | ||
|
|
ea631d0e88 | ||
|
|
66a180346e | ||
|
|
63ee878789 | ||
|
|
3479e4f2fd | ||
|
|
54f4152f89 | ||
|
|
06334bf272 | ||
|
|
839f096f39 | ||
|
|
f3b2fdc4fc | ||
|
|
16d34f3268 | ||
|
|
61e8dd09d6 | ||
|
|
90d7fea7aa | ||
|
|
b9c8bf07ea | ||
|
|
a3ba07d45f | ||
|
|
5a6a29cbb5 | ||
|
|
72aedbb76c | ||
|
|
e7e3be6ea7 | ||
|
|
62e1b9eb01 | ||
|
|
3fff92dc35 | ||
|
|
352d77719e | ||
|
|
ff397dfa4d | ||
|
|
34d64c0dff | ||
|
|
b5fdc2f956 | ||
|
|
38602965db | ||
|
|
df1ea62883 | ||
|
|
afaff52888 | ||
|
|
5b7829c288 | ||
|
|
2462eb2c79 | ||
|
|
edc26b0a55 | ||
|
|
cc94e8b0ca | ||
|
|
80f3a6e507 | ||
|
|
5709be7ff7 | ||
|
|
46fce8cf4b | ||
|
|
e84049367e | ||
|
|
f213ead595 | ||
|
|
ba540b0725 | ||
|
|
eb55691c89 | ||
|
|
dd508e7dea | ||
|
|
66357866c5 | ||
|
|
6e3728b458 | ||
|
|
31d4eef4b1 | ||
|
|
f58f32a7a8 | ||
|
|
28d8fb686a | ||
|
|
4c7fc2ef47 | ||
|
|
a3f99978c2 | ||
|
|
136b55d310 | ||
|
|
617e90259b | ||
|
|
959eb46162 | ||
|
|
998bda9de7 | ||
|
|
37a2018fe3 | ||
|
|
2c80e07c9d | ||
|
|
a115f34766 | ||
|
|
cd66c1e7c3 | ||
|
|
4f9975dc6d | ||
|
|
9da487d962 | ||
|
|
c7123b016b | ||
|
|
efb13ddaf0 | ||
|
|
3539b73c08 | ||
|
|
2c084ef4d5 | ||
|
|
754e66f4dd | ||
|
|
41b698f0a8 | ||
|
|
de78da4fa6 | ||
|
|
3d241d6fa1 | ||
|
|
1d983a0090 | ||
|
|
78fb860305 | ||
|
|
c699a84f42 | ||
|
|
d8a178d93d | ||
|
|
ada4243548 | ||
|
|
fa2e3aad6c | ||
|
|
0cf457a46f | ||
|
|
bb7b98d448 | ||
|
|
e8d90848f2 | ||
|
|
7c791451ba | ||
|
|
16d8c2b221 | ||
|
|
dceecbef0a | ||
|
|
3cbddf1de9 | ||
|
|
650340fcb3 | ||
|
|
ce5b893224 | ||
|
|
7869afa4ff | ||
|
|
9085606082 | ||
|
|
1e3f646814 | ||
|
|
933f0cb4b8 | ||
|
|
7497761fcc | ||
|
|
12b3d4ec7a | ||
|
|
8fd5ed57c4 | ||
|
|
7bc301bc70 | ||
|
|
30321d3a0e | ||
|
|
511a0ae503 | ||
|
|
1057636666 | ||
|
|
564b1d2a98 | ||
|
|
20cd0e2de2 | ||
|
|
6bc617c488 | ||
|
|
049db83423 | ||
|
|
52dd90e85d | ||
|
|
305267d07f | ||
|
|
20369aa1b5 | ||
|
|
40f05e4dbb | ||
|
|
a23d19f208 | ||
|
|
cb1d1e8ed7 | ||
|
|
4f67f32719 | ||
|
|
a80b5b6abc | ||
|
|
0be3d88872 | ||
|
|
48bb996350 | ||
|
|
ee2dde4cd1 | ||
|
|
c10a31c933 | ||
|
|
d6a846f58d | ||
|
|
945873231d | ||
|
|
5dc494978e | ||
|
|
c870ec10c0 | ||
|
|
2085b8fd14 | ||
|
|
e065b6435c | ||
|
|
da5331ceb0 | ||
|
|
8f81982de4 | ||
|
|
499b46ecf3 | ||
|
|
a7d232e15f | ||
|
|
8fdb394ec5 | ||
|
|
7a1da64bf2 | ||
|
|
95ae155fc0 | ||
|
|
d1507f2666 | ||
|
|
7e4f98d328 | ||
|
|
f9a956905e | ||
|
|
e7d95f9da6 | ||
|
|
bc8f0aa223 | ||
|
|
6f2ae94e12 | ||
|
|
8f787e9976 | ||
|
|
321d8240a2 | ||
|
|
d667b2f822 | ||
|
|
d7f511363d | ||
|
|
39e7c5c3de | ||
|
|
60acd5c864 | ||
|
|
b92cf6fd35 | ||
|
|
f7d048e0b9 | ||
|
|
b3d79622e6 | ||
|
|
7e7ae79477 | ||
|
|
0f9482864c | ||
|
|
60700d59fe | ||
|
|
3296cef02d | ||
|
|
1b55b5fa3c | ||
|
|
5910988314 | ||
|
|
8c4b1ef74a | ||
|
|
b2701f5ba4 | ||
|
|
7d4f1941e7 | ||
|
|
eedefcdbbb | ||
|
|
bdb5e82abc | ||
|
|
ff766a46c8 | ||
|
|
0a40dc5939 | ||
|
|
71862d76d3 | ||
|
|
7a35cc3d17 | ||
|
|
7a4870c977 | ||
|
|
d4d2792498 | ||
|
|
a969509283 | ||
|
|
82fa340c07 | ||
|
|
d44cd4a827 | ||
|
|
a8dbe65e30 | ||
|
|
d2ce7c11ac | ||
|
|
d02af5ccb0 | ||
|
|
9a5467dcac | ||
|
|
2af4f61882 | ||
|
|
cbd06eef96 | ||
|
|
392dc2a040 | ||
|
|
da11702f68 | ||
|
|
f262bf7cdb | ||
|
|
78ab5ad156 | ||
|
|
6af796fc3b | ||
|
|
c174be37b3 | ||
|
|
18aa067c44 | ||
|
|
8d50b338f4 | ||
|
|
37d7cfaaf2 | ||
|
|
d3564a9a4f | ||
|
|
39d6dd9916 | ||
|
|
0152ebf062 | ||
|
|
757b9b2118 | ||
|
|
f6a01551fd | ||
|
|
1f619f3801 | ||
|
|
fd436cf5b2 | ||
|
|
7e05ce38cf | ||
|
|
7d1e977ffe | ||
|
|
6c2ce83b45 | ||
|
|
d5ba0eebcb | ||
|
|
432585cb75 | ||
|
|
e41a341ce6 | ||
|
|
5d9a4b42a6 | ||
|
|
6aad80904a | ||
|
|
20e796cef4 | ||
|
|
a3b126282d | ||
|
|
5f597379b5 | ||
|
|
9d8460bb81 | ||
|
|
8943af9840 | ||
|
|
d23c718036 | ||
|
|
834c84c9ea | ||
|
|
adc436a3f5 | ||
|
|
e325bf7771 | ||
|
|
feabd07a21 | ||
|
|
e138c6fd61 | ||
|
|
d32299fde5 | ||
|
|
3d7d780e8f | ||
|
|
9f49854033 | ||
|
|
1fe820d463 | ||
|
|
4a78690fde | ||
|
|
3dcaf5a9de | ||
|
|
ff788852d6 | ||
|
|
5ae062719e | ||
|
|
421c0a11fb | ||
|
|
6ae586aeb7 | ||
|
|
7036423084 | ||
|
|
2f118a9cbe | ||
|
|
2c50255b21 | ||
|
|
8cb7210c46 | ||
|
|
ad0a24ad2f | ||
|
|
df6c951830 | ||
|
|
5da2caa616 | ||
|
|
a3fe95d1e4 | ||
|
|
38e61c121b | ||
|
|
03e9623073 | ||
|
|
93a1657e1e | ||
|
|
91d67fb72f | ||
|
|
d8cc1f885c | ||
|
|
c1f999d896 | ||
|
|
efc4d0f59b | ||
|
|
cf55d670b9 | ||
|
|
8567c5e6a1 | ||
|
|
331084fefd | ||
|
|
62bf691ac1 | ||
|
|
09b41d4665 | ||
|
|
71645240e9 | ||
|
|
603468823d | ||
|
|
01f464cc69 | ||
|
|
57ac6e982f | ||
|
|
319d2d1efe | ||
|
|
37de3a4122 | ||
|
|
bb3a49264d | ||
|
|
9cecce74fa | ||
|
|
f9cf2878ef | ||
|
|
9c80b7cf54 | ||
|
|
1ecad7031f | ||
|
|
c85d6107ec | ||
|
|
7b7445b601 | ||
|
|
1ab474673d | ||
|
|
dbf92e7f20 | ||
|
|
6c42db2508 | ||
|
|
c9a42178e8 | ||
|
|
eff48dfe67 | ||
|
|
0c38bdc068 | ||
|
|
b8e1736696 | ||
|
|
c2f36444d0 | ||
|
|
5dc74f5b4d | ||
|
|
9694dfe4cc | ||
|
|
734125ea14 | ||
|
|
438f5d1b87 | ||
|
|
fadd6d7978 | ||
|
|
5026262273 | ||
|
|
5b53fba020 | ||
|
|
3892e6e16f | ||
|
|
33467de763 | ||
|
|
f3528d97c2 | ||
|
|
6fb3b01bf0 | ||
|
|
e3c9cec440 | ||
|
|
0e011425fb | ||
|
|
ba658f7fea | ||
|
|
0e6087143b | ||
|
|
5f967e6307 | ||
|
|
2eb8ce632c | ||
|
|
f25dbd15d9 | ||
|
|
cc5ea77170 | ||
|
|
e323644af2 | ||
|
|
61f3a3219f | ||
|
|
4dcf5dbc13 | ||
|
|
8faecba0a2 | ||
|
|
739551cbe3 | ||
|
|
24a2e42881 | ||
|
|
6921754c99 | ||
|
|
d8827a0b44 | ||
|
|
a48091988f | ||
|
|
9bd9c9cf1f | ||
|
|
695692285b | ||
|
|
03edacf7b6 | ||
|
|
4802c97e89 | ||
|
|
9fc24d1981 | ||
|
|
d4ddf453b0 | ||
|
|
c0117f07cf | ||
|
|
8a88c14b13 | ||
|
|
a5b6302a69 | ||
|
|
9f29d4619d | ||
|
|
f4b9dd7d7b | ||
|
|
c0a4152b00 | ||
|
|
efb87c5a9e | ||
|
|
061e8bb662 | ||
|
|
a4f42b2948 | ||
|
|
cb2fcd3a9e | ||
|
|
1d004a35a0 | ||
|
|
c763c02018 | ||
|
|
eb36cb4436 | ||
|
|
72d4b9bf62 | ||
|
|
81ea138f41 | ||
|
|
1bbc66ad62 | ||
|
|
e7348df372 | ||
|
|
550e060647 | ||
|
|
2970a58e95 | ||
|
|
e0efa04fd4 | ||
|
|
4d24088982 | ||
|
|
baba9f5de6 | ||
|
|
c35cd63d0e | ||
|
|
80fa389ce3 | ||
|
|
8ec861c9fe | ||
|
|
837400fb5e | ||
|
|
ec4525b8ff | ||
|
|
281c927971 | ||
|
|
9dd44c13e4 | ||
|
|
f28edbcf8f | ||
|
|
29e147f992 | ||
|
|
830f4231e1 | ||
|
|
7d65e31055 | ||
|
|
dec7a91b5b | ||
|
|
1ba630c221 | ||
|
|
7d3387fb96 | ||
|
|
a0c0de28d7 | ||
|
|
dc31d52f83 | ||
|
|
620c822dac | ||
|
|
5990f5ae22 | ||
|
|
37329a50d4 | ||
|
|
550597f72e | ||
|
|
2aa4022e2c | ||
|
|
b40741b14d | ||
|
|
3c739d889e | ||
|
|
24a92a133e | ||
|
|
ce97eb5b40 | ||
|
|
7a4e3c480e | ||
|
|
eefa710839 | ||
|
|
4c3e1afcca | ||
|
|
c1a77ada5d | ||
|
|
5671e5ed67 | ||
|
|
2fdc5a8541 | ||
|
|
297dbae247 | ||
|
|
0910cdf3a4 | ||
|
|
6877fb5c74 | ||
|
|
2d65daa8c9 | ||
|
|
dab4cb6186 | ||
|
|
40773a2b49 | ||
|
|
7e0d61a6fc | ||
|
|
7f9620d75f | ||
|
|
3559aef1a1 | ||
|
|
94ceb5eaaf | ||
|
|
778ca76d22 | ||
|
|
b1c0e41c5c | ||
|
|
f826edd097 | ||
|
|
edc7c4a4b8 | ||
|
|
dafdc66d25 | ||
|
|
0d135f14bb | ||
|
|
568c08d0e9 | ||
|
|
87410e295e | ||
|
|
b163e68950 | ||
|
|
88b006e957 | ||
|
|
477f2f2814 | ||
|
|
933d99c23b | ||
|
|
d3a0c5ded1 | ||
|
|
1e173ddc24 | ||
|
|
ca404cb33b | ||
|
|
f0dc7d5b02 | ||
|
|
933702376f | ||
|
|
e08896775b | ||
|
|
d610e46f8e | ||
|
|
7d1989f5a2 | ||
|
|
5c1e371427 | ||
|
|
dbd9d51747 | ||
|
|
fdf5d3f72d | ||
|
|
2719867a86 | ||
|
|
0240412ad2 | ||
|
|
7c065c1205 | ||
|
|
f9aa1ad1f2 | ||
|
|
5feffdf544 | ||
|
|
4e56b8bb78 | ||
|
|
845017313c | ||
|
|
dc2830d94f | ||
|
|
552edf8698 | ||
|
|
41c51646fe | ||
|
|
a42024bdbc | ||
|
|
20cfb26a7f | ||
|
|
3972d11827 | ||
|
|
5cc88a0075 | ||
|
|
fc08711111 | ||
|
|
b20c2babec | ||
|
|
cb0facc6ef | ||
|
|
78abb2edcb | ||
|
|
7d350d9def | ||
|
|
48d7daf2c4 | ||
|
|
2782059d88 | ||
|
|
0ca10bc2ac | ||
|
|
880abe2305 | ||
|
|
22f61d6225 | ||
|
|
4fbaa425fb | ||
|
|
e81e228f03 | ||
|
|
1076f89954 | ||
|
|
9c6f977202 | ||
|
|
bd23ba6077 | ||
|
|
c7af56d0ed | ||
|
|
8da6db9fcc | ||
|
|
2fe7342fd7 | ||
|
|
f6221144a8 | ||
|
|
872d713e50 | ||
|
|
d5b04f572b | ||
|
|
0f7a5f1c08 | ||
|
|
a163c565a8 | ||
|
|
413a316b15 | ||
|
|
65a92a49b5 | ||
|
|
563507ca21 | ||
|
|
21b2d02f0a | ||
|
|
19e1a00fd7 | ||
|
|
a02a6a22d0 | ||
|
|
3488421f67 | ||
|
|
34a961088c | ||
|
|
b35509150a | ||
|
|
d096aa2065 | ||
|
|
efd5bef102 | ||
|
|
b8c6e44ab6 | ||
|
|
9a91cc43e2 | ||
|
|
f4cbab52a7 | ||
|
|
57b58cf203 | ||
|
|
9ba8ae08a1 | ||
|
|
dfe81f510e | ||
|
|
f3a0b35442 | ||
|
|
64e3be3bc7 | ||
|
|
4c82d1c56e | ||
|
|
d8451fc2f5 | ||
|
|
8078423252 | ||
|
|
68176b5695 | ||
|
|
1bf7833959 | ||
|
|
89770b922d | ||
|
|
716947bbb1 | ||
|
|
47e0d7786b | ||
|
|
55f9c40bba | ||
|
|
51afa30732 | ||
|
|
23c07316ee | ||
|
|
e740f52e5e | ||
|
|
a731109747 | ||
|
|
a50a011eb3 | ||
|
|
e22c6d3a94 | ||
|
|
50fb9c1795 | ||
|
|
22575c9a01 | ||
|
|
2934922cb5 | ||
|
|
9042ff46c7 | ||
|
|
a1a91539c2 | ||
|
|
468f4f94a3 | ||
|
|
3ebd35437e | ||
|
|
a166bbadad | ||
|
|
7ff07a132a | ||
|
|
6f297bcbb8 | ||
|
|
1c023e15af | ||
|
|
37f96848a7 | ||
|
|
3d04765f51 | ||
|
|
e1152fa549 | ||
|
|
ab47896f17 | ||
|
|
4f13565e51 | ||
|
|
7ab93a59e2 | ||
|
|
943c0d022b | ||
|
|
bea8922c39 | ||
|
|
97c96a7ee1 | ||
|
|
3d831ba7e8 | ||
|
|
df749a98cb | ||
|
|
22bbc9c621 | ||
|
|
30def4e515 | ||
|
|
cf8be37310 | ||
|
|
12409df446 | ||
|
|
3452a08de3 | ||
|
|
425ea0579e | ||
|
|
22afb769af | ||
|
|
884eae269e | ||
|
|
59a973970e | ||
|
|
225383464a | ||
|
|
3d82731325 | ||
|
|
dacdf08309 | ||
|
|
ad281adc97 | ||
|
|
80741c7773 | ||
|
|
532f7a4b17 | ||
|
|
5e87d582e4 | ||
|
|
b9bf47aaca | ||
|
|
0dba882817 | ||
|
|
c419883814 | ||
|
|
6f0ccbf2b5 | ||
|
|
54332c0bd1 | ||
|
|
5f80674e89 | ||
|
|
c4d0d8ff06 | ||
|
|
8ac1b7082a | ||
|
|
f146ae8be4 | ||
|
|
e7728fdc94 | ||
|
|
052122e4d0 | ||
|
|
38827d2b3d | ||
|
|
9e1f16be27 | ||
|
|
c845846317 | ||
|
|
9276556f19 | ||
|
|
c796d18948 | ||
|
|
8dee5520cf | ||
|
|
440e13714e | ||
|
|
44a70b372d | ||
|
|
504286e96e | ||
|
|
ffdd54d2fa | ||
|
|
32804b81c0 | ||
|
|
403b22ade0 | ||
|
|
a4e74abcca | ||
|
|
8dcef5bac0 | ||
|
|
49878bc4e3 | ||
|
|
3f1a71c8a4 | ||
|
|
bf9b2c0da3 | ||
|
|
909a274709 | ||
|
|
fc529b8083 | ||
|
|
f1386f26fb | ||
|
|
cccd09d329 | ||
|
|
0fccf7effe | ||
|
|
4b91a47c8b | ||
|
|
bd40499bbe | ||
|
|
c7c8cd76c6 | ||
|
|
0bb9f0ce41 | ||
|
|
7136afce8e | ||
|
|
ec17c1de6a | ||
|
|
8d6daef354 | ||
|
|
3a09d2de4a | ||
|
|
c78e10f92e | ||
|
|
b113ff35ac | ||
|
|
6360024d20 | ||
|
|
a7683f6bd7 | ||
|
|
e46a9f3f2a | ||
|
|
a8d711d4c8 | ||
|
|
df74fc67bd | ||
|
|
450261abbf | ||
|
|
12230edc54 | ||
|
|
d1cfcf561b | ||
|
|
d143f5af8b | ||
|
|
0f7ae3cda7 | ||
|
|
baf94e56c8 | ||
|
|
905bd1a4c9 | ||
|
|
96bcf24047 | ||
|
|
dfe47235cf | ||
|
|
b82ea8eaa8 | ||
|
|
b1b830c268 | ||
|
|
e654d4a6df | ||
|
|
ac30b17ecb | ||
|
|
95efdb3a51 | ||
|
|
49c165e203 | ||
|
|
a4be351d9f | ||
|
|
3d0401aecd | ||
|
|
7c27572a53 | ||
|
|
1e7760012e | ||
|
|
24d464b6e5 | ||
|
|
499d91f9f8 | ||
|
|
8e0ceaa06b | ||
|
|
4e62641f7e | ||
|
|
688644f5a4 | ||
|
|
4703f2d1f5 | ||
|
|
14149ae949 | ||
|
|
a0fb0d170c | ||
|
|
e133afec86 | ||
|
|
3ae8ee8ddb | ||
|
|
012643a231 | ||
|
|
dccb43f4dc | ||
|
|
15b3bc6a63 | ||
|
|
2d15bef76d | ||
|
|
756d298f04 | ||
|
|
9f35eb1a85 | ||
|
|
c905bb4b6c | ||
|
|
c78af01c8f | ||
|
|
084855645a | ||
|
|
afce9ece89 | ||
|
|
154e50e36d | ||
|
|
80a129102b | ||
|
|
93672a074e | ||
|
|
c7f6f6233c | ||
|
|
68915a9daf | ||
|
|
13eb91f8dd | ||
|
|
1a8355e6fb | ||
|
|
aa2b7ae60a | ||
|
|
acd36b7ea5 | ||
|
|
87245ab79f | ||
|
|
13b6a17827 | ||
|
|
615e4cf24e | ||
|
|
0e6d08f027 | ||
|
|
d593e584dd | ||
|
|
e046b97160 | ||
|
|
567d3dac55 | ||
|
|
a67a0aa924 | ||
|
|
1b1e3e88fe | ||
|
|
ec99636ef0 | ||
|
|
9d955d252a | ||
|
|
f136f6837a | ||
|
|
6fc1fb0966 | ||
|
|
fad203a66d | ||
|
|
c1bab63ebd | ||
|
|
40f012b03c | ||
|
|
a380059389 | ||
|
|
24b998ba2d | ||
|
|
9a1bb09c9f | ||
|
|
3ad66f8937 | ||
|
|
a6f3e7df55 | ||
|
|
9345d3be31 | ||
|
|
8e85bf8839 | ||
|
|
1012dcd194 | ||
|
|
70251ea11e | ||
|
|
9381471fbd | ||
|
|
1c4b716f1a | ||
|
|
c8b0584127 | ||
|
|
5194a361f4 | ||
|
|
c44e5d2a87 | ||
|
|
ee4d514b66 | ||
|
|
863995cb50 | ||
|
|
cbfe72a76e | ||
|
|
4f17d3519c | ||
|
|
3cfcad76ac | ||
|
|
1ca6535811 | ||
|
|
53612ad2e4 | ||
|
|
4b799d264c | ||
|
|
ca5594703a | ||
|
|
7fc2d9dcca | ||
|
|
c413fc1e30 | ||
|
|
b5086c7759 | ||
|
|
92a015ca4d | ||
|
|
3b2802e36d | ||
|
|
7bf23eaa15 | ||
|
|
9afd1c5ee8 | ||
|
|
5e36377b36 | ||
|
|
c988df13a8 | ||
|
|
29a40d31b7 | ||
|
|
ddc27e818b | ||
|
|
3fa70ac841 | ||
|
|
b2b7dfaf37 | ||
|
|
c309c2cf13 | ||
|
|
71304b114a | ||
|
|
0ffcbdbd38 | ||
|
|
e368a17420 | ||
|
|
2fcfb2f67d | ||
|
|
f68a85056e | ||
|
|
943f47d29d | ||
|
|
fd37a2c466 | ||
|
|
eacdd7afe8 | ||
|
|
fe5ea52cdf | ||
|
|
ca6d77cbb3 | ||
|
|
1145941d11 | ||
|
|
d61697a152 | ||
|
|
38b77a9c79 | ||
|
|
7d294ee8c2 | ||
|
|
33d9422d03 | ||
|
|
bb7302c23a | ||
|
|
d50ae63a5a | ||
|
|
1961836e19 | ||
|
|
f2ed7c15ce | ||
|
|
4dce173630 | ||
|
|
86f868b2d4 | ||
|
|
363064f5c0 | ||
|
|
9d99ee9cfc | ||
|
|
db8969707d | ||
|
|
a24ac37dfd | ||
|
|
1b04d471b3 | ||
|
|
9cc400a081 | ||
|
|
e233aeec0c | ||
|
|
5dfd621900 | ||
|
|
f0f6a9988f | ||
|
|
587438938c | ||
|
|
2497ac68d1 | ||
|
|
75918c59cc | ||
|
|
8b38a20c18 | ||
|
|
e7b76bfdc5 | ||
|
|
3503ff6d36 | ||
|
|
192e21a9fc | ||
|
|
24e288d584 | ||
|
|
0e5ffda5e5 | ||
|
|
cdf6f18ec0 | ||
|
|
188245fa7f | ||
|
|
e10b747d6a | ||
|
|
f2bb6a05a5 | ||
|
|
f41da19db5 | ||
|
|
d0a56dbb21 | ||
|
|
acbf286e59 | ||
|
|
0f7c160409 | ||
|
|
5113aacb89 | ||
|
|
4e31636181 | ||
|
|
1e497d2c44 | ||
|
|
70bd4fa161 | ||
|
|
65996050d5 | ||
|
|
7f52031199 | ||
|
|
5430f3d33c | ||
|
|
43075faaf8 | ||
|
|
f3a1272e31 | ||
|
|
41c028d4d9 | ||
|
|
a17ce04552 | ||
|
|
d0b4652dcd | ||
|
|
e66f71c76e | ||
|
|
6effd4b846 | ||
|
|
df861f5403 | ||
|
|
e74346fed6 | ||
|
|
6961c467a6 | ||
|
|
892d305165 | ||
|
|
fa16261d7a | ||
|
|
15991fd2f7 | ||
|
|
c80b8f60f8 | ||
|
|
ab6253cbd0 | ||
|
|
35ba267115 | ||
|
|
ab24e6e1c1 | ||
|
|
e25ae27a15 | ||
|
|
2b7c524908 | ||
|
|
0b069df9ce | ||
|
|
60c9ba88ae | ||
|
|
cc2e60c84a | ||
|
|
83c2c4e92e | ||
|
|
ab3d9e82ef | ||
|
|
b6063dd534 | ||
|
|
e6754354e4 | ||
|
|
4849619d67 | ||
|
|
9b0ace242a | ||
|
|
e94ba74058 | ||
|
|
569fa06d2d | ||
|
|
46dce17abc | ||
|
|
40d8f4a352 | ||
|
|
6415785220 | ||
|
|
7735edeae8 | ||
|
|
0f81d1dbb3 | ||
|
|
ae1ec8b558 | ||
|
|
09c2b39530 | ||
|
|
b443e866f9 | ||
|
|
d4404713a8 | ||
|
|
47409a9a99 | ||
|
|
60bfea2d3b | ||
|
|
d3ed8eaed5 | ||
|
|
692dccf110 | ||
|
|
92caf98683 | ||
|
|
6178d38895 | ||
|
|
40fb38a9ba | ||
|
|
20e68d53fd | ||
|
|
2d3557e049 | ||
|
|
d8f4bc7395 | ||
|
|
353f9bb809 | ||
|
|
ccfe3ad4f7 | ||
|
|
9012820c03 | ||
|
|
fe2af19e42 | ||
|
|
f721e053f1 | ||
|
|
e6ad9feb84 | ||
|
|
635350c40e | ||
|
|
17edd33703 | ||
|
|
b0f2a871c6 | ||
|
|
8928a8a1dc | ||
|
|
2b6f37a6cc | ||
|
|
f3a3b87861 | ||
|
|
9cf6ee78d4 | ||
|
|
bbc2f3962f | ||
|
|
be49eb22d2 | ||
|
|
fb47067215 | ||
|
|
2c80ef178d | ||
|
|
9af8112148 | ||
|
|
57c36f437a | ||
|
|
f2a2ad90b7 | ||
|
|
cfe4c0c510 | ||
|
|
a1819bf232 | ||
|
|
8accf07d46 | ||
|
|
6dcbace572 | ||
|
|
e90c86ec2f | ||
|
|
971ae1fa4d | ||
|
|
b537f9925b | ||
|
|
be081eec3f | ||
|
|
55b00a87f6 | ||
|
|
fafe6b0ff7 | ||
|
|
5b156006fb | ||
|
|
9f3f644b83 |
29
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
29
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Description
|
||||
** Describe your change here**
|
||||
|
||||
# Before submitting a PR:
|
||||
We love getting PRs, but we hate asking people for the same basic changes every time.
|
||||
|
||||
- [ ] 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 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"
|
||||
20
.github/release-drafter.yml
vendored
Normal file
20
.github/release-drafter.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name-template: 'v$NEXT_MINOR_VERSION 🌈'
|
||||
tag-template: 'github-api-$NEXT_MINOR_VERSION'
|
||||
version-template: '$MAJOR.$MINOR'
|
||||
categories:
|
||||
- title: '🚀 Features'
|
||||
labels:
|
||||
- 'feature'
|
||||
- 'enhancement'
|
||||
- title: '🐛 Bug Fixes'
|
||||
labels:
|
||||
- 'fix'
|
||||
- 'bugfix'
|
||||
- 'bug'
|
||||
- title: '🧰 Maintenance'
|
||||
label: 'chore'
|
||||
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
|
||||
template: |
|
||||
## Changes
|
||||
|
||||
$CHANGES
|
||||
72
.github/workflows/maven-build.yml
vendored
Normal file
72
.github/workflows/maven-build.yml
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build-only (Java ${{ matrix.java }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: [ 13 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
- name: Cached .m2
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- name: Maven Install (skipTests)
|
||||
run: mvn -B install -DskipTests -D enable-ci --file pom.xml
|
||||
site:
|
||||
name: site (Java ${{ matrix.java }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: [ 8, 11 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- name: Maven Site
|
||||
run: mvn -B site -D enable-ci --file pom.xml
|
||||
test:
|
||||
name: test (${{ matrix.os }}, Java ${{ matrix.java }})
|
||||
runs-on: ${{ matrix.os }}-latest
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ubuntu, windows ]
|
||||
java: [ 8, 11, 13, 15-ea ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- name: Maven Install without Code Coverage
|
||||
if: matrix.os == 'windows'
|
||||
run: mvn -B install --file pom.xml
|
||||
- name: Maven Install with Code Coverage
|
||||
if: matrix.os != 'windows'
|
||||
run: mvn -B install -D enable-ci --file pom.xml
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -7,3 +7,7 @@ target
|
||||
.project
|
||||
.settings/
|
||||
.DS_Store
|
||||
|
||||
dependency-reduced-pom.xml
|
||||
.factorypath
|
||||
.vscode/settings.json
|
||||
|
||||
1184
CHANGELOG.md
Normal file
1184
CHANGELOG.md
Normal file
File diff suppressed because it is too large
Load Diff
76
CODE_OF_CONDUCT.md
Normal file
76
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at bitwiseman@gmail.com. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
82
CONTRIBUTING.md
Normal file
82
CONTRIBUTING.md
Normal file
@@ -0,0 +1,82 @@
|
||||
# Contributing
|
||||
|
||||
## Using WireMock and Snapshots
|
||||
|
||||
This project has started converting to using WireMock to stub out http responses instead of use live data.
|
||||
This change will allow tests to run in a CI environment without needing to touch github.com.
|
||||
The tests will instead serve previously recorded responses from local data files.
|
||||
|
||||
### Running WireMock tests
|
||||
|
||||
Example:
|
||||
|
||||
`mvn install -Dtest=WireMockStatusReporterTest`
|
||||
|
||||
This the default behavior.
|
||||
|
||||
Example for a single test case:
|
||||
|
||||
`mvn install -Dtest=WireMockStatusReporterTest#user_whenProxying_AuthCorrectlyConfigured`
|
||||
|
||||
|
||||
### Setting up credential
|
||||
|
||||
1. Create an OAuth token on github.com
|
||||
2. Set the GITHUB_OAUTH environment variable to the value of that token
|
||||
3. Set the system property `test.github.useProxy` (usually like "-Dtest.github.useProxy" as a Java VM option)
|
||||
|
||||
`mvn install -Dtest.github.useProxy -Dtest=WireMockStatusReporterTest`
|
||||
|
||||
4. The above should report no test failures and include the following console output:
|
||||
|
||||
`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.
|
||||
|
||||
### Writing a new test
|
||||
|
||||
Once you have credentials setup, you add new test classes and test methods as you would normally.
|
||||
|
||||
#### Running tests using GitHub test proxy
|
||||
|
||||
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.
|
||||
|
||||
#### 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.
|
||||
|
||||
### Modifying existing tests
|
||||
|
||||
When modifying existing tests, you can change the stubbed WireMock data files by hand or you can try generating a new snapshot.
|
||||
|
||||
#### Manual editing of data (minor changes only)
|
||||
|
||||
If you know what data will change, it is sometimes simplest to make any required changes to the data files manually.
|
||||
This can be easier if the changes are minor or when you development environment is not setup to to take updated snapshots.
|
||||
|
||||
#### Generating a new snapshot
|
||||
|
||||
For more most changes, it is recommended to take a new snapshot when updating tests.
|
||||
Delete the wiremock data files for the test method you will be modifying.
|
||||
For more significant changes, you can even delete the WireMock files for an entire test class.
|
||||
Then follow the same as when writing a new test: run with proxy enabled to debug, take a new snapshot when done, commit everything, and submit the PR.
|
||||
3
README
3
README
@@ -1,3 +0,0 @@
|
||||
Java API for GitHub
|
||||
|
||||
See http://github-api.kohsuke.org/ for more details
|
||||
9
README.md
Normal file
9
README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Java API for GitHub
|
||||
|
||||
[](https://mvnrepository.com/artifact/org.kohsuke/github-api)
|
||||
[](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
|
||||
625
pom.xml
625
pom.xml
@@ -1,59 +1,328 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.kohsuke</groupId>
|
||||
<artifactId>pom</artifactId>
|
||||
<version>17</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.kohsuke</groupId>
|
||||
<artifactId>github-api</artifactId>
|
||||
<version>1.88</version>
|
||||
<version>1.121</version>
|
||||
<name>GitHub API for Java</name>
|
||||
<url>http://github-api.kohsuke.org/</url>
|
||||
<url>https://github-api.kohsuke.org/</url>
|
||||
<description>GitHub API for Java</description>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com/kohsuke/${project.artifactId}.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/kohsuke/${project.artifactId}.git</developerConnection>
|
||||
<url>http://${project.artifactId}.kohsuke.org/</url>
|
||||
<tag>github-api-1.88</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.121</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<name>Sonatype Nexus Snapshots</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>sonatype-nexus-staging</id>
|
||||
<name>Nexus Release Repository</name>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
<site>
|
||||
<id>github-pages</id>
|
||||
<url>gitsite:git@github.com/kohsuke/${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>
|
||||
<findbugs-maven-plugin.version>3.0.2</findbugs-maven-plugin.version>
|
||||
<findbugs-maven-plugin.failOnError>true</findbugs-maven-plugin.failOnError>
|
||||
<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.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>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.scm</groupId>
|
||||
<artifactId>maven-scm-provider-gitexe</artifactId>
|
||||
<version>1.11.2</version>
|
||||
</extension>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.scm</groupId>
|
||||
<artifactId>maven-scm-manager-plexus</artifactId>
|
||||
<version>1.11.2</version>
|
||||
</extension>
|
||||
<!-- Doing site publishing manually for now -->
|
||||
<!--
|
||||
<extension>
|
||||
<groupId>org.kohsuke</groupId>
|
||||
<artifactId>wagon-gitsite</artifactId>
|
||||
<version>0.3.5</version>
|
||||
</extension>
|
||||
-->
|
||||
</extensions>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
<excludes>
|
||||
<exclude>**/wiremock/**</exclude>
|
||||
</excludes>
|
||||
</testResource>
|
||||
</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>
|
||||
<version>3.2.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<!-- attached to Maven test phase -->
|
||||
<execution>
|
||||
<id>report</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>check</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<rule>
|
||||
<element>BUNDLE</element>
|
||||
<limits>
|
||||
<limit>
|
||||
<counter>METHOD</counter>
|
||||
<value>COVEREDRATIO</value>
|
||||
<minimum>${jacoco.coverage.target.bundle.method}</minimum>
|
||||
</limit>
|
||||
</limits>
|
||||
</rule>
|
||||
<rule>
|
||||
<!--We end up with chatty logs, but it shows us which particular classes -->
|
||||
<!--are lacking in coverage. If this is too much, just remove the -->
|
||||
<!--<element>CLASS</element> tag below. -->
|
||||
<element>CLASS</element>
|
||||
<limits>
|
||||
<limit>
|
||||
<counter>METHOD</counter>
|
||||
<value>COVEREDRATIO</value>
|
||||
<minimum>${jacoco.coverage.target.class.method}</minimum>
|
||||
</limit>
|
||||
</limits>
|
||||
<excludes>
|
||||
<!-- Code implemented externally -->
|
||||
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory.**</exclude>
|
||||
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory</exclude>
|
||||
|
||||
<!-- Sample only -->
|
||||
<exclude>org.kohsuke.github.example.*</exclude>
|
||||
|
||||
<!-- No methods -->
|
||||
<exclude>org.kohsuke.github.internal.Previews</exclude>
|
||||
|
||||
<!-- Deprecated -->
|
||||
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
|
||||
<exclude>org.kohsuke.github.EnforcementLevel</exclude>
|
||||
<exclude>org.kohsuke.github.GHPerson.1</exclude>
|
||||
|
||||
<!-- These fail coverage on windows because tests are disabled -->
|
||||
<exclude>org.kohsuke.github.GHAsset</exclude>
|
||||
<exclude>org.kohsuke.github.GHReleaseBuilder</exclude>
|
||||
<exclude>org.kohsuke.github.GHRelease</exclude>
|
||||
|
||||
<!-- TODO: These still need test coverage -->
|
||||
<exclude>org.kohsuke.github.GHBranchProtection.RequiredSignatures</exclude>
|
||||
<exclude>org.kohsuke.github.GHBranchProtectionBuilder.Restrictions</exclude>
|
||||
<exclude>org.kohsuke.github.GHBranchProtection.Restrictions</exclude>
|
||||
<exclude>org.kohsuke.github.GHCommentAuthorAssociation</exclude>
|
||||
<exclude>org.kohsuke.github.GHCommitBuilder.UserInfo</exclude>
|
||||
<exclude>org.kohsuke.github.GHCommitState</exclude>
|
||||
<exclude>org.kohsuke.github.GHCompare.Commit</exclude>
|
||||
<exclude>org.kohsuke.github.GHCompare.InnerCommit</exclude>
|
||||
<exclude>org.kohsuke.github.GHCompare.Status</exclude>
|
||||
<exclude>org.kohsuke.github.GHCompare.Tree</exclude>
|
||||
<exclude>org.kohsuke.github.GHCompare.User</exclude>
|
||||
<exclude>org.kohsuke.github.GHCompare</exclude>
|
||||
<exclude>org.kohsuke.github.GHDeployKey</exclude>
|
||||
<exclude>org.kohsuke.github.GHDeploymentStatusBuilder</exclude>
|
||||
<exclude>org.kohsuke.github.GHDirection</exclude>
|
||||
<exclude>org.kohsuke.github.GHEmail</exclude>
|
||||
<exclude>org.kohsuke.github.GHEventPayload.Ping</exclude>
|
||||
<exclude>org.kohsuke.github.GHEventPayload.Release</exclude>
|
||||
<exclude>org.kohsuke.github.GHException</exclude>
|
||||
<exclude>org.kohsuke.github.GHHook</exclude>
|
||||
<exclude>org.kohsuke.github.GHHooks.OrgContext</exclude>
|
||||
<exclude>org.kohsuke.github.GHInvitation</exclude>
|
||||
<exclude>org.kohsuke.github.GHMilestoneState</exclude>
|
||||
<exclude>org.kohsuke.github.GHOrgHook</exclude>
|
||||
<exclude>org.kohsuke.github.GHProject.ProjectStateFilter</exclude>
|
||||
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Authorship</exclude>
|
||||
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Commit</exclude>
|
||||
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.CommitPointer</exclude>
|
||||
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Tree</exclude>
|
||||
<exclude>org.kohsuke.github.GHPullRequestCommitDetail</exclude>
|
||||
<exclude>org.kohsuke.github.GHPullRequestFileDetail</exclude>
|
||||
<exclude>org.kohsuke.github.GHPullRequestQueryBuilder.Sort</exclude>
|
||||
<exclude>org.kohsuke.github.GHReleaseUpdater</exclude>
|
||||
<exclude>org.kohsuke.github.GHRepository.ForkSort</exclude>
|
||||
<exclude>org.kohsuke.github.GHRequestedAction</exclude>
|
||||
<exclude>org.kohsuke.github.GHStargazer</exclude>
|
||||
<exclude>org.kohsuke.github.GHTagObject</exclude>
|
||||
<exclude>org.kohsuke.github.GHTeam.Role</exclude>
|
||||
<exclude>org.kohsuke.github.GHUserSearchBuilder.Sort</exclude>
|
||||
<exclude>org.kohsuke.github.GHVerifiedKey</exclude>
|
||||
</excludes>
|
||||
</rule>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<failOnWarnings>true</failOnWarnings>
|
||||
<doclint>all</doclint>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.8</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>sonatype-nexus-staging</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.9.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
<configuration>
|
||||
<rerunFailingTestsCount>2</rerunFailingTestsCount>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<useReleaseProfile>false</useReleaseProfile>
|
||||
<releaseProfiles>release</releaseProfiles>
|
||||
<goals>deploy</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.bcel</groupId>
|
||||
<artifactId>bcel</artifactId>
|
||||
<version>6.5.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<annotationProcessorPaths>
|
||||
<annotationProcessorPath>
|
||||
<groupId>org.jenkins-ci</groupId>
|
||||
<artifactId>annotation-indexer</artifactId>
|
||||
<version>1.12</version>
|
||||
</annotationProcessorPath>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<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.15</version>
|
||||
<version>1.19</version>
|
||||
<configuration>
|
||||
<signature>
|
||||
<groupId>org.codehaus.mojo.signature</groupId>
|
||||
<artifactId>java15</artifactId>
|
||||
<artifactId>java18</artifactId>
|
||||
<version>1.0</version>
|
||||
</signature>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>ensure-java-1.5-class-library</id>
|
||||
<id>ensure-java-1.8-class-library</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
@@ -64,7 +333,7 @@
|
||||
<plugin>
|
||||
<groupId>com.infradna.tool</groupId>
|
||||
<artifactId>bridge-method-injector</artifactId>
|
||||
<version>1.14</version>
|
||||
<version>1.18</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -74,57 +343,137 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<version>${findbugs-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<xmlOutput>true</xmlOutput>
|
||||
<failOnError>${findbugs-maven-plugin.failOnError}</failOnError>
|
||||
</configuration>
|
||||
<groupId>com.diffplug.spotless</groupId>
|
||||
<artifactId>spotless-maven-plugin</artifactId>
|
||||
<version>2.6.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>run-findbugs</id>
|
||||
<phase>verify</phase>
|
||||
<id>spotless-check</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
<goal>${spotless-maven-plugin.goal}</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<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>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||
<version>${spotbugs-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<xmlOutput>true</xmlOutput>
|
||||
<failOnError>${spotbugs-maven-plugin.failOnError}</failOnError>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>run-spotbugs</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
|
||||
<dependency>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs</artifactId>
|
||||
<version>${spotbugs.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.7</version>
|
||||
<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>
|
||||
<version>${hamcrest.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- This is needed in order to force junit4 and JTH tests to use newer hamcrest version -->
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<version>${hamcrest.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<version>${hamcrest.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.2.3</version>
|
||||
<version>2.10.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.infradna.tool</groupId>
|
||||
<artifactId>bridge-method-annotation</artifactId>
|
||||
<version>1.14</version>
|
||||
<version>1.18</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- for stapler-jetty -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- for stapler-jetty -->
|
||||
<dependency>
|
||||
<groupId>commons-discovery</groupId>
|
||||
<artifactId>commons-discovery</artifactId>
|
||||
<version>0.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- for stapler-jetty -->
|
||||
<dependency>
|
||||
<groupId>org.kohsuke.stapler</groupId>
|
||||
<artifactId>stapler</artifactId>
|
||||
<version>1.262</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kohsuke.stapler</groupId>
|
||||
@@ -135,9 +484,47 @@
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jgit</groupId>
|
||||
<artifactId>org.eclipse.jgit</artifactId>
|
||||
<version>3.1.0.201310021548-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>
|
||||
<version>${okio.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>${okhttp3.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- This is the last version of okhttp3 that support UrlConnection -->
|
||||
<!-- The class using this has been deprecated, this dependency can be remove when that class is. -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp-urlconnection</artifactId>
|
||||
<version>3.12.3</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp</groupId>
|
||||
<artifactId>okhttp-urlconnection</artifactId>
|
||||
@@ -147,48 +534,173 @@
|
||||
<dependency>
|
||||
<groupId>org.kohsuke</groupId>
|
||||
<artifactId>wordnet-random-name</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.6.28</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-annotations</artifactId>
|
||||
<version>${spotbugs.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock-jre8-standalone</artifactId>
|
||||
<version>2.27.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<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>
|
||||
<id>repo.jenkins-ci.org</id>
|
||||
<url>http://repo.jenkins-ci.org/public/</url>
|
||||
<url>https://repo.jenkins-ci.org/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>repo.jenkins-ci.org</id>
|
||||
<url>http://repo.jenkins-ci.org/public/</url>
|
||||
<url>https://repo.jenkins-ci.org/public/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>ci-non-windows</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>enable-ci</name>
|
||||
</property>
|
||||
<os>
|
||||
<family>!windows</family>
|
||||
</os>
|
||||
</activation>
|
||||
<properties>
|
||||
<spotless-maven-plugin.goal>check</spotless-maven-plugin.goal>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>ci-all</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>enable-ci</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<jacoco.haltOnFailure>true</jacoco.haltOnFailure>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<properties>
|
||||
<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>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<gpgArguments>
|
||||
<arg>--pinentry-mode</arg>
|
||||
<arg>loopback</arg>
|
||||
</gpgArguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</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>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The MIT license</name>
|
||||
<url>http://www.opensource.org/licenses/mit-license.php</url>
|
||||
<url>https://www.opensource.org/licenses/mit-license.php</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
@@ -200,4 +712,13 @@
|
||||
<archive>https://groups.google.com/forum/#!forum/github-api</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Kohsuke Kawaguchi</name>
|
||||
<id>kohsuke</id>
|
||||
<email>kk@kohsuke.org</email>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
</project>
|
||||
|
||||
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=\#
|
||||
383
src/build/eclipse/formatter.xml
Normal file
383
src/build/eclipse/formatter.xml
Normal file
@@ -0,0 +1,383 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<profiles version="17">
|
||||
<profile kind="CodeFormatterProfile" name="Java Conventions - GitHub-api" version="17">
|
||||
<!-- Make various elements turn to colums when they wrap -->
|
||||
<!-- Basically the only way to create this is by downloading eclipse and working in their UI -->
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
|
||||
</profile>
|
||||
<!-- Keeping the "default" exported values for reference -->
|
||||
<!--
|
||||
<profile kind="CodeFormatterProfile" name="Eclipse [built-in]-Default" version="17">
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||
</profile>
|
||||
-->
|
||||
</profiles>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import java.net.HttpURLConnection;
|
||||
* Pluggable strategy to determine what to do when the API abuse limit is hit.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler)
|
||||
* @see GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler) GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler)
|
||||
* @see <a href="https://developer.github.com/v3/#abuse-rate-limits">documentation</a>
|
||||
* @see RateLimitHandler
|
||||
*/
|
||||
@@ -17,16 +17,22 @@ public abstract class AbuseLimitHandler {
|
||||
* Called when the library encounters HTTP error indicating that the API abuse limit is reached.
|
||||
*
|
||||
* <p>
|
||||
* Any exception thrown from this method will cause the request to fail, and the caller of github-api
|
||||
* will receive an exception. If this method returns normally, another request will be attempted.
|
||||
* For that to make sense, the implementation needs to wait for some time.
|
||||
* Any exception thrown from this method will cause the request to fail, and the caller of github-api will receive
|
||||
* an exception. If this method returns normally, another request will be attempted. For that to make sense, the
|
||||
* implementation needs to wait for some time.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/#abuse-rate-limits">API documentation from GitHub</a>
|
||||
* @param e
|
||||
* Exception from Java I/O layer. If you decide to fail the processing, you can throw
|
||||
* this exception (or wrap this exception into another exception and throw it.)
|
||||
* Exception from Java I/O layer. If you decide to fail the processing, you can throw this exception (or
|
||||
* wrap this exception into another exception and throw it).
|
||||
* @param uc
|
||||
* Connection that resulted in an error. Useful for accessing other response headers.
|
||||
* Connection that resulted in an error. Useful for accessing other response headers.
|
||||
* @throws IOException
|
||||
* on failure
|
||||
* @see <a href="https://developer.github.com/v3/#abuse-rate-limits">API documentation from GitHub</a>
|
||||
* @see <a href=
|
||||
* "https://developer.github.com/v3/guides/best-practices-for-integrators/#dealing-with-abuse-rate-limits">Dealing
|
||||
* with abuse rate limits</a>
|
||||
*
|
||||
*/
|
||||
public abstract void onError(IOException e, HttpURLConnection uc) throws IOException;
|
||||
|
||||
@@ -38,16 +44,17 @@ public abstract class AbuseLimitHandler {
|
||||
public void onError(IOException e, HttpURLConnection uc) throws IOException {
|
||||
try {
|
||||
Thread.sleep(parseWaitTime(uc));
|
||||
} catch (InterruptedException _) {
|
||||
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
|
||||
} catch (InterruptedException ex) {
|
||||
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private long parseWaitTime(HttpURLConnection uc) {
|
||||
String v = uc.getHeaderField("Retry-After");
|
||||
if (v==null) return 60 * 1000; // can't tell, return 1 min
|
||||
if (v == null)
|
||||
return 60 * 1000; // can't tell, return 1 min
|
||||
|
||||
return Math.max(1000, Long.parseLong(v)*1000);
|
||||
return Math.max(1000, Long.parseLong(v) * 1000);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,7 +64,7 @@ public abstract class AbuseLimitHandler {
|
||||
public static final AbuseLimitHandler FAIL = new AbuseLimitHandler() {
|
||||
@Override
|
||||
public void onError(IOException e, HttpURLConnection uc) throws IOException {
|
||||
throw (IOException)new IOException("Abust limit reached").initCause(e);
|
||||
throw (IOException) new IOException("Abuse limit reached").initCause(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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 {
|
||||
}
|
||||
292
src/main/java/org/kohsuke/github/GHApp.java
Normal file
292
src/main/java/org/kohsuke/github/GHApp.java
Normal file
@@ -0,0 +1,292 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||
|
||||
/**
|
||||
* A Github App.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GitHub#getApp() GitHub#getApp()
|
||||
*/
|
||||
public class GHApp extends GHObject {
|
||||
|
||||
private GHUser owner;
|
||||
private String name;
|
||||
private String description;
|
||||
private String externalUrl;
|
||||
private Map<String, String> permissions;
|
||||
private List<GHEvent> events;
|
||||
private long installationsCount;
|
||||
private String htmlUrl;
|
||||
|
||||
/**
|
||||
* Gets owner.
|
||||
*
|
||||
* @return the owner
|
||||
*/
|
||||
public GHUser getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets owner.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets name.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets description.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets external url.
|
||||
*
|
||||
* @return the external url
|
||||
*/
|
||||
public String getExternalUrl() {
|
||||
return externalUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets external url.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets events.
|
||||
*
|
||||
* @return the events
|
||||
*/
|
||||
public List<GHEvent> getEvents() {
|
||||
return events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets events.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets installations count.
|
||||
*
|
||||
* @return the installations count
|
||||
*/
|
||||
public long getInstallationsCount() {
|
||||
return installationsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets installations count.
|
||||
*
|
||||
* @param installationsCount
|
||||
* the installations count
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setInstallationsCount(long installationsCount) {
|
||||
this.installationsCount = installationsCount;
|
||||
}
|
||||
|
||||
public URL getHtmlUrl() {
|
||||
return GitHubClient.parseURL(htmlUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets permissions.
|
||||
*
|
||||
* @return the permissions
|
||||
*/
|
||||
public Map<String, String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets permissions.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
GHApp wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains all the installations associated with this app.
|
||||
* <p>
|
||||
* You must use a JWT to access this endpoint.
|
||||
*
|
||||
* @return a list of App installations
|
||||
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
|
||||
*/
|
||||
@Preview(MACHINE_MAN)
|
||||
@Deprecated
|
||||
public PagedIterable<GHAppInstallation> listInstallations() {
|
||||
return root.createRequest()
|
||||
.withPreview(MACHINE_MAN)
|
||||
.withUrlPath("/app/installations")
|
||||
.toIterable(GHAppInstallation[].class, item -> item.wrapUp(root));
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain an installation associated with this app.
|
||||
* <p>
|
||||
* You must use a JWT to access this endpoint.
|
||||
*
|
||||
* @param id
|
||||
* Installation Id
|
||||
* @return a GHAppInstallation
|
||||
* @throws IOException
|
||||
* on error
|
||||
* @see <a href="https://developer.github.com/v3/apps/#get-an-installation">Get an installation</a>
|
||||
*/
|
||||
@Preview(MACHINE_MAN)
|
||||
@Deprecated
|
||||
public GHAppInstallation getInstallationById(long id) throws IOException {
|
||||
return root.createRequest()
|
||||
.withPreview(MACHINE_MAN)
|
||||
.withUrlPath(String.format("/app/installations/%d", id))
|
||||
.fetch(GHAppInstallation.class)
|
||||
.wrapUp(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain an organization installation associated with this app.
|
||||
* <p>
|
||||
* You must use a JWT to access this endpoint.
|
||||
*
|
||||
* @param name
|
||||
* Organization name
|
||||
* @return a GHAppInstallation
|
||||
* @throws IOException
|
||||
* on error
|
||||
* @see <a href="https://developer.github.com/v3/apps/#get-an-organization-installation">Get an organization
|
||||
* installation</a>
|
||||
*/
|
||||
@Preview(MACHINE_MAN)
|
||||
@Deprecated
|
||||
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
|
||||
return root.createRequest()
|
||||
.withPreview(MACHINE_MAN)
|
||||
.withUrlPath(String.format("/orgs/%s/installation", name))
|
||||
.fetch(GHAppInstallation.class)
|
||||
.wrapUp(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain an repository installation associated with this app.
|
||||
* <p>
|
||||
* You must use a JWT to access this endpoint.
|
||||
*
|
||||
* @param ownerName
|
||||
* Organization or user name
|
||||
* @param repositoryName
|
||||
* Repository name
|
||||
* @return a GHAppInstallation
|
||||
* @throws IOException
|
||||
* on error
|
||||
* @see <a href="https://developer.github.com/v3/apps/#get-a-repository-installation">Get a repository
|
||||
* installation</a>
|
||||
*/
|
||||
@Preview(MACHINE_MAN)
|
||||
@Deprecated
|
||||
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
|
||||
return root.createRequest()
|
||||
.withPreview(MACHINE_MAN)
|
||||
.withUrlPath(String.format("/repos/%s/%s/installation", ownerName, repositoryName))
|
||||
.fetch(GHAppInstallation.class)
|
||||
.wrapUp(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a user installation associated with this app.
|
||||
* <p>
|
||||
* You must use a JWT to access this endpoint.
|
||||
*
|
||||
* @param name
|
||||
* user name
|
||||
* @return a GHAppInstallation
|
||||
* @throws IOException
|
||||
* on error
|
||||
* @see <a href="https://developer.github.com/v3/apps/#get-a-user-installation">Get a user installation</a>
|
||||
*/
|
||||
@Preview(MACHINE_MAN)
|
||||
@Deprecated
|
||||
public GHAppInstallation getInstallationByUser(String name) throws IOException {
|
||||
return root.createRequest()
|
||||
.withPreview(MACHINE_MAN)
|
||||
.withUrlPath(String.format("/users/%s/installation", name))
|
||||
.fetch(GHAppInstallation.class)
|
||||
.wrapUp(root);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||
|
||||
/**
|
||||
* Creates a access token for a GitHub App Installation
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
|
||||
* @see GHAppInstallation#createToken() GHAppInstallation#createToken()
|
||||
*/
|
||||
public class GHAppCreateTokenBuilder extends GitHubInteractiveObject {
|
||||
protected final Requester builder;
|
||||
private final String apiUrlTail;
|
||||
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail) {
|
||||
this.root = root;
|
||||
this.apiUrlTail = apiUrlTail;
|
||||
this.builder = root.createRequest();
|
||||
}
|
||||
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
|
||||
this(root, apiUrlTail);
|
||||
permissions(permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* By default the installation token has access to all repositories that the installation can access. To restrict
|
||||
* the access to specific repositories, you can provide the repository_ids when creating the token. When you omit
|
||||
* repository_ids, the response does not contain neither the repositories nor the permissions key.
|
||||
*
|
||||
* @param repositoryIds
|
||||
* Array containing the repositories Ids
|
||||
* @return a GHAppCreateTokenBuilder
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
|
||||
this.builder.with("repository_ids", repositoryIds);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the permissions granted to the access token. The permissions object includes the permission names and their
|
||||
* access type.
|
||||
*
|
||||
* @param permissions
|
||||
* Map containing the permission names and types.
|
||||
* @return a GHAppCreateTokenBuilder
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permissions) {
|
||||
Map<String, String> retMap = new HashMap<>();
|
||||
for (Map.Entry<String, GHPermissionType> entry : permissions.entrySet()) {
|
||||
retMap.put(entry.getKey(), GitHubRequest.transformEnum(entry.getValue()));
|
||||
}
|
||||
builder.with("permissions", retMap);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an app token with all the parameters.
|
||||
* <p>
|
||||
* You must use a JWT to access this endpoint.
|
||||
*
|
||||
* @return a GHAppInstallationToken
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
@Preview(MACHINE_MAN)
|
||||
@Deprecated
|
||||
public GHAppInstallationToken create() throws IOException {
|
||||
return builder.method("POST")
|
||||
.withPreview(MACHINE_MAN)
|
||||
.withUrlPath(apiUrlTail)
|
||||
.fetch(GHAppInstallationToken.class)
|
||||
.wrapUp(root);
|
||||
}
|
||||
|
||||
}
|
||||
368
src/main/java/org/kohsuke/github/GHAppInstallation.java
Normal file
368
src/main/java/org/kohsuke/github/GHAppInstallation.java
Normal file
@@ -0,0 +1,368 @@
|
||||
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.internal.Previews.GAMBIT;
|
||||
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||
|
||||
/**
|
||||
* A Github App Installation.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GHApp#listInstallations() GHApp#listInstallations()
|
||||
* @see GHApp#getInstallationById(long) GHApp#getInstallationById(long)
|
||||
* @see GHApp#getInstallationByOrganization(String) GHApp#getInstallationByOrganization(String)
|
||||
* @see GHApp#getInstallationByRepository(String, String) GHApp#getInstallationByRepository(String, String)
|
||||
* @see GHApp#getInstallationByUser(String) GHApp#getInstallationByUser(String)
|
||||
*/
|
||||
public class GHAppInstallation extends GHObject {
|
||||
private GHUser account;
|
||||
|
||||
@JsonProperty("access_tokens_url")
|
||||
private String accessTokenUrl;
|
||||
@JsonProperty("repositories_url")
|
||||
private String repositoriesUrl;
|
||||
@JsonProperty("app_id")
|
||||
private long appId;
|
||||
@JsonProperty("target_id")
|
||||
private long targetId;
|
||||
@JsonProperty("target_type")
|
||||
private GHTargetType targetType;
|
||||
private Map<String, GHPermissionType> permissions;
|
||||
private List<GHEvent> events;
|
||||
@JsonProperty("single_file_name")
|
||||
private String singleFileName;
|
||||
@JsonProperty("repository_selection")
|
||||
private GHRepositorySelection repositorySelection;
|
||||
private String htmlUrl;
|
||||
|
||||
public URL getHtmlUrl() {
|
||||
return GitHubClient.parseURL(htmlUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets root.
|
||||
*
|
||||
* @return the root
|
||||
*/
|
||||
public GitHub getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets root.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets account.
|
||||
*
|
||||
* @return the account
|
||||
*/
|
||||
public GHUser getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets account.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets access token url.
|
||||
*
|
||||
* @return the access token url
|
||||
*/
|
||||
public String getAccessTokenUrl() {
|
||||
return accessTokenUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets access token url.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets repositories url.
|
||||
*
|
||||
* @return the repositories url
|
||||
*/
|
||||
public String getRepositoriesUrl() {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets app id.
|
||||
*
|
||||
* @return the app id
|
||||
*/
|
||||
public long getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets app id.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets target id.
|
||||
*
|
||||
* @return the target id
|
||||
*/
|
||||
public long getTargetId() {
|
||||
return targetId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets target id.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets target type.
|
||||
*
|
||||
* @return the target type
|
||||
*/
|
||||
public GHTargetType getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets target type.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets permissions.
|
||||
*
|
||||
* @return the permissions
|
||||
*/
|
||||
public Map<String, GHPermissionType> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets permissions.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets events.
|
||||
*
|
||||
* @return the events
|
||||
*/
|
||||
public List<GHEvent> getEvents() {
|
||||
return events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets events.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets single file name.
|
||||
*
|
||||
* @return the single file name
|
||||
*/
|
||||
public String getSingleFileName() {
|
||||
return singleFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets single file name.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets repository selection.
|
||||
*
|
||||
* @return the repository selection
|
||||
*/
|
||||
public GHRepositorySelection getRepositorySelection() {
|
||||
return repositorySelection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repository selection.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
GHAppInstallation wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Github App installation
|
||||
* <p>
|
||||
* You must use a JWT to access this endpoint.
|
||||
*
|
||||
* @throws IOException
|
||||
* on error
|
||||
* @see <a href="https://developer.github.com/v3/apps/#delete-an-installation">Delete an installation</a>
|
||||
*/
|
||||
@Preview(GAMBIT)
|
||||
@Deprecated
|
||||
public void deleteInstallation() throws IOException {
|
||||
root.createRequest()
|
||||
.method("DELETE")
|
||||
.withPreview(GAMBIT)
|
||||
.withUrlPath(String.format("/app/installations/%d", getId()))
|
||||
.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a builder that creates a new App Installation Token.
|
||||
*
|
||||
* <p>
|
||||
* You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
|
||||
* finally create an access token.
|
||||
*
|
||||
* @param permissions
|
||||
* map of permissions for the created token
|
||||
* @return a GHAppCreateTokenBuilder instance
|
||||
* @deprecated Use {@link GHAppInstallation#createToken()} instead.
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permissions) {
|
||||
return new GHAppCreateTokenBuilder(root,
|
||||
String.format("/app/installations/%d/access_tokens", getId()),
|
||||
permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a builder that creates a new App Installation Token.
|
||||
*
|
||||
* <p>
|
||||
* You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
|
||||
* finally create an access token.
|
||||
*
|
||||
* @return a GHAppCreateTokenBuilder instance
|
||||
*/
|
||||
@BetaApi
|
||||
@Deprecated
|
||||
public GHAppCreateTokenBuilder createToken() {
|
||||
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", getId()));
|
||||
}
|
||||
}
|
||||
150
src/main/java/org/kohsuke/github/GHAppInstallationToken.java
Normal file
150
src/main/java/org/kohsuke/github/GHAppInstallationToken.java
Normal file
@@ -0,0 +1,150 @@
|
||||
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.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A Github App Installation Token.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
|
||||
*/
|
||||
public class GHAppInstallationToken extends GitHubInteractiveObject {
|
||||
private String token;
|
||||
protected String expires_at;
|
||||
private Map<String, String> permissions;
|
||||
private List<GHRepository> repositories;
|
||||
private GHRepositorySelection repositorySelection;
|
||||
|
||||
/**
|
||||
* Gets root.
|
||||
*
|
||||
* @return the root
|
||||
*/
|
||||
public GitHub getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets root.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets permissions.
|
||||
*
|
||||
* @return the permissions
|
||||
*/
|
||||
public Map<String, String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets permissions.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets token.
|
||||
*
|
||||
* @return the token
|
||||
*/
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets token.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets repositories.
|
||||
*
|
||||
* @return the repositories
|
||||
*/
|
||||
public List<GHRepository> getRepositories() {
|
||||
return repositories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repositories.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets repository selection.
|
||||
*
|
||||
* @return the repository selection
|
||||
*/
|
||||
public GHRepositorySelection getRepositorySelection() {
|
||||
return repositorySelection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repository selection.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets expires at.
|
||||
*
|
||||
* @return date when this token expires
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
@WithBridgeMethods(value = String.class, adapterMethod = "expiresAtStr")
|
||||
public Date getExpiresAt() throws IOException {
|
||||
return GitHubClient.parseDate(expires_at);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getExpiresAt")
|
||||
private Object expiresAtStr(Date id, Class type) {
|
||||
return expires_at;
|
||||
}
|
||||
|
||||
GHAppInstallationToken wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,9 @@ import java.net.URL;
|
||||
/**
|
||||
* Asset in a release.
|
||||
*
|
||||
* @see GHRelease#getAssets()
|
||||
* @see GHRelease#getAssets() GHRelease#getAssets()
|
||||
*/
|
||||
public class GHAsset extends GHObject {
|
||||
GitHub root;
|
||||
GHRepository owner;
|
||||
private String name;
|
||||
private String label;
|
||||
@@ -19,44 +18,100 @@ public class GHAsset extends GHObject {
|
||||
private long download_count;
|
||||
private String browser_download_url;
|
||||
|
||||
/**
|
||||
* Gets content type.
|
||||
*
|
||||
* @return the content type
|
||||
*/
|
||||
public String getContentType() {
|
||||
return content_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets content type.
|
||||
*
|
||||
* @param contentType
|
||||
* the content type
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setContentType(String contentType) throws IOException {
|
||||
edit("content_type", contentType);
|
||||
this.content_type = contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets download count.
|
||||
*
|
||||
* @return the download count
|
||||
*/
|
||||
public long getDownloadCount() {
|
||||
return download_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets label.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setLabel(String label) throws IOException {
|
||||
edit("label", label);
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets owner.
|
||||
*
|
||||
* @return the owner
|
||||
*/
|
||||
public GHRepository getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets root.
|
||||
*
|
||||
* @return the root
|
||||
*/
|
||||
public GitHub getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets size.
|
||||
*
|
||||
* @return the size
|
||||
*/
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets state.
|
||||
*
|
||||
* @return the state
|
||||
*/
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
@@ -69,21 +124,31 @@ public class GHAsset extends GHObject {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets browser download url.
|
||||
*
|
||||
* @return the browser download url
|
||||
*/
|
||||
public String getBrowserDownloadUrl() {
|
||||
return browser_download_url;
|
||||
}
|
||||
|
||||
private void edit(String key, Object value) throws IOException {
|
||||
new Requester(root)._with(key, value).method("PATCH").to(getApiRoute());
|
||||
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
new Requester(root).method("DELETE").to(getApiRoute());
|
||||
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
|
||||
}
|
||||
|
||||
|
||||
private String getApiRoute() {
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + id;
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + getId();
|
||||
}
|
||||
|
||||
GHAsset wrap(GHRelease release) {
|
||||
@@ -92,6 +157,15 @@ public class GHAsset extends GHObject {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap gh asset [ ].
|
||||
*
|
||||
* @param assets
|
||||
* the assets
|
||||
* @param release
|
||||
* the release
|
||||
* @return the gh asset [ ]
|
||||
*/
|
||||
public static GHAsset[] wrap(GHAsset[] assets, GHRelease release) {
|
||||
for (GHAsset aTo : assets) {
|
||||
aTo.wrap(release);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Generated OAuth token
|
||||
*
|
||||
* @author janinko
|
||||
* @see GitHub#createToken(Collection, String, String)
|
||||
* @see GitHub#createToken(Collection, String, String) GitHub#createToken(Collection, String, String)
|
||||
* @see <a href="http://developer.github.com/v3/oauth/#create-a-new-authorization">API documentation</a>
|
||||
*/
|
||||
public class GHAuthorization extends GHObject {
|
||||
@@ -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;
|
||||
@@ -42,41 +41,82 @@ public class GHAuthorization extends GHObject {
|
||||
private String note;
|
||||
private String note_url;
|
||||
private String fingerprint;
|
||||
//TODO add some user class for https://developer.github.com/v3/oauth_authorizations/#check-an-authorization ?
|
||||
//private GHUser user;
|
||||
// TODO add some user class for https://developer.github.com/v3/oauth_authorizations/#check-an-authorization ?
|
||||
// private GHUser user;
|
||||
|
||||
/**
|
||||
* Gets root.
|
||||
*
|
||||
* @return the root
|
||||
*/
|
||||
public GitHub getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets scopes.
|
||||
*
|
||||
* @return the scopes
|
||||
*/
|
||||
public List<String> getScopes() {
|
||||
return scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets token.
|
||||
*
|
||||
* @return the token
|
||||
*/
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets token last eight.
|
||||
*
|
||||
* @return the token last eight
|
||||
*/
|
||||
public String getTokenLastEight() {
|
||||
return token_last_eight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets hashed token.
|
||||
*
|
||||
* @return the hashed token
|
||||
*/
|
||||
public String getHashedToken() {
|
||||
return hashed_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets app url.
|
||||
*
|
||||
* @return the app url
|
||||
*/
|
||||
public URL getAppUrl() {
|
||||
return GitHub.parseURL(app.url);
|
||||
return GitHubClient.parseURL(app.url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets app name.
|
||||
*
|
||||
* @return the app name
|
||||
*/
|
||||
public String getAppName() {
|
||||
return app.name;
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = "NM_CONFUSING",
|
||||
justification = "It's a part of the library API, cannot be changed")
|
||||
/**
|
||||
* Gets api url.
|
||||
*
|
||||
* @return the api url
|
||||
* @deprecated use {@link #getUrl()}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library API, cannot be changed")
|
||||
public URL getApiURL() {
|
||||
return GitHub.parseURL(url);
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,25 +127,40 @@ public class GHAuthorization extends GHObject {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets note.
|
||||
*
|
||||
* @return the note
|
||||
*/
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets note url.
|
||||
*
|
||||
* @return the note url
|
||||
*/
|
||||
public URL getNoteUrl() {
|
||||
return GitHub.parseURL(note_url);
|
||||
return GitHubClient.parseURL(note_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets fingerprint.
|
||||
*
|
||||
* @return the fingerprint
|
||||
*/
|
||||
public String getFingerprint() {
|
||||
return fingerprint;
|
||||
}
|
||||
|
||||
/*package*/ GHAuthorization wrap(GitHub root) {
|
||||
GHAuthorization wrap(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD"},
|
||||
justification = "JSON API")
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" },
|
||||
justification = "JSON API")
|
||||
private static class App {
|
||||
private String url;
|
||||
private String name;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64InputStream;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* The type GHBlob.
|
||||
*
|
||||
* @author Kanstantsin Shautsou
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHTreeEntry#asBlob()
|
||||
* @see GHRepository#getBlob(String)
|
||||
* @see GHTreeEntry#asBlob() GHTreeEntry#asBlob()
|
||||
* @see GHRepository#getBlob(String) GHRepository#getBlob(String)
|
||||
* @see <a href="https://developer.github.com/v3/git/blobs/#get-a-blob">Get a blob</a>
|
||||
*/
|
||||
public class GHBlob {
|
||||
@@ -19,46 +19,65 @@ public class GHBlob {
|
||||
private long size;
|
||||
|
||||
/**
|
||||
* API URL of this blob.
|
||||
* Gets url.
|
||||
*
|
||||
* @return API URL of this blob.
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets sha.
|
||||
*
|
||||
* @return the sha
|
||||
*/
|
||||
public String getSha() {
|
||||
return sha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of bytes in this blob.
|
||||
* Gets size.
|
||||
*
|
||||
* @return Number of bytes in this blob.
|
||||
*/
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets encoding.
|
||||
*
|
||||
* @return the encoding
|
||||
*/
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encoded content. You probably want {@link #read()}
|
||||
* Gets content.
|
||||
*
|
||||
* @return Encoded content. You probably want {@link #read()}
|
||||
*/
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the actual bytes of the blob.
|
||||
* Read input stream.
|
||||
*
|
||||
* @return the actual bytes of the blob.
|
||||
*/
|
||||
public InputStream read() {
|
||||
if (encoding.equals("base64")) {
|
||||
try {
|
||||
return new Base64InputStream(new ByteArrayInputStream(content.getBytes("US-ASCII")), false);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new AssertionError(e); // US-ASCII is mandatory
|
||||
Base64.Decoder decoder = Base64.getMimeDecoder();
|
||||
return new ByteArrayInputStream(decoder.decode(content));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new AssertionError(e); // US-ASCII is mandatory
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("Unrecognized encoding: "+encoding);
|
||||
throw new UnsupportedOperationException("Unrecognized encoding: " + encoding);
|
||||
}
|
||||
}
|
||||
|
||||
59
src/main/java/org/kohsuke/github/GHBlobBuilder.java
Normal file
59
src/main/java/org/kohsuke/github/GHBlobBuilder.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* Builder pattern for creating a new blob. Based on https://developer.github.com/v3/git/blobs/#create-a-blob
|
||||
*/
|
||||
public class GHBlobBuilder {
|
||||
private final GHRepository repo;
|
||||
private final Requester req;
|
||||
|
||||
GHBlobBuilder(GHRepository repo) {
|
||||
this.repo = repo;
|
||||
req = repo.root.createRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a blob with the specified text {@code content}.
|
||||
*
|
||||
* @param content
|
||||
* string text of the blob
|
||||
* @return a GHBlobBuilder
|
||||
*/
|
||||
public GHBlobBuilder textContent(String content) {
|
||||
req.with("content", content);
|
||||
req.with("encoding", "utf-8");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a blob with the specified binary {@code content}.
|
||||
*
|
||||
* @param content
|
||||
* byte array of the blob
|
||||
* @return a GHBlobBuilder
|
||||
*/
|
||||
public GHBlobBuilder binaryContent(byte[] content) {
|
||||
String base64Content = Base64.getEncoder().encodeToString(content);
|
||||
req.with("content", base64Content);
|
||||
req.with("encoding", "base64");
|
||||
return this;
|
||||
}
|
||||
|
||||
private String getApiTail() {
|
||||
return String.format("/repos/%s/%s/git/blobs", repo.getOwnerName(), repo.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a blob based on the parameters specified thus far.
|
||||
*
|
||||
* @return a GHBlob
|
||||
* @throws IOException
|
||||
* if the blob cannot be created.
|
||||
*/
|
||||
public GHBlob create() throws IOException {
|
||||
return req.method("POST").withUrlPath(getApiTail()).fetch(GHBlob.class);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,27 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import static org.kohsuke.github.Previews.LOKI;
|
||||
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 com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
/**
|
||||
* A branch in a repository.
|
||||
*
|
||||
* @author Yusuke Kokubo
|
||||
*/
|
||||
@SuppressFBWarnings(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;
|
||||
@SuppressFBWarnings(
|
||||
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||
"URF_UNREAD_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHBranch extends GitHubInteractiveObject {
|
||||
private GHRepository owner;
|
||||
|
||||
private String name;
|
||||
@@ -27,7 +30,15 @@ public class GHBranch {
|
||||
private boolean protection;
|
||||
private String protection_url;
|
||||
|
||||
@JsonCreator
|
||||
GHBranch(@JsonProperty(value = "name", required = true) String name) throws Exception {
|
||||
Objects.requireNonNull(name);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type Commit.
|
||||
*/
|
||||
public static class Commit {
|
||||
String sha;
|
||||
|
||||
@@ -35,44 +46,76 @@ public class GHBranch {
|
||||
String url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets root.
|
||||
*
|
||||
* @return the root
|
||||
*/
|
||||
public GitHub getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repository that this branch is in.
|
||||
* Gets owner.
|
||||
*
|
||||
* @return the repository that this branch is in.
|
||||
*/
|
||||
public GHRepository getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the push to this branch is restricted via branch protection.
|
||||
* Is protected boolean.
|
||||
*
|
||||
* @return true if the push to this branch is restricted via branch protection.
|
||||
*/
|
||||
@Preview @Deprecated
|
||||
@Preview(Previews.LUKE_CAGE)
|
||||
@Deprecated
|
||||
public boolean isProtected() {
|
||||
return protection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns API URL that deals with the protection of this branch.
|
||||
* Gets protection url.
|
||||
*
|
||||
* @return API URL that deals with the protection of this branch.
|
||||
*/
|
||||
@Preview @Deprecated
|
||||
@Preview(Previews.LUKE_CAGE)
|
||||
@Deprecated
|
||||
public URL getProtectionUrl() {
|
||||
return GitHub.parseURL(protection_url);
|
||||
}
|
||||
|
||||
@Preview @Deprecated
|
||||
public GHBranchProtection getProtection() throws IOException {
|
||||
return root.retrieve().withPreview(LOKI).to(protection_url, GHBranchProtection.class);
|
||||
return GitHubClient.parseURL(protection_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* The commit that this branch currently points to.
|
||||
* Gets protection.
|
||||
*
|
||||
* @return the protection
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Preview(Previews.LUKE_CAGE)
|
||||
@Deprecated
|
||||
public GHBranchProtection getProtection() throws IOException {
|
||||
return root.createRequest()
|
||||
.withPreview(Previews.LUKE_CAGE)
|
||||
.setRawUrlPath(protection_url)
|
||||
.fetch(GHBranchProtection.class)
|
||||
.wrap(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets sha 1.
|
||||
*
|
||||
* @return The SHA1 of the commit that this branch currently points to.
|
||||
*/
|
||||
public String getSHA1() {
|
||||
return commit.sha;
|
||||
@@ -80,41 +123,107 @@ public class GHBranch {
|
||||
|
||||
/**
|
||||
* Disables branch protection and allows anyone with push access to push changes.
|
||||
*
|
||||
* @throws IOException
|
||||
* if disabling protection fails
|
||||
*/
|
||||
@Preview @Deprecated
|
||||
public void disableProtection() throws IOException {
|
||||
new Requester(root).method("DELETE").withPreview(LOKI).to(protection_url);
|
||||
root.createRequest().method("DELETE").setRawUrlPath(protection_url).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables branch protection to control what commit statuses are required to push.
|
||||
*
|
||||
* @see GHCommitStatus#getContext()
|
||||
* @return GHBranchProtectionBuilder for enabling protection
|
||||
* @see GHCommitStatus#getContext() GHCommitStatus#getContext()
|
||||
*/
|
||||
@Preview @Deprecated
|
||||
@Preview(Previews.LUKE_CAGE)
|
||||
@Deprecated
|
||||
public GHBranchProtectionBuilder enableProtection() {
|
||||
return new GHBranchProtectionBuilder(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable protection.
|
||||
*
|
||||
* @param level
|
||||
* the level
|
||||
* @param contexts
|
||||
* the contexts
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
// backward compatibility with previous signature
|
||||
@Deprecated
|
||||
public void enableProtection(EnforcementLevel level, Collection<String> contexts) throws IOException {
|
||||
switch (level) {
|
||||
case OFF:
|
||||
disableProtection();
|
||||
break;
|
||||
case NON_ADMINS:
|
||||
case EVERYONE:
|
||||
enableProtection()
|
||||
.addRequiredChecks(contexts)
|
||||
.includeAdmins(level==EnforcementLevel.EVERYONE)
|
||||
.enable();
|
||||
break;
|
||||
case OFF :
|
||||
disableProtection();
|
||||
break;
|
||||
case NON_ADMINS :
|
||||
case EVERYONE :
|
||||
enableProtection().addRequiredChecks(contexts)
|
||||
.includeAdmins(level == EnforcementLevel.EVERYONE)
|
||||
.enable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
return owner.getApiTailUrl("/branches/" + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,7 +232,7 @@ public class GHBranch {
|
||||
return "Branch:" + name + " in " + url;
|
||||
}
|
||||
|
||||
/*package*/ GHBranch wrap(GHRepository repo) {
|
||||
GHBranch wrap(GHRepository repo) {
|
||||
this.owner = repo;
|
||||
this.root = repo.root;
|
||||
return this;
|
||||
|
||||
@@ -1,152 +1,350 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||
"URF_UNREAD_FIELD" }, justification = "JSON API")
|
||||
public class GHBranchProtection {
|
||||
@JsonProperty("enforce_admins")
|
||||
private EnforceAdmins enforceAdmins;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
@JsonProperty("required_pull_request_reviews")
|
||||
private RequiredReviews requiredReviews;
|
||||
import static org.kohsuke.github.internal.Previews.ZZZAX;
|
||||
|
||||
@JsonProperty("required_status_checks")
|
||||
private RequiredStatusChecks requiredStatusChecks;
|
||||
/**
|
||||
* 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 extends GitHubInteractiveObject {
|
||||
private static final String REQUIRE_SIGNATURES_URI = "/required_signatures";
|
||||
|
||||
@JsonProperty
|
||||
private Restrictions restrictions;
|
||||
@JsonProperty
|
||||
private EnforceAdmins enforceAdmins;
|
||||
|
||||
@JsonProperty
|
||||
private String url;
|
||||
|
||||
public EnforceAdmins getEnforceAdmins() {
|
||||
@JsonProperty("required_pull_request_reviews")
|
||||
private RequiredReviews requiredReviews;
|
||||
|
||||
@JsonProperty
|
||||
private RequiredStatusChecks requiredStatusChecks;
|
||||
|
||||
@JsonProperty
|
||||
private Restrictions restrictions;
|
||||
|
||||
@JsonProperty
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Enabled signed commits.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Preview(ZZZAX)
|
||||
@Deprecated
|
||||
public void enabledSignedCommits() throws IOException {
|
||||
requester().method("POST").withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable signed commits.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Preview(ZZZAX)
|
||||
@Deprecated
|
||||
public void disableSignedCommits() throws IOException {
|
||||
requester().method("DELETE").withUrlPath(url + REQUIRE_SIGNATURES_URI).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets enforce admins.
|
||||
*
|
||||
* @return the enforce admins
|
||||
*/
|
||||
public EnforceAdmins getEnforceAdmins() {
|
||||
return enforceAdmins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets required reviews.
|
||||
*
|
||||
* @return the required reviews
|
||||
*/
|
||||
public RequiredReviews getRequiredReviews() {
|
||||
return requiredReviews;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets required signatures.
|
||||
*
|
||||
* @return the required signatures
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Preview(ZZZAX)
|
||||
@Deprecated
|
||||
public boolean getRequiredSignatures() throws IOException {
|
||||
return requester().withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class).enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets required status checks.
|
||||
*
|
||||
* @return the required status checks
|
||||
*/
|
||||
public RequiredStatusChecks getRequiredStatusChecks() {
|
||||
return requiredStatusChecks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets restrictions.
|
||||
*
|
||||
* @return the restrictions
|
||||
*/
|
||||
public Restrictions getRestrictions() {
|
||||
return restrictions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
GHBranchProtection wrap(GHBranch branch) {
|
||||
this.root = branch.getRoot();
|
||||
return this;
|
||||
}
|
||||
|
||||
private Requester requester() {
|
||||
return root.createRequest().withPreview(ZZZAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* The type EnforceAdmins.
|
||||
*/
|
||||
public static class EnforceAdmins {
|
||||
@JsonProperty
|
||||
private boolean enabled;
|
||||
@JsonProperty
|
||||
private boolean enabled;
|
||||
|
||||
@JsonProperty
|
||||
private String url;
|
||||
@JsonProperty
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is enabled boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class RequiredReviews {
|
||||
@JsonProperty("dismissal_restrictions")
|
||||
private Restrictions dismissalRestriction;
|
||||
/**
|
||||
* The type RequiredReviews.
|
||||
*/
|
||||
public static class RequiredReviews {
|
||||
@JsonProperty("dismissal_restrictions")
|
||||
private Restrictions dismissalRestriction;
|
||||
|
||||
@JsonProperty("dismiss_stale_reviews")
|
||||
private boolean dismissStaleReviews;
|
||||
private boolean dismissStaleReviews;
|
||||
|
||||
@JsonProperty("require_code_owner_reviews")
|
||||
private boolean requireCodeOwnerReviews;
|
||||
private boolean requireCodeOwnerReviews;
|
||||
|
||||
@JsonProperty
|
||||
private String url;
|
||||
@JsonProperty("required_approving_review_count")
|
||||
private int requiredReviewers;
|
||||
|
||||
@JsonProperty
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Gets dismissal restrictions.
|
||||
*
|
||||
* @return the dismissal restrictions
|
||||
*/
|
||||
public Restrictions getDismissalRestrictions() {
|
||||
return dismissalRestriction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is dismiss stale reviews boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isDismissStaleReviews() {
|
||||
return dismissStaleReviews;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is require code owner reviews boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isRequireCodeOwnerReviews() {
|
||||
return requireCodeOwnerReviews;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RequiredStatusChecks {
|
||||
@JsonProperty
|
||||
private Collection<String> contexts;
|
||||
/**
|
||||
* Gets required reviewers.
|
||||
*
|
||||
* @return the required reviewers
|
||||
*/
|
||||
public int getRequiredReviewers() {
|
||||
return requiredReviewers;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
private boolean strict;
|
||||
private static class RequiredSignatures {
|
||||
@JsonProperty
|
||||
private boolean enabled;
|
||||
|
||||
@JsonProperty
|
||||
private String url;
|
||||
@JsonProperty
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is enabled boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The type RequiredStatusChecks.
|
||||
*/
|
||||
public static class RequiredStatusChecks {
|
||||
@JsonProperty
|
||||
private Collection<String> contexts;
|
||||
|
||||
@JsonProperty
|
||||
private boolean strict;
|
||||
|
||||
@JsonProperty
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Gets contexts.
|
||||
*
|
||||
* @return the contexts
|
||||
*/
|
||||
public Collection<String> getContexts() {
|
||||
return contexts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is requires branch up to date boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isRequiresBranchUpToDate() {
|
||||
return strict;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Restrictions {
|
||||
@JsonProperty
|
||||
private Collection<GHTeam> teams;
|
||||
/**
|
||||
* The type Restrictions.
|
||||
*/
|
||||
public static class Restrictions {
|
||||
@JsonProperty
|
||||
private Collection<GHTeam> teams;
|
||||
|
||||
@JsonProperty("teams_url")
|
||||
private String teamsUrl;
|
||||
private String teamsUrl;
|
||||
|
||||
@JsonProperty
|
||||
private String url;
|
||||
@JsonProperty
|
||||
private String url;
|
||||
|
||||
@JsonProperty
|
||||
private Collection<GHUser> users;
|
||||
@JsonProperty
|
||||
private Collection<GHUser> users;
|
||||
|
||||
@JsonProperty("users_url")
|
||||
private String usersUrl;
|
||||
private String usersUrl;
|
||||
|
||||
/**
|
||||
* Gets teams.
|
||||
*
|
||||
* @return the teams
|
||||
*/
|
||||
public Collection<GHTeam> getTeams() {
|
||||
return teams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets teams url.
|
||||
*
|
||||
* @return the teams url
|
||||
*/
|
||||
public String getTeamsUrl() {
|
||||
return teamsUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets users.
|
||||
*
|
||||
* @return the users
|
||||
*/
|
||||
public Collection<GHUser> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets users url.
|
||||
*
|
||||
* @return the users url
|
||||
*/
|
||||
public String getUsersUrl() {
|
||||
return usersUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import static org.kohsuke.github.Previews.LOKI;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -12,15 +12,17 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import static org.kohsuke.github.internal.Previews.LUKE_CAGE;
|
||||
|
||||
/**
|
||||
* Builder to configure the branch protection settings.
|
||||
*
|
||||
* @see GHBranch#enableProtection()
|
||||
* @see GHBranch#enableProtection() GHBranch#enableProtection()
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||
"URF_UNREAD_FIELD" }, justification = "JSON API")
|
||||
@SuppressFBWarnings(
|
||||
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||
"URF_UNREAD_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHBranchProtectionBuilder {
|
||||
private final GHBranch branch;
|
||||
|
||||
@@ -33,67 +35,186 @@ public class GHBranchProtectionBuilder {
|
||||
this.branch = branch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add required checks gh branch protection builder.
|
||||
*
|
||||
* @param checks
|
||||
* the checks
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder addRequiredChecks(Collection<String> checks) {
|
||||
getStatusChecks().contexts.addAll(checks);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add required checks gh branch protection builder.
|
||||
*
|
||||
* @param checks
|
||||
* the checks
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder addRequiredChecks(String... checks) {
|
||||
addRequiredChecks(Arrays.asList(checks));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss stale reviews gh branch protection builder.
|
||||
*
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder dismissStaleReviews() {
|
||||
getPrReviews().put("dismiss_stale_reviews", true);
|
||||
return dismissStaleReviews(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss stale reviews gh branch protection builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder dismissStaleReviews(boolean v) {
|
||||
getPrReviews().put("dismiss_stale_reviews", v);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable gh branch protection.
|
||||
*
|
||||
* @return the gh branch protection
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHBranchProtection enable() throws IOException {
|
||||
return requester().method("PUT")
|
||||
.withNullable("required_status_checks", statusChecks)
|
||||
.withNullable("required_pull_request_reviews", prReviews)
|
||||
.withNullable("restrictions", restrictions)
|
||||
.withNullable("enforce_admins", enforceAdmins)
|
||||
.to(branch.getProtectionUrl().toString(), GHBranchProtection.class);
|
||||
.withUrlPath(branch.getProtectionUrl().toString())
|
||||
.fetch(GHBranchProtection.class)
|
||||
.wrap(branch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Include admins gh branch protection builder.
|
||||
*
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder includeAdmins() {
|
||||
return includeAdmins(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Include admins gh branch protection builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder includeAdmins(boolean v) {
|
||||
enforceAdmins = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required reviewers gh branch protection builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder requiredReviewers(int v) {
|
||||
getPrReviews().put("required_approving_review_count", v);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Require branch is up to date gh branch protection builder.
|
||||
*
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder requireBranchIsUpToDate() {
|
||||
return requireBranchIsUpToDate(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Require branch is up to date gh branch protection builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder requireBranchIsUpToDate(boolean v) {
|
||||
getStatusChecks().strict = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Require code own reviews gh branch protection builder.
|
||||
*
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder requireCodeOwnReviews() {
|
||||
return requireCodeOwnReviews(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Require code own reviews gh branch protection builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder requireCodeOwnReviews(boolean v) {
|
||||
getPrReviews().put("require_code_owner_reviews", v);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Require reviews gh branch protection builder.
|
||||
*
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder requireReviews() {
|
||||
getPrReviews();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restrict review dismissals gh branch protection builder.
|
||||
*
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder restrictReviewDismissals() {
|
||||
getPrReviews();
|
||||
|
||||
if (!prReviews.containsKey("dismissal_restrictions")) {
|
||||
prReviews.put("dismissal_restrictions", new Restrictions());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restrict push access gh branch protection builder.
|
||||
*
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder restrictPushAccess() {
|
||||
getRestrictions();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Team push access gh branch protection builder.
|
||||
*
|
||||
* @param teams
|
||||
* the teams
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder teamPushAccess(Collection<GHTeam> teams) {
|
||||
for (GHTeam team : teams) {
|
||||
teamPushAccess(team);
|
||||
@@ -101,6 +222,13 @@ public class GHBranchProtectionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Team push access gh branch protection builder.
|
||||
*
|
||||
* @param teams
|
||||
* the teams
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder teamPushAccess(GHTeam... teams) {
|
||||
for (GHTeam team : teams) {
|
||||
getRestrictions().teams.add(team.getSlug());
|
||||
@@ -108,6 +236,13 @@ public class GHBranchProtectionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Team review dismissals gh branch protection builder.
|
||||
*
|
||||
* @param teams
|
||||
* the teams
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder teamReviewDismissals(Collection<GHTeam> teams) {
|
||||
for (GHTeam team : teams) {
|
||||
teamReviewDismissals(team);
|
||||
@@ -115,6 +250,13 @@ public class GHBranchProtectionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Team review dismissals gh branch protection builder.
|
||||
*
|
||||
* @param teams
|
||||
* the teams
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder teamReviewDismissals(GHTeam... teams) {
|
||||
for (GHTeam team : teams) {
|
||||
addReviewRestriction(team.getSlug(), true);
|
||||
@@ -122,13 +264,27 @@ public class GHBranchProtectionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* User push access gh branch protection builder.
|
||||
*
|
||||
* @param users
|
||||
* the users
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder userPushAccess(Collection<GHUser> users) {
|
||||
for (GHUser user : users) {
|
||||
userPushAccess(user);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* User push access gh branch protection builder.
|
||||
*
|
||||
* @param users
|
||||
* the users
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder userPushAccess(GHUser... users) {
|
||||
for (GHUser user : users) {
|
||||
getRestrictions().users.add(user.getLogin());
|
||||
@@ -136,6 +292,13 @@ public class GHBranchProtectionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* User review dismissals gh branch protection builder.
|
||||
*
|
||||
* @param users
|
||||
* the users
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder userReviewDismissals(Collection<GHUser> users) {
|
||||
for (GHUser team : users) {
|
||||
userReviewDismissals(team);
|
||||
@@ -143,6 +306,13 @@ public class GHBranchProtectionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* User review dismissals gh branch protection builder.
|
||||
*
|
||||
* @param users
|
||||
* the users
|
||||
* @return the gh branch protection builder
|
||||
*/
|
||||
public GHBranchProtectionBuilder userReviewDismissals(GHUser... users) {
|
||||
for (GHUser user : users) {
|
||||
addReviewRestriction(user.getLogin(), false);
|
||||
@@ -151,14 +321,9 @@ public class GHBranchProtectionBuilder {
|
||||
}
|
||||
|
||||
private void addReviewRestriction(String restriction, boolean isTeam) {
|
||||
getPrReviews();
|
||||
|
||||
if (!prReviews.containsKey("dismissal_restrictions")) {
|
||||
prReviews.put("dismissal_restrictions", new Restrictions());
|
||||
}
|
||||
|
||||
restrictReviewDismissals();
|
||||
Restrictions restrictions = (Restrictions) prReviews.get("dismissal_restrictions");
|
||||
|
||||
|
||||
if (isTeam) {
|
||||
restrictions.teams.add(restriction);
|
||||
} else {
|
||||
@@ -188,7 +353,7 @@ public class GHBranchProtectionBuilder {
|
||||
}
|
||||
|
||||
private Requester requester() {
|
||||
return new Requester(branch.getRoot()).withPreview(LOKI);
|
||||
return branch.getRoot().createRequest().withPreview(LUKE_CAGE);
|
||||
}
|
||||
|
||||
private static class Restrictions {
|
||||
|
||||
307
src/main/java/org/kohsuke/github/GHCheckRun.java
Normal file
307
src/main/java/org/kohsuke/github/GHCheckRun.java
Normal file
@@ -0,0 +1,307 @@
|
||||
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.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/">documentation</a>
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHCheckRun extends GHObject {
|
||||
|
||||
@JsonProperty("repository")
|
||||
GHRepository owner;
|
||||
|
||||
private String status;
|
||||
private String conclusion;
|
||||
private String name;
|
||||
private String headSha;
|
||||
private String nodeId;
|
||||
private String externalId;
|
||||
private String startedAt;
|
||||
private String completedAt;
|
||||
private URL htmlUrl;
|
||||
private URL detailsUrl;
|
||||
private Output output;
|
||||
private GHApp app;
|
||||
private GHPullRequest[] pullRequests;
|
||||
private GHCheckSuite checkSuite;
|
||||
|
||||
GHCheckRun wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
wrap(owner.root);
|
||||
return this;
|
||||
}
|
||||
|
||||
GHCheckRun wrap(GitHub root) {
|
||||
this.root = root;
|
||||
if (owner != null) {
|
||||
owner.wrap(root);
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.wrap(owner);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (checkSuite != null) {
|
||||
if (owner != null) {
|
||||
checkSuite.wrap(owner);
|
||||
} else {
|
||||
checkSuite.wrap(root);
|
||||
}
|
||||
}
|
||||
if (app != null) {
|
||||
app.wrapUp(root);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
GHPullRequest[] wrap() {
|
||||
return pullRequests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets status of the check run.
|
||||
*
|
||||
* @return Status of the check run
|
||||
* @see Status
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public static enum Status {
|
||||
QUEUED, IN_PROGRESS, COMPLETED
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets conclusion of a completed check run.
|
||||
*
|
||||
* @return Status of the check run
|
||||
* @see Conclusion
|
||||
*/
|
||||
public String getConclusion() {
|
||||
return conclusion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Final conclusion of the check.
|
||||
*
|
||||
* From <a href="https://docs.github.com/en/rest/reference/checks#create-a-check-run--parameters">Check Run
|
||||
* Parameters - <code>conclusion</code></a>.
|
||||
*/
|
||||
public static enum Conclusion {
|
||||
SUCCESS, FAILURE, NEUTRAL, CANCELLED, TIMED_OUT, ACTION_REQUIRED, SKIPPED
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom name of this check run.
|
||||
*
|
||||
* @return Name of the check run
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HEAD SHA.
|
||||
*
|
||||
* @return sha for the HEAD commit
|
||||
*/
|
||||
public String getHeadSha() {
|
||||
return headSha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pull requests participated in this check run.
|
||||
*
|
||||
* Note this field is only populated for events. When getting a {@link GHCheckRun} outside of an event, this is
|
||||
* always empty.
|
||||
*
|
||||
* @return the list of {@link GHPullRequest}s for this check run. Only populated for events.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHPullRequest> getPullRequests() throws IOException {
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
// Only refresh if we haven't do so before
|
||||
singlePull.refresh(singlePull.getTitle());
|
||||
}
|
||||
return Collections.unmodifiableList(Arrays.asList(pullRequests));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTML URL: https://github.com/[owner]/[repo-name]/runs/[check-run-id], usually an GitHub Action page of
|
||||
* the check run.
|
||||
*
|
||||
* @return HTML URL
|
||||
*/
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return htmlUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the global node id to access most objects in GitHub.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v4/guides/using-global-node-ids/">documentation</a>
|
||||
* @return Global node id
|
||||
*/
|
||||
public String getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a reference for the check run on the integrator's system.
|
||||
*
|
||||
* @return Reference id
|
||||
*/
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the details URL from which to find full details of the check run on the integrator's site.
|
||||
*
|
||||
* @return Details URL
|
||||
*/
|
||||
public URL getDetailsUrl() {
|
||||
return detailsUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the start time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
|
||||
*
|
||||
* @return Timestamp of the start time
|
||||
*/
|
||||
public Date getStartedAt() {
|
||||
return GitHubClient.parseDate(startedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the completed time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
|
||||
*
|
||||
* @return Timestamp of the completed time
|
||||
*/
|
||||
public Date getCompletedAt() {
|
||||
return GitHubClient.parseDate(completedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GitHub app this check run belongs to, included in response.
|
||||
*
|
||||
* @return GitHub App
|
||||
*/
|
||||
public GHApp getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the check suite this check run belongs to
|
||||
*
|
||||
* @return Check suite
|
||||
*/
|
||||
public GHCheckSuite getCheckSuite() {
|
||||
return checkSuite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an output for a check run.
|
||||
*
|
||||
* @return Output of a check run
|
||||
*/
|
||||
public Output getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an output in a check run to include summary and other results.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#output-object">documentation</a>
|
||||
*/
|
||||
public static class Output {
|
||||
private String title;
|
||||
private String summary;
|
||||
private String text;
|
||||
private int annotationsCount;
|
||||
private URL annotationsUrl;
|
||||
|
||||
/**
|
||||
* Gets the title of check run.
|
||||
*
|
||||
* @return title of check run
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the summary of the check run, note that it supports Markdown.
|
||||
*
|
||||
* @return summary of check run
|
||||
*/
|
||||
public String getSummary() {
|
||||
return summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the details of the check run, note that it supports Markdown.
|
||||
*
|
||||
* @return Details of the check run
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the annotation count of a check run.
|
||||
*
|
||||
* @return annotation count of a check run
|
||||
*/
|
||||
public int getAnnotationsCount() {
|
||||
return annotationsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL of annotations.
|
||||
*
|
||||
* @return URL of annotations
|
||||
*/
|
||||
public URL getAnnotationsUrl() {
|
||||
return annotationsUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum AnnotationLevel {
|
||||
NOTICE, WARNING, FAILURE
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
259
src/main/java/org/kohsuke/github/GHCheckSuite.java
Normal file
259
src/main/java/org/kohsuke/github/GHCheckSuite.java
Normal file
@@ -0,0 +1,259 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a check suite.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/checks/suites/">documentation</a>
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHCheckSuite extends GHObject {
|
||||
|
||||
@JsonProperty("repository")
|
||||
GHRepository owner;
|
||||
|
||||
private String nodeId;
|
||||
private String headBranch;
|
||||
private String headSha;
|
||||
private String status;
|
||||
private String conclusion;
|
||||
private String before;
|
||||
private String after;
|
||||
private int latestCheckRunsCount;
|
||||
private URL checkRunsUrl;
|
||||
private HeadCommit headCommit;
|
||||
private GHApp app;
|
||||
private GHPullRequest[] pullRequests;
|
||||
|
||||
GHCheckSuite wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
this.wrap(owner.root);
|
||||
return this;
|
||||
}
|
||||
|
||||
GHCheckSuite wrap(GitHub root) {
|
||||
this.root = root;
|
||||
if (owner != null) {
|
||||
owner.wrap(root);
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.wrap(owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (app != null) {
|
||||
app.wrapUp(root);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
GHPullRequest[] wrap() {
|
||||
return pullRequests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the global node id to access most objects in GitHub.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v4/guides/using-global-node-ids/">documentation</a>
|
||||
* @return global node id
|
||||
*/
|
||||
public String getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The head branch name the changes are on.
|
||||
*
|
||||
* @return head branch name
|
||||
*/
|
||||
public String getHeadBranch() {
|
||||
return headBranch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HEAD SHA.
|
||||
*
|
||||
* @return sha for the HEAD commit
|
||||
*/
|
||||
public String getHeadSha() {
|
||||
return headSha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets status of the check suite. It can be one of request, in_progress, or completed.
|
||||
*
|
||||
* @return status of the check suite
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets conclusion of a completed check suite. It can be one of success, failure, neutral, cancelled, time_out,
|
||||
* action_required, or stale. The check suite will report the highest priority check run conclusion in the check
|
||||
* suite's conclusion.
|
||||
*
|
||||
* @return conclusion of the check suite
|
||||
*/
|
||||
public String getConclusion() {
|
||||
return conclusion;
|
||||
}
|
||||
|
||||
/**
|
||||
* The SHA of the most recent commit on ref before the push.
|
||||
*
|
||||
* @return sha of a commit
|
||||
*/
|
||||
public String getBefore() {
|
||||
return before;
|
||||
}
|
||||
|
||||
/**
|
||||
* The SHA of the most recent commit on ref after the push.
|
||||
*
|
||||
* @return sha of a commit
|
||||
*/
|
||||
public String getAfter() {
|
||||
return after;
|
||||
}
|
||||
|
||||
/**
|
||||
* The quantity of check runs that had run as part of the latest push.
|
||||
*
|
||||
* @return sha of the most recent commit
|
||||
*/
|
||||
public int getLatestCheckRunsCount() {
|
||||
return latestCheckRunsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* The url used to list all the check runs belonged to this suite.
|
||||
*
|
||||
* @return url containing all check runs
|
||||
*/
|
||||
public URL getCheckRunsUrl() {
|
||||
return checkRunsUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The commit of current head.
|
||||
*
|
||||
* @return head commit
|
||||
*/
|
||||
public HeadCommit getHeadCommit() {
|
||||
return headCommit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GitHub app this check suite belongs to, included in response.
|
||||
*
|
||||
* @return GitHub App
|
||||
*/
|
||||
public GHApp getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pull requests participated in this check suite.
|
||||
*
|
||||
* Note this field is only populated for events. When getting a {@link GHCheckSuite} outside of an event, this is
|
||||
* always empty.
|
||||
*
|
||||
* @return the list of {@link GHPullRequest}s for this check suite. Only populated for events.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHPullRequest> getPullRequests() throws IOException {
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
// Only refresh if we haven't do so before
|
||||
singlePull.refresh(singlePull.getTitle());
|
||||
}
|
||||
return Collections.unmodifiableList(Arrays.asList(pullRequests));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check suite doesn't have a HTML URL.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class HeadCommit {
|
||||
private String id;
|
||||
private String treeId;
|
||||
private String message;
|
||||
private String timestamp;
|
||||
private GitUser author;
|
||||
private GitUser committer;
|
||||
|
||||
/**
|
||||
* Gets id of the commit, used by {@link GHCheckSuite} when a {@link GHEvent#CHECK_SUITE} comes
|
||||
*
|
||||
* @return id of the commit
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets id of the tree.
|
||||
*
|
||||
* @return id of the tree
|
||||
*/
|
||||
public String getTreeId() {
|
||||
return treeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets message.
|
||||
*
|
||||
* @return commit message.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets timestamp of the commit.
|
||||
*
|
||||
* @return timestamp of the commit
|
||||
*/
|
||||
public Date getTimestamp() {
|
||||
return GitHubClient.parseDate(timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets author.
|
||||
*
|
||||
* @return the author
|
||||
*/
|
||||
public GitUser getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets committer.
|
||||
*
|
||||
* @return the committer
|
||||
*/
|
||||
public GitUser getCommitter() {
|
||||
return committer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
/**
|
||||
* How is an user associated with a repository?
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public enum GHCommentAuthorAssociation {
|
||||
/**
|
||||
* Author has been invited to collaborate on the repository.
|
||||
*/
|
||||
COLLABORATOR,
|
||||
/**
|
||||
* Author has previously committed to the repository.
|
||||
*/
|
||||
CONTRIBUTOR,
|
||||
/**
|
||||
* Author has not previously committed to GitHub.
|
||||
*/
|
||||
FIRST_TIMER,
|
||||
/**
|
||||
* Author has not previously committed to the repository.
|
||||
*/
|
||||
FIRST_TIME_CONTRIBUTOR,
|
||||
/**
|
||||
* Author is a member of the organization that owns the repository.
|
||||
*/
|
||||
MEMBER,
|
||||
/**
|
||||
* Author has no association with the repository.
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* Author is the owner of the repository.
|
||||
*/
|
||||
OWNER
|
||||
}
|
||||
@@ -2,6 +2,7 @@ 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.AbstractList;
|
||||
@@ -10,121 +11,176 @@ 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.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHRepository#getCommit(String)
|
||||
* @see GHCommitComment#getCommit()
|
||||
* @see GHRepository#getCommit(String) GHRepository#getCommit(String)
|
||||
* @see GHCommitComment#getCommit() GHCommitComment#getCommit()
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD"},
|
||||
justification = "JSON API")
|
||||
@SuppressFBWarnings(value = { "NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
|
||||
public class GHCommit {
|
||||
private GHRepository owner;
|
||||
|
||||
|
||||
private ShortInfo commit;
|
||||
|
||||
/**
|
||||
* Short summary of this commit.
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||
"NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||
@SuppressFBWarnings(
|
||||
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||
"UWF_UNWRITTEN_FIELD" },
|
||||
justification = "JSON API")
|
||||
public static class ShortInfo {
|
||||
private GHAuthor author;
|
||||
private GHAuthor committer;
|
||||
|
||||
|
||||
private String message;
|
||||
|
||||
|
||||
private int comment_count;
|
||||
|
||||
private GHVerification verification;
|
||||
|
||||
static class Tree {
|
||||
String sha;
|
||||
}
|
||||
|
||||
private Tree tree;
|
||||
|
||||
/**
|
||||
* Gets author.
|
||||
*
|
||||
* @return the author
|
||||
*/
|
||||
@WithBridgeMethods(value = GHAuthor.class, castRequired = true)
|
||||
public GitUser getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets authored date.
|
||||
*
|
||||
* @return the authored date
|
||||
*/
|
||||
public Date getAuthoredDate() {
|
||||
return GitHub.parseDate(author.date);
|
||||
return author.getDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets committer.
|
||||
*
|
||||
* @return the committer
|
||||
*/
|
||||
@WithBridgeMethods(value = GHAuthor.class, castRequired = true)
|
||||
public GitUser getCommitter() {
|
||||
return committer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets commit date.
|
||||
*
|
||||
* @return the commit date
|
||||
*/
|
||||
public Date getCommitDate() {
|
||||
return GitHub.parseDate(committer.date);
|
||||
return committer.getDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit message.
|
||||
* Gets message.
|
||||
*
|
||||
* @return Commit message.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets comment count.
|
||||
*
|
||||
* @return the comment count
|
||||
*/
|
||||
public int getCommentCount() {
|
||||
return comment_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Verification Status.
|
||||
*
|
||||
* @return the Verification status
|
||||
*/
|
||||
public GHVerification getVerification() {
|
||||
return verification;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The type GHAuthor.
|
||||
*
|
||||
* @deprecated Use {@link GitUser} instead.
|
||||
*/
|
||||
public static class GHAuthor extends GitUser {
|
||||
private String date;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type Stats.
|
||||
*/
|
||||
public static class Stats {
|
||||
int total,additions,deletions;
|
||||
int total, additions, deletions;
|
||||
}
|
||||
|
||||
/**
|
||||
* A file that was modified.
|
||||
*/
|
||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD",
|
||||
justification = "It's being initilized by JSON deserialization")
|
||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "It's being initilized by JSON deserialization")
|
||||
public static class File {
|
||||
String status;
|
||||
int changes,additions,deletions;
|
||||
int changes, additions, deletions;
|
||||
String raw_url, blob_url, sha, patch;
|
||||
String filename, previous_filename;
|
||||
|
||||
/**
|
||||
* Number of lines added + removed.
|
||||
* Gets lines changed.
|
||||
*
|
||||
* @return Number of lines added + removed.
|
||||
*/
|
||||
public int getLinesChanged() {
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of lines added.
|
||||
* Gets lines added.
|
||||
*
|
||||
* @return Number of lines added.
|
||||
*/
|
||||
public int getLinesAdded() {
|
||||
return additions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of lines removed.
|
||||
* Gets lines deleted.
|
||||
*
|
||||
* @return Number of lines removed.
|
||||
*/
|
||||
public int getLinesDeleted() {
|
||||
return deletions;
|
||||
}
|
||||
|
||||
/**
|
||||
* "modified", "added", or "removed"
|
||||
* Gets status.
|
||||
*
|
||||
* @return "modified", "added", or "removed"
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Full path in the repository.
|
||||
* Gets file name.
|
||||
*
|
||||
* @return Full path in the repository.
|
||||
*/
|
||||
@SuppressFBWarnings(value = "NM_CONFUSING",
|
||||
justification = "It's a part of the library's API and cannot be renamed")
|
||||
@@ -133,81 +189,108 @@ public class GHCommit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Previous path, in case file has moved.
|
||||
* Gets previous filename.
|
||||
*
|
||||
* @return Previous path, in case file has moved.
|
||||
*/
|
||||
public String getPreviousFilename() {
|
||||
return previous_filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual change.
|
||||
* Gets patch.
|
||||
*
|
||||
* @return The actual change.
|
||||
*/
|
||||
public String getPatch() {
|
||||
return patch;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL like 'https://raw.github.com/jenkinsci/jenkins/4eb17c197dfdcf8ef7ff87eb160f24f6a20b7f0e/core/pom.xml'
|
||||
* that resolves to the actual content of the file.
|
||||
* Gets raw url.
|
||||
*
|
||||
* @return URL like
|
||||
* 'https://raw.github.com/jenkinsci/jenkins/4eb17c197dfdcf8ef7ff87eb160f24f6a20b7f0e/core/pom.xml' that
|
||||
* resolves to the actual content of the file.
|
||||
*/
|
||||
public URL getRawUrl() {
|
||||
return GitHub.parseURL(raw_url);
|
||||
return GitHubClient.parseURL(raw_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* URL like 'https://github.com/jenkinsci/jenkins/blob/1182e2ebb1734d0653142bd422ad33c21437f7cf/core/pom.xml'
|
||||
* that resolves to the HTML page that describes this file.
|
||||
* Gets blob url.
|
||||
*
|
||||
* @return URL like
|
||||
* 'https://github.com/jenkinsci/jenkins/blob/1182e2ebb1734d0653142bd422ad33c21437f7cf/core/pom.xml'
|
||||
* that resolves to the HTML page that describes this file.
|
||||
*/
|
||||
public URL getBlobUrl() {
|
||||
return GitHub.parseURL(blob_url);
|
||||
return GitHubClient.parseURL(blob_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* [0-9a-f]{40} SHA1 checksum.
|
||||
* Gets sha.
|
||||
*
|
||||
* @return [0 -9a-f]{40} SHA1 checksum.
|
||||
*/
|
||||
public String getSha() {
|
||||
return sha;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The type Parent.
|
||||
*/
|
||||
public static class Parent {
|
||||
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||
String url;
|
||||
String url;
|
||||
String sha;
|
||||
}
|
||||
|
||||
static class User {
|
||||
// TODO: what if someone who doesn't have an account on GitHub makes a commit?
|
||||
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||
String url,avatar_url,gravatar_id;
|
||||
String url, avatar_url, gravatar_id;
|
||||
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||
int id;
|
||||
|
||||
|
||||
String login;
|
||||
}
|
||||
|
||||
String url,html_url,sha;
|
||||
String url, html_url, sha;
|
||||
List<File> files;
|
||||
Stats stats;
|
||||
List<Parent> parents;
|
||||
User author,committer;
|
||||
|
||||
User author, committer;
|
||||
|
||||
/**
|
||||
* Gets commit short info.
|
||||
*
|
||||
* @return the commit short info
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public ShortInfo getCommitShortInfo() throws IOException {
|
||||
if (commit==null)
|
||||
if (commit == null)
|
||||
populate();
|
||||
return commit;
|
||||
}
|
||||
|
||||
/**
|
||||
* The repository that contains the commit.
|
||||
* Gets owner.
|
||||
*
|
||||
* @return the repository that contains the commit.
|
||||
*/
|
||||
public GHRepository getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of lines added + removed.
|
||||
* Gets lines changed.
|
||||
*
|
||||
* @return the number of lines added + removed.
|
||||
* @throws IOException
|
||||
* if the field was not populated and refresh fails
|
||||
*/
|
||||
public int getLinesChanged() throws IOException {
|
||||
populate();
|
||||
@@ -215,7 +298,11 @@ public class GHCommit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of lines added.
|
||||
* Gets lines added.
|
||||
*
|
||||
* @return Number of lines added.
|
||||
* @throws IOException
|
||||
* if the field was not populated and refresh fails
|
||||
*/
|
||||
public int getLinesAdded() throws IOException {
|
||||
populate();
|
||||
@@ -223,7 +310,11 @@ public class GHCommit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of lines removed.
|
||||
* Gets lines deleted.
|
||||
*
|
||||
* @return Number of lines removed.
|
||||
* @throws IOException
|
||||
* if the field was not populated and refresh fails
|
||||
*/
|
||||
public int getLinesDeleted() throws IOException {
|
||||
populate();
|
||||
@@ -231,21 +322,30 @@ public class GHCommit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to walk the tree
|
||||
* Use this method to walk the tree.
|
||||
*
|
||||
* @return a GHTree to walk
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public GHTree getTree() throws IOException {
|
||||
return owner.getTree(getCommitShortInfo().tree.sha);
|
||||
}
|
||||
|
||||
/**
|
||||
* URL of this commit like "https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000"
|
||||
* Gets html url.
|
||||
*
|
||||
* @return URL of this commit like
|
||||
* "https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000"
|
||||
*/
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* [0-9a-f]{40} SHA1 checksum.
|
||||
* Gets sha 1.
|
||||
*
|
||||
* @return [0 -9a-f]{40} SHA1 checksum.
|
||||
*/
|
||||
public String getSHA1() {
|
||||
return sha;
|
||||
@@ -254,19 +354,23 @@ public class GHCommit {
|
||||
/**
|
||||
* List of files changed/added/removed in this commit.
|
||||
*
|
||||
* @return
|
||||
* Can be empty but never null.
|
||||
* @return Can be empty but never null.
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public List<File> getFiles() throws IOException {
|
||||
populate();
|
||||
return files!=null ? Collections.unmodifiableList(files) : Collections.<File>emptyList();
|
||||
return files != null ? Collections.unmodifiableList(files) : Collections.<File>emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SHA1 of parent commit objects.
|
||||
* Gets parent sha 1 s.
|
||||
*
|
||||
* @return SHA1 of parent commit objects.
|
||||
*/
|
||||
public List<String> getParentSHA1s() {
|
||||
if (parents==null) return Collections.emptyList();
|
||||
if (parents == null)
|
||||
return Collections.emptyList();
|
||||
return new AbstractList<String>() {
|
||||
@Override
|
||||
public String get(int index) {
|
||||
@@ -282,6 +386,10 @@ public class GHCommit {
|
||||
|
||||
/**
|
||||
* Resolves the parent commit objects and return them.
|
||||
*
|
||||
* @return parent commit objects
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public List<GHCommit> getParents() throws IOException {
|
||||
List<GHCommit> r = new ArrayList<GHCommit>();
|
||||
@@ -290,19 +398,35 @@ public class GHCommit {
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets author.
|
||||
*
|
||||
* @return the author
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getAuthor() throws IOException {
|
||||
return resolveUser(author);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date the change was authored on.
|
||||
*
|
||||
* @return the date the change was authored on.
|
||||
* @throws IOException if the information was not already fetched and an attempt at fetching the information failed.
|
||||
* @throws IOException
|
||||
* if the information was not already fetched and an attempt at fetching the information failed.
|
||||
*/
|
||||
public Date getAuthoredDate() throws IOException {
|
||||
return getCommitShortInfo().getAuthoredDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets committer.
|
||||
*
|
||||
* @return the committer
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getCommitter() throws IOException {
|
||||
return resolveUser(committer);
|
||||
}
|
||||
@@ -311,73 +435,151 @@ public class GHCommit {
|
||||
* Gets the date the change was committed on.
|
||||
*
|
||||
* @return the date the change was committed on.
|
||||
* @throws IOException if the information was not already fetched and an attempt at fetching the information failed.
|
||||
* @throws IOException
|
||||
* if the information was not already fetched and an attempt at fetching the information failed.
|
||||
*/
|
||||
public Date getCommitDate() throws IOException {
|
||||
return getCommitShortInfo().getCommitDate();
|
||||
}
|
||||
|
||||
private GHUser resolveUser(User author) throws IOException {
|
||||
if (author==null || author.login==null) return null;
|
||||
if (author == null || author.login == null)
|
||||
return null;
|
||||
return owner.root.getUser(author.login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists up all the commit comments in this repository.
|
||||
* 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.
|
||||
*
|
||||
* @return {@link PagedIterable} with all the commit comments in this repository.
|
||||
*/
|
||||
public PagedIterable<GHCommitComment> listComments() {
|
||||
return new PagedIterable<GHCommitComment>() {
|
||||
public PagedIterator<GHCommitComment> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHCommitComment>(owner.root.retrieve().asIterator(String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha), GHCommitComment[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHCommitComment[] page) {
|
||||
for (GHCommitComment c : page)
|
||||
c.wrap(owner);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return owner.root.createRequest()
|
||||
.withUrlPath(
|
||||
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha))
|
||||
.toIterable(GHCommitComment[].class, item -> item.wrap(owner));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a commit comment.
|
||||
*
|
||||
* <p>
|
||||
* I'm not sure how path/line/position parameters interact with each other.
|
||||
*
|
||||
* @param body
|
||||
* body of the comment
|
||||
* @param path
|
||||
* path of file being commented on
|
||||
* @param line
|
||||
* target line for comment
|
||||
* @param position
|
||||
* position on line
|
||||
* @return created GHCommitComment
|
||||
* @throws IOException
|
||||
* if comment is not created
|
||||
*/
|
||||
public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException {
|
||||
GHCommitComment r = new Requester(owner.root)
|
||||
.with("body",body)
|
||||
.with("path",path)
|
||||
.with("line",line)
|
||||
.with("position",position)
|
||||
.to(String.format("/repos/%s/%s/commits/%s/comments",owner.getOwnerName(),owner.getName(),sha),GHCommitComment.class);
|
||||
GHCommitComment r = owner.root.createRequest()
|
||||
.method("POST")
|
||||
.with("body", body)
|
||||
.with("path", path)
|
||||
.with("line", line)
|
||||
.with("position", position)
|
||||
.withUrlPath(
|
||||
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha))
|
||||
.fetch(GHCommitComment.class);
|
||||
return r.wrap(owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create comment gh commit comment.
|
||||
*
|
||||
* @param body
|
||||
* the body
|
||||
* @return the gh commit comment
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHCommitComment createComment(String body) throws IOException {
|
||||
return createComment(body, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status of this commit, newer ones first.
|
||||
* List statuses paged iterable.
|
||||
*
|
||||
* @return status of this commit, newer ones first.
|
||||
* @throws IOException
|
||||
* if statuses cannot be read
|
||||
*/
|
||||
public PagedIterable<GHCommitStatus> listStatuses() throws IOException {
|
||||
return owner.listCommitStatuses(sha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last status of this commit, which is what gets shown in the UI.
|
||||
* Gets last status.
|
||||
*
|
||||
* @return the last status of this commit, which is what gets shown in the UI.
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public GHCommitStatus getLastStatus() throws IOException {
|
||||
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
|
||||
*/
|
||||
void populate() throws IOException {
|
||||
if (files==null && stats==null)
|
||||
owner.root.retrieve().to(owner.getApiTailUrl("commits/" + sha), this);
|
||||
if (files == null && stats == null)
|
||||
owner.root.createRequest().withUrlPath(owner.getApiTailUrl("commits/" + sha)).fetchInto(this);
|
||||
}
|
||||
|
||||
GHCommit wrapUp(GHRepository owner) {
|
||||
|
||||
136
src/main/java/org/kohsuke/github/GHCommitBuilder.java
Normal file
136
src/main/java/org/kohsuke/github/GHCommitBuilder.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* Builder pattern for creating a new commit. Based on https://developer.github.com/v3/git/commits/#create-a-commit
|
||||
*/
|
||||
public class GHCommitBuilder {
|
||||
private final GHRepository repo;
|
||||
private final Requester req;
|
||||
|
||||
private final List<String> parents = new ArrayList<String>();
|
||||
|
||||
private static final class UserInfo {
|
||||
private final String name;
|
||||
private final String email;
|
||||
private final String date;
|
||||
|
||||
private UserInfo(String name, String email, Date date) {
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
TimeZone tz = TimeZone.getTimeZone("UTC");
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
df.setTimeZone(tz);
|
||||
this.date = df.format((date != null) ? date : new Date());
|
||||
}
|
||||
}
|
||||
|
||||
GHCommitBuilder(GHRepository repo) {
|
||||
this.repo = repo;
|
||||
req = repo.root.createRequest().method("POST");
|
||||
}
|
||||
|
||||
/**
|
||||
* Message gh commit builder.
|
||||
*
|
||||
* @param message
|
||||
* the commit message
|
||||
* @return the gh commit builder
|
||||
*/
|
||||
public GHCommitBuilder message(String message) {
|
||||
req.with("message", message);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tree gh commit builder.
|
||||
*
|
||||
* @param tree
|
||||
* the SHA of the tree object this commit points to
|
||||
* @return the gh commit builder
|
||||
*/
|
||||
public GHCommitBuilder tree(String tree) {
|
||||
req.with("tree", tree);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent gh commit builder.
|
||||
*
|
||||
* @param parent
|
||||
* the SHA of a parent commit.
|
||||
* @return the gh commit builder
|
||||
*/
|
||||
public GHCommitBuilder parent(String parent) {
|
||||
parents.add(parent);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the author of this commit.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param email
|
||||
* the email
|
||||
* @param date
|
||||
* the date
|
||||
* @return the gh commit builder
|
||||
*/
|
||||
public GHCommitBuilder author(String name, String email, Date date) {
|
||||
req.with("author", new UserInfo(name, email, date));
|
||||
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.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param email
|
||||
* the email
|
||||
* @param date
|
||||
* the date
|
||||
* @return the gh commit builder
|
||||
*/
|
||||
public GHCommitBuilder committer(String name, String email, Date date) {
|
||||
req.with("committer", new UserInfo(name, email, date));
|
||||
return this;
|
||||
}
|
||||
|
||||
private String getApiTail() {
|
||||
return String.format("/repos/%s/%s/git/commits", repo.getOwnerName(), repo.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a blob based on the parameters specified thus far.
|
||||
*
|
||||
* @return the gh commit
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHCommit create() throws IOException {
|
||||
req.with("parents", parents);
|
||||
return req.method("POST").withUrlPath(getApiTail()).fetch(GHCommit.class).wrapUp(repo);
|
||||
}
|
||||
}
|
||||
@@ -1,71 +1,93 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
|
||||
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.)
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHRepository#listCommitComments()
|
||||
* @see GHCommit#listComments()
|
||||
* @see GHCommit#createComment(String, String, Integer, Integer)
|
||||
* @see GHRepository#listCommitComments() GHRepository#listCommitComments()
|
||||
* @see GHCommit#listComments() GHCommit#listComments()
|
||||
* @see GHCommit#createComment(String, String, Integer, Integer) GHCommit#createComment(String, String, Integer,
|
||||
* Integer)
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHCommitComment extends GHObject implements Reactable {
|
||||
private GHRepository owner;
|
||||
|
||||
String body, html_url, commit_id;
|
||||
Integer line;
|
||||
String path;
|
||||
GHUser user; // not fully populated. beware.
|
||||
GHUser user; // not fully populated. beware.
|
||||
|
||||
/**
|
||||
* Gets owner.
|
||||
*
|
||||
* @return the owner
|
||||
*/
|
||||
public GHRepository getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL like 'https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000#commitcomment-1252827' to
|
||||
* URL like
|
||||
* 'https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000#commitcomment-1252827' to
|
||||
* show this commit comment in a browser.
|
||||
*/
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets sha 1.
|
||||
*
|
||||
* @return the sha 1
|
||||
*/
|
||||
public String getSHA1() {
|
||||
return commit_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit comment in the GitHub flavored markdown format.
|
||||
*
|
||||
* @return the body
|
||||
*/
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* A commit comment can be on a specific line of a specific file, if so, this field points to a file.
|
||||
* Otherwise null.
|
||||
* A commit comment can be on a specific line of a specific file, if so, this field points to a file. Otherwise
|
||||
* null.
|
||||
*
|
||||
* @return the path
|
||||
*/
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* A commit comment can be on a specific line of a specific file, if so, this field points to the line number in the file.
|
||||
* Otherwise -1.
|
||||
* A commit comment can be on a specific line of a specific file, if so, this field points to the line number in the
|
||||
* file. Otherwise -1.
|
||||
*
|
||||
* @return the line
|
||||
*/
|
||||
public int getLine() {
|
||||
return line!=null ? line : -1;
|
||||
return line != null ? line : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user who put this comment.
|
||||
*
|
||||
* @return the user
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getUser() throws IOException {
|
||||
return owner == null || owner.root.isOffline() ? user : owner.root.getUser(user.login);
|
||||
@@ -73,6 +95,10 @@ public class GHCommitComment extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* Gets the commit to which this comment is associated with.
|
||||
*
|
||||
* @return the commit
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHCommit getCommit() throws IOException {
|
||||
return getOwner().getCommit(getSHA1());
|
||||
@@ -80,49 +106,56 @@ public class GHCommitComment extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* Updates the body of the commit message.
|
||||
*
|
||||
* @param body
|
||||
* the body
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void update(String body) throws IOException {
|
||||
new Requester(owner.root)
|
||||
owner.root.createRequest()
|
||||
.method("PATCH")
|
||||
.with("body", body)
|
||||
.method("PATCH").to(getApiTail(), GHCommitComment.class);
|
||||
.withUrlPath(getApiTail())
|
||||
.fetch(GHCommitComment.class);
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
@Preview @Deprecated
|
||||
@Preview(SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public GHReaction createReaction(ReactionContent content) throws IOException {
|
||||
return new Requester(owner.root)
|
||||
return owner.root.createRequest()
|
||||
.method("POST")
|
||||
.withPreview(SQUIRREL_GIRL)
|
||||
.with("content", content.getContent())
|
||||
.to(getApiTail()+"/reactions", GHReaction.class).wrap(owner.root);
|
||||
.withUrlPath(getApiTail() + "/reactions")
|
||||
.fetch(GHReaction.class)
|
||||
.wrap(owner.root);
|
||||
}
|
||||
|
||||
@Preview @Deprecated
|
||||
@Preview(SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public PagedIterable<GHReaction> listReactions() {
|
||||
return new PagedIterable<GHReaction>() {
|
||||
public PagedIterator<GHReaction> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHReaction>(owner.root.retrieve().withPreview(SQUIRREL_GIRL).asIterator(getApiTail()+"/reactions", GHReaction[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHReaction[] page) {
|
||||
for (GHReaction c : page)
|
||||
c.wrap(owner.root);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return owner.root.createRequest()
|
||||
.withPreview(SQUIRREL_GIRL)
|
||||
.withUrlPath(getApiTail() + "/reactions")
|
||||
.toIterable(GHReaction[].class, item -> item.wrap(owner.root));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes this comment.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
new Requester(owner.root).method("DELETE").to(getApiTail());
|
||||
owner.root.createRequest().method("DELETE").withUrlPath(getApiTail()).send();
|
||||
}
|
||||
|
||||
private String getApiTail() {
|
||||
return String.format("/repos/%s/%s/comments/%s",owner.getOwnerName(),owner.getName(),id);
|
||||
return String.format("/repos/%s/%s/comments/%s", owner.getOwnerName(), owner.getName(), getId());
|
||||
}
|
||||
|
||||
|
||||
GHCommitComment wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
if (owner.root.isOffline()) {
|
||||
|
||||
@@ -36,15 +36,22 @@ public class GHCommitPointer {
|
||||
private GHRepository repo;
|
||||
|
||||
/**
|
||||
* This points to the user who owns
|
||||
* the {@link #getRepository()}.
|
||||
* This points to the user who owns the {@link #getRepository()}.
|
||||
*
|
||||
* @return the user
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getUser() {
|
||||
public GHUser getUser() throws IOException {
|
||||
if (user != null)
|
||||
return user.root.intern(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* The repository that contains the commit.
|
||||
*
|
||||
* @return the repository
|
||||
*/
|
||||
public GHRepository getRepository() {
|
||||
return repo;
|
||||
@@ -52,6 +59,8 @@ public class GHCommitPointer {
|
||||
|
||||
/**
|
||||
* Named ref to the commit. This appears to be a "short ref" that doesn't include "refs/heads/" portion.
|
||||
*
|
||||
* @return the ref
|
||||
*/
|
||||
public String getRef() {
|
||||
return ref;
|
||||
@@ -59,6 +68,8 @@ public class GHCommitPointer {
|
||||
|
||||
/**
|
||||
* SHA1 of the commit.
|
||||
*
|
||||
* @return the sha
|
||||
*/
|
||||
public String getSha() {
|
||||
return sha;
|
||||
@@ -66,6 +77,8 @@ public class GHCommitPointer {
|
||||
|
||||
/**
|
||||
* String that looks like "USERNAME:REF".
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
@@ -73,13 +86,19 @@ public class GHCommitPointer {
|
||||
|
||||
/**
|
||||
* Obtains the commit that this pointer is referring to.
|
||||
*
|
||||
* @return the commit
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHCommit getCommit() throws IOException {
|
||||
return getRepository().getCommit(getSha());
|
||||
}
|
||||
|
||||
void wrapUp(GitHub root) {
|
||||
if (user!=null) user.root = root;
|
||||
if (repo!=null) repo.wrap(root);
|
||||
if (user != null)
|
||||
user.root = root;
|
||||
if (repo != null)
|
||||
repo.wrap(root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,57 +16,83 @@ import java.util.Date;
|
||||
* </pre>
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHRepository#queryCommits()
|
||||
*/
|
||||
* @see GHRepository#queryCommits() GHRepository#queryCommits()
|
||||
*/
|
||||
public class GHCommitQueryBuilder {
|
||||
private final Requester req;
|
||||
private final GHRepository repo;
|
||||
|
||||
/*package*/ GHCommitQueryBuilder(GHRepository repo) {
|
||||
GHCommitQueryBuilder(GHRepository repo) {
|
||||
this.repo = repo;
|
||||
this.req = repo.root.retrieve(); // requester to build up
|
||||
this.req = repo.root.createRequest(); // requester to build up
|
||||
}
|
||||
|
||||
/**
|
||||
* GItHub login or email address by which to filter by commit author.
|
||||
*
|
||||
* @param author
|
||||
* the author
|
||||
* @return the gh commit query builder
|
||||
*/
|
||||
public GHCommitQueryBuilder author(String author) {
|
||||
req.with("author",author);
|
||||
req.with("author", author);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only commits containing this file path will be returned.
|
||||
*
|
||||
* @param path
|
||||
* the path
|
||||
* @return the gh commit query builder
|
||||
*/
|
||||
public GHCommitQueryBuilder path(String path) {
|
||||
req.with("path",path);
|
||||
req.with("path", path);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the SHA1 commit / tag / branch / etc to start listing commits from.
|
||||
*
|
||||
* @param ref
|
||||
* the ref
|
||||
* @return the gh commit query builder
|
||||
*/
|
||||
public GHCommitQueryBuilder from(String ref) {
|
||||
req.with("sha",ref);
|
||||
req.with("sha", ref);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Page size gh commit query builder.
|
||||
*
|
||||
* @param pageSize
|
||||
* the page size
|
||||
* @return the gh commit query builder
|
||||
*/
|
||||
public GHCommitQueryBuilder pageSize(int pageSize) {
|
||||
req.with("per_page",pageSize);
|
||||
req.with("per_page", pageSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only commits after this date will be returned
|
||||
*
|
||||
* @param dt
|
||||
* the dt
|
||||
* @return the gh commit query builder
|
||||
*/
|
||||
public GHCommitQueryBuilder since(Date dt) {
|
||||
req.with("since",GitHub.printDate(dt));
|
||||
req.with("since", GitHubClient.printDate(dt));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only commits after this date will be returned
|
||||
*
|
||||
* @param timestamp
|
||||
* the timestamp
|
||||
* @return the gh commit query builder
|
||||
*/
|
||||
public GHCommitQueryBuilder since(long timestamp) {
|
||||
return since(new Date(timestamp));
|
||||
@@ -74,14 +100,22 @@ public class GHCommitQueryBuilder {
|
||||
|
||||
/**
|
||||
* Only commits before this date will be returned
|
||||
*
|
||||
* @param dt
|
||||
* the dt
|
||||
* @return the gh commit query builder
|
||||
*/
|
||||
public GHCommitQueryBuilder until(Date dt) {
|
||||
req.with("until",GitHub.printDate(dt));
|
||||
req.with("until", GitHubClient.printDate(dt));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only commits before this date will be returned
|
||||
*
|
||||
* @param timestamp
|
||||
* the timestamp
|
||||
* @return the gh commit query builder
|
||||
*/
|
||||
public GHCommitQueryBuilder until(long timestamp) {
|
||||
return until(new Date(timestamp));
|
||||
@@ -89,17 +123,10 @@ public class GHCommitQueryBuilder {
|
||||
|
||||
/**
|
||||
* Lists up the commits with the criteria built so far.
|
||||
*
|
||||
* @return the paged iterable
|
||||
*/
|
||||
public PagedIterable<GHCommit> list() {
|
||||
return new PagedIterable<GHCommit>() {
|
||||
public PagedIterator<GHCommit> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHCommit>(req.asIterator(repo.getApiTailUrl("commits"), GHCommit[].class, pageSize)) {
|
||||
protected void wrapUp(GHCommit[] page) {
|
||||
for (GHCommit c : page)
|
||||
c.wrapUp(repo);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return req.withUrlPath(repo.getApiTailUrl("commits")).toIterable(GHCommit[].class, item -> item.wrapUp(repo));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Search commits.
|
||||
*
|
||||
* @author Marc de Verdelhan
|
||||
* @see GitHub#searchCommits()
|
||||
* @see GitHub#searchCommits() GitHub#searchCommits()
|
||||
*/
|
||||
@Preview @Deprecated
|
||||
@Preview(Previews.CLOAK)
|
||||
@Deprecated
|
||||
public class GHCommitSearchBuilder extends GHSearchBuilder<GHCommit> {
|
||||
/*package*/ GHCommitSearchBuilder(GitHub root) {
|
||||
super(root,CommitSearchResult.class);
|
||||
GHCommitSearchBuilder(GitHub root) {
|
||||
super(root, CommitSearchResult.class);
|
||||
req.withPreview(Previews.CLOAK);
|
||||
}
|
||||
|
||||
@@ -25,107 +27,240 @@ public class GHCommitSearchBuilder extends GHSearchBuilder<GHCommit> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Author gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder author(String v) {
|
||||
return q("author:"+v);
|
||||
return q("author:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Committer gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder committer(String v) {
|
||||
return q("committer:"+v);
|
||||
return q("committer:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Author name gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder authorName(String v) {
|
||||
return q("author-name:"+v);
|
||||
return q("author-name:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Committer name gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder committerName(String v) {
|
||||
return q("committer-name:"+v);
|
||||
return q("committer-name:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Author email gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder authorEmail(String v) {
|
||||
return q("author-email:"+v);
|
||||
return q("author-email:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Committer email gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder committerEmail(String v) {
|
||||
return q("committer-email:"+v);
|
||||
return q("committer-email:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Author date gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder authorDate(String v) {
|
||||
return q("author-date:"+v);
|
||||
return q("author-date:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Committer date gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder committerDate(String v) {
|
||||
return q("committer-date:"+v);
|
||||
return q("committer-date:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge gh commit search builder.
|
||||
*
|
||||
* @param merge
|
||||
* the merge
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder merge(boolean merge) {
|
||||
return q("merge:"+Boolean.valueOf(merge).toString().toLowerCase());
|
||||
return q("merge:" + Boolean.valueOf(merge).toString().toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder hash(String v) {
|
||||
return q("hash:"+v);
|
||||
return q("hash:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder parent(String v) {
|
||||
return q("parent:"+v);
|
||||
return q("parent:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tree gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder tree(String v) {
|
||||
return q("tree:"+v);
|
||||
return q("tree:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder is(String v) {
|
||||
return q("is:"+v);
|
||||
return q("is:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* User gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder user(String v) {
|
||||
return q("user:"+v);
|
||||
return q("user:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Org gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder org(String v) {
|
||||
return q("org:"+v);
|
||||
return q("org:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Repo gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder repo(String v) {
|
||||
return q("repo:"+v);
|
||||
return q("repo:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order gh commit search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder order(GHDirection v) {
|
||||
req.with("order",v);
|
||||
req.with("order", v);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort gh commit search builder.
|
||||
*
|
||||
* @param sort
|
||||
* the sort
|
||||
* @return the gh commit search builder
|
||||
*/
|
||||
public GHCommitSearchBuilder sort(Sort sort) {
|
||||
req.with("sort",sort);
|
||||
req.with("sort", sort);
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum Sort { AUTHOR_DATE, COMMITTER_DATE }
|
||||
/**
|
||||
* The enum Sort.
|
||||
*/
|
||||
public enum Sort {
|
||||
AUTHOR_DATE, COMMITTER_DATE
|
||||
}
|
||||
|
||||
private static class CommitSearchResult extends SearchResult<GHCommit> {
|
||||
private GHCommit[] items;
|
||||
|
||||
@Override
|
||||
/*package*/ GHCommit[] getItems(GitHub root) {
|
||||
GHCommit[] getItems(GitHub root) {
|
||||
for (GHCommit commit : items) {
|
||||
String repoName = getRepoName(commit.url);
|
||||
try {
|
||||
GHRepository repo = root.getRepository(repoName);
|
||||
commit.wrapUp(repo);
|
||||
} catch (IOException ioe) {}
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param commitUrl a commit URL
|
||||
* @param commitUrl
|
||||
* a commit URL
|
||||
* @return the repo name ("username/reponame")
|
||||
*/
|
||||
private static String getRepoName(String commitUrl) {
|
||||
if (StringUtils.isBlank(commitUrl)) {
|
||||
return null;
|
||||
}
|
||||
int indexOfUsername = (GitHub.GITHUB_URL + "/repos/").length();
|
||||
int indexOfUsername = (GitHubClient.GITHUB_URL + "/repos/").length();
|
||||
String[] tokens = commitUrl.substring(indexOfUsername).split("/", 3);
|
||||
return tokens[0] + '/' + tokens[1];
|
||||
}
|
||||
|
||||
@@ -1,54 +1,79 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Represents a status of a commit.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHRepository#getLastCommitStatus(String)
|
||||
* @see GHCommit#getLastStatus()
|
||||
* @see GHRepository#createCommitStatus(String, GHCommitState, String, String)
|
||||
* @see GHRepository#getLastCommitStatus(String) GHRepository#getLastCommitStatus(String)
|
||||
* @see GHCommit#getLastStatus() GHCommit#getLastStatus()
|
||||
* @see GHRepository#createCommitStatus(String, GHCommitState, String, String) GHRepository#createCommitStatus(String,
|
||||
* GHCommitState, String, String)
|
||||
*/
|
||||
public class GHCommitStatus extends GHObject {
|
||||
String state;
|
||||
String target_url,description;
|
||||
String target_url, description;
|
||||
String context;
|
||||
GHUser creator;
|
||||
|
||||
private GitHub root;
|
||||
|
||||
/*package*/ GHCommitStatus wrapUp(GitHub root) {
|
||||
if (creator!=null) creator.wrapUp(root);
|
||||
GHCommitStatus wrapUp(GitHub root) {
|
||||
if (creator != null)
|
||||
creator.wrapUp(root);
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets state.
|
||||
*
|
||||
* @return the state
|
||||
*/
|
||||
public GHCommitState getState() {
|
||||
for (GHCommitState s : GHCommitState.values()) {
|
||||
if (s.name().equalsIgnoreCase(state))
|
||||
return s;
|
||||
}
|
||||
throw new IllegalStateException("Unexpected state: "+state);
|
||||
throw new IllegalStateException("Unexpected state: " + state);
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL that this status is linked to.
|
||||
*
|
||||
* <p>
|
||||
* This is the URL specified when creating a commit status.
|
||||
*
|
||||
* @return the target url
|
||||
*/
|
||||
public String getTargetUrl() {
|
||||
return target_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public GHUser getCreator() {
|
||||
return creator;
|
||||
/**
|
||||
* Gets creator.
|
||||
*
|
||||
* @return the creator
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getCreator() throws IOException {
|
||||
return root.intern(creator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets context.
|
||||
*
|
||||
* @return the context
|
||||
*/
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -21,52 +21,108 @@ public class GHCompare {
|
||||
|
||||
private GHRepository owner;
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets html url.
|
||||
*
|
||||
* @return the html url
|
||||
*/
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets permalink url.
|
||||
*
|
||||
* @return the permalink url
|
||||
*/
|
||||
public URL getPermalinkUrl() {
|
||||
return GitHub.parseURL(permalink_url);
|
||||
return GitHubClient.parseURL(permalink_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets diff url.
|
||||
*
|
||||
* @return the diff url
|
||||
*/
|
||||
public URL getDiffUrl() {
|
||||
return GitHub.parseURL(diff_url);
|
||||
return GitHubClient.parseURL(diff_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets patch url.
|
||||
*
|
||||
* @return the patch url
|
||||
*/
|
||||
public URL getPatchUrl() {
|
||||
return GitHub.parseURL(patch_url);
|
||||
return GitHubClient.parseURL(patch_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets status.
|
||||
*
|
||||
* @return the status
|
||||
*/
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ahead by.
|
||||
*
|
||||
* @return the ahead by
|
||||
*/
|
||||
public int getAheadBy() {
|
||||
return ahead_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets behind by.
|
||||
*
|
||||
* @return the behind by
|
||||
*/
|
||||
public int getBehindBy() {
|
||||
return behind_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets total commits.
|
||||
*
|
||||
* @return the total commits
|
||||
*/
|
||||
public int getTotalCommits() {
|
||||
return total_commits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets base commit.
|
||||
*
|
||||
* @return the base commit
|
||||
*/
|
||||
public Commit getBaseCommit() {
|
||||
return base_commit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets merge base commit.
|
||||
*
|
||||
* @return the merge base commit
|
||||
*/
|
||||
public Commit getMergeBaseCommit() {
|
||||
return merge_base_commit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of commits.
|
||||
*
|
||||
* @return A copy of the array being stored in the class.
|
||||
*/
|
||||
public Commit[] getCommits() {
|
||||
@@ -74,9 +130,10 @@ public class GHCompare {
|
||||
System.arraycopy(commits, 0, newValue, 0, commits.length);
|
||||
return newValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets an array of commits.
|
||||
*
|
||||
* @return A copy of the array being stored in the class.
|
||||
*/
|
||||
public GHCommit.File[] getFiles() {
|
||||
@@ -85,6 +142,13 @@ public class GHCompare {
|
||||
return newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap gh compare.
|
||||
*
|
||||
* @param owner
|
||||
* the owner
|
||||
* @return the gh compare
|
||||
*/
|
||||
public GHCompare wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
for (Commit commit : commits) {
|
||||
@@ -96,71 +160,126 @@ public class GHCompare {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare commits had a child commit element with additional details we want to capture.
|
||||
* This extenstion of GHCommit provides that.
|
||||
* Compare commits had a child commit element with additional details we want to capture. This extenstion of
|
||||
* GHCommit provides that.
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD"},
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" },
|
||||
justification = "JSON API")
|
||||
public static class Commit extends GHCommit {
|
||||
|
||||
private InnerCommit commit;
|
||||
|
||||
/**
|
||||
* Gets commit.
|
||||
*
|
||||
* @return the commit
|
||||
*/
|
||||
public InnerCommit getCommit() {
|
||||
return commit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The type InnerCommit.
|
||||
*/
|
||||
public static class InnerCommit {
|
||||
private String url, sha, message;
|
||||
private User author, committer;
|
||||
private Tree tree;
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets sha.
|
||||
*
|
||||
* @return the sha
|
||||
*/
|
||||
public String getSha() {
|
||||
return sha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets message.
|
||||
*
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@WithBridgeMethods(value=User.class,castRequired=true)
|
||||
/**
|
||||
* Gets author.
|
||||
*
|
||||
* @return the author
|
||||
*/
|
||||
@WithBridgeMethods(value = User.class, castRequired = true)
|
||||
public GitUser getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
@WithBridgeMethods(value=User.class,castRequired=true)
|
||||
/**
|
||||
* Gets committer.
|
||||
*
|
||||
* @return the committer
|
||||
*/
|
||||
@WithBridgeMethods(value = User.class, castRequired = true)
|
||||
public GitUser getCommitter() {
|
||||
return committer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets tree.
|
||||
*
|
||||
* @return the tree
|
||||
*/
|
||||
public Tree getTree() {
|
||||
return tree;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The type Tree.
|
||||
*/
|
||||
public static class Tree {
|
||||
private String url, sha;
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets sha.
|
||||
*
|
||||
* @return the sha
|
||||
*/
|
||||
public String getSha() {
|
||||
return sha;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The type User.
|
||||
*
|
||||
* @deprecated use {@link GitUser} instead.
|
||||
*/
|
||||
public static class User extends GitUser {
|
||||
}
|
||||
|
||||
/**
|
||||
* The enum Status.
|
||||
*/
|
||||
public static enum Status {
|
||||
behind, ahead, identical, diverged
|
||||
}
|
||||
|
||||
@@ -1,112 +1,169 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* A Content of a repository.
|
||||
*
|
||||
* @author Alexandre COLLIGNON
|
||||
* @see GHRepository#getFileContent(String)
|
||||
* @see GHRepository#getFileContent(String) GHRepository#getFileContent(String)
|
||||
*/
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public class GHContent {
|
||||
@SuppressWarnings({ "UnusedDeclaration" })
|
||||
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.
|
||||
* 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
|
||||
private String html_url; // this is the UI
|
||||
private String git_url; // this is the Blob url
|
||||
private String html_url; // this is the UI
|
||||
private String download_url;
|
||||
|
||||
/**
|
||||
* Gets owner.
|
||||
*
|
||||
* @return the owner
|
||||
*/
|
||||
public GHRepository getOwner() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets encoding.
|
||||
*
|
||||
* @return the encoding
|
||||
*/
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets size.
|
||||
*
|
||||
* @return the size
|
||||
*/
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets sha.
|
||||
*
|
||||
* @return the sha
|
||||
*/
|
||||
public String getSha() {
|
||||
return sha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets path.
|
||||
*
|
||||
* @return the path
|
||||
*/
|
||||
public String getPath() {
|
||||
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.
|
||||
*
|
||||
* <p>
|
||||
* Due to the nature of GitHub's API, you're not guaranteed that
|
||||
* the content will already be populated, so this may trigger
|
||||
* network activity, and can throw an IOException.
|
||||
* Due to the nature of GitHub's API, you're not guaranteed that the content will already be populated, so this may
|
||||
* trigger network activity, and can throw an IOException.
|
||||
*
|
||||
* @deprecated
|
||||
* Use {@link #read()}
|
||||
* @return the content
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated Use {@link #read()}
|
||||
*/
|
||||
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
|
||||
public String getContent() throws IOException {
|
||||
return new String(Base64.decodeBase64(getEncodedContent()));
|
||||
return new String(Base64.getMimeDecoder().decode(getEncodedContent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the base64-encoded content that is stored at this location.
|
||||
*
|
||||
* <p>
|
||||
* Due to the nature of GitHub's API, you're not guaranteed that
|
||||
* the content will already be populated, so this may trigger
|
||||
* network activity, and can throw an IOException.
|
||||
* Due to the nature of GitHub's API, you're not guaranteed that the content will already be populated, so this may
|
||||
* trigger network activity, and can throw an IOException.
|
||||
*
|
||||
* @deprecated
|
||||
* Use {@link #read()}
|
||||
* @return the encoded content
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated Use {@link #read()}
|
||||
*/
|
||||
public String getEncodedContent() throws IOException {
|
||||
if (content!=null)
|
||||
return content;
|
||||
else
|
||||
return Base64.encodeBase64String(IOUtils.toByteArray(read()));
|
||||
refresh(content);
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets git url.
|
||||
*
|
||||
* @return the git url
|
||||
*/
|
||||
public String getGitUrl() {
|
||||
return git_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets html url.
|
||||
*
|
||||
* @return the html url
|
||||
*/
|
||||
public String getHtmlUrl() {
|
||||
return html_url;
|
||||
}
|
||||
@@ -114,85 +171,163 @@ public class GHContent {
|
||||
/**
|
||||
* Retrieves the actual content stored here.
|
||||
*/
|
||||
/**
|
||||
* Retrieves the actual bytes of the blob.
|
||||
*
|
||||
* @return the input stream
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public InputStream read() throws IOException {
|
||||
// if the download link is encoded with a token on the query string, the default behavior of POST will fail
|
||||
return new Requester(root).method("GET").asStream(getDownloadUrl());
|
||||
refresh(content);
|
||||
if (encoding.equals("base64")) {
|
||||
try {
|
||||
Base64.Decoder decoder = Base64.getMimeDecoder();
|
||||
return new ByteArrayInputStream(decoder.decode(content.getBytes(StandardCharsets.US_ASCII)));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new AssertionError(e); // US-ASCII is mandatory
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("Unrecognized encoding: " + encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* URL to retrieve the raw content of the file. Null if this is a directory.
|
||||
*
|
||||
* @return the download url
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public String getDownloadUrl() throws IOException {
|
||||
populate();
|
||||
refresh(download_url);
|
||||
return download_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is file boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isFile() {
|
||||
return "file".equals(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is directory boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isDirectory() {
|
||||
return "dir".equals(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fully populate the data by retrieving missing data.
|
||||
*
|
||||
* <p>
|
||||
* Depending on the original API call where this object is created, it may not contain everything.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
protected synchronized void populate() throws IOException {
|
||||
if (download_url!=null) return; // already populated
|
||||
root.retrieve().to(url, this);
|
||||
root.createRequest().withUrlPath(url).fetchInto(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* List immediate children of this directory.
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHContent> listDirectoryContent() throws IOException {
|
||||
if (!isDirectory())
|
||||
throw new IllegalStateException(path+" is not a directory");
|
||||
throw new IllegalStateException(path + " is not a directory");
|
||||
|
||||
return new PagedIterable<GHContent>() {
|
||||
public PagedIterator<GHContent> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHContent>(root.retrieve().asIterator(url, GHContent[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHContent[] page) {
|
||||
GHContent.wrap(page, repository);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return root.createRequest().setRawUrlPath(url).toIterable(GHContent[].class, item -> item.wrap(repository));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update gh content update response.
|
||||
*
|
||||
* @param newContent
|
||||
* the new content
|
||||
* @param commitMessage
|
||||
* the commit message
|
||||
* @return the gh content update response
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
|
||||
public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException {
|
||||
return update(newContent.getBytes(), commitMessage, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update gh content update response.
|
||||
*
|
||||
* @param newContent
|
||||
* the new content
|
||||
* @param commitMessage
|
||||
* the commit message
|
||||
* @param branch
|
||||
* the branch
|
||||
* @return the gh content update response
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
|
||||
public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException {
|
||||
return update(newContent.getBytes(), commitMessage, branch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update gh content update response.
|
||||
*
|
||||
* @param newContentBytes
|
||||
* the new content bytes
|
||||
* @param commitMessage
|
||||
* the commit message
|
||||
* @return the gh content update response
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage) throws IOException {
|
||||
return update(newContentBytes, commitMessage, null);
|
||||
}
|
||||
|
||||
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch) throws IOException {
|
||||
String encodedContent = Base64.encodeBase64String(newContentBytes);
|
||||
/**
|
||||
* Update gh content update response.
|
||||
*
|
||||
* @param newContentBytes
|
||||
* the new content bytes
|
||||
* @param commitMessage
|
||||
* the commit message
|
||||
* @param branch
|
||||
* the branch
|
||||
* @return the gh content update response
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch)
|
||||
throws IOException {
|
||||
String encodedContent = Base64.getEncoder().encodeToString(newContentBytes);
|
||||
|
||||
Requester requester = new Requester(root)
|
||||
.with("path", path)
|
||||
.with("message", commitMessage)
|
||||
.with("sha", sha)
|
||||
.with("content", encodedContent)
|
||||
.method("PUT");
|
||||
Requester requester = root.createRequest()
|
||||
.method("POST")
|
||||
.with("path", path)
|
||||
.with("message", commitMessage)
|
||||
.with("sha", sha)
|
||||
.with("content", encodedContent)
|
||||
.method("PUT");
|
||||
|
||||
if (branch != null) {
|
||||
requester.with("branch", branch);
|
||||
}
|
||||
|
||||
GHContentUpdateResponse response = requester.to(getApiRoute(), GHContentUpdateResponse.class);
|
||||
GHContentUpdateResponse response = requester.withUrlPath(getApiRoute(repository, path))
|
||||
.fetch(GHContentUpdateResponse.class);
|
||||
|
||||
response.getContent().wrap(repository);
|
||||
response.getCommit().wrapUp(repository);
|
||||
@@ -201,29 +336,51 @@ public class GHContent {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete gh content update response.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @return the gh content update response
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHContentUpdateResponse delete(String message) throws IOException {
|
||||
return delete(message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete gh content update response.
|
||||
*
|
||||
* @param commitMessage
|
||||
* the commit message
|
||||
* @param branch
|
||||
* the branch
|
||||
* @return the gh content update response
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException {
|
||||
Requester requester = new Requester(root)
|
||||
.with("path", path)
|
||||
.with("message", commitMessage)
|
||||
.with("sha", sha)
|
||||
.method("DELETE");
|
||||
Requester requester = root.createRequest()
|
||||
.method("POST")
|
||||
.with("path", path)
|
||||
.with("message", commitMessage)
|
||||
.with("sha", sha)
|
||||
.method("DELETE");
|
||||
|
||||
if (branch != null) {
|
||||
requester.with("branch", branch);
|
||||
}
|
||||
|
||||
GHContentUpdateResponse response = requester.to(getApiRoute(), GHContentUpdateResponse.class);
|
||||
GHContentUpdateResponse response = requester.withUrlPath(getApiRoute(repository, path))
|
||||
.fetch(GHContentUpdateResponse.class);
|
||||
|
||||
response.getCommit().wrapUp(repository);
|
||||
return response;
|
||||
}
|
||||
|
||||
private String getApiRoute() {
|
||||
return "/repos/" + repository.getOwnerName() + "/" + repository.getName() + "/contents/" + path;
|
||||
static String getApiRoute(GHRepository repository, String path) {
|
||||
return repository.getApiTailUrl("contents/" + path);
|
||||
}
|
||||
|
||||
GHContent wrap(GHRepository owner) {
|
||||
@@ -231,18 +388,21 @@ public class GHContent {
|
||||
this.root = owner.root;
|
||||
return this;
|
||||
}
|
||||
|
||||
GHContent wrap(GitHub root) {
|
||||
this.root = root;
|
||||
if (repository!=null)
|
||||
if (repository != null)
|
||||
repository.wrap(root);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public static GHContent[] wrap(GHContent[] contents, GHRepository repository) {
|
||||
for (GHContent unwrappedContent : contents) {
|
||||
unwrappedContent.wrap(repository);
|
||||
}
|
||||
return contents;
|
||||
/**
|
||||
* Fully populate the data by retrieving missing data.
|
||||
*
|
||||
* Depending on the original API call where this object is created, it may not contain everything.
|
||||
*/
|
||||
@Override
|
||||
public synchronized void refresh() throws IOException {
|
||||
root.createRequest().setRawUrlPath(url).fetchInto(this);
|
||||
}
|
||||
}
|
||||
|
||||
114
src/main/java/org/kohsuke/github/GHContentBuilder.java
Normal file
114
src/main/java/org/kohsuke/github/GHContentBuilder.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* Used to create/update content.
|
||||
*
|
||||
* <p>
|
||||
* Call various methods to build up parameters, then call {@link #commit()} to make the change effective.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHRepository#createContent() GHRepository#createContent()
|
||||
*/
|
||||
public final class GHContentBuilder {
|
||||
private final GHRepository repo;
|
||||
private final Requester req;
|
||||
private String path;
|
||||
|
||||
GHContentBuilder(GHRepository repo) {
|
||||
this.repo = repo;
|
||||
this.req = repo.root.createRequest().method("PUT");
|
||||
}
|
||||
|
||||
/**
|
||||
* Path gh content builder.
|
||||
*
|
||||
* @param path
|
||||
* the path
|
||||
* @return the gh content builder
|
||||
*/
|
||||
public GHContentBuilder path(String path) {
|
||||
this.path = path;
|
||||
req.with("path", path);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Branch gh content builder.
|
||||
*
|
||||
* @param branch
|
||||
* the branch
|
||||
* @return the gh content builder
|
||||
*/
|
||||
public GHContentBuilder branch(String branch) {
|
||||
req.with("branch", branch);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when updating (but not creating a new content) to specify the blob SHA of the file being replaced.
|
||||
*
|
||||
* @param sha
|
||||
* the sha
|
||||
* @return the gh content builder
|
||||
*/
|
||||
public GHContentBuilder sha(String sha) {
|
||||
req.with("sha", sha);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Content gh content builder.
|
||||
*
|
||||
* @param content
|
||||
* the content
|
||||
* @return the gh content builder
|
||||
*/
|
||||
public GHContentBuilder content(byte[] content) {
|
||||
req.with("content", Base64.getEncoder().encodeToString(content));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Content gh content builder.
|
||||
*
|
||||
* @param content
|
||||
* the content
|
||||
* @return the gh content builder
|
||||
*/
|
||||
public GHContentBuilder content(String content) {
|
||||
return content(content.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Message gh content builder.
|
||||
*
|
||||
* @param commitMessage
|
||||
* the commit message
|
||||
* @return the gh content builder
|
||||
*/
|
||||
public GHContentBuilder message(String commitMessage) {
|
||||
req.with("message", commitMessage);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commits a new content.
|
||||
*
|
||||
* @return the gh content update response
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHContentUpdateResponse commit() throws IOException {
|
||||
GHContentUpdateResponse response = req.withUrlPath(GHContent.getApiRoute(repo, path))
|
||||
.fetch(GHContentUpdateResponse.class);
|
||||
|
||||
response.getContent().wrap(repo);
|
||||
response.getCommit().wrapUp(repo);
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@ package org.kohsuke.github;
|
||||
* Search code for {@link GHContent}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GitHub#searchContent()
|
||||
* @see GitHub#searchContent() GitHub#searchContent()
|
||||
*/
|
||||
public class GHContentSearchBuilder extends GHSearchBuilder<GHContent> {
|
||||
/*package*/ GHContentSearchBuilder(GitHub root) {
|
||||
super(root,ContentSearchResult.class);
|
||||
GHContentSearchBuilder(GitHub root) {
|
||||
super(root, ContentSearchResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -19,48 +19,110 @@ public class GHContentSearchBuilder extends GHSearchBuilder<GHContent> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* In gh content search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh content search builder
|
||||
*/
|
||||
public GHContentSearchBuilder in(String v) {
|
||||
return q("in:"+v);
|
||||
return q("in:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Language gh content search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh content search builder
|
||||
*/
|
||||
public GHContentSearchBuilder language(String v) {
|
||||
return q("language:"+v);
|
||||
return q("language:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fork gh content search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh content search builder
|
||||
*/
|
||||
public GHContentSearchBuilder fork(String v) {
|
||||
return q("fork:"+v);
|
||||
return q("fork:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Size gh content search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh content search builder
|
||||
*/
|
||||
public GHContentSearchBuilder size(String v) {
|
||||
return q("size:"+v);
|
||||
return q("size:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Path gh content search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh content search builder
|
||||
*/
|
||||
public GHContentSearchBuilder path(String v) {
|
||||
return q("path:"+v);
|
||||
return q("path:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filename gh content search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh content search builder
|
||||
*/
|
||||
public GHContentSearchBuilder filename(String v) {
|
||||
return q("filename:"+v);
|
||||
return q("filename:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension gh content search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh content search builder
|
||||
*/
|
||||
public GHContentSearchBuilder extension(String v) {
|
||||
return q("extension:"+v);
|
||||
return q("extension:" + v);
|
||||
}
|
||||
|
||||
/**
|
||||
* User gh content search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh content search builder
|
||||
*/
|
||||
public GHContentSearchBuilder user(String v) {
|
||||
return q("user:"+v);
|
||||
return q("user:" + v);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Repo gh content search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh content search builder
|
||||
*/
|
||||
public GHContentSearchBuilder repo(String v) {
|
||||
return q("repo:"+v);
|
||||
return q("repo:" + v);
|
||||
}
|
||||
|
||||
private static class ContentSearchResult extends SearchResult<GHContent> {
|
||||
private GHContent[] items;
|
||||
|
||||
@Override
|
||||
/*package*/ GHContent[] getItems(GitHub root) {
|
||||
GHContent[] getItems(GitHub root) {
|
||||
for (GHContent item : items)
|
||||
item.wrap(root);
|
||||
return items;
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
/**
|
||||
* The response that is returned when updating
|
||||
* repository content.
|
||||
**/
|
||||
* The response that is returned when updating repository content.
|
||||
*/
|
||||
public class GHContentUpdateResponse {
|
||||
private GHContent content;
|
||||
private GHCommit commit;
|
||||
|
||||
/**
|
||||
* Gets content.
|
||||
*
|
||||
* @return the content
|
||||
*/
|
||||
public GHContent getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets commit.
|
||||
*
|
||||
* @return the commit
|
||||
*/
|
||||
public GHCommit getCommit() {
|
||||
return commit;
|
||||
}
|
||||
|
||||
@@ -7,14 +7,13 @@ package org.kohsuke.github;
|
||||
* @see <a href="https://developer.github.com/v3/licenses/#get-a-repositorys-license">documentation</a>
|
||||
* @see GHRepository#getLicense()
|
||||
*/
|
||||
@Preview @Deprecated
|
||||
class GHContentWithLicense extends GHContent {
|
||||
GHLicense license;
|
||||
|
||||
@Override
|
||||
GHContentWithLicense wrap(GHRepository owner) {
|
||||
super.wrap(owner);
|
||||
if (license!=null)
|
||||
if (license != null)
|
||||
license.wrap(owner.root);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,114 +1,134 @@
|
||||
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> {
|
||||
|
||||
/*package*/ GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) {
|
||||
this.root = root;
|
||||
this.apiUrlTail = apiUrlTail;
|
||||
this.builder = new Requester(root);
|
||||
this.builder.with("name",name);
|
||||
}
|
||||
public GHCreateRepositoryBuilder(String name, GitHub root, String apiTail) {
|
||||
super(GHCreateRepositoryBuilder.class, root, null);
|
||||
requester.method("POST").withUrlPath(apiTail);
|
||||
|
||||
public GHCreateRepositoryBuilder description(String description) {
|
||||
this.builder.with("description",description);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GHCreateRepositoryBuilder homepage(URL homepage) {
|
||||
return homepage(homepage.toExternalForm());
|
||||
}
|
||||
|
||||
public GHCreateRepositoryBuilder homepage(String homepage) {
|
||||
this.builder.with("homepage",homepage);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a private repository
|
||||
*/
|
||||
public GHCreateRepositoryBuilder private_(boolean b) {
|
||||
this.builder.with("private",b);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables issue tracker
|
||||
*/
|
||||
public GHCreateRepositoryBuilder issues(boolean b) {
|
||||
this.builder.with("has_issues",b);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables wiki
|
||||
*/
|
||||
public GHCreateRepositoryBuilder wiki(boolean b) {
|
||||
this.builder.with("has_wiki",b);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables downloads
|
||||
*/
|
||||
public GHCreateRepositoryBuilder downloads(boolean b) {
|
||||
this.builder.with("has_downloads",b);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If true, create an initial commit with empty README.
|
||||
*/
|
||||
public GHCreateRepositoryBuilder autoInit(boolean b) {
|
||||
this.builder.with("auto_init",b);
|
||||
return this;
|
||||
try {
|
||||
name(name);
|
||||
} catch (IOException e) {
|
||||
// not going to happen here
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default .gitignore
|
||||
*
|
||||
* See https://developer.github.com/v3/repos/#create
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desired license template to apply
|
||||
*
|
||||
* See https://developer.github.com/v3/repos/#create
|
||||
* @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);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* The team that gets granted access to this repository. Only valid for creating a repository in an organization.
|
||||
*
|
||||
* @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) throws IOException {
|
||||
if (team != null)
|
||||
return with("team_id", team.getId());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The team that gets granted access to this repository. Only valid for creating a repository in
|
||||
* an organization.
|
||||
* 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
|
||||
*/
|
||||
public GHCreateRepositoryBuilder team(GHTeam team) {
|
||||
if (team!=null)
|
||||
this.builder.with("team_id",team.getId());
|
||||
@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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a repository with all the parameters.
|
||||
*
|
||||
* @return the gh repository
|
||||
* @throws IOException
|
||||
* if repository cannot be created
|
||||
*/
|
||||
public GHRepository create() throws IOException {
|
||||
return builder.method("POST").to(apiUrlTail, GHRepository.class).wrap(root);
|
||||
return done();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,46 +1,90 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||
|
||||
/**
|
||||
* The type GHDeployKey.
|
||||
*/
|
||||
public class GHDeployKey {
|
||||
|
||||
protected String url, key, title;
|
||||
protected boolean verified;
|
||||
protected int id;
|
||||
protected long id;
|
||||
private GHRepository owner;
|
||||
|
||||
public int getId() {
|
||||
/**
|
||||
* Gets id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets key.
|
||||
*
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets title.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is verified boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isVerified() {
|
||||
return verified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap gh deploy key.
|
||||
*
|
||||
* @param repo
|
||||
* the repo
|
||||
* @return the gh deploy key
|
||||
*/
|
||||
public GHDeployKey wrap(GHRepository repo) {
|
||||
this.owner = repo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this).append("title",title).append("id",id).append("key",key).toString();
|
||||
return new ToStringBuilder(this).append("title", title).append("id", id).append("key", key).toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
new Requester(owner.root).method("DELETE").to(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id));
|
||||
owner.root.createRequest()
|
||||
.method("DELETE")
|
||||
.withUrlPath(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id))
|
||||
.send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
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
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/repos/deployments/">documentation</a>
|
||||
* @see GHRepository#listDeployments(String, String, String, String) GHRepository#listDeployments(String, String,
|
||||
* String, String)
|
||||
* @see GHRepository#getDeployment(long) GHRepository#getDeployment(long)
|
||||
*/
|
||||
public class GHDeployment extends GHObject {
|
||||
private GHRepository owner;
|
||||
private GitHub root;
|
||||
protected String sha;
|
||||
protected String ref;
|
||||
protected String task;
|
||||
@@ -15,39 +25,149 @@ 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;
|
||||
this.root = owner.root;
|
||||
if(creator != null) creator.wrapUp(root);
|
||||
if (creator != null)
|
||||
creator.wrapUp(root);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets statuses url.
|
||||
*
|
||||
* @return the statuses url
|
||||
*/
|
||||
public URL getStatusesUrl() {
|
||||
return GitHub.parseURL(statuses_url);
|
||||
return GitHubClient.parseURL(statuses_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets repository url.
|
||||
*
|
||||
* @return the repository url
|
||||
*/
|
||||
public URL getRepositoryUrl() {
|
||||
return GitHub.parseURL(repository_url);
|
||||
return GitHubClient.parseURL(repository_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets task.
|
||||
*
|
||||
* @return the task
|
||||
*/
|
||||
public String getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public String getPayload() {
|
||||
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.
|
||||
*
|
||||
* @return the environment
|
||||
*/
|
||||
public String getEnvironment() {
|
||||
return environment;
|
||||
}
|
||||
public GHUser getCreator() {
|
||||
return creator;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return the creator
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getCreator() throws IOException {
|
||||
return root.intern(creator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ref.
|
||||
*
|
||||
* @return the ref
|
||||
*/
|
||||
public String getRef() {
|
||||
return ref;
|
||||
}
|
||||
public String getSha(){
|
||||
|
||||
/**
|
||||
* Gets sha.
|
||||
*
|
||||
* @return the sha
|
||||
*/
|
||||
public String getSha() {
|
||||
return sha;
|
||||
}
|
||||
|
||||
@@ -58,4 +178,29 @@ public class GHDeployment extends GHObject {
|
||||
public URL getHtmlUrl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create status gh deployment status builder.
|
||||
*
|
||||
* @param state
|
||||
* the state
|
||||
* @return the gh deployment status builder
|
||||
*/
|
||||
public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
|
||||
return new GHDeploymentStatusBuilder(owner, getId(), state);
|
||||
}
|
||||
|
||||
/**
|
||||
* List statuses paged iterable.
|
||||
*
|
||||
* @return the paged iterable
|
||||
*/
|
||||
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,55 +1,180 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
//Based on https://developer.github.com/v3/repos/deployments/#create-a-deployment
|
||||
/**
|
||||
* The type GHDeploymentBuilder.
|
||||
*/
|
||||
// Based on https://developer.github.com/v3/repos/deployments/#create-a-deployment
|
||||
public class GHDeploymentBuilder {
|
||||
private final GHRepository repo;
|
||||
private final Requester builder;
|
||||
|
||||
/**
|
||||
* Instantiates a new Gh deployment builder.
|
||||
*
|
||||
* @param repo
|
||||
* the repo
|
||||
*/
|
||||
public GHDeploymentBuilder(GHRepository repo) {
|
||||
this.repo = repo;
|
||||
this.builder = new Requester(repo.root);
|
||||
this.builder = repo.root.createRequest()
|
||||
.withPreview(Previews.ANT_MAN)
|
||||
.withPreview(Previews.FLASH)
|
||||
.method("POST");
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Gh deployment builder.
|
||||
*
|
||||
* @param repo
|
||||
* the repo
|
||||
* @param ref
|
||||
* the ref
|
||||
*/
|
||||
public GHDeploymentBuilder(GHRepository repo, String ref) {
|
||||
this(repo);
|
||||
ref(ref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ref gh deployment builder.
|
||||
*
|
||||
* @param branch
|
||||
* the branch
|
||||
*
|
||||
* @return the gh deployment builder
|
||||
*/
|
||||
public GHDeploymentBuilder ref(String branch) {
|
||||
builder.with("ref",branch);
|
||||
builder.with("ref", branch);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Task gh deployment builder.
|
||||
*
|
||||
* @param task
|
||||
* the task
|
||||
*
|
||||
* @return the gh deployment builder
|
||||
*/
|
||||
public GHDeploymentBuilder task(String task) {
|
||||
builder.with("task",task);
|
||||
builder.with("task", task);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto merge gh deployment builder.
|
||||
*
|
||||
* @param autoMerge
|
||||
* the auto merge
|
||||
*
|
||||
* @return the gh deployment builder
|
||||
*/
|
||||
public GHDeploymentBuilder autoMerge(boolean autoMerge) {
|
||||
builder.with("auto_merge",autoMerge);
|
||||
builder.with("auto_merge", autoMerge);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required contexts gh deployment builder.
|
||||
*
|
||||
* @param requiredContexts
|
||||
* the required contexts
|
||||
*
|
||||
* @return the gh deployment builder
|
||||
*/
|
||||
public GHDeploymentBuilder requiredContexts(List<String> requiredContexts) {
|
||||
builder.with("required_contexts",requiredContexts);
|
||||
builder.with("required_contexts", requiredContexts);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Payload gh deployment builder.
|
||||
*
|
||||
* @param payload
|
||||
* the payload
|
||||
*
|
||||
* @return the gh deployment builder
|
||||
*/
|
||||
public GHDeploymentBuilder payload(String payload) {
|
||||
builder.with("payload",payload);
|
||||
builder.with("payload", payload);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Environment gh deployment builder.
|
||||
*
|
||||
* @param environment
|
||||
* the environment
|
||||
*
|
||||
* @return the gh deployment builder
|
||||
*/
|
||||
public GHDeploymentBuilder environment(String environment) {
|
||||
builder.with("environment",environment);
|
||||
return this;
|
||||
}
|
||||
public GHDeploymentBuilder description(String description) {
|
||||
builder.with("description",description);
|
||||
builder.with("environment", environment);
|
||||
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) {
|
||||
builder.with("description", description);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create gh deployment.
|
||||
*
|
||||
* @return the gh deployment
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHDeployment create() throws IOException {
|
||||
return builder.to(repo.getApiTailUrl("deployments"),GHDeployment.class).wrap(repo);
|
||||
return builder.withUrlPath(repo.getApiTailUrl("deployments")).fetch(GHDeployment.class).wrap(repo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,35 +1,103 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The type GHDeploymentStatus.
|
||||
*/
|
||||
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) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
if(creator != null) creator.wrapUp(root);
|
||||
if (creator != null)
|
||||
creator.wrapUp(root);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets target url.
|
||||
*
|
||||
* @deprecated Target url is deprecated in favor of {@link #getLogUrl() getLogUrl}
|
||||
*
|
||||
* @return the target url
|
||||
*/
|
||||
@Deprecated
|
||||
public URL getTargetUrl() {
|
||||
return GitHub.parseURL(target_url);
|
||||
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.
|
||||
*
|
||||
* @return the deployment url
|
||||
*/
|
||||
public URL getDeploymentUrl() {
|
||||
return GitHub.parseURL(deployment_url);
|
||||
return GitHubClient.parseURL(deployment_url);
|
||||
}
|
||||
|
||||
public URL getRepositoryUrl() {
|
||||
return GitHub.parseURL(repository_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.
|
||||
*
|
||||
* @return the repository url
|
||||
*/
|
||||
public URL getRepositoryUrl() {
|
||||
return GitHubClient.parseURL(repository_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets state.
|
||||
*
|
||||
* @return the state
|
||||
*/
|
||||
public GHDeploymentState getState() {
|
||||
return GHDeploymentState.valueOf(state.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
@@ -1,31 +1,158 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Creates a new deployment status.
|
||||
*
|
||||
* @see GHDeployment#createStatus(GHDeploymentState) GHDeployment#createStatus(GHDeploymentState)
|
||||
*/
|
||||
public class GHDeploymentStatusBuilder {
|
||||
private final Requester builder;
|
||||
private GHRepository repo;
|
||||
private int deploymentId;
|
||||
private long deploymentId;
|
||||
|
||||
/**
|
||||
* Instantiates a new Gh deployment status builder.
|
||||
*
|
||||
* @param repo
|
||||
* the repo
|
||||
* @param deploymentId
|
||||
* the deployment id
|
||||
* @param state
|
||||
* the state
|
||||
*
|
||||
* @deprecated Use {@link GHDeployment#createStatus(GHDeploymentState)}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeploymentState state) {
|
||||
this(repo, (long) deploymentId, state);
|
||||
}
|
||||
|
||||
GHDeploymentStatusBuilder(GHRepository repo, long deploymentId, GHDeploymentState state) {
|
||||
this.repo = repo;
|
||||
this.deploymentId = deploymentId;
|
||||
this.builder = new Requester(repo.root);
|
||||
this.builder.with("state",state);
|
||||
this.builder = repo.root.createRequest()
|
||||
.withPreview(Previews.ANT_MAN)
|
||||
.withPreview(Previews.FLASH)
|
||||
.method("POST");
|
||||
|
||||
this.builder.with("state", state);
|
||||
}
|
||||
|
||||
public GHDeploymentStatusBuilder description(String description) {
|
||||
this.builder.with("description",description);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GHDeploymentStatusBuilder targetUrl(String targetUrl) {
|
||||
this.builder.with("target_url",targetUrl);
|
||||
/**
|
||||
* 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) {
|
||||
this.builder.with("description", description);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create gh deployment status.
|
||||
*
|
||||
* @return the gh deployment status
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHDeploymentStatus create() throws IOException {
|
||||
return builder.to(repo.getApiTailUrl("deployments")+"/"+deploymentId+"/statuses",GHDeploymentStatus.class).wrap(repo);
|
||||
return builder.withUrlPath(repo.getApiTailUrl("deployments/" + deploymentId + "/statuses"))
|
||||
.fetch(GHDeploymentStatus.class)
|
||||
.wrap(repo);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -25,36 +25,51 @@ package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
|
||||
/**
|
||||
* Represents an email of GitHub.
|
||||
*
|
||||
* @author Kelly Campbell
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||
"NP_UNWRITTEN_FIELD", "NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"}, justification = "JSON API")
|
||||
@SuppressFBWarnings(
|
||||
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||
"NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHEmail {
|
||||
|
||||
protected String email;
|
||||
protected boolean primary;
|
||||
protected boolean verified;
|
||||
|
||||
/**
|
||||
* Gets email.
|
||||
*
|
||||
* @return the email
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is primary boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isPrimary() {
|
||||
return primary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is verified boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isVerified() {
|
||||
return verified;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Email:"+email;
|
||||
return "Email:" + email;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,55 +10,73 @@ import java.util.Locale;
|
||||
* @see <a href="https://developer.github.com/v3/activity/events/types/">Event type reference</a>
|
||||
*/
|
||||
public enum GHEvent {
|
||||
CHECK_RUN,
|
||||
CHECK_SUITE,
|
||||
CODE_SCANNING_ALERT,
|
||||
COMMIT_COMMENT,
|
||||
CONTENT_REFERENCE,
|
||||
CREATE,
|
||||
DELETE,
|
||||
DEPLOY_KEY,
|
||||
DEPLOYMENT,
|
||||
DEPLOYMENT_STATUS,
|
||||
DOWNLOAD,
|
||||
FOLLOW,
|
||||
FORK,
|
||||
FORK_APPLY,
|
||||
GITHUB_APP_AUTHORIZATION,
|
||||
GIST,
|
||||
GOLLUM,
|
||||
INSTALLATION,
|
||||
INSTALLATION_REPOSITORIES,
|
||||
INTEGRATION_INSTALLATION_REPOSITORIES,
|
||||
ISSUE_COMMENT,
|
||||
ISSUES,
|
||||
LABEL,
|
||||
MARKETPLACE_PURCHASE,
|
||||
MEMBER,
|
||||
MEMBERSHIP,
|
||||
META,
|
||||
MILESTONE,
|
||||
ORGANIZATION,
|
||||
ORG_BLOCK,
|
||||
PACKAGE,
|
||||
PAGE_BUILD,
|
||||
PROJECT_CARD,
|
||||
PROJECT_COLUMN,
|
||||
PROJECT,
|
||||
PING,
|
||||
PUBLIC,
|
||||
PULL_REQUEST,
|
||||
PULL_REQUEST_REVIEW,
|
||||
PULL_REQUEST_REVIEW_COMMENT,
|
||||
PUSH,
|
||||
REGISTRY_PACKAGE,
|
||||
RELEASE,
|
||||
REPOSITORY, // only valid for org hooks
|
||||
REPOSITORY_DISPATCH, // only valid for org hooks
|
||||
REPOSITORY,
|
||||
REPOSITORY_IMPORT,
|
||||
REPOSITORY_VULNERABILITY_ALERT,
|
||||
SECURITY_ADVISORY,
|
||||
STAR,
|
||||
STATUS,
|
||||
TEAM,
|
||||
TEAM_ADD,
|
||||
WATCH,
|
||||
PING,
|
||||
WORKFLOW_DISPATCH,
|
||||
WORKFLOW_RUN,
|
||||
|
||||
/**
|
||||
* Special event type that means "every possible event"
|
||||
*/
|
||||
ALL;
|
||||
|
||||
|
||||
/**
|
||||
* Returns GitHub's internal representation of this event.
|
||||
*/
|
||||
String symbol() {
|
||||
if (this==ALL) return "*";
|
||||
if (this == ALL)
|
||||
return "*";
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Represents an event.
|
||||
*
|
||||
* @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;
|
||||
|
||||
@@ -30,76 +28,121 @@ public class GHEventInfo {
|
||||
/**
|
||||
* Inside the event JSON model, GitHub uses a slightly different format.
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||
"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, justification = "JSON API")
|
||||
@SuppressFBWarnings(
|
||||
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||
"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
|
||||
justification = "JSON API")
|
||||
public static class GHEventRepository {
|
||||
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||
private int id;
|
||||
private long id;
|
||||
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
|
||||
private String url; // repository API URL
|
||||
private String name; // owner/repo
|
||||
private String url; // repository API URL
|
||||
private String name; // owner/repo
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public GHEvent getType() {
|
||||
String t = type;
|
||||
if (t.endsWith("Event")) t=t.substring(0,t.length()-5);
|
||||
if (t.endsWith("Event"))
|
||||
t = t.substring(0, t.length() - 5);
|
||||
for (GHEvent e : GHEvent.values()) {
|
||||
if (e.name().replace("_","").equalsIgnoreCase(t))
|
||||
if (e.name().replace("_", "").equalsIgnoreCase(t))
|
||||
return e;
|
||||
}
|
||||
return null; // unknown event type
|
||||
return null; // unknown event type
|
||||
}
|
||||
|
||||
/*package*/ GHEventInfo wrapUp(GitHub root) {
|
||||
GHEventInfo wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets created at.
|
||||
*
|
||||
* @return the created at
|
||||
*/
|
||||
public Date getCreatedAt() {
|
||||
return GitHub.parseDate(created_at);
|
||||
return GitHubClient.parseDate(created_at);
|
||||
}
|
||||
|
||||
/**
|
||||
* Repository where the change was made.
|
||||
* Gets repository.
|
||||
*
|
||||
* @return Repository where the change was made.
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
|
||||
@SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
|
||||
justification = "The field comes from JSON deserialization")
|
||||
public GHRepository getRepository() throws IOException {
|
||||
return root.getRepository(repo.name);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
|
||||
|
||||
/**
|
||||
* Gets actor.
|
||||
*
|
||||
* @return the {@link GHUser} actor for this event.
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
|
||||
justification = "The field comes from JSON deserialization")
|
||||
public GHUser getActor() throws IOException {
|
||||
return root.getUser(actor.getLogin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick way to just get the actor of the login.
|
||||
* Gets actor login.
|
||||
*
|
||||
* @return the login of the actor.
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public String getActorLogin() throws IOException {
|
||||
return actor.getLogin();
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
|
||||
/**
|
||||
* Gets organization.
|
||||
*
|
||||
* @return the organization
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
|
||||
justification = "The field comes from JSON deserialization")
|
||||
public GHOrganization getOrganization() throws IOException {
|
||||
return (org==null || org.getLogin()==null) ? null : root.getOrganization(org.getLogin());
|
||||
return (org == null || org.getLogin() == null) ? null : root.getOrganization(org.getLogin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the payload.
|
||||
*
|
||||
*
|
||||
* @param <T>
|
||||
* the type parameter
|
||||
* @param type
|
||||
* Specify one of the {@link GHEventPayload} subtype that defines a type-safe access to the payload.
|
||||
* This must match the {@linkplain #getType() event type}.
|
||||
* Specify one of the {@link GHEventPayload} subtype that defines a type-safe access to the payload. This
|
||||
* must match the {@linkplain #getType() event type}.
|
||||
* @return parsed event payload
|
||||
* @throws IOException
|
||||
* if payload cannot be parsed
|
||||
*/
|
||||
public <T extends GHEventPayload> T getPayload(Class<T> type) throws IOException {
|
||||
T v = GitHub.MAPPER.readValue(payload.traverse(), type);
|
||||
T v = GitHubClient.getMappingObjectReader(root).readValue(payload.traverse(), type);
|
||||
v.wrapUp(root);
|
||||
return v;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,29 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
/**
|
||||
* The type GHException.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class GHException extends RuntimeException {
|
||||
/**
|
||||
* Instantiates a new Gh exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
public GHException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Gh exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @param cause
|
||||
* the cause
|
||||
*/
|
||||
public GHException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
|
||||
*
|
||||
* @author Kanstantsin Shautsou
|
||||
*/
|
||||
public class GHFileNotFoundException extends FileNotFoundException {
|
||||
protected Map<String, List<String>> responseHeaderFields;
|
||||
|
||||
/**
|
||||
* Instantiates a new Gh file not found exception.
|
||||
*/
|
||||
public GHFileNotFoundException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Gh file not found exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
public GHFileNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Gh file not found exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @param cause
|
||||
* the cause
|
||||
*/
|
||||
public GHFileNotFoundException(String message, Throwable cause) {
|
||||
super(message);
|
||||
this.initCause(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets response header fields.
|
||||
*
|
||||
* @return the response header fields
|
||||
*/
|
||||
@CheckForNull
|
||||
public Map<String, List<String>> getResponseHeaderFields() {
|
||||
return responseHeaderFields;
|
||||
}
|
||||
|
||||
GHFileNotFoundException withResponseHeaderFields(@Nonnull Map<String, List<String>> headerFields) {
|
||||
this.responseHeaderFields = headerFields;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -13,14 +15,14 @@ import java.util.Map.Entry;
|
||||
* Gist
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHUser#listGists()
|
||||
* @see GitHub#getGist(String)
|
||||
* @see GitHub#createGist()
|
||||
* @see GHUser#listGists() GHUser#listGists()
|
||||
* @see GitHub#getGist(String) GitHub#getGist(String)
|
||||
* @see GitHub#createGist() GitHub#createGist()
|
||||
* @see <a href="https://developer.github.com/v3/gists/">documentation</a>
|
||||
*/
|
||||
public class GHGist extends GHObject {
|
||||
/*package almost final*/ GHUser owner;
|
||||
/*package almost final*/ GitHub root;
|
||||
|
||||
final GHUser owner;
|
||||
|
||||
private String forks_url, commits_url, id, git_pull_url, git_push_url, html_url;
|
||||
|
||||
@@ -33,140 +35,242 @@ public class GHGist extends GHObject {
|
||||
|
||||
private String comments_url;
|
||||
|
||||
private Map<String,GHGistFile> files = new HashMap<String, GHGistFile>();
|
||||
private final Map<String, GHGistFile> files;
|
||||
|
||||
@JsonCreator
|
||||
private GHGist(@JacksonInject GitHub root,
|
||||
@JsonProperty("owner") GHUser owner,
|
||||
@JsonProperty("files") Map<String, GHGistFile> files) {
|
||||
this.root = root;
|
||||
for (Entry<String, GHGistFile> e : files.entrySet()) {
|
||||
e.getValue().fileName = e.getKey();
|
||||
}
|
||||
this.files = Collections.unmodifiableMap(files);
|
||||
this.owner = root.getUser(owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* User that owns this Gist.
|
||||
* 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.
|
||||
*/
|
||||
public GHUser getOwner() {
|
||||
@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.
|
||||
*
|
||||
* @return User that owns this Gist.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getOwner() throws IOException {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets forks url.
|
||||
*
|
||||
* @return the forks url
|
||||
*/
|
||||
public String getForksUrl() {
|
||||
return forks_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets commits url.
|
||||
*
|
||||
* @return the commits url
|
||||
*/
|
||||
public String getCommitsUrl() {
|
||||
return commits_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL like https://gist.github.com/gists/12345.git
|
||||
* Gets git pull url.
|
||||
*
|
||||
* @return URL like https://gist.github.com/gists/12345.git
|
||||
*/
|
||||
public String getGitPullUrl() {
|
||||
return git_pull_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets git push url.
|
||||
*
|
||||
* @return the git push url
|
||||
*/
|
||||
public String getGitPushUrl() {
|
||||
return git_push_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the html url.
|
||||
*
|
||||
* @return the github html url
|
||||
*/
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is public boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isPublic() {
|
||||
return _public;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets comment count.
|
||||
*
|
||||
* @return the comment count
|
||||
*/
|
||||
public int getCommentCount() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* API URL of listing comments.
|
||||
* Gets comments url.
|
||||
*
|
||||
* @return API URL of listing comments.
|
||||
*/
|
||||
public String getCommentsUrl() {
|
||||
return comments_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets file.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @return the file
|
||||
*/
|
||||
public GHGistFile getFile(String name) {
|
||||
return files.get(name);
|
||||
}
|
||||
|
||||
public Map<String,GHGistFile> getFiles() {
|
||||
return Collections.unmodifiableMap(files);
|
||||
/**
|
||||
* Gets files.
|
||||
*
|
||||
* @return the files
|
||||
*/
|
||||
public Map<String, GHGistFile> getFiles() {
|
||||
return files;
|
||||
}
|
||||
|
||||
/*package*/ GHGist wrapUp(GHUser owner) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
wrapUp();
|
||||
return this;
|
||||
String getApiTailUrl(String tail) {
|
||||
String result = "/gists/" + id;
|
||||
if (!StringUtils.isBlank(tail)) {
|
||||
result += StringUtils.prependIfMissing(tail, "/");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when caller obtains {@link GHGist} without knowing its owner.
|
||||
* A partially constructed owner object is interned.
|
||||
* Star.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
/*package*/ GHGist wrapUp(GitHub root) throws IOException {
|
||||
this.owner = root.getUser(owner);
|
||||
this.root = root;
|
||||
wrapUp();
|
||||
return this;
|
||||
}
|
||||
|
||||
private void wrapUp() {
|
||||
for (Entry<String, GHGistFile> e : files.entrySet()) {
|
||||
e.getValue().fileName = e.getKey();
|
||||
}
|
||||
}
|
||||
String getApiTailUrl(String tail) {
|
||||
return "/gists/" + id + '/' + tail;
|
||||
}
|
||||
|
||||
public void star() throws IOException {
|
||||
new Requester(root).method("PUT").to(getApiTailUrl("star"));
|
||||
root.createRequest().method("PUT").withUrlPath(getApiTailUrl("star")).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unstar.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void unstar() throws IOException {
|
||||
new Requester(root).method("DELETE").to(getApiTailUrl("star"));
|
||||
root.createRequest().method("DELETE").withUrlPath(getApiTailUrl("star")).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is starred boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public boolean isStarred() throws IOException {
|
||||
return root.retrieve().asHttpStatusCode(getApiTailUrl("star"))/100==2;
|
||||
return root.createRequest().withUrlPath(getApiTailUrl("star")).fetchHttpStatusCode() / 100 == 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forks this gist into your own.
|
||||
*
|
||||
* @return the gh gist
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGist fork() throws IOException {
|
||||
return new Requester(root).to(getApiTailUrl("forks"),GHGist.class).wrapUp(root);
|
||||
return root.createRequest().method("POST").withUrlPath(getApiTailUrl("forks")).fetch(GHGist.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* List forks paged iterable.
|
||||
*
|
||||
* @return the paged iterable
|
||||
*/
|
||||
public PagedIterable<GHGist> listForks() {
|
||||
return new PagedIterable<GHGist>() {
|
||||
public PagedIterator<GHGist> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHGist>(root.retrieve().asIterator(getApiTailUrl("forks"), GHGist[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHGist[] page) {
|
||||
try {
|
||||
for (GHGist c : page)
|
||||
c.wrapUp(root);
|
||||
} catch (IOException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return root.createRequest().withUrlPath(getApiTailUrl("forks")).toIterable(GHGist[].class, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes this gist.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
new Requester(root).method("DELETE").to("/gists/" + id);
|
||||
root.createRequest().method("DELETE").withUrlPath("/gists/" + id).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates this gist via a builder.
|
||||
*
|
||||
* @return the gh gist updater
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGistUpdater update() throws IOException {
|
||||
return new GHGistUpdater(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
GHGist ghGist = (GHGist) o;
|
||||
return id.equals(ghGist.id);
|
||||
|
||||
|
||||
@@ -4,45 +4,75 @@ import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Builder pattern for creating a new Gist.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GitHub#createGist()
|
||||
* @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>();
|
||||
private final LinkedHashMap<String, Object> files = new LinkedHashMap<String, Object>();
|
||||
|
||||
/**
|
||||
* Instantiates a new Gh gist builder.
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
*/
|
||||
public GHGistBuilder(GitHub root) {
|
||||
this.root = root;
|
||||
req = new Requester(root);
|
||||
req = root.createRequest().method("POST");
|
||||
}
|
||||
|
||||
/**
|
||||
* Description gh gist builder.
|
||||
*
|
||||
* @param desc
|
||||
* the desc
|
||||
* @return the gh gist builder
|
||||
*/
|
||||
public GHGistBuilder description(String desc) {
|
||||
req.with("description",desc);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GHGistBuilder public_(boolean v) {
|
||||
req.with("public",v);
|
||||
req.with("description", desc);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new file.
|
||||
* Public gh gist builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh gist builder
|
||||
*/
|
||||
public GHGistBuilder file(String fileName, String content) {
|
||||
public GHGistBuilder public_(boolean v) {
|
||||
req.with("public", v);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* File gh gist builder.
|
||||
*
|
||||
* @param fileName
|
||||
* the file name
|
||||
* @param content
|
||||
* the content
|
||||
* @return Adds a new file.
|
||||
*/
|
||||
public GHGistBuilder file(@Nonnull String fileName, @Nonnull String content) {
|
||||
files.put(fileName, Collections.singletonMap("content", content));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Gist based on the parameters specified thus far.
|
||||
*
|
||||
* @return created Gist
|
||||
* @throws IOException
|
||||
* if Gist cannot be created.
|
||||
*/
|
||||
public GHGist create() throws IOException {
|
||||
req._with("files",files);
|
||||
return req.to("/gists",GHGist.class).wrapUp(root);
|
||||
req.with("files", files);
|
||||
return req.withUrlPath("/gists").fetch(GHGist.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,23 +4,29 @@ package org.kohsuke.github;
|
||||
* A file inside {@link GHGist}
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHGist#getFile(String)
|
||||
* @see GHGist#getFiles()
|
||||
* @see GHGist#getFile(String) GHGist#getFile(String)
|
||||
* @see GHGist#getFiles() GHGist#getFiles()
|
||||
*/
|
||||
public class GHGistFile {
|
||||
/*package almost final*/ String fileName;
|
||||
/* package almost final */ String fileName;
|
||||
|
||||
private int size;
|
||||
private String raw_url, type, language, content;
|
||||
private boolean truncated;
|
||||
|
||||
|
||||
/**
|
||||
* Gets file name.
|
||||
*
|
||||
* @return the file name
|
||||
*/
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* File size in bytes.
|
||||
*
|
||||
* @return the size
|
||||
*/
|
||||
public int getSize() {
|
||||
return size;
|
||||
@@ -28,6 +34,8 @@ public class GHGistFile {
|
||||
|
||||
/**
|
||||
* URL that serves this file as-is.
|
||||
*
|
||||
* @return the raw url
|
||||
*/
|
||||
public String getRawUrl() {
|
||||
return raw_url;
|
||||
@@ -35,17 +43,26 @@ public class GHGistFile {
|
||||
|
||||
/**
|
||||
* Content type of this Gist, such as "text/plain"
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets language.
|
||||
*
|
||||
* @return the language
|
||||
*/
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Content of this file.
|
||||
*
|
||||
* @return the content
|
||||
*/
|
||||
public String getContent() {
|
||||
return content;
|
||||
@@ -53,6 +70,8 @@ public class GHGistFile {
|
||||
|
||||
/**
|
||||
* (?) indicates if {@link #getContent()} contains a truncated content.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isTruncated() {
|
||||
return truncated;
|
||||
|
||||
127
src/main/java/org/kohsuke/github/GHGistUpdater.java
Normal file
127
src/main/java/org/kohsuke/github/GHGistUpdater.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Builder pattern for updating a Gist.
|
||||
*
|
||||
* @author Martin van Zijl
|
||||
*/
|
||||
public class GHGistUpdater {
|
||||
private final GHGist base;
|
||||
private final Requester builder;
|
||||
LinkedHashMap<String, Map<String, String>> files;
|
||||
|
||||
GHGistUpdater(GHGist base) {
|
||||
this.base = base;
|
||||
this.builder = base.root.createRequest();
|
||||
|
||||
files = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add file gh gist updater.
|
||||
*
|
||||
* @param fileName
|
||||
* the file name
|
||||
* @param content
|
||||
* the content
|
||||
* @return the gh gist updater
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGistUpdater addFile(@Nonnull String fileName, @Nonnull String content) throws IOException {
|
||||
updateFile(fileName, content);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GHGistUpdater deleteFile(@Nonnull String fileName) throws IOException {
|
||||
files.put(fileName, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename file gh gist updater.
|
||||
*
|
||||
* @param fileName
|
||||
* the file name
|
||||
* @param newFileName
|
||||
* the new file name
|
||||
* @return the gh gist updater
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update file gh gist updater.
|
||||
*
|
||||
* @param fileName
|
||||
* the file name
|
||||
* @param content
|
||||
* the content
|
||||
* @return the gh gist updater
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description gh gist updater.
|
||||
*
|
||||
* @param desc
|
||||
* the desc
|
||||
* @return the gh gist updater
|
||||
*/
|
||||
public GHGistUpdater description(String desc) {
|
||||
builder.with("description", desc);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the Gist based on the parameters specified thus far.
|
||||
*
|
||||
* @return the gh gist
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGist update() throws IOException {
|
||||
builder.with("files", files);
|
||||
return builder.method("PATCH").withUrlPath(base.getApiTailUrl("")).fetch(GHGist.class);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
@@ -10,49 +11,80 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The type GHHook.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
|
||||
justification = "JSON API")
|
||||
public abstract class GHHook extends GHObject {
|
||||
String name;
|
||||
List<String> events;
|
||||
boolean active;
|
||||
Map<String,String> config;
|
||||
Map<String, String> config;
|
||||
|
||||
/**
|
||||
* Gets name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets events.
|
||||
*
|
||||
* @return the events
|
||||
*/
|
||||
public EnumSet<GHEvent> getEvents() {
|
||||
EnumSet<GHEvent> s = EnumSet.noneOf(GHEvent.class);
|
||||
for (String e : events) {
|
||||
if (e.equals("*")) s.add(GHEvent.ALL);
|
||||
else s.add(Enum.valueOf(GHEvent.class, e.toUpperCase(Locale.ENGLISH)));
|
||||
if (e.equals("*"))
|
||||
s.add(GHEvent.ALL);
|
||||
else
|
||||
s.add(Enum.valueOf(GHEvent.class, e.toUpperCase(Locale.ENGLISH)));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is active boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets config.
|
||||
*
|
||||
* @return the config
|
||||
*/
|
||||
public Map<String, String> getConfig() {
|
||||
return Collections.unmodifiableMap(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ping.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see <a href="https://developer.github.com/v3/repos/hooks/#ping-a-hook">Ping hook</a>
|
||||
*/
|
||||
public void ping() throws IOException {
|
||||
new Requester(getRoot()).method("POST").to(getApiRoute() + "/pings");
|
||||
getRoot().createRequest().method("POST").withUrlPath(getApiRoute() + "/pings").send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes this hook.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
new Requester(getRoot()).method("DELETE").to(getApiRoute());
|
||||
getRoot().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -13,41 +12,77 @@ 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;
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets hooks.
|
||||
*
|
||||
* @return the hooks
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHHook> getHooks() throws IOException {
|
||||
|
||||
GHHook [] hookArray = root.retrieve().to(collection(),collectionClass()); // jdk/eclipse bug requires this to be on separate line
|
||||
|
||||
GHHook[] hookArray = root.createRequest().withUrlPath(collection()).fetch(collectionClass()); // jdk/eclipse
|
||||
// bug
|
||||
// requires this
|
||||
// to be on separate line
|
||||
List<GHHook> list = new ArrayList<GHHook>(Arrays.asList(hookArray));
|
||||
for (GHHook h : list)
|
||||
wrap(h);
|
||||
wrap(h);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets hook.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @return the hook
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHHook getHook(int id) throws IOException {
|
||||
GHHook hook = root.retrieve().to(collection() + "/" + id, clazz());
|
||||
GHHook hook = root.createRequest().withUrlPath(collection() + "/" + id).fetch(clazz());
|
||||
return wrap(hook);
|
||||
}
|
||||
|
||||
public GHHook createHook(String name, Map<String, String> config, Collection<GHEvent> events, boolean active) throws IOException {
|
||||
/**
|
||||
* Create hook gh hook.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param config
|
||||
* the config
|
||||
* @param events
|
||||
* the events
|
||||
* @param active
|
||||
* the active
|
||||
* @return the gh hook
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHHook createHook(String name, Map<String, String> config, Collection<GHEvent> events, boolean active)
|
||||
throws IOException {
|
||||
List<String> ea = null;
|
||||
if (events!=null) {
|
||||
ea = new ArrayList<String>();
|
||||
for (GHEvent e : events)
|
||||
ea.add(e.symbol());
|
||||
if (events != null) {
|
||||
ea = new ArrayList<String>();
|
||||
for (GHEvent e : events)
|
||||
ea.add(e.symbol());
|
||||
}
|
||||
|
||||
GHHook hook = new Requester(root)
|
||||
.with("name", name)
|
||||
.with("active", active)
|
||||
._with("config", config)
|
||||
._with("events", ea)
|
||||
.to(collection(), clazz());
|
||||
GHHook hook = root.createRequest()
|
||||
.method("POST")
|
||||
.with("name", name)
|
||||
.with("active", active)
|
||||
.with("config", config)
|
||||
.with("events", ea)
|
||||
.withUrlPath(collection())
|
||||
.fetch(clazz());
|
||||
|
||||
return wrap(hook);
|
||||
}
|
||||
@@ -88,7 +123,7 @@ class GHHooks {
|
||||
|
||||
@Override
|
||||
GHHook wrap(GHHook hook) {
|
||||
return ((GHRepoHook)hook).wrap(repository);
|
||||
return ((GHRepoHook) hook).wrap(repository);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,15 +152,15 @@ class GHHooks {
|
||||
|
||||
@Override
|
||||
GHHook wrap(GHHook hook) {
|
||||
return ((GHOrgHook)hook).wrap(organization);
|
||||
return ((GHOrgHook) hook).wrap(organization);
|
||||
}
|
||||
}
|
||||
|
||||
static Context repoContext(GHRepository repository, GHUser owner) {
|
||||
return new RepoContext(repository, owner);
|
||||
}
|
||||
static Context repoContext(GHRepository repository, GHUser owner) {
|
||||
return new RepoContext(repository, owner);
|
||||
}
|
||||
|
||||
static Context orgContext(GHOrganization organization) {
|
||||
return new OrgContext(organization);
|
||||
}
|
||||
static Context orgContext(GHOrganization organization) {
|
||||
return new OrgContext(organization);
|
||||
}
|
||||
}
|
||||
|
||||
62
src/main/java/org/kohsuke/github/GHIOException.java
Normal file
62
src/main/java/org/kohsuke/github/GHIOException.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
|
||||
*
|
||||
* @author Kanstantsin Shautsou
|
||||
*/
|
||||
public class GHIOException extends IOException {
|
||||
protected Map<String, List<String>> responseHeaderFields;
|
||||
|
||||
/**
|
||||
* Instantiates a new Ghio exception.
|
||||
*/
|
||||
public GHIOException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Ghio exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
public GHIOException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code GHIOException} with the specified detail message and cause.
|
||||
*
|
||||
* @param message
|
||||
* The detail message (which is saved for later retrieval by the {@link #getMessage()} method)
|
||||
*
|
||||
* @param cause
|
||||
* The cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
|
||||
* permitted, and indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public GHIOException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets response header fields.
|
||||
*
|
||||
* @return the response header fields
|
||||
*/
|
||||
@CheckForNull
|
||||
public Map<String, List<String>> getResponseHeaderFields() {
|
||||
return responseHeaderFields;
|
||||
}
|
||||
|
||||
GHIOException withResponseHeaderFields(@Nonnull Map<String, List<String>> headerFields) {
|
||||
this.responseHeaderFields = headerFields;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
55
src/main/java/org/kohsuke/github/GHInvitation.java
Normal file
55
src/main/java/org/kohsuke/github/GHInvitation.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* The type GHInvitation.
|
||||
*
|
||||
* @see GitHub#getMyInvitations() GitHub#getMyInvitations()
|
||||
* @see GHRepository#listInvitations() GHRepository#listInvitations()
|
||||
*/
|
||||
@SuppressFBWarnings(
|
||||
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||
"UUF_UNUSED_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHInvitation extends GHObject {
|
||||
|
||||
private int id;
|
||||
private GHRepository repository;
|
||||
private GHUser invitee, inviter;
|
||||
private String permissions;
|
||||
private String html_url;
|
||||
|
||||
GHInvitation wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept a repository invitation.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void accept() throws IOException {
|
||||
root.createRequest().method("PATCH").withUrlPath("/user/repository_invitations/" + id).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Decline a repository invitation.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void decline() throws IOException {
|
||||
root.createRequest().method("DELETE").withUrlPath("/user/repository_invitations/" + id).send();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ package org.kohsuke.github;
|
||||
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
@@ -36,24 +37,26 @@ 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.*;
|
||||
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||
|
||||
/**
|
||||
* Represents an issue on GitHub.
|
||||
*
|
||||
* @author Eric Maupin
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHRepository#getIssue(int)
|
||||
* @see GitHub#searchIssues()
|
||||
* @see GHRepository#getIssue(int) GHRepository#getIssue(int)
|
||||
* @see GitHub#searchIssues() GitHub#searchIssues()
|
||||
* @see GHIssueSearchBuilder
|
||||
*/
|
||||
public class GHIssue extends GHObject implements Reactable{
|
||||
GitHub root;
|
||||
public class GHIssue extends GHObject implements Reactable {
|
||||
private static final String ASSIGNEES = "assignees";
|
||||
|
||||
GHRepository owner;
|
||||
|
||||
|
||||
// API v3
|
||||
protected GHUser assignee; // not sure what this field is now that 'assignees' exist
|
||||
protected GHUser assignee; // not sure what this field is now that 'assignees' exist
|
||||
protected GHUser[] assignees;
|
||||
protected String state;
|
||||
protected int number;
|
||||
@@ -61,43 +64,38 @@ public class GHIssue extends GHObject implements Reactable{
|
||||
protected int comments;
|
||||
@SkipFromToString
|
||||
protected String body;
|
||||
// for backward compatibility with < 1.63, this collection needs to hold instances of Label, not GHLabel
|
||||
protected List<Label> labels;
|
||||
protected List<GHLabel> labels;
|
||||
protected GHUser user;
|
||||
protected String title, html_url;
|
||||
protected GHIssue.PullRequest pull_request;
|
||||
protected GHMilestone milestone;
|
||||
protected GHUser closed_by;
|
||||
protected boolean locked;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link GHLabel}
|
||||
*/
|
||||
public static class Label extends GHLabel {
|
||||
}
|
||||
|
||||
/*package*/ GHIssue wrap(GHRepository owner) {
|
||||
GHIssue wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
if(milestone != null) milestone.wrap(owner);
|
||||
if (milestone != null)
|
||||
milestone.wrap(owner);
|
||||
return wrap(owner.root);
|
||||
}
|
||||
|
||||
/*package*/ GHIssue wrap(GitHub root) {
|
||||
GHIssue wrap(GitHub root) {
|
||||
this.root = root;
|
||||
if(assignee != null) assignee.wrapUp(root);
|
||||
if(assignees!=null) GHUser.wrap(assignees,root);
|
||||
if(user != null) user.wrapUp(root);
|
||||
if(closed_by != null) closed_by.wrapUp(root);
|
||||
if (assignee != null)
|
||||
assignee.wrapUp(root);
|
||||
if (assignees != null)
|
||||
GHUser.wrap(assignees, root);
|
||||
if (user != null)
|
||||
user.wrapUp(root);
|
||||
if (closed_by != null)
|
||||
closed_by.wrapUp(root);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*package*/ static GHIssue[] wrap(GHIssue[] issues, GHRepository owner) {
|
||||
for (GHIssue i : issues)
|
||||
i.wrap(owner);
|
||||
return issues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repository to which the issue belongs.
|
||||
*
|
||||
* @return the repository
|
||||
*/
|
||||
public GHRepository getRepository() {
|
||||
return owner;
|
||||
@@ -105,6 +103,8 @@ public class GHIssue extends GHObject implements Reactable{
|
||||
|
||||
/**
|
||||
* The description of this pull request.
|
||||
*
|
||||
* @return the body
|
||||
*/
|
||||
public String getBody() {
|
||||
return body;
|
||||
@@ -112,64 +112,138 @@ public class GHIssue extends GHObject implements Reactable{
|
||||
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @return the number
|
||||
*/
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The HTML page of this issue,
|
||||
* like https://github.com/jenkinsci/jenkins/issues/100
|
||||
* The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100
|
||||
*/
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets title.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is locked boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets state.
|
||||
*
|
||||
* @return the state
|
||||
*/
|
||||
public GHIssueState getState() {
|
||||
return Enum.valueOf(GHIssueState.class, state.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public Collection<GHLabel> getLabels() throws IOException {
|
||||
if(labels == null){
|
||||
/**
|
||||
* Gets labels.
|
||||
*
|
||||
* @return the labels
|
||||
*/
|
||||
public Collection<GHLabel> getLabels() {
|
||||
if (labels == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.<GHLabel>unmodifiableList(labels);
|
||||
return Collections.unmodifiableList(labels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets closed at.
|
||||
*
|
||||
* @return the closed at
|
||||
*/
|
||||
public Date getClosedAt() {
|
||||
return GitHub.parseDate(closed_at);
|
||||
return GitHubClient.parseDate(closed_at);
|
||||
}
|
||||
|
||||
public URL getApiURL(){
|
||||
return GitHub.parseURL(url);
|
||||
/**
|
||||
* Gets api url.
|
||||
*
|
||||
* @return API URL of this object.
|
||||
* @deprecated use {@link #getUrl()}
|
||||
*/
|
||||
@Deprecated
|
||||
public URL getApiURL() {
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void lock() throws IOException {
|
||||
root.createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void unlock() throws IOException {
|
||||
root.createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the issue by adding a comment.
|
||||
*
|
||||
* @return
|
||||
* Newly posted comment.
|
||||
* @param message
|
||||
* the message
|
||||
* @return Newly posted comment.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@WithBridgeMethods(void.class)
|
||||
public GHIssueComment comment(String message) throws IOException {
|
||||
GHIssueComment r = new Requester(root).with("body",message).to(getIssuesApiRoute() + "/comments", GHIssueComment.class);
|
||||
GHIssueComment r = root.createRequest()
|
||||
.method("POST")
|
||||
.with("body", message)
|
||||
.withUrlPath(getIssuesApiRoute() + "/comments")
|
||||
.fetch(GHIssueComment.class);
|
||||
return r.wrapUp(this);
|
||||
}
|
||||
|
||||
private void edit(String key, Object value) throws IOException {
|
||||
new Requester(root)._with(key, value).method("PATCH").to(getApiRoute());
|
||||
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Identical to edit(), but allows null for the value.
|
||||
*/
|
||||
private void editNullable(String key, Object value) throws IOException {
|
||||
root.createRequest().withNullable(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
|
||||
}
|
||||
|
||||
private void editIssue(String key, Object value) throws IOException {
|
||||
new Requester(root)._with(key, value).method("PATCH").to(getIssuesApiRoute());
|
||||
root.createRequest().withNullable(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes this issue.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
edit("state", "closed");
|
||||
@@ -177,182 +251,474 @@ public class GHIssue extends GHObject implements Reactable{
|
||||
|
||||
/**
|
||||
* Reopens this issue.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void reopen() throws IOException {
|
||||
edit("state", "open");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets title.
|
||||
*
|
||||
* @param title
|
||||
* the title
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setTitle(String title) throws IOException {
|
||||
edit("title",title);
|
||||
edit("title", title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets body.
|
||||
*
|
||||
* @param body
|
||||
* the body
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setBody(String body) throws IOException {
|
||||
edit("body",body);
|
||||
edit("body", body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the milestone for this issue.
|
||||
*
|
||||
* @param milestone
|
||||
* The milestone to assign this issue to. Use null to remove the milestone for this issue.
|
||||
* @throws IOException
|
||||
* The io exception
|
||||
*/
|
||||
public void setMilestone(GHMilestone milestone) throws IOException {
|
||||
if (milestone == null) {
|
||||
editIssue("milestone", null);
|
||||
} else {
|
||||
editIssue("milestone", milestone.getNumber());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign to.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void assignTo(GHUser user) throws IOException {
|
||||
setAssignees(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets labels.
|
||||
*
|
||||
* @param labels
|
||||
* the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setLabels(String... labels) throws IOException {
|
||||
editIssue("labels",labels);
|
||||
editIssue("labels", labels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds labels to the issue.
|
||||
*
|
||||
* @param names
|
||||
* Names of the label
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void addLabels(String... names) throws IOException {
|
||||
_addLabels(Arrays.asList(names));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add labels.
|
||||
*
|
||||
* @param labels
|
||||
* the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void addLabels(GHLabel... labels) throws IOException {
|
||||
addLabels(Arrays.asList(labels));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add labels.
|
||||
*
|
||||
* @param labels
|
||||
* the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void addLabels(Collection<GHLabel> labels) throws IOException {
|
||||
_addLabels(GHLabel.toNames(labels));
|
||||
}
|
||||
|
||||
private void _addLabels(Collection<String> names) throws IOException {
|
||||
List<String> newLabels = new ArrayList<String>();
|
||||
|
||||
for (GHLabel label : getLabels()) {
|
||||
newLabels.add(label.getName());
|
||||
}
|
||||
for (String name : names) {
|
||||
if (!newLabels.contains(name)) {
|
||||
newLabels.add(name);
|
||||
}
|
||||
}
|
||||
setLabels(newLabels.toArray(new String[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a given label by name from this issue.
|
||||
*
|
||||
* @param names
|
||||
* the names
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void removeLabels(String... names) throws IOException {
|
||||
_removeLabels(Arrays.asList(names));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove labels.
|
||||
*
|
||||
* @param labels
|
||||
* the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see #removeLabels(String...) #removeLabels(String...)
|
||||
*/
|
||||
public void removeLabels(GHLabel... labels) throws IOException {
|
||||
removeLabels(Arrays.asList(labels));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove labels.
|
||||
*
|
||||
* @param labels
|
||||
* the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void removeLabels(Collection<GHLabel> labels) throws IOException {
|
||||
_removeLabels(GHLabel.toNames(labels));
|
||||
}
|
||||
|
||||
private void _removeLabels(Collection<String> names) throws IOException {
|
||||
List<String> newLabels = new ArrayList<String>();
|
||||
|
||||
for (GHLabel l : getLabels()) {
|
||||
if (!names.contains(l.getName())) {
|
||||
newLabels.add(l.getName());
|
||||
}
|
||||
}
|
||||
|
||||
setLabels(newLabels.toArray(new String[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains all the comments associated with this issue.
|
||||
*
|
||||
* @see #listComments()
|
||||
*
|
||||
* @return the comments
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see #listComments() #listComments()
|
||||
*/
|
||||
public List<GHIssueComment> getComments() throws IOException {
|
||||
return listComments().asList();
|
||||
return listComments().toList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains all the comments associated with this issue.
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHIssueComment> listComments() throws IOException {
|
||||
return new PagedIterable<GHIssueComment>() {
|
||||
public PagedIterator<GHIssueComment> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHIssueComment>(root.retrieve().asIterator(getIssuesApiRoute() + "/comments", GHIssueComment[].class, pageSize)) {
|
||||
protected void wrapUp(GHIssueComment[] page) {
|
||||
for (GHIssueComment c : page)
|
||||
c.wrapUp(GHIssue.this);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return root.createRequest()
|
||||
.withUrlPath(getIssuesApiRoute() + "/comments")
|
||||
.toIterable(GHIssueComment[].class, item -> item.wrapUp(this));
|
||||
}
|
||||
|
||||
@Preview @Deprecated
|
||||
@Preview(SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public GHReaction createReaction(ReactionContent content) throws IOException {
|
||||
return new Requester(owner.root)
|
||||
return root.createRequest()
|
||||
.method("POST")
|
||||
.withPreview(SQUIRREL_GIRL)
|
||||
.with("content", content.getContent())
|
||||
.to(getApiRoute()+"/reactions", GHReaction.class).wrap(root);
|
||||
.withUrlPath(getApiRoute() + "/reactions")
|
||||
.fetch(GHReaction.class)
|
||||
.wrap(root);
|
||||
}
|
||||
|
||||
@Preview @Deprecated
|
||||
@Preview(SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public PagedIterable<GHReaction> listReactions() {
|
||||
return new PagedIterable<GHReaction>() {
|
||||
public PagedIterator<GHReaction> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHReaction>(owner.root.retrieve().withPreview(SQUIRREL_GIRL).asIterator(getApiRoute()+"/reactions", GHReaction[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHReaction[] page) {
|
||||
for (GHReaction c : page)
|
||||
c.wrap(owner.root);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return root.createRequest()
|
||||
.withPreview(SQUIRREL_GIRL)
|
||||
.withUrlPath(getApiRoute() + "/reactions")
|
||||
.toIterable(GHReaction[].class, item -> item.wrap(root));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void addAssignees(GHUser... assignees) throws IOException {
|
||||
addAssignees(Arrays.asList(assignees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void addAssignees(Collection<GHUser> assignees) throws IOException {
|
||||
List<String> names = toLogins(assignees);
|
||||
root.retrieve().method("POST").with("assignees",names).to(getIssuesApiRoute()+"/assignees",this);
|
||||
root.createRequest()
|
||||
.method("POST")
|
||||
.with(ASSIGNEES, getLogins(assignees))
|
||||
.withUrlPath(getIssuesApiRoute() + "/assignees")
|
||||
.fetchInto(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setAssignees(GHUser... assignees) throws IOException {
|
||||
setAssignees(Arrays.asList(assignees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setAssignees(Collection<GHUser> assignees) throws IOException {
|
||||
editIssue("assignees",toLogins(assignees));
|
||||
root.createRequest()
|
||||
.method("PATCH")
|
||||
.with(ASSIGNEES, getLogins(assignees))
|
||||
.withUrlPath(getIssuesApiRoute())
|
||||
.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void removeAssignees(GHUser... assignees) throws IOException {
|
||||
removeAssignees(Arrays.asList(assignees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void removeAssignees(Collection<GHUser> assignees) throws IOException {
|
||||
List<String> names = toLogins(assignees);
|
||||
root.retrieve().method("DELETE").with("assignees",names).inBody().to(getIssuesApiRoute()+"/assignees",this);
|
||||
}
|
||||
|
||||
private List<String> toLogins(Collection<GHUser> assignees) {
|
||||
List<String> names = new ArrayList<String>(assignees.size());
|
||||
for (GHUser a : assignees) {
|
||||
names.add(a.getLogin());
|
||||
}
|
||||
return names;
|
||||
root.createRequest()
|
||||
.method("DELETE")
|
||||
.with(ASSIGNEES, getLogins(assignees))
|
||||
.inBody()
|
||||
.withUrlPath(getIssuesApiRoute() + "/assignees")
|
||||
.fetchInto(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets api route.
|
||||
*
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return getIssuesApiRoute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets issues api route.
|
||||
*
|
||||
* @return the issues api route
|
||||
*/
|
||||
protected String getIssuesApiRoute() {
|
||||
return "/repos/"+owner.getOwnerName()+"/"+owner.getName()+"/issues/"+number;
|
||||
if (owner == null) {
|
||||
// Issues returned from search to do not have an owner. Attempt to use url.
|
||||
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
|
||||
return StringUtils.prependIfMissing(url.toString().replace(root.getApiUrl(), ""), "/");
|
||||
}
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number;
|
||||
}
|
||||
|
||||
public GHUser getAssignee() {
|
||||
return assignee;
|
||||
/**
|
||||
* Gets assignee.
|
||||
*
|
||||
* @return the assignee
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getAssignee() throws IOException {
|
||||
return root.intern(assignee);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets assignees.
|
||||
*
|
||||
* @return the assignees
|
||||
*/
|
||||
public List<GHUser> getAssignees() {
|
||||
return Collections.unmodifiableList(Arrays.asList(assignees));
|
||||
}
|
||||
|
||||
/**
|
||||
* User who submitted the issue.
|
||||
*
|
||||
* @return the user
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getUser() {
|
||||
return user;
|
||||
public GHUser getUser() throws IOException {
|
||||
return root.intern(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports who has closed the issue.
|
||||
*
|
||||
* <p>
|
||||
* Note that GitHub doesn't always seem to report this information
|
||||
* even for an issue that's already closed. See
|
||||
* Note that GitHub doesn't always seem to report this information even for an issue that's already closed. See
|
||||
* https://github.com/kohsuke/github-api/issues/60.
|
||||
*
|
||||
* @return the closed by
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getClosedBy() {
|
||||
if(!"closed".equals(state)) return null;
|
||||
if(closed_by != null) return closed_by;
|
||||
|
||||
//TODO closed_by = owner.getIssue(number).getClosed_by();
|
||||
return closed_by;
|
||||
public GHUser getClosedBy() throws IOException {
|
||||
if (!"closed".equals(state))
|
||||
return null;
|
||||
|
||||
// TODO
|
||||
/*
|
||||
* if (closed_by==null) { closed_by = owner.getIssue(number).getClosed_by(); }
|
||||
*/
|
||||
return root.intern(closed_by);
|
||||
}
|
||||
|
||||
public int getCommentsCount(){
|
||||
|
||||
/**
|
||||
* Gets comments count.
|
||||
*
|
||||
* @return the comments count
|
||||
*/
|
||||
public int getCommentsCount() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-null if this issue is a shadow of a pull request.
|
||||
*
|
||||
* @return the pull request
|
||||
*/
|
||||
public PullRequest getPullRequest() {
|
||||
return pull_request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is pull request boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isPullRequest() {
|
||||
return pull_request!=null;
|
||||
return pull_request != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets milestone.
|
||||
*
|
||||
* @return the milestone
|
||||
*/
|
||||
public GHMilestone getMilestone() {
|
||||
return milestone;
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD"},
|
||||
justification = "JSON API")
|
||||
public static class PullRequest{
|
||||
/**
|
||||
* The type PullRequest.
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" },
|
||||
justification = "JSON API")
|
||||
public static class PullRequest {
|
||||
private String diff_url, patch_url, html_url;
|
||||
|
||||
|
||||
/**
|
||||
* Gets diff url.
|
||||
*
|
||||
* @return the diff url
|
||||
*/
|
||||
public URL getDiffUrl() {
|
||||
return GitHub.parseURL(diff_url);
|
||||
return GitHubClient.parseURL(diff_url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets patch url.
|
||||
*
|
||||
* @return the patch url
|
||||
*/
|
||||
public URL getPatchUrl() {
|
||||
return GitHub.parseURL(patch_url);
|
||||
return GitHubClient.parseURL(patch_url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
}
|
||||
|
||||
protected static List<String> getLogins(Collection<GHUser> users) {
|
||||
List<String> names = new ArrayList<String>(users.size());
|
||||
for (GHUser a : users) {
|
||||
names.add(a.getLogin());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists events for this issue. See https://developer.github.com/v3/issues/events/
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHIssueEvent> listEvents() throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(owner.getApiTailUrl(String.format("/issues/%s/events", number)))
|
||||
.toIterable(GHIssueEvent[].class, item -> item.wrapUp(this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type GHIssueBuilder.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class GHIssueBuilder {
|
||||
@@ -15,46 +17,86 @@ public class GHIssueBuilder {
|
||||
|
||||
GHIssueBuilder(GHRepository repo, String title) {
|
||||
this.repo = repo;
|
||||
this.builder = new Requester(repo.root);
|
||||
builder.with("title",title);
|
||||
this.builder = repo.root.createRequest().method("POST");
|
||||
builder.with("title", title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the main text of an issue, which is arbitrary multi-line text.
|
||||
*
|
||||
* @param str
|
||||
* the str
|
||||
* @return the gh issue builder
|
||||
*/
|
||||
public GHIssueBuilder body(String str) {
|
||||
builder.with("body",str);
|
||||
builder.with("body", str);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignee gh issue builder.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return the gh issue builder
|
||||
*/
|
||||
public GHIssueBuilder assignee(GHUser user) {
|
||||
if (user!=null)
|
||||
if (user != null)
|
||||
assignees.add(user.getLogin());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignee gh issue builder.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return the gh issue builder
|
||||
*/
|
||||
public GHIssueBuilder assignee(String user) {
|
||||
if (user!=null)
|
||||
if (user != null)
|
||||
assignees.add(user);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Milestone gh issue builder.
|
||||
*
|
||||
* @param milestone
|
||||
* the milestone
|
||||
* @return the gh issue builder
|
||||
*/
|
||||
public GHIssueBuilder milestone(GHMilestone milestone) {
|
||||
if (milestone!=null)
|
||||
builder.with("milestone",milestone.getNumber());
|
||||
if (milestone != null)
|
||||
builder.with("milestone", milestone.getNumber());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Label gh issue builder.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @return the gh issue builder
|
||||
*/
|
||||
public GHIssueBuilder label(String label) {
|
||||
if (label!=null)
|
||||
if (label != null)
|
||||
labels.add(label);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new issue.
|
||||
*
|
||||
* @return the gh issue
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHIssue create() throws IOException {
|
||||
return builder.with("labels",labels).with("assignees",assignees).to(repo.getApiTailUrl("issues"),GHIssue.class).wrap(repo);
|
||||
return builder.with("labels", labels)
|
||||
.with("assignees", assignees)
|
||||
.withUrlPath(repo.getApiTailUrl("issues"))
|
||||
.fetch(GHIssue.class)
|
||||
.wrap(repo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,26 +26,30 @@ package org.kohsuke.github;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
|
||||
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||
|
||||
/**
|
||||
* Comment to the issue
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHIssue#comment(String) GHIssue#comment(String)
|
||||
* @see GHIssue#listComments() GHIssue#listComments()
|
||||
*/
|
||||
public class GHIssueComment extends GHObject implements Reactable {
|
||||
GHIssue owner;
|
||||
|
||||
private String body, gravatar_id;
|
||||
private String body, gravatar_id, html_url, author_association;
|
||||
private GHUser user; // not fully populated. beware.
|
||||
|
||||
/*package*/ GHIssueComment wrapUp(GHIssue owner) {
|
||||
GHIssueComment wrapUp(GHIssue owner) {
|
||||
this.owner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the issue to which this comment is associated.
|
||||
*
|
||||
* @return the parent
|
||||
*/
|
||||
public GHIssue getParent() {
|
||||
return owner;
|
||||
@@ -53,6 +57,8 @@ public class GHIssueComment extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* The comment itself.
|
||||
*
|
||||
* @return the body
|
||||
*/
|
||||
public String getBody() {
|
||||
return body;
|
||||
@@ -60,6 +66,8 @@ public class GHIssueComment extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* Gets the ID of the user who posted this comment.
|
||||
*
|
||||
* @return the user name
|
||||
*/
|
||||
@Deprecated
|
||||
public String getUserName() {
|
||||
@@ -68,58 +76,79 @@ public class GHIssueComment extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* Gets the user who posted this comment.
|
||||
*
|
||||
* @return the user
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getUser() throws IOException {
|
||||
return owner == null || owner.root.isOffline() ? user : owner.root.getUser(user.getLogin());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This object has no HTML URL.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return null;
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets author association.
|
||||
*
|
||||
* @return the author association
|
||||
*/
|
||||
public GHCommentAuthorAssociation getAuthorAssociation() {
|
||||
return GHCommentAuthorAssociation.valueOf(author_association);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the body of the issue comment.
|
||||
*
|
||||
* @param body
|
||||
* the body
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void update(String body) throws IOException {
|
||||
new Requester(owner.root).with("body", body).method("PATCH").to(getApiRoute(), GHIssueComment.class);
|
||||
owner.root.createRequest()
|
||||
.method("PATCH")
|
||||
.with("body", body)
|
||||
.withUrlPath(getApiRoute())
|
||||
.fetch(GHIssueComment.class);
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes this issue comment.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
new Requester(owner.root).method("DELETE").to(getApiRoute());
|
||||
owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
|
||||
}
|
||||
|
||||
@Preview @Deprecated
|
||||
@Preview(SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public GHReaction createReaction(ReactionContent content) throws IOException {
|
||||
return new Requester(owner.root)
|
||||
return owner.root.createRequest()
|
||||
.method("POST")
|
||||
.withPreview(SQUIRREL_GIRL)
|
||||
.with("content", content.getContent())
|
||||
.to(getApiRoute()+"/reactions", GHReaction.class).wrap(owner.root);
|
||||
.withUrlPath(getApiRoute() + "/reactions")
|
||||
.fetch(GHReaction.class)
|
||||
.wrap(owner.root);
|
||||
}
|
||||
|
||||
@Preview @Deprecated
|
||||
@Preview(SQUIRREL_GIRL)
|
||||
@Deprecated
|
||||
public PagedIterable<GHReaction> listReactions() {
|
||||
return new PagedIterable<GHReaction>() {
|
||||
public PagedIterator<GHReaction> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHReaction>(owner.root.retrieve().withPreview(SQUIRREL_GIRL).asIterator(getApiRoute()+"/reactions", GHReaction[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHReaction[] page) {
|
||||
for (GHReaction c : page)
|
||||
c.wrap(owner.root);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return owner.root.createRequest()
|
||||
.withPreview(SQUIRREL_GIRL)
|
||||
.withUrlPath(getApiRoute() + "/reactions")
|
||||
.toIterable(GHReaction[].class, item -> item.wrap(owner.root));
|
||||
}
|
||||
|
||||
private String getApiRoute() {
|
||||
return "/repos/"+owner.getRepository().getOwnerName()+"/"+owner.getRepository().getName()+"/issues/comments/" + id;
|
||||
return "/repos/" + owner.getRepository().getOwnerName() + "/" + owner.getRepository().getName()
|
||||
+ "/issues/comments/" + getId();
|
||||
}
|
||||
}
|
||||
|
||||
166
src/main/java/org/kohsuke/github/GHIssueEvent.java
Normal file
166
src/main/java/org/kohsuke/github/GHIssueEvent.java
Normal file
@@ -0,0 +1,166 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
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 extends GitHubInteractiveObject {
|
||||
private long id;
|
||||
private String node_id;
|
||||
private String url;
|
||||
private GHUser actor;
|
||||
private String event;
|
||||
private String commit_id;
|
||||
private String commit_url;
|
||||
private String created_at;
|
||||
private GHMilestone milestone;
|
||||
private GHLabel label;
|
||||
private GHUser assignee;
|
||||
|
||||
private GHIssue issue;
|
||||
|
||||
/**
|
||||
* Gets id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets node id.
|
||||
*
|
||||
* @return the node id
|
||||
*/
|
||||
public String getNodeId() {
|
||||
return node_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets actor.
|
||||
*
|
||||
* @return the actor
|
||||
*/
|
||||
public GHUser getActor() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets event.
|
||||
*
|
||||
* @return the event
|
||||
*/
|
||||
public String getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets commit id.
|
||||
*
|
||||
* @return the commit id
|
||||
*/
|
||||
public String getCommitId() {
|
||||
return commit_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets commit url.
|
||||
*
|
||||
* @return the commit url
|
||||
*/
|
||||
public String getCommitUrl() {
|
||||
return commit_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets created at.
|
||||
*
|
||||
* @return the created at
|
||||
*/
|
||||
public Date getCreatedAt() {
|
||||
return GitHubClient.parseDate(created_at);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets root.
|
||||
*
|
||||
* @return the root
|
||||
*/
|
||||
public GitHub getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets issue.
|
||||
*
|
||||
* @return the issue
|
||||
*/
|
||||
public GHIssue getIssue() {
|
||||
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;
|
||||
}
|
||||
|
||||
GHIssueEvent wrapUp(GHIssue parent) {
|
||||
this.issue = parent;
|
||||
this.root = parent.root;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Issue %d was %s by %s on %s",
|
||||
getIssue().getNumber(),
|
||||
getEvent(),
|
||||
getActor().getLogin(),
|
||||
getCreatedAt().toString());
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Search issues.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GitHub#searchIssues()
|
||||
* @see GitHub#searchIssues() GitHub#searchIssues()
|
||||
*/
|
||||
public class GHIssueSearchBuilder extends GHSearchBuilder<GHIssue> {
|
||||
/*package*/ GHIssueSearchBuilder(GitHub root) {
|
||||
super(root,IssueSearchResult.class);
|
||||
GHIssueSearchBuilder(GitHub root) {
|
||||
super(root, IssueSearchResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,43 +19,91 @@ public class GHIssueSearchBuilder extends GHSearchBuilder<GHIssue> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mentions gh issue search builder.
|
||||
*
|
||||
* @param u
|
||||
* the u
|
||||
* @return the gh issue search builder
|
||||
*/
|
||||
public GHIssueSearchBuilder mentions(GHUser u) {
|
||||
return mentions(u.getLogin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Mentions gh issue search builder.
|
||||
*
|
||||
* @param login
|
||||
* the login
|
||||
* @return the gh issue search builder
|
||||
*/
|
||||
public GHIssueSearchBuilder mentions(String login) {
|
||||
return q("mentions:"+login);
|
||||
return q("mentions:" + login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is open gh issue search builder.
|
||||
*
|
||||
* @return the gh issue search builder
|
||||
*/
|
||||
public GHIssueSearchBuilder isOpen() {
|
||||
return q("is:open");
|
||||
}
|
||||
|
||||
/**
|
||||
* Is closed gh issue search builder.
|
||||
*
|
||||
* @return the gh issue search builder
|
||||
*/
|
||||
public GHIssueSearchBuilder isClosed() {
|
||||
return q("is:closed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Is merged gh issue search builder.
|
||||
*
|
||||
* @return the gh issue search builder
|
||||
*/
|
||||
public GHIssueSearchBuilder isMerged() {
|
||||
return q("is:merged");
|
||||
}
|
||||
|
||||
/**
|
||||
* Order gh issue search builder.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh issue search builder
|
||||
*/
|
||||
public GHIssueSearchBuilder order(GHDirection v) {
|
||||
req.with("order",v);
|
||||
req.with("order", v);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort gh issue search builder.
|
||||
*
|
||||
* @param sort
|
||||
* the sort
|
||||
* @return the gh issue search builder
|
||||
*/
|
||||
public GHIssueSearchBuilder sort(Sort sort) {
|
||||
req.with("sort",sort);
|
||||
req.with("sort", sort);
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum Sort { COMMENTS, CREATED, UPDATED }
|
||||
/**
|
||||
* The enum Sort.
|
||||
*/
|
||||
public enum Sort {
|
||||
COMMENTS, CREATED, UPDATED
|
||||
}
|
||||
|
||||
private static class IssueSearchResult extends SearchResult<GHIssue> {
|
||||
private GHIssue[] items;
|
||||
|
||||
@Override
|
||||
/*package*/ GHIssue[] getItems(GitHub root) {
|
||||
GHIssue[] getItems(GitHub root) {
|
||||
for (GHIssue i : items)
|
||||
i.wrap(root);
|
||||
return items;
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
/**
|
||||
* @see GHPullRequestQueryBuilder#state(GHIssueState)
|
||||
* The enum GHIssueState.
|
||||
*
|
||||
* @see GHPullRequestQueryBuilder#state(GHIssueState) GHPullRequestQueryBuilder#state(GHIssueState)
|
||||
*/
|
||||
public enum GHIssueState {
|
||||
OPEN,
|
||||
CLOSED,
|
||||
ALL
|
||||
}
|
||||
OPEN, CLOSED, ALL
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
/**
|
||||
* SSH public key.
|
||||
@@ -9,46 +9,71 @@ import org.apache.commons.lang.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;
|
||||
|
||||
/**
|
||||
* Gets id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets key.
|
||||
*
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets title.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Something like "https://api.github.com/user/keys/73593"
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets root.
|
||||
*
|
||||
* @return the root
|
||||
*/
|
||||
public GitHub getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is verified boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isVerified() {
|
||||
return verified;
|
||||
}
|
||||
|
||||
/*package*/ GHKey wrap(GitHub root) {
|
||||
GHKey wrap(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this).append("title",title).append("id",id).append("key",key).toString();
|
||||
return new ToStringBuilder(this).append("title", title).append("id", id).append("key", key).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,264 @@
|
||||
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 GHIssue#getLabels()
|
||||
* @see GHRepository#listLabels()
|
||||
* @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;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
@Nonnull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Color code without leading '#', such as 'f29513'
|
||||
*
|
||||
* @return the color
|
||||
*/
|
||||
@Nonnull
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/*package*/ GHLabel wrapUp(GHRepository repo) {
|
||||
this.repo = repo;
|
||||
return this;
|
||||
/**
|
||||
* Purpose of Label
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
@CheckForNull
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void delete() throws IOException {
|
||||
repo.root.retrieve().method("DELETE").to(url);
|
||||
/**
|
||||
* Sets color.
|
||||
*
|
||||
* @param newColor
|
||||
* 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 {
|
||||
set().color(newColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets description.
|
||||
*
|
||||
* @param newDescription
|
||||
* Description of label
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated use {@link #set()} or {@link #update()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setDescription(String newDescription) throws IOException {
|
||||
set().description(newDescription);
|
||||
}
|
||||
|
||||
static Collection<String> toNames(Collection<GHLabel> labels) {
|
||||
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)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
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(description, ghLabel.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
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,33 +24,26 @@
|
||||
|
||||
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 static org.kohsuke.github.Previews.DRAX;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The GitHub Preview API's license information
|
||||
* <p>
|
||||
* WARNING: This uses a PREVIEW API - subject to change.
|
||||
*
|
||||
* @author Duncan Dickinson
|
||||
* @see GitHub#getLicense(String)
|
||||
* @see GHRepository#getLicense()
|
||||
* @see GitHub#getLicense(String) GitHub#getLicense(String)
|
||||
* @see GHRepository#getLicense() GHRepository#getLicense()
|
||||
* @see <a href="https://developer.github.com/v3/licenses/">https://developer.github.com/v3/licenses/</a>
|
||||
*/
|
||||
@Preview @Deprecated
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||
@SuppressWarnings({ "UnusedDeclaration" })
|
||||
@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;
|
||||
@@ -65,6 +58,8 @@ public class GHLicense extends GHObject {
|
||||
protected List<String> forbidden = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Gets key.
|
||||
*
|
||||
* @return a mnemonic for the license
|
||||
*/
|
||||
public String getKey() {
|
||||
@@ -72,24 +67,20 @@ public class GHLicense extends GHObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name.
|
||||
*
|
||||
* @return the license name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return API URL of this object.
|
||||
*/
|
||||
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Featured licenses are bold in the new repository drop-down
|
||||
*
|
||||
* @return True if the license is featured, false otherwise
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public Boolean isFeatured() throws IOException {
|
||||
populate();
|
||||
@@ -98,39 +89,88 @@ public class GHLicense extends GHObject {
|
||||
|
||||
public URL getHtmlUrl() throws IOException {
|
||||
populate();
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets description.
|
||||
*
|
||||
* @return the description
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public String getDescription() throws IOException {
|
||||
populate();
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets category.
|
||||
*
|
||||
* @return the category
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public String getCategory() throws IOException {
|
||||
populate();
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets implementation.
|
||||
*
|
||||
* @return the implementation
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public String getImplementation() throws IOException {
|
||||
populate();
|
||||
return implementation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets required.
|
||||
*
|
||||
* @return the required
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<String> getRequired() throws IOException {
|
||||
populate();
|
||||
return required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets permitted.
|
||||
*
|
||||
* @return the permitted
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<String> getPermitted() throws IOException {
|
||||
populate();
|
||||
return permitted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets forbidden.
|
||||
*
|
||||
* @return the forbidden
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<String> getForbidden() throws IOException {
|
||||
populate();
|
||||
return forbidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets body.
|
||||
*
|
||||
* @return the body
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public String getBody() throws IOException {
|
||||
populate();
|
||||
return body;
|
||||
@@ -138,30 +178,43 @@ public class GHLicense extends GHObject {
|
||||
|
||||
/**
|
||||
* Fully populate the data by retrieving missing data.
|
||||
*
|
||||
* <p>
|
||||
* Depending on the original API call where this object is created, it may not contain everything.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
protected synchronized void populate() throws IOException {
|
||||
if (description!=null) return; // already populated
|
||||
if (description != null)
|
||||
return; // already populated
|
||||
|
||||
root.retrieve().withPreview(DRAX).to(url, this);
|
||||
if (root == null || root.isOffline()) {
|
||||
return; // cannot populate, will have to live with what we have
|
||||
}
|
||||
|
||||
URL url = getUrl();
|
||||
if (url != null) {
|
||||
root.createRequest().setRawUrlPath(url.toString()).fetchInto(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof GHLicense)) return false;
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof GHLicense))
|
||||
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());
|
||||
}
|
||||
|
||||
/*package*/ GHLicense wrap(GitHub root) {
|
||||
GHLicense wrap(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
|
||||
86
src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
Normal file
86
src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Base class for Github Marketplace Account.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GitHub#getMyMarketplacePurchases()
|
||||
* @see GHMarketplaceListAccountBuilder#createRequest()
|
||||
*/
|
||||
public class GHMarketplaceAccount extends GitHubInteractiveObject {
|
||||
private String url;
|
||||
private long id;
|
||||
private String login;
|
||||
private String email;
|
||||
private String organizationBillingEmail;
|
||||
private GHMarketplaceAccountType type;
|
||||
|
||||
/**
|
||||
* Wrap up gh marketplace account.
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
* @return an instance of the GHMarketplaceAccount class
|
||||
*/
|
||||
GHMarketplaceAccount wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets login.
|
||||
*
|
||||
* @return the login
|
||||
*/
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets email.
|
||||
*
|
||||
* @return the email
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets organization billing email.
|
||||
*
|
||||
* @return the organization billing email
|
||||
*/
|
||||
public String getOrganizationBillingEmail() {
|
||||
return organizationBillingEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public GHMarketplaceAccountType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
/**
|
||||
* A Github Marketplace Account Plan.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GHMarketplaceListAccountBuilder#createRequest()
|
||||
*/
|
||||
public class GHMarketplaceAccountPlan extends GHMarketplaceAccount {
|
||||
|
||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||
private GHMarketplacePendingChange marketplacePendingChange;
|
||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||
private GHMarketplacePurchase marketplacePurchase;
|
||||
|
||||
/**
|
||||
* Wrap up gh marketplace account.
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
* @return an instance of the GHMarketplaceAccount class
|
||||
*/
|
||||
GHMarketplaceAccountPlan wrapUp(GitHub root) {
|
||||
super.wrapUp(root);
|
||||
if (this.marketplacePendingChange != null)
|
||||
this.marketplacePendingChange.wrapUp(this.root);
|
||||
|
||||
if (this.marketplacePurchase != null)
|
||||
this.marketplacePurchase.wrapUp(this.root);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets marketplace pending change.
|
||||
*
|
||||
* @return the marketplace pending change
|
||||
*/
|
||||
public GHMarketplacePendingChange getMarketplacePendingChange() {
|
||||
return marketplacePendingChange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets marketplace purchase.
|
||||
*
|
||||
* @return the marketplace purchase
|
||||
*/
|
||||
public GHMarketplacePurchase getMarketplacePurchase() {
|
||||
return marketplacePurchase;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* GitHub Marketplace Account type.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GHMarketplaceAccount
|
||||
*/
|
||||
public enum GHMarketplaceAccountType {
|
||||
ORGANIZATION, USER;
|
||||
|
||||
/**
|
||||
* Returns GitHub's internal representation of this event.
|
||||
*/
|
||||
String symbol() {
|
||||
return StringUtils.capitalize(name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Returns any accounts associated with a plan, including free plans
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GHMarketplacePlan#listAccounts()
|
||||
*/
|
||||
public class GHMarketplaceListAccountBuilder extends GitHubInteractiveObject {
|
||||
private final Requester builder;
|
||||
private final long planId;
|
||||
|
||||
GHMarketplaceListAccountBuilder(GitHub root, long planId) {
|
||||
this.root = root;
|
||||
this.builder = root.createRequest();
|
||||
this.planId = planId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the GitHub accounts by the date they were created or last updated. Can be one of created or updated.
|
||||
* <p>
|
||||
* If omitted, the default sorting strategy will be "CREATED"
|
||||
*
|
||||
* @param sort
|
||||
* the sort strategy
|
||||
* @return a GHMarketplaceListAccountBuilder
|
||||
*/
|
||||
public GHMarketplaceListAccountBuilder sort(Sort sort) {
|
||||
this.builder.with("sort", sort);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Orders the GitHub accounts results, Can be one of asc or desc. Ignored without the sort parameter.
|
||||
*
|
||||
* @param direction
|
||||
* the order strategy
|
||||
* @return a GHMarketplaceListAccountBuilder
|
||||
*/
|
||||
public GHMarketplaceListAccountBuilder direction(GHDirection direction) {
|
||||
this.builder.with("direction", direction);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The enum Sort.
|
||||
*/
|
||||
public enum Sort {
|
||||
CREATED, UPDATED
|
||||
}
|
||||
|
||||
/**
|
||||
* List any accounts associated with the plan specified on construction with all the order/sort parameters set.
|
||||
* <p>
|
||||
* GitHub Apps must use a JWT to access this endpoint.
|
||||
* <p>
|
||||
* OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
|
||||
*
|
||||
* @return a paged iterable instance of GHMarketplaceAccountPlan
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public PagedIterable<GHMarketplaceAccountPlan> createRequest() throws IOException {
|
||||
return builder.withUrlPath(String.format("/marketplace_listing/plans/%d/accounts", this.planId))
|
||||
.toIterable(GHMarketplaceAccountPlan[].class, item -> item.wrapUp(root));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A Github Marketplace purchase pending change.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GHMarketplaceListAccountBuilder#createRequest()
|
||||
*/
|
||||
public class GHMarketplacePendingChange extends GitHubInteractiveObject {
|
||||
private long id;
|
||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||
private Long unitCount;
|
||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||
private GHMarketplacePlan plan;
|
||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||
private String effectiveDate;
|
||||
|
||||
/**
|
||||
* Wrap up gh marketplace pending change.
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
* @return an instance of the GHMarketplacePendingChange class
|
||||
*/
|
||||
GHMarketplacePendingChange wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
if (plan != null) { // sanity check
|
||||
this.plan.wrapUp(this.root);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets unit count.
|
||||
*
|
||||
* @return the unit count
|
||||
*/
|
||||
public Long getUnitCount() {
|
||||
return unitCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets plan.
|
||||
*
|
||||
* @return the plan
|
||||
*/
|
||||
public GHMarketplacePlan getPlan() {
|
||||
return plan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets effective date.
|
||||
*
|
||||
* @return the effective date
|
||||
*/
|
||||
public Date getEffectiveDate() {
|
||||
return GitHubClient.parseDate(effectiveDate);
|
||||
}
|
||||
|
||||
}
|
||||
182
src/main/java/org/kohsuke/github/GHMarketplacePlan.java
Normal file
182
src/main/java/org/kohsuke/github/GHMarketplacePlan.java
Normal file
@@ -0,0 +1,182 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A Github Marketplace plan.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GitHub#listMarketplacePlans()
|
||||
*/
|
||||
public class GHMarketplacePlan extends GitHubInteractiveObject {
|
||||
private String url;
|
||||
private String accountsUrl;
|
||||
private long id;
|
||||
private long number;
|
||||
private String name;
|
||||
private String description;
|
||||
private long monthlyPriceInCents;
|
||||
private long yearlyPriceInCents;
|
||||
private GHMarketplacePriceModel priceModel;
|
||||
@JsonProperty("has_free_trial")
|
||||
private boolean freeTrial; // JavaBeans Spec 1.01 section 8.3.2 forces us to have is<propertyName>
|
||||
private String unitName;
|
||||
private String state;
|
||||
private List<String> bullets;
|
||||
|
||||
/**
|
||||
* Wrap up gh marketplace plan.
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
* @return an instance of the GHMarketplacePlan class
|
||||
*/
|
||||
GHMarketplacePlan wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets accounts url.
|
||||
*
|
||||
* @return the accounts url
|
||||
*/
|
||||
public String getAccountsUrl() {
|
||||
return accountsUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number.
|
||||
*
|
||||
* @return the number
|
||||
*/
|
||||
public long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets monthly price in cents.
|
||||
*
|
||||
* @return the monthly price in cents
|
||||
*/
|
||||
public long getMonthlyPriceInCents() {
|
||||
return monthlyPriceInCents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets yearly price in cents.
|
||||
*
|
||||
* @return the yearly price in cents
|
||||
*/
|
||||
public long getYearlyPriceInCents() {
|
||||
return yearlyPriceInCents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets price model.
|
||||
*
|
||||
* @return the price model
|
||||
*/
|
||||
public GHMarketplacePriceModel getPriceModel() {
|
||||
return priceModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is free trial boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isFreeTrial() {
|
||||
return freeTrial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets unit name.
|
||||
*
|
||||
* @return the unit name
|
||||
*/
|
||||
public String getUnitName() {
|
||||
return unitName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets state.
|
||||
*
|
||||
* @return the state
|
||||
*/
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bullets.
|
||||
*
|
||||
* @return the bullets
|
||||
*/
|
||||
public List<String> getBullets() {
|
||||
return bullets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a builder that list any accounts associated with a plan, including free plans. For per-seat pricing, you
|
||||
* see the list of accounts that have purchased the plan, including the number of seats purchased. When someone
|
||||
* submits a plan change that won't be processed until the end of their billing cycle, you will also see the
|
||||
* upcoming pending change.
|
||||
*
|
||||
* <p>
|
||||
* You use the returned builder to set various properties, then call
|
||||
* {@link GHMarketplaceListAccountBuilder#createRequest()} to finally list the accounts related to this plan.
|
||||
*
|
||||
* <p>
|
||||
* GitHub Apps must use a JWT to access this endpoint.
|
||||
* <p>
|
||||
* OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
|
||||
*
|
||||
* @return a GHMarketplaceListAccountBuilder instance
|
||||
* @see <a href=
|
||||
* "https://developer.github.com/v3/apps/marketplace/#list-all-github-accounts-user-or-organization-on-a-specific-plan">List
|
||||
* all GitHub accounts (user or organization) on a specific plan</a>
|
||||
*/
|
||||
public GHMarketplaceListAccountBuilder listAccounts() {
|
||||
return new GHMarketplaceListAccountBuilder(root, this.id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* GitHub Marketplace plan pricing model.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GHMarketplacePlan
|
||||
*/
|
||||
public enum GHMarketplacePriceModel {
|
||||
FREE("free"), PER_UNIT("per-unit"), FLAT_RATE("flat-rate");
|
||||
|
||||
@JsonValue
|
||||
private final String internalName;
|
||||
|
||||
GHMarketplacePriceModel(String internalName) {
|
||||
this.internalName = internalName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns GitHub's internal representation of this event.
|
||||
*
|
||||
* @return a string containing GitHub's internal representation of this event.
|
||||
*/
|
||||
public String symbol() {
|
||||
return internalName;
|
||||
}
|
||||
}
|
||||
101
src/main/java/org/kohsuke/github/GHMarketplacePurchase.java
Normal file
101
src/main/java/org/kohsuke/github/GHMarketplacePurchase.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A Github Marketplace purchase.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GHMarketplaceListAccountBuilder#createRequest() GHMarketplaceListAccountBuilder#createRequest()
|
||||
*/
|
||||
public class GHMarketplacePurchase extends GitHubInteractiveObject {
|
||||
|
||||
private String billingCycle;
|
||||
private String nextBillingDate;
|
||||
private boolean onFreeTrial;
|
||||
private String freeTrialEndsOn;
|
||||
private Long unitCount;
|
||||
private String updatedAt;
|
||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||
private GHMarketplacePlan plan;
|
||||
|
||||
/**
|
||||
* Wrap up gh marketplace purchase.
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
* @return an instance of the GHMarketplacePurchase class
|
||||
*/
|
||||
GHMarketplacePurchase wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
if (plan != null) { // sanity check
|
||||
this.plan.wrapUp(this.root);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets billing cycle.
|
||||
*
|
||||
* @return the billing cycle
|
||||
*/
|
||||
public String getBillingCycle() {
|
||||
return billingCycle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets next billing date.
|
||||
*
|
||||
* @return the next billing date
|
||||
*/
|
||||
public Date getNextBillingDate() {
|
||||
return GitHubClient.parseDate(nextBillingDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is on free trial boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isOnFreeTrial() {
|
||||
return onFreeTrial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets free trial ends on.
|
||||
*
|
||||
* @return the free trial ends on
|
||||
*/
|
||||
public Date getFreeTrialEndsOn() {
|
||||
return GitHubClient.parseDate(freeTrialEndsOn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets unit count.
|
||||
*
|
||||
* @return the unit count
|
||||
*/
|
||||
public Long getUnitCount() {
|
||||
return unitCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets updated at.
|
||||
*
|
||||
* @return the updated at
|
||||
*/
|
||||
public Date getUpdatedAt() {
|
||||
return GitHubClient.parseDate(updatedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets plan.
|
||||
*
|
||||
* @return the plan
|
||||
*/
|
||||
public GHMarketplacePlan getPlan() {
|
||||
return plan;
|
||||
}
|
||||
}
|
||||
112
src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java
Normal file
112
src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Github Marketplace User Purchase
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GitHub#getMyMarketplacePurchases()
|
||||
*/
|
||||
public class GHMarketplaceUserPurchase extends GitHubInteractiveObject {
|
||||
private String billingCycle;
|
||||
private String nextBillingDate;
|
||||
private boolean onFreeTrial;
|
||||
private String freeTrialEndsOn;
|
||||
private Long unitCount;
|
||||
private String updatedAt;
|
||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||
private GHMarketplaceAccount account;
|
||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||
private GHMarketplacePlan plan;
|
||||
|
||||
/**
|
||||
* Wrap up GHMarketplaceUserPurchase.
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
* @return an instance of the GHMarketplaceUserPurchase class
|
||||
*/
|
||||
GHMarketplaceUserPurchase wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
if (this.account != null)
|
||||
this.account.wrapUp(this.root);
|
||||
if (this.plan != null)
|
||||
this.plan.wrapUp(this.root);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets billing cycle.
|
||||
*
|
||||
* @return the billing cycle
|
||||
*/
|
||||
public String getBillingCycle() {
|
||||
return billingCycle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets next billing date.
|
||||
*
|
||||
* @return the next billing date
|
||||
*/
|
||||
public Date getNextBillingDate() {
|
||||
return GitHubClient.parseDate(nextBillingDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is on free trial boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isOnFreeTrial() {
|
||||
return onFreeTrial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets free trial ends on.
|
||||
*
|
||||
* @return the free trial ends on
|
||||
*/
|
||||
public Date getFreeTrialEndsOn() {
|
||||
return GitHubClient.parseDate(freeTrialEndsOn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets unit count.
|
||||
*
|
||||
* @return the unit count
|
||||
*/
|
||||
public Long getUnitCount() {
|
||||
return unitCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets updated at.
|
||||
*
|
||||
* @return the updated at
|
||||
*/
|
||||
public Date getUpdatedAt() {
|
||||
return GitHubClient.parseDate(updatedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets account.
|
||||
*
|
||||
* @return the account
|
||||
*/
|
||||
public GHMarketplaceAccount getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets plan.
|
||||
*
|
||||
* @return the plan
|
||||
*/
|
||||
public GHMarketplacePlan getPlan() {
|
||||
return plan;
|
||||
}
|
||||
}
|
||||
@@ -8,33 +8,56 @@ import java.util.Locale;
|
||||
* Represents a membership of a user in an organization.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHMyself#listOrgMemberships()
|
||||
* @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;
|
||||
GHUser user;
|
||||
GHOrganization organization;
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets state.
|
||||
*
|
||||
* @return the state
|
||||
*/
|
||||
public State getState() {
|
||||
return Enum.valueOf(State.class, state.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets role.
|
||||
*
|
||||
* @return the role
|
||||
*/
|
||||
public Role getRole() {
|
||||
return Enum.valueOf(Role.class, role.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user.
|
||||
*
|
||||
* @return the user
|
||||
*/
|
||||
public GHUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets organization.
|
||||
*
|
||||
* @return the organization
|
||||
*/
|
||||
public GHOrganization getOrganization() {
|
||||
return organization;
|
||||
}
|
||||
@@ -42,24 +65,23 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
|
||||
/**
|
||||
* Accepts a pending invitation to an organization.
|
||||
*
|
||||
* @see GHMyself#getMembership(GHOrganization)
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see GHMyself#getMembership(GHOrganization) GHMyself#getMembership(GHOrganization)
|
||||
*/
|
||||
public void activate() throws IOException {
|
||||
root.retrieve().method("PATCH").with("state",State.ACTIVE).to(url,this);
|
||||
root.createRequest().method("PATCH").with("state", State.ACTIVE).withUrlPath(url).fetchInto(this);
|
||||
}
|
||||
|
||||
/*package*/ GHMembership wrap(GitHub root) {
|
||||
GHMembership wrap(GitHub root) {
|
||||
this.root = root;
|
||||
if (user!=null) user = root.getUser(user.wrapUp(root));
|
||||
if (organization!=null) organization.wrapUp(root);
|
||||
if (user != null)
|
||||
user = root.getUser(user.wrapUp(root));
|
||||
if (organization != null)
|
||||
organization.wrapUp(root);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*package*/ static void wrap(GHMembership[] page, GitHub root) {
|
||||
for (GHMembership m : page)
|
||||
m.wrap(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Role of a user in an organization.
|
||||
*/
|
||||
@@ -78,7 +100,6 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
|
||||
* Whether a role is currently active or waiting for acceptance (pending)
|
||||
*/
|
||||
public enum State {
|
||||
ACTIVE,
|
||||
PENDING;
|
||||
ACTIVE, PENDING;
|
||||
}
|
||||
}
|
||||
|
||||
89
src/main/java/org/kohsuke/github/GHMeta.java
Normal file
89
src/main/java/org/kohsuke/github/GHMeta.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class that wraps the list of GitHub's IP addresses.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GitHub#getMeta() GitHub#getMeta()
|
||||
* @see <a href="https://developer.github.com/v3/meta/#meta">Get Meta</a>
|
||||
*/
|
||||
public class GHMeta {
|
||||
|
||||
@JsonProperty("verifiable_password_authentication")
|
||||
private boolean verifiablePasswordAuthentication;
|
||||
private List<String> hooks;
|
||||
private List<String> git;
|
||||
private List<String> web;
|
||||
private List<String> api;
|
||||
private List<String> pages;
|
||||
private List<String> importer = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Is verifiable password authentication boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isVerifiablePasswordAuthentication() {
|
||||
return verifiablePasswordAuthentication;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets hooks.
|
||||
*
|
||||
* @return the hooks
|
||||
*/
|
||||
public List<String> getHooks() {
|
||||
return Collections.unmodifiableList(hooks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets git.
|
||||
*
|
||||
* @return the git
|
||||
*/
|
||||
public List<String> getGit() {
|
||||
return Collections.unmodifiableList(git);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets web.
|
||||
*
|
||||
* @return the web
|
||||
*/
|
||||
public List<String> getWeb() {
|
||||
return Collections.unmodifiableList(web);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets api.
|
||||
*
|
||||
* @return the api
|
||||
*/
|
||||
public List<String> getApi() {
|
||||
return Collections.unmodifiableList(api);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets pages.
|
||||
*
|
||||
* @return the pages
|
||||
*/
|
||||
public List<String> getPages() {
|
||||
return Collections.unmodifiableList(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets importer.
|
||||
*
|
||||
* @return the importer
|
||||
*/
|
||||
public List<String> getImporter() {
|
||||
return Collections.unmodifiableList(importer);
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,11 @@ import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Yusuke Kokubo
|
||||
* The type GHMilestone.
|
||||
*
|
||||
* @author Yusuke Kokubo
|
||||
*/
|
||||
public class GHMilestone extends GHObject {
|
||||
GitHub root;
|
||||
GHRepository owner;
|
||||
|
||||
GHUser creator;
|
||||
@@ -19,60 +18,120 @@ public class GHMilestone extends GHObject {
|
||||
private int closed_issues, open_issues, number;
|
||||
protected String closed_at;
|
||||
|
||||
/**
|
||||
* Gets root.
|
||||
*
|
||||
* @return the root
|
||||
*/
|
||||
public GitHub getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets owner.
|
||||
*
|
||||
* @return the owner
|
||||
*/
|
||||
public GHRepository getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public GHUser getCreator() {
|
||||
return creator;
|
||||
|
||||
/**
|
||||
* Gets creator.
|
||||
*
|
||||
* @return the creator
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getCreator() throws IOException {
|
||||
return root.intern(creator);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets due on.
|
||||
*
|
||||
* @return the due on
|
||||
*/
|
||||
public Date getDueOn() {
|
||||
if (due_on == null) return null;
|
||||
return GitHub.parseDate(due_on);
|
||||
if (due_on == null)
|
||||
return null;
|
||||
return GitHubClient.parseDate(due_on);
|
||||
}
|
||||
|
||||
/**
|
||||
* When was this milestone closed?
|
||||
*
|
||||
* @return the closed at
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public Date getClosedAt() throws IOException {
|
||||
return GitHub.parseDate(closed_at);
|
||||
return GitHubClient.parseDate(closed_at);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets title.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets closed issues.
|
||||
*
|
||||
* @return the closed issues
|
||||
*/
|
||||
public int getClosedIssues() {
|
||||
return closed_issues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets open issues.
|
||||
*
|
||||
* @return the open issues
|
||||
*/
|
||||
public int getOpenIssues() {
|
||||
return open_issues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets number.
|
||||
*
|
||||
* @return the number
|
||||
*/
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets state.
|
||||
*
|
||||
* @return the state
|
||||
*/
|
||||
public GHMilestoneState getState() {
|
||||
return Enum.valueOf(GHMilestoneState.class, state.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes this milestone.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
edit("state", "closed");
|
||||
@@ -80,19 +139,80 @@ public class GHMilestone extends GHObject {
|
||||
|
||||
/**
|
||||
* Reopens this milestone.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void reopen() throws IOException {
|
||||
edit("state", "open");
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes this milestone.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
|
||||
}
|
||||
|
||||
private void edit(String key, Object value) throws IOException {
|
||||
new Requester(root)._with(key, value).method("PATCH").to(getApiRoute());
|
||||
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets title.
|
||||
*
|
||||
* @param title
|
||||
* the title
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setTitle(String title) throws IOException {
|
||||
edit("title", title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets description.
|
||||
*
|
||||
* @param description
|
||||
* the description
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setDescription(String description) throws IOException {
|
||||
edit("description", description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets due on.
|
||||
*
|
||||
* @param dueOn
|
||||
* the due on
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setDueOn(Date dueOn) throws IOException {
|
||||
edit("due_on", GitHubClient.printDate(dueOn));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets api route.
|
||||
*
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return "/repos/"+owner.getOwnerName()+"/"+owner.getName()+"/milestones/"+number;
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/milestones/" + number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap gh milestone.
|
||||
*
|
||||
* @param repo
|
||||
* the repo
|
||||
* @return the gh milestone
|
||||
*/
|
||||
public GHMilestone wrap(GHRepository repo) {
|
||||
this.owner = repo;
|
||||
this.root = repo.root;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Yusuke Kokubo
|
||||
* The enum GHMilestoneState.
|
||||
*
|
||||
* @author Yusuke Kokubo
|
||||
*/
|
||||
public enum GHMilestoneState {
|
||||
OPEN,
|
||||
CLOSED
|
||||
}
|
||||
OPEN, CLOSED
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@ package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
@@ -45,8 +43,12 @@ public class GHMyself extends GHUser {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #getEmails2()}
|
||||
* Gets emails.
|
||||
*
|
||||
* @return the emails
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated Use {@link #getEmails2()}
|
||||
*/
|
||||
public List<String> getEmails() throws IOException {
|
||||
List<GHEmail> src = getEmails2();
|
||||
@@ -59,55 +61,64 @@ public class GHMyself extends GHUser {
|
||||
|
||||
/**
|
||||
* Returns the read-only list of e-mail addresses configured for you.
|
||||
* <p>
|
||||
* This corresponds to the stuff you configure in https://github.com/settings/emails, and not to be confused with
|
||||
* {@link #getEmail()} that shows your public e-mail address set in https://github.com/settings/profile
|
||||
*
|
||||
* This corresponds to the stuff you configure in https://github.com/settings/emails,
|
||||
* and not to be confused with {@link #getEmail()} that shows your public e-mail address
|
||||
* set in https://github.com/settings/profile
|
||||
*
|
||||
* @return
|
||||
* Always non-null.
|
||||
* @return Always non-null.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHEmail> getEmails2() throws IOException {
|
||||
GHEmail[] addresses = root.retrieve().to("/user/emails", GHEmail[].class);
|
||||
return Collections.unmodifiableList(Arrays.asList(addresses));
|
||||
return root.createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the read-only list of all the pulic keys of the current user.
|
||||
* <p>
|
||||
* NOTE: When using OAuth authenticaiton, the READ/WRITE User scope is required by the GitHub APIs, otherwise you
|
||||
* will get a 404 NOT FOUND.
|
||||
*
|
||||
* NOTE: When using OAuth authenticaiton, the READ/WRITE User scope is
|
||||
* required by the GitHub APIs, otherwise you will get a 404 NOT FOUND.
|
||||
*
|
||||
* @return
|
||||
* Always non-null.
|
||||
* @return Always non-null.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHKey> getPublicKeys() throws IOException {
|
||||
return Collections.unmodifiableList(Arrays.asList(root.retrieve().to("/user/keys", GHKey[].class)));
|
||||
return root.createRequest().withUrlPath("/user/keys").toIterable(GHKey[].class, null).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the read-only list of all the public verified keys of the current user.
|
||||
* <p>
|
||||
* Differently from the getPublicKeys() method, the retrieval of the user's verified public keys does not require
|
||||
* any READ/WRITE OAuth Scope to the user's profile.
|
||||
*
|
||||
* Differently from the getPublicKeys() method, the retrieval of the user's
|
||||
* verified public keys does not require any READ/WRITE OAuth Scope to the
|
||||
* user's profile.
|
||||
*
|
||||
* @return
|
||||
* Always non-null.
|
||||
* @return Always non-null.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHVerifiedKey> getPublicVerifiedKeys() throws IOException {
|
||||
return Collections.unmodifiableList(Arrays.asList(root.retrieve().to(
|
||||
"/users/" + getLogin() + "/keys", GHVerifiedKey[].class)));
|
||||
}
|
||||
public List<GHVerifiedKey> getPublicVerifiedKeys() throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath("/users/" + getLogin() + "/keys")
|
||||
.toIterable(GHVerifiedKey[].class, null)
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the organization that this user belongs to.
|
||||
*
|
||||
* @return the all organizations
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHPersonSet<GHOrganization> getAllOrganizations() throws IOException {
|
||||
GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>();
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (GHOrganization o : root.retrieve().to("/user/orgs", GHOrganization[].class)) {
|
||||
if (names.add(o.getLogin())) // in case of rumoured duplicates in the data
|
||||
for (GHOrganization o : root.createRequest()
|
||||
.withUrlPath("/user/orgs")
|
||||
.toIterable(GHOrganization[].class, null)
|
||||
.toArray()) {
|
||||
if (names.add(o.getLogin())) // in case of rumoured duplicates in the data
|
||||
orgs.add(root.getOrganization(o.getLogin()));
|
||||
}
|
||||
return orgs;
|
||||
@@ -115,11 +126,15 @@ public class GHMyself extends GHUser {
|
||||
|
||||
/**
|
||||
* Gets the all repositories this user owns (public and private).
|
||||
*
|
||||
* @return the all repositories
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public synchronized Map<String,GHRepository> getAllRepositories() throws IOException {
|
||||
Map<String,GHRepository> repositories = new TreeMap<String, GHRepository>();
|
||||
public synchronized Map<String, GHRepository> getAllRepositories() throws IOException {
|
||||
Map<String, GHRepository> repositories = new TreeMap<String, GHRepository>();
|
||||
for (GHRepository r : listAllRepositories()) {
|
||||
repositories.put(r.getName(),r);
|
||||
repositories.put(r.getName(), r);
|
||||
}
|
||||
return Collections.unmodifiableMap(repositories);
|
||||
}
|
||||
@@ -127,59 +142,64 @@ public class GHMyself extends GHUser {
|
||||
/**
|
||||
* Lists up all repositories this user owns (public and private).
|
||||
*
|
||||
* Unlike {@link #getAllRepositories()}, this does not wait until all the repositories are returned.
|
||||
* Repositories are returned by GitHub API with a 30 items per page.
|
||||
* Unlike {@link #getAllRepositories()}, this does not wait until all the repositories are returned. Repositories
|
||||
* are returned by GitHub API with a 30 items per page.
|
||||
*/
|
||||
@Override
|
||||
public PagedIterable<GHRepository> listRepositories() {
|
||||
return listRepositories(30);
|
||||
return listRepositories(30);
|
||||
}
|
||||
|
||||
/**
|
||||
* List repositories that are accessible to the authenticated user (public and private) using the specified page size.
|
||||
* List repositories that are accessible to the authenticated user (public and private) using the specified page
|
||||
* size.
|
||||
*
|
||||
* This includes repositories owned by the authenticated user, repositories that belong to other users
|
||||
* where the authenticated user is a collaborator, and other organizations' repositories that the authenticated
|
||||
* user has access to through an organization membership.
|
||||
* This includes repositories owned by the authenticated user, repositories that belong to other users where the
|
||||
* authenticated user is a collaborator, and other organizations' repositories that the authenticated user has
|
||||
* access to through an organization membership.
|
||||
*
|
||||
* @param pageSize size for each page of items returned by GitHub. Maximum page size is 100.
|
||||
* @param pageSize
|
||||
* size for each page of items returned by GitHub. Maximum page size is 100.
|
||||
*
|
||||
* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned.
|
||||
* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned.
|
||||
*/
|
||||
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
|
||||
return listRepositories(pageSize, RepositoryListFilter.ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* List repositories of a certain type that are accessible by current authenticated user using the specified page size.
|
||||
* List repositories of a certain type that are accessible by current authenticated user using the specified page
|
||||
* size.
|
||||
*
|
||||
* @param pageSize size for each page of items returned by GitHub. Maximum page size is 100.
|
||||
* @param repoType type of repository returned in the listing
|
||||
* @param pageSize
|
||||
* size for each page of items returned by GitHub. Maximum page size is 100.
|
||||
* @param repoType
|
||||
* type of repository returned in the listing
|
||||
* @return the paged iterable
|
||||
*/
|
||||
public PagedIterable<GHRepository> listRepositories(final int pageSize, final RepositoryListFilter repoType) {
|
||||
return new PagedIterable<GHRepository>() {
|
||||
public PagedIterator<GHRepository> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHRepository>(root.retrieve().with("type",repoType).asIterator("/user/repos", GHRepository[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHRepository[] page) {
|
||||
for (GHRepository c : page)
|
||||
c.wrap(root);
|
||||
}
|
||||
};
|
||||
}
|
||||
}.withPageSize(pageSize);
|
||||
return root.createRequest()
|
||||
.with("type", repoType)
|
||||
.withUrlPath("/user/repos")
|
||||
.toIterable(GHRepository[].class, item -> item.wrap(root))
|
||||
.withPageSize(pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #listRepositories()}
|
||||
* List all repositories paged iterable.
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @deprecated Use {@link #listRepositories()}
|
||||
*/
|
||||
@Deprecated
|
||||
public PagedIterable<GHRepository> listAllRepositories() {
|
||||
return listRepositories();
|
||||
}
|
||||
|
||||
/**
|
||||
* List your organization memberships
|
||||
*
|
||||
* @return the paged iterable
|
||||
*/
|
||||
public PagedIterable<GHMembership> listOrgMemberships() {
|
||||
return listOrgMemberships(null);
|
||||
@@ -189,30 +209,34 @@ public class GHMyself extends GHUser {
|
||||
* List your organization memberships
|
||||
*
|
||||
* @param state
|
||||
* Filter by a specific state
|
||||
* Filter by a specific state
|
||||
* @return the paged iterable
|
||||
*/
|
||||
public PagedIterable<GHMembership> listOrgMemberships(final GHMembership.State state) {
|
||||
return new PagedIterable<GHMembership>() {
|
||||
public PagedIterator<GHMembership> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHMembership>(root.retrieve().with("state",state).asIterator("/user/memberships/orgs", GHMembership[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHMembership[] page) {
|
||||
GHMembership.wrap(page,root);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return root.createRequest()
|
||||
.with("state", state)
|
||||
.withUrlPath("/user/memberships/orgs")
|
||||
.toIterable(GHMembership[].class, item -> item.wrap(root));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets your membership in a specific organization.
|
||||
*
|
||||
* @param o
|
||||
* the o
|
||||
* @return the membership
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHMembership getMembership(GHOrganization o) throws IOException {
|
||||
return root.retrieve().to("/user/memberships/orgs/"+o.getLogin(),GHMembership.class).wrap(root);
|
||||
return root.createRequest()
|
||||
.withUrlPath("/user/memberships/orgs/" + o.getLogin())
|
||||
.fetch(GHMembership.class)
|
||||
.wrap(root);
|
||||
}
|
||||
|
||||
// public void addEmails(Collection<String> emails) throws IOException {
|
||||
//// new Requester(root,ApiVersion.V3).withCredential().to("/user/emails");
|
||||
// root.retrieveWithAuth3()
|
||||
// }
|
||||
// public void addEmails(Collection<String> emails) throws IOException {
|
||||
//// new Requester(root,ApiVersion.V3).withCredential().to("/user/emails");
|
||||
// root.retrieveWithAuth3()
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -9,39 +9,37 @@ import java.util.NoSuchElementException;
|
||||
* Listens to GitHub notification stream.
|
||||
*
|
||||
* <p>
|
||||
* This class supports two modes of retrieving notifications that can
|
||||
* be controlled via {@link #nonBlocking(boolean)}.
|
||||
* This class supports two modes of retrieving notifications that can be controlled via {@link #nonBlocking(boolean)}.
|
||||
*
|
||||
* <p>
|
||||
* In the blocking mode, which is the default, iterator will be infinite.
|
||||
* The call to {@link Iterator#next()} will block until a new notification
|
||||
* arrives. This is useful for application that runs perpetually and reacts
|
||||
* to notifications.
|
||||
* In the blocking mode, which is the default, iterator will be infinite. The call to {@link Iterator#next()} will block
|
||||
* until a new notification arrives. This is useful for application that runs perpetually and reacts to notifications.
|
||||
*
|
||||
* <p>
|
||||
* In the non-blocking mode, the iterator will only report the set of
|
||||
* notifications initially retrieved from GitHub, then quit. This is useful
|
||||
* for a batch application to process the current set of notifications.
|
||||
* In the non-blocking mode, the iterator will only report the set of notifications initially retrieved from GitHub,
|
||||
* then quit. This is useful for a batch application to process the current set of notifications.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GitHub#listNotifications()
|
||||
* @see GHRepository#listNotifications()
|
||||
* @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;
|
||||
private boolean nonBlocking = false;
|
||||
|
||||
/*package*/ GHNotificationStream(GitHub root, String apiUrl) {
|
||||
GHNotificationStream(GitHub root, String apiUrl) {
|
||||
this.root = root;
|
||||
this.apiUrl = apiUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the stream include notifications that are already read?
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh notification stream
|
||||
*/
|
||||
public GHNotificationStream read(boolean v) {
|
||||
all = v;
|
||||
@@ -49,26 +47,47 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the stream be restricted to notifications in which the user
|
||||
* is directly participating or mentioned?
|
||||
* Should the stream be restricted to notifications in which the user is directly participating or mentioned?
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh notification stream
|
||||
*/
|
||||
public GHNotificationStream participating(boolean v) {
|
||||
participating = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Since gh notification stream.
|
||||
*
|
||||
* @param timestamp
|
||||
* the timestamp
|
||||
* @return the gh notification stream
|
||||
*/
|
||||
public GHNotificationStream since(long timestamp) {
|
||||
return since(new Date(timestamp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Since gh notification stream.
|
||||
*
|
||||
* @param dt
|
||||
* the dt
|
||||
* @return the gh notification stream
|
||||
*/
|
||||
public GHNotificationStream since(Date dt) {
|
||||
since = GitHub.printDate(dt);
|
||||
since = GitHubClient.printDate(dt);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If set to true, {@link #iterator()} will stop iterating instead of blocking and
|
||||
* waiting for the updates to arrive.
|
||||
* If set to true, {@link #iterator()} will stop iterating instead of blocking and waiting for the updates to
|
||||
* arrive.
|
||||
*
|
||||
* @param v
|
||||
* the v
|
||||
* @return the gh notification stream
|
||||
*/
|
||||
public GHNotificationStream nonBlocking(boolean v) {
|
||||
this.nonBlocking = v;
|
||||
@@ -76,25 +95,25 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an infinite blocking {@link Iterator} that returns
|
||||
* {@link GHThread} as notifications arrive.
|
||||
* Returns an infinite blocking {@link Iterator} that returns {@link GHThread} as notifications arrive.
|
||||
*/
|
||||
public Iterator<GHThread> iterator() {
|
||||
// capture the configuration setting here
|
||||
final Requester req = new Requester(root).method("GET")
|
||||
.with("all", all).with("participating", participating).with("since", since);
|
||||
final Requester req = root.createRequest()
|
||||
.with("all", all)
|
||||
.with("participating", participating)
|
||||
.with("since", since);
|
||||
|
||||
return new Iterator<GHThread>() {
|
||||
/**
|
||||
* Stuff we've fetched but haven't returned to the caller.
|
||||
* Newer ones first.
|
||||
* Stuff we've fetched but haven't returned to the caller. Newer ones first.
|
||||
*/
|
||||
private GHThread[] threads = EMPTY_ARRAY;
|
||||
|
||||
/**
|
||||
* Next element in {@link #threads} to return. This counts down.
|
||||
*/
|
||||
private int idx=-1;
|
||||
private int idx = -1;
|
||||
|
||||
/**
|
||||
* threads whose updated_at is older than this should be ignored.
|
||||
@@ -114,9 +133,9 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
||||
private GHThread next;
|
||||
|
||||
public GHThread next() {
|
||||
if (next==null) {
|
||||
if (next == null) {
|
||||
next = fetch();
|
||||
if (next==null)
|
||||
if (next == null)
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@@ -126,9 +145,9 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
if (next==null)
|
||||
if (next == null)
|
||||
next = fetch();
|
||||
return next!=null;
|
||||
return next != null;
|
||||
}
|
||||
|
||||
GHThread fetch() {
|
||||
@@ -136,7 +155,7 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
||||
while (true) {// loop until we get new threads to return
|
||||
|
||||
// if we have fetched un-returned threads, use them first
|
||||
while (idx>=0) {
|
||||
while (idx >= 0) {
|
||||
GHThread n = threads[idx--];
|
||||
long nt = n.getUpdatedAt().getTime();
|
||||
if (nt >= lastUpdated) {
|
||||
@@ -145,63 +164,74 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
||||
}
|
||||
}
|
||||
|
||||
if (nonBlocking && nextCheckTime>=0)
|
||||
return null; // nothing more to report, and we aren't blocking
|
||||
if (nonBlocking && nextCheckTime >= 0)
|
||||
return null; // nothing more to report, and we aren't blocking
|
||||
|
||||
// observe the polling interval before making the call
|
||||
while (true) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (nextCheckTime < now) break;
|
||||
if (nextCheckTime < now)
|
||||
break;
|
||||
long waitTime = Math.min(Math.max(nextCheckTime - now, 1000), 60 * 1000);
|
||||
Thread.sleep(waitTime);
|
||||
}
|
||||
|
||||
req.setHeader("If-Modified-Since", lastModified);
|
||||
|
||||
threads = req.to(apiUrl, GHThread[].class);
|
||||
if (threads==null) {
|
||||
threads = EMPTY_ARRAY; // if unmodified, we get empty array
|
||||
Requester requester = req.withUrlPath(apiUrl);
|
||||
GitHubResponse<GHThread[]> response = ((GitHubPageContentsIterable<GHThread>) requester
|
||||
.toIterable(GHThread[].class, null)).toResponse();
|
||||
threads = response.body();
|
||||
|
||||
if (threads == null) {
|
||||
threads = EMPTY_ARRAY; // if unmodified, we get empty array
|
||||
} else {
|
||||
// we get a new batch, but we want to ignore the ones that we've seen
|
||||
lastUpdated++;
|
||||
}
|
||||
idx = threads.length-1;
|
||||
idx = threads.length - 1;
|
||||
|
||||
nextCheckTime = calcNextCheckTime();
|
||||
lastModified = req.getResponseHeader("Last-Modified");
|
||||
nextCheckTime = calcNextCheckTime(response);
|
||||
lastModified = response.headerField("Last-Modified");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (IOException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private long calcNextCheckTime() {
|
||||
String v = req.getResponseHeader("X-Poll-Interval");
|
||||
if (v==null) v="60";
|
||||
private long calcNextCheckTime(GitHubResponse<GHThread[]> response) {
|
||||
String v = response.headerField("X-Poll-Interval");
|
||||
if (v == null)
|
||||
v = "60";
|
||||
long seconds = Integer.parseInt(v);
|
||||
return System.currentTimeMillis() + seconds*1000;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
return System.currentTimeMillis() + seconds * 1000;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark as read.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void markAsRead() throws IOException {
|
||||
markAsRead(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks all the notifications as read.
|
||||
*
|
||||
* @param timestamp
|
||||
* the timestamp
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void markAsRead(long timestamp) throws IOException {
|
||||
final Requester req = new Requester(root).method("PUT");
|
||||
if (timestamp>=0)
|
||||
req.with("last_read_at", GitHub.printDate(new Date(timestamp)));
|
||||
req.asHttpStatusCode(apiUrl);
|
||||
final Requester req = root.createRequest();
|
||||
if (timestamp >= 0)
|
||||
req.with("last_read_at", GitHubClient.printDate(new Date(timestamp)));
|
||||
req.withUrlPath(apiUrl).fetchHttpStatusCode();
|
||||
}
|
||||
|
||||
private static final GHThread[] EMPTY_ARRAY = new GHThread[0];
|
||||
|
||||
10
src/main/java/org/kohsuke/github/GHOTPRequiredException.java
Normal file
10
src/main/java/org/kohsuke/github/GHOTPRequiredException.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
/**
|
||||
* This exception is thrown when GitHub is requesting an OTP from the user
|
||||
*
|
||||
* @author Kevin Harrington mad.hephaestus@gmail.com
|
||||
*/
|
||||
public class GHOTPRequiredException extends GHIOException {
|
||||
// ...
|
||||
}
|
||||
@@ -1,86 +1,158 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
|
||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang.builder.ToStringStyle;
|
||||
import org.apache.commons.lang.reflect.FieldUtils;
|
||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
/**
|
||||
* Most (all?) domain objects in GitHub seems to have these 4 properties.
|
||||
*/
|
||||
@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD",
|
||||
"NP_UNWRITTEN_FIELD"}, justification = "JSON API")
|
||||
public abstract class GHObject {
|
||||
protected String url;
|
||||
protected int id;
|
||||
protected String created_at;
|
||||
protected String updated_at;
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
|
||||
justification = "JSON API")
|
||||
public abstract class GHObject extends GitHubInteractiveObject {
|
||||
/**
|
||||
* Capture response HTTP headers on the state object.
|
||||
*/
|
||||
protected transient Map<String, List<String>> responseHeaderFields;
|
||||
|
||||
/*package*/ GHObject() {
|
||||
private String url;
|
||||
|
||||
private long id;
|
||||
private String nodeId;
|
||||
private String createdAt;
|
||||
private String updatedAt;
|
||||
|
||||
GHObject() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by Jackson
|
||||
*
|
||||
* @param responseInfo
|
||||
* the {@link GitHubResponse.ResponseInfo} to get headers from.
|
||||
*/
|
||||
@JacksonInject
|
||||
protected void setResponseHeaderFields(@CheckForNull GitHubResponse.ResponseInfo responseInfo) {
|
||||
if (responseInfo != null) {
|
||||
responseHeaderFields = responseInfo.headers();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP response headers given along with the state of this object.
|
||||
*
|
||||
* <p>
|
||||
* Some of the HTTP headers have nothing to do with the object, for example "Cache-Control" and others are different
|
||||
* depending on how this object was retrieved.
|
||||
* <p>
|
||||
* This method was added as a kind of hack to allow the caller to retrieve OAuth scopes and such. Use with caution.
|
||||
* The method might be removed in the future.
|
||||
*
|
||||
* @return a map of header names to value lists
|
||||
*/
|
||||
@CheckForNull
|
||||
@Deprecated
|
||||
public Map<String, List<String>> getResponseHeaderFields() {
|
||||
return responseHeaderFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* When was this resource created?
|
||||
*
|
||||
* @return date created
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
@WithBridgeMethods(value=String.class, adapterMethod="createdAtStr")
|
||||
@WithBridgeMethods(value = String.class, adapterMethod = "createdAtStr")
|
||||
public Date getCreatedAt() throws IOException {
|
||||
return GitHub.parseDate(created_at);
|
||||
return GitHubClient.parseDate(createdAt);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getCreatedAt")
|
||||
private Object createdAtStr(Date id, Class type) {
|
||||
return created_at;
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* API URL of this object.
|
||||
* Gets url.
|
||||
*
|
||||
* @return API URL of this object.
|
||||
*/
|
||||
@WithBridgeMethods(value=String.class, adapterMethod="urlToString")
|
||||
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* URL of this object for humans, which renders some HTML.
|
||||
* Gets html url.
|
||||
*
|
||||
* @return URL of this object for humans, which renders some HTML.
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
@WithBridgeMethods(value=String.class, adapterMethod="urlToString")
|
||||
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
||||
public abstract URL getHtmlUrl() throws IOException;
|
||||
|
||||
/**
|
||||
* When was this resource last updated?
|
||||
*
|
||||
* @return updated date
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
public Date getUpdatedAt() throws IOException {
|
||||
return GitHub.parseDate(updated_at);
|
||||
return GitHubClient.parseDate(updatedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique ID number of this resource.
|
||||
* 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.
|
||||
*/
|
||||
@WithBridgeMethods(value=String.class, adapterMethod="intToString")
|
||||
public int getId() {
|
||||
public String getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets id.
|
||||
*
|
||||
* @return Unique ID number of this resource.
|
||||
*/
|
||||
@WithBridgeMethods(value = { String.class, int.class }, adapterMethod = "longToStringOrInt")
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getId")
|
||||
private Object intToString(int id, Class type) {
|
||||
return String.valueOf(id);
|
||||
private Object longToStringOrInt(long id, Class type) {
|
||||
if (type == String.class)
|
||||
return String.valueOf(id);
|
||||
if (type == int.class)
|
||||
return (int) id;
|
||||
throw new AssertionError("Unexpected type: " + type);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getHtmlUrl")
|
||||
private Object urlToString(URL url, Class type) {
|
||||
return url==null ? null : url.toString();
|
||||
return url == null ? null : url.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* String representation to assist debugging and inspection. The output format of this string
|
||||
* is not a committed part of the API and is subject to change.
|
||||
* String representation to assist debugging and inspection. The output format of this string is not a committed
|
||||
* part of the API and is subject to change.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -109,7 +181,7 @@ public abstract class GHObject {
|
||||
if (value instanceof GitHub)
|
||||
return;
|
||||
|
||||
super.append(buffer,fieldName,value,fullDetail);
|
||||
super.append(buffer, fieldName, value, fullDetail);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ class GHOrgHook extends GHHook {
|
||||
/**
|
||||
* Organization that the hook belongs to.
|
||||
*/
|
||||
/*package*/ transient GHOrganization organization;
|
||||
transient GHOrganization organization;
|
||||
|
||||
/*package*/ GHOrgHook wrap(GHOrganization owner) {
|
||||
GHOrgHook wrap(GHOrganization owner) {
|
||||
this.organization = owner;
|
||||
return this;
|
||||
}
|
||||
@@ -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,84 +10,170 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static org.kohsuke.github.internal.Previews.INERTIA;
|
||||
|
||||
/**
|
||||
* The type GHOrganization.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class GHOrganization extends GHPerson {
|
||||
/*package*/ GHOrganization wrapUp(GitHub root) {
|
||||
return (GHOrganization)super.wrapUp(root);
|
||||
GHOrganization wrapUp(GitHub root) {
|
||||
return (GHOrganization) super.wrapUp(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new repository.
|
||||
*
|
||||
* @return
|
||||
* Newly created repository.
|
||||
* @deprecated
|
||||
* Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
||||
* @param name
|
||||
* the name
|
||||
* @param description
|
||||
* the description
|
||||
* @param homepage
|
||||
* the homepage
|
||||
* @param team
|
||||
* the team
|
||||
* @param isPublic
|
||||
* the is public
|
||||
* @return Newly created repository.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
||||
*/
|
||||
public GHRepository createRepository(String name, String description, String homepage, String team, boolean isPublic) throws IOException {
|
||||
@Deprecated
|
||||
public GHRepository createRepository(String name,
|
||||
String description,
|
||||
String homepage,
|
||||
String team,
|
||||
boolean isPublic) throws IOException {
|
||||
GHTeam t = getTeams().get(team);
|
||||
if (t==null)
|
||||
throw new IllegalArgumentException("No such team: "+team);
|
||||
if (t == null)
|
||||
throw new IllegalArgumentException("No such team: " + team);
|
||||
return createRepository(name, description, homepage, t, isPublic);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
||||
* Create repository gh repository.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param description
|
||||
* the description
|
||||
* @param homepage
|
||||
* the homepage
|
||||
* @param team
|
||||
* the team
|
||||
* @param isPublic
|
||||
* the is public
|
||||
* @return the gh repository
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
||||
*/
|
||||
public GHRepository createRepository(String name, String description, String homepage, GHTeam team, boolean isPublic) throws IOException {
|
||||
if (team==null)
|
||||
@Deprecated
|
||||
public GHRepository createRepository(String name,
|
||||
String description,
|
||||
String homepage,
|
||||
GHTeam team,
|
||||
boolean isPublic) throws IOException {
|
||||
if (team == null)
|
||||
throw new IllegalArgumentException("Invalid team");
|
||||
return createRepository(name).description(description).homepage(homepage).private_(!isPublic).team(team).create();
|
||||
return createRepository(name).description(description)
|
||||
.homepage(homepage)
|
||||
.private_(!isPublic)
|
||||
.team(team)
|
||||
.create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a builder that creates a new repository.
|
||||
*
|
||||
* <p>
|
||||
* You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()}
|
||||
* to finally createa repository.
|
||||
* You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()} to
|
||||
* finally create a repository.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @return the gh create repository builder
|
||||
*/
|
||||
public GHCreateRepositoryBuilder createRepository(String name) throws IOException {
|
||||
return new GHCreateRepositoryBuilder(root,"/orgs/"+login+"/repos",name);
|
||||
public GHCreateRepositoryBuilder createRepository(String name) {
|
||||
return new GHCreateRepositoryBuilder(name, root, "/orgs/" + login + "/repos");
|
||||
}
|
||||
|
||||
/**
|
||||
* Teams by their names.
|
||||
*
|
||||
* @return the teams
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public Map<String,GHTeam> getTeams() throws IOException {
|
||||
Map<String,GHTeam> r = new TreeMap<String, GHTeam>();
|
||||
public Map<String, GHTeam> getTeams() throws IOException {
|
||||
Map<String, GHTeam> r = new TreeMap<String, GHTeam>();
|
||||
for (GHTeam t : listTeams()) {
|
||||
r.put(t.getName(),t);
|
||||
r.put(t.getName(), t);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* List up all the teams.
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHTeam> listTeams() throws IOException {
|
||||
return new PagedIterable<GHTeam>() {
|
||||
public PagedIterator<GHTeam> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHTeam>(root.retrieve().asIterator(String.format("/orgs/%s/teams", login), GHTeam[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHTeam[] page) {
|
||||
for (GHTeam c : page)
|
||||
c.wrapUp(GHOrganization.this);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/orgs/%s/teams", login))
|
||||
.toIterable(GHTeam[].class, item -> item.wrapUp(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single team by ID.
|
||||
*
|
||||
* @param teamId
|
||||
* id of the team that we want to query for
|
||||
* @return the team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*
|
||||
* @deprecated Use {@link GHOrganization#getTeam(long)}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHTeam getTeam(int teamId) throws IOException {
|
||||
return getTeam((long) teamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single team by ID.
|
||||
*
|
||||
* @param teamId
|
||||
* id of the team that we want to query for
|
||||
* @return the team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*
|
||||
* @see <a href= "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
|
||||
*/
|
||||
public GHTeam getTeam(long teamId) throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/organizations/%d/team/%d", getId(), teamId))
|
||||
.fetch(GHTeam.class)
|
||||
.wrapUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a team that has the given name in its {@link GHTeam#getName()}
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @return the team by name
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHTeam getTeamByName(String name) throws IOException {
|
||||
for (GHTeam t : listTeams()) {
|
||||
if(t.getName().equals(name))
|
||||
if (t.getName().equals(name))
|
||||
return t;
|
||||
}
|
||||
return null;
|
||||
@@ -95,21 +181,60 @@ public class GHOrganization extends GHPerson {
|
||||
|
||||
/**
|
||||
* Finds a team that has the given slug in its {@link GHTeam#getSlug()}
|
||||
*
|
||||
* @param slug
|
||||
* the slug
|
||||
* @return the team by slug
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see <a href= "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
|
||||
*/
|
||||
public GHTeam getTeamBySlug(String slug) throws IOException {
|
||||
for (GHTeam t : listTeams()) {
|
||||
if(t.getSlug().equals(slug))
|
||||
return t;
|
||||
}
|
||||
return null;
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/orgs/%s/teams/%s", login, slug))
|
||||
.fetch(GHTeam.class)
|
||||
.wrapUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Member's role in an organization
|
||||
*/
|
||||
public enum Role {
|
||||
ADMIN,
|
||||
/** The user is an owner of the organization. */
|
||||
MEMBER /** The user is a non-owner member of the organization. */
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds (invites) a user to the organization.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param role
|
||||
* the role
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see <a href=
|
||||
* "https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership">documentation</a>
|
||||
*/
|
||||
public void add(GHUser user, Role role) throws IOException {
|
||||
root.createRequest()
|
||||
.method("PUT")
|
||||
.with("role", role.name().toLowerCase())
|
||||
.withUrlPath("/orgs/" + login + "/memberships/" + user.getLogin())
|
||||
.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this organization has the specified user as a member.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean hasMember(GHUser user) {
|
||||
try {
|
||||
root.retrieve().to("/orgs/" + login + "/members/" + user.getLogin());
|
||||
root.createRequest().withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();
|
||||
return true;
|
||||
} catch (IOException ignore) {
|
||||
return false;
|
||||
@@ -117,19 +242,28 @@ public class GHOrganization extends GHPerson {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a member of the organisation - which will remove them from
|
||||
* all teams, and remove their access to the organization’s repositories.
|
||||
* Remove a member of the organisation - which will remove them from all teams, and remove their access to the
|
||||
* organization’s repositories.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void remove(GHUser user) throws IOException {
|
||||
root.retrieve().method("DELETE").to("/orgs/" + login + "/members/" + user.getLogin());
|
||||
root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this organization has the specified user as a public member.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean hasPublicMember(GHUser user) {
|
||||
try {
|
||||
root.retrieve().to("/orgs/" + login + "/public_members/" + user.getLogin());
|
||||
root.createRequest().withUrlPath("/orgs/" + login + "/public_members/" + user.getLogin()).send();
|
||||
return true;
|
||||
} catch (IOException ignore) {
|
||||
return false;
|
||||
@@ -138,20 +272,34 @@ public class GHOrganization extends GHPerson {
|
||||
|
||||
/**
|
||||
* Publicizes the membership.
|
||||
*
|
||||
* @param u
|
||||
* the u
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void publicize(GHUser u) throws IOException {
|
||||
root.retrieve().method("PUT").to("/orgs/" + login + "/public_members/" + u.getLogin(), null);
|
||||
root.createRequest().method("PUT").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets members.
|
||||
*
|
||||
* @return the members
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated use {@link #listMembers()}
|
||||
*/
|
||||
public List<GHUser> getMembers() throws IOException {
|
||||
return listMembers().asList();
|
||||
return listMembers().toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* All the members of this organization.
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHUser> listMembers() throws IOException {
|
||||
return listMembers("members");
|
||||
@@ -159,64 +307,233 @@ public class GHOrganization extends GHPerson {
|
||||
|
||||
/**
|
||||
* All the public members of this organization.
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHUser> listPublicMembers() throws IOException {
|
||||
return listMembers("public_members");
|
||||
}
|
||||
|
||||
private PagedIterable<GHUser> listMembers(String suffix) throws IOException {
|
||||
return listMembers(suffix, null);
|
||||
return listMembers(suffix, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* List members with filter paged iterable.
|
||||
*
|
||||
* @param filter
|
||||
* the filter
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHUser> listMembersWithFilter(String filter) throws IOException {
|
||||
return listMembers("members", filter);
|
||||
return listMembers("members", filter, null);
|
||||
}
|
||||
|
||||
private PagedIterable<GHUser> listMembers(final String suffix, final String filter) throws IOException {
|
||||
return new PagedIterable<GHUser>() {
|
||||
public PagedIterator<GHUser> _iterator(int pageSize) {
|
||||
String filterParams = (filter == null) ? "" : ("?filter=" + filter);
|
||||
return new PagedIterator<GHUser>(root.retrieve().asIterator(String.format("/orgs/%s/%s%s", login, suffix, filterParams), GHUser[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHUser[] users) {
|
||||
GHUser.wrap(users, root);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
/**
|
||||
* List members with specified role paged iterable.
|
||||
*
|
||||
* @param role
|
||||
* the role
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHUser> listMembersWithRole(String role) throws IOException {
|
||||
return listMembers("members", null, role);
|
||||
}
|
||||
|
||||
private PagedIterable<GHUser> listMembers(final String suffix, final String filter, String role)
|
||||
throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/orgs/%s/%s", login, suffix))
|
||||
.with("filter", filter)
|
||||
.with("role", role)
|
||||
.toIterable(GHUser[].class, item -> item.wrapUp(root));
|
||||
}
|
||||
|
||||
/**
|
||||
* Conceals the membership.
|
||||
*
|
||||
* @param u
|
||||
* the u
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void conceal(GHUser u) throws IOException {
|
||||
root.retrieve().method("DELETE").to("/orgs/" + login + "/public_members/" + u.getLogin(), null);
|
||||
root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();
|
||||
}
|
||||
|
||||
public enum Permission { ADMIN, PUSH, PULL }
|
||||
/**
|
||||
* Returns the projects for this organization.
|
||||
*
|
||||
* @param status
|
||||
* The status filter (all, open or closed).
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHProject> listProjects(final GHProject.ProjectStateFilter status) throws IOException {
|
||||
return root.createRequest()
|
||||
.withPreview(INERTIA)
|
||||
.with("state", status)
|
||||
.withUrlPath(String.format("/orgs/%s/projects", login))
|
||||
.toIterable(GHProject[].class, item -> item.wrap(root));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all open projects for the organization.
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHProject> listProjects() throws IOException {
|
||||
return listProjects(GHProject.ProjectStateFilter.OPEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a project for the organization.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param body
|
||||
* the body
|
||||
* @return the gh project
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHProject createProject(String name, String body) throws IOException {
|
||||
return root.createRequest()
|
||||
.method("POST")
|
||||
.withPreview(INERTIA)
|
||||
.with("name", name)
|
||||
.with("body", body)
|
||||
.withUrlPath(String.format("/orgs/%s/projects", login))
|
||||
.fetch(GHProject.class)
|
||||
.wrap(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* The enum Permission.
|
||||
*/
|
||||
public enum Permission {
|
||||
ADMIN, MAINTAIN, PUSH, TRIAGE, PULL
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new team and assigns the repositories.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param p
|
||||
* the p
|
||||
* @param repositories
|
||||
* the repositories
|
||||
* @return the gh team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
|
||||
* {@link #createTeam(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHTeam createTeam(String name, Permission p, Collection<GHRepository> repositories) throws IOException {
|
||||
Requester post = new Requester(root).with("name", name).with("permission", p);
|
||||
Requester post = root.createRequest().method("POST").with("name", name).with("permission", p);
|
||||
List<String> repo_names = new ArrayList<String>();
|
||||
for (GHRepository r : repositories) {
|
||||
repo_names.add(r.getName());
|
||||
repo_names.add(login + "/" + r.getName());
|
||||
}
|
||||
post.with("repo_names",repo_names);
|
||||
return post.method("POST").to("/orgs/" + login + "/teams", GHTeam.class).wrapUp(this);
|
||||
post.with("repo_names", repo_names);
|
||||
return post.withUrlPath("/orgs/" + login + "/teams").fetch(GHTeam.class).wrapUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create team gh team.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param p
|
||||
* the p
|
||||
* @param repositories
|
||||
* the repositories
|
||||
* @return the gh team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
|
||||
* {@link #createTeam(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHTeam createTeam(String name, Permission p, GHRepository... repositories) throws IOException {
|
||||
return createTeam(name, p, Arrays.asList(repositories));
|
||||
}
|
||||
|
||||
/**
|
||||
* List up repositories that has some open pull requests.
|
||||
* Creates a new team and assigns the repositories.
|
||||
*
|
||||
* This used to be an efficient method that didn't involve traversing every repository, but now
|
||||
* it doesn't do any optimization.
|
||||
* @param name
|
||||
* the name
|
||||
* @param repositories
|
||||
* the repositories
|
||||
* @return the gh team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated Use {@link #createTeam(String)} that uses a builder pattern to let you control every aspect.
|
||||
*/
|
||||
@Deprecated
|
||||
public GHTeam createTeam(String name, Collection<GHRepository> repositories) throws IOException {
|
||||
Requester post = root.createRequest().method("POST").with("name", name);
|
||||
List<String> repo_names = new ArrayList<String>();
|
||||
for (GHRepository r : repositories) {
|
||||
repo_names.add(login + "/" + r.getName());
|
||||
}
|
||||
post.with("repo_names", repo_names);
|
||||
return post.withUrlPath("/orgs/" + login + "/teams").fetch(GHTeam.class).wrapUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create team gh team.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param repositories
|
||||
* the repositories
|
||||
* @return the gh team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated Use {@link #createTeam(String)} that uses a builder pattern to let you control every aspect.
|
||||
*/
|
||||
@Deprecated
|
||||
public GHTeam createTeam(String name, GHRepository... repositories) throws IOException {
|
||||
return createTeam(name, Arrays.asList(repositories));
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a builder that creates a new team.
|
||||
*
|
||||
* <p>
|
||||
* You use the returned builder to set various properties, then call {@link GHTeamBuilder#create()} to finally
|
||||
* create a team.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @return the gh create repository builder
|
||||
*/
|
||||
public GHTeamBuilder createTeam(String name) {
|
||||
return new GHTeamBuilder(root, login, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* List up repositories that has some open pull requests.
|
||||
* <p>
|
||||
* This used to be an efficient method that didn't involve traversing every repository, but now it doesn't do any
|
||||
* optimization.
|
||||
*
|
||||
* @return the repositories with open pull requests
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHRepository> getRepositoriesWithOpenPullRequests() throws IOException {
|
||||
List<GHRepository> r = new ArrayList<GHRepository>();
|
||||
@@ -232,6 +549,10 @@ public class GHOrganization extends GHPerson {
|
||||
|
||||
/**
|
||||
* Gets all the open pull requests in this organizataion.
|
||||
*
|
||||
* @return the pull requests
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHPullRequest> getPullRequests() throws IOException {
|
||||
List<GHPullRequest> all = new ArrayList<GHPullRequest>();
|
||||
@@ -245,72 +566,96 @@ public class GHOrganization extends GHPerson {
|
||||
* Lists events performed by a user (this includes private events if the caller is authenticated.
|
||||
*/
|
||||
public PagedIterable<GHEventInfo> listEvents() throws IOException {
|
||||
return new PagedIterable<GHEventInfo>() {
|
||||
public PagedIterator<GHEventInfo> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHEventInfo>(root.retrieve().asIterator(String.format("/orgs/%s/events", login), GHEventInfo[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHEventInfo[] page) {
|
||||
for (GHEventInfo c : page)
|
||||
c.wrapUp(root);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/orgs/%s/events", login))
|
||||
.toIterable(GHEventInfo[].class, item -> item.wrapUp(root));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists up all the repositories using the specified page size.
|
||||
*
|
||||
* @param pageSize size for each page of items returned by GitHub. Maximum page size is 100.
|
||||
* @param pageSize
|
||||
* size for each page of items returned by GitHub. Maximum page size is 100.
|
||||
*
|
||||
* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned.
|
||||
* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned.
|
||||
*/
|
||||
@Override
|
||||
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
|
||||
return new PagedIterable<GHRepository>() {
|
||||
public PagedIterator<GHRepository> _iterator(int pageSize) {
|
||||
return new PagedIterator<GHRepository>(root.retrieve().asIterator("/orgs/" + login + "/repos?per_page=" + pageSize, GHRepository[].class, pageSize)) {
|
||||
@Override
|
||||
protected void wrapUp(GHRepository[] page) {
|
||||
for (GHRepository c : page)
|
||||
c.wrap(root);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
return root.createRequest()
|
||||
.withUrlPath("/orgs/" + login + "/repos")
|
||||
.toIterable(GHRepository[].class, item -> item.wrap(root))
|
||||
.withPageSize(pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the currently configured hooks.
|
||||
*
|
||||
* @return the hooks
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHHook> getHooks() throws IOException {
|
||||
return GHHooks.orgContext(this).getHooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets hook.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @return the hook
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHHook getHook(int id) throws IOException {
|
||||
return GHHooks.orgContext(this).getHook(id);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* See https://api.github.com/hooks for possible names and their configuration scheme.
|
||||
* TODO: produce type-safe binding
|
||||
* See https://api.github.com/hooks for possible names and their configuration scheme. TODO: produce type-safe
|
||||
* binding
|
||||
*
|
||||
* @param name
|
||||
* Type of the hook to be created. See https://api.github.com/hooks for possible names.
|
||||
* Type of the hook to be created. See https://api.github.com/hooks for possible names.
|
||||
* @param config
|
||||
* The configuration hash.
|
||||
* The configuration hash.
|
||||
* @param events
|
||||
* Can be null. Types of events to hook into.
|
||||
* Can be null. Types of events to hook into.
|
||||
* @param active
|
||||
* the active
|
||||
* @return the gh hook
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHHook createHook(String name, Map<String,String> config, Collection<GHEvent> events, boolean active) throws IOException {
|
||||
public GHHook createHook(String name, Map<String, String> config, Collection<GHEvent> events, boolean active)
|
||||
throws IOException {
|
||||
return GHHooks.orgContext(this).createHook(name, config, events, active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create web hook gh hook.
|
||||
*
|
||||
* @param url
|
||||
* the url
|
||||
* @param events
|
||||
* the events
|
||||
* @return the gh hook
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHHook createWebHook(URL url, Collection<GHEvent> events) throws IOException {
|
||||
return createHook("web", Collections.singletonMap("url", url.toExternalForm()),events,true);
|
||||
return createHook("web", Collections.singletonMap("url", url.toExternalForm()), events, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create web hook gh hook.
|
||||
*
|
||||
* @param url
|
||||
* the url
|
||||
* @return the gh hook
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHHook createWebHook(URL url) throws IOException {
|
||||
return createWebHook(url, null);
|
||||
}
|
||||
|
||||
@@ -28,24 +28,37 @@ 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>
|
||||
*/
|
||||
/*package*/ class GHPermission {
|
||||
class GHPermission {
|
||||
|
||||
private String permission;
|
||||
private GHUser user;
|
||||
|
||||
/**
|
||||
* Gets permission.
|
||||
*
|
||||
* @return one of {@code admin}, {@code write}, {@code read}, or {@code none}
|
||||
*/
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets permission type.
|
||||
*
|
||||
* @return the permission type
|
||||
*/
|
||||
public GHPermissionType getPermissionType() {
|
||||
return Enum.valueOf(GHPermissionType.class, permission.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user.
|
||||
*
|
||||
* @return the user
|
||||
*/
|
||||
public GHUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user