mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
Compare commits
1120 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
598f289311 | ||
|
|
447288db9d | ||
|
|
2b8c2a5c06 | ||
|
|
6fd3a73268 | ||
|
|
4536e42949 | ||
|
|
fc575388f1 | ||
|
|
1044d1cc32 | ||
|
|
253eabf2f2 | ||
|
|
8219d57b92 | ||
|
|
89381d3314 | ||
|
|
2e1037e107 | ||
|
|
0a77c71278 | ||
|
|
275101d11b | ||
|
|
bfd7f3b2bc | ||
|
|
21fcedf000 | ||
|
|
d963070f73 | ||
|
|
8174c89f9e | ||
|
|
5bdc74f0a6 | ||
|
|
b259386b67 | ||
|
|
984b52e7ec | ||
|
|
d36ef805f6 | ||
|
|
02bdbd281b | ||
|
|
b3cca9ea91 | ||
|
|
7409c08122 | ||
|
|
339b54cd4b | ||
|
|
1bbdf4917b | ||
|
|
465ed988a9 | ||
|
|
d5d7fe47d5 | ||
|
|
81d14dfaf2 | ||
|
|
302da30746 | ||
|
|
e9110aac80 | ||
|
|
6d104bd585 | ||
|
|
7c47462de8 | ||
|
|
cc8b83cbc5 | ||
|
|
07decd00a0 | ||
|
|
7c3e82f4dd | ||
|
|
95c31dd7b7 | ||
|
|
5ea905e3a2 | ||
|
|
e40d1f42c7 | ||
|
|
aa00351606 | ||
|
|
6311a1f146 | ||
|
|
1517e1f580 | ||
|
|
833f3584c2 | ||
|
|
cdc67bffcb | ||
|
|
52794aa9ea | ||
|
|
9ea3670a56 | ||
|
|
652ec3e029 | ||
|
|
b543bae958 | ||
|
|
4f574cdbcd | ||
|
|
29fc2a666b | ||
|
|
4498c016a4 | ||
|
|
31a1d46175 | ||
|
|
e3904ebdfe | ||
|
|
6e5ffdf658 | ||
|
|
5d0531f00d | ||
|
|
01ea533b97 | ||
|
|
86fc492668 | ||
|
|
3a78356019 | ||
|
|
44f7931ae6 | ||
|
|
7094f99a85 | ||
|
|
550c4a6e60 | ||
|
|
64aeb422c8 | ||
|
|
c2265dc44c | ||
|
|
507085cd56 | ||
|
|
36ef7ddf94 | ||
|
|
be1fbc8594 | ||
|
|
d73eacfa5d | ||
|
|
5d495cfa12 | ||
|
|
acaadff6cb | ||
|
|
e22371e4a5 | ||
|
|
81c426b112 | ||
|
|
1481872ddb | ||
|
|
523da8afb9 | ||
|
|
828dcb7173 | ||
|
|
eaf7bfb78d | ||
|
|
cbcf5ce4b6 | ||
|
|
36dce286b5 | ||
|
|
8ffe75786e | ||
|
|
5d63bc71aa | ||
|
|
37f8f7edda | ||
|
|
fd1c85afb2 | ||
|
|
c08bb6e89f | ||
|
|
d25889f6d2 | ||
|
|
dabddf60b1 | ||
|
|
c7ade7ec4d | ||
|
|
9caa73a585 | ||
|
|
0ee849c73d | ||
|
|
7883d8fd1e | ||
|
|
783ddfffa3 | ||
|
|
24b7cade49 | ||
|
|
51554d4325 | ||
|
|
90bcbd212b | ||
|
|
4ca3816522 | ||
|
|
fc4819cb29 | ||
|
|
5291df8e03 | ||
|
|
5afb0094f6 | ||
|
|
e76813cbee | ||
|
|
bc6398ca3b | ||
|
|
3d5ca44d66 | ||
|
|
8cd7068131 | ||
|
|
0db23b7f4a | ||
|
|
66d9ce328d | ||
|
|
36de0b3097 | ||
|
|
4f3cd26cf4 | ||
|
|
561e1bfec7 | ||
|
|
de64206a82 | ||
|
|
65ddffde89 | ||
|
|
1bc6ddc1a3 | ||
|
|
a404bd0776 | ||
|
|
ccbdd383ae | ||
|
|
acb846e885 | ||
|
|
fa23b4c89e | ||
|
|
a70e1f53b5 | ||
|
|
176deb4930 | ||
|
|
6e26d090ed | ||
|
|
070f74e7dc | ||
|
|
bcd78b3e5b | ||
|
|
be8f45ce49 | ||
|
|
baa96408a8 | ||
|
|
d2a7548f73 | ||
|
|
31e3fc64fc | ||
|
|
01a9883847 | ||
|
|
3cf2bea01e | ||
|
|
7caf11ae83 | ||
|
|
b22bc6fef0 | ||
|
|
88533c5807 | ||
|
|
53d955f198 | ||
|
|
724550ec5f | ||
|
|
1a63eff8f9 | ||
|
|
cf1b245229 | ||
|
|
c54a76c9b4 | ||
|
|
1a7213e2f0 | ||
|
|
a386cda024 | ||
|
|
f414bb4c79 | ||
|
|
6a51c7414a | ||
|
|
9718a67a74 | ||
|
|
179f86c904 | ||
|
|
e6ae6fc17d | ||
|
|
1f42b52cfd | ||
|
|
cdff342e3d | ||
|
|
daa8b6acf2 | ||
|
|
2ae72c6db4 | ||
|
|
9e3204d546 | ||
|
|
59e560b8e1 | ||
|
|
186269f8ff | ||
|
|
e441c40429 | ||
|
|
e1fa85848c | ||
|
|
8d66348634 | ||
|
|
f16b7d2c9b | ||
|
|
0ae8cc2820 | ||
|
|
ca25e7fe90 | ||
|
|
2692e29716 | ||
|
|
b71ccfbcc5 | ||
|
|
659a157cb7 | ||
|
|
f22fab32cc | ||
|
|
631e418733 | ||
|
|
0f57da14e4 | ||
|
|
424790e686 | ||
|
|
5dc43a7f75 | ||
|
|
debb131623 | ||
|
|
e3e21e9590 | ||
|
|
42fa7ea74d | ||
|
|
8ada3dde04 | ||
|
|
d43a666dfc | ||
|
|
5b266229c3 | ||
|
|
d8b0062f2b | ||
|
|
7f0859c0a3 | ||
|
|
38c7fbf589 | ||
|
|
41335964b7 | ||
|
|
c5464b2099 | ||
|
|
dc49b0dace | ||
|
|
365f30b76b | ||
|
|
ff1bc0fbca | ||
|
|
41d55372b5 | ||
|
|
ba8e5fe3cb | ||
|
|
6e692f70b7 | ||
|
|
aab979b78b | ||
|
|
9b7856464a | ||
|
|
903008b417 | ||
|
|
515cf86e4f | ||
|
|
c0b9eb8789 | ||
|
|
fefbf92f83 | ||
|
|
006fae36c9 | ||
|
|
281f7f37d8 | ||
|
|
36c6dd979f | ||
|
|
9f44015003 | ||
|
|
e719533ed9 | ||
|
|
773221d65b | ||
|
|
6beacb6af3 | ||
|
|
f11b92d391 | ||
|
|
def222d035 | ||
|
|
5dee7a9057 | ||
|
|
c20cc1271c | ||
|
|
843d429cb2 | ||
|
|
372e17ea2b | ||
|
|
5490e82411 | ||
|
|
d30a5d2f92 | ||
|
|
ef69763749 | ||
|
|
59d1250e36 | ||
|
|
33bf0b7b31 | ||
|
|
884cd498ce | ||
|
|
e0b021cb3e | ||
|
|
57edf101fa | ||
|
|
a2bf0d86d8 | ||
|
|
32e2ea5061 | ||
|
|
e28c0592f6 | ||
|
|
60627060d5 | ||
|
|
cea4d7e15f | ||
|
|
ca1670b21a | ||
|
|
c9c72faaf1 | ||
|
|
ba42538775 | ||
|
|
39141d8996 | ||
|
|
e3dd099bbb | ||
|
|
6b37d1027f | ||
|
|
b521f43c84 | ||
|
|
7c5a9df759 | ||
|
|
04762a3e53 | ||
|
|
d2ba2df2ba | ||
|
|
0e7f34f1d7 | ||
|
|
d576bbfaed | ||
|
|
2bfdca6992 | ||
|
|
d18fdb6399 | ||
|
|
fe02605544 | ||
|
|
f86ae20791 | ||
|
|
df69f88186 | ||
|
|
8d1323f354 | ||
|
|
2f598b618b | ||
|
|
baf0b0b92c | ||
|
|
27a75250a6 | ||
|
|
15f60402a5 | ||
|
|
41c6fc90b3 | ||
|
|
34356b04a8 | ||
|
|
2ca02b6539 | ||
|
|
cd0c71dffb | ||
|
|
a59120fe19 | ||
|
|
fdc35f48ed | ||
|
|
bae9b7ddc3 | ||
|
|
3dd9b7e587 | ||
|
|
44c905bdab | ||
|
|
5214040257 | ||
|
|
7ad9f901dd | ||
|
|
f472d52954 | ||
|
|
1e752af41b | ||
|
|
3ba46c3fc6 | ||
|
|
bf83da476f | ||
|
|
6b8c4cf8d0 | ||
|
|
445329c07a | ||
|
|
8f370e19c6 | ||
|
|
736dbcfb58 | ||
|
|
c1cb7f87e0 | ||
|
|
3c14fcefc9 | ||
|
|
831badf8db | ||
|
|
5f8a6e8d24 | ||
|
|
a3981493f7 | ||
|
|
6919cf5d4d | ||
|
|
f6d1e6bdd6 | ||
|
|
a13ff89acd | ||
|
|
cd5c76279a | ||
|
|
debff5e4b8 | ||
|
|
433e207ec5 | ||
|
|
3775f6a907 | ||
|
|
10d611c0eb | ||
|
|
963bc4d672 | ||
|
|
e68a21ee30 | ||
|
|
d5c083b70f | ||
|
|
2deb9cf417 | ||
|
|
fca0cfcdc7 | ||
|
|
1466e1bdb3 | ||
|
|
dd48bc443a | ||
|
|
f455738e5f | ||
|
|
85193803cd | ||
|
|
4e90a6074a | ||
|
|
ca94fa5184 | ||
|
|
f14a7c996f | ||
|
|
989d22f4d8 | ||
|
|
400a812343 | ||
|
|
97284f1ced | ||
|
|
5e6a0d7e16 | ||
|
|
599e11245f | ||
|
|
538d714c96 | ||
|
|
953915ba2a | ||
|
|
1a2f5da055 | ||
|
|
749a469d37 | ||
|
|
c7d084321a | ||
|
|
00a61cd6cf | ||
|
|
d9c6c13c62 | ||
|
|
5260c5e889 | ||
|
|
1700f96c62 | ||
|
|
5a0f9f8bbb | ||
|
|
8fa22b4de2 | ||
|
|
d17cae16fd | ||
|
|
c4c48962cf | ||
|
|
4140e92f0b | ||
|
|
887e560a1b | ||
|
|
e2d70181e8 | ||
|
|
148c453dbc | ||
|
|
f6ee9d311d | ||
|
|
35209e43bb | ||
|
|
4a3ecf063d | ||
|
|
4c79101624 | ||
|
|
921b01661b | ||
|
|
c63301d8e6 | ||
|
|
c9ed9d2237 | ||
|
|
ca55cbe456 | ||
|
|
d4828613ee | ||
|
|
a0be02ce2f | ||
|
|
9b8016a4d5 | ||
|
|
8fdd3bfd21 | ||
|
|
695a061e3c | ||
|
|
bd50d9218e | ||
|
|
d8f13bc1ce | ||
|
|
ed84d1a3c9 | ||
|
|
3c765d879c | ||
|
|
4c76b6dd96 | ||
|
|
7e66917993 | ||
|
|
eb0f985399 | ||
|
|
3a2908c3a3 | ||
|
|
f13c10859f | ||
|
|
8e8a314c91 | ||
|
|
dad0478b87 | ||
|
|
240b34016d | ||
|
|
2c164d630c | ||
|
|
3d12a9038f | ||
|
|
71fc02b5cd | ||
|
|
74caaa3d94 | ||
|
|
e024c12521 | ||
|
|
1d0c364947 | ||
|
|
88e59405c5 | ||
|
|
8160c93c15 | ||
|
|
3c8113d607 | ||
|
|
8e2f421e76 | ||
|
|
56df833b4a | ||
|
|
119d7d0be0 | ||
|
|
d4d2ca19a1 | ||
|
|
4ce5597d67 | ||
|
|
17888327b3 | ||
|
|
997def54ab | ||
|
|
a407e75459 | ||
|
|
cece53aad9 | ||
|
|
a2d63bc5f8 | ||
|
|
0c81c63ab7 | ||
|
|
3e8f1eee22 | ||
|
|
a91d1def45 | ||
|
|
032e6d1c57 | ||
|
|
93eb133cba | ||
|
|
b7b78842da | ||
|
|
8100ccaf5f | ||
|
|
936e1c0e96 | ||
|
|
1a7274e475 | ||
|
|
ac7b83b6ed | ||
|
|
e298279032 | ||
|
|
f7e58c28c6 | ||
|
|
18f3bc4056 | ||
|
|
4638f82889 | ||
|
|
4396b6eab5 | ||
|
|
594ae2bb7e | ||
|
|
429cf54bd4 | ||
|
|
274357abc4 | ||
|
|
0e21247755 | ||
|
|
37f2868ff3 | ||
|
|
6a85e25a62 | ||
|
|
a91b1c7e79 | ||
|
|
bfd9ecd130 | ||
|
|
ec888e94fd | ||
|
|
a19c80bef2 | ||
|
|
7b9ade2698 | ||
|
|
d03f28eeb9 | ||
|
|
288dd788bc | ||
|
|
2069a5a931 | ||
|
|
8a434cbd15 | ||
|
|
faafe49848 | ||
|
|
17a72292ce | ||
|
|
9ae09f1801 | ||
|
|
abbba17e4b | ||
|
|
479d5da17e | ||
|
|
dec7890d04 | ||
|
|
61910a6667 | ||
|
|
ac2119ac3b | ||
|
|
8c71cd7369 | ||
|
|
ec8b6ff18f | ||
|
|
e214804d57 | ||
|
|
39448f2e3c | ||
|
|
79dc6fc247 | ||
|
|
a800f305f2 | ||
|
|
67e0fb6b3f | ||
|
|
e401d30159 | ||
|
|
504e651828 | ||
|
|
7a8da2f074 | ||
|
|
1e47e96634 | ||
|
|
69502480b4 | ||
|
|
5833e3fcca | ||
|
|
4e47ffb1d2 | ||
|
|
3056333a7c | ||
|
|
ad0cd7f625 | ||
|
|
dedaa263ce | ||
|
|
bccf729102 | ||
|
|
a244c61e56 | ||
|
|
37594935f0 | ||
|
|
e521c2158b | ||
|
|
b1c8a8c76e | ||
|
|
8d92f210f0 | ||
|
|
287281923c | ||
|
|
6f18135574 | ||
|
|
58cf9bec3b | ||
|
|
b7a45e9901 | ||
|
|
f5585b39c6 | ||
|
|
9c3ef37274 | ||
|
|
e904c0b689 | ||
|
|
237f97f069 | ||
|
|
1eb2a04090 | ||
|
|
cda6106858 | ||
|
|
8c4ce5e5f4 | ||
|
|
b5ee6431c4 | ||
|
|
bd06e6d4dc | ||
|
|
3b607e74ed | ||
|
|
dc16474ed3 | ||
|
|
dc0f088be0 | ||
|
|
2718e10044 | ||
|
|
4213dcb8a2 | ||
|
|
39afb31200 | ||
|
|
8e1ce1c96a | ||
|
|
fdfd8293d6 | ||
|
|
b7d3be6a14 | ||
|
|
bb5c809749 | ||
|
|
a2cbe7cbf5 | ||
|
|
b1fb09ac99 | ||
|
|
201ae7e7db | ||
|
|
2978decb84 | ||
|
|
5fbbd4d5f3 | ||
|
|
4abd363f62 | ||
|
|
8288db60a9 | ||
|
|
6cdf679571 | ||
|
|
51179acc12 | ||
|
|
1ff27d3e17 | ||
|
|
1e9bce3d5a | ||
|
|
8811ea2b58 | ||
|
|
be7cdd0a28 | ||
|
|
611a05aa48 | ||
|
|
9f95a757a2 | ||
|
|
58b577453c | ||
|
|
78acfd87e8 | ||
|
|
bf9cb26164 | ||
|
|
68a99ada0b | ||
|
|
1d841ce171 | ||
|
|
ccfdbfd276 | ||
|
|
70d584d56d | ||
|
|
a49ffb07be | ||
|
|
baa9caf010 | ||
|
|
22025c875f | ||
|
|
3806995a50 | ||
|
|
94d2650491 | ||
|
|
844f24afa4 | ||
|
|
083396a8e4 | ||
|
|
e02769056b | ||
|
|
024f8e8d80 | ||
|
|
3b4a7c3c47 | ||
|
|
d9838d9cba | ||
|
|
b3ca4468cd | ||
|
|
452e41603a | ||
|
|
b41de4a770 | ||
|
|
3423d2f2f3 | ||
|
|
9269acc64d | ||
|
|
18b5f20f1c | ||
|
|
68d592a8ff | ||
|
|
ee18d96f98 | ||
|
|
6d3687cbdf | ||
|
|
1ef1a2983b | ||
|
|
47850fe0fa | ||
|
|
055a37cac0 | ||
|
|
333deb4756 | ||
|
|
34cde4b09a | ||
|
|
5091b4838c | ||
|
|
2e83289061 | ||
|
|
e11f651002 | ||
|
|
be684a567d | ||
|
|
97e552b10f | ||
|
|
5bb8046c32 | ||
|
|
e7192655f7 | ||
|
|
19ba09740c | ||
|
|
d169777722 | ||
|
|
ff8a5f6b77 | ||
|
|
ec953df156 | ||
|
|
d6a191d95b | ||
|
|
aba428bba1 | ||
|
|
6ab37fd596 | ||
|
|
73fc70f55b | ||
|
|
aad18b7a50 | ||
|
|
cc278be5cd | ||
|
|
d0f4f82a0f | ||
|
|
1dcbf386b1 | ||
|
|
414afd285c | ||
|
|
35b645d8b5 | ||
|
|
b3cba53866 | ||
|
|
a4773bb3ca | ||
|
|
863d8a4af5 | ||
|
|
3fccd7b53c | ||
|
|
dd2760eaf7 | ||
|
|
824bafa739 | ||
|
|
60cdaec05f | ||
|
|
c204a435b3 | ||
|
|
37accd92d6 | ||
|
|
01fd0ee1f0 | ||
|
|
fab1c74473 | ||
|
|
0d8fcfd28d | ||
|
|
b91a7c32a6 | ||
|
|
7f665c649b | ||
|
|
dcbadb4071 | ||
|
|
e3096d15ff | ||
|
|
a83c24e7b3 | ||
|
|
73457c9658 | ||
|
|
cfc8d9f3f1 | ||
|
|
8f423b83ea | ||
|
|
1e7ac532b6 | ||
|
|
0fd1db4596 | ||
|
|
0755b7ab7f | ||
|
|
052382e5c4 | ||
|
|
f44a63cec1 | ||
|
|
603d67354a | ||
|
|
aafa423b9f | ||
|
|
2da9d0a801 | ||
|
|
b60c112a74 | ||
|
|
843ed6df37 | ||
|
|
0f0a849677 | ||
|
|
682901ccbb | ||
|
|
048fdb8837 | ||
|
|
3353616789 | ||
|
|
b6cb4c865f | ||
|
|
1fcfd093f7 | ||
|
|
3f27c6e733 | ||
|
|
b6bd9bfc3b | ||
|
|
6c392f0056 | ||
|
|
9a38de9a23 | ||
|
|
8883600090 | ||
|
|
ab822a3c27 | ||
|
|
0e4d64de23 | ||
|
|
fbc6bd36bd | ||
|
|
ed90ca2dce | ||
|
|
537ef92149 | ||
|
|
d51afa7d40 | ||
|
|
975cffff48 | ||
|
|
d92e9c00e8 | ||
|
|
12d72cbb19 | ||
|
|
e7a6f0930b | ||
|
|
d8e03bed1f | ||
|
|
f48c087cd8 | ||
|
|
917663e0df | ||
|
|
556ddbc926 | ||
|
|
1c6f37b8e8 | ||
|
|
720a329a50 | ||
|
|
220a8f076a | ||
|
|
43be8333c7 | ||
|
|
08706ab4df | ||
|
|
b1196657e0 | ||
|
|
334bd0c919 | ||
|
|
cf0f896972 | ||
|
|
d21ca3ff8a | ||
|
|
83f1f16de7 | ||
|
|
0fa2ccf107 | ||
|
|
18e3dd431b | ||
|
|
f25dee2249 | ||
|
|
575ffa9580 | ||
|
|
f17af5aeb0 | ||
|
|
639f153589 | ||
|
|
fb07098c13 | ||
|
|
74fc08b039 | ||
|
|
2776e00004 | ||
|
|
5932fce303 | ||
|
|
39c9fc4261 | ||
|
|
89ea4509a3 | ||
|
|
d19d838ead | ||
|
|
633a2699a8 | ||
|
|
e79bca4a3c | ||
|
|
f8ab480d20 | ||
|
|
a14129e340 | ||
|
|
5ec39df6e0 | ||
|
|
956e0c6321 | ||
|
|
0660a9203a | ||
|
|
1b660272a1 | ||
|
|
d9ef9b874d | ||
|
|
7824f796ee | ||
|
|
838a8d4c7b | ||
|
|
8db9f77f91 | ||
|
|
4f82a469d9 | ||
|
|
0f6ae8559b | ||
|
|
3f4b2eec35 | ||
|
|
a020601d3a | ||
|
|
d511205588 | ||
|
|
fc896b2ea1 | ||
|
|
3819670535 | ||
|
|
067669a18c | ||
|
|
bef7cee8db | ||
|
|
cb9f56fc22 | ||
|
|
719a521f06 | ||
|
|
413754976f | ||
|
|
4530cfc068 | ||
|
|
fcc7d6da2d | ||
|
|
33e565d029 | ||
|
|
6a1da37e9a | ||
|
|
897cc5eea4 | ||
|
|
5cbea281af | ||
|
|
e74db57b75 | ||
|
|
6b2d124d09 | ||
|
|
7b3c77db8c | ||
|
|
1bcab5c2c7 | ||
|
|
16020e9a7d | ||
|
|
dfd3e22986 | ||
|
|
48d7a20fb7 | ||
|
|
04108a0a1a | ||
|
|
e0bab59846 | ||
|
|
1004c83bc4 | ||
|
|
502bb450e3 | ||
|
|
fb03b0bec7 | ||
|
|
2c3a1c9c92 | ||
|
|
73b7ee2d57 | ||
|
|
71df890f39 | ||
|
|
1fdac404b1 | ||
|
|
47be1e60bb | ||
|
|
1c05f50954 | ||
|
|
ce26a48fd7 | ||
|
|
26e0838ae0 | ||
|
|
6b5b0db20a | ||
|
|
5973c8cb85 | ||
|
|
f683439c73 | ||
|
|
625f3655ec | ||
|
|
4a5ab1ae71 | ||
|
|
3bcae2c6d2 | ||
|
|
4441eff657 | ||
|
|
9fed83e222 | ||
|
|
42ea9bac65 | ||
|
|
2aba827772 | ||
|
|
31e84bd543 | ||
|
|
ba471b8bf7 | ||
|
|
90ec95494d | ||
|
|
e72dbad765 | ||
|
|
ed63ea4674 | ||
|
|
559a52404f | ||
|
|
5e80848524 | ||
|
|
055a4f0798 | ||
|
|
6f432e537c | ||
|
|
a2abbbbd63 | ||
|
|
16707b99e6 | ||
|
|
80a4ed62cc | ||
|
|
b713a334f0 | ||
|
|
ec6264c04c | ||
|
|
44bb1ab565 | ||
|
|
523ee025ac | ||
|
|
d193c6399c | ||
|
|
8c9715f4d9 | ||
|
|
3bbdcd5f14 | ||
|
|
c183d3b0b5 | ||
|
|
b6f0c6bf57 | ||
|
|
8719e834f3 | ||
|
|
f23b8c6d61 | ||
|
|
d46be31ea8 | ||
|
|
9bb36e4cb2 | ||
|
|
2780fb9605 | ||
|
|
b69e2d299a | ||
|
|
a07bd7b1a4 | ||
|
|
d605455678 | ||
|
|
781b1169a2 | ||
|
|
80112d3437 | ||
|
|
131af7f4fa | ||
|
|
1ceac4ef9f | ||
|
|
b7aa3e69f4 | ||
|
|
62231c41b2 | ||
|
|
6c0a33712b | ||
|
|
e192624489 | ||
|
|
68609e44de | ||
|
|
c8e3af6072 | ||
|
|
9f7048a19c | ||
|
|
cbdc0528ca | ||
|
|
444facc95b | ||
|
|
ed40ddaa45 | ||
|
|
43c629b3e5 | ||
|
|
0d2c156579 | ||
|
|
ab218f8540 | ||
|
|
4b8a375890 | ||
|
|
9c3a5f3f0a | ||
|
|
1bcfbec29c | ||
|
|
781940436a | ||
|
|
7f226a6ab1 | ||
|
|
f538950d64 | ||
|
|
142be65893 | ||
|
|
8b01e5bc1f | ||
|
|
bde0aab207 | ||
|
|
31ecfef1c9 | ||
|
|
0fdae4c334 | ||
|
|
3ea7de974b | ||
|
|
34a7990d1d | ||
|
|
709d759d09 | ||
|
|
2d47252b27 | ||
|
|
8586e141fc | ||
|
|
e3887e6872 | ||
|
|
fd658c35ee | ||
|
|
ca4c1b237f | ||
|
|
92b17fd719 | ||
|
|
b4453531a3 | ||
|
|
de72a9223f | ||
|
|
ae26e3031e | ||
|
|
c26b41cfc2 | ||
|
|
2c4ee664ab | ||
|
|
911cd45965 | ||
|
|
320cc58c62 | ||
|
|
cfa1638e3c | ||
|
|
27264bf59a | ||
|
|
935283272e | ||
|
|
ea440294b1 | ||
|
|
df8435bf6a | ||
|
|
4fe019b11f | ||
|
|
538c79705a | ||
|
|
e94d972741 | ||
|
|
c58a9aca6a | ||
|
|
a6612e8522 | ||
|
|
bd455b9a0a | ||
|
|
122853f1f6 | ||
|
|
debbc21bf3 | ||
|
|
d991fdcbd9 | ||
|
|
78cc8f14fd | ||
|
|
09f1a06267 | ||
|
|
6fb910a939 | ||
|
|
9e891a0168 | ||
|
|
0bc77ce453 | ||
|
|
a46c821673 | ||
|
|
cae843d18f | ||
|
|
40ffc689b0 | ||
|
|
65afbd25b8 | ||
|
|
458b30610f | ||
|
|
a89608a2e2 | ||
|
|
0f45311d5e | ||
|
|
447ed6ce88 | ||
|
|
ab358a10bc | ||
|
|
5148851d49 | ||
|
|
068ecd30fe | ||
|
|
5396c0ee58 | ||
|
|
2328c1878b | ||
|
|
bc9a6f464a | ||
|
|
4613fd4cb4 | ||
|
|
ff89c8805c | ||
|
|
95d98c525b | ||
|
|
bc78a38570 | ||
|
|
8db2398dd8 | ||
|
|
e073ca74da | ||
|
|
50e899bf83 | ||
|
|
5ddd6234e3 | ||
|
|
84fa11b5df | ||
|
|
f51db60fc7 | ||
|
|
351e72e8c2 | ||
|
|
a0f54b0b8e | ||
|
|
4c491e40c7 | ||
|
|
54440d9cde | ||
|
|
ea8333844c | ||
|
|
fc34df7008 | ||
|
|
d49d62edfc | ||
|
|
246e2e2de4 | ||
|
|
83b48d26ce | ||
|
|
3d40094925 | ||
|
|
2d7e8526ed | ||
|
|
7768f4c4dd | ||
|
|
e43fabf895 | ||
|
|
7cf83979a6 | ||
|
|
1ecc30c570 | ||
|
|
ee0721f40d | ||
|
|
07836edf84 | ||
|
|
bfbe40e027 | ||
|
|
842d3b6185 | ||
|
|
086437ca4f | ||
|
|
6e48435f38 | ||
|
|
3b8e903cb5 | ||
|
|
55308f2deb | ||
|
|
a913a95d5b | ||
|
|
870a20721c | ||
|
|
df81f6e364 | ||
|
|
d4a892bf7f | ||
|
|
41d13db5d4 | ||
|
|
c63e20ce7d | ||
|
|
736fdafea4 | ||
|
|
1dfe76e21c | ||
|
|
e7ddfc7ebb | ||
|
|
66be84289d | ||
|
|
2a3c8e0712 | ||
|
|
d3a29b3ecb | ||
|
|
7a50a15748 | ||
|
|
9a1b55b992 | ||
|
|
828b798c0e | ||
|
|
8d8845536d | ||
|
|
f20497e769 | ||
|
|
6053d9826e | ||
|
|
85263474a7 | ||
|
|
c02a722799 | ||
|
|
ce4faceccc | ||
|
|
04c8f8b864 | ||
|
|
1b32e13113 | ||
|
|
401728d47f | ||
|
|
31ace89f43 | ||
|
|
995cb86e90 | ||
|
|
e27623ca29 | ||
|
|
ea4da561c5 | ||
|
|
2e8f3efafd | ||
|
|
f25cf5781c | ||
|
|
d97f7c6025 | ||
|
|
e91d903650 | ||
|
|
4f93f06de5 | ||
|
|
08ed3c4171 | ||
|
|
5193d82980 | ||
|
|
eab82bf1be | ||
|
|
311d758910 | ||
|
|
097a2d32b8 | ||
|
|
a34766ccfd | ||
|
|
147eef9ee5 | ||
|
|
49118662b2 | ||
|
|
5989f2e2cb | ||
|
|
127f034bba | ||
|
|
e1e00c4b94 | ||
|
|
eb64cdd9cd | ||
|
|
1bfa8dffb8 | ||
|
|
33361b8015 | ||
|
|
b5ee074075 | ||
|
|
cbddc34bfa | ||
|
|
61504ae9e3 | ||
|
|
3049f6010c | ||
|
|
d4e01d631f | ||
|
|
a46aa2c61c | ||
|
|
ad147e8dd5 | ||
|
|
3555519392 | ||
|
|
f6a5def638 | ||
|
|
0590cb7048 | ||
|
|
b35d0792aa | ||
|
|
0d20bc0173 | ||
|
|
851141c2f4 | ||
|
|
31a104a697 | ||
|
|
bfc44cff98 | ||
|
|
0da781c33d | ||
|
|
8dbcbb5485 | ||
|
|
7544f64c65 | ||
|
|
73d05aefad | ||
|
|
4d70b056ad | ||
|
|
b81ce41d51 | ||
|
|
a143683d7f | ||
|
|
5ba38057dc | ||
|
|
07eb2bc41e | ||
|
|
5e4d041295 | ||
|
|
4d7fc061a4 | ||
|
|
8db98d7b16 | ||
|
|
a6063c8aa9 | ||
|
|
2cc1336e82 | ||
|
|
308bda2050 | ||
|
|
36989c38d4 | ||
|
|
29357ae170 | ||
|
|
36643bcdd0 | ||
|
|
72e40a0b12 | ||
|
|
2194ff7625 | ||
|
|
b247864bfe | ||
|
|
b1c3ae4974 | ||
|
|
81c0e2037f | ||
|
|
6224ec2a7b | ||
|
|
9ff4507fe2 | ||
|
|
67667dbff1 | ||
|
|
1a4961c3e1 | ||
|
|
561220237f | ||
|
|
f45b85aa71 | ||
|
|
83b3a7983e | ||
|
|
63d4c5054e | ||
|
|
c8f6017be9 | ||
|
|
f9fcb54861 | ||
|
|
3534b7172d | ||
|
|
42a7f974e9 | ||
|
|
b8e02d995a | ||
|
|
e0d038aa92 | ||
|
|
3d01df2bdc | ||
|
|
6f08f1fd23 | ||
|
|
3dd366b394 | ||
|
|
8cf4528959 | ||
|
|
5d77bc5d98 | ||
|
|
572c9ef558 | ||
|
|
7c736c526e | ||
|
|
696d354f3c | ||
|
|
501cbf54ab | ||
|
|
c15d69d566 | ||
|
|
83eb933230 | ||
|
|
43bec9b0df | ||
|
|
279305c202 | ||
|
|
ecbb86c006 | ||
|
|
921fb17ef0 | ||
|
|
0362de7d35 | ||
|
|
cf0d8ea2d0 | ||
|
|
0e9026447d | ||
|
|
cf4d9cb03c | ||
|
|
2a1edeaca3 | ||
|
|
eebabf9b08 | ||
|
|
d882fcad12 | ||
|
|
f976290282 | ||
|
|
f3f9d5dae2 | ||
|
|
71dffd1089 | ||
|
|
f411e98c9a | ||
|
|
1baa489bc7 | ||
|
|
f996b0fc4a | ||
|
|
eb6ba1c800 | ||
|
|
8fac1baa3c | ||
|
|
2d327543b9 | ||
|
|
8a080efe9d | ||
|
|
aaaf61e29e | ||
|
|
1294323df5 | ||
|
|
9ef4e75746 | ||
|
|
ded4ab702d | ||
|
|
f893d045c7 | ||
|
|
ef2e3adcfb | ||
|
|
a1908c5398 | ||
|
|
ec4f0d6531 | ||
|
|
9ef366237c | ||
|
|
9197ad2600 | ||
|
|
2cb7ecd851 | ||
|
|
7d1ad4ce66 | ||
|
|
c274acc8f4 | ||
|
|
7a0d48dd7a | ||
|
|
9c6f9048e1 | ||
|
|
4ff4acfd7e | ||
|
|
d8e9f07721 | ||
|
|
662c5638dd | ||
|
|
02b830d034 | ||
|
|
3734529e5c | ||
|
|
715ec24389 | ||
|
|
5615b23548 | ||
|
|
ca2eeb48cf | ||
|
|
b063c0a80c | ||
|
|
ee8b5692bd | ||
|
|
7a749dca67 | ||
|
|
0378f26ee6 | ||
|
|
4d281273c1 | ||
|
|
e23e11e1a8 | ||
|
|
772835dd22 | ||
|
|
bbf2e57548 | ||
|
|
aecda130b6 | ||
|
|
1d48030e7c | ||
|
|
929ba2fa19 | ||
|
|
6fefa947ca | ||
|
|
072cd2e846 | ||
|
|
5d20cd0365 | ||
|
|
03ec055f66 | ||
|
|
4b6a5e5d49 | ||
|
|
6d21e38159 | ||
|
|
a47c8249bf | ||
|
|
59d7a672b3 | ||
|
|
564e95d36e | ||
|
|
9aee99be74 | ||
|
|
aecd8b503d | ||
|
|
fa65eeea35 | ||
|
|
fe43584c3d | ||
|
|
c255b13dfc | ||
|
|
917b204e5b | ||
|
|
6225fd79fc | ||
|
|
cbec567ef4 | ||
|
|
84b62242d3 | ||
|
|
f17f74c30b | ||
|
|
63b04d5a27 | ||
|
|
f02073a24c | ||
|
|
cb87d126de | ||
|
|
941f8002e5 | ||
|
|
90f4f5cd89 | ||
|
|
a6e7761141 | ||
|
|
eb053a66d7 | ||
|
|
5257c83563 | ||
|
|
04bc92001f | ||
|
|
d939082e1f | ||
|
|
a943a5985d | ||
|
|
9e19821256 | ||
|
|
455183a13e | ||
|
|
c241c08904 | ||
|
|
08389cb1a0 | ||
|
|
94f9d42fc4 | ||
|
|
f35ecce3c7 | ||
|
|
2837bb40b0 | ||
|
|
54331f976d | ||
|
|
b975e74de3 | ||
|
|
c45ab34f43 | ||
|
|
4ee442f697 | ||
|
|
3c25d322f2 | ||
|
|
265c6b3e0f | ||
|
|
fad4503aec | ||
|
|
d8f70bfde3 | ||
|
|
d7dfb44efc | ||
|
|
409330a9fb | ||
|
|
0fd7e07831 | ||
|
|
91bd26d2a9 | ||
|
|
e5c4cf3298 | ||
|
|
c874d3fd84 | ||
|
|
c06f95256e | ||
|
|
2f1e05833e | ||
|
|
719cad00d6 | ||
|
|
b372c71fbf | ||
|
|
6b252a7018 | ||
|
|
6575258b6c | ||
|
|
d33280f9af | ||
|
|
863bb80ad1 | ||
|
|
e4266f31a6 | ||
|
|
0405fccb69 | ||
|
|
9a41adcec8 | ||
|
|
1d54920165 | ||
|
|
7ace37cd07 | ||
|
|
eb6398654d | ||
|
|
10a4c3e2a4 | ||
|
|
d494014011 | ||
|
|
91bf562b91 | ||
|
|
ec3961555f | ||
|
|
33b46869b6 | ||
|
|
88db21ef07 | ||
|
|
d53948f4a9 | ||
|
|
f97992a776 | ||
|
|
f9d99703cb | ||
|
|
b015cdde74 | ||
|
|
92b35bd458 | ||
|
|
3c8026f135 | ||
|
|
6a3f51a784 | ||
|
|
160c4a8a72 | ||
|
|
c4ff760bda | ||
|
|
aaed8f595a | ||
|
|
3c0a2e8385 | ||
|
|
0eef0f9aa5 | ||
|
|
169e2f16fb | ||
|
|
3800391a0e | ||
|
|
1f564808d5 | ||
|
|
433639dd04 | ||
|
|
f1e4116672 | ||
|
|
6cf00c5c66 | ||
|
|
71248cd9b7 | ||
|
|
841e6d110c | ||
|
|
f7defffeab | ||
|
|
13e6f5f6cf | ||
|
|
130cbf0b24 | ||
|
|
642d85b6bf | ||
|
|
8fe7f85e1a | ||
|
|
d1fb794783 | ||
|
|
e7aedb405a | ||
|
|
9dc148dace | ||
|
|
8ad0b25023 | ||
|
|
f648d60abb | ||
|
|
bf90d2842b | ||
|
|
7004c4f44c | ||
|
|
76eeb3d0f7 | ||
|
|
279caca502 | ||
|
|
1c6bdc7369 | ||
|
|
8705d3450a | ||
|
|
33277bf25f | ||
|
|
cbd2342208 | ||
|
|
831f87f62e | ||
|
|
06c9609587 | ||
|
|
9b43d31b75 | ||
|
|
23a3c7f960 | ||
|
|
81acfaa424 | ||
|
|
9de40292c4 | ||
|
|
c489a7ed75 | ||
|
|
6c26eb8333 | ||
|
|
6a57c5ed74 | ||
|
|
dce33aaabc | ||
|
|
b1db0ff498 | ||
|
|
a348b483c3 | ||
|
|
d7ce99526c | ||
|
|
90f0cb862a | ||
|
|
ff0c7f6a50 | ||
|
|
d608b171de | ||
|
|
5e76488276 | ||
|
|
bc265c09ff | ||
|
|
c7fe828252 | ||
|
|
9fbf67d451 | ||
|
|
e5572d5833 | ||
|
|
6b647e4cf3 | ||
|
|
4661dc3124 | ||
|
|
e428346d3b | ||
|
|
59af264463 | ||
|
|
01c60a2faa | ||
|
|
0f880143e3 | ||
|
|
bbba8b4b30 | ||
|
|
3a3a864bcb | ||
|
|
2bc0b3716a | ||
|
|
1e89e70e57 | ||
|
|
c160e7a945 | ||
|
|
d6f6938465 | ||
|
|
0d2a154622 | ||
|
|
142ea20eaf | ||
|
|
c9b910937c | ||
|
|
70c863c80c | ||
|
|
b90d206514 | ||
|
|
29ea484a26 | ||
|
|
8aa6e83673 | ||
|
|
aef8e32da3 | ||
|
|
be0f64a6ad | ||
|
|
3c88fabab3 | ||
|
|
ee85ee0660 | ||
|
|
f639cf1134 | ||
|
|
65549d4456 | ||
|
|
d194681981 | ||
|
|
5b5ddb251b | ||
|
|
5ce72e2056 | ||
|
|
ef2218a3d8 | ||
|
|
2745a3bfaa | ||
|
|
dd3fc3b0be | ||
|
|
957dfaef52 | ||
|
|
9e8015f475 | ||
|
|
38c8977dab | ||
|
|
fdf2bc6adf | ||
|
|
89344f92b3 | ||
|
|
8e8eeaf6c8 | ||
|
|
dcf2f1dfdf | ||
|
|
a7f183d40d | ||
|
|
114de52434 | ||
|
|
468cab6982 | ||
|
|
02f12d40f0 | ||
|
|
1da452aa92 | ||
|
|
2cf2adafd3 | ||
|
|
261e72cae4 | ||
|
|
1cc3ab30cf | ||
|
|
987f4f1afd | ||
|
|
9a1536484a | ||
|
|
5dd03cff69 | ||
|
|
a6d682fdee | ||
|
|
f8013c0ec0 | ||
|
|
d6fff29a72 | ||
|
|
4cf37af114 | ||
|
|
916edf9415 | ||
|
|
dba5a44c60 | ||
|
|
c20a43433d |
@@ -5,6 +5,10 @@ trim_trailing_whitespace = true
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
[*.java]
|
[*.java]
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|||||||
2
.git-blame-ignore-revs
Normal file
2
.git-blame-ignore-revs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# update scalafmt
|
||||||
|
3d5ca44d66c77a46770a65a895c9737c542690f6
|
||||||
5
.github/CODEOWNERS
vendored
Normal file
5
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
* @takezoe
|
||||||
|
|
||||||
|
build.sbt @xuwei-k
|
||||||
|
project/* @xuwei-k
|
||||||
|
.github/workflows/* @xuwei-k
|
||||||
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
@@ -1,6 +1,6 @@
|
|||||||
# The guidelines for contributing
|
# The guidelines for contributing
|
||||||
|
|
||||||
- At first, see [Wiki](https://github.com/gitbucket/gitbucket/wiki) and check issues and pull requests whether there is a same request in the past.
|
- At first, see [Wiki](https://github.com/gitbucket/gitbucket/wiki) and check issues and pull requests whether there is a same request in the past.
|
||||||
- The highest priority of GitBucket is the ease of installation and API compatibility with GitHub, so your feature request might be rejected if they go against those principles. If you don't wanna waste your time to make a pull request, ask us about your idea at [gitter room](https://gitter.im/gitbucket/gitbucket) before staring your work.
|
- The highest priority of GitBucket is the ease of installation and API compatibility with GitHub, so your feature request might be rejected if they go against those principles. If you don't wanna waste your time to make a pull request, ask us about your idea at [gitter room](https://gitter.im/gitbucket/gitbucket) before starting your work.
|
||||||
- You can edit the GitBucket documentation on Wiki if you have a GitHub account. When you find any mistakes or lacks in the documentation, please update it directly.
|
- You can edit the GitBucket documentation on Wiki if you have a GitHub account. When you find any mistakes or lacks in the documentation, please update it directly.
|
||||||
- All your contributions are handled as [Apache Software License, Version 2.0](https://github.com/gitbucket/gitbucket/blob/master/LICENSE). When you create a pull request or update the documentation, we assume you agreed this clause.
|
- All your contributions are handled as [Apache Software License, Version 2.0](https://github.com/gitbucket/gitbucket/blob/master/LICENSE). When you create a pull request or update the documentation, we assume you agreed this clause.
|
||||||
|
|||||||
12
.github/ISSUE_TEMPLATE.md
vendored
12
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,18 +1,22 @@
|
|||||||
### Before submitting an issue to GitBucket I have first:
|
### Before submitting an issue to GitBucket I have first:
|
||||||
|
|
||||||
- [] read the [contribution guidelines](https://github.com/gitbucket/gitbucket/blob/master/.github/CONTRIBUTING.md)
|
- [ ] read the [contribution guidelines](https://github.com/gitbucket/gitbucket/blob/master/.github/CONTRIBUTING.md)
|
||||||
- [] searched for similar already existing issue
|
- [ ] searched for similar already existing issue
|
||||||
- [] read the documentation and [wiki](https://github.com/gitbucket/gitbucket/wiki)
|
- [ ] read the documentation and [wiki](https://github.com/gitbucket/gitbucket/wiki)
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
*(if you have performed all the above, remove the paragraph and continue describing the issue with template below)*
|
*(if you have performed all the above, remove the paragraph and continue describing the issue with template below)*
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
## Issue
|
## Issue
|
||||||
**Impacted version**: xxxx
|
**Impacted version**: xxxx
|
||||||
|
|
||||||
**Deployment mode**: *explain here how you use GitBucket : standalone app, under webcontainer (which one), with an http frontend (nginx, httpd, ...)*
|
**Deployment mode**: *explain here how you use GitBucket : standalone app, under webcontainer (which one), with an http frontend (nginx, httpd, ...)*
|
||||||
|
|
||||||
**Problem description**:
|
**Problem description**:
|
||||||
- *be as explicit has you can*
|
- *be as explicit as you can*
|
||||||
- *describe the problem and its symptoms*
|
- *describe the problem and its symptoms*
|
||||||
- *explain how to reproduce*
|
- *explain how to reproduce*
|
||||||
- *attach whatever information that can help understanding the context (screen capture, log files)*
|
- *attach whatever information that can help understanding the context (screen capture, log files)*
|
||||||
|
|||||||
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,8 +1,8 @@
|
|||||||
### Before submitting a pull-request to GitBucket I have first:
|
### Before submitting a pull-request to GitBucket I have first:
|
||||||
|
|
||||||
- [] read the [contribution guidelines](https://github.com/gitbucket/gitbucket/blob/master/.github/CONTRIBUTING.md)
|
- [ ] read the [contribution guidelines](https://github.com/gitbucket/gitbucket/blob/master/.github/CONTRIBUTING.md)
|
||||||
- [] rebased my branch over master
|
- [ ] rebased my branch over master
|
||||||
- [] verified that project is compiling
|
- [ ] verified that project is compiling
|
||||||
- [] verified that tests are passing
|
- [ ] verified that tests are passing
|
||||||
- [] squashed my commits as appropriate *(keep several commits if it is relevant to understand the PR)*
|
- [ ] squashed my commits as appropriate *(keep several commits if it is relevant to understand the PR)*
|
||||||
- [] [marked as closed using commit message](https://help.github.com/articles/closing-issues-via-commit-messages/) all issue ID that this PR should correct
|
- [ ] [marked as closed using commit message](https://help.github.com/articles/closing-issues-via-commit-messages/) all issue ID that this PR should correct
|
||||||
|
|||||||
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
39
.github/workflows/build.yml
vendored
Normal file
39
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: build
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 30
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
java: [11, 21]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
env:
|
||||||
|
cache-name: cache-sbt-libs
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.ivy2/cache
|
||||||
|
~/.sbt
|
||||||
|
~/.cache/coursier/v1
|
||||||
|
key: build-${{ env.cache-name }}-${{ hashFiles('build.sbt') }}
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: ${{ matrix.java }}
|
||||||
|
distribution: adopt
|
||||||
|
- name: Run tests
|
||||||
|
run: sbt scalafmtSbtCheck scalafmtCheckAll test
|
||||||
|
- name: Scala 3
|
||||||
|
run: sbt '++ 3.x' update # TODO
|
||||||
|
- name: Build executable
|
||||||
|
run: sbt executable
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: gitbucket-java${{ matrix.java }}-${{ github.sha }}
|
||||||
|
path: ./target/executable/gitbucket.*
|
||||||
13
.gitignore
vendored
13
.gitignore
vendored
@@ -2,6 +2,9 @@
|
|||||||
*.log
|
*.log
|
||||||
.ensime
|
.ensime
|
||||||
.ensime_cache
|
.ensime_cache
|
||||||
|
.DS_Store
|
||||||
|
.java-version
|
||||||
|
.tmp
|
||||||
|
|
||||||
# sbt specific
|
# sbt specific
|
||||||
dist/*
|
dist/*
|
||||||
@@ -10,6 +13,7 @@ lib_managed/
|
|||||||
src_managed/
|
src_managed/
|
||||||
project/boot/
|
project/boot/
|
||||||
project/plugins/project/
|
project/plugins/project/
|
||||||
|
.bsp/
|
||||||
|
|
||||||
# Scala-IDE specific
|
# Scala-IDE specific
|
||||||
.scala_dependencies
|
.scala_dependencies
|
||||||
@@ -24,3 +28,12 @@ project/plugins/project/
|
|||||||
.idea/
|
.idea/
|
||||||
.idea_modules/
|
.idea_modules/
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
|
# Metals specific
|
||||||
|
.metals
|
||||||
|
.bloop
|
||||||
|
**/metals.sbt
|
||||||
|
|
||||||
|
# Visual Studio Code specific
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
|||||||
8
.scala-steward.conf
Normal file
8
.scala-steward.conf
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
updates.limit = 3
|
||||||
|
|
||||||
|
updates.includeScala = true
|
||||||
|
|
||||||
|
updates.pin = [
|
||||||
|
{ groupId = "org.eclipse.jetty", version = "10." }
|
||||||
|
{ groupId = "org.mariadb.jdbc", version = "2." }
|
||||||
|
]
|
||||||
@@ -1,11 +1,24 @@
|
|||||||
|
version = "3.8.1"
|
||||||
project.git = true
|
project.git = true
|
||||||
|
|
||||||
maxColumn = 120
|
maxColumn = 120
|
||||||
docstrings = JavaDoc
|
docstrings.style = keep
|
||||||
|
|
||||||
align.tokens = ["%", "%%", {code = "=>", owner = "Case"}]
|
align.tokens = ["%", "%%", {code = "=>", owner = "Case"}]
|
||||||
align.openParenCallSite = false
|
align.openParenCallSite = false
|
||||||
align.openParenDefnSite = false
|
align.openParenDefnSite = false
|
||||||
continuationIndent.callSite = 2
|
continuationIndent.callSite = 2
|
||||||
continuationIndent.defnSite = 2
|
continuationIndent.defnSite = 2
|
||||||
danglingParentheses = true
|
danglingParentheses.preset = true
|
||||||
|
runner.dialect = scala213source3
|
||||||
|
rewrite.trailingCommas.style = keep
|
||||||
|
fileOverride {
|
||||||
|
"glob:**/*.sbt" {
|
||||||
|
runner.dialect = scala212
|
||||||
|
rewrite.scala3.convertToNewSyntax = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rewrite.scala3.convertToNewSyntax = true
|
||||||
|
runner.dialectOverride.allowSignificantIndentation = false
|
||||||
|
runner.dialectOverride.allowAsForImportRename = false
|
||||||
|
runner.dialectOverride.allowStarWildcardImport = false
|
||||||
|
|||||||
21
.travis.yml
21
.travis.yml
@@ -1,21 +0,0 @@
|
|||||||
language: scala
|
|
||||||
sudo: true
|
|
||||||
jdk:
|
|
||||||
- oraclejdk8
|
|
||||||
- oraclejdk11
|
|
||||||
- openjdk8
|
|
||||||
- openjdk11
|
|
||||||
script:
|
|
||||||
- sbt scalafmtSbtCheck scalafmtCheck test:scalafmtCheck test
|
|
||||||
before_script:
|
|
||||||
- sudo /etc/init.d/mysql stop
|
|
||||||
- sudo /etc/init.d/postgresql stop
|
|
||||||
- sudo chmod +x /usr/local/bin/sbt
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- $HOME/.ivy2/cache
|
|
||||||
- $HOME/.sbt/boot
|
|
||||||
- $HOME/.sbt/launchers
|
|
||||||
- $HOME/.coursier
|
|
||||||
- $HOME/.embedmysql
|
|
||||||
- $HOME/.embedpostgresql
|
|
||||||
149
CHANGELOG.md
149
CHANGELOG.md
@@ -1,7 +1,152 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to the project will be documented in this file.
|
All changes to the project will be documented in this file.
|
||||||
|
|
||||||
## 4.30.0 - xx Dec 2018
|
## 4.41.0 - 18 May 2024
|
||||||
|
- Simplify pull request UI
|
||||||
|
- Fix layout of branch selector
|
||||||
|
- Integrate keyword search with filtering in the search box
|
||||||
|
- Make max files and lines limit in showing diff configurable
|
||||||
|
- Adjust the default branch automatically when cloning external repo
|
||||||
|
- Performance improvement for listing branches
|
||||||
|
- Upgrade internal libraries
|
||||||
|
|
||||||
|
## 4.40.0 - 22 Oct 2023
|
||||||
|
- Configurable default branch name
|
||||||
|
- Support custom fields of issues and pull requests in search condition
|
||||||
|
- Create pull request from default branch of forked repositories
|
||||||
|
- News feed shows activities of all visible repositories
|
||||||
|
- Drop Java 8 support
|
||||||
|
- Improve git push performance
|
||||||
|
|
||||||
|
## 4.39.0 - 29 Apr 2023
|
||||||
|
- Support enum type in custom fields of Issues and Pull requests
|
||||||
|
- Hide large diffs by default
|
||||||
|
- Add new options to make it possible to run GitBucket using multiple machines
|
||||||
|
- Fix many API issues
|
||||||
|
|
||||||
|
## 4.38.4 - 2 Nov 2022
|
||||||
|
- Downgrade MariaDB JDBC drive to avoid unknown error
|
||||||
|
|
||||||
|
## 4.38.3 - 30 Oct 2022
|
||||||
|
- Fix several issues around multiple assignees in issues and pull requests
|
||||||
|
- Fix IllegalStateException when returning unknown avatar image
|
||||||
|
|
||||||
|
## 4.38.2 - 20 Sep 2022
|
||||||
|
- Resurrect assignee icons on the issue list
|
||||||
|
|
||||||
|
## 4.38.1 - 10 Sep 2022
|
||||||
|
- Fix comment diff in Chrome 105
|
||||||
|
- Fix Markdown table CSS
|
||||||
|
- Fix HTML rendering of multiple asignees
|
||||||
|
|
||||||
|
## 4.38.0 - 3 Sep 2022
|
||||||
|
- Support multiple assignees for Issues and Pull requests
|
||||||
|
- Custom fields for issues and pull requests
|
||||||
|
- Reset password by users
|
||||||
|
- Allow to configure Jetty idle timeout in standalone mode
|
||||||
|
- Horizontal scroll for too wide tables in Markdown
|
||||||
|
- Hide header content on signin and register page
|
||||||
|
- Fix the default charset of the online editor in the repository viewer
|
||||||
|
- Fix the milestone count
|
||||||
|
- Some improvements and bugfixes for WebAPI and WebHook
|
||||||
|
|
||||||
|
## 4.37.2 - 16 Jan 2022
|
||||||
|
- Fixed a security issue reported by [Positive Technologies](https://www.ptsecurity.com/ww-en/). Great thanks for their detailed report and close support!
|
||||||
|
|
||||||
|
## 4.37.1 - 14 Dec 2021
|
||||||
|
- Update gist-plugin and notification-plugin
|
||||||
|
- Fix SSHCommand extension point for apache-sshd 2.x
|
||||||
|
|
||||||
|
## 4.37.0 - 11 Dec 2021
|
||||||
|
- Enhance Git Reference APIs
|
||||||
|
- Add milestone data to issue list API
|
||||||
|
- Support "all" in issue list API
|
||||||
|
- Support EDDSA in signed commit verification
|
||||||
|
- Support custom SSH url
|
||||||
|
- Relax max passward length limitation
|
||||||
|
- Relax max webhook url length limitation
|
||||||
|
|
||||||
|
## 4.36.2 - 16 Aug 2021
|
||||||
|
- Escape user name in avatar image tag
|
||||||
|
|
||||||
|
## 4.36.1 - 22 Jul 2021
|
||||||
|
- Bump gitbucket-gist-plugin to 4.21.0
|
||||||
|
|
||||||
|
## 4.36.0 - 17 Jul 2021
|
||||||
|
- Tag selector in the repository viewer
|
||||||
|
- Link issues/pull requests of other repositories
|
||||||
|
- Files and lines can be linked in the diff view
|
||||||
|
- Option to disable XSS protection
|
||||||
|
|
||||||
|
## 4.35.3 - 14 Jan 2021
|
||||||
|
- Fix a bug that Wiki page cannot be deleted
|
||||||
|
- Fix a deployment issue on Tomcat
|
||||||
|
|
||||||
|
## 4.35.2 - 30 Dec 2020
|
||||||
|
- Upgrade gitbucket-notifications-plugin to 1.10.0
|
||||||
|
- Upgrade oauth2-oidc-sdk to 8.29.1 to solve dependency issue
|
||||||
|
|
||||||
|
## 4.35.1 - 29 Dec 2020
|
||||||
|
- Fix database migration issue which happens if webhook is configured
|
||||||
|
- Call push webhook when pull request is merged
|
||||||
|
- Show commit status at commits tab of pull request
|
||||||
|
|
||||||
|
## 4.35.0 - 25 Dec 2020
|
||||||
|
- Editor and source viewer color theme
|
||||||
|
- Auto completion for issues and pull requests
|
||||||
|
- Upload image from clipboard
|
||||||
|
- Close multiple issues by commit comment
|
||||||
|
- Create pull request from online editor
|
||||||
|
- Milestone overview
|
||||||
|
- Commit status at various places
|
||||||
|
- WebAPI coverage improvements
|
||||||
|
|
||||||
|
## 4.34.0 - 26 Jul 2020
|
||||||
|
- Enhancement admin settings UI
|
||||||
|
- File upload settings
|
||||||
|
- Restrict repository operations
|
||||||
|
- User-defined CSS
|
||||||
|
- Limit the repository list in the sidebar
|
||||||
|
- Improve MariaDB support
|
||||||
|
- Improve activity logging
|
||||||
|
- CLI option to persist session on disk in the standalone mode
|
||||||
|
- Web API updates
|
||||||
|
- Add [list commits API](https://developer.github.com/v3/repos/commits/#list-commits)
|
||||||
|
- Bundled plugins updates
|
||||||
|
- [gitbucket-gist-plugin](https://github.com/gitbucket/gitbucket-gist-plugin) 4.18.0 -> 4.19.0
|
||||||
|
- [gitbucket-notifications-plugin](https://github.com/gitbucket/gitbucket-notifications-plugin) 1.8.0 -> 1.9.0
|
||||||
|
|
||||||
|
## 4.33.0 - 31 Dec 2019
|
||||||
|
- All CLI options are configurable by environment variables
|
||||||
|
- Folding pull request files
|
||||||
|
- WebHook security options
|
||||||
|
- Add assignee and assignees properties to some Web APIs' response
|
||||||
|
|
||||||
|
## 4.32.0 - 7 Aug 2019
|
||||||
|
- Bump to Scala 2.13.0 and Scalatra 2.7.0
|
||||||
|
- Draft pull request
|
||||||
|
- Drop network installation of plugins
|
||||||
|
- Compare view works for commit id
|
||||||
|
- Apply default priority to pull requests
|
||||||
|
- Focus title after clicking issue / pull request edit button
|
||||||
|
|
||||||
|
## 4.31.2 - 7 Apr 2019
|
||||||
|
- Bug and security fix
|
||||||
|
|
||||||
|
## 4.31.1 - 17 Mar 2019
|
||||||
|
- Bug fix
|
||||||
|
|
||||||
|
## 4.31.0 - 17 Mar 2019
|
||||||
|
- Docker support in CI plugin
|
||||||
|
- Verify GPG key signed commit
|
||||||
|
- OAuth2 Token (sent as a parameter) authentication support and new APIs in Web API
|
||||||
|
- OGP (Open Graph protocol) support
|
||||||
|
- Username completion with avatars
|
||||||
|
|
||||||
|
## 4.30.1 - 22 Dec 2018
|
||||||
|
- Bug fix for several WebHooks and Web API
|
||||||
|
|
||||||
|
## 4.30.0 - 15 Dec 2018
|
||||||
- Automatic ChangeLog Summary generation for new Releases
|
- Automatic ChangeLog Summary generation for new Releases
|
||||||
- A lot of GitBucket Web API updates to increase compatibility with the GitHub API.
|
- A lot of GitBucket Web API updates to increase compatibility with the GitHub API.
|
||||||
- Display of checkboxes in Markdown files in Git repositories
|
- Display of checkboxes in Markdown files in Git repositories
|
||||||
@@ -85,7 +230,7 @@ All changes to the project will be documented in this file.
|
|||||||
- Submodule links to web page
|
- Submodule links to web page
|
||||||
- Clarify close/reopen button
|
- Clarify close/reopen button
|
||||||
|
|
||||||
# 4.20.0 - 23 Dec 2017
|
## 4.20.0 - 23 Dec 2017
|
||||||
- Squash and rebase merge strategy for pull requests
|
- Squash and rebase merge strategy for pull requests
|
||||||
- Quick pull request creation
|
- Quick pull request creation
|
||||||
- Download patch from the diff view
|
- Download patch from the diff view
|
||||||
|
|||||||
48
README.md
48
README.md
@@ -1,4 +1,4 @@
|
|||||||
GitBucket [](https://gitter.im/gitbucket/gitbucket) [](https://travis-ci.org/gitbucket/gitbucket) [](https://maven-badges.herokuapp.com/maven-central/io.github.gitbucket/gitbucket_2.12) [](https://github.com/gitbucket/gitbucket/blob/master/LICENSE)
|
GitBucket [](https://gitter.im/gitbucket/gitbucket) [](https://github.com/gitbucket/gitbucket/actions?query=workflow%3Abuild+branch%3Amaster) [](https://index.scala-lang.org/gitbucket/gitbucket/gitbucket) [](https://github.com/gitbucket/gitbucket/blob/master/LICENSE)
|
||||||
=========
|
=========
|
||||||
|
|
||||||
GitBucket is a Git web platform powered by Scala offering:
|
GitBucket is a Git web platform powered by Scala offering:
|
||||||
@@ -8,7 +8,7 @@ GitBucket is a Git web platform powered by Scala offering:
|
|||||||
- High extensibility by plugins
|
- High extensibility by plugins
|
||||||
- API compatibility with GitHub
|
- API compatibility with GitHub
|
||||||
|
|
||||||
You can try an [online demo](https://gitbucket.herokuapp.com/) *(ID: root / Pass: root)* of GitBucket, and also get the latest information at [GitBucket News](https://gitbucket.github.io/gitbucket-news/).
|

|
||||||
|
|
||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
@@ -22,29 +22,14 @@ The current version of GitBucket provides many features such as:
|
|||||||
- Account and group management with LDAP integration
|
- Account and group management with LDAP integration
|
||||||
- a Plug-in system
|
- a Plug-in system
|
||||||
|
|
||||||
If you want to try the development version of GitBucket, see the [Developer's Guide](https://github.com/gitbucket/gitbucket/blob/master/doc/how_to_run.md).
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
--------
|
--------
|
||||||
GitBucket requires **Java8**. You have to install it, if it is not already installed.
|
GitBucket requires **Java 11**. You have to install it, if it is not already installed.
|
||||||
|
|
||||||
1. Download the latest **gitbucket.war** from [the releases page](https://github.com/gitbucket/gitbucket/releases) and run it by `java -jar gitbucket.war`.
|
1. Download the latest **gitbucket.war** from [the releases page](https://github.com/gitbucket/gitbucket/releases) and run it by `java -jar gitbucket.war`.
|
||||||
2. Go to `http://[hostname]:8080/` and log in with ID: **root** / Pass: **root**.
|
2. Go to `http://[hostname]:8080/` and log in with ID: **root** / Pass: **root**.
|
||||||
|
|
||||||
You can specify following options:
|
You can also deploy `gitbucket.war` to a servlet container which supports Servlet 3.0 (like Jetty, Tomcat, JBoss, etc). Note that GitBucket doesn't support Jakarta EE yet.
|
||||||
|
|
||||||
- `--port=[NUMBER]`
|
|
||||||
- `--prefix=[CONTEXTPATH]`
|
|
||||||
- `--host=[HOSTNAME]`
|
|
||||||
- `--gitbucket.home=[DATA_DIR]`
|
|
||||||
- `--temp_dir=[TEMP_DIR]`
|
|
||||||
- `--max_file_size=[MAX_FILE_SIZE]`
|
|
||||||
|
|
||||||
`TEMP_DIR` is used as the [temporary directory for the jetty application context](https://www.eclipse.org/jetty/documentation/9.3.x/ref-temporary-directories.html). This is the directory into which the `gitbucket.war` file is unpacked, the source files are compiled, etc. If given this parameter **must** match the path of an existing directory or the application will quit reporting an error; if not given the path used will be a `tmp` directory inside the gitbucket home.
|
|
||||||
|
|
||||||
`MAX_FILE_SIZE` is the max file size for upload files.
|
|
||||||
|
|
||||||
You can also deploy `gitbucket.war` to a servlet container which supports Servlet 3.0 (like Jetty, Tomcat, JBoss, etc)
|
|
||||||
|
|
||||||
For more information about installation on Mac or Windows Server (with IIS), or configuration of Apache or Nginx and also integration with other tools or services such as Jenkins or Slack, see [Wiki](https://github.com/gitbucket/gitbucket/wiki).
|
For more information about installation on Mac or Windows Server (with IIS), or configuration of Apache or Nginx and also integration with other tools or services such as Jenkins or Slack, see [Wiki](https://github.com/gitbucket/gitbucket/wiki).
|
||||||
|
|
||||||
@@ -61,21 +46,28 @@ GitBucket has a plug-in system that allows extra functionality. Officially the f
|
|||||||
|
|
||||||
You can find more plugins made by the community at [GitBucket community plugins](https://gitbucket-plugins.github.io/).
|
You can find more plugins made by the community at [GitBucket community plugins](https://gitbucket-plugins.github.io/).
|
||||||
|
|
||||||
|
Building and Development
|
||||||
|
-----------
|
||||||
|
If you want to try the development version of GitBucket, or want to contribute to the project, please see the [Developer's Guide](https://github.com/gitbucket/gitbucket/blob/master/doc/readme.md).
|
||||||
|
It provides instructions on building from source and on setting up an IDE for debugging.
|
||||||
|
It also contains documentation of the core concepts used within the project.
|
||||||
|
|
||||||
Support
|
Support
|
||||||
--------
|
--------
|
||||||
|
|
||||||
- If you have any questions about GitBucket, see [Wiki](https://github.com/gitbucket/gitbucket/wiki) and check issues whether there is a same question or request in the past.
|
- If you have any questions about GitBucket, see [Wiki](https://github.com/gitbucket/gitbucket/wiki) and check issues whether there is a same question or request in the past.
|
||||||
- If you can't find same question and report, send it to [gitter room](https://gitter.im/gitbucket/gitbucket) before raising an issue.
|
- If you can't find same question and report, send it to our [Gitter room](https://gitter.im/gitbucket/gitbucket) before raising an issue.
|
||||||
- The highest priority of GitBucket is the ease of installation and API compatibility with GitHub, so your feature request might be rejected if they go against those principles.
|
- The highest priority of GitBucket is the ease of installation and API compatibility with GitHub, so your feature request might be rejected if they go against those principles.
|
||||||
|
|
||||||
What's New in 4.30.x
|
What's New in 4.41.x
|
||||||
-------------
|
-------------
|
||||||
### 4.30.0 - xx Dec 2018
|
## 4.41.0 - 18 May 2024
|
||||||
- Automatic ChangeLog Summary generation for new Releases
|
- Simplify pull request UI
|
||||||
- A lot of GitBucket Web API updates to increase compatibility with the GitHub API.
|
- Fix layout of branch selector
|
||||||
- Display of checkboxes in Markdown files in Git repositories
|
- Integrate keyword search with filtering in the search box
|
||||||
- A new extension point for plugins: anonymousAccessiblePaths
|
- Make max files and lines limit in showing diff configurable
|
||||||
- Group support in the Gist Plugin
|
- Adjust the default branch automatically when cloning external repo
|
||||||
- Allow redirection to the Release Page from the Activity Timeline Page
|
- Performance improvement for listing branches
|
||||||
|
- Upgrade internal libraries
|
||||||
|
|
||||||
See the [change log](CHANGELOG.md) for all of the updates.
|
See the [change log](CHANGELOG.md) for all of the updates.
|
||||||
|
|||||||
179
build.sbt
179
build.sbt
@@ -1,95 +1,104 @@
|
|||||||
import com.typesafe.sbt.license.{DepModuleInfo, LicenseInfo}
|
import sbtlicensereport.license.{DepModuleInfo, LicenseInfo}
|
||||||
import com.typesafe.sbt.pgp.PgpKeys._
|
import com.jsuereth.sbtpgp.PgpKeys._
|
||||||
|
|
||||||
val Organization = "io.github.gitbucket"
|
val Organization = "io.github.gitbucket"
|
||||||
val Name = "gitbucket"
|
val Name = "gitbucket"
|
||||||
val GitBucketVersion = "4.30.0"
|
val GitBucketVersion = "4.41.0"
|
||||||
val ScalatraVersion = "2.6.3"
|
val ScalatraVersion = "3.0.0"
|
||||||
val JettyVersion = "9.4.14.v20181114"
|
val JettyVersion = "10.0.21"
|
||||||
val JgitVersion = "5.1.3.201810200350-r"
|
val JgitVersion = "6.9.0.202403050737-r"
|
||||||
|
|
||||||
lazy val root = (project in file("."))
|
lazy val root = (project in file("."))
|
||||||
.enablePlugins(SbtTwirl, ScalatraPlugin)
|
.enablePlugins(SbtTwirl, ScalatraPlugin)
|
||||||
.settings(
|
|
||||||
)
|
|
||||||
|
|
||||||
sourcesInBase := false
|
sourcesInBase := false
|
||||||
organization := Organization
|
organization := Organization
|
||||||
name := Name
|
name := Name
|
||||||
version := GitBucketVersion
|
version := GitBucketVersion
|
||||||
scalaVersion := "2.12.8"
|
scalaVersion := "2.13.14"
|
||||||
|
|
||||||
scalafmtOnCompile := true
|
crossScalaVersions += "3.4.2"
|
||||||
|
|
||||||
// dependency settings
|
// scalafmtOnCompile := true
|
||||||
resolvers ++= Seq(
|
|
||||||
Classpaths.typesafeReleases,
|
coverageExcludedPackages := ".*\\.html\\..*"
|
||||||
Resolver.jcenterRepo,
|
|
||||||
"amateras" at "http://amateras.sourceforge.jp/mvn/",
|
|
||||||
"sonatype-snapshot" at "https://oss.sonatype.org/content/repositories/snapshots/",
|
|
||||||
"amateras-snapshot" at "http://amateras.sourceforge.jp/mvn-snapshot/"
|
|
||||||
)
|
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % JgitVersion,
|
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % JgitVersion,
|
||||||
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % JgitVersion,
|
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % JgitVersion,
|
||||||
"org.scalatra" %% "scalatra" % ScalatraVersion,
|
"org.scalatra" %% "scalatra-javax" % ScalatraVersion,
|
||||||
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
|
"org.scalatra" %% "scalatra-json-javax" % ScalatraVersion,
|
||||||
"org.scalatra" %% "scalatra-forms" % ScalatraVersion,
|
"org.scalatra" %% "scalatra-forms-javax" % ScalatraVersion,
|
||||||
"org.json4s" %% "json4s-jackson" % "3.6.2",
|
"org.json4s" %% "json4s-jackson" % "4.1.0-M5",
|
||||||
"commons-io" % "commons-io" % "2.6",
|
"commons-io" % "commons-io" % "2.16.1",
|
||||||
"io.github.gitbucket" % "solidbase" % "1.0.3",
|
"io.github.gitbucket" % "solidbase" % "1.1.0",
|
||||||
"io.github.gitbucket" % "markedj" % "1.0.15",
|
"io.github.gitbucket" % "markedj" % "1.0.20",
|
||||||
"org.apache.commons" % "commons-compress" % "1.18",
|
"org.apache.commons" % "commons-compress" % "1.26.1",
|
||||||
"org.apache.commons" % "commons-email" % "1.5",
|
"org.apache.commons" % "commons-email" % "1.6.0",
|
||||||
"org.apache.httpcomponents" % "httpclient" % "4.5.6",
|
"commons-net" % "commons-net" % "3.10.0",
|
||||||
"org.apache.sshd" % "apache-sshd" % "2.1.0" exclude ("org.slf4j", "slf4j-jdk14") exclude ("org.apache.sshd", "sshd-mina") exclude ("org.apache.sshd", "sshd-netty"),
|
"org.apache.httpcomponents" % "httpclient" % "4.5.14",
|
||||||
"org.apache.tika" % "tika-core" % "1.19.1",
|
"org.apache.sshd" % "apache-sshd" % "2.12.1" exclude ("org.slf4j", "slf4j-jdk14") exclude ("org.apache.sshd", "sshd-mina") exclude ("org.apache.sshd", "sshd-netty"),
|
||||||
"com.github.takezoe" %% "blocking-slick-32" % "0.0.11",
|
"org.apache.tika" % "tika-core" % "2.9.2",
|
||||||
|
"com.github.takezoe" %% "blocking-slick" % "0.0.14",
|
||||||
"com.novell.ldap" % "jldap" % "2009-10-07",
|
"com.novell.ldap" % "jldap" % "2009-10-07",
|
||||||
"com.h2database" % "h2" % "1.4.197",
|
"com.h2database" % "h2" % "1.4.199",
|
||||||
"org.mariadb.jdbc" % "mariadb-java-client" % "2.3.0",
|
"org.mariadb.jdbc" % "mariadb-java-client" % "2.7.12",
|
||||||
"org.postgresql" % "postgresql" % "42.2.5",
|
"org.postgresql" % "postgresql" % "42.7.3",
|
||||||
"ch.qos.logback" % "logback-classic" % "1.2.3",
|
"ch.qos.logback" % "logback-classic" % "1.5.6",
|
||||||
"com.zaxxer" % "HikariCP" % "3.2.0",
|
"com.zaxxer" % "HikariCP" % "5.1.0" exclude ("org.slf4j", "slf4j-api"),
|
||||||
"com.typesafe" % "config" % "1.3.3",
|
"com.typesafe" % "config" % "1.4.3",
|
||||||
"com.typesafe.akka" %% "akka-actor" % "2.5.18",
|
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.1.0",
|
||||||
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.0.0",
|
"io.github.java-diff-utils" % "java-diff-utils" % "4.12",
|
||||||
"com.github.bkromhout" % "java-diff-utils" % "2.1.1",
|
"org.cache2k" % "cache2k-all" % "1.6.0.Final",
|
||||||
"org.cache2k" % "cache2k-all" % "1.2.0.Final",
|
"net.coobird" % "thumbnailator" % "0.4.20",
|
||||||
"com.enragedginger" %% "akka-quartz-scheduler" % "1.7.0-akka-2.5.x" exclude ("c3p0", "c3p0") exclude ("com.zaxxer", "HikariCP-java6"),
|
"com.github.zafarkhaja" % "java-semver" % "0.10.2",
|
||||||
"net.coobird" % "thumbnailator" % "0.4.8",
|
"com.nimbusds" % "oauth2-oidc-sdk" % "11.12",
|
||||||
"com.github.zafarkhaja" % "java-semver" % "0.9.0",
|
|
||||||
"com.nimbusds" % "oauth2-oidc-sdk" % "5.64.4",
|
|
||||||
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
|
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
|
||||||
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
|
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
|
||||||
"junit" % "junit" % "4.12" % "test",
|
"junit" % "junit" % "4.13.2" % "test",
|
||||||
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
|
"org.scalatra" %% "scalatra-scalatest-javax" % ScalatraVersion % "test",
|
||||||
"org.mockito" % "mockito-core" % "2.23.4" % "test",
|
"org.mockito" % "mockito-core" % "5.12.0" % "test",
|
||||||
"com.wix" % "wix-embedded-mysql" % "4.2.0" % "test",
|
"com.dimafeng" %% "testcontainers-scala" % "0.41.3" % "test",
|
||||||
"ru.yandex.qatools.embed" % "postgresql-embedded" % "2.10" % "test",
|
"org.testcontainers" % "mysql" % "1.19.8" % "test",
|
||||||
|
"org.testcontainers" % "postgresql" % "1.19.8" % "test",
|
||||||
"net.i2p.crypto" % "eddsa" % "0.3.0",
|
"net.i2p.crypto" % "eddsa" % "0.3.0",
|
||||||
"is.tagomor.woothee" % "woothee-java" % "1.8.0",
|
"is.tagomor.woothee" % "woothee-java" % "1.11.0",
|
||||||
"org.ec4j.core" % "ec4j-core" % "0.0.3"
|
"org.ec4j.core" % "ec4j-core" % "0.3.0",
|
||||||
|
"org.kohsuke" % "github-api" % "1.321" % "test"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Compiler settings
|
// Compiler settings
|
||||||
scalacOptions := Seq("-deprecation", "-language:postfixOps", "-opt:l:method", "-Xfuture")
|
scalacOptions := Seq(
|
||||||
javacOptions in compile ++= Seq("-target", "8", "-source", "8")
|
"-deprecation",
|
||||||
javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml"
|
"-language:postfixOps",
|
||||||
|
"-opt:l:method",
|
||||||
|
"-feature",
|
||||||
|
"-Wunused:imports",
|
||||||
|
"-Wconf:cat=unused&src=twirl/.*:s,cat=unused&src=scala/gitbucket/core/model/[^/]+\\.scala:s"
|
||||||
|
)
|
||||||
|
scalacOptions ++= {
|
||||||
|
scalaBinaryVersion.value match {
|
||||||
|
case "2.13" =>
|
||||||
|
Seq("-Xsource:3")
|
||||||
|
case _ =>
|
||||||
|
Nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compile / javacOptions ++= Seq("-target", "11", "-source", "11")
|
||||||
|
Jetty / javaOptions += "-Dlogback.configurationFile=/logback-dev.xml"
|
||||||
|
|
||||||
// Test settings
|
// Test settings
|
||||||
//testOptions in Test += Tests.Argument("-l", "ExternalDBTest")
|
//testOptions in Test += Tests.Argument("-l", "ExternalDBTest")
|
||||||
javaOptions in Test += "-Dgitbucket.home=target/gitbucket_home_for_test"
|
Test / javaOptions += "-Dgitbucket.home=target/gitbucket_home_for_test"
|
||||||
testOptions in Test += Tests.Setup(() => new java.io.File("target/gitbucket_home_for_test").mkdir())
|
Test / testOptions += Tests.Setup(() => new java.io.File("target/gitbucket_home_for_test").mkdir())
|
||||||
fork in Test := true
|
Test / fork := true
|
||||||
|
|
||||||
// Packaging options
|
// Packaging options
|
||||||
packageOptions += Package.MainClass("JettyLauncher")
|
packageOptions += Package.MainClass("JettyLauncher")
|
||||||
|
|
||||||
// Assembly settings
|
// Assembly settings
|
||||||
test in assembly := {}
|
assembly / test := {}
|
||||||
assemblyMergeStrategy in assembly := {
|
assembly / assemblyMergeStrategy := {
|
||||||
case PathList("META-INF", xs @ _*) =>
|
case PathList("META-INF", xs @ _*) =>
|
||||||
(xs map { _.toLowerCase }) match {
|
(xs map { _.toLowerCase }) match {
|
||||||
case ("manifest.mf" :: Nil) => MergeStrategy.discard
|
case ("manifest.mf" :: Nil) => MergeStrategy.discard
|
||||||
@@ -100,8 +109,8 @@ assemblyMergeStrategy in assembly := {
|
|||||||
|
|
||||||
// Exclude a war file from published artifacts
|
// Exclude a war file from published artifacts
|
||||||
signedArtifacts := {
|
signedArtifacts := {
|
||||||
signedArtifacts.value.filterNot {
|
signedArtifacts.value.filterNot { case (_, file) =>
|
||||||
case (_, file) => file.getName.endsWith(".war") || file.getName.endsWith(".war.asc")
|
file.getName.endsWith(".war") || file.getName.endsWith(".war.asc")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +120,6 @@ Keys.ivyConfigurations += ExecutableConfig
|
|||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
|
"org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
|
||||||
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
|
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
|
||||||
"org.eclipse.jetty" % "jetty-continuation" % JettyVersion % "executable",
|
|
||||||
"org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
|
"org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
|
||||||
"org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
|
"org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
|
||||||
"org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
|
"org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
|
||||||
@@ -120,6 +128,12 @@ libraryDependencies ++= Seq(
|
|||||||
"org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
|
"org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Run package task before test to generate target/webapp for integration test
|
||||||
|
Test / test := {
|
||||||
|
_root_.sbt.Keys.`package`.value
|
||||||
|
(Test / test).value
|
||||||
|
}
|
||||||
|
|
||||||
val executableKey = TaskKey[File]("executable")
|
val executableKey = TaskKey[File]("executable")
|
||||||
executableKey := {
|
executableKey := {
|
||||||
import java.util.jar.Attributes.{Name => AttrName}
|
import java.util.jar.Attributes.{Name => AttrName}
|
||||||
@@ -139,8 +153,7 @@ executableKey := {
|
|||||||
val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
|
val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
|
||||||
jettyJars foreach { jar =>
|
jettyJars foreach { jar =>
|
||||||
IO unzip (jar, temp, (name: String) =>
|
IO unzip (jar, temp, (name: String) =>
|
||||||
(name startsWith "javax/") ||
|
(name startsWith "javax/") || (name startsWith "org/") || (name startsWith "META-INF/services/"))
|
||||||
(name startsWith "org/"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// include original war file
|
// include original war file
|
||||||
@@ -148,7 +161,7 @@ executableKey := {
|
|||||||
IO unzip (warFile, temp)
|
IO unzip (warFile, temp)
|
||||||
|
|
||||||
// include launcher classes
|
// include launcher classes
|
||||||
val classDir = (Keys.classDirectory in Compile).value
|
val classDir = (Compile / Keys.classDirectory).value
|
||||||
val launchClasses = Seq("JettyLauncher.class" /*, "HttpsSupportConnector.class" */ )
|
val launchClasses = Seq("JettyLauncher.class" /*, "HttpsSupportConnector.class" */ )
|
||||||
launchClasses foreach { name =>
|
launchClasses foreach { name =>
|
||||||
IO copyFile (classDir / name, temp / name)
|
IO copyFile (classDir / name, temp / name)
|
||||||
@@ -162,10 +175,10 @@ executableKey := {
|
|||||||
plugins.foreach { plugin =>
|
plugins.foreach { plugin =>
|
||||||
plugin.trim.split(":") match {
|
plugin.trim.split(":") match {
|
||||||
case Array(pluginId, pluginVersion) =>
|
case Array(pluginId, pluginVersion) =>
|
||||||
val url = "https://plugins.gitbucket-community.org/releases/" +
|
val url = "https://github.com/" +
|
||||||
s"gitbucket-${pluginId}-plugin/gitbucket-${pluginId}-plugin-gitbucket_${version.value}-${pluginVersion}.jar"
|
s"gitbucket/gitbucket-${pluginId}-plugin/releases/download/${pluginVersion}/gitbucket-${pluginId}-plugin-${pluginVersion}.jar"
|
||||||
log info s"Download: ${url}"
|
log info s"Download: ${url}"
|
||||||
IO transfer (new java.net.URL(url).openStream, pluginsDir / url.substring(url.lastIndexOf("/") + 1))
|
IO transfer (new java.net.URI(url).toURL.openStream, pluginsDir / url.substring(url.lastIndexOf("/") + 1))
|
||||||
case _ => ()
|
case _ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,15 +192,14 @@ executableKey := {
|
|||||||
manifest.getMainAttributes put (AttrName.MANIFEST_VERSION, "1.0")
|
manifest.getMainAttributes put (AttrName.MANIFEST_VERSION, "1.0")
|
||||||
manifest.getMainAttributes put (AttrName.MAIN_CLASS, "JettyLauncher")
|
manifest.getMainAttributes put (AttrName.MAIN_CLASS, "JettyLauncher")
|
||||||
val outputFile = workDir / warName
|
val outputFile = workDir / warName
|
||||||
IO jar (contentMappings.map { case (file, path) => (file, path.toString) }, outputFile, manifest)
|
IO jar (contentMappings.map { case (file, path) => (file, path.toString) }, outputFile, manifest, None)
|
||||||
|
|
||||||
// generate checksums
|
// generate checksums
|
||||||
Seq(
|
Seq(
|
||||||
"md5" -> "MD5",
|
"md5" -> "MD5",
|
||||||
"sha1" -> "SHA-1",
|
"sha1" -> "SHA-1",
|
||||||
"sha256" -> "SHA-256"
|
"sha256" -> "SHA-256"
|
||||||
).foreach {
|
).foreach { case (extension, algorithm) =>
|
||||||
case (extension, algorithm) =>
|
|
||||||
val checksumFile = workDir / (warName + "." + extension)
|
val checksumFile = workDir / (warName + "." + extension)
|
||||||
Checksums generate (outputFile, checksumFile, algorithm)
|
Checksums generate (outputFile, checksumFile, algorithm)
|
||||||
}
|
}
|
||||||
@@ -251,7 +263,24 @@ pomExtra := (
|
|||||||
</developers>
|
</developers>
|
||||||
)
|
)
|
||||||
|
|
||||||
licenseOverrides := {
|
Test / testOptions ++= {
|
||||||
case DepModuleInfo("com.github.bkromhout", "java-diff-utils", _) =>
|
if (scala.util.Properties.isWin) {
|
||||||
LicenseInfo(LicenseCategory.Apache, "Apache-2.0", "http://www.apache.org/licenses/LICENSE-2.0")
|
Seq(
|
||||||
|
Tests.Exclude(
|
||||||
|
Set(
|
||||||
|
"gitbucket.core.GitBucketCoreModuleSpec"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Jetty / javaOptions ++= Seq(
|
||||||
|
"-Dlogback.configurationFile=/logback-dev.xml",
|
||||||
|
"-Xdebug",
|
||||||
|
"-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000",
|
||||||
|
"-Dorg.eclipse.jetty.annotations.AnnotationParser.LEVEL=OFF",
|
||||||
|
// "-Ddev-features=keep-session"
|
||||||
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Authentication in Controller
|
|||||||
========
|
========
|
||||||
GitBucket provides many [authenticators](https://github.com/gitbucket/gitbucket/blob/master/src/main/scala/gitbucket/core/util/Authenticator.scala) to access controlling in the controller.
|
GitBucket provides many [authenticators](https://github.com/gitbucket/gitbucket/blob/master/src/main/scala/gitbucket/core/util/Authenticator.scala) to access controlling in the controller.
|
||||||
|
|
||||||
For example, in the case of `RepositoryViwerController`,
|
For example, in the case of `RepositoryViewerController`,
|
||||||
it references three authenticators: `ReadableUsersAuthenticator`, `ReferrerAuthenticator` and `CollaboratorsAuthenticator`.
|
it references three authenticators: `ReadableUsersAuthenticator`, `ReferrerAuthenticator` and `CollaboratorsAuthenticator`.
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
@@ -19,13 +19,13 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
Authenticators provides a method to add guard to actions in the controller:
|
Authenticators provide a method to add guard to actions in the controller:
|
||||||
|
|
||||||
- `ReadableUsersAuthenticator` provides `readableUsersOnly` method
|
- `ReadableUsersAuthenticator` provides `readableUsersOnly` method
|
||||||
- `ReferrerAuthenticator` provides `referrersOnly` method
|
- `ReferrerAuthenticator` provides `referrersOnly` method
|
||||||
- `CollaboratorsAuthenticator` provides `collaboratorsOnly` method
|
- `CollaboratorsAuthenticator` provides `collaboratorsOnly` method
|
||||||
|
|
||||||
These methods are available in each actions as below:
|
These methods are available in each action as below:
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
// Allows only the repository owner (or manager for group repository) and administrators.
|
// Allows only the repository owner (or manager for group repository) and administrators.
|
||||||
@@ -38,7 +38,7 @@ get("/:owner/:repository/new/*")(collaboratorsOnly { repository =>
|
|||||||
...
|
...
|
||||||
})
|
})
|
||||||
|
|
||||||
// Allows only signed in users which can access the repository.
|
// Allows only signed-in users which can access the repository.
|
||||||
post("/:owner/:repository/commit/:id/comment/new", commentForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/commit/:id/comment/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
...
|
...
|
||||||
})
|
})
|
||||||
@@ -50,11 +50,11 @@ Currently, GitBucket provides below authenticators:
|
|||||||
|--------------------------|-----------------|--------------------------------------------------------------------------------------|
|
|--------------------------|-----------------|--------------------------------------------------------------------------------------|
|
||||||
|OneselfAuthenticator |oneselfOnly |Allows only oneself and administrators. |
|
|OneselfAuthenticator |oneselfOnly |Allows only oneself and administrators. |
|
||||||
|OwnerAuthenticator |ownerOnly |Allows only the repository owner and administrators. |
|
|OwnerAuthenticator |ownerOnly |Allows only the repository owner and administrators. |
|
||||||
|UsersAuthenticator |usersOnly |Allows only signed in users. |
|
|UsersAuthenticator |usersOnly |Allows only signed-in users. |
|
||||||
|AdminAuthenticator |adminOnly |Allows only administrators. |
|
|AdminAuthenticator |adminOnly |Allows only administrators. |
|
||||||
|CollaboratorsAuthenticator|collaboratorsOnly|Allows only collaborators and administrators. |
|
|CollaboratorsAuthenticator|collaboratorsOnly|Allows only collaborators and administrators. |
|
||||||
|ReferrerAuthenticator |referrersOnly |Allows only the repository owner (or manager for group repository) and administrators.|
|
|ReferrerAuthenticator |referrersOnly |Allows only the repository owner (or manager for group repository) and administrators.|
|
||||||
|ReadableUsersAuthenticator|readableUsersOnly|Allows only signed in users which can access the repository. |
|
|ReadableUsersAuthenticator|readableUsersOnly|Allows only signed-in users which can access the repository. |
|
||||||
|GroupManagerAuthenticator |managersOnly |Allows only the group managers. |
|
|GroupManagerAuthenticator |managersOnly |Allows only the group managers. |
|
||||||
|
|
||||||
Of course, if you make a new plugin, you can define a your own authenticator according to requirement in your plugin.
|
Of course, if you make a new plugin, you can implement your own authenticator according to requirement in your plugin.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Automatic Schema Updating
|
|||||||
========
|
========
|
||||||
GitBucket updates database schema automatically using [Solidbase](https://github.com/gitbucket/solidbase) in the first run after the upgrading.
|
GitBucket updates database schema automatically using [Solidbase](https://github.com/gitbucket/solidbase) in the first run after the upgrading.
|
||||||
|
|
||||||
To release a new version of GitBucket, add the version definition to the [gitbucket.core.GitBucketCoreModule](https://github.com/gitbucket/gitbucket/blob/master/src/main/scala/gitbucket/core/GitBucketCoreModule.scala) at first.
|
To release a new version of GitBucket, add the version definition to [gitbucket.core.GitBucketCoreModule](https://github.com/gitbucket/gitbucket/blob/master/src/main/scala/gitbucket/core/GitBucketCoreModule.scala) at first.
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
object GitBucketCoreModule extends Module("gitbucket-core",
|
object GitBucketCoreModule extends Module("gitbucket-core",
|
||||||
@@ -17,7 +17,7 @@ object GitBucketCoreModule extends Module("gitbucket-core",
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Next, add a XML file which updates database schema into [/src/main/resources/update/](https://github.com/gitbucket/gitbucket/tree/master/src/main/resources/update) with a filenane defined in `GitBucketCoreModule`.
|
Next, add a XML file which updates database schema into [/src/main/resources/update/](https://github.com/gitbucket/gitbucket/tree/master/src/main/resources/update) with a filename defined in `GitBucketCoreModule`.
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
@@ -31,9 +31,9 @@ Next, add a XML file which updates database schema into [/src/main/resources/upd
|
|||||||
</changeSet>
|
</changeSet>
|
||||||
```
|
```
|
||||||
|
|
||||||
Solidbase stores the current version to `VERSIONS` table and checks it at start-up. If the stored version differs from the actual version, it executes differences between the stored version and the actual version.
|
Solidbase stores the current version to `VERSIONS` table and checks it at start-up. If the stored version different from the actual version, it executes differences between the stored version and the actual version.
|
||||||
|
|
||||||
We can add the SQL file instead of the XML file using `SqlMigration`. It try to load a SQL file from classpath as following order:
|
We can add the SQL file instead of the XML file using `SqlMigration`. It tries to load a SQL file from classpath in the following order:
|
||||||
|
|
||||||
1. Specified path (if specified)
|
1. Specified path (if specified)
|
||||||
2. `${moduleId}_${version}_${database}.sql`
|
2. `${moduleId}_${version}_${database}.sql`
|
||||||
@@ -51,4 +51,4 @@ object GitBucketCoreModule extends Module("gitbucket-core",
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
See more details [README of Solidbase](https://github.com/gitbucket/solidbase).
|
See more details at [README of Solidbase](https://github.com/gitbucket/solidbase).
|
||||||
|
|||||||
76
doc/build.md
Normal file
76
doc/build.md
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
How to build and run from the source tree
|
||||||
|
========
|
||||||
|
|
||||||
|
First of all, Install [sbt](https://www.scala-sbt.org/index.html).
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ brew install sbt
|
||||||
|
```
|
||||||
|
|
||||||
|
Run for Development
|
||||||
|
--------
|
||||||
|
|
||||||
|
If you want to test GitBucket, type the following command in the root directory of the source tree.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ sbt ~jetty:start
|
||||||
|
```
|
||||||
|
|
||||||
|
Then access `http://localhost:8080/` in your browser. The default administrator account is `root` and password is `root`.
|
||||||
|
|
||||||
|
Source code modifications are detected and a reloading happens automatically.
|
||||||
|
You can modify the logging configuration by editing `src/main/resources/logback-dev.xml`.
|
||||||
|
|
||||||
|
Note that HttpSession is cleared when auto-reloading happened.
|
||||||
|
This is a bit annoying when developing features that requires sign-in.
|
||||||
|
You can keep HttpSession even if GitBucket is restarted by enabling this configuration in `build.sbt`:
|
||||||
|
https://github.com/gitbucket/gitbucket/blob/d5c083b70f7f3748d080166252e9a3dcaf579648/build.sbt#L292
|
||||||
|
|
||||||
|
Or by launching GitBucket with the following command:
|
||||||
|
```shell
|
||||||
|
sbt '; set Jetty/javaOptions += "-Ddev-features=keep-session" ; ~jetty:start'
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that this feature serializes HttpSession on the local disk and assigns all requests to the same session
|
||||||
|
which means you cannot test multi users behavior in this mode.
|
||||||
|
|
||||||
|
Build war file
|
||||||
|
--------
|
||||||
|
|
||||||
|
To build a war file, run the following command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ sbt package
|
||||||
|
```
|
||||||
|
|
||||||
|
`gitbucket_2.13-x.x.x.war` is generated into `target/scala-2.13`.
|
||||||
|
|
||||||
|
To build an executable war file, run
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ sbt executable
|
||||||
|
```
|
||||||
|
|
||||||
|
at the top of the source tree. It generates executable `gitbucket.war` into `target/executable`.
|
||||||
|
We release this war file as release artifact.
|
||||||
|
|
||||||
|
Run tests spec
|
||||||
|
---------
|
||||||
|
Before running tests, you need to install docker.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ brew cask install docker # Install Docker
|
||||||
|
$ open /Applications/Docker.app # Start Docker
|
||||||
|
```
|
||||||
|
|
||||||
|
To run the full series of tests, run the following command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ sbt test
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't have docker, you can skip docker tests which require docker as follows:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ sbt "testOnly * -- -l ExternalDBTest"
|
||||||
|
```
|
||||||
22
doc/debug.md
Normal file
22
doc/debug.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
Debug GitBucket on IntelliJ
|
||||||
|
========
|
||||||
|
Add following configuration for allowing remote debugging to `build.sbt`:
|
||||||
|
|
||||||
|
```scala
|
||||||
|
javaOptions in Jetty ++= Seq(
|
||||||
|
"-Xdebug",
|
||||||
|
"-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
Run GitBucket:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ sbt ~jetty:start
|
||||||
|
```
|
||||||
|
|
||||||
|
In IntelliJ, create remote debug configuration as follows. Make sure port number is same as above configuration.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Then you can start debugging on IntelliJ!
|
||||||
@@ -5,20 +5,27 @@ GitBucket persists all data into __HOME/.gitbucket__ in default (In 1.9 or befor
|
|||||||
This directory has following structure:
|
This directory has following structure:
|
||||||
|
|
||||||
```
|
```
|
||||||
* /HOME/gitbucket
|
* /HOME/.gitbucket
|
||||||
|
* gitbucket.conf
|
||||||
|
* database.conf
|
||||||
|
* activity.log
|
||||||
|
* data.mv.db, data.trace.db (H2 data files if the default embed H2 is used)
|
||||||
* /repositories
|
* /repositories
|
||||||
* /USER_NAME
|
* /USER_NAME
|
||||||
* /REPO_NAME.git (substance of repository. GitServlet sees this directory)
|
* /REPO_NAME.git (substance of repository. GitServlet sees this directory)
|
||||||
* /REPO_NAME
|
|
||||||
* /issues (files which are attached to issue)
|
|
||||||
* /REPO_NAME.wiki.git (wiki repository)
|
* /REPO_NAME.wiki.git (wiki repository)
|
||||||
|
* /REPO_NAME
|
||||||
|
* /issues (files attached to issue)
|
||||||
|
* /lfs (LFS managed files)
|
||||||
* /data
|
* /data
|
||||||
* /USER_NAME
|
* /USER_NAME
|
||||||
* /files
|
* /files
|
||||||
* avatar.xxx (image file of user avatar)
|
* avatar.xxx (image file of user avatar)
|
||||||
* /plugins
|
* /plugins
|
||||||
* /PLUGIN_NAME
|
* plugin.jar
|
||||||
* plugin.js
|
* /.installed (copied available plugins from the parent directory automatically)
|
||||||
|
* /sessions
|
||||||
|
* HTTP session data created (if '--save_sessions' option is used in the standalone mode)
|
||||||
* /tmp
|
* /tmp
|
||||||
* /_upload
|
* /_upload
|
||||||
* /SESSION_ID (removed at session timeout)
|
* /SESSION_ID (removed at session timeout)
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
How to run from the source tree
|
|
||||||
========
|
|
||||||
|
|
||||||
Install [sbt](http://www.scala-sbt.org/index.html) at first.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ brew install sbt
|
|
||||||
```
|
|
||||||
|
|
||||||
Run for Development
|
|
||||||
--------
|
|
||||||
|
|
||||||
If you want to test GitBucket, type the following command in the root directory of the source tree.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sbt ~jetty:start
|
|
||||||
```
|
|
||||||
|
|
||||||
Then access `http://localhost:8080/` in your browser. The default administrator account is `root` and password is `root`.
|
|
||||||
|
|
||||||
Source code modifications are detected and a reloaded happens automatically. You can modify the logging configuration by editing `src/main/resources/logback-dev.xml`.
|
|
||||||
|
|
||||||
Build war file
|
|
||||||
--------
|
|
||||||
|
|
||||||
To build war file, run the following command:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sbt package
|
|
||||||
```
|
|
||||||
|
|
||||||
`gitbucket_2.12-x.x.x.war` is generated into `target/scala-2.12`.
|
|
||||||
|
|
||||||
To build an executable war file, run
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sbt executable
|
|
||||||
```
|
|
||||||
|
|
||||||
at the top of the source tree. It generates executable `gitbucket.war` into `target/executable`. We release this war file as release artifact.
|
|
||||||
|
|
||||||
Run tests spec
|
|
||||||
---------
|
|
||||||
To run the full series of tests, run the following command:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sbt test
|
|
||||||
```
|
|
||||||
172
doc/licenses.md
172
doc/licenses.md
@@ -4,98 +4,128 @@ Category | License | Dependency | Notes
|
|||||||
--- | --- | --- | ---
|
--- | --- | --- | ---
|
||||||
Apache | [ Apache License, Version 2.0 ]( http://opensource.org/licenses/apache2.0.php ) | org.osgi # org.osgi.core # 4.3.1 | <notextile></notextile>
|
Apache | [ Apache License, Version 2.0 ]( http://opensource.org/licenses/apache2.0.php ) | org.osgi # org.osgi.core # 4.3.1 | <notextile></notextile>
|
||||||
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.googlecode.javaewah # JavaEWAH # 1.1.6 | <notextile></notextile>
|
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.googlecode.javaewah # JavaEWAH # 1.1.6 | <notextile></notextile>
|
||||||
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0) | org.cache2k # cache2k-all # 1.0.0.CR1 | <notextile></notextile>
|
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0) | org.cache2k # cache2k-all # 1.2.0.Final | <notextile></notextile>
|
||||||
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.objenesis # objenesis # 2.5 | <notextile></notextile>
|
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0) | org.cache2k # cache2k-api # 1.2.0.Final | <notextile></notextile>
|
||||||
Apache | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) | org.apache.sshd # apache-sshd # 1.4.0 | <notextile></notextile>
|
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0) | org.cache2k # cache2k-core # 1.2.0.Final | <notextile></notextile>
|
||||||
Apache | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) | org.apache.sshd # sshd-core # 1.4.0 | <notextile></notextile>
|
Apache | [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.objenesis # objenesis # 2.6 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | com.typesafe # config # 1.3.1 | <notextile></notextile>
|
Apache | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) | org.apache.sshd # apache-sshd # 2.1.0 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | com.typesafe.akka # akka-actor_2.12 # 2.5.0 | <notextile></notextile>
|
Apache | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) | org.apache.sshd # sshd-cli # 2.1.0 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | commons-io # commons-io # 2.5 | <notextile></notextile>
|
Apache | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) | org.apache.sshd # sshd-common # 2.1.0 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | fr.brouillard.oss.security.xhub # xhub4j-core # 1.0.0 | <notextile></notextile>
|
Apache | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) | org.apache.sshd # sshd-core # 2.1.0 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.commons # commons-compress # 1.13 | <notextile></notextile>
|
Apache | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) | org.apache.sshd # sshd-putty # 2.1.0 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.commons # commons-email # 1.4 | <notextile></notextile>
|
Apache | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) | org.apache.sshd # sshd-scp # 2.1.0 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.commons # commons-lang3 # 3.5 | <notextile></notextile>
|
Apache | [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) | org.apache.sshd # sshd-sftp # 2.1.0 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.httpcomponents # httpclient # 4.5.3 | <notextile></notextile>
|
Apache | [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | net.java.dev.jna # jna # 4.5.1 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.httpcomponents # httpcore # 4.4.6 | <notextile></notextile>
|
Apache | [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | net.java.dev.jna # jna-platform # 4.5.1 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.httpcomponents # httpmime # 4.5.2 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.github.stephenc.jcip # jcip-annotations # 1.0-1 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.tika # tika-core # 1.14 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.kohlschutter.junixsocket # junixsocket-common # 2.0.4 | <notextile></notextile>
|
||||||
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.liquibase # liquibase-core # 3.4.1 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.kohlschutter.junixsocket # junixsocket-native-common # 2.0.4 | <notextile></notextile>
|
||||||
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-http # 9.2.19.v20160908 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) | com.typesafe # config # 1.3.3 | <notextile></notextile>
|
||||||
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-io # 9.2.19.v20160908 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | com.typesafe.akka # akka-actor_2.12 # 2.5.18 | <notextile></notextile>
|
||||||
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-security # 9.2.19.v20160908 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) | commons-io # commons-io # 2.6 | <notextile></notextile>
|
||||||
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-server # 9.2.19.v20160908 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | is.tagomor.woothee # woothee-java # 1.8.0 | <notextile></notextile>
|
||||||
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-servlet # 9.2.19.v20160908 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.commons # commons-compress # 1.18 | <notextile></notextile>
|
||||||
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-util # 9.2.19.v20160908 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.commons # commons-email # 1.5 | <notextile></notextile>
|
||||||
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-webapp # 9.2.19.v20160908 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.commons # commons-lang3 # 3.6 | <notextile></notextile>
|
||||||
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-xml # 9.2.19.v20160908 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.httpcomponents # httpclient # 4.5.6 | <notextile></notextile>
|
||||||
Apache | [Apache Software License, Version 1.1](http://www.apache.org/licenses/LICENSE-1.1) | org.bouncycastle # bcpg-jdk15on # 1.56 | <notextile></notextile>
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.httpcomponents # httpcore # 4.4.10 | <notextile></notextile>
|
||||||
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.httpcomponents # httpmime # 4.5.3 | <notextile></notextile>
|
||||||
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.apache.tika # tika-core # 1.19.1 | <notextile></notextile>
|
||||||
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.ec4j.core # ec4j-core # 0.0.3 | <notextile></notextile>
|
||||||
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.liquibase # liquibase-core # 3.6.2 | <notextile></notextile>
|
||||||
|
Apache | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.yaml # snakeyaml # 1.18 | <notextile></notextile>
|
||||||
|
Apache | [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) | com.nimbusds # oauth2-oidc-sdk # 5.64.4 | <notextile></notextile>
|
||||||
|
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-http # 9.4.6.v20170531 | <notextile></notextile>
|
||||||
|
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-io # 9.4.6.v20170531 | <notextile></notextile>
|
||||||
|
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-security # 9.4.6.v20170531 | <notextile></notextile>
|
||||||
|
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-server # 9.4.6.v20170531 | <notextile></notextile>
|
||||||
|
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-servlet # 9.4.6.v20170531 | <notextile></notextile>
|
||||||
|
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-util # 9.4.6.v20170531 | <notextile></notextile>
|
||||||
|
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-webapp # 9.4.6.v20170531 | <notextile></notextile>
|
||||||
|
Apache | [Apache Software License - Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.eclipse.jetty # jetty-xml # 9.4.6.v20170531 | <notextile></notextile>
|
||||||
|
Apache | [Apache Software License, Version 1.1](http://www.apache.org/licenses/LICENSE-1.1) | org.bouncycastle # bcpg-jdk15on # 1.60 | <notextile></notextile>
|
||||||
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | com.github.bkromhout # java-diff-utils # 2.1.1 | <notextile></notextile>
|
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | com.github.bkromhout # java-diff-utils # 2.1.1 | <notextile></notextile>
|
||||||
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0.html) | com.typesafe.play # twirl-api_2.12 # 1.3.7 | <notextile></notextile>
|
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0.html) | com.typesafe.play # twirl-api_2.12 # 1.3.15 | <notextile></notextile>
|
||||||
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.json4s # json4s-ast_2.12 # 3.5.1 | <notextile></notextile>
|
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.json4s # json4s-ast_2.12 # 3.5.2 | <notextile></notextile>
|
||||||
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.json4s # json4s-core_2.12 # 3.5.1 | <notextile></notextile>
|
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.json4s # json4s-core_2.12 # 3.5.2 | <notextile></notextile>
|
||||||
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.json4s # json4s-jackson_2.12 # 3.5.1 | <notextile></notextile>
|
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.json4s # json4s-jackson_2.12 # 3.5.2 | <notextile></notextile>
|
||||||
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.json4s # json4s-scalap_2.12 # 3.5.1 | <notextile></notextile>
|
Apache | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.json4s # json4s-scalap_2.12 # 3.5.2 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.enragedginger # akka-quartz-scheduler_2.12 # 1.6.0-akka-2.4.x | <notextile></notextile>
|
Apache | [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0) | org.scala-lang # scala-library # 2.12.8 | <notextile></notextile>
|
||||||
|
Apache | [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0) | org.scala-lang # scala-reflect # 2.12.8 | <notextile></notextile>
|
||||||
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.enragedginger # akka-quartz-scheduler_2.12 # 1.7.0-akka-2.5.x | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.fasterxml.jackson.core # jackson-annotations # 2.8.0 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.fasterxml.jackson.core # jackson-annotations # 2.8.0 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.fasterxml.jackson.core # jackson-core # 2.8.4 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.fasterxml.jackson.core # jackson-core # 2.8.4 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.fasterxml.jackson.core # jackson-databind # 2.8.4 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.fasterxml.jackson.core # jackson-databind # 2.8.4 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.github.takezoe # blocking-slick-32_2.12 # 0.0.10 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.github.takezoe # blocking-slick-32_2.12 # 0.0.11 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.code.findbugs # jsr305 # 3.0.0 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.google.code.findbugs # jsr305 # 3.0.0 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.zaxxer # HikariCP # 2.6.1 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.nimbusds # lang-tag # 1.4.3 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | commons-codec # commons-codec # 1.9 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.nimbusds # nimbus-jose-jwt # 5.5 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | commons-logging # commons-logging # 1.2 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | com.zaxxer # HikariCP # 3.2.0 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | de.flapdoodle.embed # de.flapdoodle.embed.process # 2.0.1 | <notextile></notextile>
|
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | eu.medsea.mimeutil # mime-util # 2.1.3 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | eu.medsea.mimeutil # mime-util # 2.1.3 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | io.github.gitbucket # markedj # 1.0.15 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | io.github.gitbucket # markedj # 1.0.15 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | io.github.gitbucket # scalatra-forms_2.12 # 1.1.0 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | io.github.gitbucket # solidbase # 1.0.3 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | io.github.gitbucket # solidbase # 1.0.2 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | net.bytebuddy # byte-buddy # 1.9.3 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | net.bytebuddy # byte-buddy # 1.6.11 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | net.bytebuddy # byte-buddy-agent # 1.9.3 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | net.bytebuddy # byte-buddy-agent # 1.6.11 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | net.minidev # accessors-smart # 1.2 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.quartz-scheduler # quartz # 2.2.3 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | net.minidev # json-smart # 2.3 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | ru.yandex.qatools.embed # postgresql-embedded # 2.0 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.jetbrains # annotations # 15.0 | <notextile></notextile>
|
||||||
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | tomcat # tomcat-apr # 5.5.23 | <notextile></notextile>
|
Apache | [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) | org.quartz-scheduler # quartz # 2.3.0 | <notextile></notextile>
|
||||||
Apache | [the Apache License, ASL Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.scalactic # scalactic_2.12 # 3.0.0 | <notextile></notextile>
|
Apache | [the Apache License, ASL Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.scalactic # scalactic_2.12 # 3.0.3 | <notextile></notextile>
|
||||||
Apache | [the Apache License, ASL Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.scalatest # scalatest_2.12 # 3.0.0 | <notextile></notextile>
|
Apache | [the Apache License, ASL Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | org.scalatest # scalatest_2.12 # 3.0.3 | <notextile></notextile>
|
||||||
BSD | [BSD](LICENSE.txt) | com.thoughtworks.paranamer # paranamer # 2.8 | <notextile></notextile>
|
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra-common_2.12 # 2.6.3 | <notextile></notextile>
|
||||||
BSD | [BSD](http://software.clapper.org/grizzled-slf4j/license.html) | org.clapper # grizzled-slf4j_2.12 # 1.3.0 | <notextile></notextile>
|
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra-forms_2.12 # 2.6.3 | <notextile></notextile>
|
||||||
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra-common_2.12 # 2.5.0 | <notextile></notextile>
|
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra-json_2.12 # 2.6.3 | <notextile></notextile>
|
||||||
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra-json_2.12 # 2.5.0 | <notextile></notextile>
|
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra-scalatest_2.12 # 2.6.3 | <notextile></notextile>
|
||||||
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra-scalatest_2.12 # 2.5.0 | <notextile></notextile>
|
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra-test_2.12 # 2.6.3 | <notextile></notextile>
|
||||||
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra-test_2.12 # 2.5.0 | <notextile></notextile>
|
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra_2.12 # 2.6.3 | <notextile></notextile>
|
||||||
BSD | [BSD](http://github.com/scalatra/scalatra/raw/HEAD/LICENSE) | org.scalatra # scalatra_2.12 # 2.5.0 | <notextile></notextile>
|
|
||||||
BSD | [BSD 3-Clause](http://www.scala-lang.org/license.html) | org.scala-lang # scala-library # 2.12.3 | <notextile></notextile>
|
|
||||||
BSD | [BSD 3-Clause](http://www.scala-lang.org/license.html) | org.scala-lang # scala-reflect # 2.12.3 | <notextile></notextile>
|
|
||||||
BSD | [BSD 3-clause](http://opensource.org/licenses/BSD-3-Clause) | org.scala-lang.modules # scala-java8-compat_2.12 # 0.8.0 | <notextile></notextile>
|
BSD | [BSD 3-clause](http://opensource.org/licenses/BSD-3-Clause) | org.scala-lang.modules # scala-java8-compat_2.12 # 0.8.0 | <notextile></notextile>
|
||||||
BSD | [BSD 3-clause](http://opensource.org/licenses/BSD-3-Clause) | org.scala-lang.modules # scala-parser-combinators_2.12 # 1.0.4 | <notextile></notextile>
|
BSD | [BSD 3-clause](http://opensource.org/licenses/BSD-3-Clause) | org.scala-lang.modules # scala-parser-combinators_2.12 # 1.0.6 | <notextile></notextile>
|
||||||
BSD | [BSD 3-clause](http://opensource.org/licenses/BSD-3-Clause) | org.scala-lang.modules # scala-xml_2.12 # 1.0.6 | <notextile></notextile>
|
BSD | [BSD 3-clause](http://opensource.org/licenses/BSD-3-Clause) | org.scala-lang.modules # scala-xml_2.12 # 1.0.6 | <notextile></notextile>
|
||||||
BSD | [BSD License](http://www.opensource.org/licenses/bsd-license.php) | com.wix # wix-embedded-mysql # 2.1.4 | <notextile></notextile>
|
BSD | [BSD-2-Clause](https://jdbc.postgresql.org/about/license.html) | org.postgresql # postgresql # 42.2.5 | <notextile></notextile>
|
||||||
BSD | [BSD-2-Clause](https://jdbc.postgresql.org/about/license.html) | org.postgresql # postgresql # 42.0.0 | <notextile></notextile>
|
BSD | [Eclipse Distribution License (New BSD License)](null) | org.eclipse.jgit # org.eclipse.jgit # 5.2.0.201812061821-r | <notextile></notextile>
|
||||||
BSD | [Eclipse Distribution License (New BSD License)](null) | org.eclipse.jgit # org.eclipse.jgit # 4.8.0.201706111038-r | <notextile></notextile>
|
BSD | [Eclipse Distribution License (New BSD License)](null) | org.eclipse.jgit # org.eclipse.jgit.archive # 5.2.0.201812061821-r | <notextile></notextile>
|
||||||
BSD | [Eclipse Distribution License (New BSD License)](null) | org.eclipse.jgit # org.eclipse.jgit.archive # 4.8.0.201706111038-r | <notextile></notextile>
|
BSD | [Eclipse Distribution License (New BSD License)](null) | org.eclipse.jgit # org.eclipse.jgit.http.server # 5.2.0.201812061821-r | <notextile></notextile>
|
||||||
BSD | [Eclipse Distribution License (New BSD License)](null) | org.eclipse.jgit # org.eclipse.jgit.http.server # 4.8.0.201706111038-r | <notextile></notextile>
|
|
||||||
BSD | [New BSD License](http://www.opensource.org/licenses/bsd-license.php) | org.hamcrest # hamcrest-core # 1.3 | <notextile></notextile>
|
BSD | [New BSD License](http://www.opensource.org/licenses/bsd-license.php) | org.hamcrest # hamcrest-core # 1.3 | <notextile></notextile>
|
||||||
BSD | [Revised BSD](http://www.jcraft.com/jsch/LICENSE.txt) | com.jcraft # jsch # 0.1.54 | <notextile></notextile>
|
BSD | [Revised BSD](http://www.jcraft.com/jsch/LICENSE.txt) | com.jcraft # jsch # 0.1.54 | <notextile></notextile>
|
||||||
|
BSD | [Revised BSD](http://www.jcraft.com/jzlib/LICENSE.txt) | com.jcraft # jzlib # 1.1.1 | <notextile></notextile>
|
||||||
BSD | [Two-clause BSD-style license](http://github.com/slick/slick/blob/master/LICENSE.txt) | com.typesafe.slick # slick_2.12 # 3.2.1 | <notextile></notextile>
|
BSD | [Two-clause BSD-style license](http://github.com/slick/slick/blob/master/LICENSE.txt) | com.typesafe.slick # slick_2.12 # 3.2.1 | <notextile></notextile>
|
||||||
CC0 | [CC0](http://creativecommons.org/publicdomain/zero/1.0/) | org.reactivestreams # reactive-streams # 1.0.0 | <notextile></notextile>
|
CC0 | [CC0](http://creativecommons.org/publicdomain/zero/1.0/) | org.reactivestreams # reactive-streams # 1.0.0 | <notextile></notextile>
|
||||||
CDDL | [COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0](https://glassfish.dev.java.net/public/CDDLv1.0.html) | javax.activation # activation # 1.1.1 | <notextile></notextile>
|
CC0 | [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/) | net.i2p.crypto # eddsa # 0.3.0 | <notextile></notextile>
|
||||||
GPL | [CDDL/GPLv2+CE](https://glassfish.java.net/public/CDDL+GPL_1_1.html) | com.sun.mail # javax.mail # 1.5.2 | <notextile></notextile>
|
CC0 | [CC0 1.0 Universal License](http://creativecommons.org/publicdomain/zero/1.0/) | org.scijava # native-lib-loader # 2.0.2 | <notextile></notextile>
|
||||||
|
CDDL | [Common Development and Distribution License (CDDL) v1.0](https://glassfish.dev.java.net/public/CDDLv1.0.html) | javax.activation # activation # 1.1 | <notextile></notextile>
|
||||||
|
GPL | [CDDL/GPLv2+CE](https://javaee.github.io/javamail/LICENSE) | com.sun.mail # javax.mail # 1.6.1 | <notextile></notextile>
|
||||||
|
GPL | [GPL2 w/ CPE](https://oss.oracle.com/licenses/CDDL+GPL-1.1) | javax.xml.bind # jaxb-api # 2.3.0 | <notextile></notextile>
|
||||||
|
GPL with Classpath Extension | [CDDL + GPLv2 with classpath exception](https://github.com/javaee/javax.annotation/blob/master/LICENSE) | javax.annotation # javax.annotation-api # 1.3.1 | <notextile></notextile>
|
||||||
GPL with Classpath Extension | [CDDL + GPLv2 with classpath exception](https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html) | javax.servlet # javax.servlet-api # 3.1.0 | <notextile></notextile>
|
GPL with Classpath Extension | [CDDL + GPLv2 with classpath exception](https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html) | javax.servlet # javax.servlet-api # 3.1.0 | <notextile></notextile>
|
||||||
LGPL | [GNU Lesser General Public License](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) | ch.qos.logback # logback-classic # 1.2.3 | <notextile></notextile>
|
LGPL | [GNU Lesser General Public License](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) | ch.qos.logback # logback-classic # 1.2.3 | <notextile></notextile>
|
||||||
LGPL | [GNU Lesser General Public License](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) | ch.qos.logback # logback-core # 1.2.3 | <notextile></notextile>
|
LGPL | [GNU Lesser General Public License](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) | ch.qos.logback # logback-core # 1.2.3 | <notextile></notextile>
|
||||||
LGPL | [LGPL, version 2.1](http://www.gnu.org/licenses/licenses.html) | net.java.dev.jna # jna # 4.0.0 | <notextile></notextile>
|
LGPL | [GNU Lesser General Public License, Version 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) | com.mchange # c3p0 # 0.9.5.2 | <notextile></notextile>
|
||||||
LGPL | [LGPL, version 2.1](http://www.gnu.org/licenses/licenses.html) | net.java.dev.jna # jna-platform # 4.0.0 | <notextile></notextile>
|
LGPL | [GNU Lesser General Public License, Version 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) | com.mchange # mchange-commons-java # 0.2.11 | <notextile></notextile>
|
||||||
LGPL | [LGPL-2.1](null) | org.mariadb.jdbc # mariadb-java-client # 2.0.3 | <notextile></notextile>
|
LGPL | [LGPL-2.1](null) | org.mariadb.jdbc # mariadb-java-client # 2.3.0 | <notextile></notextile>
|
||||||
|
MIT | [MIT](http://opensource.org/licenses/MIT) | org.rnorth # tcp-unix-socket-proxy # 1.0.2 | <notextile></notextile>
|
||||||
|
MIT | [MIT](http://opensource.org/licenses/MIT) | org.rnorth.duct-tape # duct-tape # 1.0.7 | <notextile></notextile>
|
||||||
|
MIT | [MIT](http://opensource.org/licenses/MIT) | org.rnorth.visible-assertions # visible-assertions # 2.1.1 | <notextile></notextile>
|
||||||
|
MIT | [MIT](http://opensource.org/licenses/MIT) | org.testcontainers # database-commons # 1.10.3 | <notextile></notextile>
|
||||||
|
MIT | [MIT](http://opensource.org/licenses/MIT) | org.testcontainers # jdbc # 1.10.3 | <notextile></notextile>
|
||||||
|
MIT | [MIT](http://opensource.org/licenses/MIT) | org.testcontainers # mysql # 1.10.3 | <notextile></notextile>
|
||||||
|
MIT | [MIT](http://opensource.org/licenses/MIT) | org.testcontainers # postgresql # 1.10.3 | <notextile></notextile>
|
||||||
|
MIT | [MIT](http://opensource.org/licenses/MIT) | org.testcontainers # testcontainers # 1.10.3 | <notextile></notextile>
|
||||||
MIT | [MIT License](http://www.opensource.org/licenses/mit-license.php) | org.slf4j # slf4j-api # 1.7.25 | <notextile></notextile>
|
MIT | [MIT License](http://www.opensource.org/licenses/mit-license.php) | org.slf4j # slf4j-api # 1.7.25 | <notextile></notextile>
|
||||||
MIT | [The MIT License](http://www.opensource.org/licenses/mit-license.php) | com.github.zafarkhaja # java-semver # 0.9.0 | <notextile></notextile>
|
MIT | [The MIT License](http://www.opensource.org/licenses/mit-license.php) | com.github.zafarkhaja # java-semver # 0.9.0 | <notextile></notextile>
|
||||||
MIT | [The MIT License](https://jsoup.org/license) | org.jsoup # jsoup # 1.10.2 | <notextile></notextile>
|
MIT | [The MIT License](https://jsoup.org/license) | org.jsoup # jsoup # 1.10.2 | <notextile></notextile>
|
||||||
MIT | [The MIT License](http://github.com/mockito/mockito/blob/master/LICENSE) | org.mockito # mockito-all # 1.10.19 | <notextile></notextile>
|
MIT | [The MIT License](https://github.com/mockito/mockito/blob/master/LICENSE) | org.mockito # mockito-core # 2.23.4 | <notextile></notextile>
|
||||||
MIT | [The MIT License](http://github.com/mockito/mockito/blob/master/LICENSE) | org.mockito # mockito-core # 2.7.22 | <notextile></notextile>
|
MIT | [The MIT License (MIT)](https://opensource.org/licenses/MIT) | com.dimafeng # testcontainers-scala_2.12 # 0.22.0 | <notextile></notextile>
|
||||||
MIT | [The MIT License (MIT)](http://www.opensource.org/licenses/mit-license.html) | net.coobird # thumbnailator # 0.4.8 | <notextile></notextile>
|
MIT | [The MIT License (MIT)](http://www.opensource.org/licenses/mit-license.html) | net.coobird # thumbnailator # 0.4.8 | <notextile></notextile>
|
||||||
Mozilla | [MPL 2.0 or EPL 1.0](http://h2database.com/html/license.html) | com.h2database # h2 # 1.4.195 | <notextile></notextile>
|
Mozilla | [MPL 2.0 or EPL 1.0](http://h2database.com/html/license.html) | com.h2database # h2 # 1.4.197 | <notextile></notextile>
|
||||||
Mozilla | [Mozilla Public License 1.1 (MPL 1.1)](http://www.mozilla.org/MPL/MPL-1.1.html) | com.googlecode.juniversalchardet # juniversalchardet # 1.0.3 | <notextile></notextile>
|
Mozilla | [Mozilla Public License 1.1 (MPL 1.1)](http://www.mozilla.org/MPL/MPL-1.1.html) | com.googlecode.juniversalchardet # juniversalchardet # 1.0.3 | <notextile></notextile>
|
||||||
Public Domain | [Public Domain](http://en.wikipedia.org/wiki/Public_domain) | net.i2p.crypto # eddsa # 0.1.0 | <notextile></notextile>
|
unrecognized | [Bouncy Castle Licence](http://www.bouncycastle.org/licence.html) | org.bouncycastle # bcpkix-jdk15on # 1.60 | <notextile></notextile>
|
||||||
unrecognized | [Bouncy Castle Licence](http://www.bouncycastle.org/licence.html) | org.bouncycastle # bcpkix-jdk15on # 1.56 | <notextile></notextile>
|
unrecognized | [Bouncy Castle Licence](http://www.bouncycastle.org/licence.html) | org.bouncycastle # bcprov-jdk15on # 1.60 | <notextile></notextile>
|
||||||
unrecognized | [Bouncy Castle Licence](http://www.bouncycastle.org/licence.html) | org.bouncycastle # bcprov-jdk15on # 1.56 | <notextile></notextile>
|
|
||||||
unrecognized | [Eclipse Public License 1.0](http://www.eclipse.org/legal/epl-v10.html) | junit # junit # 4.12 | <notextile></notextile>
|
unrecognized | [Eclipse Public License 1.0](http://www.eclipse.org/legal/epl-v10.html) | junit # junit # 4.12 | <notextile></notextile>
|
||||||
unrecognized | [The OpenLDAP Public License](http://www.openldap.org/software/release/license.html) | com.novell.ldap # jldap # 2009-10-07 | <notextile></notextile>
|
unrecognized | [The OpenLDAP Public License](http://www.openldap.org/software/release/license.html) | com.novell.ldap # jldap # 2009-10-07 | <notextile></notextile>
|
||||||
|
unrecognized | [none specified](none specified) | com.thoughtworks.paranamer # paranamer # 2.8 | <notextile></notextile>
|
||||||
|
unrecognized | [none specified](none specified) | commons-codec # commons-codec # 1.10 | <notextile></notextile>
|
||||||
|
unrecognized | [none specified](none specified) | commons-logging # commons-logging # 1.2 | <notextile></notextile>
|
||||||
|
unrecognized | [none specified](none specified) | fr.brouillard.oss.security.xhub # xhub4j-core # 1.0.0 | <notextile></notextile>
|
||||||
|
unrecognized | [none specified](none specified) | org.ow2.asm # asm # 5.0.4 | <notextile></notextile>
|
||||||
|
unrecognized | [none specified](none specified) | tomcat # tomcat-apr # 5.5.23 | <notextile></notextile>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
Developer's Guide
|
Developer's Guide
|
||||||
========
|
========
|
||||||
* [How to run from source tree](how_to_run.md)
|
* [Build from source tree](build.md)
|
||||||
|
* [Debug on IntelliJ](debug.md)
|
||||||
* [Directory Structure](directory.md)
|
* [Directory Structure](directory.md)
|
||||||
* [Mapping and Validation](validation.md)
|
* [Mapping and Validation](validation.md)
|
||||||
* [Authentication in Controller](authenticator.md)
|
* [Authentication in Controller](authenticator.md)
|
||||||
|
|||||||
@@ -34,6 +34,20 @@ object GitBucketCoreModule extends Module("gitbucket-core",
|
|||||||
Generate release files
|
Generate release files
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
### Deploy assembly jar file
|
||||||
|
|
||||||
|
For plug-in development, we have to publish the GitBucket jar file to the Maven central repository before release GitBucket itself.
|
||||||
|
|
||||||
|
First, hit following command to publish artifacts to the sonatype OSS repository:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ sbt publishSigned
|
||||||
|
```
|
||||||
|
|
||||||
|
Then logged-in to https://oss.sonatype.org/, close and release the repository.
|
||||||
|
|
||||||
|
You need to wait up to a day until [gitbucket-notification-plugin](https://plugins.gitbucket-community.org/) which is default bundled plugin is built for new version of GitBucket.
|
||||||
|
|
||||||
### Make release war file
|
### Make release war file
|
||||||
|
|
||||||
Run `sbt executable`. The release war file and fingerprint are generated into `target/executable/gitbucket.war`.
|
Run `sbt executable`. The release war file and fingerprint are generated into `target/executable/gitbucket.war`.
|
||||||
@@ -42,20 +56,4 @@ Run `sbt executable`. The release war file and fingerprint are generated into `t
|
|||||||
$ sbt executable
|
$ sbt executable
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deploy assembly jar file
|
Create new release from the corresponded tag on GitHub, then upload generated jar file and fingerprints to the release.
|
||||||
|
|
||||||
For plug-in development, we have to publish the GitBucket jar file to the Maven central repository as well. At first, hit following command to publish artifacts to the sonatype OSS repository:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ sbt publishSigned
|
|
||||||
```
|
|
||||||
|
|
||||||
Then logged-in https://oss.sonatype.org/ and delete following files from the staging repository:
|
|
||||||
|
|
||||||
- gitbucket_2.12-x.x.x.war
|
|
||||||
- gitbucket_2.12-x.x.x.war.asc
|
|
||||||
- gitbucket_2.12-x.x.x.war.asc.md5
|
|
||||||
- gitbucket_2.12-x.x.x.war.asc.sha1
|
|
||||||
- gitbucket_2.12-x.x.x.war.md5
|
|
||||||
|
|
||||||
At last, close and release the repository.
|
|
||||||
|
|||||||
BIN
doc/remote_debug.png
Normal file
BIN
doc/remote_debug.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 112 KiB |
@@ -1,11 +1,11 @@
|
|||||||
Mapping and Validation
|
Mapping and Validation
|
||||||
========
|
========
|
||||||
GitBucket uses [scalatra-forms](https://github.com/takezoe/scalatra-forms) to validate request parameters and map them to the scala object. This is inspired by Play2 form mapping / validation.
|
GitBucket uses [scalatra-forms](https://scalatra.org/guides/2.8/formats/forms.html) to validate request parameters and map them to the scala object. This is inspired by Play2 form mapping / validation.
|
||||||
|
|
||||||
At first, define the mapping as following:
|
At first, define the mapping as following:
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
|
|
||||||
case class RegisterForm(name: String, description: String)
|
case class RegisterForm(name: String, description: String)
|
||||||
|
|
||||||
@@ -15,17 +15,17 @@ val form = mapping(
|
|||||||
)(RegisterForm.apply)
|
)(RegisterForm.apply)
|
||||||
```
|
```
|
||||||
|
|
||||||
The servlet have to mixed in ```jp.sf.amateras.scalatra.forms.ClientSideValidationFormSupport``` to validate request parameters and take mapped object. It validates request parameters before action. If any errors are detected, it throws an exception.
|
The servlet have to mixed in `gitbucket.core.controller.ValidationFormSupport` to validate request parameters and take mapped object. It validates request parameters before action. If any errors are detected, it throws an exception.
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
class RegisterServlet extends ScalatraServlet with ClientSideValidationFormSupport {
|
class RegisterServlet extends ScalatraServlet with ValidationFormSupport {
|
||||||
post("/register", form) { form: RegisterForm =>
|
post("/register", form) { form: RegisterForm =>
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
In the view template, you can add client-side validation by adding ```validate="true"``` to your form. Error messages are set to ```span#error-<fieldname>```.
|
In the view template, you can add client-side validation by adding `validate="true"` to your form. Error messages are set to `span#error-<fieldname>`.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<form method="POST" action="/register" validate="true">
|
<form method="POST" action="/register" validate="true">
|
||||||
@@ -39,9 +39,9 @@ In the view template, you can add client-side validation by adding ```validate="
|
|||||||
</form>
|
</form>
|
||||||
```
|
```
|
||||||
|
|
||||||
Client-side validation calls ```<form-action>/validate``` to validate form contents. It returns a validation result as JSON. In this case, form action is ```/register```, so ```/register/validate``` is called before submitting a form. ```ClientSideValidationFormSupport``` adds this JSON API automatically.
|
Client-side validation calls `<form-action>/validate` to validate form contents. It returns a validation result as JSON. In this case, form action is `/register`, so `/register/validate` is called before submitting a form. `ValidationFormSupport` adds this JSON API automatically.
|
||||||
|
|
||||||
For Ajax request, you have to use '''ajaxGet''' or '''ajaxPost''' to define action. It almost same as '''get''' or '''post'''. You can implement actions which handle Ajax request as same as normal actions.
|
For Ajax request, you have to use `ajaxGet` or `ajaxPost` to define action. It almost same as '''get''' or '''post'''. You can implement actions which handle Ajax request as same as normal actions.
|
||||||
Small difference is they return validation errors as JSON.
|
Small difference is they return validation errors as JSON.
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
sbt.version=1.2.6
|
sbt.version=1.10.0
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
|
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
|
||||||
|
|
||||||
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.0")
|
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
|
||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.3.15")
|
addSbtPlugin("org.playframework.twirl" % "sbt-twirl" % "2.0.5")
|
||||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
|
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0")
|
||||||
addSbtPlugin("org.scalatra.sbt" % "sbt-scalatra" % "1.0.3")
|
addSbtPlugin("org.scalatra.sbt" % "sbt-scalatra" % "1.0.4")
|
||||||
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
|
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
|
||||||
addSbtCoursier
|
addSbtPlugin("com.github.sbt" % "sbt-license-report" % "1.6.1")
|
||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-license-report" % "1.2.0")
|
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.12")
|
||||||
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")
|
|
||||||
|
addDependencyTreePlugin
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0")
|
|
||||||
@@ -1,46 +1,109 @@
|
|||||||
import org.eclipse.jetty.server.ConnectionFactory;
|
import org.eclipse.jetty.http.HttpVersion;
|
||||||
import org.eclipse.jetty.server.Connector;
|
|
||||||
import org.eclipse.jetty.server.Handler;
|
import org.eclipse.jetty.server.Handler;
|
||||||
|
import org.eclipse.jetty.server.HttpConfiguration;
|
||||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||||
|
import org.eclipse.jetty.server.SecureRequestCustomizer;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
|
import org.eclipse.jetty.server.SslConnectionFactory;
|
||||||
|
import org.eclipse.jetty.server.handler.HandlerList;
|
||||||
|
import org.eclipse.jetty.server.handler.SecuredRedirectHandler;
|
||||||
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
||||||
|
import org.eclipse.jetty.server.session.DefaultSessionCache;
|
||||||
|
import org.eclipse.jetty.server.session.FileSessionDataStore;
|
||||||
|
import org.eclipse.jetty.server.session.SessionCache;
|
||||||
|
import org.eclipse.jetty.server.session.SessionHandler;
|
||||||
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.security.ProtectionDomain;
|
import java.security.ProtectionDomain;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static java.util.function.Function.identity;
|
||||||
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
public class JettyLauncher {
|
public class JettyLauncher {
|
||||||
|
|
||||||
|
private interface Defaults {
|
||||||
|
|
||||||
|
String CONNECTORS = "http";
|
||||||
|
String HOST = "0.0.0.0";
|
||||||
|
|
||||||
|
int HTTP_PORT = 8080;
|
||||||
|
int HTTPS_PORT = 8443;
|
||||||
|
|
||||||
|
boolean REDIRECT_HTTPS = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface Connectors {
|
||||||
|
|
||||||
|
String HTTP = "http";
|
||||||
|
String HTTPS = "https";
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.setProperty("java.awt.headless", "true");
|
System.setProperty("java.awt.headless", "true");
|
||||||
|
|
||||||
String host = null;
|
String connectors = getEnvironmentVariable("gitbucket.connectors");
|
||||||
int port = 8080;
|
String host = getEnvironmentVariable("gitbucket.host");
|
||||||
InetSocketAddress address = null;
|
String port = getEnvironmentVariable("gitbucket.port");
|
||||||
String contextPath = "/";
|
String securePort = getEnvironmentVariable("gitbucket.securePort");
|
||||||
String tmpDirPath="";
|
String keyStorePath = getEnvironmentVariable("gitbucket.keyStorePath");
|
||||||
boolean forceHttps = false;
|
String keyStorePassword = getEnvironmentVariable("gitbucket.keyStorePassword");
|
||||||
|
String keyManagerPassword = getEnvironmentVariable("gitbucket.keyManagerPassword");
|
||||||
|
String redirectHttps = getEnvironmentVariable("gitbucket.redirectHttps");
|
||||||
|
String contextPath = getEnvironmentVariable("gitbucket.prefix");
|
||||||
|
String tmpDirPath = getEnvironmentVariable("gitbucket.tempDir");
|
||||||
|
String jettyIdleTimeout = getEnvironmentVariable("gitbucket.jettyIdleTimeout");
|
||||||
|
boolean saveSessions = false;
|
||||||
|
|
||||||
for(String arg: args) {
|
for(String arg: args) {
|
||||||
|
if (arg.equals("--save_sessions")) {
|
||||||
|
saveSessions = true;
|
||||||
|
}
|
||||||
|
if (arg.equals("--disable_news_feed")) {
|
||||||
|
System.setProperty("gitbucket.disableNewsFeed", "true");
|
||||||
|
}
|
||||||
|
if (arg.equals("--disable_cache")) {
|
||||||
|
System.setProperty("gitbucket.disableCache", "true");
|
||||||
|
}
|
||||||
if(arg.startsWith("--") && arg.contains("=")) {
|
if(arg.startsWith("--") && arg.contains("=")) {
|
||||||
String[] dim = arg.split("=");
|
String[] dim = arg.split("=", 2);
|
||||||
if(dim.length >= 2) {
|
if(dim.length == 2) {
|
||||||
switch (dim[0]) {
|
switch (dim[0]) {
|
||||||
|
case "--connectors":
|
||||||
|
connectors = dim[1];
|
||||||
|
break;
|
||||||
case "--host":
|
case "--host":
|
||||||
host = dim[1];
|
host = dim[1];
|
||||||
break;
|
break;
|
||||||
case "--port":
|
case "--port":
|
||||||
port = Integer.parseInt(dim[1]);
|
port = dim[1];
|
||||||
|
break;
|
||||||
|
case "--secure_port":
|
||||||
|
securePort = dim[1];
|
||||||
|
break;
|
||||||
|
case "--key_store_path":
|
||||||
|
keyStorePath = dim[1];
|
||||||
|
break;
|
||||||
|
case "--key_store_password":
|
||||||
|
keyStorePassword = dim[1];
|
||||||
|
break;
|
||||||
|
case "--key_manager_password":
|
||||||
|
keyManagerPassword = dim[1];
|
||||||
|
break;
|
||||||
|
case "--redirect_https":
|
||||||
|
redirectHttps = dim[1];
|
||||||
break;
|
break;
|
||||||
case "--prefix":
|
case "--prefix":
|
||||||
contextPath = dim[1];
|
contextPath = dim[1];
|
||||||
if (!contextPath.startsWith("/")) {
|
|
||||||
contextPath = "/" + contextPath;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "--max_file_size":
|
|
||||||
System.setProperty("gitbucket.maxFileSize", dim[1]);
|
|
||||||
break;
|
break;
|
||||||
case "--gitbucket.home":
|
case "--gitbucket.home":
|
||||||
System.setProperty("gitbucket.home", dim[1]);
|
System.setProperty("gitbucket.home", dim[1]);
|
||||||
@@ -51,47 +114,100 @@ public class JettyLauncher {
|
|||||||
case "--plugin_dir":
|
case "--plugin_dir":
|
||||||
System.setProperty("gitbucket.pluginDir", dim[1]);
|
System.setProperty("gitbucket.pluginDir", dim[1]);
|
||||||
break;
|
break;
|
||||||
case "--validate_password":
|
case "--jetty_idle_timeout":
|
||||||
System.setProperty("gitbucket.validate.password", dim[1]);
|
jettyIdleTimeout = dim[1];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(host != null) {
|
if (contextPath != null && !contextPath.startsWith("/")) {
|
||||||
address = new InetSocketAddress(host, port);
|
contextPath = "/" + contextPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String hostName = InetAddress.getByName(fallback(host, Defaults.HOST)).getHostName();
|
||||||
|
|
||||||
|
final Server server = new Server();
|
||||||
|
|
||||||
|
final Set<String> connectorsSet = Stream.of(fallback(connectors, Defaults.CONNECTORS)
|
||||||
|
.toLowerCase().split(",")).map(String::trim).collect(toSet());
|
||||||
|
|
||||||
|
final List<ServerConnector> connectorInstances = new ArrayList<>();
|
||||||
|
|
||||||
|
final HttpConfiguration httpConfig = new HttpConfiguration();
|
||||||
|
httpConfig.setSendServerVersion(false);
|
||||||
|
if (connectorsSet.contains(Connectors.HTTPS)) {
|
||||||
|
httpConfig.setSecurePort(fallback(securePort, Defaults.HTTPS_PORT, Integer::parseInt));
|
||||||
|
}
|
||||||
|
if (jettyIdleTimeout != null && jettyIdleTimeout.trim().length() != 0) {
|
||||||
|
httpConfig.setIdleTimeout(Long.parseLong(jettyIdleTimeout.trim()));
|
||||||
} else {
|
} else {
|
||||||
address = new InetSocketAddress(port);
|
httpConfig.setIdleTimeout(300000L); // default is 5min
|
||||||
}
|
}
|
||||||
|
|
||||||
Server server = new Server(address);
|
if (connectorsSet.contains(Connectors.HTTP)) {
|
||||||
|
final ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
|
||||||
|
connector.setHost(hostName);
|
||||||
|
connector.setPort(fallback(port, Defaults.HTTP_PORT, Integer::parseInt));
|
||||||
|
|
||||||
// SelectChannelConnector connector = new SelectChannelConnector();
|
connectorInstances.add(connector);
|
||||||
// if(host != null) {
|
}
|
||||||
// connector.setHost(host);
|
|
||||||
// }
|
|
||||||
// connector.setMaxIdleTime(1000 * 60 * 60);
|
|
||||||
// connector.setSoLingerTime(-1);
|
|
||||||
// connector.setPort(port);
|
|
||||||
// server.addConnector(connector);
|
|
||||||
|
|
||||||
// Disabling Server header
|
if (connectorsSet.contains(Connectors.HTTPS)) {
|
||||||
for (Connector connector : server.getConnectors()) {
|
final SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
||||||
for (ConnectionFactory factory : connector.getConnectionFactories()) {
|
|
||||||
if (factory instanceof HttpConnectionFactory) {
|
sslContextFactory.setKeyStorePath(requireNonNull(keyStorePath,
|
||||||
((HttpConnectionFactory) factory).getHttpConfiguration().setSendServerVersion(false);
|
"You must specify a path to an SSL keystore via the --key_store_path command line argument" +
|
||||||
}
|
" or GITBUCKET_KEYSTOREPATH environment variable."));
|
||||||
}
|
|
||||||
|
sslContextFactory.setKeyStorePassword(requireNonNull(keyStorePassword,
|
||||||
|
"You must specify a an SSL keystore password via the --key_store_password argument" +
|
||||||
|
" or GITBUCKET_KEYSTOREPASSWORD environment variable."));
|
||||||
|
|
||||||
|
sslContextFactory.setKeyManagerPassword(requireNonNull(keyManagerPassword,
|
||||||
|
"You must specify a key manager password via the --key_manager_password' argument" +
|
||||||
|
" or GITBUCKET_KEYMANAGERPASSWORD environment variable."));
|
||||||
|
|
||||||
|
final HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
|
||||||
|
httpsConfig.addCustomizer(new SecureRequestCustomizer());
|
||||||
|
|
||||||
|
final ServerConnector connector = new ServerConnector(server,
|
||||||
|
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
|
||||||
|
new HttpConnectionFactory(httpsConfig));
|
||||||
|
|
||||||
|
connector.setHost(hostName);
|
||||||
|
connector.setPort(fallback(securePort, Defaults.HTTPS_PORT, Integer::parseInt));
|
||||||
|
|
||||||
|
connectorInstances.add(connector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require(!connectorInstances.isEmpty(),
|
||||||
|
"No server connectors could be configured, please check your --connectors command line argument" +
|
||||||
|
" or GITBUCKET_CONNECTORS environment variable.");
|
||||||
|
|
||||||
|
server.setConnectors(connectorInstances.toArray(new ServerConnector[0]));
|
||||||
|
|
||||||
WebAppContext context = new WebAppContext();
|
WebAppContext context = new WebAppContext();
|
||||||
|
|
||||||
|
if(saveSessions) {
|
||||||
|
File sessDir = new File(getGitBucketHome(), "sessions");
|
||||||
|
if(!sessDir.exists()){
|
||||||
|
mkdir(sessDir);
|
||||||
|
}
|
||||||
|
SessionHandler sessions = context.getSessionHandler();
|
||||||
|
SessionCache cache = new DefaultSessionCache(sessions);
|
||||||
|
FileSessionDataStore fsds = new FileSessionDataStore();
|
||||||
|
fsds.setStoreDir(sessDir);
|
||||||
|
cache.setSessionDataStore(fsds);
|
||||||
|
sessions.setSessionCache(cache);
|
||||||
|
}
|
||||||
|
|
||||||
File tmpDir;
|
File tmpDir;
|
||||||
if(tmpDirPath.equals("")){
|
if(tmpDirPath == null || tmpDirPath.equals("")){
|
||||||
tmpDir = new File(getGitBucketHome(), "tmp");
|
tmpDir = new File(getGitBucketHome(), "tmp");
|
||||||
if(!tmpDir.exists()){
|
if(!tmpDir.exists()){
|
||||||
tmpDir.mkdirs();
|
mkdir(tmpDir);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tmpDir = new File(tmpDirPath);
|
tmpDir = new File(tmpDirPath);
|
||||||
@@ -111,17 +227,20 @@ public class JettyLauncher {
|
|||||||
ProtectionDomain domain = JettyLauncher.class.getProtectionDomain();
|
ProtectionDomain domain = JettyLauncher.class.getProtectionDomain();
|
||||||
URL location = domain.getCodeSource().getLocation();
|
URL location = domain.getCodeSource().getLocation();
|
||||||
|
|
||||||
context.setContextPath(contextPath);
|
context.setContextPath(contextPath == null ? "" : contextPath);
|
||||||
context.setDescriptor(location.toExternalForm() + "/WEB-INF/web.xml");
|
context.setDescriptor(location.toExternalForm() + "/WEB-INF/web.xml");
|
||||||
context.setServer(server);
|
context.setServer(server);
|
||||||
context.setWar(location.toExternalForm());
|
context.setWar(location.toExternalForm());
|
||||||
if (forceHttps) {
|
|
||||||
context.setInitParameter("org.scalatra.ForceHttps", "true");
|
final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
if (fallback(redirectHttps, Defaults.REDIRECT_HTTPS, Boolean::parseBoolean)) {
|
||||||
|
handlers.addHandler(new SecuredRedirectHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
Handler handler = addStatisticsHandler(context);
|
handlers.addHandler(addStatisticsHandler(context));
|
||||||
|
|
||||||
server.setHandler(handler);
|
server.setHandler(handlers);
|
||||||
server.setStopAtShutdown(true);
|
server.setStopAtShutdown(true);
|
||||||
server.setStopTimeout(7_000);
|
server.setStopTimeout(7_000);
|
||||||
server.start();
|
server.start();
|
||||||
@@ -140,6 +259,40 @@ public class JettyLauncher {
|
|||||||
return new File(System.getProperty("user.home"), ".gitbucket");
|
return new File(System.getProperty("user.home"), ".gitbucket");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getEnvironmentVariable(String key){
|
||||||
|
String value = System.getenv(key.toUpperCase().replace('.', '_'));
|
||||||
|
if (value != null && value.length() == 0){
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T, R> T fallback(R value, T defaultValue, Function<R, T> converter) {
|
||||||
|
return value == null ? defaultValue : converter.apply(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> T fallback(T value, T defaultValue) {
|
||||||
|
return fallback(value, defaultValue, identity());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void require(boolean condition, String message) {
|
||||||
|
if (!condition) {
|
||||||
|
throw new IllegalArgumentException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> T requireNonNull(T value, String message) {
|
||||||
|
require(value != null, message);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void mkdir(File dir) {
|
||||||
|
if (!dir.mkdirs()) {
|
||||||
|
throw new RuntimeException("Unable to create directory: " + dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Handler addStatisticsHandler(Handler handler) {
|
private static Handler addStatisticsHandler(Handler handler) {
|
||||||
// The graceful shutdown is implemented via the statistics handler.
|
// The graceful shutdown is implemented via the statistics handler.
|
||||||
// See the following: https://bugs.eclipse.org/bugs/show_bug.cgi?id=420142
|
// See the following: https://bugs.eclipse.org/bugs/show_bug.cgi?id=420142
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ public class PatchUtil {
|
|||||||
public static String apply(String source, String patch, FileHeader fh)
|
public static String apply(String source, String patch, FileHeader fh)
|
||||||
throws IOException, PatchApplyException {
|
throws IOException, PatchApplyException {
|
||||||
RawText rt = new RawText(source.getBytes("UTF-8"));
|
RawText rt = new RawText(source.getBytes("UTF-8"));
|
||||||
List<String> oldLines = new ArrayList<String>(rt.size());
|
List<String> oldLines = new ArrayList<>(rt.size());
|
||||||
for (int i = 0; i < rt.size(); i++)
|
for (int i = 0; i < rt.size(); i++)
|
||||||
oldLines.add(rt.getString(i));
|
oldLines.add(rt.getString(i));
|
||||||
List<String> newLines = new ArrayList<String>(oldLines);
|
List<String> newLines = new ArrayList<>(oldLines);
|
||||||
for (HunkHeader hh : fh.getHunks()) {
|
for (HunkHeader hh : fh.getHunks()) {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
out.write(patch.getBytes("UTF-8"), hh.getStartOffset(), hh.getEndOffset() - hh.getStartOffset());
|
out.write(patch.getBytes("UTF-8"), hh.getStartOffset(), hh.getEndOffset() - hh.getStartOffset());
|
||||||
RawText hrt = new RawText(out.toByteArray());
|
RawText hrt = new RawText(out.toByteArray());
|
||||||
List<String> hunkLines = new ArrayList<String>(hrt.size());
|
List<String> hunkLines = new ArrayList<>(hrt.size());
|
||||||
for (int i = 0; i < hrt.size(); i++)
|
for (int i = 0; i < hrt.size(); i++)
|
||||||
hunkLines.add(hrt.getString(i));
|
hunkLines.add(hrt.getString(i));
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|||||||
@@ -1 +1,4 @@
|
|||||||
notifications:1.6.0
|
notifications:1.11.0
|
||||||
|
gist:4.23.0
|
||||||
|
emoji:4.6.0
|
||||||
|
pages:1.10.0
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
<file>gitbucket.log</file>
|
<file>.tmp/gitbucket.log</file>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -1,18 +0,0 @@
|
|||||||
CREATE OR REPLACE VIEW ISSUE_OUTLINE_VIEW AS
|
|
||||||
SELECT
|
|
||||||
A.USER_NAME,
|
|
||||||
A.REPOSITORY_NAME,
|
|
||||||
A.ISSUE_ID,
|
|
||||||
COALESCE(B.COMMENT_COUNT, 0) + COALESCE(C.COMMENT_COUNT, 0) AS COMMENT_COUNT
|
|
||||||
FROM ISSUE A
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM ISSUE_COMMENT
|
|
||||||
WHERE ACTION IN ('comment', 'close_comment', 'reopen_comment')
|
|
||||||
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
|
||||||
) B
|
|
||||||
ON (A.USER_NAME = B.USER_NAME AND A.REPOSITORY_NAME = B.REPOSITORY_NAME AND A.ISSUE_ID = B.ISSUE_ID)
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM COMMIT_COMMENT
|
|
||||||
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
|
||||||
) C
|
|
||||||
ON (A.USER_NAME = C.USER_NAME AND A.REPOSITORY_NAME = C.REPOSITORY_NAME AND A.ISSUE_ID = C.ISSUE_ID);
|
|
||||||
@@ -60,13 +60,12 @@
|
|||||||
<!-- ACCESS_TOKEN -->
|
<!-- ACCESS_TOKEN -->
|
||||||
<!--================================================================================================-->
|
<!--================================================================================================-->
|
||||||
<createTable tableName="ACCESS_TOKEN">
|
<createTable tableName="ACCESS_TOKEN">
|
||||||
<column name="ACCESS_TOKEN_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
<column name="ACCESS_TOKEN_ID" type="int" nullable="false" autoIncrement="true" unique="true" primaryKeyName="IDX_ACCESS_TOKEN_PK" primaryKey="true" />
|
||||||
<column name="TOKEN_HASH" type="varchar(40)" nullable="false"/>
|
<column name="TOKEN_HASH" type="varchar(40)" nullable="false"/>
|
||||||
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="NOTE" type="text" nullable="false"/>
|
<column name="NOTE" type="text" nullable="false"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<addPrimaryKey constraintName="IDX_ACCESS_TOKEN_PK" tableName="ACCESS_TOKEN" columnNames="ACCESS_TOKEN_ID"/>
|
|
||||||
<addUniqueConstraint constraintName="IDX_ACCESS_TOKEN_TOKEN_HASH" tableName="ACCESS_TOKEN" columnNames="TOKEN_HASH"/>
|
<addUniqueConstraint constraintName="IDX_ACCESS_TOKEN_TOKEN_HASH" tableName="ACCESS_TOKEN" columnNames="TOKEN_HASH"/>
|
||||||
<addForeignKeyConstraint constraintName="IDX_ACCESS_TOKEN_FK0" baseTableName="ACCESS_TOKEN" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
<addForeignKeyConstraint constraintName="IDX_ACCESS_TOKEN_FK0" baseTableName="ACCESS_TOKEN" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@
|
|||||||
<!-- ACTIVITY -->
|
<!-- ACTIVITY -->
|
||||||
<!--================================================================================================-->
|
<!--================================================================================================-->
|
||||||
<createTable tableName="ACTIVITY">
|
<createTable tableName="ACTIVITY">
|
||||||
<column name="ACTIVITY_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
<column name="ACTIVITY_ID" type="int" nullable="false" autoIncrement="true" unique="true" primaryKeyName="IDX_ACTIVITY_PK" primaryKey="true"/>
|
||||||
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="ACTIVITY_USER_NAME" type="varchar(100)" nullable="false"/>
|
<column name="ACTIVITY_USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
@@ -84,7 +83,6 @@
|
|||||||
<column name="ACTIVITY_DATE" type="datetime" nullable="false"/>
|
<column name="ACTIVITY_DATE" type="datetime" nullable="false"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<addPrimaryKey constraintName="IDX_ACTIVITY_PK" tableName="ACTIVITY" columnNames="ACTIVITY_ID"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_ACTIVITY_FK1" baseTableName="ACTIVITY" baseColumnNames="ACTIVITY_USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
<addForeignKeyConstraint constraintName="IDX_ACTIVITY_FK1" baseTableName="ACTIVITY" baseColumnNames="ACTIVITY_USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
<addForeignKeyConstraint constraintName="IDX_ACTIVITY_FK0" baseTableName="ACTIVITY" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
<addForeignKeyConstraint constraintName="IDX_ACTIVITY_FK0" baseTableName="ACTIVITY" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
|
||||||
@@ -108,7 +106,7 @@
|
|||||||
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="COMMIT_ID" type="varchar(100)" nullable="false"/>
|
<column name="COMMIT_ID" type="varchar(100)" nullable="false"/>
|
||||||
<column name="COMMENT_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
<column name="COMMENT_ID" type="int" nullable="false" autoIncrement="true" unique="true" primaryKeyName="IDX_COMMIT_COMMENT_PK" primaryKey="true" />
|
||||||
<column name="COMMENTED_USER_NAME" type="varchar(100)" nullable="false"/>
|
<column name="COMMENTED_USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="CONTENT" type="text" nullable="false"/>
|
<column name="CONTENT" type="text" nullable="false"/>
|
||||||
<column name="FILE_NAME" type="varchar(260)" nullable="true"/>
|
<column name="FILE_NAME" type="varchar(260)" nullable="true"/>
|
||||||
@@ -119,14 +117,13 @@
|
|||||||
<column name="ISSUE_ID" type="int" nullable="true"/>
|
<column name="ISSUE_ID" type="int" nullable="true"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<addPrimaryKey constraintName="IDX_COMMIT_COMMENT_PK" tableName="COMMIT_COMMENT" columnNames="COMMENT_ID"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_COMMIT_COMMENT_FK0" baseTableName="COMMIT_COMMENT" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
<addForeignKeyConstraint constraintName="IDX_COMMIT_COMMENT_FK0" baseTableName="COMMIT_COMMENT" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
|
||||||
<!--================================================================================================-->
|
<!--================================================================================================-->
|
||||||
<!-- COMMIT_STATUS -->
|
<!-- COMMIT_STATUS -->
|
||||||
<!--================================================================================================-->
|
<!--================================================================================================-->
|
||||||
<createTable tableName="COMMIT_STATUS">
|
<createTable tableName="COMMIT_STATUS">
|
||||||
<column name="COMMIT_STATUS_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
<column name="COMMIT_STATUS_ID" type="int" nullable="false" autoIncrement="true" unique="true" primaryKeyName="IDX_COMMIT_STATUS_PK" primaryKey="true" />
|
||||||
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="COMMIT_ID" type="varchar(40)" nullable="false"/>
|
<column name="COMMIT_ID" type="varchar(40)" nullable="false"/>
|
||||||
@@ -139,7 +136,6 @@
|
|||||||
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
|
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<addPrimaryKey constraintName="IDX_COMMIT_STATUS_PK" tableName="COMMIT_STATUS" columnNames="COMMIT_STATUS_ID"/>
|
|
||||||
<addUniqueConstraint constraintName="IDX_COMMIT_STATUS_1" tableName="COMMIT_STATUS" columnNames="USER_NAME, REPOSITORY_NAME, COMMIT_ID, CONTEXT"/>
|
<addUniqueConstraint constraintName="IDX_COMMIT_STATUS_1" tableName="COMMIT_STATUS" columnNames="USER_NAME, REPOSITORY_NAME, COMMIT_ID, CONTEXT"/>
|
||||||
<addForeignKeyConstraint constraintName="IDX_COMMIT_STATUS_FK3" baseTableName="COMMIT_STATUS" baseColumnNames="CREATOR" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
<addForeignKeyConstraint constraintName="IDX_COMMIT_STATUS_FK3" baseTableName="COMMIT_STATUS" baseColumnNames="CREATOR" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
<addForeignKeyConstraint constraintName="IDX_COMMIT_STATUS_FK2" baseTableName="COMMIT_STATUS" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
<addForeignKeyConstraint constraintName="IDX_COMMIT_STATUS_FK2" baseTableName="COMMIT_STATUS" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
@@ -206,7 +202,7 @@
|
|||||||
<column name="PULL_REQUEST" type="boolean" nullable="false"/>
|
<column name="PULL_REQUEST" type="boolean" nullable="false"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<addPrimaryKey constraintName="IDX_ISSUE_PK" tableName="ISSUE" columnNames="ISSUE_ID, USER_NAME, REPOSITORY_NAME"/>
|
<addPrimaryKey constraintName="IDX_ISSUE_PK" tableName="ISSUE" columnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID"/>
|
||||||
<addForeignKeyConstraint constraintName="IDX_ISSUE_FK0" baseTableName="ISSUE" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_FK0" baseTableName="ISSUE" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
<addForeignKeyConstraint constraintName="IDX_ISSUE_FK2" baseTableName="ISSUE" baseColumnNames="MILESTONE_ID" referencedTableName="MILESTONE" referencedColumnNames="MILESTONE_ID"/>
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_FK2" baseTableName="ISSUE" baseColumnNames="MILESTONE_ID" referencedTableName="MILESTONE" referencedColumnNames="MILESTONE_ID"/>
|
||||||
<addForeignKeyConstraint constraintName="IDX_ISSUE_FK1" baseTableName="ISSUE" baseColumnNames="OPENED_USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_FK1" baseTableName="ISSUE" baseColumnNames="OPENED_USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
@@ -218,7 +214,7 @@
|
|||||||
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="ISSUE_ID" type="int" nullable="false"/>
|
<column name="ISSUE_ID" type="int" nullable="false"/>
|
||||||
<column name="COMMENT_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
<column name="COMMENT_ID" type="int" nullable="false" autoIncrement="true" unique="true" primaryKeyName="IDX_ISSUE_COMMENT_PK" primaryKey="true" />
|
||||||
<column name="ACTION" type="varchar(20)" nullable="false"/>
|
<column name="ACTION" type="varchar(20)" nullable="false"/>
|
||||||
<column name="COMMENTED_USER_NAME" type="varchar(100)" nullable="false"/>
|
<column name="COMMENTED_USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
<column name="CONTENT" type="text" nullable="false"/>
|
<column name="CONTENT" type="text" nullable="false"/>
|
||||||
@@ -226,7 +222,6 @@
|
|||||||
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
|
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<addPrimaryKey constraintName="IDX_ISSUE_COMMENT_PK" tableName="ISSUE_COMMENT" columnNames="COMMENT_ID"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_ISSUE_COMMENT_FK0" baseTableName="ISSUE_COMMENT" baseColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID" referencedTableName="ISSUE" referencedColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID"/>
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_COMMENT_FK0" baseTableName="ISSUE_COMMENT" baseColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID" referencedTableName="ISSUE" referencedColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID"/>
|
||||||
|
|
||||||
<!--================================================================================================-->
|
<!--================================================================================================-->
|
||||||
@@ -348,4 +343,28 @@
|
|||||||
<addPrimaryKey constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_PK" tableName="PROTECTED_BRANCH_REQUIRE_CONTEXT" columnNames="USER_NAME, REPOSITORY_NAME, BRANCH, CONTEXT"/>
|
<addPrimaryKey constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_PK" tableName="PROTECTED_BRANCH_REQUIRE_CONTEXT" columnNames="USER_NAME, REPOSITORY_NAME, BRANCH, CONTEXT"/>
|
||||||
<addForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_FK0" baseTableName="PROTECTED_BRANCH_REQUIRE_CONTEXT" baseColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" referencedTableName="PROTECTED_BRANCH" referencedColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" onDelete="CASCADE" onUpdate="CASCADE"/>
|
<addForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_FK0" baseTableName="PROTECTED_BRANCH_REQUIRE_CONTEXT" baseColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" referencedTableName="PROTECTED_BRANCH" referencedColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ISSUE_OUTLINE_VIEW -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<sql>
|
||||||
|
CREATE OR REPLACE VIEW ISSUE_OUTLINE_VIEW AS
|
||||||
|
SELECT
|
||||||
|
A.USER_NAME,
|
||||||
|
A.REPOSITORY_NAME,
|
||||||
|
A.ISSUE_ID,
|
||||||
|
COALESCE(B.COMMENT_COUNT, 0) + COALESCE(C.COMMENT_COUNT, 0) AS COMMENT_COUNT
|
||||||
|
FROM ISSUE A
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM ISSUE_COMMENT
|
||||||
|
WHERE ACTION IN ('comment', 'close_comment', 'reopen_comment')
|
||||||
|
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
||||||
|
) B
|
||||||
|
ON (A.USER_NAME = B.USER_NAME AND A.REPOSITORY_NAME = B.REPOSITORY_NAME AND A.ISSUE_ID = B.ISSUE_ID)
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM COMMIT_COMMENT
|
||||||
|
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
||||||
|
) C
|
||||||
|
ON (A.USER_NAME = C.USER_NAME AND A.REPOSITORY_NAME = C.REPOSITORY_NAME AND A.ISSUE_ID = C.ISSUE_ID)
|
||||||
|
</sql>
|
||||||
|
|
||||||
</changeSet>
|
</changeSet>
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
CREATE OR REPLACE VIEW ISSUE_OUTLINE_VIEW AS
|
|
||||||
|
|
||||||
SELECT
|
|
||||||
A.USER_NAME,
|
|
||||||
A.REPOSITORY_NAME,
|
|
||||||
A.ISSUE_ID,
|
|
||||||
COALESCE(B.COMMENT_COUNT, 0) + COALESCE(C.COMMENT_COUNT, 0) AS COMMENT_COUNT,
|
|
||||||
COALESCE(D.ORDERING, 9999) AS PRIORITY
|
|
||||||
|
|
||||||
FROM ISSUE A
|
|
||||||
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM ISSUE_COMMENT
|
|
||||||
WHERE ACTION IN ('comment', 'close_comment', 'reopen_comment')
|
|
||||||
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
|
||||||
) B
|
|
||||||
ON (A.USER_NAME = B.USER_NAME AND A.REPOSITORY_NAME = B.REPOSITORY_NAME AND A.ISSUE_ID = B.ISSUE_ID)
|
|
||||||
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM COMMIT_COMMENT
|
|
||||||
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
|
||||||
) C
|
|
||||||
ON (A.USER_NAME = C.USER_NAME AND A.REPOSITORY_NAME = C.REPOSITORY_NAME AND A.ISSUE_ID = C.ISSUE_ID)
|
|
||||||
|
|
||||||
LEFT OUTER JOIN PRIORITY D
|
|
||||||
ON (A.PRIORITY_ID = D.PRIORITY_ID);
|
|
||||||
@@ -35,4 +35,28 @@
|
|||||||
<column name="URL" type="varchar(200)" nullable="false"/>
|
<column name="URL" type="varchar(200)" nullable="false"/>
|
||||||
<column name="EVENT" type="varchar(30)" nullable="false"/>
|
<column name="EVENT" type="varchar(30)" nullable="false"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
|
<sql>
|
||||||
|
CREATE OR REPLACE VIEW ISSUE_OUTLINE_VIEW AS
|
||||||
|
SELECT
|
||||||
|
A.USER_NAME,
|
||||||
|
A.REPOSITORY_NAME,
|
||||||
|
A.ISSUE_ID,
|
||||||
|
COALESCE(B.COMMENT_COUNT, 0) + COALESCE(C.COMMENT_COUNT, 0) AS COMMENT_COUNT,
|
||||||
|
COALESCE(D.ORDERING, 9999) AS PRIORITY
|
||||||
|
FROM ISSUE A
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM ISSUE_COMMENT
|
||||||
|
WHERE ACTION IN ('comment', 'close_comment', 'reopen_comment')
|
||||||
|
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
||||||
|
) B
|
||||||
|
ON (A.USER_NAME = B.USER_NAME AND A.REPOSITORY_NAME = B.REPOSITORY_NAME AND A.ISSUE_ID = B.ISSUE_ID)
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM COMMIT_COMMENT
|
||||||
|
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
||||||
|
) C
|
||||||
|
ON (A.USER_NAME = C.USER_NAME AND A.REPOSITORY_NAME = C.REPOSITORY_NAME AND A.ISSUE_ID = C.ISSUE_ID)
|
||||||
|
LEFT OUTER JOIN PRIORITY D
|
||||||
|
ON (A.PRIORITY_ID = D.PRIORITY_ID);
|
||||||
|
</sql>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|||||||
16
src/main/resources/update/gitbucket-core_4.31.xml
Normal file
16
src/main/resources/update/gitbucket-core_4.31.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- SSH_KEY -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="GPG_KEY">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="KEY_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="GPG_KEY_ID" type="bigint" nullable="false"/>
|
||||||
|
<column name="TITLE" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="PUBLIC_KEY" type="text" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_GPG_KEY_PK" tableName="GPG_KEY" columnNames="USER_NAME, GPG_KEY_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_GPG_KEY_FK0" baseTableName="GPG_KEY" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
|
</changeSet>
|
||||||
6
src/main/resources/update/gitbucket-core_4.32.xml
Normal file
6
src/main/resources/update/gitbucket-core_4.32.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="PULL_REQUEST">
|
||||||
|
<column name="IS_DRAFT" type="boolean" nullable="false" defaultValueBoolean="false" />
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
4
src/main/resources/update/gitbucket-core_4.34.xml
Normal file
4
src/main/resources/update/gitbucket-core_4.34.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<dropTable tableName="ACTIVITY" />
|
||||||
|
</changeSet>
|
||||||
39
src/main/resources/update/gitbucket-core_4.35.xml
Normal file
39
src/main/resources/update/gitbucket-core_4.35.xml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- WEB_HOOK -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<dropForeignKeyConstraint constraintName="IDX_WEB_HOOK_EVENT_FK0" baseTableName="WEB_HOOK_EVENT"/>
|
||||||
|
<dropForeignKeyConstraint constraintName="IDX_WEB_HOOK_FK0" baseTableName="WEB_HOOK"/>
|
||||||
|
<dropPrimaryKey constraintName="IDX_WEB_HOOK_PK" tableName="WEB_HOOK"/>
|
||||||
|
|
||||||
|
<createTable tableName="WEB_HOOK_2">
|
||||||
|
<column name="HOOK_ID" type="int" nullable="true" autoIncrement="true" unique="false" primaryKeyName="IDX_WEB_HOOK_PK" primaryKey="true" />
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="URL" type="varchar(200)" nullable="false"/>
|
||||||
|
<column name="TOKEN" type="varchar(100)" nullable="true"/>
|
||||||
|
<column name="CTYPE" type="varchar(10)" nullable="true"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<sql>
|
||||||
|
INSERT INTO WEB_HOOK_2 (USER_NAME, REPOSITORY_NAME, URL, TOKEN, CTYPE) SELECT USER_NAME, REPOSITORY_NAME, URL, TOKEN, CTYPE FROM WEB_HOOK
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<renameTable newTableName="WEB_HOOK_BK" oldTableName="WEB_HOOK"/>
|
||||||
|
<renameTable newTableName="WEB_HOOK" oldTableName="WEB_HOOK_2"/>
|
||||||
|
|
||||||
|
<addUniqueConstraint constraintName="IDX_WEB_HOOK_1" tableName="WEB_HOOK" columnNames="USER_NAME, REPOSITORY_NAME, URL"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_WEB_HOOK_FK0" baseTableName="WEB_HOOK" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_WEB_HOOK_EVENT_FK0" baseTableName="WEB_HOOK_EVENT" baseColumnNames="USER_NAME, REPOSITORY_NAME, URL" referencedTableName="WEB_HOOK" referencedColumnNames="USER_NAME, REPOSITORY_NAME, URL" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ACCOUNT_PREFERENCE -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ACCOUNT_PREFERENCE">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="HIGHLIGHTER_THEME" type="varchar(100)" nullable="false" defaultValue="prettify"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey constraintName="IDX_ACCOUNT_PREFERENCE_PK" tableName="ACCOUNT_PREFERENCE" columnNames="USER_NAME"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ACCOUNT_PREFERENCE_FK0" baseTableName="ACCOUNT_PREFERENCE" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
|
</changeSet>
|
||||||
6
src/main/resources/update/gitbucket-core_4.36.xml
Normal file
6
src/main/resources/update/gitbucket-core_4.36.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="REPOSITORY">
|
||||||
|
<column name="SAFE_MODE" type="boolean" nullable="false" defaultValue="true"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
7
src/main/resources/update/gitbucket-core_4.37.xml
Normal file
7
src/main/resources/update/gitbucket-core_4.37.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<dropForeignKeyConstraint constraintName="IDX_WEB_HOOK_EVENT_FK0" baseTableName="WEB_HOOK_EVENT"/>
|
||||||
|
<modifyDataType columnName="URL" newDataType="varchar(400)" tableName="WEB_HOOK_EVENT"/>
|
||||||
|
<modifyDataType columnName="URL" newDataType="varchar(400)" tableName="WEB_HOOK"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_WEB_HOOK_EVENT_FK0" baseTableName="WEB_HOOK_EVENT" baseColumnNames="USER_NAME, REPOSITORY_NAME, URL" referencedTableName="WEB_HOOK" referencedColumnNames="USER_NAME, REPOSITORY_NAME, URL" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
|
</changeSet>
|
||||||
53
src/main/resources/update/gitbucket-core_4.38.xml
Normal file
53
src/main/resources/update/gitbucket-core_4.38.xml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- CUSTOM_FIELD -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="CUSTOM_FIELD">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="FIELD_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="FIELD_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="FIELD_TYPE" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="ENABLE_FOR_ISSUES" type="boolean" nullable="false"/>
|
||||||
|
<column name="ENABLE_FOR_PULL_REQUESTS" type="boolean" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey constraintName="IDX_CUSTOM_FIELD_PK" tableName="CUSTOM_FIELD" columnNames="USER_NAME, REPOSITORY_NAME, FIELD_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_CUSTOM_FIELD_FK0" baseTableName="CUSTOM_FIELD" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ISSUE_CUSTOM_FIELD -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ISSUE_CUSTOM_FIELD">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="ISSUE_ID" type="int" nullable="false"/>
|
||||||
|
<column name="FIELD_ID" type="int" nullable="false"/>
|
||||||
|
<column name="VALUE" type="varchar(200)" nullable="true"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey constraintName="IDX_ISSUE_CUSTOM_FIELD_PK" tableName="ISSUE_CUSTOM_FIELD" columnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID, FIELD_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_CUSTOM_FIELD_FK0" baseTableName="ISSUE_CUSTOM_FIELD" baseColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID" referencedTableName="ISSUE" referencedColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_CUSTOM_FIELD_FK1" baseTableName="ISSUE_CUSTOM_FIELD" baseColumnNames="USER_NAME, REPOSITORY_NAME, FIELD_ID" referencedTableName="CUSTOM_FIELD" referencedColumnNames="USER_NAME, REPOSITORY_NAME, FIELD_ID"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ISSUE_ASSIGNEE -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ISSUE_ASSIGNEE">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="ISSUE_ID" type="int" nullable="false"/>
|
||||||
|
<column name="ASSIGNEE_USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey constraintName="IDX_ISSUE_ASSIGNEE_PK" tableName="ISSUE_ASSIGNEE" columnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID, ASSIGNEE_USER_NAME"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_ASSIGNEE_FK0" baseTableName="ISSUE_ASSIGNEE" baseColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID" referencedTableName="ISSUE" referencedColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID"/>
|
||||||
|
<!--
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_ASSIGNEE_FK1" baseTableName="ISSUE_ASSIGNEE" baseColumnNames="ASSIGNEE_USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<sql>
|
||||||
|
INSERT INTO ISSUE_ASSIGNEE (USER_NAME, REPOSITORY_NAME, ISSUE_ID, ASSIGNEE_USER_NAME)
|
||||||
|
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, ASSIGNED_USER_NAME FROM ISSUE WHERE ASSIGNED_USER_NAME IS NOT NULL
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<dropColumn tableName="ISSUE" columnName="ASSIGNED_USER_NAME"/>
|
||||||
|
</changeSet>
|
||||||
6
src/main/resources/update/gitbucket-core_4.39.xml
Normal file
6
src/main/resources/update/gitbucket-core_4.39.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="CUSTOM_FIELD">
|
||||||
|
<column name="CONSTRAINTS" type="varchar(200)" nullable="true"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
-- DELETE COLLABORATORS IN GROUP REPOSITORIES
|
|
||||||
DELETE FROM COLLABORATOR WHERE USER_NAME IN (SELECT USER_NAME FROM ACCOUNT WHERE GROUP_ACCOUNT = TRUE)
|
|
||||||
@@ -30,4 +30,9 @@
|
|||||||
<dropColumn tableName="REPOSITORY" columnName="ENABLE_WIKI"/>
|
<dropColumn tableName="REPOSITORY" columnName="ENABLE_WIKI"/>
|
||||||
<dropColumn tableName="REPOSITORY" columnName="ALLOW_WIKI_EDITING"/>
|
<dropColumn tableName="REPOSITORY" columnName="ALLOW_WIKI_EDITING"/>
|
||||||
<dropColumn tableName="REPOSITORY" columnName="ENABLE_ISSUES"/>
|
<dropColumn tableName="REPOSITORY" columnName="ENABLE_ISSUES"/>
|
||||||
|
|
||||||
|
<!-- DELETE COLLABORATORS IN GROUP REPOSITORIES -->
|
||||||
|
<sql>
|
||||||
|
DELETE FROM COLLABORATOR WHERE USER_NAME IN (SELECT USER_NAME FROM ACCOUNT WHERE GROUP_ACCOUNT = TRUE)
|
||||||
|
</sql>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import java.util.EnumSet
|
|||||||
import javax.servlet._
|
import javax.servlet._
|
||||||
|
|
||||||
import gitbucket.core.controller.{ReleaseController, _}
|
import gitbucket.core.controller.{ReleaseController, _}
|
||||||
import gitbucket.core.plugin.PluginRegistry
|
|
||||||
import gitbucket.core.service.SystemSettingsService
|
import gitbucket.core.service.SystemSettingsService
|
||||||
import gitbucket.core.servlet._
|
import gitbucket.core.servlet._
|
||||||
import gitbucket.core.util.Directory
|
import gitbucket.core.util.Directory
|
||||||
@@ -16,7 +15,7 @@ class ScalatraBootstrap extends LifeCycle with SystemSettingsService {
|
|||||||
context.getSessionCookieConfig.setSecure(true)
|
context.getSessionCookieConfig.setSecure(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register TransactionFilter and BasicAuthenticationFilter at first
|
// Register TransactionFilter at first
|
||||||
context.addFilter("transactionFilter", new TransactionFilter)
|
context.addFilter("transactionFilter", new TransactionFilter)
|
||||||
context
|
context
|
||||||
.getFilterRegistration("transactionFilter")
|
.getFilterRegistration("transactionFilter")
|
||||||
|
|||||||
@@ -1,16 +1,26 @@
|
|||||||
package gitbucket.core
|
package gitbucket.core
|
||||||
|
|
||||||
import io.github.gitbucket.solidbase.migration.{SqlMigration, LiquibaseMigration}
|
import java.io.FileOutputStream
|
||||||
import io.github.gitbucket.solidbase.model.{Version, Module}
|
import java.nio.charset.StandardCharsets
|
||||||
|
import java.sql.Connection
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
import gitbucket.core.model.Activity
|
||||||
|
import gitbucket.core.util.Directory.ActivityLog
|
||||||
|
import gitbucket.core.util.JDBCUtil
|
||||||
|
import io.github.gitbucket.solidbase.Solidbase
|
||||||
|
import io.github.gitbucket.solidbase.migration.{LiquibaseMigration, Migration}
|
||||||
|
import io.github.gitbucket.solidbase.model.{Module, Version}
|
||||||
|
import org.json4s.{Formats, NoTypeHints}
|
||||||
|
import org.json4s.jackson.Serialization
|
||||||
|
import org.json4s.jackson.Serialization.write
|
||||||
|
|
||||||
|
import scala.util.Using
|
||||||
|
|
||||||
object GitBucketCoreModule
|
object GitBucketCoreModule
|
||||||
extends Module(
|
extends Module(
|
||||||
"gitbucket-core",
|
"gitbucket-core",
|
||||||
new Version(
|
new Version("4.0.0", new LiquibaseMigration("update/gitbucket-core_4.0.xml")),
|
||||||
"4.0.0",
|
|
||||||
new LiquibaseMigration("update/gitbucket-core_4.0.xml"),
|
|
||||||
new SqlMigration("update/gitbucket-core_4.0.sql")
|
|
||||||
),
|
|
||||||
new Version("4.1.0"),
|
new Version("4.1.0"),
|
||||||
new Version("4.2.0", new LiquibaseMigration("update/gitbucket-core_4.2.xml")),
|
new Version("4.2.0", new LiquibaseMigration("update/gitbucket-core_4.2.xml")),
|
||||||
new Version("4.2.1"),
|
new Version("4.2.1"),
|
||||||
@@ -18,11 +28,7 @@ object GitBucketCoreModule
|
|||||||
new Version("4.4.0"),
|
new Version("4.4.0"),
|
||||||
new Version("4.5.0"),
|
new Version("4.5.0"),
|
||||||
new Version("4.6.0", new LiquibaseMigration("update/gitbucket-core_4.6.xml")),
|
new Version("4.6.0", new LiquibaseMigration("update/gitbucket-core_4.6.xml")),
|
||||||
new Version(
|
new Version("4.7.0", new LiquibaseMigration("update/gitbucket-core_4.7.xml")),
|
||||||
"4.7.0",
|
|
||||||
new LiquibaseMigration("update/gitbucket-core_4.7.xml"),
|
|
||||||
new SqlMigration("update/gitbucket-core_4.7.sql")
|
|
||||||
),
|
|
||||||
new Version("4.7.1"),
|
new Version("4.7.1"),
|
||||||
new Version("4.8"),
|
new Version("4.8"),
|
||||||
new Version("4.9.0", new LiquibaseMigration("update/gitbucket-core_4.9.xml")),
|
new Version("4.9.0", new LiquibaseMigration("update/gitbucket-core_4.9.xml")),
|
||||||
@@ -31,11 +37,7 @@ object GitBucketCoreModule
|
|||||||
new Version("4.12.0"),
|
new Version("4.12.0"),
|
||||||
new Version("4.12.1"),
|
new Version("4.12.1"),
|
||||||
new Version("4.13.0"),
|
new Version("4.13.0"),
|
||||||
new Version(
|
new Version("4.14.0", new LiquibaseMigration("update/gitbucket-core_4.14.xml")),
|
||||||
"4.14.0",
|
|
||||||
new LiquibaseMigration("update/gitbucket-core_4.14.xml"),
|
|
||||||
new SqlMigration("update/gitbucket-core_4.14.sql")
|
|
||||||
),
|
|
||||||
new Version("4.14.1"),
|
new Version("4.14.1"),
|
||||||
new Version("4.15.0"),
|
new Version("4.15.0"),
|
||||||
new Version("4.16.0"),
|
new Version("4.16.0"),
|
||||||
@@ -59,5 +61,61 @@ object GitBucketCoreModule
|
|||||||
new Version("4.27.0", new LiquibaseMigration("update/gitbucket-core_4.27.xml")),
|
new Version("4.27.0", new LiquibaseMigration("update/gitbucket-core_4.27.xml")),
|
||||||
new Version("4.28.0"),
|
new Version("4.28.0"),
|
||||||
new Version("4.29.0"),
|
new Version("4.29.0"),
|
||||||
new Version("4.30.0")
|
new Version("4.30.0"),
|
||||||
|
new Version("4.30.1"),
|
||||||
|
new Version("4.31.0", new LiquibaseMigration("update/gitbucket-core_4.31.xml")),
|
||||||
|
new Version("4.31.1"),
|
||||||
|
new Version("4.31.2"),
|
||||||
|
new Version("4.32.0", new LiquibaseMigration("update/gitbucket-core_4.32.xml")),
|
||||||
|
new Version("4.33.0"),
|
||||||
|
new Version(
|
||||||
|
"4.34.0",
|
||||||
|
new Migration() {
|
||||||
|
override def migrate(moduleId: String, version: String, context: java.util.Map[String, AnyRef]): Unit = {
|
||||||
|
implicit val formats: Formats = Serialization.formats(NoTypeHints)
|
||||||
|
import JDBCUtil._
|
||||||
|
|
||||||
|
val conn = context.get(Solidbase.CONNECTION).asInstanceOf[Connection]
|
||||||
|
val list = conn.select("SELECT * FROM ACTIVITY ORDER BY ACTIVITY_ID") { rs =>
|
||||||
|
Activity(
|
||||||
|
activityId = UUID.randomUUID().toString,
|
||||||
|
userName = rs.getString("USER_NAME"),
|
||||||
|
repositoryName = rs.getString("REPOSITORY_NAME"),
|
||||||
|
activityUserName = rs.getString("ACTIVITY_USER_NAME"),
|
||||||
|
activityType = rs.getString("ACTIVITY_TYPE"),
|
||||||
|
message = rs.getString("MESSAGE"),
|
||||||
|
additionalInfo = {
|
||||||
|
val additionalInfo = rs.getString("ADDITIONAL_INFO")
|
||||||
|
if (rs.wasNull()) None else Some(additionalInfo)
|
||||||
|
},
|
||||||
|
activityDate = rs.getTimestamp("ACTIVITY_DATE")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Using.resource(new FileOutputStream(ActivityLog, true)) { out =>
|
||||||
|
list.foreach { activity =>
|
||||||
|
out.write((write(activity) + "\n").getBytes(StandardCharsets.UTF_8))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new LiquibaseMigration("update/gitbucket-core_4.34.xml")
|
||||||
|
),
|
||||||
|
new Version("4.35.0", new LiquibaseMigration("update/gitbucket-core_4.35.xml")),
|
||||||
|
new Version("4.35.1"),
|
||||||
|
new Version("4.35.2"),
|
||||||
|
new Version("4.35.3"),
|
||||||
|
new Version("4.36.0", new LiquibaseMigration("update/gitbucket-core_4.36.xml")),
|
||||||
|
new Version("4.36.1"),
|
||||||
|
new Version("4.36.2"),
|
||||||
|
new Version("4.37.0", new LiquibaseMigration("update/gitbucket-core_4.37.xml")),
|
||||||
|
new Version("4.37.1"),
|
||||||
|
new Version("4.37.2"),
|
||||||
|
new Version("4.38.0", new LiquibaseMigration("update/gitbucket-core_4.38.xml")),
|
||||||
|
new Version("4.38.1"),
|
||||||
|
new Version("4.38.2"),
|
||||||
|
new Version("4.38.3"),
|
||||||
|
new Version("4.38.4"),
|
||||||
|
new Version("4.39.0", new LiquibaseMigration("update/gitbucket-core_4.39.xml")),
|
||||||
|
new Version("4.40.0"),
|
||||||
|
new Version("4.41.0")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue
|
||||||
|
*/
|
||||||
|
case class AddLabelsToAnIssue(labels: Seq[String])
|
||||||
@@ -9,7 +9,7 @@ import gitbucket.core.util.RepositoryName
|
|||||||
case class ApiBranch(name: String, commit: ApiBranchCommit, protection: ApiBranchProtection)(
|
case class ApiBranch(name: String, commit: ApiBranchCommit, protection: ApiBranchProtection)(
|
||||||
repositoryName: RepositoryName
|
repositoryName: RepositoryName
|
||||||
) extends FieldSerializable {
|
) extends FieldSerializable {
|
||||||
def _links =
|
val _links =
|
||||||
Map(
|
Map(
|
||||||
"self" -> ApiPath(s"/api/v3/repos/${repositoryName.fullName}/branches/${name}"),
|
"self" -> ApiPath(s"/api/v3/repos/${repositoryName.fullName}/branches/${name}"),
|
||||||
"html" -> ApiPath(s"/${repositoryName.fullName}/tree/${name}")
|
"html" -> ApiPath(s"/${repositoryName.fullName}/tree/${name}")
|
||||||
@@ -22,3 +22,12 @@ case class ApiBranchForList(
|
|||||||
name: String,
|
name: String,
|
||||||
commit: ApiBranchCommit
|
commit: ApiBranchCommit
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://docs.github.com/en/rest/reference/repos#list-branches-for-head-commit
|
||||||
|
*/
|
||||||
|
case class ApiBranchForHeadCommit(
|
||||||
|
name: String,
|
||||||
|
commit: ApiBranchCommit,
|
||||||
|
`protected`: Boolean
|
||||||
|
)
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ import gitbucket.core.service.ProtectedBranchService
|
|||||||
import org.json4s._
|
import org.json4s._
|
||||||
|
|
||||||
/** https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection */
|
/** https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection */
|
||||||
case class ApiBranchProtection(enabled: Boolean, required_status_checks: Option[ApiBranchProtection.Status]) {
|
case class ApiBranchProtection(
|
||||||
|
url: Option[ApiPath], // for output
|
||||||
|
enabled: Boolean,
|
||||||
|
required_status_checks: Option[ApiBranchProtection.Status]
|
||||||
|
) {
|
||||||
def status: ApiBranchProtection.Status = required_status_checks.getOrElse(ApiBranchProtection.statusNone)
|
def status: ApiBranchProtection.Status = required_status_checks.getOrElse(ApiBranchProtection.statusNone)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,13 +19,36 @@ object ApiBranchProtection {
|
|||||||
|
|
||||||
def apply(info: ProtectedBranchService.ProtectedBranchInfo): ApiBranchProtection =
|
def apply(info: ProtectedBranchService.ProtectedBranchInfo): ApiBranchProtection =
|
||||||
ApiBranchProtection(
|
ApiBranchProtection(
|
||||||
|
url = Some(
|
||||||
|
ApiPath(
|
||||||
|
s"/api/v3/repos/${info.owner}/${info.repository}/branches/${info.branch}/protection"
|
||||||
|
)
|
||||||
|
),
|
||||||
enabled = info.enabled,
|
enabled = info.enabled,
|
||||||
required_status_checks = Some(
|
required_status_checks = Some(
|
||||||
Status(EnforcementLevel(info.enabled && info.contexts.nonEmpty, info.includeAdministrators), info.contexts)
|
Status(
|
||||||
|
Some(
|
||||||
|
ApiPath(
|
||||||
|
s"/api/v3/repos/${info.owner}/${info.repository}/branches/${info.branch}/protection/required_status_checks"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
EnforcementLevel(info.enabled && info.contexts.nonEmpty, info.includeAdministrators),
|
||||||
|
info.contexts,
|
||||||
|
Some(
|
||||||
|
ApiPath(
|
||||||
|
s"/api/v3/repos/${info.owner}/${info.repository}/branches/${info.branch}/protection/required_status_checks/contexts"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val statusNone = Status(Off, Seq.empty)
|
)
|
||||||
case class Status(enforcement_level: EnforcementLevel, contexts: Seq[String])
|
)
|
||||||
|
)
|
||||||
|
val statusNone = Status(None, Off, Seq.empty, None)
|
||||||
|
case class Status(
|
||||||
|
url: Option[ApiPath], // for output
|
||||||
|
enforcement_level: EnforcementLevel,
|
||||||
|
contexts: Seq[String],
|
||||||
|
contexts_url: Option[ApiPath] // for output
|
||||||
|
)
|
||||||
sealed class EnforcementLevel(val name: String)
|
sealed class EnforcementLevel(val name: String)
|
||||||
case object Off extends EnforcementLevel("off")
|
case object Off extends EnforcementLevel("off")
|
||||||
case object NonAdmins extends EnforcementLevel("non_admins")
|
case object NonAdmins extends EnforcementLevel("non_admins")
|
||||||
@@ -39,15 +66,16 @@ object ApiBranchProtection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
implicit val enforcementLevelSerializer = new CustomSerializer[EnforcementLevel](
|
implicit val enforcementLevelSerializer: CustomSerializer[EnforcementLevel] =
|
||||||
format =>
|
new CustomSerializer[EnforcementLevel](format =>
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
case JString("off") => Off
|
case JString("off") => Off
|
||||||
case JString("non_admins") => NonAdmins
|
case JString("non_admins") => NonAdmins
|
||||||
case JString("everyone") => Everyone
|
case JString("everyone") => Everyone
|
||||||
}, {
|
},
|
||||||
case x: EnforcementLevel => JString(x.name)
|
{ case x: EnforcementLevel =>
|
||||||
|
JString(x.name)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ case class ApiComment(id: Int, user: ApiUser, body: String, created_at: Date, up
|
|||||||
isPullRequest: Boolean
|
isPullRequest: Boolean
|
||||||
) {
|
) {
|
||||||
val html_url = ApiPath(
|
val html_url = ApiPath(
|
||||||
s"/${repositoryName.fullName}/${if (isPullRequest) { "pull" } else { "issues" }}/${issueId}#comment-${id}"
|
s"/${repositoryName.fullName}/${if (isPullRequest) { "pull" }
|
||||||
|
else { "issues" }}/${issueId}#comment-${id}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,23 +21,15 @@ case class ApiCommit(
|
|||||||
modified: List[String],
|
modified: List[String],
|
||||||
author: ApiPersonIdent,
|
author: ApiPersonIdent,
|
||||||
committer: ApiPersonIdent
|
committer: ApiPersonIdent
|
||||||
)(repositoryName: RepositoryName, urlIsHtmlUrl: Boolean)
|
)(repositoryName: RepositoryName)
|
||||||
extends FieldSerializable {
|
extends FieldSerializable {
|
||||||
val url = if (urlIsHtmlUrl) {
|
val url = ApiPath(s"/api/v3/${repositoryName.fullName}/commits/${id}")
|
||||||
ApiPath(s"/${repositoryName.fullName}/commit/${id}")
|
val html_url = ApiPath(s"/${repositoryName.fullName}/commit/${id}")
|
||||||
} else {
|
|
||||||
ApiPath(s"/api/v3/${repositoryName.fullName}/commits/${id}")
|
|
||||||
}
|
|
||||||
val html_url = if (urlIsHtmlUrl) {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(ApiPath(s"/${repositoryName.fullName}/commit/${id}"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object ApiCommit {
|
object ApiCommit {
|
||||||
def apply(git: Git, repositoryName: RepositoryName, commit: CommitInfo, urlIsHtmlUrl: Boolean = false): ApiCommit = {
|
def apply(git: Git, repositoryName: RepositoryName, commit: CommitInfo): ApiCommit = {
|
||||||
val diffs = JGitUtil.getDiffs(git, None, commit.id, false, false)
|
val diffs = JGitUtil.getDiffs(git = git, from = None, to = commit.id, fetchContent = false, makePatch = false)
|
||||||
ApiCommit(
|
ApiCommit(
|
||||||
id = commit.id,
|
id = commit.id,
|
||||||
message = commit.fullMessage,
|
message = commit.fullMessage,
|
||||||
@@ -53,8 +45,6 @@ object ApiCommit {
|
|||||||
},
|
},
|
||||||
author = ApiPersonIdent.author(commit),
|
author = ApiPersonIdent.author(commit),
|
||||||
committer = ApiPersonIdent.committer(commit)
|
committer = ApiPersonIdent.committer(commit)
|
||||||
)(repositoryName, urlIsHtmlUrl)
|
)(repositoryName)
|
||||||
}
|
}
|
||||||
def forWebhookPayload(git: Git, repositoryName: RepositoryName, commit: CommitInfo): ApiCommit =
|
|
||||||
apply(git, repositoryName, commit, true)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ object ApiCommits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
File(
|
File(
|
||||||
filename = if (diff.changeType == ChangeType.DELETE) { diff.oldPath } else { diff.newPath },
|
filename = if (diff.changeType == ChangeType.DELETE) { diff.oldPath }
|
||||||
|
else { diff.newPath },
|
||||||
additions = additions,
|
additions = additions,
|
||||||
deletions = deletions,
|
deletions = deletions,
|
||||||
changes = additions + deletions,
|
changes = additions + deletions,
|
||||||
@@ -97,8 +98,8 @@ object ApiCommits {
|
|||||||
ApiCommits(
|
ApiCommits(
|
||||||
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${commitInfo.id}"),
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${commitInfo.id}"),
|
||||||
sha = commitInfo.id,
|
sha = commitInfo.id,
|
||||||
html_url = ApiPath(s"${repositoryName.fullName}/commit/${commitInfo.id}"),
|
html_url = ApiPath(s"/${repositoryName.fullName}/commit/${commitInfo.id}"),
|
||||||
comment_url = ApiPath(""),
|
comment_url = ApiPath(""), // TODO no API for commit comment
|
||||||
commit = Commit(
|
commit = Commit(
|
||||||
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${commitInfo.id}"),
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${commitInfo.id}"),
|
||||||
author = ApiPersonIdent.author(commitInfo),
|
author = ApiPersonIdent.author(commitInfo),
|
||||||
@@ -106,7 +107,9 @@ object ApiCommits {
|
|||||||
message = commitInfo.shortMessage,
|
message = commitInfo.shortMessage,
|
||||||
comment_count = commentCount,
|
comment_count = commentCount,
|
||||||
tree = Tree(
|
tree = Tree(
|
||||||
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/tree/${commitInfo.id}"), // TODO This endpoint has not been implemented yet.
|
url = ApiPath(
|
||||||
|
s"/api/v3/repos/${repositoryName.fullName}/tree/${commitInfo.id}"
|
||||||
|
), // TODO This endpoint has not been implemented yet.
|
||||||
sha = commitInfo.id
|
sha = commitInfo.id
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@@ -114,7 +117,9 @@ object ApiCommits {
|
|||||||
committer = ApiUser(committer),
|
committer = ApiUser(committer),
|
||||||
parents = commitInfo.parents.map { parent =>
|
parents = commitInfo.parents.map { parent =>
|
||||||
Tree(
|
Tree(
|
||||||
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/tree/${parent}"), // TODO This endpoint has not been implemented yet.
|
url = ApiPath(
|
||||||
|
s"/api/v3/repos/${repositoryName.fullName}/tree/${parent}"
|
||||||
|
), // TODO This endpoint has not been implemented yet.
|
||||||
sha = parent
|
sha = parent
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,13 +22,12 @@ object ApiContents {
|
|||||||
ApiContents("dir", fileInfo.name, fileInfo.path, fileInfo.commitId, None, None)(repositoryName)
|
ApiContents("dir", fileInfo.name, fileInfo.path, fileInfo.commitId, None, None)(repositoryName)
|
||||||
} else {
|
} else {
|
||||||
content
|
content
|
||||||
.map(
|
.map(arr =>
|
||||||
arr =>
|
|
||||||
ApiContents(
|
ApiContents(
|
||||||
"file",
|
"file",
|
||||||
fileInfo.name,
|
fileInfo.name,
|
||||||
fileInfo.path,
|
fileInfo.path,
|
||||||
fileInfo.commitId,
|
fileInfo.id.getName,
|
||||||
Some(Base64.getEncoder.encodeToString(arr)),
|
Some(Base64.getEncoder.encodeToString(arr)),
|
||||||
Some("base64")
|
Some("base64")
|
||||||
)(repositoryName)
|
)(repositoryName)
|
||||||
|
|||||||
@@ -12,15 +12,19 @@ case class ApiIssue(
|
|||||||
number: Int,
|
number: Int,
|
||||||
title: String,
|
title: String,
|
||||||
user: ApiUser,
|
user: ApiUser,
|
||||||
|
assignees: List[ApiUser],
|
||||||
labels: List[ApiLabel],
|
labels: List[ApiLabel],
|
||||||
state: String,
|
state: String,
|
||||||
created_at: Date,
|
created_at: Date,
|
||||||
updated_at: Date,
|
updated_at: Date,
|
||||||
body: String
|
body: String,
|
||||||
|
milestone: Option[ApiMilestone]
|
||||||
)(repositoryName: RepositoryName, isPullRequest: Boolean) {
|
)(repositoryName: RepositoryName, isPullRequest: Boolean) {
|
||||||
val id = 0 // dummy id
|
val id = 0 // dummy id
|
||||||
|
val assignee = assignees.headOption
|
||||||
val comments_url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/issues/${number}/comments")
|
val comments_url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/issues/${number}/comments")
|
||||||
val html_url = ApiPath(s"/${repositoryName.fullName}/${if (isPullRequest) { "pull" } else { "issues" }}/${number}")
|
val html_url = ApiPath(s"/${repositoryName.fullName}/${if (isPullRequest) { "pull" }
|
||||||
|
else { "issues" }}/${number}")
|
||||||
val pull_request = if (isPullRequest) {
|
val pull_request = if (isPullRequest) {
|
||||||
Some(
|
Some(
|
||||||
Map(
|
Map(
|
||||||
@@ -36,13 +40,23 @@ case class ApiIssue(
|
|||||||
}
|
}
|
||||||
|
|
||||||
object ApiIssue {
|
object ApiIssue {
|
||||||
def apply(issue: Issue, repositoryName: RepositoryName, user: ApiUser, labels: List[ApiLabel]): ApiIssue =
|
def apply(
|
||||||
|
issue: Issue,
|
||||||
|
repositoryName: RepositoryName,
|
||||||
|
user: ApiUser,
|
||||||
|
assignees: List[ApiUser],
|
||||||
|
labels: List[ApiLabel],
|
||||||
|
milestone: Option[ApiMilestone]
|
||||||
|
): ApiIssue =
|
||||||
ApiIssue(
|
ApiIssue(
|
||||||
number = issue.issueId,
|
number = issue.issueId,
|
||||||
title = issue.title,
|
title = issue.title,
|
||||||
user = user,
|
user = user,
|
||||||
|
assignees = assignees,
|
||||||
labels = labels,
|
labels = labels,
|
||||||
state = if (issue.closed) { "closed" } else { "open" },
|
milestone = milestone,
|
||||||
|
state = if (issue.closed) { "closed" }
|
||||||
|
else { "open" },
|
||||||
body = issue.content.getOrElse(""),
|
body = issue.content.getOrElse(""),
|
||||||
created_at = issue.registeredDate,
|
created_at = issue.registeredDate,
|
||||||
updated_at = issue.updatedDate
|
updated_at = issue.updatedDate
|
||||||
|
|||||||
49
src/main/scala/gitbucket/core/api/ApiMilestone.scala
Normal file
49
src/main/scala/gitbucket/core/api/ApiMilestone.scala
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
import gitbucket.core.model.{Milestone, Repository}
|
||||||
|
import gitbucket.core.util.RepositoryName
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://docs.github.com/en/rest/reference/issues#milestones
|
||||||
|
*/
|
||||||
|
case class ApiMilestone(
|
||||||
|
url: ApiPath,
|
||||||
|
html_url: ApiPath,
|
||||||
|
// label_url: ApiPath,
|
||||||
|
id: Int,
|
||||||
|
number: Int,
|
||||||
|
state: String,
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
// creator: ApiUser, // MILESTONE table does not have created user column
|
||||||
|
open_issues: Int,
|
||||||
|
closed_issues: Int,
|
||||||
|
// created_at: Option[Date],
|
||||||
|
// updated_at: Option[Date],
|
||||||
|
closed_at: Option[Date],
|
||||||
|
due_on: Option[Date]
|
||||||
|
)
|
||||||
|
|
||||||
|
object ApiMilestone {
|
||||||
|
def apply(
|
||||||
|
repository: Repository,
|
||||||
|
milestone: Milestone,
|
||||||
|
open_issue_count: Int = 0,
|
||||||
|
closed_issue_count: Int = 0
|
||||||
|
): ApiMilestone =
|
||||||
|
ApiMilestone(
|
||||||
|
url = ApiPath(s"/api/v3/repos/${RepositoryName(repository).fullName}/milestones/${milestone.milestoneId}"),
|
||||||
|
html_url = ApiPath(s"/${RepositoryName(repository).fullName}/milestone/${milestone.milestoneId}"),
|
||||||
|
// label_url = ApiPath(s"/api/v3/repos/${RepositoryName(repository).fullName}/milestones/${milestone_number}/labels"),
|
||||||
|
id = milestone.milestoneId,
|
||||||
|
number = milestone.milestoneId, // use milestoneId as number
|
||||||
|
state = if (milestone.closedDate.isDefined) "closed" else "open",
|
||||||
|
title = milestone.title,
|
||||||
|
description = milestone.description.getOrElse(""),
|
||||||
|
open_issues = open_issue_count,
|
||||||
|
closed_issues = closed_issue_count,
|
||||||
|
closed_at = milestone.closedDate,
|
||||||
|
due_on = milestone.dueDate
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package gitbucket.core.api
|
package gitbucket.core.api
|
||||||
|
|
||||||
import gitbucket.core.plugin.{PluginRegistry, PluginInfo}
|
import gitbucket.core.plugin.PluginInfo
|
||||||
|
|
||||||
case class ApiPlugin(
|
case class ApiPlugin(
|
||||||
id: String,
|
id: String,
|
||||||
|
|||||||
@@ -21,14 +21,16 @@ case class ApiPullRequest(
|
|||||||
body: String,
|
body: String,
|
||||||
user: ApiUser,
|
user: ApiUser,
|
||||||
labels: List[ApiLabel],
|
labels: List[ApiLabel],
|
||||||
assignee: Option[ApiUser]
|
assignees: List[ApiUser],
|
||||||
|
draft: Option[Boolean]
|
||||||
) {
|
) {
|
||||||
val id = 0 // dummy id
|
val id = 0 // dummy id
|
||||||
|
val assignee = assignees.headOption
|
||||||
val html_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}")
|
val html_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}")
|
||||||
//val diff_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.diff")
|
// val diff_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.diff")
|
||||||
//val patch_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.patch")
|
// val patch_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.patch")
|
||||||
val url = ApiPath(s"${base.repo.url.path}/pulls/${number}")
|
val url = ApiPath(s"${base.repo.url.path}/pulls/${number}")
|
||||||
//val issue_url = ApiPath(s"${base.repo.url.path}/issues/${number}")
|
// val issue_url = ApiPath(s"${base.repo.url.path}/issues/${number}")
|
||||||
val commits_url = ApiPath(s"${base.repo.url.path}/pulls/${number}/commits")
|
val commits_url = ApiPath(s"${base.repo.url.path}/pulls/${number}/commits")
|
||||||
val review_comments_url = ApiPath(s"${base.repo.url.path}/pulls/${number}/comments")
|
val review_comments_url = ApiPath(s"${base.repo.url.path}/pulls/${number}/comments")
|
||||||
val review_comment_url = ApiPath(s"${base.repo.url.path}/pulls/comments/{number}")
|
val review_comment_url = ApiPath(s"${base.repo.url.path}/pulls/comments/{number}")
|
||||||
@@ -44,7 +46,7 @@ object ApiPullRequest {
|
|||||||
baseRepo: ApiRepository,
|
baseRepo: ApiRepository,
|
||||||
user: ApiUser,
|
user: ApiUser,
|
||||||
labels: List[ApiLabel],
|
labels: List[ApiLabel],
|
||||||
assignee: Option[ApiUser],
|
assignees: List[ApiUser],
|
||||||
mergedComment: Option[(IssueComment, Account)]
|
mergedComment: Option[(IssueComment, Account)]
|
||||||
): ApiPullRequest =
|
): ApiPullRequest =
|
||||||
ApiPullRequest(
|
ApiPullRequest(
|
||||||
@@ -62,11 +64,13 @@ object ApiPullRequest {
|
|||||||
body = issue.content.getOrElse(""),
|
body = issue.content.getOrElse(""),
|
||||||
user = user,
|
user = user,
|
||||||
labels = labels,
|
labels = labels,
|
||||||
assignee = assignee
|
assignees = assignees,
|
||||||
|
draft = Some(pullRequest.isDraft)
|
||||||
)
|
)
|
||||||
|
|
||||||
case class Commit(sha: String, ref: String, repo: ApiRepository)(baseOwner: String) {
|
case class Commit(sha: String, ref: String, repo: ApiRepository)(baseOwner: String) {
|
||||||
val label = if (baseOwner == repo.owner.login) { ref } else { s"${repo.owner.login}:${ref}" }
|
val label = if (baseOwner == repo.owner.login) { ref }
|
||||||
|
else { s"${repo.owner.login}:${ref}" }
|
||||||
val user = repo.owner
|
val user = repo.owner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,55 @@
|
|||||||
package gitbucket.core.api
|
package gitbucket.core.api
|
||||||
|
|
||||||
case class ApiObject(sha: String)
|
import gitbucket.core.util.JGitUtil.TagInfo
|
||||||
|
import gitbucket.core.util.RepositoryName
|
||||||
|
import org.eclipse.jgit.lib.Ref
|
||||||
|
|
||||||
case class ApiRef(ref: String, `object`: ApiObject)
|
case class ApiRefCommit(
|
||||||
|
sha: String,
|
||||||
|
`type`: String,
|
||||||
|
url: ApiPath
|
||||||
|
)
|
||||||
|
|
||||||
|
case class ApiRef(
|
||||||
|
ref: String,
|
||||||
|
node_id: String = "",
|
||||||
|
url: ApiPath,
|
||||||
|
`object`: ApiRefCommit,
|
||||||
|
)
|
||||||
|
|
||||||
|
object ApiRef {
|
||||||
|
|
||||||
|
def fromRef(
|
||||||
|
repositoryName: RepositoryName,
|
||||||
|
ref: Ref
|
||||||
|
): ApiRef =
|
||||||
|
ApiRef(
|
||||||
|
ref = ref.getName,
|
||||||
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/git/${ref.getName}"),
|
||||||
|
`object` = ApiRefCommit(
|
||||||
|
sha = ref.getObjectId.getName,
|
||||||
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${ref.getObjectId.getName}"),
|
||||||
|
`type` = "commit"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def fromTag(
|
||||||
|
repositoryName: RepositoryName,
|
||||||
|
tagInfo: TagInfo
|
||||||
|
): ApiRef =
|
||||||
|
ApiRef(
|
||||||
|
ref = s"refs/tags/${tagInfo.name}",
|
||||||
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/git/refs/tags/${tagInfo.name}"),
|
||||||
|
// the GH api distinguishes between "releases" and plain git tags
|
||||||
|
// for "releases", the api returns a reference to the release object (with type `tag`)
|
||||||
|
// this would be something like s"/api/v3/repos/${repositoryName.fullName}/git/tags/<hash-of-tag>"
|
||||||
|
// with a hash for the tag, which I do not fully understand
|
||||||
|
// since this is not yet implemented in GB, we always return a link to the plain `commit` object,
|
||||||
|
// which GH does for tags that are not annotated
|
||||||
|
`object` = ApiRefCommit(
|
||||||
|
sha = tagInfo.objectId,
|
||||||
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${tagInfo.objectId}"),
|
||||||
|
`type` = "commit"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
42
src/main/scala/gitbucket/core/api/ApiRelease.scala
Normal file
42
src/main/scala/gitbucket/core/api/ApiRelease.scala
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
import gitbucket.core.model.{Account, ReleaseAsset, ReleaseTag}
|
||||||
|
import gitbucket.core.util.RepositoryName
|
||||||
|
|
||||||
|
case class ApiReleaseAsset(name: String, size: Long)(tag: String, fileName: String, repositoryName: RepositoryName) {
|
||||||
|
val label = name
|
||||||
|
val file_id = fileName
|
||||||
|
val browser_download_url = ApiPath(
|
||||||
|
s"/${repositoryName.fullName}/releases/${tag}/assets/${fileName}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
object ApiReleaseAsset {
|
||||||
|
def apply(asset: ReleaseAsset, repositoryName: RepositoryName): ApiReleaseAsset =
|
||||||
|
ApiReleaseAsset(asset.label, asset.size)(asset.tag, asset.fileName, repositoryName)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class ApiRelease(
|
||||||
|
name: String,
|
||||||
|
tag_name: String,
|
||||||
|
body: Option[String],
|
||||||
|
author: ApiUser,
|
||||||
|
assets: Seq[ApiReleaseAsset]
|
||||||
|
)
|
||||||
|
|
||||||
|
object ApiRelease {
|
||||||
|
def apply(
|
||||||
|
release: ReleaseTag,
|
||||||
|
assets: Seq[ReleaseAsset],
|
||||||
|
author: Account,
|
||||||
|
repositoryName: RepositoryName
|
||||||
|
): ApiRelease =
|
||||||
|
ApiRelease(
|
||||||
|
release.name,
|
||||||
|
release.tag,
|
||||||
|
release.content,
|
||||||
|
ApiUser(author),
|
||||||
|
assets.map { asset =>
|
||||||
|
ApiReleaseAsset(asset, repositoryName)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -12,20 +12,16 @@ case class ApiRepository(
|
|||||||
forks: Int,
|
forks: Int,
|
||||||
`private`: Boolean,
|
`private`: Boolean,
|
||||||
default_branch: String,
|
default_branch: String,
|
||||||
owner: ApiUser
|
owner: ApiUser,
|
||||||
)(urlIsHtmlUrl: Boolean) {
|
has_issues: Boolean
|
||||||
|
) {
|
||||||
val id = 0 // dummy id
|
val id = 0 // dummy id
|
||||||
val forks_count = forks
|
val forks_count = forks
|
||||||
val watchers_count = watchers
|
val watchers_count = watchers
|
||||||
val url = if (urlIsHtmlUrl) {
|
val url = ApiPath(s"/api/v3/repos/${full_name}")
|
||||||
ApiPath(s"/${full_name}")
|
|
||||||
} else {
|
|
||||||
ApiPath(s"/api/v3/repos/${full_name}")
|
|
||||||
}
|
|
||||||
val http_url = ApiPath(s"/git/${full_name}.git")
|
|
||||||
val clone_url = ApiPath(s"/git/${full_name}.git")
|
val clone_url = ApiPath(s"/git/${full_name}.git")
|
||||||
val html_url = ApiPath(s"/${full_name}")
|
val html_url = ApiPath(s"/${full_name}")
|
||||||
val ssh_url = Some(SshPath(s":${full_name}.git"))
|
val ssh_url = Some(SshPath(""))
|
||||||
}
|
}
|
||||||
|
|
||||||
object ApiRepository {
|
object ApiRepository {
|
||||||
@@ -33,8 +29,7 @@ object ApiRepository {
|
|||||||
repository: Repository,
|
repository: Repository,
|
||||||
owner: ApiUser,
|
owner: ApiUser,
|
||||||
forkedCount: Int = 0,
|
forkedCount: Int = 0,
|
||||||
watchers: Int = 0,
|
watchers: Int = 0
|
||||||
urlIsHtmlUrl: Boolean = false
|
|
||||||
): ApiRepository =
|
): ApiRepository =
|
||||||
ApiRepository(
|
ApiRepository(
|
||||||
name = repository.repositoryName,
|
name = repository.repositoryName,
|
||||||
@@ -44,17 +39,19 @@ object ApiRepository {
|
|||||||
forks = forkedCount,
|
forks = forkedCount,
|
||||||
`private` = repository.isPrivate,
|
`private` = repository.isPrivate,
|
||||||
default_branch = repository.defaultBranch,
|
default_branch = repository.defaultBranch,
|
||||||
owner = owner
|
owner = owner,
|
||||||
)(urlIsHtmlUrl)
|
has_issues = if (repository.options.issuesOption == "DISABLE") false else true
|
||||||
|
)
|
||||||
|
|
||||||
def apply(repositoryInfo: RepositoryInfo, owner: ApiUser): ApiRepository =
|
def apply(repositoryInfo: RepositoryInfo, owner: ApiUser): ApiRepository =
|
||||||
ApiRepository(repositoryInfo.repository, owner, forkedCount = repositoryInfo.forkedCount)
|
ApiRepository(
|
||||||
|
repositoryInfo.repository,
|
||||||
|
owner,
|
||||||
|
forkedCount = repositoryInfo.forkedCount
|
||||||
|
)
|
||||||
|
|
||||||
def apply(repositoryInfo: RepositoryInfo, owner: Account): ApiRepository =
|
def apply(repositoryInfo: RepositoryInfo, owner: Account): ApiRepository =
|
||||||
this(repositoryInfo.repository, ApiUser(owner))
|
this(repositoryInfo, ApiUser(owner))
|
||||||
|
|
||||||
def forWebhookPayload(repositoryInfo: RepositoryInfo, owner: ApiUser): ApiRepository =
|
|
||||||
ApiRepository(repositoryInfo.repository, owner, forkedCount = repositoryInfo.forkedCount, urlIsHtmlUrl = true)
|
|
||||||
|
|
||||||
def forDummyPayload(owner: ApiUser): ApiRepository =
|
def forDummyPayload(owner: ApiUser): ApiRepository =
|
||||||
ApiRepository(
|
ApiRepository(
|
||||||
@@ -64,7 +61,8 @@ object ApiRepository {
|
|||||||
watchers = 0,
|
watchers = 0,
|
||||||
forks = 0,
|
forks = 0,
|
||||||
`private` = false,
|
`private` = false,
|
||||||
default_branch = "master",
|
default_branch = "main",
|
||||||
owner = owner
|
owner = owner,
|
||||||
)(true)
|
has_issues = true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
case class ApiRepositoryCollaborator(
|
||||||
|
permission: String,
|
||||||
|
user: ApiUser
|
||||||
|
)
|
||||||
@@ -24,7 +24,8 @@ object ApiUser {
|
|||||||
def apply(user: Account): ApiUser = ApiUser(
|
def apply(user: Account): ApiUser = ApiUser(
|
||||||
login = user.userName,
|
login = user.userName,
|
||||||
email = user.mailAddress,
|
email = user.mailAddress,
|
||||||
`type` = if (user.isGroupAccount) { "Organization" } else { "User" },
|
`type` = if (user.isGroupAccount) { "Organization" }
|
||||||
|
else { "User" },
|
||||||
site_admin = user.isAdmin,
|
site_admin = user.isAdmin,
|
||||||
created_at = user.registeredDate
|
created_at = user.registeredDate
|
||||||
)
|
)
|
||||||
|
|||||||
44
src/main/scala/gitbucket/core/api/ApiWebhook.scala
Normal file
44
src/main/scala/gitbucket/core/api/ApiWebhook.scala
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
import gitbucket.core.model.{RepositoryWebHook, WebHook}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://docs.github.com/en/rest/reference/repos#webhooks
|
||||||
|
*/
|
||||||
|
case class ApiWebhookConfig(
|
||||||
|
content_type: String,
|
||||||
|
// insecure_ssl: String,
|
||||||
|
url: String
|
||||||
|
)
|
||||||
|
|
||||||
|
case class ApiWebhook(
|
||||||
|
`type`: String,
|
||||||
|
id: Int,
|
||||||
|
name: String,
|
||||||
|
active: Boolean,
|
||||||
|
events: List[String],
|
||||||
|
config: ApiWebhookConfig,
|
||||||
|
// updated_at: Option[Date],
|
||||||
|
// created_at: Option[Date],
|
||||||
|
url: ApiPath,
|
||||||
|
// test_url: ApiPath,
|
||||||
|
// ping_url: ApiPath,
|
||||||
|
// last_response: ...
|
||||||
|
)
|
||||||
|
|
||||||
|
object ApiWebhook {
|
||||||
|
def apply(
|
||||||
|
_type: String,
|
||||||
|
hook: RepositoryWebHook,
|
||||||
|
hookEvents: Set[WebHook.Event]
|
||||||
|
): ApiWebhook =
|
||||||
|
ApiWebhook(
|
||||||
|
`type` = _type,
|
||||||
|
id = hook.hookId,
|
||||||
|
name = "web", // dummy
|
||||||
|
active = true, // dummy
|
||||||
|
events = hookEvents.toList.map(_.name),
|
||||||
|
config = ApiWebhookConfig(hook.ctype.code, hook.url),
|
||||||
|
url = ApiPath(s"/api/v3/${hook.userName}/${hook.repositoryName}/hooks/${hook.hookId}")
|
||||||
|
)
|
||||||
|
}
|
||||||
13
src/main/scala/gitbucket/core/api/CreateAFile.scala
Normal file
13
src/main/scala/gitbucket/core/api/CreateAFile.scala
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/contents/#create-a-file
|
||||||
|
*/
|
||||||
|
case class CreateAFile(
|
||||||
|
message: String,
|
||||||
|
content: String,
|
||||||
|
sha: Option[String],
|
||||||
|
branch: Option[String],
|
||||||
|
committer: Option[ApiPusher],
|
||||||
|
author: Option[ApiPusher]
|
||||||
|
)
|
||||||
8
src/main/scala/gitbucket/core/api/CreateAGroup.scala
Normal file
8
src/main/scala/gitbucket/core/api/CreateAGroup.scala
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
case class CreateAGroup(
|
||||||
|
login: String,
|
||||||
|
admin: String,
|
||||||
|
profile_name: Option[String],
|
||||||
|
url: Option[String]
|
||||||
|
)
|
||||||
14
src/main/scala/gitbucket/core/api/CreateAMilestone.scala
Normal file
14
src/main/scala/gitbucket/core/api/CreateAMilestone.scala
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
case class CreateAMilestone(
|
||||||
|
title: String,
|
||||||
|
state: String = "open",
|
||||||
|
description: Option[String],
|
||||||
|
due_on: Option[Date]
|
||||||
|
) {
|
||||||
|
def isValid: Boolean = {
|
||||||
|
title.length <= 100 && title.matches("[a-zA-Z0-9\\-\\+_.]+")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,8 @@ case class CreateAPullRequest(
|
|||||||
head: String,
|
head: String,
|
||||||
base: String,
|
base: String,
|
||||||
body: Option[String],
|
body: Option[String],
|
||||||
maintainer_can_modify: Option[Boolean]
|
maintainer_can_modify: Option[Boolean],
|
||||||
|
draft: Option[Boolean]
|
||||||
)
|
)
|
||||||
|
|
||||||
case class CreateAPullRequestAlt(
|
case class CreateAPullRequestAlt(
|
||||||
@@ -14,3 +15,11 @@ case class CreateAPullRequestAlt(
|
|||||||
base: String,
|
base: String,
|
||||||
maintainer_can_modify: Option[Boolean]
|
maintainer_can_modify: Option[Boolean]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
case class UpdateAPullRequest(
|
||||||
|
title: Option[String],
|
||||||
|
body: Option[String],
|
||||||
|
state: Option[String],
|
||||||
|
base: Option[String],
|
||||||
|
maintainer_can_modify: Option[Boolean],
|
||||||
|
)
|
||||||
|
|||||||
7
src/main/scala/gitbucket/core/api/CreateARef.scala
Normal file
7
src/main/scala/gitbucket/core/api/CreateARef.scala
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#create-a-reference
|
||||||
|
* api form
|
||||||
|
*/
|
||||||
|
case class CreateARef(ref: String, sha: String)
|
||||||
10
src/main/scala/gitbucket/core/api/CreateARelease.scala
Normal file
10
src/main/scala/gitbucket/core/api/CreateARelease.scala
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
case class CreateARelease(
|
||||||
|
tag_name: String,
|
||||||
|
target_commitish: Option[String],
|
||||||
|
name: Option[String],
|
||||||
|
body: Option[String],
|
||||||
|
draft: Option[Boolean],
|
||||||
|
prerelease: Option[Boolean]
|
||||||
|
)
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
case class CreateARepositoryWebhookConfig(
|
||||||
|
url: String,
|
||||||
|
content_type: String = "form",
|
||||||
|
insecure_ssl: String = "0",
|
||||||
|
secret: Option[String]
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://docs.github.com/en/rest/reference/repos#create-a-repository-webhook
|
||||||
|
*/
|
||||||
|
case class CreateARepositoryWebhook(
|
||||||
|
name: String = "web",
|
||||||
|
config: CreateARepositoryWebhookConfig,
|
||||||
|
events: List[String] = List("push"),
|
||||||
|
active: Boolean = true
|
||||||
|
) {
|
||||||
|
def isValid: Boolean = {
|
||||||
|
config.content_type == "form" || config.content_type == "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case class UpdateARepositoryWebhook(
|
||||||
|
name: String = "web",
|
||||||
|
config: CreateARepositoryWebhookConfig,
|
||||||
|
events: List[String] = List("push"),
|
||||||
|
add_events: List[String] = List(),
|
||||||
|
remove_events: List[String] = List(),
|
||||||
|
active: Boolean = true
|
||||||
|
) {
|
||||||
|
def isValid: Boolean = {
|
||||||
|
config.content_type == "form" || config.content_type == "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,13 +15,12 @@ object JsonFormat {
|
|||||||
|
|
||||||
val parserISO = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
val parserISO = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||||
|
|
||||||
val jsonFormats = Serialization.formats(NoTypeHints) + new CustomSerializer[Date](
|
val jsonFormats = Serialization.formats(NoTypeHints) + new CustomSerializer[Date](format =>
|
||||||
format =>
|
|
||||||
(
|
(
|
||||||
{
|
{ case JString(s) =>
|
||||||
case JString(s) =>
|
|
||||||
Try(Date.from(Instant.parse(s))).getOrElse(throw new MappingException("Can't convert " + s + " to Date"))
|
Try(Date.from(Instant.parse(s))).getOrElse(throw new MappingException("Can't convert " + s + " to Date"))
|
||||||
}, { case x: Date => JString(OffsetDateTime.ofInstant(x.toInstant, ZoneId.of("UTC")).format(parserISO)) }
|
},
|
||||||
|
{ case x: Date => JString(OffsetDateTime.ofInstant(x.toInstant, ZoneId.of("UTC")).format(parserISO)) }
|
||||||
)
|
)
|
||||||
) + FieldSerializer[ApiUser]() +
|
) + FieldSerializer[ApiUser]() +
|
||||||
FieldSerializer[ApiGroup]() +
|
FieldSerializer[ApiGroup]() +
|
||||||
@@ -43,32 +42,37 @@ object JsonFormat {
|
|||||||
FieldSerializer[ApiCommits.Tree]() +
|
FieldSerializer[ApiCommits.Tree]() +
|
||||||
FieldSerializer[ApiCommits.Stats]() +
|
FieldSerializer[ApiCommits.Stats]() +
|
||||||
FieldSerializer[ApiCommits.File]() +
|
FieldSerializer[ApiCommits.File]() +
|
||||||
|
FieldSerializer[ApiRelease]() +
|
||||||
|
FieldSerializer[ApiReleaseAsset]() +
|
||||||
ApiBranchProtection.enforcementLevelSerializer
|
ApiBranchProtection.enforcementLevelSerializer
|
||||||
|
|
||||||
def apiPathSerializer(c: Context) =
|
def apiPathSerializer(c: Context) =
|
||||||
new CustomSerializer[ApiPath](
|
new CustomSerializer[ApiPath](_ =>
|
||||||
_ =>
|
(
|
||||||
({
|
{
|
||||||
case JString(s) if s.startsWith(c.baseUrl) => ApiPath(s.substring(c.baseUrl.length))
|
case JString(s) if s.startsWith(c.baseUrl) => ApiPath(s.substring(c.baseUrl.length))
|
||||||
case JString(s) => throw new MappingException("Can't convert " + s + " to ApiPath")
|
case JString(s) => throw new MappingException("Can't convert " + s + " to ApiPath")
|
||||||
}, {
|
},
|
||||||
case ApiPath(path) => JString(c.baseUrl + path)
|
{ case ApiPath(path) =>
|
||||||
})
|
JString(c.baseUrl + path)
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def sshPathSerializer(c: Context) =
|
def sshPathSerializer(c: Context) =
|
||||||
new CustomSerializer[SshPath](
|
new CustomSerializer[SshPath](_ =>
|
||||||
_ =>
|
(
|
||||||
({
|
{
|
||||||
case JString(s) if c.sshUrl.exists(sshUrl => s.startsWith(sshUrl)) =>
|
case JString(s) if c.sshUrl.exists(sshUrl => s.startsWith(sshUrl)) =>
|
||||||
SshPath(s.substring(c.sshUrl.get.length))
|
SshPath(s.substring(c.sshUrl.get.length))
|
||||||
case JString(s) => throw new MappingException("Can't convert " + s + " to ApiPath")
|
case JString(s) => throw new MappingException("Can't convert " + s + " to ApiPath")
|
||||||
}, {
|
},
|
||||||
case SshPath(path) =>
|
{ case SshPath(path) =>
|
||||||
c.sshUrl.map { sshUrl =>
|
c.sshUrl.map { sshUrl =>
|
||||||
JString(sshUrl + path)
|
JString(sshUrl + path)
|
||||||
} getOrElse JNothing
|
} getOrElse JNothing
|
||||||
})
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
23
src/main/scala/gitbucket/core/api/MergeAPullRequest.scala
Normal file
23
src/main/scala/gitbucket/core/api/MergeAPullRequest.scala
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://docs.github.com/en/rest/reference/pulls#merge-a-pull-request
|
||||||
|
*/
|
||||||
|
case class MergeAPullRequest(
|
||||||
|
commit_title: Option[String],
|
||||||
|
commit_message: Option[String],
|
||||||
|
/* TODO: Not Implemented
|
||||||
|
sha: Option[String],*/
|
||||||
|
merge_method: Option[String]
|
||||||
|
)
|
||||||
|
|
||||||
|
case class SuccessToMergePrResponse(
|
||||||
|
sha: String,
|
||||||
|
merged: Boolean,
|
||||||
|
message: String
|
||||||
|
)
|
||||||
|
|
||||||
|
case class FailToMergePrResponse(
|
||||||
|
documentation_url: String,
|
||||||
|
message: String
|
||||||
|
)
|
||||||
7
src/main/scala/gitbucket/core/api/UpdateARef.scala
Normal file
7
src/main/scala/gitbucket/core/api/UpdateARef.scala
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#update-a-reference
|
||||||
|
* api form
|
||||||
|
*/
|
||||||
|
case class UpdateARef(sha: String, force: Boolean)
|
||||||
@@ -5,7 +5,6 @@ import java.io.File
|
|||||||
import gitbucket.core.account.html
|
import gitbucket.core.account.html
|
||||||
import gitbucket.core.helper
|
import gitbucket.core.helper
|
||||||
import gitbucket.core.model._
|
import gitbucket.core.model._
|
||||||
import gitbucket.core.plugin.PluginRegistry
|
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.service.WebHookService._
|
import gitbucket.core.service.WebHookService._
|
||||||
import gitbucket.core.ssh.SshUtil
|
import gitbucket.core.ssh.SshUtil
|
||||||
@@ -17,6 +16,7 @@ import gitbucket.core.util._
|
|||||||
import org.scalatra.i18n.Messages
|
import org.scalatra.i18n.Messages
|
||||||
import org.scalatra.BadRequest
|
import org.scalatra.BadRequest
|
||||||
import org.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
|
import org.scalatra.Forbidden
|
||||||
|
|
||||||
class AccountController
|
class AccountController
|
||||||
extends AccountControllerBase
|
extends AccountControllerBase
|
||||||
@@ -26,6 +26,7 @@ class AccountController
|
|||||||
with WikiService
|
with WikiService
|
||||||
with LabelsService
|
with LabelsService
|
||||||
with SshKeyService
|
with SshKeyService
|
||||||
|
with GpgKeyService
|
||||||
with OneselfAuthenticator
|
with OneselfAuthenticator
|
||||||
with UsersAuthenticator
|
with UsersAuthenticator
|
||||||
with GroupManagerAuthenticator
|
with GroupManagerAuthenticator
|
||||||
@@ -34,6 +35,7 @@ class AccountController
|
|||||||
with WebHookService
|
with WebHookService
|
||||||
with PrioritiesService
|
with PrioritiesService
|
||||||
with RepositoryCreationService
|
with RepositoryCreationService
|
||||||
|
with RequestCache
|
||||||
|
|
||||||
trait AccountControllerBase extends AccountManagementControllerBase {
|
trait AccountControllerBase extends AccountManagementControllerBase {
|
||||||
self: AccountService
|
self: AccountService
|
||||||
@@ -42,6 +44,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
with WikiService
|
with WikiService
|
||||||
with LabelsService
|
with LabelsService
|
||||||
with SshKeyService
|
with SshKeyService
|
||||||
|
with GpgKeyService
|
||||||
with OneselfAuthenticator
|
with OneselfAuthenticator
|
||||||
with UsersAuthenticator
|
with UsersAuthenticator
|
||||||
with GroupManagerAuthenticator
|
with GroupManagerAuthenticator
|
||||||
@@ -75,11 +78,15 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
case class SshKeyForm(title: String, publicKey: String)
|
case class SshKeyForm(title: String, publicKey: String)
|
||||||
|
|
||||||
|
case class GpgKeyForm(title: String, publicKey: String)
|
||||||
|
|
||||||
case class PersonalTokenForm(note: String)
|
case class PersonalTokenForm(note: String)
|
||||||
|
|
||||||
|
case class SyntaxHighlighterThemeForm(theme: String)
|
||||||
|
|
||||||
val newForm = mapping(
|
val newForm = mapping(
|
||||||
"userName" -> trim(label("User name", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
"userName" -> trim(label("User name", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
"password" -> trim(label("Password", text(required, maxlength(20), password))),
|
"password" -> trim(label("Password", text(required, maxlength(40)))),
|
||||||
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress()))),
|
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress()))),
|
||||||
"extraMailAddresses" -> list(
|
"extraMailAddresses" -> list(
|
||||||
@@ -91,7 +98,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
)(AccountNewForm.apply)
|
)(AccountNewForm.apply)
|
||||||
|
|
||||||
val editForm = mapping(
|
val editForm = mapping(
|
||||||
"password" -> trim(label("Password", optional(text(maxlength(20), password)))),
|
"password" -> trim(label("Password", optional(text(maxlength(40))))),
|
||||||
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress("userName")))),
|
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress("userName")))),
|
||||||
"extraMailAddresses" -> list(
|
"extraMailAddresses" -> list(
|
||||||
@@ -108,10 +115,28 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"publicKey" -> trim2(label("Key", text(required, validPublicKey)))
|
"publicKey" -> trim2(label("Key", text(required, validPublicKey)))
|
||||||
)(SshKeyForm.apply)
|
)(SshKeyForm.apply)
|
||||||
|
|
||||||
|
val gpgKeyForm = mapping(
|
||||||
|
"title" -> trim(label("Title", text(required, maxlength(100)))),
|
||||||
|
"publicKey" -> label("Key", text(required, validGpgPublicKey))
|
||||||
|
)(GpgKeyForm.apply)
|
||||||
|
|
||||||
val personalTokenForm = mapping(
|
val personalTokenForm = mapping(
|
||||||
"note" -> trim(label("Token", text(required, maxlength(100))))
|
"note" -> trim(label("Token", text(required, maxlength(100))))
|
||||||
)(PersonalTokenForm.apply)
|
)(PersonalTokenForm.apply)
|
||||||
|
|
||||||
|
val syntaxHighlighterThemeForm = mapping(
|
||||||
|
"highlighterTheme" -> trim(label("Theme", text(required)))
|
||||||
|
)(SyntaxHighlighterThemeForm.apply)
|
||||||
|
|
||||||
|
val resetPasswordEmailForm = mapping(
|
||||||
|
"mailAddress" -> trim(label("Email", text(required)))
|
||||||
|
)(ResetPasswordEmailForm.apply)
|
||||||
|
|
||||||
|
val resetPasswordForm = mapping(
|
||||||
|
"token" -> trim(label("Token", text(required))),
|
||||||
|
"password" -> trim(label("Password", text(required, maxlength(40))))
|
||||||
|
)(ResetPasswordForm.apply)
|
||||||
|
|
||||||
case class NewGroupForm(
|
case class NewGroupForm(
|
||||||
groupName: String,
|
groupName: String,
|
||||||
description: Option[String],
|
description: Option[String],
|
||||||
@@ -127,6 +152,13 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
members: String,
|
members: String,
|
||||||
clearImage: Boolean
|
clearImage: Boolean
|
||||||
)
|
)
|
||||||
|
case class ResetPasswordEmailForm(
|
||||||
|
mailAddress: String
|
||||||
|
)
|
||||||
|
case class ResetPasswordForm(
|
||||||
|
token: String,
|
||||||
|
password: String
|
||||||
|
)
|
||||||
|
|
||||||
val newGroupForm = mapping(
|
val newGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
"groupName" -> trim(label("Group name", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
@@ -153,7 +185,6 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
initOption: String,
|
initOption: String,
|
||||||
sourceUrl: Option[String]
|
sourceUrl: Option[String]
|
||||||
)
|
)
|
||||||
case class ForkRepositoryForm(owner: String, name: String)
|
|
||||||
|
|
||||||
val newRepositoryForm = mapping(
|
val newRepositoryForm = mapping(
|
||||||
"owner" -> trim(label("Owner", text(required, maxlength(100), identifier, existsAccount))),
|
"owner" -> trim(label("Owner", text(required, maxlength(100), identifier, existsAccount))),
|
||||||
@@ -164,11 +195,6 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"sourceUrl" -> trim(label("Source URL", optionalRequired(_.value("initOption") == "COPY", text())))
|
"sourceUrl" -> trim(label("Source URL", optionalRequired(_.value("initOption") == "COPY", text())))
|
||||||
)(RepositoryCreationForm.apply)
|
)(RepositoryCreationForm.apply)
|
||||||
|
|
||||||
val forkRepositoryForm = mapping(
|
|
||||||
"owner" -> trim(label("Repository owner", text(required))),
|
|
||||||
"name" -> trim(label("Repository name", text(required)))
|
|
||||||
)(ForkRepositoryForm.apply)
|
|
||||||
|
|
||||||
case class AccountForm(accountName: String)
|
case class AccountForm(accountName: String)
|
||||||
|
|
||||||
val accountForm = mapping(
|
val accountForm = mapping(
|
||||||
@@ -189,9 +215,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"events" -> accountWebhookEvents,
|
"events" -> accountWebhookEvents,
|
||||||
"ctype" -> label("ctype", text()),
|
"ctype" -> label("ctype", text()),
|
||||||
"token" -> optional(trim(label("token", text(maxlength(100)))))
|
"token" -> optional(trim(label("token", text(maxlength(100)))))
|
||||||
)(
|
)((url, events, ctype, token) => AccountWebHookForm(url, events, WebHookContentType.valueOf(ctype), token))
|
||||||
(url, events, ctype, token) => AccountWebHookForm(url, events, WebHookContentType.valueOf(ctype), token)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides duplication check for web hook url. duplicated from RepositorySettingsController.scala
|
* Provides duplication check for web hook url. duplicated from RepositorySettingsController.scala
|
||||||
@@ -236,7 +260,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
gitbucket.core.account.html.activity(
|
gitbucket.core.account.html.activity(
|
||||||
account,
|
account,
|
||||||
if (account.isGroupAccount) Nil else getGroupsByUserName(userName),
|
if (account.isGroupAccount) Nil else getGroupsByUserName(userName),
|
||||||
getActivitiesByUser(userName, true),
|
getActivitiesByUser(userName, publicOnly = true),
|
||||||
extraMailAddresses
|
extraMailAddresses
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -247,12 +271,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
account,
|
account,
|
||||||
members,
|
members,
|
||||||
extraMailAddresses,
|
extraMailAddresses,
|
||||||
context.loginAccount.exists(
|
isGroupManager(context.loginAccount, members)
|
||||||
x =>
|
|
||||||
members.exists { member =>
|
|
||||||
member.userName == x.userName && member.isManager
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,12 +283,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
if (account.isGroupAccount) Nil else getGroupsByUserName(userName),
|
if (account.isGroupAccount) Nil else getGroupsByUserName(userName),
|
||||||
getVisibleRepositories(context.loginAccount, Some(userName)),
|
getVisibleRepositories(context.loginAccount, Some(userName)),
|
||||||
extraMailAddresses,
|
extraMailAddresses,
|
||||||
context.loginAccount.exists(
|
isGroupManager(context.loginAccount, members)
|
||||||
x =>
|
|
||||||
members.exists { member =>
|
|
||||||
member.userName == x.userName && member.isManager
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -324,8 +338,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
post("/:userName/_edit", editForm)(oneselfOnly { form =>
|
post("/:userName/_edit", editForm)(oneselfOnly { form =>
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map {
|
getAccountByUserName(userName).map { account =>
|
||||||
account =>
|
|
||||||
updateAccount(
|
updateAccount(
|
||||||
account.copy(
|
account.copy(
|
||||||
password = form.password.map(pbkdf2_sha256).getOrElse(account.password),
|
password = form.password.map(pbkdf2_sha256).getOrElse(account.password),
|
||||||
@@ -338,7 +351,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
updateImage(userName, form.fileId, form.clearImage)
|
updateImage(userName, form.fileId, form.clearImage)
|
||||||
updateAccountExtraMailAddresses(userName, form.extraMailAddresses.filter(_ != ""))
|
updateAccountExtraMailAddresses(userName, form.extraMailAddresses.filter(_ != ""))
|
||||||
flash += "info" -> "Account information has been updated."
|
flash.update("info", "Account information has been updated.")
|
||||||
redirect(s"/${userName}/_edit")
|
redirect(s"/${userName}/_edit")
|
||||||
|
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
@@ -347,10 +360,9 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
get("/:userName/_delete")(oneselfOnly {
|
get("/:userName/_delete")(oneselfOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
|
|
||||||
getAccountByUserName(userName, true).map {
|
getAccountByUserName(userName, true).map { account =>
|
||||||
account =>
|
|
||||||
if (isLastAdministrator(account)) {
|
if (isLastAdministrator(account)) {
|
||||||
flash += "error" -> "Account can't be removed because this is last one administrator."
|
flash.update("error", "Account can't be removed because this is last one administrator.")
|
||||||
redirect(s"/${userName}/_edit")
|
redirect(s"/${userName}/_edit")
|
||||||
} else {
|
} else {
|
||||||
// // Remove repositories
|
// // Remove repositories
|
||||||
@@ -387,6 +399,27 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
redirect(s"/${userName}/_ssh")
|
redirect(s"/${userName}/_ssh")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
get("/:userName/_gpg")(oneselfOnly {
|
||||||
|
val userName = params("userName")
|
||||||
|
getAccountByUserName(userName).map { x =>
|
||||||
|
// html.ssh(x, getPublicKeys(x.userName))
|
||||||
|
html.gpg(x, getGpgPublicKeys(x.userName))
|
||||||
|
} getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
post("/:userName/_gpg", gpgKeyForm)(oneselfOnly { form =>
|
||||||
|
val userName = params("userName")
|
||||||
|
addGpgPublicKey(userName, form.title, form.publicKey)
|
||||||
|
redirect(s"/${userName}/_gpg")
|
||||||
|
})
|
||||||
|
|
||||||
|
get("/:userName/_gpg/delete/:id")(oneselfOnly {
|
||||||
|
val userName = params("userName")
|
||||||
|
val keyId = params("id").toInt
|
||||||
|
deleteGpgPublicKey(userName, keyId)
|
||||||
|
redirect(s"/${userName}/_gpg")
|
||||||
|
})
|
||||||
|
|
||||||
get("/:userName/_application")(oneselfOnly {
|
get("/:userName/_application")(oneselfOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map { x =>
|
getAccountByUserName(userName).map { x =>
|
||||||
@@ -407,9 +440,9 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
post("/:userName/_personalToken", personalTokenForm)(oneselfOnly { form =>
|
post("/:userName/_personalToken", personalTokenForm)(oneselfOnly { form =>
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map { x =>
|
getAccountByUserName(userName).foreach { x =>
|
||||||
val (tokenId, token) = generateAccessToken(userName, form.note)
|
val (tokenId, token) = generateAccessToken(userName, form.note)
|
||||||
flash += "generatedToken" -> (tokenId, token)
|
flash.update("generatedToken", (tokenId, token))
|
||||||
}
|
}
|
||||||
redirect(s"/${userName}/_application")
|
redirect(s"/${userName}/_application")
|
||||||
})
|
})
|
||||||
@@ -421,6 +454,29 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
redirect(s"/${userName}/_application")
|
redirect(s"/${userName}/_application")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the user preference settings page
|
||||||
|
*/
|
||||||
|
get("/:userName/_preferences")(oneselfOnly {
|
||||||
|
val userName = params("userName")
|
||||||
|
val currentTheme = getAccountPreference(userName) match {
|
||||||
|
case Some(accountHighlighter) => accountHighlighter.highlighterTheme
|
||||||
|
case _ => "github-v2"
|
||||||
|
}
|
||||||
|
getAccountByUserName(userName).map { x =>
|
||||||
|
html.preferences(x, currentTheme)
|
||||||
|
} getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the syntax highlighter setting of user
|
||||||
|
*/
|
||||||
|
post("/:userName/_preferences/highlighter", syntaxHighlighterThemeForm)(oneselfOnly { form =>
|
||||||
|
val userName = params("userName")
|
||||||
|
addOrUpdateAccountPreference(userName, form.theme)
|
||||||
|
redirect(s"/${userName}/_preferences")
|
||||||
|
})
|
||||||
|
|
||||||
get("/:userName/_hooks")(managersOnly {
|
get("/:userName/_hooks")(managersOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map { account =>
|
getAccountByUserName(userName).map { account =>
|
||||||
@@ -445,7 +501,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
post("/:userName/_hooks/new", accountWebHookForm(false))(managersOnly { form =>
|
post("/:userName/_hooks/new", accountWebHookForm(false))(managersOnly { form =>
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
addAccountWebHook(userName, form.url, form.events, form.ctype, form.token)
|
addAccountWebHook(userName, form.url, form.events, form.ctype, form.token)
|
||||||
flash += "info" -> s"Webhook ${form.url} created"
|
flash.update("info", s"Webhook ${form.url} created")
|
||||||
redirect(s"/${userName}/_hooks")
|
redirect(s"/${userName}/_hooks")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -455,7 +511,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
get("/:userName/_hooks/delete")(managersOnly {
|
get("/:userName/_hooks/delete")(managersOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
deleteAccountWebHook(userName, params("url"))
|
deleteAccountWebHook(userName, params("url"))
|
||||||
flash += "info" -> s"Webhook ${params("url")} deleted"
|
flash.update("info", s"Webhook ${params("url")} deleted")
|
||||||
redirect(s"/${userName}/_hooks")
|
redirect(s"/${userName}/_hooks")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -465,8 +521,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
get("/:userName/_hooks/edit")(managersOnly {
|
get("/:userName/_hooks/edit")(managersOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).flatMap { account =>
|
getAccountByUserName(userName).flatMap { account =>
|
||||||
getAccountWebHook(userName, params("url")).map {
|
getAccountWebHook(userName, params("url")).map { case (webhook, events) =>
|
||||||
case (webhook, events) =>
|
|
||||||
html.edithook(webhook, events, account, false)
|
html.edithook(webhook, events, account, false)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
@@ -478,7 +533,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
post("/:userName/_hooks/edit", accountWebHookForm(true))(managersOnly { form =>
|
post("/:userName/_hooks/edit", accountWebHookForm(true))(managersOnly { form =>
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
updateAccountWebHook(userName, form.url, form.events, form.ctype, form.token)
|
updateAccountWebHook(userName, form.url, form.events, form.ctype, form.token)
|
||||||
flash += "info" -> s"webhook ${form.url} updated"
|
flash.update("info", s"webhook ${form.url} updated")
|
||||||
redirect(s"/${userName}/_hooks")
|
redirect(s"/${userName}/_hooks")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -501,19 +556,21 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
val url = params("url")
|
val url = params("url")
|
||||||
val token = Some(params("token"))
|
val token = Some(params("token"))
|
||||||
val ctype = WebHookContentType.valueOf(params("ctype"))
|
val ctype = WebHookContentType.valueOf(params("ctype"))
|
||||||
val dummyWebHookInfo = RepositoryWebHook(userName, "dummy", url, ctype, token)
|
val dummyWebHookInfo =
|
||||||
|
RepositoryWebHook(userName = userName, repositoryName = "dummy", url = url, ctype = ctype, token = token)
|
||||||
val dummyPayload = {
|
val dummyPayload = {
|
||||||
val ownerAccount = getAccountByUserName(userName).get
|
val ownerAccount = getAccountByUserName(userName).get
|
||||||
WebHookPushPayload.createDummyPayload(ownerAccount)
|
WebHookPushPayload.createDummyPayload(ownerAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
val (webHook, json, reqFuture, resFuture) = callWebHook(WebHook.Push, List(dummyWebHookInfo), dummyPayload).head
|
val (webHook, json, reqFuture, resFuture) =
|
||||||
|
callWebHook(WebHook.Push, List(dummyWebHookInfo), dummyPayload, context.settings).head
|
||||||
|
|
||||||
val toErrorMap: PartialFunction[Throwable, Map[String, String]] = {
|
val toErrorMap: PartialFunction[Throwable, Map[String, String]] = {
|
||||||
case e: java.net.UnknownHostException => Map("error" -> ("Unknown host " + e.getMessage))
|
case e: java.net.UnknownHostException => Map("error" -> ("Unknown host " + e.getMessage))
|
||||||
case e: java.lang.IllegalArgumentException => Map("error" -> ("invalid url"))
|
case e: java.lang.IllegalArgumentException => Map("error" -> ("invalid url"))
|
||||||
case e: org.apache.http.client.ClientProtocolException => Map("error" -> ("invalid url"))
|
case e: org.apache.http.client.ClientProtocolException => Map("error" -> ("invalid url"))
|
||||||
case NonFatal(e) => Map("error" -> (e.getClass + " " + e.getMessage))
|
case NonFatal(e) => Map("error" -> (s"${e.getClass} ${e.getMessage}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
@@ -522,8 +579,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"url" -> url,
|
"url" -> url,
|
||||||
"request" -> Await.result(
|
"request" -> Await.result(
|
||||||
reqFuture
|
reqFuture
|
||||||
.map(
|
.map(req =>
|
||||||
req =>
|
|
||||||
Map(
|
Map(
|
||||||
"headers" -> _headers(req.getAllHeaders),
|
"headers" -> _headers(req.getAllHeaders),
|
||||||
"payload" -> json
|
"payload" -> json
|
||||||
@@ -534,8 +590,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
),
|
),
|
||||||
"response" -> Await.result(
|
"response" -> Await.result(
|
||||||
resFuture
|
resFuture
|
||||||
.map(
|
.map(res =>
|
||||||
res =>
|
|
||||||
Map(
|
Map(
|
||||||
"status" -> res.getStatusLine(),
|
"status" -> res.getStatusLine(),
|
||||||
"body" -> EntityUtils.toString(res.getEntity()),
|
"body" -> EntityUtils.toString(res.getEntity()),
|
||||||
@@ -550,7 +605,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/register") {
|
get("/register") {
|
||||||
if (context.settings.allowAccountRegistration) {
|
if (context.settings.basicBehavior.allowAccountRegistration) {
|
||||||
if (context.loginAccount.isDefined) {
|
if (context.loginAccount.isDefined) {
|
||||||
redirect("/")
|
redirect("/")
|
||||||
} else {
|
} else {
|
||||||
@@ -560,7 +615,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
post("/register", newForm) { form =>
|
post("/register", newForm) { form =>
|
||||||
if (context.settings.allowAccountRegistration) {
|
if (context.settings.basicBehavior.allowAccountRegistration) {
|
||||||
createAccount(
|
createAccount(
|
||||||
form.userName,
|
form.userName,
|
||||||
pbkdf2_sha256(form.password),
|
pbkdf2_sha256(form.password),
|
||||||
@@ -576,8 +631,67 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
} else NotFound()
|
} else NotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get("/reset") {
|
||||||
|
if (context.settings.basicBehavior.allowResetPassword) {
|
||||||
|
html.reset()
|
||||||
|
} else NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
post("/reset", resetPasswordEmailForm) { form =>
|
||||||
|
if (context.settings.basicBehavior.allowResetPassword) {
|
||||||
|
getAccountByMailAddress(form.mailAddress).foreach { account =>
|
||||||
|
val token = generateResetPasswordToken(form.mailAddress)
|
||||||
|
val mailer = new Mailer(context.settings)
|
||||||
|
mailer.send(
|
||||||
|
form.mailAddress,
|
||||||
|
"Reset password",
|
||||||
|
s"""Hello, ${account.fullName}!
|
||||||
|
|
|
||||||
|
|You requested to reset the password for your GitBucket account.
|
||||||
|
|If you are not sure about the request, you can ignore this email.
|
||||||
|
|Otherwise, click the following link to set the new password:
|
||||||
|
|${context.baseUrl}/reset/form/${token}
|
||||||
|
|""".stripMargin
|
||||||
|
)
|
||||||
|
}
|
||||||
|
redirect("/reset/sent")
|
||||||
|
} else NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
get("/reset/sent") {
|
||||||
|
if (context.settings.basicBehavior.allowResetPassword) {
|
||||||
|
html.resetsent()
|
||||||
|
} else NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
get("/reset/form/:token") {
|
||||||
|
if (context.settings.basicBehavior.allowResetPassword) {
|
||||||
|
val token = params("token")
|
||||||
|
decodeResetPasswordToken(token)
|
||||||
|
.map { _ =>
|
||||||
|
html.resetform(token)
|
||||||
|
}
|
||||||
|
.getOrElse(NotFound())
|
||||||
|
} else NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
post("/reset/form", resetPasswordForm) { form =>
|
||||||
|
if (context.settings.basicBehavior.allowResetPassword) {
|
||||||
|
decodeResetPasswordToken(form.token)
|
||||||
|
.flatMap { mailAddress =>
|
||||||
|
getAccountByMailAddress(mailAddress).map { account =>
|
||||||
|
updateAccount(account.copy(password = pbkdf2_sha256(form.password)))
|
||||||
|
html.resetcomplete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.getOrElse(NotFound())
|
||||||
|
} else NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
get("/groups/new")(usersOnly {
|
get("/groups/new")(usersOnly {
|
||||||
html.creategroup(List(GroupMember("", context.loginAccount.get.userName, true)))
|
context.withLoginAccount { loginAccount =>
|
||||||
|
html.creategroup(List(GroupMember("", loginAccount.userName, true)))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/groups/new", newGroupForm)(usersOnly { form =>
|
post("/groups/new", newGroupForm)(usersOnly { form =>
|
||||||
@@ -598,16 +712,14 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:groupName/_editgroup")(managersOnly {
|
get("/:groupName/_editgroup")(managersOnly {
|
||||||
defining(params("groupName")) { groupName =>
|
val groupName = params("groupName")
|
||||||
getAccountByUserName(groupName, true).map { account =>
|
getAccountByUserName(groupName, true).map { account =>
|
||||||
html.editgroup(account, getGroupMembers(groupName), flash.get("info"))
|
html.editgroup(account, getGroupMembers(groupName), flash.get("info"))
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:groupName/_deletegroup")(managersOnly {
|
get("/:groupName/_deletegroup")(managersOnly {
|
||||||
defining(params("groupName")) {
|
val groupName = params("groupName")
|
||||||
groupName =>
|
|
||||||
// Remove from GROUP_MEMBER
|
// Remove from GROUP_MEMBER
|
||||||
updateGroupMembers(groupName, Nil)
|
updateGroupMembers(groupName, Nil)
|
||||||
// Disable group
|
// Disable group
|
||||||
@@ -621,14 +733,12 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
// FileUtils.deleteDirectory(getWikiRepositoryDir(groupName, repositoryName))
|
// FileUtils.deleteDirectory(getWikiRepositoryDir(groupName, repositoryName))
|
||||||
// FileUtils.deleteDirectory(getTemporaryDir(groupName, repositoryName))
|
// FileUtils.deleteDirectory(getTemporaryDir(groupName, repositoryName))
|
||||||
// }
|
// }
|
||||||
}
|
|
||||||
redirect("/")
|
redirect("/")
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:groupName/_editgroup", editGroupForm)(managersOnly { form =>
|
post("/:groupName/_editgroup", editGroupForm)(managersOnly { form =>
|
||||||
defining(
|
val groupName = params("groupName")
|
||||||
params("groupName"),
|
val members = form.members
|
||||||
form.members
|
|
||||||
.split(",")
|
.split(",")
|
||||||
.map {
|
.map {
|
||||||
_.split(":") match {
|
_.split(":") match {
|
||||||
@@ -636,8 +746,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.toList
|
.toList
|
||||||
) {
|
|
||||||
case (groupName, members) =>
|
|
||||||
getAccountByUserName(groupName, true).map { account =>
|
getAccountByUserName(groupName, true).map { account =>
|
||||||
updateGroup(groupName, form.description, form.url, false)
|
updateGroup(groupName, form.description, form.url, false)
|
||||||
|
|
||||||
@@ -653,53 +762,66 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
updateImage(form.groupName, form.fileId, form.clearImage)
|
updateImage(form.groupName, form.fileId, form.clearImage)
|
||||||
|
|
||||||
flash += "info" -> "Account information has been updated."
|
flash.update("info", "Account information has been updated.")
|
||||||
redirect(s"/${groupName}/_editgroup")
|
redirect(s"/${groupName}/_editgroup")
|
||||||
|
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the new repository form.
|
* Show the new repository form.
|
||||||
*/
|
*/
|
||||||
get("/new")(usersOnly {
|
get("/new")(usersOnly {
|
||||||
html.newrepo(getGroupsByUserName(context.loginAccount.get.userName), context.settings.isCreateRepoOptionPublic)
|
context.withLoginAccount { loginAccount =>
|
||||||
|
html.newrepo(getGroupsByUserName(loginAccount.userName), context.settings.basicBehavior.isCreateRepoOptionPublic)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new repository.
|
* Create new repository.
|
||||||
*/
|
*/
|
||||||
post("/new", newRepositoryForm)(usersOnly { form =>
|
post("/new", newRepositoryForm)(usersOnly { form =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
|
if (context.settings.basicBehavior.repositoryOperation.create || loginAccount.isAdmin) {
|
||||||
LockUtil.lock(s"${form.owner}/${form.name}") {
|
LockUtil.lock(s"${form.owner}/${form.name}") {
|
||||||
if (getRepository(form.owner, form.name).isEmpty) {
|
if (getRepository(form.owner, form.name).isDefined) {
|
||||||
|
// redirect to the repository if repository already exists
|
||||||
|
redirect(s"/${form.owner}/${form.name}")
|
||||||
|
} else if (!canCreateRepository(form.owner, loginAccount)) {
|
||||||
|
// Permission error
|
||||||
|
Forbidden()
|
||||||
|
} else {
|
||||||
|
// create repository asynchronously
|
||||||
createRepository(
|
createRepository(
|
||||||
context.loginAccount.get,
|
loginAccount,
|
||||||
form.owner,
|
form.owner,
|
||||||
form.name,
|
form.name,
|
||||||
form.description,
|
form.description,
|
||||||
form.isPrivate,
|
form.isPrivate,
|
||||||
form.initOption,
|
form.initOption,
|
||||||
form.sourceUrl
|
form.sourceUrl,
|
||||||
|
context.settings.defaultBranch
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// redirect to the repository
|
// redirect to the repository
|
||||||
redirect(s"/${form.owner}/${form.name}")
|
redirect(s"/${form.owner}/${form.name}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else Forbidden()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/fork")(readableUsersOnly { repository =>
|
get("/:owner/:repository/fork")(readableUsersOnly { repository =>
|
||||||
if (repository.repository.options.allowFork) {
|
context.withLoginAccount { loginAccount =>
|
||||||
val loginAccount = context.loginAccount.get
|
if (
|
||||||
|
repository.repository.options.allowFork && (context.settings.basicBehavior.repositoryOperation.fork || loginAccount.isAdmin)
|
||||||
|
) {
|
||||||
val loginUserName = loginAccount.userName
|
val loginUserName = loginAccount.userName
|
||||||
val groups = getGroupsByUserName(loginUserName)
|
val groups = getGroupsByUserName(loginUserName)
|
||||||
groups match {
|
groups match {
|
||||||
case _: List[String] =>
|
case _: List[String] =>
|
||||||
val managerPermissions = groups.map { group =>
|
val managerPermissions = groups.map { group =>
|
||||||
val members = getGroupMembers(group)
|
val members = getGroupMembers(group)
|
||||||
context.loginAccount.exists(
|
context.loginAccount.exists(x =>
|
||||||
x =>
|
|
||||||
members.exists { member =>
|
members.exists { member =>
|
||||||
member.userName == x.userName && member.isManager
|
member.userName == x.userName && member.isManager
|
||||||
}
|
}
|
||||||
@@ -712,25 +834,31 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
case _ => redirect(s"/${loginUserName}")
|
case _ => redirect(s"/${loginUserName}")
|
||||||
}
|
}
|
||||||
} else BadRequest()
|
} else BadRequest()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/fork", accountForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/fork", accountForm)(readableUsersOnly { (form, repository) =>
|
||||||
if (repository.repository.options.allowFork) {
|
context.withLoginAccount { loginAccount =>
|
||||||
val loginAccount = context.loginAccount.get
|
if (
|
||||||
|
repository.repository.options.allowFork && (context.settings.basicBehavior.repositoryOperation.fork || loginAccount.isAdmin)
|
||||||
|
) {
|
||||||
val loginUserName = loginAccount.userName
|
val loginUserName = loginAccount.userName
|
||||||
val accountName = form.accountName
|
val accountName = form.accountName
|
||||||
|
|
||||||
if (getRepository(accountName, repository.name).isDefined ||
|
if (getRepository(accountName, repository.name).isDefined) {
|
||||||
(accountName != loginUserName && !getGroupsByUserName(loginUserName).contains(accountName))) {
|
|
||||||
// redirect to the repository if repository already exists
|
// redirect to the repository if repository already exists
|
||||||
redirect(s"/${accountName}/${repository.name}")
|
redirect(s"/${accountName}/${repository.name}")
|
||||||
|
} else if (!canCreateRepository(accountName, loginAccount)) {
|
||||||
|
// Permission error
|
||||||
|
Forbidden()
|
||||||
} else {
|
} else {
|
||||||
// fork repository asynchronously
|
// fork repository asynchronously
|
||||||
forkRepository(accountName, repository, loginUserName)
|
forkRepository(accountName, repository, loginUserName)
|
||||||
// redirect to the repository
|
// redirect to the repository
|
||||||
redirect(s"/${accountName}/${repository.name}")
|
redirect(s"/${accountName}/${repository.name}")
|
||||||
}
|
}
|
||||||
} else BadRequest()
|
} else Forbidden()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
private def existsAccount: Constraint = new Constraint() {
|
private def existsAccount: Constraint = new Constraint() {
|
||||||
@@ -756,9 +884,11 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
private def members: Constraint = new Constraint() {
|
private def members: Constraint = new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
||||||
if (value.split(",").exists {
|
if (
|
||||||
|
value.split(",").exists {
|
||||||
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
|
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
|
||||||
}) None
|
}
|
||||||
|
) None
|
||||||
else Some("Must select one manager at least.")
|
else Some("Must select one manager at least.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -771,6 +901,20 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def validGpgPublicKey: Constraint = new Constraint() {
|
||||||
|
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
||||||
|
GpgUtil.str2GpgKeyId(value) match {
|
||||||
|
case Some(s) if GpgUtil.getGpgKey(s).isEmpty =>
|
||||||
|
None
|
||||||
|
case Some(_) =>
|
||||||
|
Some("GPG key is duplicated.")
|
||||||
|
case None =>
|
||||||
|
Some("GPG key is invalid.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private def validAccountName: Constraint = new Constraint() {
|
private def validAccountName: Constraint = new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
||||||
getAccountByUserName(value) match {
|
getAccountByUserName(value) match {
|
||||||
@@ -779,4 +923,13 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def isGroupManager(account: Option[Account], members: Seq[GroupMember]): Boolean = {
|
||||||
|
account.exists { account =>
|
||||||
|
account.isAdmin || members.exists { member =>
|
||||||
|
member.userName == account.userName && member.isManager
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,17 @@ class ApiController
|
|||||||
with ApiIssueCommentControllerBase
|
with ApiIssueCommentControllerBase
|
||||||
with ApiIssueControllerBase
|
with ApiIssueControllerBase
|
||||||
with ApiIssueLabelControllerBase
|
with ApiIssueLabelControllerBase
|
||||||
|
with ApiIssueMilestoneControllerBase
|
||||||
with ApiOrganizationControllerBase
|
with ApiOrganizationControllerBase
|
||||||
with ApiPullRequestControllerBase
|
with ApiPullRequestControllerBase
|
||||||
|
with ApiReleaseControllerBase
|
||||||
with ApiRepositoryBranchControllerBase
|
with ApiRepositoryBranchControllerBase
|
||||||
with ApiRepositoryCollaboratorControllerBase
|
with ApiRepositoryCollaboratorControllerBase
|
||||||
with ApiRepositoryCommitControllerBase
|
with ApiRepositoryCommitControllerBase
|
||||||
|
with ApiRepositoryContentsControllerBase
|
||||||
with ApiRepositoryControllerBase
|
with ApiRepositoryControllerBase
|
||||||
with ApiRepositoryStatusControllerBase
|
with ApiRepositoryStatusControllerBase
|
||||||
|
with ApiRepositoryWebhookControllerBase
|
||||||
with ApiUserControllerBase
|
with ApiUserControllerBase
|
||||||
with RepositoryService
|
with RepositoryService
|
||||||
with AccountService
|
with AccountService
|
||||||
@@ -30,7 +34,9 @@ class ApiController
|
|||||||
with PullRequestService
|
with PullRequestService
|
||||||
with CommitsService
|
with CommitsService
|
||||||
with CommitStatusService
|
with CommitStatusService
|
||||||
|
with ReleaseService
|
||||||
with RepositoryCreationService
|
with RepositoryCreationService
|
||||||
|
with RepositoryCommitFileService
|
||||||
with IssueCreationService
|
with IssueCreationService
|
||||||
with HandleCommentService
|
with HandleCommentService
|
||||||
with MergeService
|
with MergeService
|
||||||
@@ -48,6 +54,7 @@ class ApiController
|
|||||||
with ReferrerAuthenticator
|
with ReferrerAuthenticator
|
||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with WritableUsersAuthenticator
|
with WritableUsersAuthenticator
|
||||||
|
with RequestCache
|
||||||
|
|
||||||
trait ApiControllerBase extends ControllerBase {
|
trait ApiControllerBase extends ControllerBase {
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import java.io.{File, FileInputStream}
|
import java.io.{File, FileInputStream, FileOutputStream}
|
||||||
|
|
||||||
import gitbucket.core.api.{ApiError, JsonFormat}
|
import gitbucket.core.api.{ApiError, JsonFormat}
|
||||||
import gitbucket.core.model.Account
|
import gitbucket.core.model.Account
|
||||||
import gitbucket.core.service.{AccountService, RepositoryService, SystemSettingsService}
|
import gitbucket.core.service.{AccountService, RepositoryService, SystemSettingsService}
|
||||||
@@ -14,12 +13,13 @@ import org.scalatra._
|
|||||||
import org.scalatra.i18n._
|
import org.scalatra.i18n._
|
||||||
import org.scalatra.json._
|
import org.scalatra.json._
|
||||||
import org.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
|
|
||||||
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
||||||
import javax.servlet.{FilterChain, ServletRequest, ServletResponse}
|
import javax.servlet.{FilterChain, ServletRequest, ServletResponse}
|
||||||
|
|
||||||
import is.tagomor.woothee.Classifier
|
import is.tagomor.woothee.Classifier
|
||||||
|
|
||||||
import scala.util.Try
|
import scala.util.Try
|
||||||
|
import scala.util.Using
|
||||||
import net.coobird.thumbnailator.Thumbnails
|
import net.coobird.thumbnailator.Thumbnails
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.lib.ObjectId
|
import org.eclipse.jgit.lib.ObjectId
|
||||||
@@ -27,6 +27,10 @@ import org.eclipse.jgit.revwalk.RevCommit
|
|||||||
import org.eclipse.jgit.treewalk._
|
import org.eclipse.jgit.treewalk._
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
import org.json4s.Formats
|
||||||
|
import org.json4s.jackson.Serialization
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides generic features for controller implementations.
|
* Provides generic features for controller implementations.
|
||||||
@@ -42,7 +46,7 @@ abstract class ControllerBase
|
|||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(getClass)
|
private val logger = LoggerFactory.getLogger(getClass)
|
||||||
|
|
||||||
implicit val jsonFormats = gitbucket.core.api.JsonFormat.jsonFormats
|
implicit val jsonFormats: Formats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||||
|
|
||||||
before("/api/v3/*") {
|
before("/api/v3/*") {
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
@@ -91,8 +95,16 @@ abstract class ControllerBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def LoginAccount: Option[Account] =
|
private def LoginAccount: Option[Account] = {
|
||||||
request.getAs[Account](Keys.Session.LoginAccount).orElse(session.getAs[Account](Keys.Session.LoginAccount))
|
request
|
||||||
|
.getAs[Account](Keys.Session.LoginAccount)
|
||||||
|
.orElse(session.getAs[Account](Keys.Session.LoginAccount))
|
||||||
|
.orElse {
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
getLoginAccountFromLocalFile()
|
||||||
|
} else None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def ajaxGet(path: String)(action: => Any): Route =
|
def ajaxGet(path: String)(action: => Any): Route =
|
||||||
super.get(path) {
|
super.get(path) {
|
||||||
@@ -156,11 +168,8 @@ abstract class ControllerBase
|
|||||||
org.scalatra.Unauthorized(
|
org.scalatra.Unauthorized(
|
||||||
redirect(
|
redirect(
|
||||||
"/signin?redirect=" + StringUtil.urlEncode(
|
"/signin?redirect=" + StringUtil.urlEncode(
|
||||||
defining(request.getQueryString) { queryString =>
|
request.getRequestURI
|
||||||
request.getRequestURI.substring(request.getContextPath.length) + (if (queryString != null)
|
.substring(request.getContextPath.length) + Option(request.getQueryString).map("?" + _).getOrElse("")
|
||||||
"?" + queryString
|
|
||||||
else "")
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -240,7 +249,7 @@ abstract class ControllerBase
|
|||||||
case false => None
|
case false => None
|
||||||
}
|
}
|
||||||
|
|
||||||
using(new TreeWalk(git.getRepository)) { treeWalk =>
|
Using.resource(new TreeWalk(git.getRepository)) { treeWalk =>
|
||||||
treeWalk.addTree(revCommit.getTree)
|
treeWalk.addTree(revCommit.getTree)
|
||||||
treeWalk.setRecursive(true)
|
treeWalk.setRecursive(true)
|
||||||
_getPathObjectId(path, treeWalk)
|
_getPathObjectId(path, treeWalk)
|
||||||
@@ -254,7 +263,7 @@ abstract class ControllerBase
|
|||||||
repository: RepositoryService.RepositoryInfo
|
repository: RepositoryService.RepositoryInfo
|
||||||
): Unit = {
|
): Unit = {
|
||||||
JGitUtil.getObjectLoaderFromId(git, objectId) { loader =>
|
JGitUtil.getObjectLoaderFromId(git, objectId) { loader =>
|
||||||
contentType = FileUtil.getSafeMimeType(path)
|
contentType = FileUtil.getSafeMimeType(path, repository.repository.options.safeMode)
|
||||||
|
|
||||||
if (loader.isLarge) {
|
if (loader.isLarge) {
|
||||||
response.setContentLength(loader.getSize.toInt)
|
response.setContentLength(loader.getSize.toInt)
|
||||||
@@ -268,7 +277,7 @@ abstract class ControllerBase
|
|||||||
response.setContentLength(attrs("size").toInt)
|
response.setContentLength(attrs("size").toInt)
|
||||||
val oid = attrs("oid").split(":")(1)
|
val oid = attrs("oid").split(":")(1)
|
||||||
|
|
||||||
using(new FileInputStream(FileUtil.getLfsFilePath(repository.owner, repository.name, oid))) { in =>
|
Using.resource(new FileInputStream(FileUtil.getLfsFilePath(repository.owner, repository.name, oid))) { in =>
|
||||||
IOUtils.copy(in, response.getOutputStream)
|
IOUtils.copy(in, response.getOutputStream)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -278,6 +287,47 @@ abstract class ControllerBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected object DevFeatures {
|
||||||
|
val KeepSession = "keep-session"
|
||||||
|
}
|
||||||
|
|
||||||
|
private val loginAccountFile = new File(".tmp/login_account.json")
|
||||||
|
|
||||||
|
protected def isDevFeatureEnabled(feature: String): Boolean = {
|
||||||
|
Option(System.getProperty("dev-features")).getOrElse("").split(",").map(_.trim).contains(feature)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected def getLoginAccountFromLocalFile(): Option[Account] = {
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
if (loginAccountFile.exists()) {
|
||||||
|
Using.resource(new FileInputStream(loginAccountFile)) { in =>
|
||||||
|
val json = IOUtils.toString(in, StandardCharsets.UTF_8)
|
||||||
|
val account = parse(json).extract[Account]
|
||||||
|
session.setAttribute(Keys.Session.LoginAccount, account)
|
||||||
|
Some(parse(json).extract[Account])
|
||||||
|
}
|
||||||
|
} else None
|
||||||
|
|
||||||
|
} else None
|
||||||
|
}
|
||||||
|
|
||||||
|
protected def saveLoginAccountToLocalFile(account: Account): Unit = {
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
if (!loginAccountFile.getParentFile.exists()) {
|
||||||
|
loginAccountFile.getParentFile.mkdirs()
|
||||||
|
}
|
||||||
|
Using.resource(new FileOutputStream(loginAccountFile)) { in =>
|
||||||
|
in.write(Serialization.write(account).getBytes(StandardCharsets.UTF_8))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected def deleteLoginAccountFromLocalFile(): Unit = {
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
loginAccountFile.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -301,14 +351,21 @@ case class Context(
|
|||||||
}
|
}
|
||||||
val sidebarCollapse = request.getSession.getAttribute("sidebar-collapse") != null
|
val sidebarCollapse = request.getSession.getAttribute("sidebar-collapse") != null
|
||||||
|
|
||||||
|
def withLoginAccount(f: Account => Any): Any = {
|
||||||
|
loginAccount match {
|
||||||
|
case Some(loginAccount) => f(loginAccount)
|
||||||
|
case None => Unauthorized()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get object from cache.
|
* Get object from cache.
|
||||||
*
|
*
|
||||||
* If object has not been cached with the specified key then retrieves by given action.
|
* If object has not been cached with the specified key then retrieves by given action.
|
||||||
* Cached object are available during a request.
|
* Cached object are available during a request.
|
||||||
*/
|
*/
|
||||||
def cache[A](key: String)(action: => A): A =
|
def cache[A](key: String)(action: => A): A = {
|
||||||
defining(Keys.Request.Cache(key)) { cacheKey =>
|
val cacheKey = Keys.Request.Cache(key)
|
||||||
Option(request.getAttribute(cacheKey).asInstanceOf[A]).getOrElse {
|
Option(request.getAttribute(cacheKey).asInstanceOf[A]).getOrElse {
|
||||||
val newObject = action
|
val newObject = action
|
||||||
request.setAttribute(cacheKey, newObject)
|
request.setAttribute(cacheKey, newObject)
|
||||||
@@ -324,6 +381,8 @@ case class Context(
|
|||||||
trait AccountManagementControllerBase extends ControllerBase {
|
trait AccountManagementControllerBase extends ControllerBase {
|
||||||
self: AccountService =>
|
self: AccountService =>
|
||||||
|
|
||||||
|
private val logger = LoggerFactory.getLogger(getClass)
|
||||||
|
|
||||||
protected def updateImage(userName: String, fileId: Option[String], clearImage: Boolean): Unit =
|
protected def updateImage(userName: String, fileId: Option[String], clearImage: Boolean): Unit =
|
||||||
if (clearImage) {
|
if (clearImage) {
|
||||||
getAccountByUserName(userName).flatMap(_.image).foreach { image =>
|
getAccountByUserName(userName).flatMap(_.image).foreach { image =>
|
||||||
@@ -331,6 +390,7 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
updateAvatarImage(userName, None)
|
updateAvatarImage(userName, None)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
fileId.foreach { fileId =>
|
fileId.foreach { fileId =>
|
||||||
val filename = "avatar." + FileUtil.getExtension(session.getAndRemove(Keys.Session.Upload(fileId)).get)
|
val filename = "avatar." + FileUtil.getExtension(session.getAndRemove(Keys.Session.Upload(fileId)).get)
|
||||||
val uploadDir = getUserUploadDir(userName)
|
val uploadDir = getUserUploadDir(userName)
|
||||||
@@ -343,6 +403,9 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
.toFile(new File(uploadDir, FileUtil.checkFilename(filename)))
|
.toFile(new File(uploadDir, FileUtil.checkFilename(filename)))
|
||||||
updateAvatarImage(userName, Some(filename))
|
updateAvatarImage(userName, Some(filename))
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
case e: Exception => logger.info("Error while updateImage" + e.getMessage)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected def uniqueUserName: Constraint = new Constraint() {
|
protected def uniqueUserName: Constraint = new Constraint() {
|
||||||
@@ -359,11 +422,12 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
params: Map[String, Seq[String]],
|
params: Map[String, Seq[String]],
|
||||||
messages: Messages
|
messages: Messages
|
||||||
): Option[String] = {
|
): Option[String] = {
|
||||||
val extraMailAddresses = params.filterKeys(k => k.startsWith("extraMailAddresses"))
|
val extraMailAddresses = params.view.filterKeys(k => k.startsWith("extraMailAddresses"))
|
||||||
if (extraMailAddresses.exists {
|
if (
|
||||||
case (k, v) =>
|
extraMailAddresses.exists { case (k, v) =>
|
||||||
v.contains(value)
|
v.contains(value)
|
||||||
}) {
|
}
|
||||||
|
) {
|
||||||
Some("These mail addresses are duplicated.")
|
Some("These mail addresses are duplicated.")
|
||||||
} else {
|
} else {
|
||||||
getAccountByMailAddress(value, true)
|
getAccountByMailAddress(value, true)
|
||||||
@@ -382,11 +446,12 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
params: Map[String, Seq[String]],
|
params: Map[String, Seq[String]],
|
||||||
messages: Messages
|
messages: Messages
|
||||||
): Option[String] = {
|
): Option[String] = {
|
||||||
val extraMailAddresses = params.filterKeys(k => k.startsWith("extraMailAddresses"))
|
val extraMailAddresses = params.view.filterKeys(k => k.startsWith("extraMailAddresses"))
|
||||||
if (Some(value) == params.optionValue("mailAddress") || extraMailAddresses.count {
|
if (
|
||||||
case (k, v) =>
|
Some(value) == params.optionValue("mailAddress") || extraMailAddresses.count { case (k, v) =>
|
||||||
v.contains(value)
|
v.contains(value)
|
||||||
} > 1) {
|
} > 1
|
||||||
|
) {
|
||||||
Some("These mail addresses are duplicated.")
|
Some("These mail addresses are duplicated.")
|
||||||
} else {
|
} else {
|
||||||
getAccountByMailAddress(value, true)
|
getAccountByMailAddress(value, true)
|
||||||
@@ -414,7 +479,7 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
"new"
|
"new"
|
||||||
)
|
)
|
||||||
|
|
||||||
protected def reservedNames(): Constraint = new Constraint() {
|
protected def reservedNames: Constraint = new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
||||||
if (allReservedNames.contains(value.toLowerCase)) {
|
if (allReservedNames.contains(value.toLowerCase)) {
|
||||||
Some(s"${value} is reserved")
|
Some(s"${value} is reserved")
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.dashboard.html
|
import gitbucket.core.dashboard.html
|
||||||
|
import gitbucket.core.model.Account
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.{Keys, UsersAuthenticator}
|
import gitbucket.core.util.{Keys, UsersAuthenticator}
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.service.IssuesService._
|
import gitbucket.core.service.IssuesService._
|
||||||
|
import gitbucket.core.service.ActivityService._
|
||||||
|
|
||||||
class DashboardController
|
class DashboardController
|
||||||
extends DashboardControllerBase
|
extends DashboardControllerBase
|
||||||
with IssuesService
|
with IssuesService
|
||||||
|
with MergeService
|
||||||
with PullRequestService
|
with PullRequestService
|
||||||
with RepositoryService
|
with RepositoryService
|
||||||
with AccountService
|
with AccountService
|
||||||
@@ -20,46 +23,76 @@ class DashboardController
|
|||||||
with WebHookPullRequestService
|
with WebHookPullRequestService
|
||||||
with WebHookPullRequestReviewCommentService
|
with WebHookPullRequestReviewCommentService
|
||||||
with MilestonesService
|
with MilestonesService
|
||||||
|
with CommitStatusService
|
||||||
with UsersAuthenticator
|
with UsersAuthenticator
|
||||||
|
with RequestCache
|
||||||
|
|
||||||
trait DashboardControllerBase extends ControllerBase {
|
trait DashboardControllerBase extends ControllerBase {
|
||||||
self: IssuesService with PullRequestService with RepositoryService with AccountService with UsersAuthenticator =>
|
self: IssuesService
|
||||||
|
with PullRequestService
|
||||||
|
with RepositoryService
|
||||||
|
with AccountService
|
||||||
|
with CommitStatusService
|
||||||
|
with UsersAuthenticator =>
|
||||||
|
|
||||||
get("/dashboard/repos")(usersOnly {
|
get("/dashboard/repos")(usersOnly {
|
||||||
val repos = getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true)
|
context.withLoginAccount { loginAccount =>
|
||||||
html.repos(getGroupNames(context.loginAccount.get.userName), repos, repos)
|
val repos = getVisibleRepositories(
|
||||||
|
context.loginAccount,
|
||||||
|
None,
|
||||||
|
withoutPhysicalInfo = true,
|
||||||
|
limit = context.settings.basicBehavior.limitVisibleRepositories
|
||||||
|
)
|
||||||
|
html.repos(getGroupNames(loginAccount.userName), repos, repos, isNewsFeedEnabled)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/issues")(usersOnly {
|
get("/dashboard/issues")(usersOnly {
|
||||||
searchIssues("created_by")
|
context.withLoginAccount { loginAccount =>
|
||||||
|
searchIssues(loginAccount, "created_by")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/issues/assigned")(usersOnly {
|
get("/dashboard/issues/assigned")(usersOnly {
|
||||||
searchIssues("assigned")
|
context.withLoginAccount { loginAccount =>
|
||||||
|
searchIssues(loginAccount, "assigned")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/issues/created_by")(usersOnly {
|
get("/dashboard/issues/created_by")(usersOnly {
|
||||||
searchIssues("created_by")
|
context.withLoginAccount { loginAccount =>
|
||||||
|
searchIssues(loginAccount, "created_by")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/issues/mentioned")(usersOnly {
|
get("/dashboard/issues/mentioned")(usersOnly {
|
||||||
searchIssues("mentioned")
|
context.withLoginAccount { loginAccount =>
|
||||||
|
searchIssues(loginAccount, "mentioned")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/pulls")(usersOnly {
|
get("/dashboard/pulls")(usersOnly {
|
||||||
searchPullRequests("created_by")
|
context.withLoginAccount { loginAccount =>
|
||||||
|
searchPullRequests(loginAccount, "created_by")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/pulls/created_by")(usersOnly {
|
get("/dashboard/pulls/created_by")(usersOnly {
|
||||||
searchPullRequests("created_by")
|
context.withLoginAccount { loginAccount =>
|
||||||
|
searchPullRequests(loginAccount, "created_by")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/pulls/assigned")(usersOnly {
|
get("/dashboard/pulls/assigned")(usersOnly {
|
||||||
searchPullRequests("assigned")
|
context.withLoginAccount { loginAccount =>
|
||||||
|
searchPullRequests(loginAccount, "assigned")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/pulls/mentioned")(usersOnly {
|
get("/dashboard/pulls/mentioned")(usersOnly {
|
||||||
searchPullRequests("mentioned")
|
context.withLoginAccount { loginAccount =>
|
||||||
|
searchPullRequests(loginAccount, "mentioned")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
private def getOrCreateCondition(key: String, filter: String, userName: String) = {
|
private def getOrCreateCondition(key: String, filter: String, userName: String) = {
|
||||||
@@ -72,19 +105,20 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def searchIssues(filter: String) = {
|
private def searchIssues(loginAccount: Account, filter: String) = {
|
||||||
import IssuesService._
|
import IssuesService._
|
||||||
|
|
||||||
val userName = context.loginAccount.get.userName
|
val userName = loginAccount.userName
|
||||||
val condition = getOrCreateCondition(Keys.Session.DashboardIssues, filter, userName)
|
val condition = getOrCreateCondition(Keys.Session.DashboardIssues, filter, userName)
|
||||||
val userRepos = getUserRepositories(userName, true).map(repo => repo.owner -> repo.name)
|
val userRepos = getUserRepositories(userName, true).map(repo => repo.owner -> repo.name)
|
||||||
val page = IssueSearchCondition.page(request)
|
val page = IssueSearchCondition.page(request)
|
||||||
|
val issues = searchIssue(condition, IssueSearchOption.Issues, (page - 1) * IssueLimit, IssueLimit, userRepos*)
|
||||||
|
|
||||||
html.issues(
|
html.issues(
|
||||||
searchIssue(condition, false, (page - 1) * IssueLimit, IssueLimit, userRepos: _*),
|
issues.map(issue => (issue, None)),
|
||||||
page,
|
page,
|
||||||
countIssue(condition.copy(state = "open"), false, userRepos: _*),
|
countIssue(condition.copy(state = "open"), IssueSearchOption.Issues, userRepos*),
|
||||||
countIssue(condition.copy(state = "closed"), false, userRepos: _*),
|
countIssue(condition.copy(state = "closed"), IssueSearchOption.Issues, userRepos*),
|
||||||
filter match {
|
filter match {
|
||||||
case "assigned" => condition.copy(assigned = Some(Some(userName)))
|
case "assigned" => condition.copy(assigned = Some(Some(userName)))
|
||||||
case "mentioned" => condition.copy(mentioned = Some(userName))
|
case "mentioned" => condition.copy(mentioned = Some(userName))
|
||||||
@@ -92,24 +126,42 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
},
|
},
|
||||||
filter,
|
filter,
|
||||||
getGroupNames(userName),
|
getGroupNames(userName),
|
||||||
getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true)
|
getVisibleRepositories(
|
||||||
|
context.loginAccount,
|
||||||
|
None,
|
||||||
|
withoutPhysicalInfo = true,
|
||||||
|
limit = context.settings.basicBehavior.limitVisibleRepositories
|
||||||
|
),
|
||||||
|
isNewsFeedEnabled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def searchPullRequests(filter: String) = {
|
private def searchPullRequests(loginAccount: Account, filter: String) = {
|
||||||
import IssuesService._
|
import IssuesService._
|
||||||
import PullRequestService._
|
import PullRequestService._
|
||||||
|
|
||||||
val userName = context.loginAccount.get.userName
|
val userName = loginAccount.userName
|
||||||
val condition = getOrCreateCondition(Keys.Session.DashboardPulls, filter, userName)
|
val condition = getOrCreateCondition(Keys.Session.DashboardPulls, filter, userName)
|
||||||
val allRepos = getAllRepositories(userName)
|
val allRepos = getAllRepositories(userName)
|
||||||
val page = IssueSearchCondition.page(request)
|
val page = IssueSearchCondition.page(request)
|
||||||
|
val issues = searchIssue(
|
||||||
|
condition,
|
||||||
|
IssueSearchOption.PullRequests,
|
||||||
|
(page - 1) * PullRequestLimit,
|
||||||
|
PullRequestLimit,
|
||||||
|
allRepos*
|
||||||
|
)
|
||||||
|
val status = issues.map { issue =>
|
||||||
|
issue.commitId.flatMap { commitId =>
|
||||||
|
getCommitStatusWithSummary(issue.issue.userName, issue.issue.repositoryName, commitId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
html.pulls(
|
html.pulls(
|
||||||
searchIssue(condition, true, (page - 1) * PullRequestLimit, PullRequestLimit, allRepos: _*),
|
issues.zip(status),
|
||||||
page,
|
page,
|
||||||
countIssue(condition.copy(state = "open"), true, allRepos: _*),
|
countIssue(condition.copy(state = "open"), IssueSearchOption.PullRequests, allRepos*),
|
||||||
countIssue(condition.copy(state = "closed"), true, allRepos: _*),
|
countIssue(condition.copy(state = "closed"), IssueSearchOption.PullRequests, allRepos*),
|
||||||
filter match {
|
filter match {
|
||||||
case "assigned" => condition.copy(assigned = Some(Some(userName)))
|
case "assigned" => condition.copy(assigned = Some(Some(userName)))
|
||||||
case "mentioned" => condition.copy(mentioned = Some(userName))
|
case "mentioned" => condition.copy(mentioned = Some(userName))
|
||||||
@@ -117,7 +169,13 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
},
|
},
|
||||||
filter,
|
filter,
|
||||||
getGroupNames(userName),
|
getGroupNames(userName),
|
||||||
getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true)
|
getVisibleRepositories(
|
||||||
|
context.loginAccount,
|
||||||
|
None,
|
||||||
|
withoutPhysicalInfo = true,
|
||||||
|
limit = context.settings.basicBehavior.limitVisibleRepositories
|
||||||
|
),
|
||||||
|
isNewsFeedEnabled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import gitbucket.core.model.Account
|
|||||||
import gitbucket.core.service.{AccountService, ReleaseService, RepositoryService}
|
import gitbucket.core.service.{AccountService, ReleaseService, RepositoryService}
|
||||||
import gitbucket.core.servlet.Database
|
import gitbucket.core.servlet.Database
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
import gitbucket.core.util.SyntaxSugars._
|
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
@@ -16,6 +15,10 @@ import org.scalatra._
|
|||||||
import org.scalatra.servlet.{FileItem, FileUploadSupport, MultipartConfig}
|
import org.scalatra.servlet.{FileItem, FileUploadSupport, MultipartConfig}
|
||||||
import org.apache.commons.io.{FileUtils, IOUtils}
|
import org.apache.commons.io.{FileUtils, IOUtils}
|
||||||
|
|
||||||
|
import scala.util.Using
|
||||||
|
import gitbucket.core.service.SystemSettingsService
|
||||||
|
import slick.jdbc.JdbcBackend.Session
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Ajax based file upload functionality.
|
* Provides Ajax based file upload functionality.
|
||||||
*
|
*
|
||||||
@@ -26,26 +29,27 @@ class FileUploadController
|
|||||||
with FileUploadSupport
|
with FileUploadSupport
|
||||||
with RepositoryService
|
with RepositoryService
|
||||||
with AccountService
|
with AccountService
|
||||||
with ReleaseService {
|
with ReleaseService
|
||||||
|
with SystemSettingsService {
|
||||||
configureMultipartHandling(MultipartConfig(maxFileSize = Some(FileUtil.MaxFileSize)))
|
|
||||||
|
|
||||||
post("/image") {
|
post("/image") {
|
||||||
|
setMultipartConfig()
|
||||||
execute(
|
execute(
|
||||||
{ (file, fileId) =>
|
{ (file, fileId) =>
|
||||||
FileUtils
|
FileUtils
|
||||||
.writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get)
|
.writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get())
|
||||||
session += Keys.Session.Upload(fileId) -> file.name
|
session += Keys.Session.Upload(fileId) -> file.name
|
||||||
},
|
},
|
||||||
FileUtil.isImage
|
FileUtil.isImage(_)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
post("/tmp") {
|
post("/tmp") {
|
||||||
|
setMultipartConfig()
|
||||||
execute(
|
execute(
|
||||||
{ (file, fileId) =>
|
{ (file, fileId) =>
|
||||||
FileUtils
|
FileUtils
|
||||||
.writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get)
|
.writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get())
|
||||||
session += Keys.Session.Upload(fileId) -> file.name
|
session += Keys.Session.Upload(fileId) -> file.name
|
||||||
},
|
},
|
||||||
_ => true
|
_ => true
|
||||||
@@ -53,6 +57,7 @@ class FileUploadController
|
|||||||
}
|
}
|
||||||
|
|
||||||
post("/file/:owner/:repository") {
|
post("/file/:owner/:repository") {
|
||||||
|
setMultipartConfig()
|
||||||
execute(
|
execute(
|
||||||
{ (file, fileId) =>
|
{ (file, fileId) =>
|
||||||
FileUtils.writeByteArrayToFile(
|
FileUtils.writeByteArrayToFile(
|
||||||
@@ -60,7 +65,7 @@ class FileUploadController
|
|||||||
getAttachedDir(params("owner"), params("repository")),
|
getAttachedDir(params("owner"), params("repository")),
|
||||||
FileUtil.checkFilename(fileId + "." + FileUtil.getExtension(file.getName))
|
FileUtil.checkFilename(fileId + "." + FileUtil.getExtension(file.getName))
|
||||||
),
|
),
|
||||||
file.get
|
file.get()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
_ => true
|
_ => true
|
||||||
@@ -68,9 +73,9 @@ class FileUploadController
|
|||||||
}
|
}
|
||||||
|
|
||||||
post("/wiki/:owner/:repository") {
|
post("/wiki/:owner/:repository") {
|
||||||
|
setMultipartConfig()
|
||||||
// Don't accept not logged-in users
|
// Don't accept not logged-in users
|
||||||
session.get(Keys.Session.LoginAccount).collect {
|
session.get(Keys.Session.LoginAccount).collect { case loginAccount: Account =>
|
||||||
case loginAccount: Account =>
|
|
||||||
val owner = params("owner")
|
val owner = params("owner")
|
||||||
val repository = params("repository")
|
val repository = params("repository")
|
||||||
|
|
||||||
@@ -80,8 +85,7 @@ class FileUploadController
|
|||||||
{ (file, fileId) =>
|
{ (file, fileId) =>
|
||||||
val fileName = file.getName
|
val fileName = file.getName
|
||||||
LockUtil.lock(s"${owner}/${repository}/wiki") {
|
LockUtil.lock(s"${owner}/${repository}/wiki") {
|
||||||
using(Git.open(Directory.getWikiRepositoryDir(owner, repository))) {
|
Using.resource(Git.open(Directory.getWikiRepositoryDir(owner, repository))) { git =>
|
||||||
git =>
|
|
||||||
val builder = DirCache.newInCore.builder()
|
val builder = DirCache.newInCore.builder()
|
||||||
val inserter = git.getRepository.newObjectInserter()
|
val inserter = git.getRepository.newObjectInserter()
|
||||||
val headId = git.getRepository.resolve(Constants.HEAD + "^{commit}")
|
val headId = git.getRepository.resolve(Constants.HEAD + "^{commit}")
|
||||||
@@ -125,19 +129,19 @@ class FileUploadController
|
|||||||
} getOrElse BadRequest()
|
} getOrElse BadRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
post("/release/:owner/:repository/:tag") {
|
post("/release/:owner/:repository/*") {
|
||||||
|
setMultipartConfigForLargeFile()
|
||||||
session
|
session
|
||||||
.get(Keys.Session.LoginAccount)
|
.get(Keys.Session.LoginAccount)
|
||||||
.collect {
|
.collect { case _: Account =>
|
||||||
case _: Account =>
|
|
||||||
val owner = params("owner")
|
val owner = params("owner")
|
||||||
val repository = params("repository")
|
val repository = params("repository")
|
||||||
val tag = params("tag")
|
val tag = multiParams("splat").head
|
||||||
execute(
|
execute(
|
||||||
{ (file, fileId) =>
|
{ (file, fileId) =>
|
||||||
FileUtils.writeByteArrayToFile(
|
FileUtils.writeByteArrayToFile(
|
||||||
new File(getReleaseFilesDir(owner, repository), FileUtil.checkFilename(tag + "/" + fileId)),
|
new File(getReleaseFilesDir(owner, repository), FileUtil.checkFilename(tag + "/" + fileId)),
|
||||||
file.get
|
file.get()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
_ => true
|
_ => true
|
||||||
@@ -148,17 +152,33 @@ class FileUploadController
|
|||||||
|
|
||||||
post("/import") {
|
post("/import") {
|
||||||
import JDBCUtil._
|
import JDBCUtil._
|
||||||
|
setMultipartConfig()
|
||||||
session.get(Keys.Session.LoginAccount).collect {
|
session.get(Keys.Session.LoginAccount).collect {
|
||||||
case loginAccount: Account if loginAccount.isAdmin =>
|
case loginAccount: Account if loginAccount.isAdmin =>
|
||||||
execute({ (file, fileId) =>
|
execute(
|
||||||
|
{ (file, fileId) =>
|
||||||
request2Session(request).conn.importAsSQL(file.getInputStream)
|
request2Session(request).conn.importAsSQL(file.getInputStream)
|
||||||
}, _ => true)
|
},
|
||||||
|
_ => true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
redirect("/admin/data")
|
redirect("/admin/data")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def setMultipartConfig(): Unit = {
|
||||||
|
val settings = loadSystemSettings()
|
||||||
|
val config = MultipartConfig(maxFileSize = Some(settings.upload.maxFileSize))
|
||||||
|
config.apply(request.getServletContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
private def setMultipartConfigForLargeFile(): Unit = {
|
||||||
|
val settings = loadSystemSettings()
|
||||||
|
val config = MultipartConfig(maxFileSize = Some(settings.upload.largeMaxFileSize))
|
||||||
|
config.apply(request.getServletContext())
|
||||||
|
}
|
||||||
|
|
||||||
private def onlyWikiEditable(owner: String, repository: String, loginAccount: Account)(action: => Any): Any = {
|
private def onlyWikiEditable(owner: String, repository: String, loginAccount: Account)(action: => Any): Any = {
|
||||||
implicit val session = Database.getSession(request)
|
implicit val session: Session = Database.getSession(request)
|
||||||
getRepository(owner, repository) match {
|
getRepository(owner, repository) match {
|
||||||
case Some(x) =>
|
case Some(x) =>
|
||||||
x.repository.options.wikiOption match {
|
x.repository.options.wikiOption match {
|
||||||
@@ -171,14 +191,13 @@ class FileUploadController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def execute(f: (FileItem, String) => Unit, mimeTypeChcker: (String) => Boolean) =
|
private def execute(f: (FileItem, String) => Unit, mimeTypeChecker: (String) => Boolean) =
|
||||||
fileParams.get("file") match {
|
fileParams.get("file") match {
|
||||||
case Some(file) if (mimeTypeChcker(file.name)) =>
|
case Some(file) if mimeTypeChecker(file.name) =>
|
||||||
defining(FileUtil.generateFileId) { fileId =>
|
val fileId = FileUtil.generateFileId
|
||||||
f(file, fileId)
|
f(file, fileId)
|
||||||
contentType = "text/plain"
|
contentType = "text/plain"
|
||||||
Ok(fileId)
|
Ok(fileId)
|
||||||
}
|
|
||||||
case _ => BadRequest()
|
case _ => BadRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import java.net.URI
|
import com.nimbusds.jwt.JWT
|
||||||
|
|
||||||
|
import java.net.URI
|
||||||
import com.nimbusds.oauth2.sdk.id.State
|
import com.nimbusds.oauth2.sdk.id.State
|
||||||
import com.nimbusds.openid.connect.sdk.Nonce
|
import com.nimbusds.openid.connect.sdk.Nonce
|
||||||
import gitbucket.core.helper.xml
|
import gitbucket.core.helper.xml
|
||||||
import gitbucket.core.model.Account
|
import gitbucket.core.model.Account
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.SyntaxSugars._
|
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
|
import gitbucket.core.view.helpers._
|
||||||
import org.scalatra.Ok
|
import org.scalatra.Ok
|
||||||
import org.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
|
|
||||||
|
import gitbucket.core.service.ActivityService._
|
||||||
|
|
||||||
class IndexController
|
class IndexController
|
||||||
extends IndexControllerBase
|
extends IndexControllerBase
|
||||||
with RepositoryService
|
with RepositoryService
|
||||||
@@ -28,6 +31,7 @@ class IndexController
|
|||||||
with AccessTokenService
|
with AccessTokenService
|
||||||
with AccountFederationService
|
with AccountFederationService
|
||||||
with OpenIDConnectService
|
with OpenIDConnectService
|
||||||
|
with RequestCache
|
||||||
|
|
||||||
trait IndexControllerBase extends ControllerBase {
|
trait IndexControllerBase extends ControllerBase {
|
||||||
self: RepositoryService
|
self: RepositoryService
|
||||||
@@ -56,25 +60,41 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
//
|
//
|
||||||
// case class SearchForm(query: String, owner: String, repository: String)
|
// case class SearchForm(query: String, owner: String, repository: String)
|
||||||
|
|
||||||
case class OidcContext(state: State, nonce: Nonce, redirectBackURI: String)
|
case class OidcAuthContext(state: State, nonce: Nonce, redirectBackURI: String)
|
||||||
|
case class OidcSessionContext(token: JWT)
|
||||||
|
|
||||||
get("/") {
|
get("/") {
|
||||||
context.loginAccount
|
context.loginAccount
|
||||||
.map { account =>
|
.map { account =>
|
||||||
val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName)
|
val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName)
|
||||||
|
if (!isNewsFeedEnabled) {
|
||||||
|
redirect("/dashboard/repos")
|
||||||
|
} else {
|
||||||
|
val repos = getVisibleRepositories(
|
||||||
|
Some(account),
|
||||||
|
None,
|
||||||
|
withoutPhysicalInfo = true,
|
||||||
|
limit = false
|
||||||
|
)
|
||||||
|
|
||||||
gitbucket.core.html.index(
|
gitbucket.core.html.index(
|
||||||
getRecentActivitiesByOwners(visibleOwnerSet),
|
activities = getRecentActivitiesByRepos(repos.map(x => (x.owner, x.name)).toSet),
|
||||||
getVisibleRepositories(Some(account), withoutPhysicalInfo = true),
|
recentRepositories = if (context.settings.basicBehavior.limitVisibleRepositories) {
|
||||||
|
repos.filter(x => x.owner == account.userName)
|
||||||
|
} else repos,
|
||||||
showBannerToCreatePersonalAccessToken = hasAccountFederation(account.userName) && !hasAccessToken(
|
showBannerToCreatePersonalAccessToken = hasAccountFederation(account.userName) && !hasAccessToken(
|
||||||
account.userName
|
account.userName
|
||||||
|
),
|
||||||
|
enableNewsFeed = isNewsFeedEnabled
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
.getOrElse {
|
.getOrElse {
|
||||||
gitbucket.core.html.index(
|
gitbucket.core.html.index(
|
||||||
getRecentActivities(),
|
activities = getRecentPublicActivities(),
|
||||||
getVisibleRepositories(None, withoutPhysicalInfo = true),
|
recentRepositories = getVisibleRepositories(None, withoutPhysicalInfo = true),
|
||||||
showBannerToCreatePersonalAccessToken = false
|
showBannerToCreatePersonalAccessToken = false,
|
||||||
|
enableNewsFeed = isNewsFeedEnabled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,7 +102,7 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
get("/signin") {
|
get("/signin") {
|
||||||
val redirect = params.get("redirect")
|
val redirect = params.get("redirect")
|
||||||
if (redirect.isDefined && redirect.get.startsWith("/")) {
|
if (redirect.isDefined && redirect.get.startsWith("/")) {
|
||||||
flash += Keys.Flash.Redirect -> redirect.get
|
flash.update(Keys.Flash.Redirect, redirect.get)
|
||||||
}
|
}
|
||||||
gitbucket.core.html.signin(flash.get("userName"), flash.get("password"), flash.get("error"))
|
gitbucket.core.html.signin(flash.get("userName"), flash.get("password"), flash.get("error"))
|
||||||
}
|
}
|
||||||
@@ -95,9 +115,9 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
case _ => signin(account)
|
case _ => signin(account)
|
||||||
}
|
}
|
||||||
case None =>
|
case None =>
|
||||||
flash += "userName" -> form.userName
|
flash.update("userName", form.userName)
|
||||||
flash += "password" -> form.password
|
flash.update("password", form.password)
|
||||||
flash += "error" -> "Sorry, your Username and/or Password is incorrect. Please try again."
|
flash.update("error", "Sorry, your Username and/or Password is incorrect. Please try again.")
|
||||||
redirect("/signin")
|
redirect("/signin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,8 +134,8 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
case _ => "/"
|
case _ => "/"
|
||||||
}
|
}
|
||||||
session.setAttribute(
|
session.setAttribute(
|
||||||
Keys.Session.OidcContext,
|
Keys.Session.OidcAuthContext,
|
||||||
OidcContext(authenticationRequest.getState, authenticationRequest.getNonce, redirectBackURI)
|
OidcAuthContext(authenticationRequest.getState, authenticationRequest.getNonce, redirectBackURI)
|
||||||
)
|
)
|
||||||
redirect(authenticationRequest.toURI.toString)
|
redirect(authenticationRequest.toURI.toString)
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
@@ -129,17 +149,18 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
get("/signin/oidc") {
|
get("/signin/oidc") {
|
||||||
context.settings.oidc.map { oidc =>
|
context.settings.oidc.map { oidc =>
|
||||||
val redirectURI = new URI(s"$baseUrl/signin/oidc")
|
val redirectURI = new URI(s"$baseUrl/signin/oidc")
|
||||||
session.get(Keys.Session.OidcContext) match {
|
session.get(Keys.Session.OidcAuthContext) match {
|
||||||
case Some(context: OidcContext) =>
|
case Some(context: OidcAuthContext) =>
|
||||||
authenticate(params, redirectURI, context.state, context.nonce, oidc) map { account =>
|
authenticate(params.toMap, redirectURI, context.state, context.nonce, oidc).map { case (jwt, account) =>
|
||||||
|
session.setAttribute(Keys.Session.OidcSessionContext, OidcSessionContext(jwt))
|
||||||
signin(account, context.redirectBackURI)
|
signin(account, context.redirectBackURI)
|
||||||
} orElse {
|
} orElse {
|
||||||
flash += "error" -> "Sorry, authentication failed. Please try again."
|
flash.update("error", "Sorry, authentication failed. Please try again.")
|
||||||
session.invalidate()
|
session.invalidate()
|
||||||
redirect("/signin")
|
redirect("/signin")
|
||||||
}
|
}
|
||||||
case _ =>
|
case _ =>
|
||||||
flash += "error" -> "Sorry, something wrong. Please try again."
|
flash.update("error", "Sorry, something wrong. Please try again.")
|
||||||
session.invalidate()
|
session.invalidate()
|
||||||
redirect("/signin")
|
redirect("/signin")
|
||||||
}
|
}
|
||||||
@@ -149,13 +170,24 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get("/signout") {
|
get("/signout") {
|
||||||
session.invalidate
|
context.settings.oidc.foreach { oidc =>
|
||||||
|
session.get(Keys.Session.OidcSessionContext).foreach { case context: OidcSessionContext =>
|
||||||
|
val redirectURI = new URI(baseUrl)
|
||||||
|
val authenticationRequest = createOIDLogoutRequest(oidc.issuer, oidc.clientID, redirectURI, context.token)
|
||||||
|
session.invalidate()
|
||||||
|
redirect(authenticationRequest.toURI.toString)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.invalidate()
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
deleteLoginAccountFromLocalFile()
|
||||||
|
}
|
||||||
redirect("/")
|
redirect("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
get("/activities.atom") {
|
get("/activities.atom") {
|
||||||
contentType = "application/atom+xml; type=feed"
|
contentType = "application/atom+xml; type=feed"
|
||||||
xml.feed(getRecentActivities())
|
xml.feed(getRecentPublicActivities())
|
||||||
}
|
}
|
||||||
|
|
||||||
post("/sidebar-collapse") {
|
post("/sidebar-collapse") {
|
||||||
@@ -172,6 +204,9 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
private def signin(account: Account, redirectUrl: String = "/") = {
|
private def signin(account: Account, redirectUrl: String = "/") = {
|
||||||
session.setAttribute(Keys.Session.LoginAccount, account)
|
session.setAttribute(Keys.Session.LoginAccount, account)
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
saveLoginAccountToLocalFile(account)
|
||||||
|
}
|
||||||
updateLastLoginDate(account.userName)
|
updateLastLoginDate(account.userName)
|
||||||
|
|
||||||
if (LDAPUtil.isDummyMailAddress(account)) {
|
if (LDAPUtil.isDummyMailAddress(account)) {
|
||||||
@@ -195,7 +230,7 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
Map(
|
Map(
|
||||||
"options" -> (
|
"options" -> (
|
||||||
getAllUsers(false)
|
getAllUsers(includeRemoved = false)
|
||||||
.withFilter { t =>
|
.withFilter { t =>
|
||||||
(user, group) match {
|
(user, group) match {
|
||||||
case (true, true) => true
|
case (true, true) => true
|
||||||
@@ -206,7 +241,10 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
.map { t =>
|
.map { t =>
|
||||||
Map(
|
Map(
|
||||||
"label" -> s"<b>@${StringUtil.escapeHtml(t.userName)}</b> ${StringUtil.escapeHtml(t.fullName)}",
|
"label" -> s"${avatar(t.userName, 16)}<b>@${StringUtil.escapeHtml(
|
||||||
|
StringUtil.cutTail(t.userName, 25, "...")
|
||||||
|
)}</b> ${StringUtil
|
||||||
|
.escapeHtml(StringUtil.cutTail(t.fullName, 25, "..."))}",
|
||||||
"value" -> t.userName
|
"value" -> t.userName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -225,22 +263,23 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
} getOrElse ""
|
} getOrElse ""
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO Move to RepositoryViwerController?
|
// TODO Move to RepositoryViewerController?
|
||||||
get("/:owner/:repository/search")(referrersOnly { repository =>
|
get("/:owner/:repository/search")(referrersOnly { repository =>
|
||||||
defining(params.getOrElse("q", "").trim, params.getOrElse("type", "code")) {
|
val query = params.getOrElse("q", "").trim
|
||||||
case (query, target) =>
|
val target = params.getOrElse("type", "code")
|
||||||
val page = try {
|
val page =
|
||||||
|
try {
|
||||||
val i = params.getOrElse("page", "1").toInt
|
val i = params.getOrElse("page", "1").toInt
|
||||||
if (i <= 0) 1 else i
|
if (i <= 0) 1 else i
|
||||||
} catch {
|
} catch {
|
||||||
case e: NumberFormatException => 1
|
case _: NumberFormatException => 1
|
||||||
}
|
}
|
||||||
|
|
||||||
target.toLowerCase match {
|
target.toLowerCase match {
|
||||||
case "issues" =>
|
case "issues" =>
|
||||||
gitbucket.core.search.html.issues(
|
gitbucket.core.search.html.issues(
|
||||||
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, false) else Nil,
|
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, pullRequest = false) else Nil,
|
||||||
false,
|
pullRequest = false,
|
||||||
query,
|
query,
|
||||||
page,
|
page,
|
||||||
repository
|
repository
|
||||||
@@ -248,8 +287,8 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
case "pulls" =>
|
case "pulls" =>
|
||||||
gitbucket.core.search.html.issues(
|
gitbucket.core.search.html.issues(
|
||||||
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, true) else Nil,
|
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, pullRequest = true) else Nil,
|
||||||
true,
|
pullRequest = true,
|
||||||
query,
|
query,
|
||||||
page,
|
page,
|
||||||
repository
|
repository
|
||||||
@@ -271,17 +310,33 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
repository
|
repository
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/search") {
|
get("/search") {
|
||||||
val query = params.getOrElse("query", "").trim.toLowerCase
|
val query = params.getOrElse("query", "").trim.toLowerCase
|
||||||
val visibleRepositories =
|
val visibleRepositories =
|
||||||
getVisibleRepositories(context.loginAccount, repositoryUserName = None, withoutPhysicalInfo = true)
|
getVisibleRepositories(
|
||||||
val repositories = visibleRepositories.filter { repository =>
|
context.loginAccount,
|
||||||
|
None,
|
||||||
|
withoutPhysicalInfo = true,
|
||||||
|
limit = context.settings.basicBehavior.limitVisibleRepositories
|
||||||
|
)
|
||||||
|
|
||||||
|
val repositories = {
|
||||||
|
if (context.settings.basicBehavior.limitVisibleRepositories) {
|
||||||
|
getVisibleRepositories(
|
||||||
|
context.loginAccount,
|
||||||
|
None,
|
||||||
|
withoutPhysicalInfo = true,
|
||||||
|
limit = false
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
visibleRepositories
|
||||||
|
}
|
||||||
|
}.filter { repository =>
|
||||||
repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0
|
repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
gitbucket.core.search.html.repositories(query, repositories, visibleRepositories)
|
gitbucket.core.search.html.repositories(query, repositories, visibleRepositories)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.issues.html
|
import gitbucket.core.issues.html
|
||||||
|
import gitbucket.core.model.{Account, CustomFieldBehavior}
|
||||||
import gitbucket.core.service.IssuesService._
|
import gitbucket.core.service.IssuesService._
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.SyntaxSugars._
|
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
import gitbucket.core.view
|
import gitbucket.core.view
|
||||||
@@ -21,14 +21,17 @@ class IssuesController
|
|||||||
with ActivityService
|
with ActivityService
|
||||||
with HandleCommentService
|
with HandleCommentService
|
||||||
with IssueCreationService
|
with IssueCreationService
|
||||||
|
with CustomFieldsService
|
||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with ReferrerAuthenticator
|
with ReferrerAuthenticator
|
||||||
with WritableUsersAuthenticator
|
with WritableUsersAuthenticator
|
||||||
|
with MergeService
|
||||||
with PullRequestService
|
with PullRequestService
|
||||||
with WebHookIssueCommentService
|
with WebHookIssueCommentService
|
||||||
with WebHookPullRequestReviewCommentService
|
with WebHookPullRequestReviewCommentService
|
||||||
with CommitsService
|
with CommitsService
|
||||||
with PrioritiesService
|
with PrioritiesService
|
||||||
|
with RequestCache
|
||||||
|
|
||||||
trait IssuesControllerBase extends ControllerBase {
|
trait IssuesControllerBase extends ControllerBase {
|
||||||
self: IssuesService
|
self: IssuesService
|
||||||
@@ -39,6 +42,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
with ActivityService
|
with ActivityService
|
||||||
with HandleCommentService
|
with HandleCommentService
|
||||||
with IssueCreationService
|
with IssueCreationService
|
||||||
|
with CustomFieldsService
|
||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with ReferrerAuthenticator
|
with ReferrerAuthenticator
|
||||||
with WritableUsersAuthenticator
|
with WritableUsersAuthenticator
|
||||||
@@ -49,7 +53,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
case class IssueCreateForm(
|
case class IssueCreateForm(
|
||||||
title: String,
|
title: String,
|
||||||
content: Option[String],
|
content: Option[String],
|
||||||
assignedUserName: Option[String],
|
assigneeUserNames: Option[String],
|
||||||
milestoneId: Option[Int],
|
milestoneId: Option[Int],
|
||||||
priorityId: Option[Int],
|
priorityId: Option[Int],
|
||||||
labelNames: Option[String]
|
labelNames: Option[String]
|
||||||
@@ -60,7 +64,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
val issueCreateForm = mapping(
|
val issueCreateForm = mapping(
|
||||||
"title" -> trim(label("Title", text(required))),
|
"title" -> trim(label("Title", text(required))),
|
||||||
"content" -> trim(optional(text())),
|
"content" -> trim(optional(text())),
|
||||||
"assignedUserName" -> trim(optional(text())),
|
"assigneeUserNames" -> trim(optional(text())),
|
||||||
"milestoneId" -> trim(optional(number())),
|
"milestoneId" -> trim(optional(number())),
|
||||||
"priorityId" -> trim(optional(number())),
|
"priorityId" -> trim(optional(number())),
|
||||||
"labelNames" -> trim(optional(text()))
|
"labelNames" -> trim(optional(text()))
|
||||||
@@ -85,168 +89,195 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
get("/:owner/:repository/issues")(referrersOnly { repository =>
|
get("/:owner/:repository/issues")(referrersOnly { repository =>
|
||||||
val q = request.getParameter("q")
|
val q = request.getParameter("q")
|
||||||
if (Option(q).exists(_.contains("is:pr"))) {
|
Option(q) match {
|
||||||
|
case Some(filter) if filter.contains("is:pr") =>
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pulls?q=${StringUtil.urlEncode(q)}")
|
redirect(s"/${repository.owner}/${repository.name}/pulls?q=${StringUtil.urlEncode(q)}")
|
||||||
|
case Some(filter) =>
|
||||||
|
val condition = IssueSearchCondition(filter)
|
||||||
|
if (condition.isEmpty) {
|
||||||
|
// Redirect to keyword search
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/search?q=${StringUtil.urlEncode(q)}&type=issues")
|
||||||
} else {
|
} else {
|
||||||
searchIssues(repository)
|
searchIssues(repository, condition, IssueSearchCondition.page(request))
|
||||||
|
}
|
||||||
|
case None =>
|
||||||
|
searchIssues(repository, IssueSearchCondition(request), IssueSearchCondition.page(request))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/:id")(referrersOnly { repository =>
|
get("/:owner/:repository/issues/:id")(referrersOnly { repository =>
|
||||||
defining(repository.owner, repository.name, params("id")) {
|
val issueId = params("id")
|
||||||
case (owner, name, issueId) =>
|
getIssue(repository.owner, repository.name, issueId) map { issue =>
|
||||||
getIssue(owner, name, issueId) map {
|
|
||||||
issue =>
|
|
||||||
if (issue.isPullRequest) {
|
if (issue.isPullRequest) {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
} else {
|
} else {
|
||||||
html.issue(
|
html.issue(
|
||||||
issue,
|
issue,
|
||||||
getComments(owner, name, issueId.toInt),
|
getComments(repository.owner, repository.name, issueId.toInt),
|
||||||
getIssueLabels(owner, name, issueId.toInt),
|
getIssueLabels(repository.owner, repository.name, issueId.toInt),
|
||||||
getAssignableUserNames(owner, name),
|
getIssueAssignees(repository.owner, repository.name, issueId.toInt),
|
||||||
getMilestonesWithIssueCount(owner, name),
|
getAssignableUserNames(repository.owner, repository.name),
|
||||||
getPriorities(owner, name),
|
getMilestonesWithIssueCount(repository.owner, repository.name),
|
||||||
getLabels(owner, name),
|
getPriorities(repository.owner, repository.name),
|
||||||
|
getLabels(repository.owner, repository.name),
|
||||||
|
getCustomFieldsWithValue(repository.owner, repository.name, issueId.toInt).filter(_._1.enableForIssues),
|
||||||
isIssueEditable(repository),
|
isIssueEditable(repository),
|
||||||
isIssueManageable(repository),
|
isIssueManageable(repository),
|
||||||
|
isIssueCommentManageable(repository),
|
||||||
repository
|
repository
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/new")(readableUsersOnly { repository =>
|
get("/:owner/:repository/issues/new")(readableUsersOnly { repository =>
|
||||||
if (isIssueEditable(repository)) { // TODO Should this check is provided by authenticator?
|
if (isIssueEditable(repository)) { // TODO Should this check is provided by authenticator?
|
||||||
defining(repository.owner, repository.name) {
|
|
||||||
case (owner, name) =>
|
|
||||||
html.create(
|
html.create(
|
||||||
getAssignableUserNames(owner, name),
|
getAssignableUserNames(repository.owner, repository.name),
|
||||||
getMilestones(owner, name),
|
getMilestones(repository.owner, repository.name),
|
||||||
getPriorities(owner, name),
|
getPriorities(repository.owner, repository.name),
|
||||||
getDefaultPriority(owner, name),
|
getDefaultPriority(repository.owner, repository.name),
|
||||||
getLabels(owner, name),
|
getLabels(repository.owner, repository.name),
|
||||||
|
getCustomFields(repository.owner, repository.name).filter(_.enableForIssues),
|
||||||
isIssueManageable(repository),
|
isIssueManageable(repository),
|
||||||
getContentTemplate(repository, "ISSUE_TEMPLATE"),
|
getContentTemplate(repository, "ISSUE_TEMPLATE"),
|
||||||
repository
|
repository
|
||||||
)
|
)
|
||||||
}
|
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
if (isIssueEditable(repository)) { // TODO Should this check is provided by authenticator?
|
if (isIssueEditable(repository)) { // TODO Should this check is provided by authenticator?
|
||||||
val issue = createIssue(
|
val issue = createIssue(
|
||||||
repository,
|
repository,
|
||||||
form.title,
|
form.title,
|
||||||
form.content,
|
form.content,
|
||||||
form.assignedUserName,
|
form.assigneeUserNames.toSeq.flatMap(_.split(",")),
|
||||||
form.milestoneId,
|
form.milestoneId,
|
||||||
form.priorityId,
|
form.priorityId,
|
||||||
form.labelNames.toArray.flatMap(_.split(",")),
|
form.labelNames.toSeq.flatMap(_.split(",")),
|
||||||
context.loginAccount.get
|
loginAccount
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Insert custom field values
|
||||||
|
params.toMap.foreach { case (key, value) =>
|
||||||
|
if (key.startsWith("custom-field-")) {
|
||||||
|
getCustomField(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
key.replaceFirst("^custom-field-", "").toInt
|
||||||
|
).foreach { field =>
|
||||||
|
CustomFieldBehavior.validate(field, value, messages) match {
|
||||||
|
case None =>
|
||||||
|
insertOrUpdateCustomFieldValue(field, repository.owner, repository.name, issue.issueId, value)
|
||||||
|
case Some(_) => halt(400)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
redirect(s"/${issue.userName}/${issue.repositoryName}/issues/${issue.issueId}")
|
redirect(s"/${issue.userName}/${issue.repositoryName}/issues/${issue.issueId}")
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/edit_title/:id", issueTitleEditForm)(readableUsersOnly { (title, repository) =>
|
ajaxPost("/:owner/:repository/issues/edit_title/:id", issueTitleEditForm)(readableUsersOnly { (title, repository) =>
|
||||||
defining(repository.owner, repository.name) {
|
context.withLoginAccount { loginAccount =>
|
||||||
case (owner, name) =>
|
getIssue(repository.owner, repository.name, params("id")).map { issue =>
|
||||||
getIssue(owner, name, params("id")).map {
|
if (isEditableContent(repository.owner, repository.name, issue.openedUserName, loginAccount)) {
|
||||||
issue =>
|
|
||||||
if (isEditableContent(owner, name, issue.openedUserName)) {
|
|
||||||
if (issue.title != title) {
|
if (issue.title != title) {
|
||||||
// update issue
|
// update issue
|
||||||
updateIssue(owner, name, issue.issueId, title, issue.content)
|
updateIssue(repository.owner, repository.name, issue.issueId, title, issue.content)
|
||||||
// extract references and create refer comment
|
// extract references and create refer comment
|
||||||
createReferComment(owner, name, issue.copy(title = title), title, context.loginAccount.get)
|
createReferComment(repository.owner, repository.name, issue.copy(title = title), title, loginAccount)
|
||||||
createComment(
|
createComment(
|
||||||
owner,
|
repository.owner,
|
||||||
name,
|
repository.name,
|
||||||
context.loginAccount.get.userName,
|
loginAccount.userName,
|
||||||
issue.issueId,
|
issue.issueId,
|
||||||
issue.title + "\r\n" + title,
|
issue.title + "\r\n" + title,
|
||||||
"change_title"
|
"change_title"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
|
redirect(s"/${repository.owner}/${repository.name}/issues/_data/${issue.issueId}")
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/edit/:id", issueEditForm)(readableUsersOnly { (content, repository) =>
|
ajaxPost("/:owner/:repository/issues/edit/:id", issueEditForm)(readableUsersOnly { (content, repository) =>
|
||||||
defining(repository.owner, repository.name) {
|
context.withLoginAccount { loginAccount =>
|
||||||
case (owner, name) =>
|
getIssue(repository.owner, repository.name, params("id")).map { issue =>
|
||||||
getIssue(owner, name, params("id")).map { issue =>
|
if (isEditableContent(repository.owner, repository.name, issue.openedUserName, loginAccount)) {
|
||||||
if (isEditableContent(owner, name, issue.openedUserName)) {
|
|
||||||
// update issue
|
// update issue
|
||||||
updateIssue(owner, name, issue.issueId, issue.title, content)
|
updateIssue(repository.owner, repository.name, issue.issueId, issue.title, content)
|
||||||
// extract references and create refer comment
|
// extract references and create refer comment
|
||||||
createReferComment(owner, name, issue, content.getOrElse(""), context.loginAccount.get)
|
createReferComment(repository.owner, repository.name, issue, content.getOrElse(""), loginAccount)
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
|
redirect(s"/${repository.owner}/${repository.name}/issues/_data/${issue.issueId}")
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
||||||
val actionOpt =
|
val actionOpt =
|
||||||
params.get("action").filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName))
|
params
|
||||||
handleComment(issue, Some(form.content), repository, actionOpt) map {
|
.get("action")
|
||||||
case (issue, id) =>
|
.filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName, loginAccount))
|
||||||
|
handleComment(issue, Some(form.content), repository, actionOpt) map { case (issue, id) =>
|
||||||
redirect(
|
redirect(
|
||||||
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}"
|
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issue_comments/state", issueStateForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issue_comments/state", issueStateForm)(readableUsersOnly { (form, repository) =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
||||||
val actionOpt =
|
val actionOpt =
|
||||||
params.get("action").filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName))
|
params
|
||||||
handleComment(issue, form.content, repository, actionOpt) map {
|
.get("action")
|
||||||
case (issue, id) =>
|
.filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName, loginAccount))
|
||||||
|
handleComment(issue, form.content, repository, actionOpt) map { case (issue, id) =>
|
||||||
redirect(
|
redirect(
|
||||||
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}"
|
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issue_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/issue_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
defining(repository.owner, repository.name) {
|
context.withLoginAccount { loginAccount =>
|
||||||
case (owner, name) =>
|
getComment(repository.owner, repository.name, params("id")).map { comment =>
|
||||||
getComment(owner, name, params("id")).map { comment =>
|
if (isEditableContent(repository.owner, repository.name, comment.commentedUserName, loginAccount)) {
|
||||||
if (isEditableContent(owner, name, comment.commentedUserName)) {
|
updateComment(repository.owner, repository.name, comment.issueId, comment.commentId, form.content)
|
||||||
updateComment(comment.issueId, comment.commentId, form.content)
|
redirect(s"/${repository.owner}/${repository.name}/issue_comments/_data/${comment.commentId}")
|
||||||
redirect(s"/${owner}/${name}/issue_comments/_data/${comment.commentId}")
|
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issue_comments/delete/:id")(readableUsersOnly { repository =>
|
ajaxPost("/:owner/:repository/issue_comments/delete/:id")(readableUsersOnly { repository =>
|
||||||
defining(repository.owner, repository.name) {
|
context.withLoginAccount { loginAccount =>
|
||||||
case (owner, name) =>
|
getComment(repository.owner, repository.name, params("id")).map { comment =>
|
||||||
getComment(owner, name, params("id")).map { comment =>
|
if (isDeletableComment(repository.owner, repository.name, comment.commentedUserName, loginAccount)) {
|
||||||
if (isEditableContent(owner, name, comment.commentedUserName)) {
|
Ok(deleteComment(repository.owner, repository.name, comment.issueId, comment.commentId))
|
||||||
Ok(deleteComment(comment.issueId, comment.commentId))
|
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issues/_data/:id")(readableUsersOnly { repository =>
|
ajaxGet("/:owner/:repository/issues/_data/:id")(readableUsersOnly { repository =>
|
||||||
getIssue(repository.owner, repository.name, params("id")) map {
|
context.withLoginAccount { loginAccount =>
|
||||||
x =>
|
getIssue(repository.owner, repository.name, params("id")) map { x =>
|
||||||
if (isEditableContent(x.userName, x.repositoryName, x.openedUserName)) {
|
if (isEditableContent(x.userName, x.repositoryName, x.openedUserName, loginAccount)) {
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editissue(x.content, x.issueId, repository)
|
case t if t == "html" => html.editissue(x.content, x.issueId, repository)
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
@@ -270,12 +301,13 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issue_comments/_data/:id")(readableUsersOnly { repository =>
|
ajaxGet("/:owner/:repository/issue_comments/_data/:id")(readableUsersOnly { repository =>
|
||||||
getComment(repository.owner, repository.name, params("id")) map {
|
context.withLoginAccount { loginAccount =>
|
||||||
x =>
|
getComment(repository.owner, repository.name, params("id")) map { x =>
|
||||||
if (isEditableContent(x.userName, x.repositoryName, x.commentedUserName)) {
|
if (isEditableContent(x.userName, x.repositoryName, x.commentedUserName, loginAccount)) {
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
|
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
@@ -298,6 +330,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/new/label")(writableUsersOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/new/label")(writableUsersOnly { repository =>
|
||||||
@@ -307,28 +340,27 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/label/new")(writableUsersOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/label/new")(writableUsersOnly { repository =>
|
||||||
defining(params("id").toInt) { issueId =>
|
val issueId = params("id").toInt
|
||||||
registerIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt, true)
|
registerIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt, true)
|
||||||
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/label/delete")(writableUsersOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/label/delete")(writableUsersOnly { repository =>
|
||||||
defining(params("id").toInt) { issueId =>
|
val issueId = params("id").toInt
|
||||||
deleteIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt, true)
|
deleteIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt, true)
|
||||||
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/assign")(writableUsersOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/assignee/new")(writableUsersOnly { repository =>
|
||||||
updateAssignedUserName(
|
val issueId = params("id").toInt
|
||||||
repository.owner,
|
registerIssueAssignee(repository.owner, repository.name, issueId, params("assigneeUserName"), true)
|
||||||
repository.name,
|
Ok()
|
||||||
params("id").toInt,
|
})
|
||||||
assignedUserName("assignedUserName"),
|
|
||||||
true
|
ajaxPost("/:owner/:repository/issues/:id/assignee/delete")(writableUsersOnly { repository =>
|
||||||
)
|
val issueId = params("id").toInt
|
||||||
Ok("updated")
|
deleteIssueAssignee(repository.owner, repository.name, issueId, params("assigneeUserName"), true)
|
||||||
|
Ok()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/milestone")(writableUsersOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/milestone")(writableUsersOnly { repository =>
|
||||||
@@ -336,8 +368,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
milestoneId("milestoneId").map { milestoneId =>
|
milestoneId("milestoneId").map { milestoneId =>
|
||||||
getMilestonesWithIssueCount(repository.owner, repository.name)
|
getMilestonesWithIssueCount(repository.owner, repository.name)
|
||||||
.find(_._1.milestoneId == milestoneId)
|
.find(_._1.milestoneId == milestoneId)
|
||||||
.map {
|
.map { case (_, openCount, closeCount) =>
|
||||||
case (_, openCount, closeCount) =>
|
|
||||||
gitbucket.core.issues.milestones.html.progress(openCount + closeCount, closeCount)
|
gitbucket.core.issues.milestones.html.progress(openCount + closeCount, closeCount)
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
} getOrElse Ok()
|
} getOrElse Ok()
|
||||||
@@ -349,9 +380,37 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
Ok("updated")
|
Ok("updated")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ajaxPost("/:owner/:repository/issues/customfield_validation/:fieldId")(writableUsersOnly { repository =>
|
||||||
|
val fieldId = params("fieldId").toInt
|
||||||
|
val value = params("value")
|
||||||
|
getCustomField(repository.owner, repository.name, fieldId)
|
||||||
|
.flatMap { field =>
|
||||||
|
CustomFieldBehavior.validate(field, value, messages).map { error =>
|
||||||
|
Ok(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.getOrElse(Ok())
|
||||||
|
})
|
||||||
|
|
||||||
|
ajaxPost("/:owner/:repository/issues/:id/customfield/:fieldId")(writableUsersOnly { repository =>
|
||||||
|
val issueId = params("id").toInt
|
||||||
|
val fieldId = params("fieldId").toInt
|
||||||
|
val value = params("value")
|
||||||
|
|
||||||
|
for {
|
||||||
|
_ <- getIssue(repository.owner, repository.name, issueId.toString)
|
||||||
|
field <- getCustomField(repository.owner, repository.name, fieldId)
|
||||||
|
} {
|
||||||
|
CustomFieldBehavior.validate(field, value, messages) match {
|
||||||
|
case None => insertOrUpdateCustomFieldValue(field, repository.owner, repository.name, issueId, value)
|
||||||
|
case Some(_) => halt(400)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(value)
|
||||||
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/state")(writableUsersOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/state")(writableUsersOnly { repository =>
|
||||||
defining(params.get("value")) {
|
val action = params.get("value")
|
||||||
action =>
|
|
||||||
action match {
|
action match {
|
||||||
case Some("open") =>
|
case Some("open") =>
|
||||||
executeBatch(repository) { issueId =>
|
executeBatch(repository) { issueId =>
|
||||||
@@ -359,14 +418,19 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
handleComment(issue, None, repository, Some("reopen"))
|
handleComment(issue, None, repository, Some("reopen"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (params("uri").nonEmpty) {
|
||||||
|
redirect(params("uri"))
|
||||||
|
}
|
||||||
case Some("close") =>
|
case Some("close") =>
|
||||||
executeBatch(repository) { issueId =>
|
executeBatch(repository) { issueId =>
|
||||||
getIssue(repository.owner, repository.name, issueId.toString).foreach { issue =>
|
getIssue(repository.owner, repository.name, issueId.toString).foreach { issue =>
|
||||||
handleComment(issue, None, repository, Some("close"))
|
handleComment(issue, None, repository, Some("close"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case _ => BadRequest()
|
if (params("uri").nonEmpty) {
|
||||||
|
redirect(params("uri"))
|
||||||
}
|
}
|
||||||
|
case _ => BadRequest()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -375,33 +439,42 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
executeBatch(repository) { issueId =>
|
executeBatch(repository) { issueId =>
|
||||||
getIssueLabel(repository.owner, repository.name, issueId, labelId) getOrElse {
|
getIssueLabel(repository.owner, repository.name, issueId, labelId) getOrElse {
|
||||||
registerIssueLabel(repository.owner, repository.name, issueId, labelId, true)
|
registerIssueLabel(repository.owner, repository.name, issueId, labelId, true)
|
||||||
|
if (params("uri").nonEmpty) {
|
||||||
|
redirect(params("uri"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/assign")(writableUsersOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/assign")(writableUsersOnly { repository =>
|
||||||
defining(assignedUserName("value")) { value =>
|
val value = assignedUserName("value")
|
||||||
executeBatch(repository) {
|
executeBatch(repository) {
|
||||||
updateAssignedUserName(repository.owner, repository.name, _, value, true)
|
// updateAssignedUserName(repository.owner, repository.name, _, value, true)
|
||||||
|
value match {
|
||||||
|
case Some(assignedUserName) =>
|
||||||
|
registerIssueAssignee(repository.owner, repository.name, _, assignedUserName, true)
|
||||||
|
case None =>
|
||||||
|
deleteAllIssueAssignees(repository.owner, repository.name, _, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (params("uri").nonEmpty) {
|
||||||
|
redirect(params("uri"))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/milestone")(writableUsersOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/milestone")(writableUsersOnly { repository =>
|
||||||
defining(milestoneId("value")) { value =>
|
val value = milestoneId("value")
|
||||||
executeBatch(repository) {
|
executeBatch(repository) {
|
||||||
updateMilestoneId(repository.owner, repository.name, _, value, true)
|
updateMilestoneId(repository.owner, repository.name, _, value, true)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/priority")(writableUsersOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/priority")(writableUsersOnly { repository =>
|
||||||
defining(priorityId("value")) { value =>
|
val value = priorityId("value")
|
||||||
executeBatch(repository) {
|
executeBatch(repository) {
|
||||||
updatePriorityId(repository.owner, repository.name, _, value, true)
|
updatePriorityId(repository.owner, repository.name, _, value, true)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/_attached/:file")(referrersOnly { repository =>
|
get("/:owner/:repository/_attached/:file")(referrersOnly { repository =>
|
||||||
@@ -415,6 +488,29 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON API for issue and PR completion.
|
||||||
|
*/
|
||||||
|
ajaxGet("/:owner/:repository/_issue/proposals")(writableUsersOnly { repository =>
|
||||||
|
contentType = formats("json")
|
||||||
|
org.json4s.jackson.Serialization.write(
|
||||||
|
Map(
|
||||||
|
"options" -> (
|
||||||
|
getOpenIssues(repository.owner, repository.name)
|
||||||
|
.map { t =>
|
||||||
|
Map(
|
||||||
|
"label" -> s"""${if (t.isPullRequest) "<i class='octicon octicon-git-pull-request'></i>"
|
||||||
|
else "<i class='octicon octicon-issue-opened'></i>"}<b> #${StringUtil
|
||||||
|
.escapeHtml(t.issueId.toString)} ${StringUtil
|
||||||
|
.escapeHtml(StringUtil.cutTail(t.title, 50, "..."))}</b>""",
|
||||||
|
"value" -> t.issueId.toString
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
val assignedUserName = (key: String) => params.get(key) filter (_.trim != "")
|
val assignedUserName = (key: String) => params.get(key) filter (_.trim != "")
|
||||||
val milestoneId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
|
val milestoneId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
|
||||||
val priorityId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
|
val priorityId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
|
||||||
@@ -424,41 +520,53 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
params("from") match {
|
params("from") match {
|
||||||
case "issues" => redirect(s"/${repository.owner}/${repository.name}/issues")
|
case "issues" => redirect(s"/${repository.owner}/${repository.name}/issues")
|
||||||
case "pulls" => redirect(s"/${repository.owner}/${repository.name}/pulls")
|
case "pulls" => redirect(s"/${repository.owner}/${repository.name}/pulls")
|
||||||
|
case _ =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def searchIssues(repository: RepositoryService.RepositoryInfo) = {
|
private def searchIssues(repository: RepositoryService.RepositoryInfo, condition: IssueSearchCondition, page: Int) = {
|
||||||
defining(repository.owner, repository.name) {
|
// search issues
|
||||||
case (owner, repoName) =>
|
val issues =
|
||||||
val page = IssueSearchCondition.page(request)
|
searchIssue(
|
||||||
|
condition,
|
||||||
// retrieve search condition
|
IssueSearchOption.Issues,
|
||||||
val condition = IssueSearchCondition(request)
|
(page - 1) * IssueLimit,
|
||||||
|
IssueLimit,
|
||||||
|
repository.owner -> repository.name
|
||||||
|
)
|
||||||
|
|
||||||
html.list(
|
html.list(
|
||||||
"issues",
|
"issues",
|
||||||
searchIssue(condition, false, (page - 1) * IssueLimit, IssueLimit, owner -> repoName),
|
issues.map(issue => (issue, None)),
|
||||||
page,
|
page,
|
||||||
getAssignableUserNames(owner, repoName),
|
getAssignableUserNames(repository.owner, repository.name),
|
||||||
getMilestones(owner, repoName),
|
getMilestones(repository.owner, repository.name),
|
||||||
getPriorities(owner, repoName),
|
getPriorities(repository.owner, repository.name),
|
||||||
getLabels(owner, repoName),
|
getLabels(repository.owner, repository.name),
|
||||||
countIssue(condition.copy(state = "open"), false, owner -> repoName),
|
countIssue(condition.copy(state = "open"), IssueSearchOption.Issues, repository.owner -> repository.name),
|
||||||
countIssue(condition.copy(state = "closed"), false, owner -> repoName),
|
countIssue(condition.copy(state = "closed"), IssueSearchOption.Issues, repository.owner -> repository.name),
|
||||||
condition,
|
condition,
|
||||||
repository,
|
repository,
|
||||||
isIssueEditable(repository),
|
isIssueEditable(repository),
|
||||||
isIssueManageable(repository)
|
isIssueManageable(repository)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether an issue or a comment is editable by a logged-in user.
|
* Tests whether an issue or a comment is editable by a logged-in user.
|
||||||
*/
|
*/
|
||||||
private def isEditableContent(owner: String, repository: String, author: String)(
|
private def isEditableContent(owner: String, repository: String, author: String, loginAccount: Account)(implicit
|
||||||
implicit context: Context
|
context: Context
|
||||||
): Boolean = {
|
): Boolean = {
|
||||||
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
hasDeveloperRole(owner, repository, context.loginAccount) || author == loginAccount.userName
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an issue comment is deletable by a logged-in user.
|
||||||
|
*/
|
||||||
|
private def isDeletableComment(owner: String, repository: String, author: String, loginAccount: Account)(implicit
|
||||||
|
context: Context
|
||||||
|
): Boolean = {
|
||||||
|
hasOwnerRole(owner, repository, context.loginAccount) || author == loginAccount.userName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
get("/:owner/:repository/issues/labels")(referrersOnly { repository =>
|
get("/:owner/:repository/issues/labels")(referrersOnly { repository =>
|
||||||
html.list(
|
html.list(
|
||||||
getLabels(repository.owner, repository.name),
|
getLabels(repository.owner, repository.name),
|
||||||
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
@@ -59,7 +59,7 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
html.label(
|
html.label(
|
||||||
getLabel(repository.owner, repository.name, labelId).get,
|
getLabel(repository.owner, repository.name, labelId).get,
|
||||||
// TODO futility
|
// TODO futility
|
||||||
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
@@ -76,7 +76,7 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
html.label(
|
html.label(
|
||||||
getLabel(repository.owner, repository.name, params("labelId").toInt).get,
|
getLabel(repository.owner, repository.name, params("labelId").toInt).get,
|
||||||
// TODO futility
|
// TODO futility
|
||||||
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,26 +1,41 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.issues.milestones.html
|
import gitbucket.core.issues.milestones.html
|
||||||
import gitbucket.core.service.{RepositoryService, MilestonesService, AccountService}
|
import gitbucket.core.service.IssuesService.{IssueLimit, IssueSearchCondition}
|
||||||
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
import gitbucket.core.service.{
|
||||||
|
AccountService,
|
||||||
|
CommitStatusService,
|
||||||
|
IssueSearchOption,
|
||||||
|
MilestonesService,
|
||||||
|
RepositoryService
|
||||||
|
}
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
|
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
||||||
|
import gitbucket.core.util.SyntaxSugars._
|
||||||
|
import gitbucket.core.view.helpers.{getAssignableUserNames, getLabels, getPriorities, searchIssue}
|
||||||
import org.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
|
import org.scalatra.i18n.Messages
|
||||||
|
|
||||||
class MilestonesController
|
class MilestonesController
|
||||||
extends MilestonesControllerBase
|
extends MilestonesControllerBase
|
||||||
with MilestonesService
|
with MilestonesService
|
||||||
with RepositoryService
|
with RepositoryService
|
||||||
with AccountService
|
with AccountService
|
||||||
|
with CommitStatusService
|
||||||
with ReferrerAuthenticator
|
with ReferrerAuthenticator
|
||||||
with WritableUsersAuthenticator
|
with WritableUsersAuthenticator
|
||||||
|
|
||||||
trait MilestonesControllerBase extends ControllerBase {
|
trait MilestonesControllerBase extends ControllerBase {
|
||||||
self: MilestonesService with RepositoryService with ReferrerAuthenticator with WritableUsersAuthenticator =>
|
self: MilestonesService
|
||||||
|
with RepositoryService
|
||||||
|
with CommitStatusService
|
||||||
|
with ReferrerAuthenticator
|
||||||
|
with WritableUsersAuthenticator =>
|
||||||
|
|
||||||
case class MilestoneForm(title: String, description: Option[String], dueDate: Option[java.util.Date])
|
case class MilestoneForm(title: String, description: Option[String], dueDate: Option[java.util.Date])
|
||||||
|
|
||||||
val milestoneForm = mapping(
|
val milestoneForm = mapping(
|
||||||
"title" -> trim(label("Title", text(required, maxlength(100)))),
|
"title" -> trim(label("Title", text(required, maxlength(100), uniqueMilestone))),
|
||||||
"description" -> trim(label("Description", optional(text()))),
|
"description" -> trim(label("Description", optional(text()))),
|
||||||
"dueDate" -> trim(label("Due Date", optional(date())))
|
"dueDate" -> trim(label("Due Date", optional(date())))
|
||||||
)(MilestoneForm.apply)
|
)(MilestoneForm.apply)
|
||||||
@@ -34,6 +49,41 @@ trait MilestonesControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
get("/:owner/:repository/milestone/:id")(referrersOnly { repository =>
|
||||||
|
val milestone = getMilestone(repository.owner, repository.name, params("id").toInt)
|
||||||
|
val page = IssueSearchCondition.page(request)
|
||||||
|
val condition = IssueSearchCondition(
|
||||||
|
request,
|
||||||
|
milestone.get.title
|
||||||
|
)
|
||||||
|
val issues = searchIssue(
|
||||||
|
condition,
|
||||||
|
IssueSearchOption.Both,
|
||||||
|
(page - 1) * IssueLimit,
|
||||||
|
IssueLimit,
|
||||||
|
repository.owner -> repository.name
|
||||||
|
)
|
||||||
|
val status = issues.map { issue =>
|
||||||
|
issue.commitId.flatMap { commitId =>
|
||||||
|
getCommitStatusWithSummary(issue.issue.userName, issue.issue.repositoryName, commitId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html.milestone(
|
||||||
|
condition.state,
|
||||||
|
issues.zip(status),
|
||||||
|
page,
|
||||||
|
getAssignableUserNames(repository.owner, repository.name),
|
||||||
|
getPriorities(repository.owner, repository.name),
|
||||||
|
getLabels(repository.owner, repository.name),
|
||||||
|
condition,
|
||||||
|
getMilestonesWithIssueCount(repository.owner, repository.name)
|
||||||
|
.filter(p => p._1.milestoneId == milestone.get.milestoneId),
|
||||||
|
repository,
|
||||||
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/new")(writableUsersOnly {
|
get("/:owner/:repository/issues/milestones/new")(writableUsersOnly {
|
||||||
html.edit(None, _)
|
html.edit(None, _)
|
||||||
})
|
})
|
||||||
@@ -86,4 +136,29 @@ trait MilestonesControllerBase extends ControllerBase {
|
|||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
private def uniqueMilestone: Constraint = new Constraint() {
|
||||||
|
override def validate(
|
||||||
|
name: String,
|
||||||
|
value: String,
|
||||||
|
params: Map[String, Seq[String]],
|
||||||
|
messages: Messages
|
||||||
|
): Option[String] = {
|
||||||
|
for {
|
||||||
|
owner <- params.optionValue("owner")
|
||||||
|
repository <- params.optionValue("repository")
|
||||||
|
_ <- params.optionValue("milestoneId") match {
|
||||||
|
// existing milestone
|
||||||
|
case Some(id) =>
|
||||||
|
getMilestones(owner, repository)
|
||||||
|
.find(m => m.title.equalsIgnoreCase(value) && m.milestoneId.toString != id)
|
||||||
|
// new milestone
|
||||||
|
case None =>
|
||||||
|
getMilestones(owner, repository)
|
||||||
|
.find(m => m.title.equalsIgnoreCase(value))
|
||||||
|
}
|
||||||
|
} yield {
|
||||||
|
"Milestone already exists."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,12 +29,15 @@ trait PreProcessControllerBase extends ControllerBase {
|
|||||||
* If anonymous access is allowed, pass all requests.
|
* If anonymous access is allowed, pass all requests.
|
||||||
* But if it's not allowed, demands authentication except some paths.
|
* But if it's not allowed, demands authentication except some paths.
|
||||||
*/
|
*/
|
||||||
get(!context.settings.allowAnonymousAccess, context.loginAccount.isEmpty) {
|
get(!context.settings.basicBehavior.allowAnonymousAccess, context.loginAccount.isEmpty) {
|
||||||
if (!context.currentPath.startsWith("/assets") && !context.currentPath.startsWith("/signin") &&
|
if (
|
||||||
|
!context.currentPath.startsWith("/assets") && !context.currentPath.startsWith("/signin") &&
|
||||||
!context.currentPath.startsWith("/register") && !context.currentPath.endsWith("/info/refs") &&
|
!context.currentPath.startsWith("/register") && !context.currentPath.endsWith("/info/refs") &&
|
||||||
|
!context.currentPath.startsWith("/plugin-assets") &&
|
||||||
!PluginRegistry().getAnonymousAccessiblePaths().exists { path =>
|
!PluginRegistry().getAnonymousAccessiblePaths().exists { path =>
|
||||||
context.currentPath.startsWith(path)
|
context.currentPath.startsWith(path)
|
||||||
}) {
|
}
|
||||||
|
) {
|
||||||
Unauthorized()
|
Unauthorized()
|
||||||
} else {
|
} else {
|
||||||
pass()
|
pass()
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ trait PrioritiesControllerBase extends ControllerBase {
|
|||||||
get("/:owner/:repository/issues/priorities")(referrersOnly { repository =>
|
get("/:owner/:repository/issues/priorities")(referrersOnly { repository =>
|
||||||
html.list(
|
html.list(
|
||||||
getPriorities(repository.owner, repository.name),
|
getPriorities(repository.owner, repository.name),
|
||||||
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
@@ -60,7 +60,7 @@ trait PrioritiesControllerBase extends ControllerBase {
|
|||||||
createPriority(repository.owner, repository.name, form.priorityName, form.description, form.color.substring(1))
|
createPriority(repository.owner, repository.name, form.priorityName, form.description, form.color.substring(1))
|
||||||
html.priority(
|
html.priority(
|
||||||
getPriority(repository.owner, repository.name, priorityId).get,
|
getPriority(repository.owner, repository.name, priorityId).get,
|
||||||
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
@@ -84,7 +84,7 @@ trait PrioritiesControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
html.priority(
|
html.priority(
|
||||||
getPriority(repository.owner, repository.name, params("priorityId").toInt).get,
|
getPriority(repository.owner, repository.name, params("priorityId").toInt).get,
|
||||||
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.model.{CommitComment, CommitComments, IssueComment, WebHook}
|
import gitbucket.core.model.activity.DeleteBranchInfo
|
||||||
import gitbucket.core.plugin.PluginRegistry
|
|
||||||
import gitbucket.core.pulls.html
|
import gitbucket.core.pulls.html
|
||||||
import gitbucket.core.service.CommitStatusService
|
import gitbucket.core.service.CommitStatusService
|
||||||
import gitbucket.core.service.MergeService
|
import gitbucket.core.service.MergeService
|
||||||
@@ -9,17 +8,14 @@ import gitbucket.core.service.IssuesService._
|
|||||||
import gitbucket.core.service.PullRequestService._
|
import gitbucket.core.service.PullRequestService._
|
||||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.SyntaxSugars._
|
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
import org.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.lib.{ObjectId, PersonIdent}
|
|
||||||
import org.eclipse.jgit.revwalk.RevWalk
|
|
||||||
import org.scalatra.BadRequest
|
import org.scalatra.BadRequest
|
||||||
|
|
||||||
import scala.collection.JavaConverters._
|
import scala.util.Using
|
||||||
|
|
||||||
class PullRequestsController
|
class PullRequestsController
|
||||||
extends PullRequestsControllerBase
|
extends PullRequestsControllerBase
|
||||||
@@ -29,6 +25,7 @@ class PullRequestsController
|
|||||||
with PullRequestService
|
with PullRequestService
|
||||||
with MilestonesService
|
with MilestonesService
|
||||||
with LabelsService
|
with LabelsService
|
||||||
|
with CustomFieldsService
|
||||||
with CommitsService
|
with CommitsService
|
||||||
with ActivityService
|
with ActivityService
|
||||||
with WebHookPullRequestService
|
with WebHookPullRequestService
|
||||||
@@ -40,6 +37,7 @@ class PullRequestsController
|
|||||||
with MergeService
|
with MergeService
|
||||||
with ProtectedBranchService
|
with ProtectedBranchService
|
||||||
with PrioritiesService
|
with PrioritiesService
|
||||||
|
with RequestCache
|
||||||
|
|
||||||
trait PullRequestsControllerBase extends ControllerBase {
|
trait PullRequestsControllerBase extends ControllerBase {
|
||||||
self: RepositoryService
|
self: RepositoryService
|
||||||
@@ -47,6 +45,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
with IssuesService
|
with IssuesService
|
||||||
with MilestonesService
|
with MilestonesService
|
||||||
with LabelsService
|
with LabelsService
|
||||||
|
with CustomFieldsService
|
||||||
with CommitsService
|
with CommitsService
|
||||||
with ActivityService
|
with ActivityService
|
||||||
with PullRequestService
|
with PullRequestService
|
||||||
@@ -60,7 +59,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
with PrioritiesService =>
|
with PrioritiesService =>
|
||||||
|
|
||||||
val pullRequestForm = mapping(
|
val pullRequestForm = mapping(
|
||||||
"title" -> trim(label("Title", text(required, maxlength(100)))),
|
"title" -> trim(label("Title", text(required))),
|
||||||
"content" -> trim(label("Content", optional(text()))),
|
"content" -> trim(label("Content", optional(text()))),
|
||||||
"targetUserName" -> trim(text(required, maxlength(100))),
|
"targetUserName" -> trim(text(required, maxlength(100))),
|
||||||
"targetBranch" -> trim(text(required, maxlength(100))),
|
"targetBranch" -> trim(text(required, maxlength(100))),
|
||||||
@@ -69,7 +68,8 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
"requestBranch" -> trim(text(required, maxlength(100))),
|
"requestBranch" -> trim(text(required, maxlength(100))),
|
||||||
"commitIdFrom" -> trim(text(required, maxlength(40))),
|
"commitIdFrom" -> trim(text(required, maxlength(40))),
|
||||||
"commitIdTo" -> trim(text(required, maxlength(40))),
|
"commitIdTo" -> trim(text(required, maxlength(40))),
|
||||||
"assignedUserName" -> trim(optional(text())),
|
"isDraft" -> trim(boolean(required)),
|
||||||
|
"assigneeUserNames" -> trim(optional(text())),
|
||||||
"milestoneId" -> trim(optional(number())),
|
"milestoneId" -> trim(optional(number())),
|
||||||
"priorityId" -> trim(optional(number())),
|
"priorityId" -> trim(optional(number())),
|
||||||
"labelNames" -> trim(optional(text()))
|
"labelNames" -> trim(optional(text()))
|
||||||
@@ -77,7 +77,8 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
val mergeForm = mapping(
|
val mergeForm = mapping(
|
||||||
"message" -> trim(label("Message", text(required))),
|
"message" -> trim(label("Message", text(required))),
|
||||||
"strategy" -> trim(label("Strategy", text(required)))
|
"strategy" -> trim(label("Strategy", text(required))),
|
||||||
|
"isDraft" -> trim(boolean(required))
|
||||||
)(MergeForm.apply)
|
)(MergeForm.apply)
|
||||||
|
|
||||||
case class PullRequestForm(
|
case class PullRequestForm(
|
||||||
@@ -90,89 +91,96 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
requestBranch: String,
|
requestBranch: String,
|
||||||
commitIdFrom: String,
|
commitIdFrom: String,
|
||||||
commitIdTo: String,
|
commitIdTo: String,
|
||||||
assignedUserName: Option[String],
|
isDraft: Boolean,
|
||||||
|
assigneeUserNames: Option[String],
|
||||||
milestoneId: Option[Int],
|
milestoneId: Option[Int],
|
||||||
priorityId: Option[Int],
|
priorityId: Option[Int],
|
||||||
labelNames: Option[String]
|
labelNames: Option[String]
|
||||||
)
|
)
|
||||||
|
|
||||||
case class MergeForm(message: String, strategy: String)
|
case class MergeForm(message: String, strategy: String, isDraft: Boolean)
|
||||||
|
|
||||||
get("/:owner/:repository/pulls")(referrersOnly { repository =>
|
get("/:owner/:repository/pulls")(referrersOnly { repository =>
|
||||||
val q = request.getParameter("q")
|
val q = request.getParameter("q")
|
||||||
if (Option(q).exists(_.contains("is:issue"))) {
|
Option(q) match {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues?q=" + StringUtil.urlEncode(q))
|
case Some(filter) if filter.contains("is:issue") =>
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/issues?q=${StringUtil.urlEncode(q)}")
|
||||||
|
case Some(filter) =>
|
||||||
|
val condition = IssueSearchCondition(filter)
|
||||||
|
if (condition.isEmpty) {
|
||||||
|
// Redirect to keyword search
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/search?q=${StringUtil.urlEncode(q)}&type=pulls")
|
||||||
} else {
|
} else {
|
||||||
searchPullRequests(None, repository)
|
searchPullRequests(repository, IssueSearchCondition(filter), IssueSearchCondition.page(request))
|
||||||
|
}
|
||||||
|
case None =>
|
||||||
|
searchPullRequests(repository, IssueSearchCondition(request), IssueSearchCondition.page(request))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/pull/:id")(referrersOnly { repository =>
|
get("/:owner/:repository/pull/:id")(referrersOnly { repository =>
|
||||||
params("id").toIntOpt.flatMap {
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
issueId =>
|
getPullRequest(repository.owner, repository.name, issueId) map { case (issue, pullreq) =>
|
||||||
val owner = repository.owner
|
|
||||||
val name = repository.name
|
|
||||||
getPullRequest(owner, name, issueId) map {
|
|
||||||
case (issue, pullreq) =>
|
|
||||||
val (commits, diffs) =
|
val (commits, diffs) =
|
||||||
getRequestCompareInfo(owner, name, pullreq.commitIdFrom, owner, name, pullreq.commitIdTo)
|
getRequestCompareInfo(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
pullreq.commitIdFrom,
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
pullreq.commitIdTo,
|
||||||
|
context.settings
|
||||||
|
)
|
||||||
|
|
||||||
html.conversation(
|
html.conversation(
|
||||||
issue,
|
issue,
|
||||||
pullreq,
|
pullreq,
|
||||||
commits.flatten,
|
commits.flatten,
|
||||||
getPullRequestComments(owner, name, issue.issueId, commits.flatten),
|
getPullRequestComments(repository.owner, repository.name, issue.issueId, commits.flatten),
|
||||||
diffs.size,
|
diffs.size,
|
||||||
getIssueLabels(owner, name, issueId),
|
getIssueLabels(repository.owner, repository.name, issueId),
|
||||||
getAssignableUserNames(owner, name),
|
getIssueAssignees(repository.owner, repository.name, issueId),
|
||||||
getMilestonesWithIssueCount(owner, name),
|
getAssignableUserNames(repository.owner, repository.name),
|
||||||
getPriorities(owner, name),
|
getMilestonesWithIssueCount(repository.owner, repository.name),
|
||||||
getLabels(owner, name),
|
getPriorities(repository.owner, repository.name),
|
||||||
|
getLabels(repository.owner, repository.name),
|
||||||
|
getCustomFieldsWithValue(repository.owner, repository.name, issueId).filter(_._1.enableForPullRequests),
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
isManageable(repository),
|
isManageable(repository),
|
||||||
hasDeveloperRole(pullreq.requestUserName, pullreq.requestRepositoryName, context.loginAccount),
|
hasDeveloperRole(pullreq.requestUserName, pullreq.requestRepositoryName, context.loginAccount),
|
||||||
repository,
|
repository,
|
||||||
getRepository(pullreq.requestUserName, pullreq.requestRepositoryName),
|
getRepository(pullreq.requestUserName, pullreq.requestRepositoryName),
|
||||||
flash.toMap.map(f => f._1 -> f._2.toString)
|
flash.iterator.map(f => f._1 -> f._2.toString).toMap
|
||||||
)
|
)
|
||||||
|
|
||||||
// html.pullreq(
|
|
||||||
// issue,
|
|
||||||
// pullreq,
|
|
||||||
// comments,
|
|
||||||
// getIssueLabels(owner, name, issueId),
|
|
||||||
// getAssignableUserNames(owner, name),
|
|
||||||
// getMilestonesWithIssueCount(owner, name),
|
|
||||||
// getPriorities(owner, name),
|
|
||||||
// getLabels(owner, name),
|
|
||||||
// commits,
|
|
||||||
// diffs,
|
|
||||||
// isEditable(repository),
|
|
||||||
// isManageable(repository),
|
|
||||||
// hasDeveloperRole(pullreq.requestUserName, pullreq.requestRepositoryName, context.loginAccount),
|
|
||||||
// repository,
|
|
||||||
// getRepository(pullreq.requestUserName, pullreq.requestRepositoryName),
|
|
||||||
// flash.toMap.map(f => f._1 -> f._2.toString)
|
|
||||||
// )
|
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/pull/:id/commits")(referrersOnly { repository =>
|
get("/:owner/:repository/pull/:id/commits")(referrersOnly { repository =>
|
||||||
params("id").toIntOpt.flatMap {
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
issueId =>
|
getPullRequest(repository.owner, repository.name, issueId) map { case (issue, pullreq) =>
|
||||||
val owner = repository.owner
|
|
||||||
val name = repository.name
|
|
||||||
getPullRequest(owner, name, issueId) map {
|
|
||||||
case (issue, pullreq) =>
|
|
||||||
val (commits, diffs) =
|
val (commits, diffs) =
|
||||||
getRequestCompareInfo(owner, name, pullreq.commitIdFrom, owner, name, pullreq.commitIdTo)
|
getRequestCompareInfo(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
pullreq.commitIdFrom,
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
pullreq.commitIdTo,
|
||||||
|
context.settings
|
||||||
|
)
|
||||||
|
|
||||||
|
val commitsWithStatus = commits.map { day =>
|
||||||
|
day.map { commit =>
|
||||||
|
(commit, getCommitStatusWithSummary(repository.owner, repository.name, commit.id))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
html.commits(
|
html.commits(
|
||||||
issue,
|
issue,
|
||||||
pullreq,
|
pullreq,
|
||||||
commits,
|
commitsWithStatus,
|
||||||
getPullRequestComments(owner, name, issue.issueId, commits.flatten),
|
getPullRequestComments(repository.owner, repository.name, issue.issueId, commits.flatten),
|
||||||
diffs.size,
|
diffs.size,
|
||||||
isManageable(repository),
|
isManageable(repository),
|
||||||
repository
|
repository
|
||||||
@@ -182,21 +190,25 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/pull/:id/files")(referrersOnly { repository =>
|
get("/:owner/:repository/pull/:id/files")(referrersOnly { repository =>
|
||||||
params("id").toIntOpt.flatMap {
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
issueId =>
|
getPullRequest(repository.owner, repository.name, issueId) map { case (issue, pullreq) =>
|
||||||
val owner = repository.owner
|
|
||||||
val name = repository.name
|
|
||||||
getPullRequest(owner, name, issueId) map {
|
|
||||||
case (issue, pullreq) =>
|
|
||||||
val (commits, diffs) =
|
val (commits, diffs) =
|
||||||
getRequestCompareInfo(owner, name, pullreq.commitIdFrom, owner, name, pullreq.commitIdTo)
|
getRequestCompareInfo(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
pullreq.commitIdFrom,
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
pullreq.commitIdTo,
|
||||||
|
context.settings
|
||||||
|
)
|
||||||
|
|
||||||
html.files(
|
html.files(
|
||||||
issue,
|
issue,
|
||||||
pullreq,
|
pullreq,
|
||||||
diffs,
|
diffs,
|
||||||
commits.flatten,
|
commits.flatten,
|
||||||
getPullRequestComments(owner, name, issue.issueId, commits.flatten),
|
getPullRequestComments(repository.owner, repository.name, issue.issueId, commits.flatten),
|
||||||
isManageable(repository),
|
isManageable(repository),
|
||||||
repository
|
repository
|
||||||
)
|
)
|
||||||
@@ -205,41 +217,34 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/pull/:id/mergeguide")(referrersOnly { repository =>
|
ajaxGet("/:owner/:repository/pull/:id/mergeguide")(referrersOnly { repository =>
|
||||||
params("id").toIntOpt.flatMap {
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
issueId =>
|
getPullRequest(repository.owner, repository.name, issueId) map { case (issue, pullreq) =>
|
||||||
val owner = repository.owner
|
val conflictMessage = LockUtil.lock(s"${repository.owner}/${repository.name}") {
|
||||||
val name = repository.name
|
checkConflict(repository.owner, repository.name, pullreq.branch, issueId)
|
||||||
getPullRequest(owner, name, issueId) map {
|
|
||||||
case (issue, pullreq) =>
|
|
||||||
val conflictMessage = LockUtil.lock(s"${owner}/${name}") {
|
|
||||||
checkConflict(owner, name, pullreq.branch, issueId)
|
|
||||||
}
|
}
|
||||||
val hasMergePermission = hasDeveloperRole(owner, name, context.loginAccount)
|
val hasMergePermission = hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.branch)
|
val branchProtection = getProtectedBranchInfo(repository.owner, repository.name, pullreq.branch)
|
||||||
val mergeStatus = PullRequestService.MergeStatus(
|
val mergeStatus = PullRequestService.MergeStatus(
|
||||||
conflictMessage = conflictMessage,
|
conflictMessage = conflictMessage,
|
||||||
commitStatues = getCommitStatues(owner, name, pullreq.commitIdTo),
|
commitStatuses = getCommitStatuses(repository.owner, repository.name, pullreq.commitIdTo),
|
||||||
branchProtection = branchProtection,
|
branchProtection = branchProtection,
|
||||||
branchIsOutOfDate = JGitUtil.getShaByRef(owner, name, pullreq.branch) != Some(pullreq.commitIdFrom),
|
branchIsOutOfDate =
|
||||||
needStatusCheck = context.loginAccount
|
!JGitUtil.getShaByRef(repository.owner, repository.name, pullreq.branch).contains(pullreq.commitIdFrom),
|
||||||
.map { u =>
|
needStatusCheck = context.loginAccount.forall { u =>
|
||||||
branchProtection.needStatusCheck(u.userName)
|
branchProtection.needStatusCheck(u.userName)
|
||||||
}
|
},
|
||||||
.getOrElse(true),
|
|
||||||
hasUpdatePermission = hasDeveloperRole(
|
hasUpdatePermission = hasDeveloperRole(
|
||||||
pullreq.requestUserName,
|
pullreq.requestUserName,
|
||||||
pullreq.requestRepositoryName,
|
pullreq.requestRepositoryName,
|
||||||
context.loginAccount
|
context.loginAccount
|
||||||
) &&
|
) &&
|
||||||
context.loginAccount
|
context.loginAccount.exists { u =>
|
||||||
.map { u =>
|
|
||||||
!getProtectedBranchInfo(
|
!getProtectedBranchInfo(
|
||||||
pullreq.requestUserName,
|
pullreq.requestUserName,
|
||||||
pullreq.requestRepositoryName,
|
pullreq.requestRepositoryName,
|
||||||
pullreq.requestBranch
|
pullreq.requestBranch
|
||||||
).needStatusCheck(u.userName)
|
).needStatusCheck(u.userName)
|
||||||
}
|
},
|
||||||
.getOrElse(false),
|
|
||||||
hasMergePermission = hasMergePermission,
|
hasMergePermission = hasMergePermission,
|
||||||
commitIdTo = pullreq.commitIdTo
|
commitIdTo = pullreq.commitIdTo
|
||||||
)
|
)
|
||||||
@@ -266,13 +271,14 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
val repository = getRepository(owner, name).get
|
val repository = getRepository(owner, name).get
|
||||||
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.requestBranch)
|
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.requestBranch)
|
||||||
if (branchProtection.enabled) {
|
if (branchProtection.enabled) {
|
||||||
flash += "error" -> s"branch ${pullreq.requestBranch} is protected."
|
flash.update("error", s"branch ${pullreq.requestBranch} is protected.")
|
||||||
} else {
|
} else {
|
||||||
if (repository.repository.defaultBranch != pullreq.requestBranch) {
|
if (repository.repository.defaultBranch != pullreq.requestBranch) {
|
||||||
val userName = context.loginAccount.get.userName
|
val userName = context.loginAccount.get.userName
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git.branchDelete().setForce(true).setBranchNames(pullreq.requestBranch).call()
|
git.branchDelete().setForce(true).setBranchNames(pullreq.requestBranch).call()
|
||||||
recordDeleteBranchActivity(repository.owner, repository.name, userName, pullreq.requestBranch)
|
val deleteBranchInfo = DeleteBranchInfo(repository.owner, repository.name, userName, pullreq.requestBranch)
|
||||||
|
recordActivity(deleteBranchInfo)
|
||||||
}
|
}
|
||||||
createComment(
|
createComment(
|
||||||
baseRepository.owner,
|
baseRepository.owner,
|
||||||
@@ -283,9 +289,10 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
"delete_branch"
|
"delete_branch"
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
flash += "error" -> s"""Can't delete the default branch "${pullreq.requestBranch}"."""
|
flash.update("error", s"""Can't delete the default branch "${pullreq.requestBranch}".""")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(s"/${baseRepository.owner}/${baseRepository.name}/pull/${issueId}")
|
redirect(s"/${baseRepository.owner}/${baseRepository.name}/pull/${issueId}")
|
||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
@@ -303,18 +310,22 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
} yield {
|
} yield {
|
||||||
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.requestBranch)
|
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.requestBranch)
|
||||||
if (branchProtection.needStatusCheck(loginAccount.userName)) {
|
if (branchProtection.needStatusCheck(loginAccount.userName)) {
|
||||||
flash += "error" -> s"branch ${pullreq.requestBranch} is protected need status check."
|
flash.update("error", s"branch ${pullreq.requestBranch} is protected need status check.")
|
||||||
} else {
|
} else {
|
||||||
LockUtil.lock(s"${owner}/${name}") {
|
LockUtil.lock(s"${owner}/${name}") {
|
||||||
val alias =
|
val alias =
|
||||||
if (pullreq.repositoryName == pullreq.requestRepositoryName && pullreq.userName == pullreq.requestUserName) {
|
if (
|
||||||
|
pullreq.repositoryName == pullreq.requestRepositoryName && pullreq.userName == pullreq.requestUserName
|
||||||
|
) {
|
||||||
pullreq.branch
|
pullreq.branch
|
||||||
} else {
|
} else {
|
||||||
s"${pullreq.userName}:${pullreq.branch}"
|
s"${pullreq.userName}:${pullreq.branch}"
|
||||||
}
|
}
|
||||||
val existIds = using(Git.open(Directory.getRepositoryDir(owner, name))) { git =>
|
val existIds = Using
|
||||||
|
.resource(Git.open(Directory.getRepositoryDir(owner, name))) { git =>
|
||||||
JGitUtil.getAllCommitIds(git)
|
JGitUtil.getAllCommitIds(git)
|
||||||
}.toSet
|
}
|
||||||
|
.toSet
|
||||||
pullRemote(
|
pullRemote(
|
||||||
repository,
|
repository,
|
||||||
pullreq.requestBranch,
|
pullreq.requestBranch,
|
||||||
@@ -322,14 +333,15 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
pullreq.branch,
|
pullreq.branch,
|
||||||
loginAccount,
|
loginAccount,
|
||||||
s"Merge branch '${alias}' into ${pullreq.requestBranch}",
|
s"Merge branch '${alias}' into ${pullreq.requestBranch}",
|
||||||
Some(pullreq)
|
Some(pullreq),
|
||||||
|
context.settings
|
||||||
) match {
|
) match {
|
||||||
case None => // conflict
|
case None => // conflict
|
||||||
flash += "error" -> s"Can't automatic merging branch '${alias}' into ${pullreq.requestBranch}."
|
flash.update("error", s"Can't automatic merging branch '${alias}' into ${pullreq.requestBranch}.")
|
||||||
case Some(oldId) =>
|
case Some(oldId) =>
|
||||||
// update pull request
|
// update pull request
|
||||||
updatePullRequests(owner, name, pullreq.requestBranch, loginAccount, "synchronize")
|
updatePullRequests(owner, name, pullreq.requestBranch, loginAccount, "synchronize", context.settings)
|
||||||
flash += "info" -> s"Merge branch '${alias}' into ${pullreq.requestBranch}"
|
flash.update("info", s"Merge branch '${alias}' into ${pullreq.requestBranch}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,25 +350,43 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/pull/:id/merge", mergeForm)(writableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/pull/:id/update_draft")(readableUsersOnly { baseRepository =>
|
||||||
params("id").toIntOpt.flatMap { issueId =>
|
(for {
|
||||||
val owner = repository.owner
|
issueId <- params("id").toIntOpt
|
||||||
val name = repository.name
|
(_, pullreq) <- getPullRequest(baseRepository.owner, baseRepository.name, issueId)
|
||||||
|
owner = pullreq.requestUserName
|
||||||
|
name = pullreq.requestRepositoryName
|
||||||
|
if hasDeveloperRole(owner, name, context.loginAccount)
|
||||||
|
} yield {
|
||||||
|
updateDraftToPullRequest(baseRepository.owner, baseRepository.name, issueId)
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
mergePullRequest(repository, issueId, context.loginAccount.get, form.message, form.strategy) match {
|
post("/:owner/:repository/pull/:id/merge", mergeForm)(writableUsersOnly { (form, repository) =>
|
||||||
case Right(objectId) => redirect(s"/${owner}/${name}/pull/${issueId}")
|
context.withLoginAccount { loginAccount =>
|
||||||
case Left(message) => Some(BadRequest())
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
|
mergePullRequest(
|
||||||
|
repository,
|
||||||
|
issueId,
|
||||||
|
loginAccount,
|
||||||
|
form.message,
|
||||||
|
form.strategy,
|
||||||
|
form.isDraft,
|
||||||
|
context.settings
|
||||||
|
) match {
|
||||||
|
case Right(objectId) => redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
|
case Left(message) => Some(BadRequest(message))
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/compare")(referrersOnly { forkedRepository =>
|
get("/:owner/:repository/compare")(referrersOnly { forkedRepository =>
|
||||||
val headBranch: Option[String] = params.get("head")
|
val headBranch = params.get("head")
|
||||||
(forkedRepository.repository.originUserName, forkedRepository.repository.originRepositoryName) match {
|
(forkedRepository.repository.originUserName, forkedRepository.repository.originRepositoryName) match {
|
||||||
case (Some(originUserName), Some(originRepositoryName)) => {
|
case (Some(originUserName), Some(originRepositoryName)) =>
|
||||||
getRepository(originUserName, originRepositoryName).map {
|
getRepository(originUserName, originRepositoryName).map { originRepository =>
|
||||||
originRepository =>
|
Using.resources(
|
||||||
using(
|
|
||||||
Git.open(getRepositoryDir(originUserName, originRepositoryName)),
|
Git.open(getRepositoryDir(originUserName, originRepositoryName)),
|
||||||
Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))
|
Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))
|
||||||
) { (oldGit, newGit) =>
|
) { (oldGit, newGit) =>
|
||||||
@@ -370,11 +400,9 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
case _ =>
|
||||||
case _ => {
|
Using.resource(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))) { git =>
|
||||||
using(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))) { git =>
|
JGitUtil.getDefaultBranch(git, forkedRepository).map { case (_, defaultBranch) =>
|
||||||
JGitUtil.getDefaultBranch(git, forkedRepository).map {
|
|
||||||
case (_, defaultBranch) =>
|
|
||||||
redirect(
|
redirect(
|
||||||
s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${defaultBranch}...${headBranch.getOrElse(defaultBranch)}"
|
s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${defaultBranch}...${headBranch.getOrElse(defaultBranch)}"
|
||||||
)
|
)
|
||||||
@@ -383,15 +411,14 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/compare/*...*")(referrersOnly { forkedRepository =>
|
private def getOriginRepositoryName(
|
||||||
val Seq(origin, forked) = multiParams("splat")
|
originOwner: String,
|
||||||
val (originOwner, originId) = parseCompareIdentifier(origin, forkedRepository.owner)
|
forkedOwner: String,
|
||||||
val (forkedOwner, forkedId) = parseCompareIdentifier(forked, forkedRepository.owner)
|
forkedRepository: RepositoryInfo
|
||||||
|
): Option[String] = {
|
||||||
(for (originRepositoryName <- if (originOwner == forkedOwner) {
|
if (originOwner == forkedOwner) {
|
||||||
// Self repository
|
// Self repository
|
||||||
Some(forkedRepository.name)
|
Some(forkedRepository.name)
|
||||||
} else if (forkedRepository.repository.originUserName.isEmpty) {
|
} else if (forkedRepository.repository.originUserName.isEmpty) {
|
||||||
@@ -410,20 +437,31 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
x.repository.originRepositoryName == forkedRepository.repository.originRepositoryName
|
x.repository.originRepositoryName == forkedRepository.repository.originRepositoryName
|
||||||
}
|
}
|
||||||
.map(_.repository.repositoryName)
|
.map(_.repository.repositoryName)
|
||||||
};
|
}
|
||||||
originRepository <- getRepository(originOwner, originRepositoryName)) yield {
|
}
|
||||||
|
|
||||||
|
get("/:owner/:repository/compare/*...*")(referrersOnly { forkedRepository =>
|
||||||
|
val Seq(origin, forked) = multiParams("splat")
|
||||||
|
val (originOwner, originId) = parseCompareIdentifier(origin, forkedRepository.owner)
|
||||||
|
val (forkedOwner, forkedId) = parseCompareIdentifier(forked, forkedRepository.owner)
|
||||||
|
|
||||||
|
(for (
|
||||||
|
originRepositoryName <- getOriginRepositoryName(originOwner, forkedOwner, forkedRepository);
|
||||||
|
originRepository <- getRepository(originOwner, originRepositoryName)
|
||||||
|
) yield {
|
||||||
val (oldId, newId) =
|
val (oldId, newId) =
|
||||||
getPullRequestCommitFromTo(originRepository, forkedRepository, originId, forkedId)
|
getPullRequestCommitFromTo(originRepository, forkedRepository, originId, forkedId)
|
||||||
|
|
||||||
(oldId, newId) match {
|
(oldId, newId) match {
|
||||||
case (Some(oldId), Some(newId)) => {
|
case (Some(oldId), Some(newId)) =>
|
||||||
val (commits, diffs) = getRequestCompareInfo(
|
val (commits, diffs) = getRequestCompareInfo(
|
||||||
originRepository.owner,
|
originRepository.owner,
|
||||||
originRepository.name,
|
originRepository.name,
|
||||||
oldId.getName,
|
oldId.getName,
|
||||||
forkedRepository.owner,
|
forkedRepository.owner,
|
||||||
forkedRepository.name,
|
forkedRepository.name,
|
||||||
newId.getName
|
newId.getName,
|
||||||
|
context.settings
|
||||||
)
|
)
|
||||||
|
|
||||||
val title = if (commits.flatten.length == 1) {
|
val title = if (commits.flatten.length == 1) {
|
||||||
@@ -449,8 +487,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
(repository.userName, repository.repositoryName, repository.defaultBranch)
|
(repository.userName, repository.repositoryName, repository.defaultBranch)
|
||||||
},
|
},
|
||||||
commits.flatten
|
commits.flatten
|
||||||
.map(commit => getCommitComments(forkedRepository.owner, forkedRepository.name, commit.id, false))
|
.flatMap(commit => getCommitComments(forkedRepository.owner, forkedRepository.name, commit.id, false))
|
||||||
.flatten
|
|
||||||
.toList,
|
.toList,
|
||||||
originId,
|
originId,
|
||||||
forkedId,
|
forkedId,
|
||||||
@@ -464,9 +501,10 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
getAssignableUserNames(originRepository.owner, originRepository.name),
|
getAssignableUserNames(originRepository.owner, originRepository.name),
|
||||||
getMilestones(originRepository.owner, originRepository.name),
|
getMilestones(originRepository.owner, originRepository.name),
|
||||||
getPriorities(originRepository.owner, originRepository.name),
|
getPriorities(originRepository.owner, originRepository.name),
|
||||||
getLabels(originRepository.owner, originRepository.name)
|
getDefaultPriority(originRepository.owner, originRepository.name),
|
||||||
|
getLabels(originRepository.owner, originRepository.name),
|
||||||
|
getCustomFields(originRepository.owner, originRepository.name).filter(_.enableForPullRequests)
|
||||||
)
|
)
|
||||||
}
|
|
||||||
case (oldId, newId) =>
|
case (oldId, newId) =>
|
||||||
redirect(
|
redirect(
|
||||||
s"/${forkedRepository.owner}/${forkedRepository.name}/compare/" +
|
s"/${forkedRepository.owner}/${forkedRepository.name}/compare/" +
|
||||||
@@ -478,12 +516,62 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ajaxGet("/:owner/:repository/diff/:id")(referrersOnly { repository =>
|
||||||
|
(for {
|
||||||
|
commitId <- params.get("id")
|
||||||
|
path <- params.get("path")
|
||||||
|
diff <- getSingleDiff(repository.owner, repository.name, commitId, path)
|
||||||
|
} yield {
|
||||||
|
contentType = formats("json")
|
||||||
|
org.json4s.jackson.Serialization.write(
|
||||||
|
Map(
|
||||||
|
"oldContent" -> diff.oldContent,
|
||||||
|
"newContent" -> diff.newContent
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
ajaxGet("/:owner/:repository/diff/*...*")(referrersOnly { forkedRepository =>
|
||||||
|
val Seq(origin, forked) = multiParams("splat")
|
||||||
|
val (originOwner, originId) = parseCompareIdentifier(origin, forkedRepository.owner)
|
||||||
|
val (forkedOwner, forkedId) = parseCompareIdentifier(forked, forkedRepository.owner)
|
||||||
|
|
||||||
|
(for {
|
||||||
|
path <- params.get("path")
|
||||||
|
originRepositoryName <- getOriginRepositoryName(originOwner, forkedOwner, forkedRepository)
|
||||||
|
originRepository <- getRepository(originOwner, originRepositoryName)
|
||||||
|
(oldId, newId) = getPullRequestCommitFromTo(originRepository, forkedRepository, originId, forkedId)
|
||||||
|
oldId <- oldId
|
||||||
|
newId <- newId
|
||||||
|
diff <- getSingleDiff(
|
||||||
|
originRepository.owner,
|
||||||
|
originRepository.name,
|
||||||
|
oldId.getName,
|
||||||
|
forkedRepository.owner,
|
||||||
|
forkedRepository.name,
|
||||||
|
newId.getName,
|
||||||
|
path
|
||||||
|
)
|
||||||
|
} yield {
|
||||||
|
contentType = formats("json")
|
||||||
|
org.json4s.jackson.Serialization.write(
|
||||||
|
Map(
|
||||||
|
"oldContent" -> diff.oldContent,
|
||||||
|
"newContent" -> diff.newContent
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/compare/*...*/mergecheck")(readableUsersOnly { forkedRepository =>
|
ajaxGet("/:owner/:repository/compare/*...*/mergecheck")(readableUsersOnly { forkedRepository =>
|
||||||
val Seq(origin, forked) = multiParams("splat")
|
val Seq(origin, forked) = multiParams("splat")
|
||||||
val (originOwner, tmpOriginBranch) = parseCompareIdentifier(origin, forkedRepository.owner)
|
val (originOwner, tmpOriginBranch) = parseCompareIdentifier(origin, forkedRepository.owner)
|
||||||
val (forkedOwner, tmpForkedBranch) = parseCompareIdentifier(forked, forkedRepository.owner)
|
val (forkedOwner, tmpForkedBranch) = parseCompareIdentifier(forked, forkedRepository.owner)
|
||||||
|
|
||||||
(for (originRepositoryName <- if (originOwner == forkedOwner) {
|
(for (
|
||||||
|
originRepositoryName <-
|
||||||
|
if (originOwner == forkedOwner) {
|
||||||
Some(forkedRepository.name)
|
Some(forkedRepository.name)
|
||||||
} else {
|
} else {
|
||||||
forkedRepository.repository.originRepositoryName.orElse {
|
forkedRepository.repository.originRepositoryName.orElse {
|
||||||
@@ -492,12 +580,12 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
.map(_.repositoryName)
|
.map(_.repositoryName)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
originRepository <- getRepository(originOwner, originRepositoryName)) yield {
|
originRepository <- getRepository(originOwner, originRepositoryName)
|
||||||
using(
|
) yield {
|
||||||
|
Using.resources(
|
||||||
Git.open(getRepositoryDir(originRepository.owner, originRepository.name)),
|
Git.open(getRepositoryDir(originRepository.owner, originRepository.name)),
|
||||||
Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))
|
Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))
|
||||||
) {
|
) { case (oldGit, newGit) =>
|
||||||
case (oldGit, newGit) =>
|
|
||||||
val originBranch = JGitUtil.getDefaultBranch(oldGit, originRepository, tmpOriginBranch).get._2
|
val originBranch = JGitUtil.getDefaultBranch(oldGit, originRepository, tmpOriginBranch).get._2
|
||||||
val forkedBranch = JGitUtil.getDefaultBranch(newGit, forkedRepository, tmpForkedBranch).get._2
|
val forkedBranch = JGitUtil.getDefaultBranch(newGit, forkedRepository, tmpForkedBranch).get._2
|
||||||
val conflict = LockUtil.lock(s"${originRepository.owner}/${originRepository.name}") {
|
val conflict = LockUtil.lock(s"${originRepository.owner}/${originRepository.name}") {
|
||||||
@@ -516,39 +604,44 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/pulls/new", pullRequestForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/pulls/new", pullRequestForm)(readableUsersOnly { (form, repository) =>
|
||||||
defining(repository.owner, repository.name) {
|
context.withLoginAccount { loginAccount =>
|
||||||
case (owner, name) =>
|
|
||||||
val manageable = isManageable(repository)
|
val manageable = isManageable(repository)
|
||||||
val loginUserName = context.loginAccount.get.userName
|
|
||||||
|
|
||||||
val issueId = insertIssue(
|
val issueId = insertIssue(
|
||||||
owner = repository.owner,
|
owner = repository.owner,
|
||||||
repository = repository.name,
|
repository = repository.name,
|
||||||
loginUser = loginUserName,
|
loginUser = loginAccount.userName,
|
||||||
title = form.title,
|
title = form.title,
|
||||||
content = form.content,
|
content = form.content,
|
||||||
assignedUserName = if (manageable) form.assignedUserName else None,
|
|
||||||
milestoneId = if (manageable) form.milestoneId else None,
|
milestoneId = if (manageable) form.milestoneId else None,
|
||||||
priorityId = if (manageable) form.priorityId else None,
|
priorityId = if (manageable) form.priorityId else None,
|
||||||
isPullRequest = true
|
isPullRequest = true
|
||||||
)
|
)
|
||||||
|
|
||||||
createPullRequest(
|
createPullRequest(
|
||||||
originUserName = repository.owner,
|
originRepository = repository,
|
||||||
originRepositoryName = repository.name,
|
|
||||||
issueId = issueId,
|
issueId = issueId,
|
||||||
originBranch = form.targetBranch,
|
originBranch = form.targetBranch,
|
||||||
requestUserName = form.requestUserName,
|
requestUserName = form.requestUserName,
|
||||||
requestRepositoryName = form.requestRepositoryName,
|
requestRepositoryName = form.requestRepositoryName,
|
||||||
requestBranch = form.requestBranch,
|
requestBranch = form.requestBranch,
|
||||||
commitIdFrom = form.commitIdFrom,
|
commitIdFrom = form.commitIdFrom,
|
||||||
commitIdTo = form.commitIdTo
|
commitIdTo = form.commitIdTo,
|
||||||
|
isDraft = form.isDraft,
|
||||||
|
loginAccount = loginAccount,
|
||||||
|
settings = context.settings
|
||||||
)
|
)
|
||||||
|
|
||||||
// insert labels
|
|
||||||
if (manageable) {
|
if (manageable) {
|
||||||
|
// insert assignees
|
||||||
|
form.assigneeUserNames.foreach { value =>
|
||||||
|
value.split(",").foreach { userName =>
|
||||||
|
registerIssueAssignee(repository.owner, repository.name, issueId, userName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// insert labels
|
||||||
form.labelNames.foreach { value =>
|
form.labelNames.foreach { value =>
|
||||||
val labels = getLabels(owner, name)
|
val labels = getLabels(repository.owner, repository.name)
|
||||||
value.split(",").foreach { labelName =>
|
value.split(",").foreach { labelName =>
|
||||||
labels.find(_.labelName == labelName).map { label =>
|
labels.find(_.labelName == labelName).map { label =>
|
||||||
registerIssueLabel(repository.owner, repository.name, issueId, label.labelId)
|
registerIssueLabel(repository.owner, repository.name, issueId, label.labelId)
|
||||||
@@ -557,30 +650,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch requested branch
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
fetchAsPullRequest(owner, name, form.requestUserName, form.requestRepositoryName, form.requestBranch, issueId)
|
|
||||||
|
|
||||||
// record activity
|
|
||||||
recordPullRequestActivity(owner, name, loginUserName, issueId, form.title)
|
|
||||||
|
|
||||||
// call web hook
|
|
||||||
callPullRequestWebHook("opened", repository, issueId, context.loginAccount.get)
|
|
||||||
|
|
||||||
getIssue(owner, name, issueId.toString) foreach { issue =>
|
|
||||||
// extract references and create refer comment
|
|
||||||
createReferComment(
|
|
||||||
owner,
|
|
||||||
name,
|
|
||||||
issue,
|
|
||||||
form.title + " " + form.content.getOrElse(""),
|
|
||||||
context.loginAccount.get
|
|
||||||
)
|
|
||||||
|
|
||||||
// call hooks
|
|
||||||
PluginRegistry().getPullRequestHooks.foreach(_.created(issue, repository))
|
|
||||||
}
|
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/pull/${issueId}")
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -589,10 +659,11 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
val mailAddresses =
|
val mailAddresses =
|
||||||
context.loginAccount.map(x => Seq(x.mailAddress) ++ getAccountExtraMailAddresses(x.userName)).getOrElse(Nil)
|
context.loginAccount.map(x => Seq(x.mailAddress) ++ getAccountExtraMailAddresses(x.userName)).getOrElse(Nil)
|
||||||
|
|
||||||
val branches = JGitUtil
|
val branches =
|
||||||
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
|
JGitUtil
|
||||||
.getBranches(
|
.getBranches(
|
||||||
owner = repository.owner,
|
git = git,
|
||||||
name = repository.name,
|
|
||||||
defaultBranch = repository.repository.defaultBranch,
|
defaultBranch = repository.repository.defaultBranch,
|
||||||
origin = repository.repository.originUserName.isEmpty
|
origin = repository.repository.originUserName.isEmpty
|
||||||
)
|
)
|
||||||
@@ -606,6 +677,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
.map(_.name)
|
.map(_.name)
|
||||||
.reverse
|
.reverse
|
||||||
|
}
|
||||||
|
|
||||||
val targetRepository = (for {
|
val targetRepository = (for {
|
||||||
parentUserName <- repository.repository.parentUserName
|
parentUserName <- repository.repository.parentUserName
|
||||||
@@ -624,24 +696,36 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
html.proposals(proposedBranches, targetRepository, repository)
|
html.proposals(proposedBranches, targetRepository, repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
private def searchPullRequests(userName: Option[String], repository: RepositoryService.RepositoryInfo) =
|
private def searchPullRequests(
|
||||||
defining(repository.owner, repository.name) {
|
repository: RepositoryService.RepositoryInfo,
|
||||||
case (owner, repoName) =>
|
condition: IssueSearchCondition,
|
||||||
val page = IssueSearchCondition.page(request)
|
page: Int
|
||||||
|
) = {
|
||||||
// retrieve search condition
|
// search issues
|
||||||
val condition = IssueSearchCondition(request)
|
val issues = searchIssue(
|
||||||
|
condition,
|
||||||
|
IssueSearchOption.PullRequests,
|
||||||
|
(page - 1) * PullRequestLimit,
|
||||||
|
PullRequestLimit,
|
||||||
|
repository.owner -> repository.name
|
||||||
|
)
|
||||||
|
// commit status
|
||||||
|
val status = issues.map { issue =>
|
||||||
|
issue.commitId.flatMap { commitId =>
|
||||||
|
getCommitStatusWithSummary(repository.owner, repository.name, commitId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gitbucket.core.issues.html.list(
|
gitbucket.core.issues.html.list(
|
||||||
"pulls",
|
"pulls",
|
||||||
searchIssue(condition, true, (page - 1) * PullRequestLimit, PullRequestLimit, owner -> repoName),
|
issues.zip(status),
|
||||||
page,
|
page,
|
||||||
getAssignableUserNames(owner, repoName),
|
getAssignableUserNames(repository.owner, repository.name),
|
||||||
getMilestones(owner, repoName),
|
getMilestones(repository.owner, repository.name),
|
||||||
getPriorities(owner, repoName),
|
getPriorities(repository.owner, repository.name),
|
||||||
getLabels(owner, repoName),
|
getLabels(repository.owner, repository.name),
|
||||||
countIssue(condition.copy(state = "open"), true, owner -> repoName),
|
countIssue(condition.copy(state = "open"), IssueSearchOption.PullRequests, repository.owner -> repository.name),
|
||||||
countIssue(condition.copy(state = "closed"), true, owner -> repoName),
|
countIssue(condition.copy(state = "closed"), IssueSearchOption.PullRequests, repository.owner -> repository.name),
|
||||||
condition,
|
condition,
|
||||||
repository,
|
repository,
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
|
|||||||
@@ -2,16 +2,25 @@ package gitbucket.core.controller
|
|||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
import gitbucket.core.service.{AccountService, ActivityService, ReleaseService, RepositoryService}
|
import gitbucket.core.model.activity.ReleaseInfo
|
||||||
|
import gitbucket.core.service.{
|
||||||
|
AccountService,
|
||||||
|
ActivityService,
|
||||||
|
PaginationHelper,
|
||||||
|
ReleaseService,
|
||||||
|
RepositoryService,
|
||||||
|
RequestCache
|
||||||
|
}
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import org.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
import gitbucket.core.releases.html
|
import gitbucket.core.releases.html
|
||||||
import gitbucket.core.util.SyntaxSugars.using
|
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
|
|
||||||
|
import scala.util.Using
|
||||||
|
|
||||||
class ReleaseController
|
class ReleaseController
|
||||||
extends ReleaseControllerBase
|
extends ReleaseControllerBase
|
||||||
with RepositoryService
|
with RepositoryService
|
||||||
@@ -21,6 +30,7 @@ class ReleaseController
|
|||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with ReferrerAuthenticator
|
with ReferrerAuthenticator
|
||||||
with WritableUsersAuthenticator
|
with WritableUsersAuthenticator
|
||||||
|
with RequestCache
|
||||||
|
|
||||||
trait ReleaseControllerBase extends ControllerBase {
|
trait ReleaseControllerBase extends ControllerBase {
|
||||||
self: RepositoryService
|
self: RepositoryService
|
||||||
@@ -42,22 +52,19 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
)(ReleaseForm.apply)
|
)(ReleaseForm.apply)
|
||||||
|
|
||||||
get("/:owner/:repository/releases")(referrersOnly { repository =>
|
get("/:owner/:repository/releases")(referrersOnly { repository =>
|
||||||
val releases = getReleases(repository.owner, repository.name)
|
val page = PaginationHelper.page(params.get("page"))
|
||||||
val assets = getReleaseAssetsMap(repository.owner, repository.name)
|
|
||||||
|
|
||||||
html.list(
|
html.list(
|
||||||
repository,
|
repository,
|
||||||
repository.tags.reverse.map { tag =>
|
fetchReleases(repository, page),
|
||||||
(tag, releases.find(_.tag == tag.name).map { release =>
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||||
(release, assets(release))
|
page,
|
||||||
})
|
repository.tags.size
|
||||||
},
|
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/releases/:tag")(referrersOnly { repository =>
|
get("/:owner/:repository/releases/*")(referrersOnly { repository =>
|
||||||
val tagName = params("tag")
|
val tagName = multiParams("splat").head
|
||||||
getRelease(repository.owner, repository.name, tagName)
|
getRelease(repository.owner, repository.name, tagName)
|
||||||
.map { release =>
|
.map { release =>
|
||||||
html.release(
|
html.release(
|
||||||
@@ -70,8 +77,8 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
.getOrElse(NotFound())
|
.getOrElse(NotFound())
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/releases/:tag/assets/:fileId")(referrersOnly { repository =>
|
get("/:owner/:repository/releases/*/assets/:fileId")(referrersOnly { repository =>
|
||||||
val tagName = params("tag")
|
val tagName = multiParams("splat").head
|
||||||
val fileId = params("fileId")
|
val fileId = params("fileId")
|
||||||
(for {
|
(for {
|
||||||
_ <- repository.tags.find(_.name == tagName)
|
_ <- repository.tags.find(_.name == tagName)
|
||||||
@@ -86,8 +93,8 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
}).getOrElse(NotFound())
|
}).getOrElse(NotFound())
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/releases/:tag/create")(writableUsersOnly { repository =>
|
get("/:owner/:repository/releases/*/create")(writableUsersOnly { repository =>
|
||||||
val tagName = params("tag")
|
val tagName = multiParams("splat").head
|
||||||
val previousTags = repository.tags.takeWhile(_.name != tagName).reverse
|
val previousTags = repository.tags.takeWhile(_.name != tagName).reverse
|
||||||
|
|
||||||
repository.tags
|
repository.tags
|
||||||
@@ -98,21 +105,20 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
.getOrElse(NotFound())
|
.getOrElse(NotFound())
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/releases/:tag/create", releaseForm)(writableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/releases/*/create", releaseForm)(writableUsersOnly { (form, repository) =>
|
||||||
val tagName = params("tag")
|
context.withLoginAccount { loginAccount =>
|
||||||
val loginAccount = context.loginAccount.get
|
val tagName = multiParams("splat").head
|
||||||
|
|
||||||
// Insert into RELEASE
|
// Insert into RELEASE
|
||||||
createRelease(repository.owner, repository.name, form.name, form.content, tagName, loginAccount)
|
createRelease(repository.owner, repository.name, form.name, form.content, tagName, loginAccount)
|
||||||
|
|
||||||
// Insert into RELEASE_ASSET
|
// Insert into RELEASE_ASSET
|
||||||
val files = params.collect {
|
val files = params.toMap.collect {
|
||||||
case (name, value) if name.startsWith("file:") =>
|
case (name, value) if name.startsWith("file:") =>
|
||||||
val Array(_, fileId) = name.split(":")
|
val Array(_, fileId) = name.split(":")
|
||||||
(fileId, value)
|
(fileId, value)
|
||||||
}
|
}
|
||||||
files.foreach {
|
files.foreach { case (fileId, fileName) =>
|
||||||
case (fileId, fileName) =>
|
|
||||||
val size =
|
val size =
|
||||||
new File(
|
new File(
|
||||||
getReleaseFilesDir(repository.owner, repository.name),
|
getReleaseFilesDir(repository.owner, repository.name),
|
||||||
@@ -121,16 +127,18 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
createReleaseAsset(repository.owner, repository.name, tagName, fileId, fileName, size, loginAccount)
|
createReleaseAsset(repository.owner, repository.name, tagName, fileId, fileName, size, loginAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
recordReleaseActivity(repository.owner, repository.name, loginAccount.userName, form.name)
|
val releaseInfo = ReleaseInfo(repository.owner, repository.name, loginAccount.userName, form.name, tagName)
|
||||||
|
recordActivity(releaseInfo)
|
||||||
|
|
||||||
redirect(s"/${repository.owner}/${repository.name}/releases/${tagName}")
|
redirect(s"/${repository.owner}/${repository.name}/releases/${tagName}")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/changelog/*...*")(writableUsersOnly { repository =>
|
get("/:owner/:repository/changelog/*...*")(writableUsersOnly { repository =>
|
||||||
val Seq(previousTag, currentTag) = multiParams("splat")
|
val Seq(previousTag, currentTag) = multiParams("splat")
|
||||||
val previousTagId = repository.tags.collectFirst { case x if x.name == previousTag => x.id }.getOrElse("")
|
val previousTagId = repository.tags.collectFirst { case x if x.name == previousTag => x.commitId }.getOrElse("")
|
||||||
|
|
||||||
val commitLog = using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
val commitLog = Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
val commits = JGitUtil.getCommitLog(git, previousTagId, currentTag).reverse
|
val commits = JGitUtil.getCommitLog(git, previousTagId, currentTag).reverse
|
||||||
commits
|
commits
|
||||||
.map { commit =>
|
.map { commit =>
|
||||||
@@ -142,8 +150,8 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
commitLog
|
commitLog
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/releases/:tag/edit")(writableUsersOnly { repository =>
|
get("/:owner/:repository/releases/*/edit")(writableUsersOnly { repository =>
|
||||||
val tagName = params("tag")
|
val tagName = multiParams("splat").head
|
||||||
val previousTags = repository.tags.takeWhile(_.name != tagName).reverse
|
val previousTags = repository.tags.takeWhile(_.name != tagName).reverse
|
||||||
|
|
||||||
(for {
|
(for {
|
||||||
@@ -160,10 +168,9 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
}).getOrElse(NotFound())
|
}).getOrElse(NotFound())
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/releases/:tag/edit", releaseForm)(writableUsersOnly {
|
post("/:owner/:repository/releases/*/edit", releaseForm)(writableUsersOnly { (form, repository) =>
|
||||||
(form, repository) =>
|
context.withLoginAccount { loginAccount =>
|
||||||
val tagName = params("tag")
|
val tagName = multiParams("splat").head
|
||||||
val loginAccount = context.loginAccount.get
|
|
||||||
|
|
||||||
getRelease(repository.owner, repository.name, tagName)
|
getRelease(repository.owner, repository.name, tagName)
|
||||||
.map { release =>
|
.map { release =>
|
||||||
@@ -174,13 +181,12 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
val assets = getReleaseAssets(repository.owner, repository.name, tagName)
|
val assets = getReleaseAssets(repository.owner, repository.name, tagName)
|
||||||
deleteReleaseAssets(repository.owner, repository.name, tagName)
|
deleteReleaseAssets(repository.owner, repository.name, tagName)
|
||||||
|
|
||||||
val files = params.collect {
|
val files = params.toMap.collect {
|
||||||
case (name, value) if name.startsWith("file:") =>
|
case (name, value) if name.startsWith("file:") =>
|
||||||
val Array(_, fileId) = name.split(":")
|
val Array(_, fileId) = name.split(":")
|
||||||
(fileId, value)
|
(fileId, value)
|
||||||
}
|
}
|
||||||
files.foreach {
|
files.foreach { case (fileId, fileName) =>
|
||||||
case (fileId, fileName) =>
|
|
||||||
val size =
|
val size =
|
||||||
new File(
|
new File(
|
||||||
getReleaseFilesDir(repository.owner, repository.name),
|
getReleaseFilesDir(repository.owner, repository.name),
|
||||||
@@ -202,10 +208,11 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
redirect(s"/${release.userName}/${release.repositoryName}/releases/${tagName}")
|
redirect(s"/${release.userName}/${release.repositoryName}/releases/${tagName}")
|
||||||
}
|
}
|
||||||
.getOrElse(NotFound())
|
.getOrElse(NotFound())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/releases/:tag/delete")(writableUsersOnly { repository =>
|
post("/:owner/:repository/releases/*/delete")(writableUsersOnly { repository =>
|
||||||
val tagName = params("tag")
|
val tagName = multiParams("splat").head
|
||||||
getRelease(repository.owner, repository.name, tagName).foreach { release =>
|
getRelease(repository.owner, repository.name, tagName).foreach { release =>
|
||||||
FileUtils.deleteDirectory(
|
FileUtils.deleteDirectory(
|
||||||
new File(getReleaseFilesDir(repository.owner, repository.name), FileUtil.checkFilename(release.tag))
|
new File(getReleaseFilesDir(repository.owner, repository.name), FileUtil.checkFilename(release.tag))
|
||||||
@@ -215,4 +222,23 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
redirect(s"/${repository.owner}/${repository.name}/releases")
|
redirect(s"/${repository.owner}/${repository.name}/releases")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
private def fetchReleases(repository: RepositoryService.RepositoryInfo, page: Int) = {
|
||||||
|
import gitbucket.core.service.ReleaseService._
|
||||||
|
|
||||||
|
val (offset, limit) = ((page - 1) * ReleaseLimit, ReleaseLimit)
|
||||||
|
val tagsToDisplay = repository.tags.reverse.slice(offset, offset + limit)
|
||||||
|
|
||||||
|
val releases = getReleases(repository.owner, repository.name, tagsToDisplay)
|
||||||
|
val assets = getReleaseAssetsMap(repository.owner, repository.name, releases)
|
||||||
|
|
||||||
|
val tagsWithReleases = tagsToDisplay.map { tag =>
|
||||||
|
(
|
||||||
|
tag,
|
||||||
|
releases.find(_.tag == tag.name).map { release =>
|
||||||
|
(release, assets(release))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
tagsWithReleases
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import java.time.{LocalDateTime, ZoneId, ZoneOffset}
|
import java.time.{LocalDateTime, ZoneOffset}
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
import gitbucket.core.settings.html
|
import gitbucket.core.settings.html
|
||||||
import gitbucket.core.model.{RepositoryWebHook, WebHook}
|
import gitbucket.core.model.{RepositoryWebHook, WebHook}
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
@@ -12,12 +11,16 @@ import gitbucket.core.util.JGitUtil._
|
|||||||
import gitbucket.core.util.SyntaxSugars._
|
import gitbucket.core.util.SyntaxSugars._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
|
import gitbucket.core.model.WebHookContentType
|
||||||
|
import gitbucket.core.model.activity.RenameRepositoryInfo
|
||||||
import org.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
import org.scalatra.i18n.Messages
|
import org.scalatra.i18n.Messages
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.lib.Constants
|
import org.eclipse.jgit.lib.Constants
|
||||||
import org.eclipse.jgit.lib.ObjectId
|
import org.eclipse.jgit.lib.ObjectId
|
||||||
import gitbucket.core.model.WebHookContentType
|
|
||||||
|
import scala.util.Using
|
||||||
|
import org.scalatra.{Forbidden, Ok}
|
||||||
|
|
||||||
class RepositorySettingsController
|
class RepositorySettingsController
|
||||||
extends RepositorySettingsControllerBase
|
extends RepositorySettingsControllerBase
|
||||||
@@ -27,8 +30,11 @@ class RepositorySettingsController
|
|||||||
with ProtectedBranchService
|
with ProtectedBranchService
|
||||||
with CommitStatusService
|
with CommitStatusService
|
||||||
with DeployKeyService
|
with DeployKeyService
|
||||||
|
with CustomFieldsService
|
||||||
|
with ActivityService
|
||||||
with OwnerAuthenticator
|
with OwnerAuthenticator
|
||||||
with UsersAuthenticator
|
with UsersAuthenticator
|
||||||
|
with RequestCache
|
||||||
|
|
||||||
trait RepositorySettingsControllerBase extends ControllerBase {
|
trait RepositorySettingsControllerBase extends ControllerBase {
|
||||||
self: RepositoryService
|
self: RepositoryService
|
||||||
@@ -37,12 +43,13 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
with ProtectedBranchService
|
with ProtectedBranchService
|
||||||
with CommitStatusService
|
with CommitStatusService
|
||||||
with DeployKeyService
|
with DeployKeyService
|
||||||
|
with CustomFieldsService
|
||||||
|
with ActivityService
|
||||||
with OwnerAuthenticator
|
with OwnerAuthenticator
|
||||||
with UsersAuthenticator =>
|
with UsersAuthenticator =>
|
||||||
|
|
||||||
// for repository options
|
// for repository options
|
||||||
case class OptionsForm(
|
case class OptionsForm(
|
||||||
repositoryName: String,
|
|
||||||
description: Option[String],
|
description: Option[String],
|
||||||
isPrivate: Boolean,
|
isPrivate: Boolean,
|
||||||
issuesOption: String,
|
issuesOption: String,
|
||||||
@@ -51,13 +58,11 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
externalWikiUrl: Option[String],
|
externalWikiUrl: Option[String],
|
||||||
allowFork: Boolean,
|
allowFork: Boolean,
|
||||||
mergeOptions: Seq[String],
|
mergeOptions: Seq[String],
|
||||||
defaultMergeOption: String
|
defaultMergeOption: String,
|
||||||
|
safeMode: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
val optionsForm = mapping(
|
val optionsForm = mapping(
|
||||||
"repositoryName" -> trim(
|
|
||||||
label("Repository Name", text(required, maxlength(100), repository, renameRepositoryName))
|
|
||||||
),
|
|
||||||
"description" -> trim(label("Description", optional(text()))),
|
"description" -> trim(label("Description", optional(text()))),
|
||||||
"isPrivate" -> trim(label("Repository Type", boolean())),
|
"isPrivate" -> trim(label("Repository Type", boolean())),
|
||||||
"issuesOption" -> trim(label("Issues Option", text(required, featureOption))),
|
"issuesOption" -> trim(label("Issues Option", text(required, featureOption))),
|
||||||
@@ -66,7 +71,8 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
"externalWikiUrl" -> trim(label("External Wiki URL", optional(text(maxlength(200))))),
|
"externalWikiUrl" -> trim(label("External Wiki URL", optional(text(maxlength(200))))),
|
||||||
"allowFork" -> trim(label("Allow Forking", boolean())),
|
"allowFork" -> trim(label("Allow Forking", boolean())),
|
||||||
"mergeOptions" -> mergeOptions,
|
"mergeOptions" -> mergeOptions,
|
||||||
"defaultMergeOption" -> trim(label("Default merge strategy", text(required)))
|
"defaultMergeOption" -> trim(label("Default merge strategy", text(required))),
|
||||||
|
"safeMode" -> trim(label("XSS protection", boolean()))
|
||||||
)(OptionsForm.apply).verifying { form =>
|
)(OptionsForm.apply).verifying { form =>
|
||||||
if (!form.mergeOptions.contains(form.defaultMergeOption)) {
|
if (!form.mergeOptions.contains(form.defaultMergeOption)) {
|
||||||
Seq("defaultMergeOption" -> s"This merge strategy isn't enabled.")
|
Seq("defaultMergeOption" -> s"This merge strategy isn't enabled.")
|
||||||
@@ -98,9 +104,16 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
"events" -> webhookEvents,
|
"events" -> webhookEvents,
|
||||||
"ctype" -> label("ctype", text()),
|
"ctype" -> label("ctype", text()),
|
||||||
"token" -> optional(trim(label("token", text(maxlength(100)))))
|
"token" -> optional(trim(label("token", text(maxlength(100)))))
|
||||||
)(
|
)((url, events, ctype, token) => WebHookForm(url, events, WebHookContentType.valueOf(ctype), token))
|
||||||
(url, events, ctype, token) => WebHookForm(url, events, WebHookContentType.valueOf(ctype), token)
|
|
||||||
|
// for rename repository
|
||||||
|
case class RenameRepositoryForm(repositoryName: String)
|
||||||
|
|
||||||
|
val renameForm = mapping(
|
||||||
|
"repositoryName" -> trim(
|
||||||
|
label("New repository name", text(required, maxlength(100), repository, renameRepositoryName))
|
||||||
)
|
)
|
||||||
|
)(RenameRepositoryForm.apply)
|
||||||
|
|
||||||
// for transfer ownership
|
// for transfer ownership
|
||||||
case class TransferOwnerShipForm(newOwner: String)
|
case class TransferOwnerShipForm(newOwner: String)
|
||||||
@@ -109,6 +122,23 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
"newOwner" -> trim(label("New owner", text(required, transferUser)))
|
"newOwner" -> trim(label("New owner", text(required, transferUser)))
|
||||||
)(TransferOwnerShipForm.apply)
|
)(TransferOwnerShipForm.apply)
|
||||||
|
|
||||||
|
// for custom field
|
||||||
|
case class CustomFieldForm(
|
||||||
|
fieldName: String,
|
||||||
|
fieldType: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
enableForIssues: Boolean,
|
||||||
|
enableForPullRequests: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
|
val customFieldForm = mapping(
|
||||||
|
"fieldName" -> trim(label("Field name", text(required, maxlength(100)))),
|
||||||
|
"fieldType" -> trim(label("Field type", text(required))),
|
||||||
|
"constraints" -> trim(label("Constraints", optional(text()))),
|
||||||
|
"enableForIssues" -> trim(label("Enable for issues", boolean(required))),
|
||||||
|
"enableForPullRequests" -> trim(label("Enable for pull requests", boolean(required))),
|
||||||
|
)(CustomFieldForm.apply)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirect to the Options page.
|
* Redirect to the Options page.
|
||||||
*/
|
*/
|
||||||
@@ -140,15 +170,11 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
form.externalWikiUrl,
|
form.externalWikiUrl,
|
||||||
form.allowFork,
|
form.allowFork,
|
||||||
form.mergeOptions,
|
form.mergeOptions,
|
||||||
form.defaultMergeOption
|
form.defaultMergeOption,
|
||||||
|
form.safeMode
|
||||||
)
|
)
|
||||||
// Change repository name
|
flash.update("info", "Repository settings has been updated.")
|
||||||
if (repository.name != form.repositoryName) {
|
redirect(s"/${repository.owner}/${repository.name}/settings/options")
|
||||||
// Update database
|
|
||||||
renameRepository(repository.owner, repository.name, repository.owner, form.repositoryName)
|
|
||||||
}
|
|
||||||
flash += "info" -> "Repository settings has been updated."
|
|
||||||
redirect(s"/${repository.owner}/${form.repositoryName}/settings/options")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/** branch settings */
|
/** branch settings */
|
||||||
@@ -164,23 +190,24 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
} else {
|
} else {
|
||||||
saveRepositoryDefaultBranch(repository.owner, repository.name, form.defaultBranch)
|
saveRepositoryDefaultBranch(repository.owner, repository.name, form.defaultBranch)
|
||||||
// Change repository HEAD
|
// Change repository HEAD
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git.getRepository.updateRef(Constants.HEAD, true).link(Constants.R_HEADS + form.defaultBranch)
|
git.getRepository.updateRef(Constants.HEAD, true).link(Constants.R_HEADS + form.defaultBranch)
|
||||||
}
|
}
|
||||||
flash += "info" -> "Repository default branch has been updated."
|
flash.update("info", "Repository default branch has been updated.")
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/branches")
|
redirect(s"/${repository.owner}/${repository.name}/settings/branches")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/** Branch protection for branch */
|
/** Branch protection for branch */
|
||||||
get("/:owner/:repository/settings/branches/:branch")(ownerOnly { repository =>
|
get("/:owner/:repository/settings/branches/*")(ownerOnly { repository =>
|
||||||
import gitbucket.core.api._
|
import gitbucket.core.api._
|
||||||
val branch = params("branch")
|
val branch = params("splat")
|
||||||
|
|
||||||
if (!repository.branchList.contains(branch)) {
|
if (!repository.branchList.contains(branch)) {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/branches")
|
redirect(s"/${repository.owner}/${repository.name}/settings/branches")
|
||||||
} else {
|
} else {
|
||||||
val protection = ApiBranchProtection(getProtectedBranchInfo(repository.owner, repository.name, branch))
|
val protection = ApiBranchProtection(getProtectedBranchInfo(repository.owner, repository.name, branch))
|
||||||
val lastWeeks = getRecentStatuesContexts(
|
val lastWeeks = getRecentStatusContexts(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
repository.name,
|
repository.name,
|
||||||
Date.from(LocalDateTime.now.minusWeeks(1).toInstant(ZoneOffset.UTC))
|
Date.from(LocalDateTime.now.minusWeeks(1).toInstant(ZoneOffset.UTC))
|
||||||
@@ -222,7 +249,13 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
* Display the web hook edit page.
|
* Display the web hook edit page.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/settings/hooks/new")(ownerOnly { repository =>
|
get("/:owner/:repository/settings/hooks/new")(ownerOnly { repository =>
|
||||||
val webhook = RepositoryWebHook(repository.owner, repository.name, "", WebHookContentType.FORM, None)
|
val webhook = RepositoryWebHook(
|
||||||
|
userName = repository.owner,
|
||||||
|
repositoryName = repository.name,
|
||||||
|
url = "",
|
||||||
|
ctype = WebHookContentType.FORM,
|
||||||
|
token = None
|
||||||
|
)
|
||||||
html.edithook(webhook, Set(WebHook.Push), repository, true)
|
html.edithook(webhook, Set(WebHook.Push), repository, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -231,7 +264,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/hooks/new", webHookForm(false))(ownerOnly { (form, repository) =>
|
post("/:owner/:repository/settings/hooks/new", webHookForm(false))(ownerOnly { (form, repository) =>
|
||||||
addWebHook(repository.owner, repository.name, form.url, form.events, form.ctype, form.token)
|
addWebHook(repository.owner, repository.name, form.url, form.events, form.ctype, form.token)
|
||||||
flash += "info" -> s"Webhook ${form.url} created"
|
flash.update("info", s"Webhook ${form.url} created")
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -240,7 +273,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
get("/:owner/:repository/settings/hooks/delete")(ownerOnly { repository =>
|
get("/:owner/:repository/settings/hooks/delete")(ownerOnly { repository =>
|
||||||
deleteWebHook(repository.owner, repository.name, params("url"))
|
deleteWebHook(repository.owner, repository.name, params("url"))
|
||||||
flash += "info" -> s"Webhook ${params("url")} deleted"
|
flash.update("info", s"Webhook ${params("url")} deleted")
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -248,15 +281,15 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
* Send the test request to registered web hook URLs.
|
* Send the test request to registered web hook URLs.
|
||||||
*/
|
*/
|
||||||
ajaxPost("/:owner/:repository/settings/hooks/test")(ownerOnly { repository =>
|
ajaxPost("/:owner/:repository/settings/hooks/test")(ownerOnly { repository =>
|
||||||
def _headers(h: Array[org.apache.http.Header]): Array[Array[String]] = h.map { h =>
|
def _headers(h: Array[org.apache.http.Header]): Array[Array[String]] =
|
||||||
|
h.map { h =>
|
||||||
Array(h.getName, h.getValue)
|
Array(h.getName, h.getValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
import scala.collection.JavaConverters._
|
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import scala.concurrent._
|
import scala.concurrent._
|
||||||
|
import scala.jdk.CollectionConverters._
|
||||||
import scala.util.control.NonFatal
|
import scala.util.control.NonFatal
|
||||||
import org.apache.http.util.EntityUtils
|
import org.apache.http.util.EntityUtils
|
||||||
import scala.concurrent.ExecutionContext.Implicits.global
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
@@ -264,7 +297,13 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
val url = params("url")
|
val url = params("url")
|
||||||
val token = Some(params("token"))
|
val token = Some(params("token"))
|
||||||
val ctype = WebHookContentType.valueOf(params("ctype"))
|
val ctype = WebHookContentType.valueOf(params("ctype"))
|
||||||
val dummyWebHookInfo = RepositoryWebHook(repository.owner, repository.name, url, ctype, token)
|
val dummyWebHookInfo = RepositoryWebHook(
|
||||||
|
userName = repository.owner,
|
||||||
|
repositoryName = repository.name,
|
||||||
|
url = url,
|
||||||
|
ctype = ctype,
|
||||||
|
token = token
|
||||||
|
)
|
||||||
val dummyPayload = {
|
val dummyPayload = {
|
||||||
val ownerAccount = getAccountByUserName(repository.owner).get
|
val ownerAccount = getAccountByUserName(repository.owner).get
|
||||||
val commits =
|
val commits =
|
||||||
@@ -292,13 +331,14 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val (webHook, json, reqFuture, resFuture) = callWebHook(WebHook.Push, List(dummyWebHookInfo), dummyPayload).head
|
val (webHook, json, reqFuture, resFuture) =
|
||||||
|
callWebHook(WebHook.Push, List(dummyWebHookInfo), dummyPayload, context.settings).head
|
||||||
|
|
||||||
val toErrorMap: PartialFunction[Throwable, Map[String, String]] = {
|
val toErrorMap: PartialFunction[Throwable, Map[String, String]] = {
|
||||||
case e: java.net.UnknownHostException => Map("error" -> ("Unknown host " + e.getMessage))
|
case e: java.net.UnknownHostException => Map("error" -> ("Unknown host " + e.getMessage))
|
||||||
case e: java.lang.IllegalArgumentException => Map("error" -> ("invalid url"))
|
case e: java.lang.IllegalArgumentException => Map("error" -> ("invalid url"))
|
||||||
case e: org.apache.http.client.ClientProtocolException => Map("error" -> ("invalid url"))
|
case e: org.apache.http.client.ClientProtocolException => Map("error" -> ("invalid url"))
|
||||||
case NonFatal(e) => Map("error" -> (e.getClass + " " + e.getMessage))
|
case NonFatal(e) => Map("error" -> (s"${e.getClass} ${e.getMessage}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
@@ -307,8 +347,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
"url" -> url,
|
"url" -> url,
|
||||||
"request" -> Await.result(
|
"request" -> Await.result(
|
||||||
reqFuture
|
reqFuture
|
||||||
.map(
|
.map(req =>
|
||||||
req =>
|
|
||||||
Map(
|
Map(
|
||||||
"headers" -> _headers(req.getAllHeaders),
|
"headers" -> _headers(req.getAllHeaders),
|
||||||
"payload" -> json
|
"payload" -> json
|
||||||
@@ -319,10 +358,9 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
),
|
),
|
||||||
"response" -> Await.result(
|
"response" -> Await.result(
|
||||||
resFuture
|
resFuture
|
||||||
.map(
|
.map(res =>
|
||||||
res =>
|
|
||||||
Map(
|
Map(
|
||||||
"status" -> res.getStatusLine(),
|
"status" -> res.getStatusLine.getStatusCode,
|
||||||
"body" -> EntityUtils.toString(res.getEntity()),
|
"body" -> EntityUtils.toString(res.getEntity()),
|
||||||
"headers" -> _headers(res.getAllHeaders())
|
"headers" -> _headers(res.getAllHeaders())
|
||||||
)
|
)
|
||||||
@@ -339,8 +377,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
* Display the web hook edit page.
|
* Display the web hook edit page.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/settings/hooks/edit")(ownerOnly { repository =>
|
get("/:owner/:repository/settings/hooks/edit")(ownerOnly { repository =>
|
||||||
getWebHook(repository.owner, repository.name, params("url")).map {
|
getWebHook(repository.owner, repository.name, params("url")).map { case (webhook, events) =>
|
||||||
case (webhook, events) =>
|
|
||||||
html.edithook(webhook, events, repository, false)
|
html.edithook(webhook, events, repository, false)
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
@@ -350,7 +387,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/hooks/edit", webHookForm(true))(ownerOnly { (form, repository) =>
|
post("/:owner/:repository/settings/hooks/edit", webHookForm(true))(ownerOnly { (form, repository) =>
|
||||||
updateWebHook(repository.owner, repository.name, form.url, form.events, form.ctype, form.token)
|
updateWebHook(repository.owner, repository.name, form.url, form.events, form.ctype, form.token)
|
||||||
flash += "info" -> s"webhook ${form.url} updated"
|
flash.update("info", s"webhook ${form.url} updated")
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -361,24 +398,64 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
html.danger(_, flash.get("info"))
|
html.danger(_, flash.get("info"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename repository.
|
||||||
|
*/
|
||||||
|
post("/:owner/:repository/settings/rename", renameForm)(ownerOnly { (form, repository) =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
|
if (context.settings.basicBehavior.repositoryOperation.rename || loginAccount.isAdmin) {
|
||||||
|
if (repository.name != form.repositoryName) {
|
||||||
|
// Update database and move git repository
|
||||||
|
renameRepository(repository.owner, repository.name, repository.owner, form.repositoryName)
|
||||||
|
// Record activity log
|
||||||
|
val renameInfo = RenameRepositoryInfo(
|
||||||
|
repository.owner,
|
||||||
|
form.repositoryName,
|
||||||
|
loginAccount.userName,
|
||||||
|
repository.name
|
||||||
|
)
|
||||||
|
recordActivity(renameInfo)
|
||||||
|
}
|
||||||
|
redirect(s"/${repository.owner}/${form.repositoryName}")
|
||||||
|
} else Forbidden()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transfer repository ownership.
|
* Transfer repository ownership.
|
||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/transfer", transferForm)(ownerOnly { (form, repository) =>
|
post("/:owner/:repository/settings/transfer", transferForm)(ownerOnly { (form, repository) =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
|
if (context.settings.basicBehavior.repositoryOperation.transfer || loginAccount.isAdmin) {
|
||||||
// Change repository owner
|
// Change repository owner
|
||||||
if (repository.owner != form.newOwner) {
|
if (repository.owner != form.newOwner) {
|
||||||
|
// Update database and move git repository
|
||||||
renameRepository(repository.owner, repository.name, form.newOwner, repository.name)
|
renameRepository(repository.owner, repository.name, form.newOwner, repository.name)
|
||||||
|
// Record activity log
|
||||||
|
val renameInfo = RenameRepositoryInfo(
|
||||||
|
form.newOwner,
|
||||||
|
repository.name,
|
||||||
|
loginAccount.userName,
|
||||||
|
repository.owner
|
||||||
|
)
|
||||||
|
recordActivity(renameInfo)
|
||||||
}
|
}
|
||||||
redirect(s"/${form.newOwner}/${repository.name}")
|
redirect(s"/${form.newOwner}/${repository.name}")
|
||||||
|
} else Forbidden()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the repository.
|
* Delete the repository.
|
||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/delete")(ownerOnly { repository =>
|
post("/:owner/:repository/settings/delete")(ownerOnly { repository =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
|
if (context.settings.basicBehavior.repositoryOperation.delete || loginAccount.isAdmin) {
|
||||||
// Delete the repository and related files
|
// Delete the repository and related files
|
||||||
deleteRepository(repository.repository)
|
deleteRepository(repository.repository)
|
||||||
redirect(s"/${repository.owner}")
|
redirect(s"/${repository.owner}")
|
||||||
|
} else Forbidden()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -386,11 +463,11 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/gc")(ownerOnly { repository =>
|
post("/:owner/:repository/settings/gc")(ownerOnly { repository =>
|
||||||
LockUtil.lock(s"${repository.owner}/${repository.name}") {
|
LockUtil.lock(s"${repository.owner}/${repository.name}") {
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git.gc().call()
|
git.gc().call()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flash += "info" -> "Garbage collection has been executed."
|
flash.update("info", "Garbage collection has been executed.")
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/danger")
|
redirect(s"/${repository.owner}/${repository.name}/settings/danger")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -412,10 +489,65 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
redirect(s"/${repository.owner}/${repository.name}/settings/deploykey")
|
redirect(s"/${repository.owner}/${repository.name}/settings/deploykey")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** Custom fields for issues and pull requests */
|
||||||
|
get("/:owner/:repository/settings/issues")(ownerOnly { repository =>
|
||||||
|
val customFields = getCustomFields(repository.owner, repository.name)
|
||||||
|
html.issues(customFields, repository)
|
||||||
|
})
|
||||||
|
|
||||||
|
/** New custom field form */
|
||||||
|
get("/:owner/:repository/settings/issues/fields/new")(ownerOnly { repository =>
|
||||||
|
html.issuesfieldform(None, repository)
|
||||||
|
})
|
||||||
|
|
||||||
|
/** Add custom field */
|
||||||
|
ajaxPost("/:owner/:repository/settings/issues/fields/new", customFieldForm)(ownerOnly { (form, repository) =>
|
||||||
|
val fieldId = createCustomField(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
form.fieldName,
|
||||||
|
form.fieldType,
|
||||||
|
if (form.fieldType == "enum") form.constraints else None,
|
||||||
|
form.enableForIssues,
|
||||||
|
form.enableForPullRequests
|
||||||
|
)
|
||||||
|
html.issuesfield(getCustomField(repository.owner, repository.name, fieldId).get)
|
||||||
|
})
|
||||||
|
|
||||||
|
/** Edit custom field form */
|
||||||
|
ajaxGet("/:owner/:repository/settings/issues/fields/:fieldId/edit")(ownerOnly { repository =>
|
||||||
|
getCustomField(repository.owner, repository.name, params("fieldId").toInt).map { customField =>
|
||||||
|
html.issuesfieldform(Some(customField), repository)
|
||||||
|
} getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/** Update custom field */
|
||||||
|
ajaxPost("/:owner/:repository/settings/issues/fields/:fieldId/edit", customFieldForm)(ownerOnly {
|
||||||
|
(form, repository) =>
|
||||||
|
updateCustomField(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
params("fieldId").toInt,
|
||||||
|
form.fieldName,
|
||||||
|
form.fieldType,
|
||||||
|
if (form.fieldType == "enum") form.constraints else None,
|
||||||
|
form.enableForIssues,
|
||||||
|
form.enableForPullRequests
|
||||||
|
)
|
||||||
|
html.issuesfield(getCustomField(repository.owner, repository.name, params("fieldId").toInt).get)
|
||||||
|
})
|
||||||
|
|
||||||
|
/** Delete custom field */
|
||||||
|
ajaxPost("/:owner/:repository/settings/issues/fields/:fieldId/delete")(ownerOnly { repository =>
|
||||||
|
deleteCustomField(repository.owner, repository.name, params("fieldId").toInt)
|
||||||
|
Ok()
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides duplication check for web hook url.
|
* Provides duplication check for web hook url.
|
||||||
*/
|
*/
|
||||||
private def webHook(needExists: Boolean): Constraint = new Constraint() {
|
private def webHook(needExists: Boolean): Constraint =
|
||||||
|
new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
||||||
if (getWebHook(params("owner"), params("repository"), value).isDefined != needExists) {
|
if (getWebHook(params("owner"), params("repository"), value).isDefined != needExists) {
|
||||||
Some(if (needExists) {
|
Some(if (needExists) {
|
||||||
@@ -428,7 +560,8 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def webhookEvents = new ValueType[Set[WebHook.Event]] {
|
private def webhookEvents =
|
||||||
|
new ValueType[Set[WebHook.Event]] {
|
||||||
def convert(name: String, params: Map[String, Seq[String]], messages: Messages): Set[WebHook.Event] = {
|
def convert(name: String, params: Map[String, Seq[String]], messages: Messages): Set[WebHook.Event] = {
|
||||||
WebHook.Event.values.flatMap { t =>
|
WebHook.Event.values.flatMap { t =>
|
||||||
params.get(name + "." + t.name).map(_ => t)
|
params.get(name + "." + t.name).map(_ => t)
|
||||||
@@ -460,7 +593,8 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
/**
|
/**
|
||||||
* Duplicate check for the rename repository name.
|
* Duplicate check for the rename repository name.
|
||||||
*/
|
*/
|
||||||
private def renameRepositoryName: Constraint = new Constraint() {
|
private def renameRepositoryName: Constraint =
|
||||||
|
new Constraint() {
|
||||||
override def validate(
|
override def validate(
|
||||||
name: String,
|
name: String,
|
||||||
value: String,
|
value: String,
|
||||||
@@ -478,9 +612,9 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private def featureOption: Constraint = new Constraint() {
|
private def featureOption: Constraint =
|
||||||
|
new Constraint() {
|
||||||
override def validate(
|
override def validate(
|
||||||
name: String,
|
name: String,
|
||||||
value: String,
|
value: String,
|
||||||
@@ -493,7 +627,8 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
/**
|
/**
|
||||||
* Provides Constraint to validate the repository transfer user.
|
* Provides Constraint to validate the repository transfer user.
|
||||||
*/
|
*/
|
||||||
private def transferUser: Constraint = new Constraint() {
|
private def transferUser: Constraint =
|
||||||
|
new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
||||||
getAccountByUserName(value) match {
|
getAccountByUserName(value) match {
|
||||||
case None => Some("User does not exist.")
|
case None => Some("User does not exist.")
|
||||||
@@ -510,11 +645,16 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def mergeOptions = new ValueType[Seq[String]] {
|
private def mergeOptions =
|
||||||
|
new ValueType[Seq[String]] {
|
||||||
override def convert(name: String, params: Map[String, Seq[String]], messages: Messages): Seq[String] = {
|
override def convert(name: String, params: Map[String, Seq[String]], messages: Messages): Seq[String] = {
|
||||||
params.getOrElse("mergeOptions", Nil)
|
params.getOrElse("mergeOptions", Nil)
|
||||||
}
|
}
|
||||||
override def validate(name: String, params: Map[String, Seq[String]], messages: Messages): Seq[(String, String)] = {
|
override def validate(
|
||||||
|
name: String,
|
||||||
|
params: Map[String, Seq[String]],
|
||||||
|
messages: Messages
|
||||||
|
): Seq[(String, String)] = {
|
||||||
val mergeOptions = params.getOrElse("mergeOptions", Nil)
|
val mergeOptions = params.getOrElse("mergeOptions", Nil)
|
||||||
if (mergeOptions.isEmpty) {
|
if (mergeOptions.isEmpty) {
|
||||||
Seq("mergeOptions" -> "At least one option must be enabled.")
|
Seq("mergeOptions" -> "At least one option must be enabled.")
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,13 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
|
|
||||||
import com.github.zafarkhaja.semver.{Version => Semver}
|
|
||||||
import gitbucket.core.GitBucketCoreModule
|
|
||||||
import gitbucket.core.admin.html
|
import gitbucket.core.admin.html
|
||||||
import gitbucket.core.plugin.{PluginInfoBase, PluginRegistry, PluginRepository}
|
import gitbucket.core.plugin.PluginRegistry
|
||||||
import gitbucket.core.service.SystemSettingsService._
|
import gitbucket.core.service.SystemSettingsService._
|
||||||
import gitbucket.core.service.{AccountService, RepositoryService}
|
import gitbucket.core.service.{AccountService, RepositoryService}
|
||||||
import gitbucket.core.ssh.SshServer
|
import gitbucket.core.ssh.SshServer
|
||||||
import gitbucket.core.util.Directory._
|
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.StringUtil._
|
import gitbucket.core.util.StringUtil._
|
||||||
import gitbucket.core.util.SyntaxSugars._
|
|
||||||
import gitbucket.core.util.{AdminAuthenticator, Mailer}
|
import gitbucket.core.util.{AdminAuthenticator, Mailer}
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.apache.commons.mail.EmailException
|
import org.apache.commons.mail.EmailException
|
||||||
@@ -21,8 +16,8 @@ import org.scalatra._
|
|||||||
import org.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
import org.scalatra.i18n.Messages
|
import org.scalatra.i18n.Messages
|
||||||
|
|
||||||
import scala.collection.JavaConverters._
|
|
||||||
import scala.collection.mutable.ListBuffer
|
import scala.collection.mutable.ListBuffer
|
||||||
|
import scala.util.Using
|
||||||
|
|
||||||
class SystemSettingsController
|
class SystemSettingsController
|
||||||
extends SystemSettingsControllerBase
|
extends SystemSettingsControllerBase
|
||||||
@@ -39,16 +34,36 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
private val form = mapping(
|
private val form = mapping(
|
||||||
"baseUrl" -> trim(label("Base URL", optional(text()))),
|
"baseUrl" -> trim(label("Base URL", optional(text()))),
|
||||||
"information" -> trim(label("Information", optional(text()))),
|
"information" -> trim(label("Information", optional(text()))),
|
||||||
|
"basicBehavior" -> mapping(
|
||||||
"allowAccountRegistration" -> trim(label("Account registration", boolean())),
|
"allowAccountRegistration" -> trim(label("Account registration", boolean())),
|
||||||
|
"allowResetPassword" -> trim(label("Reset password", boolean())),
|
||||||
"allowAnonymousAccess" -> trim(label("Anonymous access", boolean())),
|
"allowAnonymousAccess" -> trim(label("Anonymous access", boolean())),
|
||||||
"isCreateRepoOptionPublic" -> trim(label("Default option to create a new repository", boolean())),
|
"isCreateRepoOptionPublic" -> trim(label("Default visibility of new repository", boolean())),
|
||||||
|
"repositoryOperation" -> mapping(
|
||||||
|
"create" -> trim(label("Allow all users to create repository", boolean())),
|
||||||
|
"delete" -> trim(label("Allow all users to delete repository", boolean())),
|
||||||
|
"rename" -> trim(label("Allow all users to rename repository", boolean())),
|
||||||
|
"transfer" -> trim(label("Allow all users to transfer repository", boolean())),
|
||||||
|
"fork" -> trim(label("Allow all users to fork repository", boolean()))
|
||||||
|
)(RepositoryOperation.apply),
|
||||||
"gravatar" -> trim(label("Gravatar", boolean())),
|
"gravatar" -> trim(label("Gravatar", boolean())),
|
||||||
"notification" -> trim(label("Notification", boolean())),
|
"notification" -> trim(label("Notification", boolean())),
|
||||||
"activityLogLimit" -> trim(label("Limit of activity logs", optional(number()))),
|
"limitVisibleRepositories" -> trim(label("limitVisibleRepositories", boolean())),
|
||||||
|
)(BasicBehavior.apply),
|
||||||
"ssh" -> mapping(
|
"ssh" -> mapping(
|
||||||
"enabled" -> trim(label("SSH access", boolean())),
|
"enabled" -> trim(label("SSH access", boolean())),
|
||||||
"host" -> trim(label("SSH host", optional(text()))),
|
"bindAddress" -> mapping(
|
||||||
"port" -> trim(label("SSH port", optional(number()))),
|
"host" -> trim(label("Bind SSH host", optional(text()))),
|
||||||
|
"port" -> trim(label("Bind SSH port", optional(number()))),
|
||||||
|
)((hostOption, portOption) =>
|
||||||
|
hostOption.map(h => SshAddress(h, portOption.getOrElse(DefaultSshPort), GenericSshUser))
|
||||||
|
),
|
||||||
|
"publicAddress" -> mapping(
|
||||||
|
"host" -> trim(label("Public SSH host", optional(text()))),
|
||||||
|
"port" -> trim(label("Public SSH port", optional(number()))),
|
||||||
|
)((hostOption, portOption) =>
|
||||||
|
hostOption.map(h => SshAddress(h, portOption.getOrElse(PublicSshPort), GenericSshUser))
|
||||||
|
),
|
||||||
)(Ssh.apply),
|
)(Ssh.apply),
|
||||||
"useSMTP" -> trim(label("SMTP", boolean())),
|
"useSMTP" -> trim(label("SMTP", boolean())),
|
||||||
"smtp" -> optionalIfNotChecked(
|
"smtp" -> optionalIfNotChecked(
|
||||||
@@ -93,24 +108,31 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
)(OIDC.apply)
|
)(OIDC.apply)
|
||||||
),
|
),
|
||||||
"skinName" -> trim(label("AdminLTE skin name", text(required))),
|
"skinName" -> trim(label("AdminLTE skin name", text(required))),
|
||||||
|
"userDefinedCss" -> trim(label("User-defined CSS", optional(text()))),
|
||||||
"showMailAddress" -> trim(label("Show mail address", boolean())),
|
"showMailAddress" -> trim(label("Show mail address", boolean())),
|
||||||
"pluginNetworkInstall" -> trim(label("Network plugin installation", boolean())),
|
"webhook" -> mapping(
|
||||||
"proxy" -> optionalIfNotChecked(
|
"blockPrivateAddress" -> trim(label("Block private address", boolean())),
|
||||||
"useProxy",
|
"whitelist" -> trim(label("Whitelist", multiLineText()))
|
||||||
mapping(
|
)(WebHook.apply),
|
||||||
"host" -> trim(label("Proxy host", text(required))),
|
"upload" -> mapping(
|
||||||
"port" -> trim(label("Proxy port", number())),
|
"maxFileSize" -> trim(label("Max file size", long(required))),
|
||||||
"user" -> trim(label("Keystore", optional(text()))),
|
"timeout" -> trim(label("Timeout", long(required))),
|
||||||
"password" -> trim(label("Keystore", optional(text())))
|
"largeMaxFileSize" -> trim(label("Max file size for large file", long(required))),
|
||||||
)(Proxy.apply)
|
"largeTimeout" -> trim(label("Timeout for large file", long(required)))
|
||||||
)
|
)(Upload.apply),
|
||||||
|
"repositoryViewer" -> mapping(
|
||||||
|
"maxFiles" -> trim(label("Max files", number(required))),
|
||||||
|
"maxDiffFiles" -> trim(label("Max diff files", number(required))),
|
||||||
|
"maxDiffLines" -> trim(label("Max diff lines", number(required)))
|
||||||
|
)(RepositoryViewerSettings.apply),
|
||||||
|
"defaultBranch" -> trim(label("Default branch", text(required)))
|
||||||
)(SystemSettings.apply).verifying { settings =>
|
)(SystemSettings.apply).verifying { settings =>
|
||||||
Vector(
|
Vector(
|
||||||
if (settings.ssh.enabled && settings.baseUrl.isEmpty) {
|
if (settings.ssh.enabled && settings.baseUrl.isEmpty) {
|
||||||
Some("baseUrl" -> "Base URL is required if SSH access is enabled.")
|
Some("baseUrl" -> "Base URL is required if SSH access is enabled.")
|
||||||
} else None,
|
} else None,
|
||||||
if (settings.ssh.enabled && settings.ssh.sshHost.isEmpty) {
|
if (settings.ssh.enabled && settings.ssh.bindAddress.isEmpty) {
|
||||||
Some("sshHost" -> "SSH host is required if SSH access is enabled.")
|
Some("ssh.bindAddress.host" -> "SSH bind host is required if SSH access is enabled.")
|
||||||
} else None
|
} else None
|
||||||
).flatten
|
).flatten
|
||||||
}
|
}
|
||||||
@@ -179,7 +201,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
val newUserForm = mapping(
|
val newUserForm = mapping(
|
||||||
"userName" -> trim(label("Username", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
"userName" -> trim(label("Username", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
"password" -> trim(label("Password", text(required, maxlength(20), password))),
|
"password" -> trim(label("Password", text(required, maxlength(40)))),
|
||||||
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress()))),
|
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress()))),
|
||||||
"extraMailAddresses" -> list(
|
"extraMailAddresses" -> list(
|
||||||
@@ -193,7 +215,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
val editUserForm = mapping(
|
val editUserForm = mapping(
|
||||||
"userName" -> trim(label("Username", text(required, maxlength(100), identifier))),
|
"userName" -> trim(label("Username", text(required, maxlength(100), identifier))),
|
||||||
"password" -> trim(label("Password", optional(text(maxlength(20), password)))),
|
"password" -> trim(label("Password", optional(text(maxlength(40))))),
|
||||||
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress("userName")))),
|
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress("userName")))),
|
||||||
"extraMailAddresses" -> list(
|
"extraMailAddresses" -> list(
|
||||||
@@ -229,30 +251,29 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
val conn = request2Session(request).conn
|
val conn = request2Session(request).conn
|
||||||
val meta = conn.getMetaData
|
val meta = conn.getMetaData
|
||||||
val tables = ListBuffer[Table]()
|
val tables = ListBuffer[Table]()
|
||||||
using(meta.getTables(null, "%", "%", Array("TABLE", "VIEW"))) {
|
Using.resource(meta.getTables(null, "%", "%", Array("TABLE", "VIEW"))) { rs =>
|
||||||
rs =>
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
val tableName = rs.getString("TABLE_NAME")
|
val tableName = rs.getString("TABLE_NAME")
|
||||||
|
|
||||||
val pkColumns = ListBuffer[String]()
|
val pkColumns = ListBuffer[String]()
|
||||||
using(meta.getPrimaryKeys(null, null, tableName)) { rs =>
|
Using.resource(meta.getPrimaryKeys(null, null, tableName)) { rs =>
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
pkColumns += rs.getString("COLUMN_NAME").toUpperCase
|
pkColumns += rs.getString("COLUMN_NAME").toUpperCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val columns = ListBuffer[Column]()
|
val columns = ListBuffer[Column]()
|
||||||
using(meta.getColumns(null, "%", tableName, "%")) { rs =>
|
Using.resource(meta.getColumns(null, "%", tableName, "%")) { rs =>
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
val columnName = rs.getString("COLUMN_NAME").toUpperCase
|
val columnName = rs.getString("COLUMN_NAME").toUpperCase
|
||||||
columns += Column(columnName, pkColumns.contains(columnName))
|
columns += Column(columnName, pkColumns.contains(columnName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tables += Table(tableName.toUpperCase, columns)
|
tables += Table(tableName.toUpperCase, columns.toSeq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
html.dbviewer(tables)
|
html.dbviewer(tables.toSeq)
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/dbviewer/_query")(adminOnly {
|
post("/admin/dbviewer/_query")(adminOnly {
|
||||||
@@ -263,11 +284,9 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
if (trimmedQuery.nonEmpty) {
|
if (trimmedQuery.nonEmpty) {
|
||||||
try {
|
try {
|
||||||
val conn = request2Session(request).conn
|
val conn = request2Session(request).conn
|
||||||
using(conn.prepareStatement(query)) {
|
Using.resource(conn.prepareStatement(query)) { stmt =>
|
||||||
stmt =>
|
|
||||||
if (trimmedQuery.toUpperCase.startsWith("SELECT")) {
|
if (trimmedQuery.toUpperCase.startsWith("SELECT")) {
|
||||||
using(stmt.executeQuery()) {
|
Using.resource(stmt.executeQuery()) { rs =>
|
||||||
rs =>
|
|
||||||
val meta = rs.getMetaData
|
val meta = rs.getMetaData
|
||||||
val columns = for (i <- 1 to meta.getColumnCount) yield {
|
val columns = for (i <- 1 to meta.getColumnCount) yield {
|
||||||
meta.getColumnName(i)
|
meta.getColumnName(i)
|
||||||
@@ -301,21 +320,29 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
post("/admin/system", form)(adminOnly { form =>
|
post("/admin/system", form)(adminOnly { form =>
|
||||||
saveSystemSettings(form)
|
saveSystemSettings(form)
|
||||||
|
|
||||||
if (form.sshAddress != context.settings.sshAddress) {
|
if (
|
||||||
|
form.ssh.bindAddress != context.settings.sshBindAddress || form.ssh.publicAddress != context.settings.sshPublicAddress
|
||||||
|
) {
|
||||||
SshServer.stop()
|
SshServer.stop()
|
||||||
for {
|
for {
|
||||||
sshAddress <- form.sshAddress
|
bindAddress <- form.ssh.bindAddress
|
||||||
|
publicAddress <- form.ssh.publicAddress.orElse(form.ssh.bindAddress)
|
||||||
baseUrl <- form.baseUrl
|
baseUrl <- form.baseUrl
|
||||||
} SshServer.start(sshAddress, baseUrl)
|
} SshServer.start(bindAddress, publicAddress, baseUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
flash += "info" -> "System settings has been updated."
|
flash.update("info", "System settings has been updated.")
|
||||||
redirect("/admin/system")
|
redirect("/admin/system")
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/system/sendmail", sendMailForm)(adminOnly { form =>
|
post("/admin/system/sendmail", sendMailForm)(adminOnly { form =>
|
||||||
try {
|
try {
|
||||||
new Mailer(context.settings.copy(smtp = Some(form.smtp), notification = true)).send(
|
new Mailer(
|
||||||
|
context.settings.copy(
|
||||||
|
smtp = Some(form.smtp),
|
||||||
|
basicBehavior = context.settings.basicBehavior.copy(notification = true)
|
||||||
|
)
|
||||||
|
).send(
|
||||||
to = form.testAddress,
|
to = form.testAddress,
|
||||||
subject = "Test message from GitBucket",
|
subject = "Test message from GitBucket",
|
||||||
textMsg = "This is a test message from GitBucket.",
|
textMsg = "This is a test message from GitBucket.",
|
||||||
@@ -332,63 +359,12 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/admin/plugins")(adminOnly {
|
get("/admin/plugins")(adminOnly {
|
||||||
// Installed plugins
|
html.plugins(PluginRegistry().getPlugins(), flash.get("info"))
|
||||||
val enabledPlugins = PluginRegistry().getPlugins()
|
|
||||||
val gitbucketVersion = GitBucketCoreModule.getVersions.asScala.last.getVersion
|
|
||||||
val gitbucketSemver = Semver.valueOf(gitbucketVersion)
|
|
||||||
|
|
||||||
// Plugins in the remote repository
|
|
||||||
val repositoryPlugins = if (context.settings.pluginNetworkInstall) {
|
|
||||||
PluginRepository
|
|
||||||
.getPlugins()
|
|
||||||
.map {
|
|
||||||
meta =>
|
|
||||||
(meta, meta.versions.reverse.find {
|
|
||||||
version =>
|
|
||||||
val semver = Semver.valueOf(version.version)
|
|
||||||
gitbucketVersion == version.gitbucketVersion && !enabledPlugins.exists { plugin =>
|
|
||||||
if (plugin.pluginId == meta.id) {
|
|
||||||
Semver.valueOf(plugin.pluginVersion) match {
|
|
||||||
case x if x.greaterThan(semver) => true
|
|
||||||
case x if x.equals(semver) =>
|
|
||||||
plugin.gitbucketVersion match {
|
|
||||||
case None => true
|
|
||||||
case Some(x) => Semver.valueOf(x).greaterThanOrEqualTo(gitbucketSemver)
|
|
||||||
}
|
|
||||||
case _ => false
|
|
||||||
}
|
|
||||||
} else false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.collect {
|
|
||||||
case (meta, Some(version)) =>
|
|
||||||
new PluginInfoBase(
|
|
||||||
pluginId = meta.id,
|
|
||||||
pluginName = meta.name,
|
|
||||||
pluginVersion = version.version,
|
|
||||||
gitbucketVersion = Some(version.gitbucketVersion),
|
|
||||||
description = meta.description
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else Nil
|
|
||||||
|
|
||||||
// Merge
|
|
||||||
val plugins = (enabledPlugins.map((_, true)) ++ repositoryPlugins.map((_, false)))
|
|
||||||
.groupBy(_._1.pluginId)
|
|
||||||
.map {
|
|
||||||
case (pluginId, plugins) =>
|
|
||||||
val (plugin, enabled) = plugins.head
|
|
||||||
(plugin, enabled, if (plugins.length > 1) plugins.last._1.pluginVersion else "")
|
|
||||||
}
|
|
||||||
.toList
|
|
||||||
|
|
||||||
html.plugins(plugins, flash.get("info"))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/plugins/_reload")(adminOnly {
|
post("/admin/plugins/_reload")(adminOnly {
|
||||||
PluginRegistry.reload(request.getServletContext(), loadSystemSettings(), request2Session(request).conn)
|
PluginRegistry.reload(request.getServletContext(), loadSystemSettings(), request2Session(request).conn)
|
||||||
flash += "info" -> "All plugins were reloaded."
|
flash.update("info", "All plugins were reloaded.")
|
||||||
redirect("/admin/plugins")
|
redirect("/admin/plugins")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -398,45 +374,15 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
if (PluginRegistry().getPlugins().exists(_.pluginId == pluginId)) {
|
if (PluginRegistry().getPlugins().exists(_.pluginId == pluginId)) {
|
||||||
PluginRegistry
|
PluginRegistry
|
||||||
.uninstall(pluginId, request.getServletContext, loadSystemSettings(), request2Session(request).conn)
|
.uninstall(pluginId, request.getServletContext, loadSystemSettings(), request2Session(request).conn)
|
||||||
flash += "info" -> s"${pluginId} was uninstalled."
|
flash.update("info", s"${pluginId} was uninstalled.")
|
||||||
}
|
|
||||||
|
|
||||||
redirect("/admin/plugins")
|
|
||||||
})
|
|
||||||
|
|
||||||
post("/admin/plugins/:pluginId/:version/_install")(adminOnly {
|
|
||||||
if (context.settings.pluginNetworkInstall) {
|
|
||||||
val pluginId = params("pluginId")
|
|
||||||
val version = params("version")
|
|
||||||
val gitbucketVersion = GitBucketCoreModule.getVersions.asScala.last.getVersion
|
|
||||||
|
|
||||||
PluginRepository
|
|
||||||
.getPlugins()
|
|
||||||
.collectFirst {
|
|
||||||
case meta if meta.id == pluginId =>
|
|
||||||
(meta, meta.versions.find(x => x.gitbucketVersion == gitbucketVersion && x.version == version))
|
|
||||||
}
|
|
||||||
.foreach {
|
|
||||||
case (meta, version) =>
|
|
||||||
version.foreach { version =>
|
|
||||||
PluginRegistry.install(
|
|
||||||
pluginId,
|
|
||||||
new java.net.URL(version.url),
|
|
||||||
request.getServletContext,
|
|
||||||
loadSystemSettings(),
|
|
||||||
request2Session(request).conn
|
|
||||||
)
|
|
||||||
flash += "info" -> s"${pluginId}:${version.version} was installed."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect("/admin/plugins")
|
redirect("/admin/plugins")
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/admin/users")(adminOnly {
|
get("/admin/users")(adminOnly {
|
||||||
val includeRemoved = params.get("includeRemoved").map(_.toBoolean).getOrElse(false)
|
val includeRemoved = params.get("includeRemoved").exists(_.toBoolean)
|
||||||
val includeGroups = params.get("includeGroups").map(_.toBoolean).getOrElse(false)
|
val includeGroups = params.get("includeGroups").exists(_.toBoolean)
|
||||||
val users = getAllUsers(includeRemoved, includeGroups)
|
val users = getAllUsers(includeRemoved, includeGroups)
|
||||||
val members = users.collect {
|
val members = users.collect {
|
||||||
case account if (account.isGroupAccount) =>
|
case account if (account.isGroupAccount) =>
|
||||||
@@ -473,10 +419,9 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
post("/admin/users/:name/_edituser", editUserForm)(adminOnly { form =>
|
post("/admin/users/:name/_edituser", editUserForm)(adminOnly { form =>
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName, true).map {
|
getAccountByUserName(userName, true).map { account =>
|
||||||
account =>
|
|
||||||
if (account.isAdmin && (form.isRemoved || !form.isAdmin) && isLastAdministrator(account)) {
|
if (account.isAdmin && (form.isRemoved || !form.isAdmin) && isLastAdministrator(account)) {
|
||||||
flash += "error" -> "Account can't be turned off because this is last one administrator."
|
flash.update("error", "Account can't be turned off because this is last one administrator.")
|
||||||
redirect(s"/admin/users/${userName}/_edituser")
|
redirect(s"/admin/users/${userName}/_edituser")
|
||||||
} else {
|
} else {
|
||||||
if (form.isRemoved) {
|
if (form.isRemoved) {
|
||||||
@@ -536,15 +481,13 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/admin/users/:groupName/_editgroup")(adminOnly {
|
get("/admin/users/:groupName/_editgroup")(adminOnly {
|
||||||
defining(params("groupName")) { groupName =>
|
val groupName = params("groupName")
|
||||||
html.usergroup(getAccountByUserName(groupName, true), getGroupMembers(groupName))
|
html.usergroup(getAccountByUserName(groupName, true), getGroupMembers(groupName))
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/users/:groupName/_editgroup", editGroupForm)(adminOnly { form =>
|
post("/admin/users/:groupName/_editgroup", editGroupForm)(adminOnly { form =>
|
||||||
defining(
|
val groupName = params("groupName")
|
||||||
params("groupName"),
|
val members = form.members
|
||||||
form.members
|
|
||||||
.split(",")
|
.split(",")
|
||||||
.map {
|
.map {
|
||||||
_.split(":") match {
|
_.split(":") match {
|
||||||
@@ -552,10 +495,8 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.toList
|
.toList
|
||||||
) {
|
|
||||||
case (groupName, members) =>
|
getAccountByUserName(groupName, true).map { account =>
|
||||||
getAccountByUserName(groupName, true).map {
|
|
||||||
account =>
|
|
||||||
updateGroup(groupName, form.description, form.url, form.isRemoved)
|
updateGroup(groupName, form.description, form.url, form.isRemoved)
|
||||||
|
|
||||||
if (form.isRemoved) {
|
if (form.isRemoved) {
|
||||||
@@ -584,7 +525,6 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
redirect("/admin/users")
|
redirect("/admin/users")
|
||||||
|
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/admin/data")(adminOnly {
|
get("/admin/data")(adminOnly {
|
||||||
@@ -601,30 +541,44 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName)
|
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName)
|
||||||
response.setContentLength(file.length.toInt)
|
response.setContentLength(file.length.toInt)
|
||||||
|
|
||||||
using(new FileInputStream(file)) { in =>
|
Using.resource(new FileInputStream(file)) { in =>
|
||||||
IOUtils.copy(in, response.outputStream)
|
IOUtils.copy(in, response.outputStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
()
|
()
|
||||||
})
|
})
|
||||||
|
|
||||||
private def members: Constraint = new Constraint() {
|
private def multiLineText(constraints: Constraint*): SingleValueType[Seq[String]] =
|
||||||
|
new SingleValueType[Seq[String]](constraints*) {
|
||||||
|
def convert(value: String, messages: Messages): Seq[String] = {
|
||||||
|
if (value == null) {
|
||||||
|
Nil
|
||||||
|
} else {
|
||||||
|
value.split("\n").toIndexedSeq.map(_.trim)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private def members: Constraint =
|
||||||
|
new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
||||||
if (value.split(",").exists {
|
if (
|
||||||
|
value.split(",").exists {
|
||||||
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
|
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
|
||||||
}) None
|
}
|
||||||
|
) None
|
||||||
else Some("Must select one manager at least.")
|
else Some("Must select one manager at least.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected def disableByNotYourself(paramName: String): Constraint = new Constraint() {
|
protected def disableByNotYourself(paramName: String): Constraint =
|
||||||
|
new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
||||||
params.get(paramName).flatMap { userName =>
|
for {
|
||||||
if (userName == context.loginAccount.get.userName && params.get("removed") == Some("true"))
|
userName <- params.get(paramName)
|
||||||
Some("You can't disable your account yourself")
|
loginAccount <- context.loginAccount
|
||||||
else
|
if userName == loginAccount.userName && params.get("removed") == Some("true")
|
||||||
None
|
} yield "You can't disable your account yourself"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ trait ValidationSupport extends FormSupport { self: ServletBase with JacksonJson
|
|||||||
* Converts errors to JSON.
|
* Converts errors to JSON.
|
||||||
*/
|
*/
|
||||||
private def toJson(errors: Seq[(String, String)]): JObject =
|
private def toJson(errors: Seq[(String, String)]): JObject =
|
||||||
JObject(errors.map {
|
JObject(errors.map { case (key, value) =>
|
||||||
case (key, value) =>
|
|
||||||
JField(key, JString(value))
|
JField(key, JString(value))
|
||||||
}.toList)
|
}.toList)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.model.WebHook
|
import gitbucket.core.model.WebHook
|
||||||
|
import gitbucket.core.model.activity.{CreateWikiPageInfo, DeleteWikiInfo, EditWikiPageInfo}
|
||||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
import gitbucket.core.service.WebHookService.WebHookGollumPayload
|
import gitbucket.core.service.WebHookService.WebHookGollumPayload
|
||||||
import gitbucket.core.wiki.html
|
import gitbucket.core.wiki.html
|
||||||
@@ -14,6 +15,8 @@ import org.scalatra.forms._
|
|||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.scalatra.i18n.Messages
|
import org.scalatra.i18n.Messages
|
||||||
|
|
||||||
|
import scala.util.Using
|
||||||
|
|
||||||
class WikiController
|
class WikiController
|
||||||
extends WikiControllerBase
|
extends WikiControllerBase
|
||||||
with WikiService
|
with WikiService
|
||||||
@@ -23,6 +26,7 @@ class WikiController
|
|||||||
with WebHookService
|
with WebHookService
|
||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with ReferrerAuthenticator
|
with ReferrerAuthenticator
|
||||||
|
with RequestCache
|
||||||
|
|
||||||
trait WikiControllerBase extends ControllerBase {
|
trait WikiControllerBase extends ControllerBase {
|
||||||
self: WikiService
|
self: WikiService
|
||||||
@@ -42,7 +46,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val newForm = mapping(
|
val newForm = mapping(
|
||||||
"pageName" -> trim(label("Page name", text(required, maxlength(40), pagename, unique))),
|
"pageName" -> trim(label("Page name", text(required, maxlength(40), pageName, unique))),
|
||||||
"content" -> trim(label("Content", text(required, conflictForNew))),
|
"content" -> trim(label("Content", text(required, conflictForNew))),
|
||||||
"message" -> trim(label("Message", optional(text()))),
|
"message" -> trim(label("Message", optional(text()))),
|
||||||
"currentPageName" -> trim(label("Current page name", text())),
|
"currentPageName" -> trim(label("Current page name", text())),
|
||||||
@@ -50,7 +54,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
)(WikiPageEditForm.apply)
|
)(WikiPageEditForm.apply)
|
||||||
|
|
||||||
val editForm = mapping(
|
val editForm = mapping(
|
||||||
"pageName" -> trim(label("Page name", text(required, maxlength(40), pagename))),
|
"pageName" -> trim(label("Page name", text(required, maxlength(40), pageName))),
|
||||||
"content" -> trim(label("Content", text(required, conflictForEdit))),
|
"content" -> trim(label("Content", text(required, conflictForEdit))),
|
||||||
"message" -> trim(label("Message", optional(text()))),
|
"message" -> trim(label("Message", optional(text()))),
|
||||||
"currentPageName" -> trim(label("Current page name", text(required))),
|
"currentPageName" -> trim(label("Current page name", text(required))),
|
||||||
@@ -58,56 +62,76 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
)(WikiPageEditForm.apply)
|
)(WikiPageEditForm.apply)
|
||||||
|
|
||||||
get("/:owner/:repository/wiki")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki")(referrersOnly { repository =>
|
||||||
getWikiPage(repository.owner, repository.name, "Home").map { page =>
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
|
getWikiPage(repository.owner, repository.name, "Home", branch).map { page =>
|
||||||
html.page(
|
html.page(
|
||||||
"Home",
|
"Home",
|
||||||
page,
|
page,
|
||||||
getWikiPageList(repository.owner, repository.name),
|
getWikiPageList(repository.owner, repository.name, branch),
|
||||||
repository,
|
repository,
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
getWikiPage(repository.owner, repository.name, "_Sidebar"),
|
getWikiPage(repository.owner, repository.name, "_Sidebar", branch),
|
||||||
getWikiPage(repository.owner, repository.name, "_Footer")
|
getWikiPage(repository.owner, repository.name, "_Footer", branch)
|
||||||
)
|
)
|
||||||
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/Home/_edit")
|
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/Home/_edit")
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/:page")(referrersOnly { repository =>
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
getWikiPage(repository.owner, repository.name, pageName).map { page =>
|
getWikiPage(repository.owner, repository.name, pageName, branch).map { page =>
|
||||||
html.page(
|
html.page(
|
||||||
pageName,
|
pageName,
|
||||||
page,
|
page,
|
||||||
getWikiPageList(repository.owner, repository.name),
|
getWikiPageList(repository.owner, repository.name, branch),
|
||||||
repository,
|
repository,
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
getWikiPage(repository.owner, repository.name, "_Sidebar"),
|
getWikiPage(repository.owner, repository.name, "_Sidebar", branch),
|
||||||
getWikiPage(repository.owner, repository.name, "_Footer")
|
getWikiPage(repository.owner, repository.name, "_Footer", branch)
|
||||||
)
|
)
|
||||||
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}/_edit")
|
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}/_edit")
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_history")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_history")(referrersOnly { repository =>
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
using(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
JGitUtil.getCommitLog(git, "master", path = pageName + ".md") match {
|
JGitUtil.getCommitLog(git, branch, path = pageName + ".md") match {
|
||||||
case Right((logs, hasNext)) => html.history(Some(pageName), logs, repository, isEditable(repository))
|
case Right((logs, hasNext)) => html.history(Some(pageName), logs, repository, isEditable(repository))
|
||||||
case Left(_) => NotFound()
|
case Left(_) => NotFound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
private def getWikiBranch(owner: String, repository: String): String = {
|
||||||
|
Using.resource(Git.open(Directory.getWikiRepositoryDir(owner, repository))) { git =>
|
||||||
|
git.getRepository.getBranch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_compare/:commitId")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_compare/:commitId")(referrersOnly { repository =>
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||||
|
|
||||||
using(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
html.compare(
|
html.compare(
|
||||||
Some(pageName),
|
Some(pageName),
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
JGitUtil.getDiffs(git, Some(from), to, true, false).filter(_.newPath == pageName + ".md"),
|
JGitUtil
|
||||||
|
.getDiffs(
|
||||||
|
git = git,
|
||||||
|
from = Some(from),
|
||||||
|
to = to,
|
||||||
|
fetchContent = true,
|
||||||
|
makePatch = false,
|
||||||
|
maxFiles = context.settings.repositoryViewer.maxDiffFiles,
|
||||||
|
maxLines = context.settings.repositoryViewer.maxDiffLines
|
||||||
|
)
|
||||||
|
.filter(_.newPath == pageName + ".md"),
|
||||||
repository,
|
repository,
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
flash.get("info")
|
flash.get("info")
|
||||||
@@ -118,12 +142,20 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
get("/:owner/:repository/wiki/_compare/:commitId")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/_compare/:commitId")(referrersOnly { repository =>
|
||||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||||
|
|
||||||
using(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
html.compare(
|
html.compare(
|
||||||
None,
|
None,
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
JGitUtil.getDiffs(git, Some(from), to, true, false),
|
JGitUtil.getDiffs(
|
||||||
|
git = git,
|
||||||
|
from = Some(from),
|
||||||
|
to = to,
|
||||||
|
fetchContent = true,
|
||||||
|
makePatch = false,
|
||||||
|
maxFiles = context.settings.repositoryViewer.maxDiffFiles,
|
||||||
|
maxLines = context.settings.repositoryViewer.maxDiffLines
|
||||||
|
),
|
||||||
repository,
|
repository,
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
flash.get("info")
|
flash.get("info")
|
||||||
@@ -132,45 +164,52 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_revert/:commitId")(readableUsersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_revert/:commitId")(readableUsersOnly { repository =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||||
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
if (revertWikiPage(repository.owner, repository.name, from, to, context.loginAccount.get, Some(pageName))) {
|
if (revertWikiPage(repository.owner, repository.name, from, to, loginAccount, Some(pageName), branch)) {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}")
|
redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}")
|
||||||
} else {
|
} else {
|
||||||
flash += "info" -> "This patch was not able to be reversed."
|
flash.update("info", "This patch was not able to be reversed.")
|
||||||
redirect(
|
redirect(
|
||||||
s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}/_compare/${from}...${to}"
|
s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}/_compare/${from}...${to}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/_revert/:commitId")(readableUsersOnly { repository =>
|
get("/:owner/:repository/wiki/_revert/:commitId")(readableUsersOnly { repository =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||||
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
if (revertWikiPage(repository.owner, repository.name, from, to, context.loginAccount.get, None)) {
|
if (revertWikiPage(repository.owner, repository.name, from, to, loginAccount, None, branch)) {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/wiki")
|
redirect(s"/${repository.owner}/${repository.name}/wiki")
|
||||||
} else {
|
} else {
|
||||||
flash += "info" -> "This patch was not able to be reversed."
|
flash.update("info", "This patch was not able to be reversed.")
|
||||||
redirect(s"/${repository.owner}/${repository.name}/wiki/_compare/${from}...${to}")
|
redirect(s"/${repository.owner}/${repository.name}/wiki/_compare/${from}...${to}")
|
||||||
}
|
}
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_edit")(readableUsersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_edit")(readableUsersOnly { repository =>
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
html.edit(pageName, getWikiPage(repository.owner, repository.name, pageName), repository)
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
|
html.edit(pageName, getWikiPage(repository.owner, repository.name, pageName, branch), repository)
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/wiki/_edit", editForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/wiki/_edit", editForm)(readableUsersOnly { (form, repository) =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
defining(context.loginAccount.get) {
|
|
||||||
loginAccount =>
|
|
||||||
saveWikiPage(
|
saveWikiPage(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
repository.name,
|
repository.name,
|
||||||
@@ -180,17 +219,12 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
loginAccount,
|
loginAccount,
|
||||||
form.message.getOrElse(""),
|
form.message.getOrElse(""),
|
||||||
Some(form.id)
|
Some(form.id)
|
||||||
).foreach {
|
).foreach { commitId =>
|
||||||
commitId =>
|
|
||||||
updateLastActivityDate(repository.owner, repository.name)
|
updateLastActivityDate(repository.owner, repository.name)
|
||||||
recordEditWikiPageActivity(
|
val wikiEditInfo =
|
||||||
repository.owner,
|
EditWikiPageInfo(repository.owner, repository.name, loginAccount.userName, form.pageName, commitId)
|
||||||
repository.name,
|
recordActivity(wikiEditInfo)
|
||||||
loginAccount.userName,
|
callWebHookOf(repository.owner, repository.name, WebHook.Gollum, context.settings) {
|
||||||
form.pageName,
|
|
||||||
commitId
|
|
||||||
)
|
|
||||||
callWebHookOf(repository.owner, repository.name, WebHook.Gollum) {
|
|
||||||
getAccountByUserName(repository.owner).map { repositoryUser =>
|
getAccountByUserName(repository.owner).map { repositoryUser =>
|
||||||
WebHookGollumPayload("edited", form.pageName, commitId, repository, repositoryUser, loginAccount)
|
WebHookGollumPayload("edited", form.pageName, commitId, repository, repositoryUser, loginAccount)
|
||||||
}
|
}
|
||||||
@@ -201,8 +235,8 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
} else {
|
} else {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/wiki")
|
redirect(s"/${repository.owner}/${repository.name}/wiki")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/_new")(readableUsersOnly { repository =>
|
get("/:owner/:repository/wiki/_new")(readableUsersOnly { repository =>
|
||||||
@@ -212,9 +246,8 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/wiki/_new", newForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/wiki/_new", newForm)(readableUsersOnly { (form, repository) =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
defining(context.loginAccount.get) {
|
|
||||||
loginAccount =>
|
|
||||||
saveWikiPage(
|
saveWikiPage(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
repository.name,
|
repository.name,
|
||||||
@@ -224,11 +257,12 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
loginAccount,
|
loginAccount,
|
||||||
form.message.getOrElse(""),
|
form.message.getOrElse(""),
|
||||||
None
|
None
|
||||||
).foreach {
|
).foreach { commitId =>
|
||||||
commitId =>
|
|
||||||
updateLastActivityDate(repository.owner, repository.name)
|
updateLastActivityDate(repository.owner, repository.name)
|
||||||
recordCreateWikiPageActivity(repository.owner, repository.name, loginAccount.userName, form.pageName)
|
val createWikiPageInfo =
|
||||||
callWebHookOf(repository.owner, repository.name, WebHook.Gollum) {
|
CreateWikiPageInfo(repository.owner, repository.name, loginAccount.userName, form.pageName)
|
||||||
|
recordActivity(createWikiPageInfo)
|
||||||
|
callWebHookOf(repository.owner, repository.name, WebHook.Gollum, context.settings) {
|
||||||
getAccountByUserName(repository.owner).map { repositoryUser =>
|
getAccountByUserName(repository.owner).map { repositoryUser =>
|
||||||
WebHookGollumPayload("created", form.pageName, commitId, repository, repositoryUser, loginAccount)
|
WebHookGollumPayload("created", form.pageName, commitId, repository, repositoryUser, loginAccount)
|
||||||
}
|
}
|
||||||
@@ -240,15 +274,14 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
} else {
|
} else {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/wiki")
|
redirect(s"/${repository.owner}/${repository.name}/wiki")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_delete")(readableUsersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_delete")(readableUsersOnly { repository =>
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
|
|
||||||
defining(context.loginAccount.get) { loginAccount =>
|
|
||||||
deleteWikiPage(
|
deleteWikiPage(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
repository.name,
|
repository.name,
|
||||||
@@ -257,19 +290,27 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
loginAccount.mailAddress,
|
loginAccount.mailAddress,
|
||||||
s"Destroyed ${pageName}"
|
s"Destroyed ${pageName}"
|
||||||
)
|
)
|
||||||
|
val deleteWikiInfo = DeleteWikiInfo(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
loginAccount.userName,
|
||||||
|
pageName
|
||||||
|
)
|
||||||
|
recordActivity(deleteWikiInfo)
|
||||||
updateLastActivityDate(repository.owner, repository.name)
|
updateLastActivityDate(repository.owner, repository.name)
|
||||||
|
|
||||||
redirect(s"/${repository.owner}/${repository.name}/wiki")
|
redirect(s"/${repository.owner}/${repository.name}/wiki")
|
||||||
}
|
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/_pages")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/_pages")(referrersOnly { repository =>
|
||||||
html.pages(getWikiPageList(repository.owner, repository.name), repository, isEditable(repository))
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
html.pages(getWikiPageList(repository.owner, repository.name, branch), repository, isEditable(repository))
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/_history")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/_history")(referrersOnly { repository =>
|
||||||
using(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
JGitUtil.getCommitLog(git, "master") match {
|
JGitUtil.getCommitLog(git, "master") match {
|
||||||
case Right((logs, hasNext)) => html.history(None, logs, repository, isEditable(repository))
|
case Right((logs, hasNext)) => html.history(None, logs, repository, isEditable(repository))
|
||||||
case Left(_) => NotFound()
|
case Left(_) => NotFound()
|
||||||
@@ -279,7 +320,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
get("/:owner/:repository/wiki/_blob/*")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/_blob/*")(referrersOnly { repository =>
|
||||||
val path = multiParams("splat").head
|
val path = multiParams("splat").head
|
||||||
using(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve("master"))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve("master"))
|
||||||
|
|
||||||
getPathObjectId(git, path, revCommit).map { objectId =>
|
getPathObjectId(git, path, revCommit).map { objectId =>
|
||||||
@@ -294,13 +335,18 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
value: String,
|
value: String,
|
||||||
params: Map[String, Seq[String]],
|
params: Map[String, Seq[String]],
|
||||||
messages: Messages
|
messages: Messages
|
||||||
): Option[String] =
|
): Option[String] = {
|
||||||
getWikiPageList(params.value("owner"), params.value("repository"))
|
val owner = params.value("owner")
|
||||||
|
val repository = params.value("repository")
|
||||||
|
val branch = getWikiBranch(owner, repository)
|
||||||
|
|
||||||
|
getWikiPageList(owner, repository, branch)
|
||||||
.find(_ == value)
|
.find(_ == value)
|
||||||
.map(_ => "Page already exists.")
|
.map(_ => "Page already exists.")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private def pagename: Constraint = new Constraint() {
|
private def pageName: Constraint = new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
||||||
if (value.exists("\\/:*?\"<>|".contains(_))) {
|
if (value.exists("\\/:*?\"<>|".contains(_))) {
|
||||||
Some(s"${name} contains invalid character.")
|
Some(s"${name} contains invalid character.")
|
||||||
@@ -311,7 +357,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def notReservedPageName(value: String) = !(Array[String]("_Sidebar", "_Footer") contains value)
|
private def notReservedPageName(value: String): Boolean = !(Array[String]("_Sidebar", "_Footer") contains value)
|
||||||
|
|
||||||
private def conflictForNew: Constraint = new Constraint() {
|
private def conflictForNew: Constraint = new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
||||||
@@ -329,7 +375,13 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def targetWikiPage = getWikiPage(params("owner"), params("repository"), params("pageName"))
|
private def targetWikiPage: Option[WikiService.WikiPageInfo] = {
|
||||||
|
val owner = params("owner")
|
||||||
|
val repository = params("repository")
|
||||||
|
val pageName = params("pageName")
|
||||||
|
val branch = getWikiBranch(owner, repository)
|
||||||
|
getWikiPage(owner, repository, pageName, branch)
|
||||||
|
}
|
||||||
|
|
||||||
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||||
repository.repository.options.wikiOption match {
|
repository.repository.options.wikiOption match {
|
||||||
|
|||||||
@@ -1,60 +1,160 @@
|
|||||||
package gitbucket.core.controller.api
|
package gitbucket.core.controller.api
|
||||||
import gitbucket.core.api.{ApiObject, ApiRef, JsonFormat}
|
import gitbucket.core.api.{ApiError, ApiRef, CreateARef, JsonFormat, UpdateARef}
|
||||||
import gitbucket.core.controller.ControllerBase
|
import gitbucket.core.controller.ControllerBase
|
||||||
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
import gitbucket.core.util.Directory.getRepositoryDir
|
import gitbucket.core.util.Directory.getRepositoryDir
|
||||||
import gitbucket.core.util.ReferrerAuthenticator
|
|
||||||
import gitbucket.core.util.SyntaxSugars.using
|
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
|
import gitbucket.core.util.{ReferrerAuthenticator, RepositoryName, WritableUsersAuthenticator}
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import scala.collection.JavaConverters._
|
import org.eclipse.jgit.lib.ObjectId
|
||||||
|
import org.eclipse.jgit.lib.RefUpdate.Result
|
||||||
|
import org.scalatra.{BadRequest, NoContent, UnprocessableEntity}
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
|
import scala.jdk.CollectionConverters._
|
||||||
|
import scala.util.Using
|
||||||
|
|
||||||
trait ApiGitReferenceControllerBase extends ControllerBase {
|
trait ApiGitReferenceControllerBase extends ControllerBase {
|
||||||
self: ReferrerAuthenticator =>
|
self: ReferrerAuthenticator with WritableUsersAuthenticator =>
|
||||||
|
|
||||||
/*
|
private val logger = LoggerFactory.getLogger(classOf[ApiGitReferenceControllerBase])
|
||||||
* i. Get a reference
|
|
||||||
* https://developer.github.com/v3/git/refs/#get-a-reference
|
|
||||||
*/
|
|
||||||
get("/api/v3/repos/:owner/:repository/git/refs/*")(referrersOnly { repository =>
|
|
||||||
val revstr = multiParams("splat").head
|
|
||||||
using(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
|
|
||||||
val ref = git.getRepository().findRef(revstr)
|
|
||||||
|
|
||||||
if (ref != null) {
|
get("/api/v3/repos/:owner/:repository/git/refs")(referrersOnly { repository =>
|
||||||
val sha = ref.getObjectId().name()
|
val result = Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
JsonFormat(ApiRef(revstr, ApiObject(sha)))
|
|
||||||
|
|
||||||
} else {
|
|
||||||
val refs = git
|
val refs = git
|
||||||
.getRepository()
|
.getRepository()
|
||||||
.getRefDatabase()
|
.getRefDatabase()
|
||||||
.getRefsByPrefix("refs/")
|
.getRefsByPrefix("refs")
|
||||||
.asScala
|
.asScala
|
||||||
|
|
||||||
JsonFormat(refs.map { ref =>
|
refs.map(ApiRef.fromRef(RepositoryName(s"${repository.owner}/${repository.name}"), _))
|
||||||
val sha = ref.getObjectId().name()
|
|
||||||
ApiRef(revstr, ApiObject(sha))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
JsonFormat(result)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* i. Get a reference
|
||||||
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#get-a-reference
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/git/ref/*")(referrersOnly { repository =>
|
||||||
|
val revstr = multiParams("splat").head
|
||||||
|
getRef(revstr, repository)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Some versions of GHE support this path
|
||||||
|
get("/api/v3/repos/:owner/:repository/git/refs/*")(referrersOnly { repository =>
|
||||||
|
logger.warn("git/refs/ endpoint may not be compatible with GitHub API v3. Consider using git/ref/ endpoint instead")
|
||||||
|
val revstr = multiParams("splat").head
|
||||||
|
getRef(revstr, repository)
|
||||||
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ii. Get all references
|
* ii. Get all references
|
||||||
* https://developer.github.com/v3/git/refs/#get-all-references
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#list-matching-references
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* iii. Create a reference
|
* iii. Create a reference
|
||||||
* https://developer.github.com/v3/git/refs/#create-a-reference
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#create-a-reference
|
||||||
*/
|
*/
|
||||||
|
post("/api/v3/repos/:owner/:repository/git/refs")(writableUsersOnly { repository =>
|
||||||
|
extractFromJsonBody[CreateARef].map { data =>
|
||||||
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
|
val ref = git.getRepository.findRef(data.ref)
|
||||||
|
if (ref == null) {
|
||||||
|
val update = git.getRepository.updateRef(data.ref)
|
||||||
|
update.setNewObjectId(ObjectId.fromString(data.sha))
|
||||||
|
val result = update.update()
|
||||||
|
result match {
|
||||||
|
case Result.NEW =>
|
||||||
|
JsonFormat(
|
||||||
|
ApiRef
|
||||||
|
.fromRef(RepositoryName(repository.owner, repository.name), git.getRepository.findRef(data.ref))
|
||||||
|
)
|
||||||
|
case _ => UnprocessableEntity(result.name())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UnprocessableEntity("Ref already exists.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} getOrElse BadRequest()
|
||||||
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* iv. Update a reference
|
* iv. Update a reference
|
||||||
* https://developer.github.com/v3/git/refs/#update-a-reference
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#update-a-reference
|
||||||
*/
|
*/
|
||||||
|
patch("/api/v3/repos/:owner/:repository/git/refs/*")(writableUsersOnly { repository =>
|
||||||
|
val refName = multiParams("splat").mkString("/")
|
||||||
|
extractFromJsonBody[UpdateARef].map { data =>
|
||||||
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
|
val ref = git.getRepository.findRef(refName)
|
||||||
|
if (ref == null) {
|
||||||
|
UnprocessableEntity("Ref does not exist.")
|
||||||
|
} else {
|
||||||
|
val update = git.getRepository.updateRef(ref.getName)
|
||||||
|
update.setNewObjectId(ObjectId.fromString(data.sha))
|
||||||
|
update.setForceUpdate(data.force)
|
||||||
|
val result = update.update()
|
||||||
|
result match {
|
||||||
|
case Result.FORCED | Result.FAST_FORWARD | Result.NO_CHANGE =>
|
||||||
|
JsonFormat(ApiRef.fromRef(RepositoryName(repository), git.getRepository.findRef(refName)))
|
||||||
|
case _ => UnprocessableEntity(result.name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} getOrElse BadRequest()
|
||||||
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* v. Delete a reference
|
* v. Delete a reference
|
||||||
* https://developer.github.com/v3/git/refs/#delete-a-reference
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#delete-a-reference
|
||||||
*/
|
*/
|
||||||
|
delete("/api/v3/repos/:owner/:repository/git/refs/*")(writableUsersOnly { _ =>
|
||||||
|
val refName = multiParams("splat").mkString("/")
|
||||||
|
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
|
||||||
|
val ref = git.getRepository.findRef(refName)
|
||||||
|
if (ref == null) {
|
||||||
|
UnprocessableEntity("Ref does not exist.")
|
||||||
|
} else {
|
||||||
|
val update = git.getRepository.updateRef(ref.getName)
|
||||||
|
update.setForceUpdate(true)
|
||||||
|
val result = update.delete()
|
||||||
|
result match {
|
||||||
|
case Result.FORCED => NoContent()
|
||||||
|
case _ => UnprocessableEntity(result.name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
private def notFound(): ApiError = {
|
||||||
|
response.setStatus(404)
|
||||||
|
ApiError("Not Found")
|
||||||
|
}
|
||||||
|
|
||||||
|
protected def getRef(revstr: String, repository: RepositoryInfo): AnyRef = {
|
||||||
|
logger.debug(s"getRef: path '${revstr}'")
|
||||||
|
|
||||||
|
val name = RepositoryName(repository)
|
||||||
|
val result = JsonFormat(revstr match {
|
||||||
|
case "tags" => repository.tags.map(ApiRef.fromTag(name, _))
|
||||||
|
case x if x.startsWith("tags/") =>
|
||||||
|
val tagName = x.substring("tags/".length)
|
||||||
|
repository.tags.find(_.name == tagName) match {
|
||||||
|
case Some(tagInfo) => ApiRef.fromTag(name, tagInfo)
|
||||||
|
case None => notFound()
|
||||||
|
}
|
||||||
|
case other =>
|
||||||
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
|
git.getRepository().findRef(other) match {
|
||||||
|
case null => notFound()
|
||||||
|
case ref => ApiRef.fromRef(name, ref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
logger.debug(s"json result: $result")
|
||||||
|
result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import gitbucket.core.controller.{Context, ControllerBase}
|
|||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.{ReadableUsersAuthenticator, ReferrerAuthenticator, RepositoryName}
|
import gitbucket.core.util.{ReadableUsersAuthenticator, ReferrerAuthenticator, RepositoryName}
|
||||||
|
import org.scalatra.ActionResult
|
||||||
|
|
||||||
trait ApiIssueCommentControllerBase extends ControllerBase {
|
trait ApiIssueCommentControllerBase extends ControllerBase {
|
||||||
self: AccountService
|
self: AccountService
|
||||||
@@ -14,34 +15,105 @@ trait ApiIssueCommentControllerBase extends ControllerBase {
|
|||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with ReferrerAuthenticator =>
|
with ReferrerAuthenticator =>
|
||||||
/*
|
/*
|
||||||
* i. List comments on an issue
|
* i. List issue comments for a repository
|
||||||
* https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
|
* https://docs.github.com/en/rest/reference/issues#list-issue-comments-for-a-repository
|
||||||
*/
|
*/
|
||||||
get("/api/v3/repos/:owner/:repository/issues/:id/comments")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/issues/:id/comments")(referrersOnly { repository =>
|
||||||
(for {
|
(for {
|
||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
comments = getCommentsForApi(repository.owner, repository.name, issueId)
|
comments = getCommentsForApi(repository.owner, repository.name, issueId)
|
||||||
} yield {
|
} yield {
|
||||||
JsonFormat(comments.map {
|
JsonFormat(comments.map { case (issueComment, user, issue) =>
|
||||||
case (issueComment, user, issue) =>
|
|
||||||
ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(user), issue.isPullRequest)
|
ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(user), issue.isPullRequest)
|
||||||
})
|
})
|
||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ii. List comments in a repository
|
* ii. Get an issue comment
|
||||||
* https://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
|
* https://docs.github.com/en/rest/reference/issues#get-an-issue-comment
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/issues/comments/:id")(referrersOnly { repository =>
|
||||||
|
val commentId = params("id").toInt
|
||||||
|
getCommentForApi(repository.owner, repository.name, commentId) match {
|
||||||
|
case Some((issueComment, user, issue)) =>
|
||||||
|
JsonFormat(
|
||||||
|
ApiComment(issueComment, RepositoryName(repository), issue.issueId, ApiUser(user), issue.isPullRequest)
|
||||||
|
)
|
||||||
|
case _ => NotFound()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* iii. Update an issue comment
|
||||||
|
* https://docs.github.com/en/rest/reference/issues#update-an-issue-comment
|
||||||
|
*/
|
||||||
|
patch("/api/v3/repos/:owner/:repository/issues/comments/:id")(readableUsersOnly { repository =>
|
||||||
|
val commentId = params("id")
|
||||||
|
val result = for {
|
||||||
|
issueComment <- getComment(repository.owner, repository.name, commentId)
|
||||||
|
issue <- getIssue(repository.owner, repository.name, issueComment.issueId.toString)
|
||||||
|
} yield {
|
||||||
|
if (isEditable(repository.owner, repository.name, issueComment.commentedUserName)) {
|
||||||
|
val body = extractFromJsonBody[CreateAComment].map(_.body)
|
||||||
|
updateCommentByApi(repository, issue, issueComment.commentId.toString, body)
|
||||||
|
getComment(repository.owner, repository.name, commentId) match {
|
||||||
|
case Some(issueComment) =>
|
||||||
|
JsonFormat(
|
||||||
|
ApiComment(
|
||||||
|
issueComment,
|
||||||
|
RepositoryName(repository),
|
||||||
|
issue.issueId,
|
||||||
|
ApiUser(context.loginAccount.get),
|
||||||
|
issue.isPullRequest
|
||||||
|
)
|
||||||
|
)
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Unauthorized()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result match {
|
||||||
|
case Some(response) => response
|
||||||
|
case None => NotFound()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* iv. Delete a comment
|
||||||
|
* https://docs.github.com/en/rest/reference/issues#delete-an-issue-comment
|
||||||
|
*/
|
||||||
|
delete("/api/v3/repos/:owner/:repository/issues/comments/:id")(readableUsersOnly { repository =>
|
||||||
|
val maybeDeleteResponse: Option[Either[ActionResult, Option[Int]]] =
|
||||||
|
for {
|
||||||
|
commentId <- params("id").toIntOpt
|
||||||
|
comment <- getComment(repository.owner, repository.name, commentId.toString)
|
||||||
|
issue <- getIssue(repository.owner, repository.name, comment.issueId.toString)
|
||||||
|
} yield {
|
||||||
|
if (isEditable(repository.owner, repository.name, comment.commentedUserName)) {
|
||||||
|
val maybeDeletedComment = deleteCommentByApi(repository, comment, issue)
|
||||||
|
Right(maybeDeletedComment.map(_.commentId))
|
||||||
|
} else {
|
||||||
|
Left(Unauthorized())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maybeDeleteResponse
|
||||||
|
.map {
|
||||||
|
case Right(maybeDeletedCommentId) => maybeDeletedCommentId.getOrElse(NotFound())
|
||||||
|
case Left(err) => err
|
||||||
|
}
|
||||||
|
.getOrElse(NotFound())
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* v. List issue comments
|
||||||
|
* https://docs.github.com/en/rest/reference/issues#list-issue-comments
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* iii. Get a single comment
|
* vi. Create an issue comment
|
||||||
* https://developer.github.com/v3/issues/comments/#get-a-single-comment
|
* https://docs.github.com/en/rest/reference/issues#create-an-issue-comment
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* iv. Create a comment
|
|
||||||
* https://developer.github.com/v3/issues/comments/#create-a-comment
|
|
||||||
*/
|
*/
|
||||||
post("/api/v3/repos/:owner/:repository/issues/:id/comments")(readableUsersOnly { repository =>
|
post("/api/v3/repos/:owner/:repository/issues/:id/comments")(readableUsersOnly { repository =>
|
||||||
(for {
|
(for {
|
||||||
@@ -64,16 +136,6 @@ trait ApiIssueCommentControllerBase extends ControllerBase {
|
|||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
|
||||||
* v. Edit a comment
|
|
||||||
* https://developer.github.com/v3/issues/comments/#edit-a-comment
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* vi. Delete a comment
|
|
||||||
* https://developer.github.com/v3/issues/comments/#delete-a-comment
|
|
||||||
*/
|
|
||||||
|
|
||||||
private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean =
|
private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean =
|
||||||
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import gitbucket.core.model.{Account, Issue}
|
|||||||
import gitbucket.core.service.{AccountService, IssueCreationService, IssuesService, MilestonesService}
|
import gitbucket.core.service.{AccountService, IssueCreationService, IssuesService, MilestonesService}
|
||||||
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
||||||
import gitbucket.core.service.PullRequestService.PullRequestLimit
|
import gitbucket.core.service.PullRequestService.PullRequestLimit
|
||||||
import gitbucket.core.util.{ReadableUsersAuthenticator, ReferrerAuthenticator, RepositoryName, UsersAuthenticator}
|
import gitbucket.core.util.{ReadableUsersAuthenticator, ReferrerAuthenticator, RepositoryName}
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
|
|
||||||
trait ApiIssueControllerBase extends ControllerBase {
|
trait ApiIssueControllerBase extends ControllerBase {
|
||||||
@@ -29,9 +29,9 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
val page = IssueSearchCondition.page(request)
|
val page = IssueSearchCondition.page(request)
|
||||||
// TODO: more api spec condition
|
// TODO: more api spec condition
|
||||||
val condition = IssueSearchCondition(request)
|
val condition = IssueSearchCondition(request)
|
||||||
val baseOwner = getAccountByUserName(repository.owner).get
|
// val baseOwner = getAccountByUserName(repository.owner).get
|
||||||
|
|
||||||
val issues: List[(Issue, Account)] =
|
val issues: List[(Issue, Account, List[Account])] =
|
||||||
searchIssueByApi(
|
searchIssueByApi(
|
||||||
condition = condition,
|
condition = condition,
|
||||||
offset = (page - 1) * PullRequestLimit,
|
offset = (page - 1) * PullRequestLimit,
|
||||||
@@ -39,14 +39,15 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
repos = repository.owner -> repository.name
|
repos = repository.owner -> repository.name
|
||||||
)
|
)
|
||||||
|
|
||||||
JsonFormat(issues.map {
|
JsonFormat(issues.map { case (issue, issueUser, assigneeUsers) =>
|
||||||
case (issue, issueUser) =>
|
|
||||||
ApiIssue(
|
ApiIssue(
|
||||||
issue = issue,
|
issue = issue,
|
||||||
repositoryName = RepositoryName(repository),
|
repositoryName = RepositoryName(repository),
|
||||||
user = ApiUser(issueUser),
|
user = ApiUser(issueUser),
|
||||||
|
assignees = assigneeUsers.map(ApiUser(_)),
|
||||||
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
||||||
.map(ApiLabel(_, RepositoryName(repository)))
|
.map(ApiLabel(_, RepositoryName(repository))),
|
||||||
|
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -59,14 +60,18 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
(for {
|
(for {
|
||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
issue <- getIssue(repository.owner, repository.name, issueId.toString)
|
issue <- getIssue(repository.owner, repository.name, issueId.toString)
|
||||||
openedUser <- getAccountByUserName(issue.openedUserName)
|
assigneeUsers = getIssueAssignees(repository.owner, repository.name, issueId)
|
||||||
|
users = getAccountsByUserNames(Set(issue.openedUserName) ++ assigneeUsers.map(_.assigneeUserName), Set())
|
||||||
|
openedUser <- users.get(issue.openedUserName)
|
||||||
} yield {
|
} yield {
|
||||||
JsonFormat(
|
JsonFormat(
|
||||||
ApiIssue(
|
ApiIssue(
|
||||||
issue,
|
issue,
|
||||||
RepositoryName(repository),
|
RepositoryName(repository),
|
||||||
ApiUser(openedUser),
|
ApiUser(openedUser),
|
||||||
getIssueLabels(repository.owner, repository.name, issue.issueId).map(ApiLabel(_, RepositoryName(repository)))
|
assigneeUsers.flatMap(x => users.get(x.assigneeUserName)).map(ApiUser(_)),
|
||||||
|
getIssueLabels(repository.owner, repository.name, issue.issueId).map(ApiLabel(_, RepositoryName(repository))),
|
||||||
|
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
@@ -87,7 +92,7 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
repository,
|
repository,
|
||||||
data.title,
|
data.title,
|
||||||
data.body,
|
data.body,
|
||||||
data.assignees.headOption,
|
data.assignees,
|
||||||
milestone.map(_.milestoneId),
|
milestone.map(_.milestoneId),
|
||||||
None,
|
None,
|
||||||
data.labels,
|
data.labels,
|
||||||
@@ -98,8 +103,12 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
issue,
|
issue,
|
||||||
RepositoryName(repository),
|
RepositoryName(repository),
|
||||||
ApiUser(loginAccount),
|
ApiUser(loginAccount),
|
||||||
|
getIssueAssignees(repository.owner, repository.name, issue.issueId)
|
||||||
|
.flatMap(x => getAccountByUserName(x.assigneeUserName, false))
|
||||||
|
.map(ApiUser.apply),
|
||||||
getIssueLabels(repository.owner, repository.name, issue.issueId)
|
getIssueLabels(repository.owner, repository.name, issue.issueId)
|
||||||
.map(ApiLabel(_, RepositoryName(repository)))
|
.map(ApiLabel(_, RepositoryName(repository))),
|
||||||
|
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package gitbucket.core.controller.api
|
package gitbucket.core.controller.api
|
||||||
import gitbucket.core.api.{ApiError, ApiLabel, CreateALabel, JsonFormat}
|
import gitbucket.core.api.{AddLabelsToAnIssue, ApiError, ApiLabel, CreateALabel, JsonFormat}
|
||||||
import gitbucket.core.controller.ControllerBase
|
import gitbucket.core.controller.ControllerBase
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
@@ -69,8 +69,7 @@ trait ApiIssueLabelControllerBase extends ControllerBase {
|
|||||||
data <- extractFromJsonBody[CreateALabel] if data.isValid
|
data <- extractFromJsonBody[CreateALabel] if data.isValid
|
||||||
} yield {
|
} yield {
|
||||||
LockUtil.lock(RepositoryName(repository).fullName) {
|
LockUtil.lock(RepositoryName(repository).fullName) {
|
||||||
getLabel(repository.owner, repository.name, params("labelName")).map {
|
getLabel(repository.owner, repository.name, params("labelName")).map { label =>
|
||||||
label =>
|
|
||||||
if (getLabel(repository.owner, repository.name, data.name).isEmpty) {
|
if (getLabel(repository.owner, repository.name, data.name).isEmpty) {
|
||||||
updateLabel(repository.owner, repository.name, label.labelId, data.name, data.color)
|
updateLabel(repository.owner, repository.name, label.labelId, data.name, data.color)
|
||||||
JsonFormat(
|
JsonFormat(
|
||||||
@@ -121,10 +120,10 @@ trait ApiIssueLabelControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
post("/api/v3/repos/:owner/:repository/issues/:id/labels")(writableUsersOnly { repository =>
|
post("/api/v3/repos/:owner/:repository/issues/:id/labels")(writableUsersOnly { repository =>
|
||||||
JsonFormat(for {
|
JsonFormat(for {
|
||||||
data <- extractFromJsonBody[Seq[String]];
|
data <- extractFromJsonBody[AddLabelsToAnIssue]
|
||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
} yield {
|
} yield {
|
||||||
data.map { labelName =>
|
data.labels.map { labelName =>
|
||||||
val label = getLabel(repository.owner, repository.name, labelName).getOrElse(
|
val label = getLabel(repository.owner, repository.name, labelName).getOrElse(
|
||||||
getLabel(
|
getLabel(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
@@ -160,11 +159,11 @@ trait ApiIssueLabelControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
put("/api/v3/repos/:owner/:repository/issues/:id/labels")(writableUsersOnly { repository =>
|
put("/api/v3/repos/:owner/:repository/issues/:id/labels")(writableUsersOnly { repository =>
|
||||||
JsonFormat(for {
|
JsonFormat(for {
|
||||||
data <- extractFromJsonBody[Seq[String]];
|
data <- extractFromJsonBody[AddLabelsToAnIssue]
|
||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
} yield {
|
} yield {
|
||||||
deleteAllIssueLabels(repository.owner, repository.name, issueId, true)
|
deleteAllIssueLabels(repository.owner, repository.name, issueId, true)
|
||||||
data.map { labelName =>
|
data.labels.map { labelName =>
|
||||||
val label = getLabel(repository.owner, repository.name, labelName).getOrElse(
|
val label = getLabel(repository.owner, repository.name, labelName).getOrElse(
|
||||||
getLabel(
|
getLabel(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package gitbucket.core.controller.api
|
||||||
|
import gitbucket.core.api._
|
||||||
|
import gitbucket.core.controller.ControllerBase
|
||||||
|
import gitbucket.core.service.MilestonesService
|
||||||
|
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
||||||
|
import gitbucket.core.util.Implicits._
|
||||||
|
import org.scalatra.NoContent
|
||||||
|
|
||||||
|
trait ApiIssueMilestoneControllerBase extends ControllerBase {
|
||||||
|
self: MilestonesService with WritableUsersAuthenticator with ReferrerAuthenticator =>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* i. List milestones
|
||||||
|
* https://docs.github.com/en/rest/reference/issues#list-milestones
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/milestones")(referrersOnly { repository =>
|
||||||
|
val state = params.getOrElse("state", "all")
|
||||||
|
// TODO "sort", "direction" params should be implemented.
|
||||||
|
val apiMilestones = (for (
|
||||||
|
milestoneWithIssue <- getMilestonesWithIssueCount(repository.owner, repository.name)
|
||||||
|
.sortBy(p => p._1.milestoneId)
|
||||||
|
)
|
||||||
|
yield {
|
||||||
|
ApiMilestone(
|
||||||
|
repository.repository,
|
||||||
|
milestoneWithIssue._1,
|
||||||
|
milestoneWithIssue._2,
|
||||||
|
milestoneWithIssue._3
|
||||||
|
)
|
||||||
|
}).reverse
|
||||||
|
state match {
|
||||||
|
case "all" => JsonFormat(apiMilestones)
|
||||||
|
case "open" | "closed" =>
|
||||||
|
JsonFormat(
|
||||||
|
apiMilestones.filter(p => p.state == state)
|
||||||
|
)
|
||||||
|
case _ => NotFound()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ii. Create a milestone
|
||||||
|
* https://docs.github.com/en/rest/reference/issues#create-a-milestone
|
||||||
|
*/
|
||||||
|
post("/api/v3/repos/:owner/:repository/milestones")(writableUsersOnly { repository =>
|
||||||
|
(for {
|
||||||
|
data <- extractFromJsonBody[CreateAMilestone] if data.isValid
|
||||||
|
milestoneId = createMilestone(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
data.title,
|
||||||
|
data.description,
|
||||||
|
data.due_on
|
||||||
|
)
|
||||||
|
apiMilestone <- getApiMilestone(repository, milestoneId)
|
||||||
|
} yield {
|
||||||
|
JsonFormat(apiMilestone)
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* iii. Get a milestone
|
||||||
|
* https://docs.github.com/en/rest/reference/issues#get-a-milestone
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/milestones/:number")(referrersOnly { repository =>
|
||||||
|
val milestoneId = params("number").toInt // use milestoneId as number
|
||||||
|
(for (apiMilestone <- getApiMilestone(repository, milestoneId)) yield {
|
||||||
|
JsonFormat(apiMilestone)
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* iv.Update a milestone
|
||||||
|
* https://docs.github.com/en/rest/reference/issues#update-a-milestone
|
||||||
|
*/
|
||||||
|
patch("/api/v3/repos/:owner/:repository/milestones/:number")(writableUsersOnly { repository =>
|
||||||
|
val milestoneId = params("number").toInt
|
||||||
|
(for {
|
||||||
|
data <- extractFromJsonBody[CreateAMilestone] if data.isValid
|
||||||
|
milestone <- getMilestone(repository.owner, repository.name, milestoneId)
|
||||||
|
_ = (data.state, milestone.closedDate) match {
|
||||||
|
case ("open", Some(_)) =>
|
||||||
|
openMilestone(milestone)
|
||||||
|
case ("closed", None) =>
|
||||||
|
closeMilestone(milestone)
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
|
milestone <- getMilestone(repository.owner, repository.name, milestoneId)
|
||||||
|
_ = updateMilestone(milestone.copy(title = data.title, description = data.description, dueDate = data.due_on))
|
||||||
|
apiMilestone <- getApiMilestone(repository, milestoneId)
|
||||||
|
} yield {
|
||||||
|
JsonFormat(apiMilestone)
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* v. Delete a milestone
|
||||||
|
* https://docs.github.com/en/rest/reference/issues#delete-a-milestone
|
||||||
|
*/
|
||||||
|
delete("/api/v3/repos/:owner/:repository/milestones/:number")(writableUsersOnly { repository =>
|
||||||
|
val milestoneId = params("number").toInt // use milestoneId as number
|
||||||
|
deleteMilestone(repository.owner, repository.name, milestoneId)
|
||||||
|
NoContent()
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user