mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 04:56:02 +01:00
Compare commits
933 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
161c5513df | ||
|
|
538c1d7a9a | ||
|
|
123c17d442 | ||
|
|
6b7fd7fb7b | ||
|
|
0c0fde3077 | ||
|
|
1cf6950e70 | ||
|
|
5eddeba3ef | ||
|
|
75f4903ffb | ||
|
|
9727259d0c | ||
|
|
6bb664e592 | ||
|
|
f106dea3d9 | ||
|
|
982cc15052 | ||
|
|
1ef3299574 | ||
|
|
49f0795b5f | ||
|
|
af697d8155 | ||
|
|
81a779d1d9 | ||
|
|
7c484297d7 | ||
|
|
a91e46f3e9 | ||
|
|
5f18de06f5 | ||
|
|
bef5b5f22e | ||
|
|
092e832d21 | ||
|
|
cd836f331e | ||
|
|
53537eaa09 | ||
|
|
8515ef5b26 | ||
|
|
a2524608c7 | ||
|
|
127ddcef6d | ||
|
|
076bc9e2d6 | ||
|
|
d19b2778fe | ||
|
|
4d947aef7b | ||
|
|
1f3fc62a0e | ||
|
|
8b089837f9 | ||
|
|
4c4327b569 | ||
|
|
d72e9b2692 | ||
|
|
e021868a96 | ||
|
|
0c3cf5b140 | ||
|
|
32bd52d74d | ||
|
|
55f52b7f78 | ||
|
|
4ef45d3987 | ||
|
|
ebc6121526 | ||
|
|
8a36acb673 | ||
|
|
9efe438697 | ||
|
|
4c7540451e | ||
|
|
cdeaede8bf | ||
|
|
ad73e1d529 | ||
|
|
68e858541d | ||
|
|
709e423a6d | ||
|
|
392139c061 | ||
|
|
64db3e7842 | ||
|
|
14e8071713 | ||
|
|
cea09fa766 | ||
|
|
019767e8c3 | ||
|
|
3c34689e7d | ||
|
|
d3cca0685a | ||
|
|
72049c5bdf | ||
|
|
d636413471 | ||
|
|
d1c6cbf55a | ||
|
|
e439a2f5f7 | ||
|
|
ecde6aefbf | ||
|
|
b95d912542 | ||
|
|
eb50b74b4a | ||
|
|
d460185317 | ||
|
|
2297ef0bec | ||
|
|
8d7ec16ed0 | ||
|
|
4dfc9fc456 | ||
|
|
3b99e619db | ||
|
|
9cded1b4de | ||
|
|
bfc88a489a | ||
|
|
f2a213f32a | ||
|
|
9663d21ce8 | ||
|
|
30c8d3c39c | ||
|
|
88e72bee2c | ||
|
|
c67441b6d4 | ||
|
|
e1802978d3 | ||
|
|
1ccdc79051 | ||
|
|
3ca0d35a1b | ||
|
|
7bbeceec97 | ||
|
|
1295e621ce | ||
|
|
5f4580399b | ||
|
|
8d735205aa | ||
|
|
64f15e015f | ||
|
|
a95abf7397 | ||
|
|
3054834b91 | ||
|
|
572ea5bf47 | ||
|
|
9c9876c918 | ||
|
|
8d30d68a4a | ||
|
|
88a8552d4d | ||
|
|
7608a41f9c | ||
|
|
7f7c55aeee | ||
|
|
2ebed8ef94 | ||
|
|
2904bcf4a7 | ||
|
|
6630fa2f37 | ||
|
|
351e63e7b6 | ||
|
|
ea0f35a0a1 | ||
|
|
623c53e169 | ||
|
|
3e6fd2caf8 | ||
|
|
39f1aa4487 | ||
|
|
8ffd905a9f | ||
|
|
668f9ef919 | ||
|
|
ffb9bb10f5 | ||
|
|
2618f54442 | ||
|
|
6b3218dd43 | ||
|
|
56a9b7b0f1 | ||
|
|
4f4afc5686 | ||
|
|
87fb136b85 | ||
|
|
7af271e14a | ||
|
|
f44d44cb4a | ||
|
|
e7fc5f1753 | ||
|
|
f0e2775861 | ||
|
|
2488ab9bd4 | ||
|
|
f0872d410c | ||
|
|
9d69cc9d45 | ||
|
|
1c66052372 | ||
|
|
158f799ca1 | ||
|
|
907532fd13 | ||
|
|
0f6a433623 | ||
|
|
00eab5d584 | ||
|
|
5d928b1a62 | ||
|
|
50d6f0c96f | ||
|
|
a60b43b862 | ||
|
|
4b1235b484 | ||
|
|
f354b9cfd7 | ||
|
|
0c2283ce28 | ||
|
|
840479a022 | ||
|
|
1bceaaab1d | ||
|
|
65ece3292a | ||
|
|
e410623cac | ||
|
|
09f7f036aa | ||
|
|
5249224dec | ||
|
|
00def3a46d | ||
|
|
134c0010b5 | ||
|
|
fe3b40557a | ||
|
|
d3cdc5d5fc | ||
|
|
7ebb28be74 | ||
|
|
707cd3c5c3 | ||
|
|
4c5017d108 | ||
|
|
fdd91b1e0e | ||
|
|
9124777ce7 | ||
|
|
7c575fdc52 | ||
|
|
f9d6f1334f | ||
|
|
65d4900325 | ||
|
|
64248d1fce | ||
|
|
bec75120bc | ||
|
|
3b0eed48d9 | ||
|
|
25c4b1e6a7 | ||
|
|
cccff46715 | ||
|
|
fc0ffd1b4f | ||
|
|
b70a2a2327 | ||
|
|
b5ca7ca0e1 | ||
|
|
7bb5379b45 | ||
|
|
5692a8c83e | ||
|
|
6c6126148e | ||
|
|
5b2e24daef | ||
|
|
29f390e48c | ||
|
|
c49eff6e54 | ||
|
|
27930a5849 | ||
|
|
6ffc139d2f | ||
|
|
59ed027b60 | ||
|
|
5dc55822d7 | ||
|
|
9bfe5115cc | ||
|
|
aaf9c65f30 | ||
|
|
d6197261fb | ||
|
|
8fd7df2a9d | ||
|
|
4eb148f4a6 | ||
|
|
8f1e460893 | ||
|
|
8c80f8a506 | ||
|
|
9eb9fc666c | ||
|
|
d70c6cece7 | ||
|
|
dbdee135a3 | ||
|
|
132bb6bee4 | ||
|
|
c64428e37f | ||
|
|
2dfa7a1190 | ||
|
|
06d559b47e | ||
|
|
83baaa6ed9 | ||
|
|
85d38a47f1 | ||
|
|
0c3c6ea15a | ||
|
|
2ce436bddc | ||
|
|
a60c607fcb | ||
|
|
0456739118 | ||
|
|
368052bd8f | ||
|
|
ce916a7d4b | ||
|
|
60ff046823 | ||
|
|
7d3bda42e2 | ||
|
|
83a39f1e39 | ||
|
|
de726d8d96 | ||
|
|
91bb241e8c | ||
|
|
8da55d8aa8 | ||
|
|
3355c46503 | ||
|
|
0a3d457218 | ||
|
|
7fa5fdfbd0 | ||
|
|
95f88891d0 | ||
|
|
550f8f415c | ||
|
|
5ab947d8ec | ||
|
|
ec793535e7 | ||
|
|
2f1d81cc4c | ||
|
|
0f189ca710 | ||
|
|
6afd51bb8d | ||
|
|
e415f9d24e | ||
|
|
ba5d587a1e | ||
|
|
92f778b6e9 | ||
|
|
b52981a845 | ||
|
|
9c5d3edc72 | ||
|
|
56d68c6145 | ||
|
|
4d13282915 | ||
|
|
872320ccab | ||
|
|
28ee80b727 | ||
|
|
2621de2cde | ||
|
|
82b102845f | ||
|
|
28c9f8b89a | ||
|
|
23fa937fd1 | ||
|
|
02330a2050 | ||
|
|
c65599d995 | ||
|
|
22ae1df4b1 | ||
|
|
6b22342166 | ||
|
|
53f6190267 | ||
|
|
f73daaef44 | ||
|
|
d99e382dfe | ||
|
|
aefbee2093 | ||
|
|
11fb0a7edf | ||
|
|
fe959aecff | ||
|
|
9b33655bd4 | ||
|
|
33acad85db | ||
|
|
6bfe3ea760 | ||
|
|
1532fd71d0 | ||
|
|
c14a732e2a | ||
|
|
a1372034ed | ||
|
|
98914269b7 | ||
|
|
d5e455336b | ||
|
|
7b84f25c56 | ||
|
|
2ca20af502 | ||
|
|
78df2accfc | ||
|
|
7a282fb67e | ||
|
|
db679967af | ||
|
|
9e98d30612 | ||
|
|
a47065e4a9 | ||
|
|
94d18c471c | ||
|
|
f8f3019228 | ||
|
|
c3d90b8593 | ||
|
|
62c1299f29 | ||
|
|
b75db98cad | ||
|
|
3592b3d13c | ||
|
|
ca814e2c08 | ||
|
|
48b6a590bf | ||
|
|
285ef02a17 | ||
|
|
18375c741e | ||
|
|
21030344cc | ||
|
|
a494027217 | ||
|
|
7bca01af59 | ||
|
|
acf3fa9980 | ||
|
|
c0ce0f8d19 | ||
|
|
56e7168461 | ||
|
|
c2d0d94f05 | ||
|
|
fc22cfbbdd | ||
|
|
d62adbf649 | ||
|
|
dba5539e3e | ||
|
|
f0a8b3bb17 | ||
|
|
f52e7e1bdd | ||
|
|
58ba26f21e | ||
|
|
bf7b30630c | ||
|
|
b5cac0308e | ||
|
|
373ea39048 | ||
|
|
427f5eec5f | ||
|
|
a4e9903e00 | ||
|
|
0d900a892c | ||
|
|
dc6fdaf482 | ||
|
|
b79498ed9f | ||
|
|
69e8f628df | ||
|
|
d3d8e3ce5f | ||
|
|
0499c47f4b | ||
|
|
7fd0cdd7d8 | ||
|
|
49eaf79e01 | ||
|
|
3a96c30aa8 | ||
|
|
6d550fa485 | ||
|
|
7f9d69bb51 | ||
|
|
709fab9ccc | ||
|
|
fd13a2db79 | ||
|
|
840d81f7bd | ||
|
|
5d08f4d339 | ||
|
|
ef48b2d5ef | ||
|
|
f54e4f337f | ||
|
|
743965d3b8 | ||
|
|
0e787eddfd | ||
|
|
442c0d575e | ||
|
|
485516be2e | ||
|
|
6b2fbb3bf0 | ||
|
|
e510b1c26b | ||
|
|
8d35494169 | ||
|
|
cf1504bae7 | ||
|
|
9bb4e473b9 | ||
|
|
d67afebadc | ||
|
|
417886161c | ||
|
|
1b85d511e9 | ||
|
|
45d84f63c1 | ||
|
|
fff60b2704 | ||
|
|
c9339aec9e | ||
|
|
7c98ae1341 | ||
|
|
01c2291715 | ||
|
|
2e03f081d9 | ||
|
|
0cbafdd884 | ||
|
|
d5a9c2c15d | ||
|
|
1496591244 | ||
|
|
f5acce3901 | ||
|
|
5568a0ad8e | ||
|
|
26a18287c7 | ||
|
|
b0f819b9bd | ||
|
|
ebff7baf07 | ||
|
|
cf9a55d896 | ||
|
|
72f7b659f4 | ||
|
|
87192d025b | ||
|
|
fd181b9a0c | ||
|
|
9c4cc12a02 | ||
|
|
44497b559e | ||
|
|
09c50a149b | ||
|
|
88beb68e01 | ||
|
|
0da358311b | ||
|
|
cf97b63dab | ||
|
|
4b5f22144e | ||
|
|
0d342a6863 | ||
|
|
458820a09d | ||
|
|
135c34ef0f | ||
|
|
8187c5a013 | ||
|
|
6ff48c8130 | ||
|
|
d37c70cd8d | ||
|
|
8abf357405 | ||
|
|
c93ac71634 | ||
|
|
408180f071 | ||
|
|
4e98abfe5c | ||
|
|
efbb404bd4 | ||
|
|
66f409bfad | ||
|
|
44ec64fb4b | ||
|
|
fb27bd29e8 | ||
|
|
c26ca9d463 | ||
|
|
8c36ba33f4 | ||
|
|
fe1e18b495 | ||
|
|
29e632af04 | ||
|
|
2b9daae62b | ||
|
|
8a11f85dd1 | ||
|
|
b09c72b106 | ||
|
|
43456e817a | ||
|
|
7876a60106 | ||
|
|
38e71001cb | ||
|
|
a1307b7464 | ||
|
|
fd413d36ad | ||
|
|
509dfc57ca | ||
|
|
95bdd6228e | ||
|
|
fd1430371a | ||
|
|
437f944c6e | ||
|
|
f64b6e10bb | ||
|
|
5925bd3772 | ||
|
|
fe8d4616db | ||
|
|
99b40974c3 | ||
|
|
c463590ede | ||
|
|
82163eebc2 | ||
|
|
f1e427f926 | ||
|
|
c21dcdca80 | ||
|
|
2ce51472c3 | ||
|
|
514b1aeec1 | ||
|
|
3f34622fe0 | ||
|
|
8c6d5b8178 | ||
|
|
1971c29fd0 | ||
|
|
40ca9b6682 | ||
|
|
81aeed6f6c | ||
|
|
bf50b1bf82 | ||
|
|
1094e8ca2d | ||
|
|
860ccce89b | ||
|
|
59e5993eba | ||
|
|
c08627e5d6 | ||
|
|
3e0bb46699 | ||
|
|
9a972e40ef | ||
|
|
99ad0db1f6 | ||
|
|
12d11bc80c | ||
|
|
dc98079b55 | ||
|
|
88f56126a6 | ||
|
|
313c9976c8 | ||
|
|
5b6a1d0adc | ||
|
|
6db43e6ca7 | ||
|
|
46177e814c | ||
|
|
2fe79baed8 | ||
|
|
02e17c76a7 | ||
|
|
4d8acfd286 | ||
|
|
4a5c287b8f | ||
|
|
0d4047b4ee | ||
|
|
2b730ef180 | ||
|
|
ecbe7228b9 | ||
|
|
e36d0f65d6 | ||
|
|
30818fb797 | ||
|
|
6d7685fcce | ||
|
|
2cec5be3d9 | ||
|
|
038b70ff0b | ||
|
|
23a5f7dcf9 | ||
|
|
baa27d6090 | ||
|
|
f71acfcbe8 | ||
|
|
c65e843491 | ||
|
|
9103c88f0e | ||
|
|
90170f0fcc | ||
|
|
2e3de336cb | ||
|
|
da50d317e7 | ||
|
|
7a91e14b03 | ||
|
|
58eff0a1a3 | ||
|
|
8559f3e354 | ||
|
|
7606097a4d | ||
|
|
dfbace3d26 | ||
|
|
d61ab632f1 | ||
|
|
c3b341d945 | ||
|
|
59f063627c | ||
|
|
b4aba76005 | ||
|
|
81afea350d | ||
|
|
5c5da60dd6 | ||
|
|
89c69cdfc2 | ||
|
|
0789010248 | ||
|
|
37c23f615f | ||
|
|
b4d3573a84 | ||
|
|
5161ece63b | ||
|
|
5b7955cee6 | ||
|
|
60099e2b0d | ||
|
|
f04c486251 | ||
|
|
7b23bbf9ba | ||
|
|
0a532d9774 | ||
|
|
208b98285c | ||
|
|
56c9aa32a4 | ||
|
|
35080a9f33 | ||
|
|
6c41505c91 | ||
|
|
05bfaafe32 | ||
|
|
7534a88607 | ||
|
|
d7817d3d88 | ||
|
|
37780d467d | ||
|
|
ad4af67b30 | ||
|
|
29b0c22b0e | ||
|
|
c400678550 | ||
|
|
3c40e93346 | ||
|
|
247b664654 | ||
|
|
b3db0a6a7b | ||
|
|
0a03e41f1c | ||
|
|
a79f105eea | ||
|
|
74f3f6bf2e | ||
|
|
a4bf73724d | ||
|
|
8d91253ede | ||
|
|
b7355af49a | ||
|
|
7ec85cbf99 | ||
|
|
a6790b049d | ||
|
|
dce747b1e8 | ||
|
|
c22ee8acfd | ||
|
|
30b8b738b6 | ||
|
|
b916595da3 | ||
|
|
1accafa8b1 | ||
|
|
11700f4cb4 | ||
|
|
c9de8dd323 | ||
|
|
fd694e38aa | ||
|
|
8822c36b5f | ||
|
|
e614e31162 | ||
|
|
ad47ad4269 | ||
|
|
90b63090cc | ||
|
|
345685ed7c | ||
|
|
1d9fe5770e | ||
|
|
0c50545cbd | ||
|
|
53cbc36a01 | ||
|
|
85b2053004 | ||
|
|
eba240de65 | ||
|
|
1e5114cd54 | ||
|
|
90cb5de5f0 | ||
|
|
11d33e9389 | ||
|
|
c71e9331ae | ||
|
|
ec307b84d3 | ||
|
|
f37b5fa682 | ||
|
|
8cb1ac734d | ||
|
|
05ff2a854c | ||
|
|
d956ade5e3 | ||
|
|
73228506a5 | ||
|
|
2525bbafa8 | ||
|
|
338946dd3a | ||
|
|
2d225641ee | ||
|
|
3c727fe678 | ||
|
|
523ea0d437 | ||
|
|
9eff8f248b | ||
|
|
d50c858a26 | ||
|
|
6f4e94ba9a | ||
|
|
f2750c20a2 | ||
|
|
2da2b426a1 | ||
|
|
5a0bc127b7 | ||
|
|
23a482bbba | ||
|
|
6c2fce1b16 | ||
|
|
5d7346db91 | ||
|
|
443498433d | ||
|
|
a58ce07736 | ||
|
|
1903c3990c | ||
|
|
90441c8eec | ||
|
|
601919bcc6 | ||
|
|
6903b096f5 | ||
|
|
e44fed09fa | ||
|
|
8ed0c8a170 | ||
|
|
31118ac285 | ||
|
|
c851b7582f | ||
|
|
102a02d527 | ||
|
|
1968bf871a | ||
|
|
5cd4e48173 | ||
|
|
111d212cb5 | ||
|
|
d648d34393 | ||
|
|
bbaa5b38e7 | ||
|
|
3c50a78be2 | ||
|
|
82cc1fa530 | ||
|
|
8c0581973e | ||
|
|
bfa15f5d75 | ||
|
|
57e87b581d | ||
|
|
5aa6f5bce3 | ||
|
|
9ba098a805 | ||
|
|
b2d8567c26 | ||
|
|
19d97c93ce | ||
|
|
cad2daa2f9 | ||
|
|
585f0b5769 | ||
|
|
dd23d1109b | ||
|
|
5e84221d39 | ||
|
|
faf3e6c26b | ||
|
|
969da2c63b | ||
|
|
ba61891510 | ||
|
|
a581871a89 | ||
|
|
d96e1fa503 | ||
|
|
b66812d76c | ||
|
|
ae32016856 | ||
|
|
56aec15e68 | ||
|
|
d0c8e33ec5 | ||
|
|
7ab260e688 | ||
|
|
0d2c923664 | ||
|
|
e7a47fe3a4 | ||
|
|
e454f78c5a | ||
|
|
192e4ade3e | ||
|
|
733797cb6f | ||
|
|
f0e4157a46 | ||
|
|
2ad6948bb4 | ||
|
|
dd46d649a6 | ||
|
|
bbe8a9b9e4 | ||
|
|
376b109602 | ||
|
|
1d085d52bb | ||
|
|
d1f42e0ed7 | ||
|
|
101f8598ed | ||
|
|
da62f6f8fb | ||
|
|
5750286b5d | ||
|
|
f2ca4fb64b | ||
|
|
5f6b577cbf | ||
|
|
62004c279c | ||
|
|
838c7fb991 | ||
|
|
93786f0fd6 | ||
|
|
f3514e5625 | ||
|
|
a2b0ee0c24 | ||
|
|
2bcab30529 | ||
|
|
91cda6d245 | ||
|
|
a82e579d57 | ||
|
|
94421c7a63 | ||
|
|
ea7c8e62de | ||
|
|
b84421723b | ||
|
|
9a42b93d1f | ||
|
|
e162cd956a | ||
|
|
6431d25409 | ||
|
|
c8686f4b34 | ||
|
|
43097b4c1c | ||
|
|
539751a1d9 | ||
|
|
70e2079c7f | ||
|
|
e8737d263a | ||
|
|
4c4b08f1b8 | ||
|
|
c7e1edf262 | ||
|
|
876bb396fd | ||
|
|
a6788f858f | ||
|
|
b263764730 | ||
|
|
1b1bd371a4 | ||
|
|
f194a08cfe | ||
|
|
1211bfc7be | ||
|
|
eab7011e0f | ||
|
|
6f30ffa865 | ||
|
|
de3026248c | ||
|
|
413e75be5a | ||
|
|
6a8ec18f9a | ||
|
|
5b1b2ef3d7 | ||
|
|
9a705c62bf | ||
|
|
b103180bf6 | ||
|
|
536a0d3fe2 | ||
|
|
356202e28a | ||
|
|
6db36e12b5 | ||
|
|
bfcd5a2855 | ||
|
|
e218b52b78 | ||
|
|
46998dc1fa | ||
|
|
977f856854 | ||
|
|
da2a7bf77d | ||
|
|
3da3a048f0 | ||
|
|
7b5b453e56 | ||
|
|
c18f95edf8 | ||
|
|
71cf043f56 | ||
|
|
a31e4b5897 | ||
|
|
1679da4abe | ||
|
|
505bc71f9a | ||
|
|
4bc057c653 | ||
|
|
8eee13d7aa | ||
|
|
8981e339b4 | ||
|
|
e1dd5dd057 | ||
|
|
cb64f8eab8 | ||
|
|
c47d50d0df | ||
|
|
1f46da2273 | ||
|
|
06fc26cd06 | ||
|
|
3a4f9b9027 | ||
|
|
f98c849c7c | ||
|
|
aa0bd5b34a | ||
|
|
b52e904ed1 | ||
|
|
70e0dcf99d | ||
|
|
56bb20dfd2 | ||
|
|
7d7d2f488d | ||
|
|
72affd67b9 | ||
|
|
0cf1f43deb | ||
|
|
8494c682a7 | ||
|
|
1af5611159 | ||
|
|
4d39f63ef7 | ||
|
|
120d1c2fff | ||
|
|
62e9c0358a | ||
|
|
5a90848c75 | ||
|
|
760d443f74 | ||
|
|
5ee0e75dfe | ||
|
|
3b4d2d6f91 | ||
|
|
dfaabeb41d | ||
|
|
ff3205b6c7 | ||
|
|
0fae2dac35 | ||
|
|
4db4fe28b4 | ||
|
|
5b87efa032 | ||
|
|
3ad609bad7 | ||
|
|
8145cba111 | ||
|
|
24b9a9a12c | ||
|
|
ee7220ebd2 | ||
|
|
8fb72fd55e | ||
|
|
a1eded2d9a | ||
|
|
7f184e1126 | ||
|
|
09aafbcce1 | ||
|
|
7f5024a746 | ||
|
|
8fec0870a8 | ||
|
|
a8d2afaff7 | ||
|
|
8fd92f1c2f | ||
|
|
419ea16ead | ||
|
|
e72d808a3c | ||
|
|
44e8c0a9be | ||
|
|
e2c39d7815 | ||
|
|
687cd54f9a | ||
|
|
911754e1dc | ||
|
|
0067cbce6f | ||
|
|
f40f8427aa | ||
|
|
98ceff2391 | ||
|
|
642a51a208 | ||
|
|
9ec7c321d8 | ||
|
|
a3c419b6f5 | ||
|
|
15c28cffa4 | ||
|
|
f4d0f16481 | ||
|
|
45535e4fdf | ||
|
|
64635c5dc6 | ||
|
|
2fd95c7f1a | ||
|
|
eb6da85183 | ||
|
|
bcc05f021c | ||
|
|
d58ed55c3a | ||
|
|
057f029c80 | ||
|
|
c9a12ff913 | ||
|
|
66bf00b5d3 | ||
|
|
7ba3ca6f15 | ||
|
|
a1bacccc09 | ||
|
|
333eeb4bad | ||
|
|
3f2935612d | ||
|
|
4c87bdd959 | ||
|
|
3543073150 | ||
|
|
e50fe604c2 | ||
|
|
63369258bd | ||
|
|
e7c3376303 | ||
|
|
86163f66ce | ||
|
|
518f0bfc28 | ||
|
|
0a759f6127 | ||
|
|
afa79d01b1 | ||
|
|
860fc8ef4c | ||
|
|
5a2224623b | ||
|
|
dda3458e80 | ||
|
|
40e36e3f8b | ||
|
|
df06f509f5 | ||
|
|
0b4d0be1b4 | ||
|
|
0bef8d29d5 | ||
|
|
6265faa14f | ||
|
|
7593c97ad3 | ||
|
|
7c8de834bc | ||
|
|
637e9f906b | ||
|
|
97035be2e5 | ||
|
|
80fedbd335 | ||
|
|
3f6ebc1164 | ||
|
|
27b99319d3 | ||
|
|
a46d1ecf69 | ||
|
|
fb531526bd | ||
|
|
21d6143e40 | ||
|
|
129b424a3a | ||
|
|
689334a599 | ||
|
|
b3ee2222f3 | ||
|
|
da5e4fe5b1 | ||
|
|
f3b7318453 | ||
|
|
3d1c9bc9de | ||
|
|
9874eb7243 | ||
|
|
cc6f4d70da | ||
|
|
9b06bfaaf5 | ||
|
|
cdf0d06bcc | ||
|
|
501f542982 | ||
|
|
1a3504e885 | ||
|
|
fa617badc1 | ||
|
|
1a1267dc60 | ||
|
|
361babd327 | ||
|
|
64cacb18a4 | ||
|
|
833cfc3465 | ||
|
|
5a5bf34fe0 | ||
|
|
95746de5aa | ||
|
|
af7043f4bf | ||
|
|
4f3c780d05 | ||
|
|
249b27593e | ||
|
|
33a079e55f | ||
|
|
27eb1c36bd | ||
|
|
1201271949 | ||
|
|
5c12cca7f5 | ||
|
|
206d597d9b | ||
|
|
1b4c621fef | ||
|
|
03d4b9e9c6 | ||
|
|
82a9d9f7cf | ||
|
|
3e79dcf7a4 | ||
|
|
c9f3ec12a7 | ||
|
|
b781696803 | ||
|
|
19e74a4fe1 | ||
|
|
130aa1e515 | ||
|
|
8dcb8c2ecb | ||
|
|
b599219852 | ||
|
|
58078989f8 | ||
|
|
4276c0970b | ||
|
|
4abd4a4bac | ||
|
|
2b2ae718f7 | ||
|
|
ef201e3319 | ||
|
|
0ab28e6daa | ||
|
|
9b3e8bd22b | ||
|
|
15e8527e01 | ||
|
|
f991f3b454 | ||
|
|
d6a39403e2 | ||
|
|
aa065fd030 | ||
|
|
e92d1eae5a | ||
|
|
b1b132dfc3 | ||
|
|
90c379b3b9 | ||
|
|
b71ff6f179 | ||
|
|
8b44a00299 | ||
|
|
f5c1c0703d | ||
|
|
5036b1a1aa | ||
|
|
f63542dbd0 | ||
|
|
63e605d99c | ||
|
|
9e313bb2b3 | ||
|
|
a03fc4cf4a | ||
|
|
d18f92cfbf | ||
|
|
b96821ca44 | ||
|
|
c61ecdef7a | ||
|
|
b50ca63c2b | ||
|
|
f6624c0002 | ||
|
|
d62fc6e135 | ||
|
|
926c4d948f | ||
|
|
5fd87ca764 | ||
|
|
1042c50cc3 | ||
|
|
adff36c44b | ||
|
|
e8f6d2b990 | ||
|
|
a3b3262ad5 | ||
|
|
9efba82e94 | ||
|
|
781d465f8d | ||
|
|
766867f341 | ||
|
|
e237a44f56 | ||
|
|
249430449b | ||
|
|
73d935efe3 | ||
|
|
79251ef1d1 | ||
|
|
1081c0f16c | ||
|
|
3302b607f1 | ||
|
|
f13a3ee580 | ||
|
|
927969ac17 | ||
|
|
2d8aa4f8b5 | ||
|
|
645af4d2c0 | ||
|
|
34240d16b5 | ||
|
|
89210985d4 | ||
|
|
9d6258861a | ||
|
|
6661314be5 | ||
|
|
e187d026cc | ||
|
|
100b34085c | ||
|
|
ba75079409 | ||
|
|
cbb847704b | ||
|
|
739c99edce | ||
|
|
af2e2f5fd1 | ||
|
|
09fcf9c003 | ||
|
|
5dad0777d7 | ||
|
|
be3aa21651 | ||
|
|
abd729e45f | ||
|
|
162e9a9feb | ||
|
|
7500d017d5 | ||
|
|
e8c4004d5a | ||
|
|
a6f4d9d7cf | ||
|
|
3399278925 | ||
|
|
4457a317e6 | ||
|
|
990d082422 | ||
|
|
dfe3fbc02f | ||
|
|
c077dd0046 | ||
|
|
9cc6beead7 | ||
|
|
92f6792ad9 | ||
|
|
25031eadfb | ||
|
|
a7024615e1 | ||
|
|
8191a4bedb | ||
|
|
7e1f5aa353 | ||
|
|
44e161f6ec | ||
|
|
7bd17ed038 | ||
|
|
a47404130b | ||
|
|
669949aa8c | ||
|
|
c773bb90f6 | ||
|
|
18f525523b | ||
|
|
3bfd228df1 | ||
|
|
c072ab2dc5 | ||
|
|
53e06c5e86 | ||
|
|
b0a749bdc1 | ||
|
|
809443a46f | ||
|
|
59ef44dd71 | ||
|
|
d77973a29e | ||
|
|
be6bc16d3d | ||
|
|
407e926abe | ||
|
|
117655b011 | ||
|
|
2ea4a5a7ef | ||
|
|
30b0279efe | ||
|
|
7511701bb2 | ||
|
|
a919ae3430 | ||
|
|
c30ee24f8d | ||
|
|
10b5de571e | ||
|
|
c6f4ec7250 | ||
|
|
b229058726 | ||
|
|
21363794b6 | ||
|
|
1754d37ac0 | ||
|
|
1c36b185ec | ||
|
|
1a4b94e5df | ||
|
|
31bd8e1741 | ||
|
|
e8824ad1ac | ||
|
|
17636a5ecf | ||
|
|
8f36ff60de | ||
|
|
7ad605afba | ||
|
|
f080e8693e | ||
|
|
e27bf7868f | ||
|
|
db55fe9ff3 | ||
|
|
de4db0764c | ||
|
|
9d644b4625 | ||
|
|
354dc27e84 | ||
|
|
1c639474d3 | ||
|
|
4d8b47732e | ||
|
|
8650abf679 | ||
|
|
27dcc2ef48 | ||
|
|
94a12cd28c | ||
|
|
a982b64fd4 | ||
|
|
ee5b4bbf2e | ||
|
|
d09ddd8d07 | ||
|
|
c7bf47820c | ||
|
|
4dfb01d59e | ||
|
|
54bef6505f | ||
|
|
2aa71ed217 | ||
|
|
ef3b02b718 | ||
|
|
d90938421f | ||
|
|
e4992bbd17 | ||
|
|
7853b22522 | ||
|
|
9475215fa6 | ||
|
|
8622bbd2ac | ||
|
|
0cdcc252e0 | ||
|
|
9477cca8e8 | ||
|
|
176e427058 | ||
|
|
1bf26cacb9 | ||
|
|
38e8247483 | ||
|
|
44aa12108c | ||
|
|
dd73405aa9 | ||
|
|
6710393a53 | ||
|
|
711aee1c8b | ||
|
|
51be1048d5 | ||
|
|
50166f04d8 | ||
|
|
7eb6fea08b | ||
|
|
8e3c054da4 | ||
|
|
5249b67df1 | ||
|
|
583830c1c2 | ||
|
|
bb75f1c034 | ||
|
|
b7a9236283 | ||
|
|
7e0e172d37 | ||
|
|
ea37a34476 | ||
|
|
fb5564de07 | ||
|
|
cead7e9e4e | ||
|
|
7cf23b6c56 | ||
|
|
1080821862 | ||
|
|
0bf843ce2a | ||
|
|
b8bd8f5512 | ||
|
|
12fba30ef8 | ||
|
|
dc5cb74f4d | ||
|
|
446a524b5a | ||
|
|
121110aede | ||
|
|
c76a8562ea | ||
|
|
495d8069f5 | ||
|
|
70af6d0c35 | ||
|
|
9777d543b1 | ||
|
|
abfc6eea1e | ||
|
|
fd2f3e252c | ||
|
|
3b6d0065a2 | ||
|
|
51acf72e0d | ||
|
|
6ad724d80c | ||
|
|
7ffe2ab864 | ||
|
|
2f6febb748 | ||
|
|
092c897150 | ||
|
|
30f072f925 | ||
|
|
72d0282613 | ||
|
|
a56f766497 | ||
|
|
31b5583896 | ||
|
|
7c95bfc77e | ||
|
|
c6804fe589 | ||
|
|
fc41e282ce | ||
|
|
d3b21a4e39 | ||
|
|
7b6d9850a2 | ||
|
|
84d97817e3 | ||
|
|
2c6d2176bb | ||
|
|
7840d28ed2 | ||
|
|
d4fd2e6cd6 | ||
|
|
70e8385246 | ||
|
|
3fd23f1749 | ||
|
|
a3e3aea4e0 | ||
|
|
dcfb8ad8eb | ||
|
|
35f82e91bc | ||
|
|
f1533cb168 | ||
|
|
763fbec0ca | ||
|
|
111c893d94 | ||
|
|
80c38a45c5 | ||
|
|
548860607b | ||
|
|
66b5fe7337 | ||
|
|
2b2a117912 | ||
|
|
39a10fd167 | ||
|
|
93f8dbd42a | ||
|
|
4f280d0df8 | ||
|
|
5e9ff3278a | ||
|
|
b4b68f0e17 | ||
|
|
a08a212fdc | ||
|
|
82b056bd43 | ||
|
|
4c417daee5 | ||
|
|
28c47dd9c7 | ||
|
|
cd62220ba0 | ||
|
|
96e6aa89e3 | ||
|
|
41e49423b2 | ||
|
|
3cc7bd3cdb |
6
.github/CONTRIBUTING.md
vendored
Normal file
6
.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Guideline for Issues
|
||||||
|
|
||||||
|
- At first, See [FAQ](https://github.com/gitbucket/gitbucket/wiki/FAQ) 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.
|
||||||
|
- We can also support in Japaneses other than English at [gitter room for Japanese](https://gitter.im/gitbucket/gitbucket_ja).
|
||||||
|
- Write an issue in English. At least, write subject in English.
|
||||||
19
.github/ISSUE_TEMPLATE.md
vendored
Normal file
19
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
### Before submitting an issue to Gitbucket I have first:
|
||||||
|
|
||||||
|
- [] read the [contribution guidelines](https://github.com/gitbucket/gitbucket/blob/master/.github/CONTRIBUTING.md)
|
||||||
|
- [] searched for similar already existing issue
|
||||||
|
- [] 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)*
|
||||||
|
|
||||||
|
## Issue
|
||||||
|
**Impacted version**: xxxx
|
||||||
|
|
||||||
|
**Deployment mode**: *explain here how you use gitbucket : standalone app, under webcontainer (which one), with an http frontend (nginx, httpd, ...)*
|
||||||
|
|
||||||
|
**Problem description**:
|
||||||
|
- *be as explicit has you can*
|
||||||
|
- *describe the problem and its symptoms*
|
||||||
|
- *explain how to reproduce*
|
||||||
|
- *attach whatever information that can help understanding the context (screen capture, log files)*
|
||||||
|
- *do your best to use a correct english (re-read yourself)*
|
||||||
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
### Before submitting a pull-request to Gitbucket I have first:
|
||||||
|
|
||||||
|
- [] read the [contribution guidelines](https://github.com/gitbucket/gitbucket/blob/master/.github/CONTRIBUTING.md)
|
||||||
|
- [] rebased my branch over master
|
||||||
|
- [] verified that project is compiling
|
||||||
|
- [] verified that tests are passing
|
||||||
|
- [] 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
|
||||||
14
.travis.yml
14
.travis.yml
@@ -1,6 +1,18 @@
|
|||||||
language: scala
|
language: scala
|
||||||
sudo: false
|
sudo: true
|
||||||
script:
|
script:
|
||||||
- sbt test
|
- sbt test
|
||||||
jdk:
|
jdk:
|
||||||
- oraclejdk8
|
- oraclejdk8
|
||||||
|
before_script:
|
||||||
|
- sudo apt-get install libaio1
|
||||||
|
- sudo /etc/init.d/mysql stop
|
||||||
|
- sudo /etc/init.d/postgresql stop
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.ivy2/cache
|
||||||
|
- $HOME/.sbt/boot
|
||||||
|
- $HOME/.sbt/launchers
|
||||||
|
- $HOME/.coursier
|
||||||
|
- $HOME/.embedmysql
|
||||||
|
- $HOME/.embedpostgresql
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
# Guideline for Issues
|
|
||||||
|
|
||||||
- If you have any question about GitBucket, send it to [gitter room](https://gitter.im/gitbucket/gitbucket) before raise an issue.
|
|
||||||
- Make sure check whether there is a same question or request in the past.
|
|
||||||
- When raise a new issue, write subject in **English** at least.
|
|
||||||
- We can also support in Japaneses other than English at [gitter room for Japanese](https://gitter.im/gitbucket/gitbucket_ja).
|
|
||||||
- First priority of GitBucket is easy installation and reproduce GitHub behavior, so we might reject if your request is against it.
|
|
||||||
2
LICENSE
2
LICENSE
@@ -187,7 +187,7 @@
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
Copyright 2013-2016 GitBucket Team
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
234
README.md
234
README.md
@@ -1,102 +1,202 @@
|
|||||||
GitBucket [](https://gitter.im/gitbucket/gitbucket) [](https://travis-ci.org/gitbucket/gitbucket)
|
GitBucket [](https://gitter.im/gitbucket/gitbucket) [](https://travis-ci.org/gitbucket/gitbucket)
|
||||||
=========
|
=========
|
||||||
|
|
||||||
GitBucket is the easily installable GitHub clone powered by Scala.
|
GitBucket is a Git platform powered by Scala offering:
|
||||||
|
- Easy installation
|
||||||
|
- High extensibility by plugins
|
||||||
|
- API compatibility with GitHub
|
||||||
|
|
||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
The current version of GitBucket provides a basic features below:
|
The current version of GitBucket provides a basic features below:
|
||||||
|
|
||||||
- Public / Private Git repository (http and ssh access)
|
- Public / Private Git repository (http and ssh access)
|
||||||
- Repository viewer and online file editing
|
- Repository viewer and online file editor
|
||||||
- Repository search (Code and Issues)
|
- Issues, Pull request and Wiki for repositories
|
||||||
- Wiki
|
|
||||||
- Issues
|
|
||||||
- Fork / Pull request
|
|
||||||
- Email notification
|
- Email notification
|
||||||
- Activity timeline
|
- Account and group management with LDAP integration
|
||||||
- Simple user and group management with LDAP integration
|
|
||||||
- Gravatar support
|
|
||||||
- Plug-in system
|
- Plug-in system
|
||||||
|
|
||||||
If you want to try the development version of GitBucket, see the documentation for developers at [Wiki](https://github.com/gitbucket/gitbucket/wiki).
|
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.
|
||||||
|
|
||||||
1. Download latest **gitbucket.war** from [the release page](https://github.com/gitbucket/gitbucket/releases).
|
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. Deploy it to the Servlet 3.0 container such as Tomcat 7.x, Jetty 8.x, GlassFish 3.x or higher.
|
2. Go to `http://[hostname]:8080/` and log in with **root** / **root**.
|
||||||
3. Access **http://[hostname]:[port]/gitbucket/** using your web browser.
|
|
||||||
|
|
||||||
If you are using Gitbucket behind a webserver please make sure you have increased the **client_max_body_size** (on nginx)
|
You can specify following options:
|
||||||
|
|
||||||
The default administrator account is **root** and password is **root**.
|
- `--port=[NUMBER]`
|
||||||
|
- `--prefix=[CONTEXTPATH]`
|
||||||
|
- `--host=[HOSTNAME]`
|
||||||
|
- `--gitbucket.home=[DATA_DIR]`
|
||||||
|
- `--temp_dir=[TEMP_DIR]`
|
||||||
|
|
||||||
or you can start GitBucket by `java -jar gitbucket.war` without servlet container. In this case, GitBucket URL is **http://[hostname]:8080/**. You can specify following options.
|
`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.
|
||||||
|
|
||||||
- --port=[NUMBER]
|
You can also deploy gitbucket.war to a servlet container which supports Servlet 3.0 (like Jetty, Tomcat, JBoss, etc)
|
||||||
- --prefix=[CONTEXTPATH]
|
|
||||||
- --host=[HOSTNAME]
|
|
||||||
- --gitbucket.home=[DATA_DIR]
|
|
||||||
|
|
||||||
To upgrade GitBucket, only replace gitbucket.war. All GitBucket data is stored in HOME/.gitbucket. So if you want to back up GitBucket data, copy this directory to the other disk.
|
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 Installation on Windows Server with IIS see [this wiki page](https://github.com/gitbucket/gitbucket/wiki/Installation-on-IIS-and-Helicontech-Zoo)
|
To upgrade GitBucket, replace `gitbucket.war` with the new version, after stopping GitBucket. All GitBucket data is stored in `HOME/.gitbucket` by default. So if you want to back up GitBucket's data, copy this directory to the backup location.
|
||||||
|
|
||||||
### Mac OS X
|
Plugins
|
||||||
#### Installing Via Homebrew
|
|
||||||
|
|
||||||
```
|
|
||||||
$ brew install gitbucket
|
|
||||||
==> Downloading https://github.com/takezoe/gitbucket/releases/download/1.10/gitbucket.war
|
|
||||||
######################################################################## 100.0%
|
|
||||||
==> Caveats
|
|
||||||
Note: When using launchctl the port will be 8080.
|
|
||||||
|
|
||||||
To have launchd start gitbucket at login:
|
|
||||||
ln -sfv /usr/local/opt/gitbucket/*.plist ~/Library/LaunchAgents
|
|
||||||
Then to load gitbucket now:
|
|
||||||
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.gitbucket.plist
|
|
||||||
Or, if you don't want/need launchctl, you can just run:
|
|
||||||
java -jar /usr/local/opt/gitbucket/libexec/gitbucket.war
|
|
||||||
==> Summary
|
|
||||||
/usr/local/Cellar/gitbucket/1.10: 3 files, 42M, built in 11 seconds
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Manual Installation
|
|
||||||
On OS X, generate `gitbucket.plist` by [this script](https://raw.githubusercontent.com/gitbucket/gitbucket/master/contrib/macosx/makePlist) and copy it to `~/Library/LaunchAgents/`
|
|
||||||
|
|
||||||
Run the following commands in `Terminal` to
|
|
||||||
|
|
||||||
- start gitbucket: `launchctl load ~/Library/LaunchAgents/gitbucket.plist`
|
|
||||||
- stop gitbucket: `launchctl unload ~/Library/LaunchAgents/gitbucket.plist`
|
|
||||||
|
|
||||||
Plug-ins
|
|
||||||
--------
|
--------
|
||||||
GitBucket has the plug-in system to extend GitBucket from outside of GitBucket. Some plug-ins are available now:
|
GitBucket has a plug-in system to allow extensions to GitBucket. We provide some official plug-ins:
|
||||||
|
|
||||||
- [gitbucket-gist-plugin](https://github.com/gitbucket/gitbucket-gist-plugin)
|
- [gitbucket-gist-plugin](https://github.com/gitbucket/gitbucket-gist-plugin)
|
||||||
- [gitbucket-announce-plugin](https://github.com/gitbucket-plugins/gitbucket-announce-plugin)
|
- [gitbucket-emoji-plugin](https://github.com/gitbucket/gitbucket-emoji-plugin)
|
||||||
- [gitbucket-h2-backup-plugin](https://github.com/gitbucket-plugins/gitbucket-h2-backup-plugin)
|
|
||||||
- [gitbucket-desktopnotify-plugin](https://github.com/yoshiyoshifujii/gitbucket-desktopnotify-plugin)
|
|
||||||
- [gitbucket-commitgraphs-plugin](https://github.com/yoshiyoshifujii/gitbucket-commitgraphs-plugin)
|
|
||||||
|
|
||||||
You can find community plugins other than them at [gitbucket community plugins](http://gitbucket-plugins.github.io/).
|
You can find more plugins made by the community at [GitBucket community plugins](http://gitbucket-plugins.github.io/).
|
||||||
|
|
||||||
Support
|
Support
|
||||||
--------
|
--------
|
||||||
|
|
||||||
- If you have any question about GitBucket, send it to [gitter room](https://gitter.im/gitbucket/gitbucket) before raise an issue.
|
- If you have any questions about GitBucket, send it to the [gitter room](https://gitter.im/gitbucket/gitbucket) before opening an issue.
|
||||||
- Make sure check whether there is a same question or request in the past.
|
- Make sure check whether there is the same question or request in the past.
|
||||||
- When raise a new issue, write subject in **English** at least.
|
- When raise a new issue, write at least the subject in **English**.
|
||||||
- We can also support in Japaneses other than English at [gitter room for Japanese](https://gitter.im/gitbucket/gitbucket_ja).
|
- We can also provide support in Japanese at [gitter room for Japanese](https://gitter.im/gitbucket/gitbucket_ja).
|
||||||
- First priority of GitBucket is easy installation and reproduce GitHub behavior, so we might reject if your request is against it.
|
- The first priority of GitBucket is easy installation and API compatibility with GitHub, so we might reject if your request is against it.
|
||||||
|
|
||||||
Release Notes
|
Release Notes
|
||||||
--------
|
-------------
|
||||||
|
## 4.9 - 29 Jan 2017
|
||||||
|
- GitLFS support
|
||||||
|
- Template for issues and pull requests
|
||||||
|
- Manual label color editing
|
||||||
|
- Account description
|
||||||
|
- `--tmp-dir` option for standalone mode
|
||||||
|
- More APIs for issues
|
||||||
|
- [List issues for a repository](https://developer.github.com/v3/issues/#list-issues-for-a-repository)
|
||||||
|
- [Create an issue](https://developer.github.com/v3/issues/#create-an-issue)
|
||||||
|
|
||||||
|
## 4.8 - 23 Dec 2016
|
||||||
|
- Search for repository names from the global header
|
||||||
|
- Filter repositories on the sidebar of the dashboard
|
||||||
|
- Search issues and wiki
|
||||||
|
- Keep pull request comments after new commits are pushed
|
||||||
|
- New web API to get a single issue
|
||||||
|
- Performance improvement for the repository viewer
|
||||||
|
|
||||||
|
### 4.7.1 - 28 Nov 2016
|
||||||
|
- Bug fix: group repositories are not shown in the your repositories list on the sidebar
|
||||||
|
- Small performance improvement of the dashboard
|
||||||
|
|
||||||
|
### 4.7 - 26 Nov 2016
|
||||||
|
- New permission system
|
||||||
|
- Dropdown filter for issue labels, milestones and assignees
|
||||||
|
- Keep sidebar folding status
|
||||||
|
- Link from milestone label to the issue list
|
||||||
|
|
||||||
|
### 4.6 - 29 Oct 2016
|
||||||
|
- Add disable option for forking
|
||||||
|
- Add History button to wiki page
|
||||||
|
- Git repository URL redirection for GitHub compatibility
|
||||||
|
- Get-Content API improvement
|
||||||
|
- Indicate who is group master in Members tab in group view
|
||||||
|
|
||||||
|
### 4.5 - 29 Sep 2016
|
||||||
|
- Attach files by dropping into textarea
|
||||||
|
- Issues / Pull requests switcher in dashboard
|
||||||
|
- HikariCP could be configured in `GITBUCKET_HOME/database.conf`
|
||||||
|
- Improve Cookie security
|
||||||
|
- Display commit count on the history button
|
||||||
|
- Improve mobile view
|
||||||
|
|
||||||
|
### 4.4 - 28 Aug 2016
|
||||||
|
- Import a SQL dump file to the database
|
||||||
|
- `go get` support in private repositories
|
||||||
|
- Sort milestones by due date
|
||||||
|
- apache-sshd has been updated to 1.2.0
|
||||||
|
|
||||||
|
### 4.3 - 30 Jul 2016
|
||||||
|
- Emoji support by [gitbucket-emoji-plugin](https://github.com/gitbucket/gitbucket-emoji-plugin)
|
||||||
|
- User name suggestion
|
||||||
|
- Add new web APIs and basic authentication support for API access
|
||||||
|
- Root Endpoint
|
||||||
|
- [List endpoints](https://developer.github.com/v3/#root-endpoint)
|
||||||
|
- [List Branches](https://developer.github.com/v3/repos/branches/#list-branches)
|
||||||
|
- [Get contents](https://developer.github.com/v3/repos/contents/#get-contents)
|
||||||
|
- [Get a Reference](https://developer.github.com/v3/git/refs/#get-a-reference)
|
||||||
|
- [List Collaborators](https://developer.github.com/v3/repos/collaborators/#list-collaborators)
|
||||||
|
- [List user repositories](https://developer.github.com/v3/repos/#list-user-repositories)
|
||||||
|
- [Get a group](https://developer.github.com/v3/orgs/#get-an-organization)
|
||||||
|
- [List group repositories](https://developer.github.com/v3/repos/#list-organization-repositories)
|
||||||
|
- Add new extension points
|
||||||
|
- `assetsMapping` : Supplies resources in plugin classpath as web assets
|
||||||
|
- `suggestionProvider` : Provides suggestion in the Markdown editing textarea
|
||||||
|
- `textDecorator` : Decorate text nodes in HTML which is converted from Markdown
|
||||||
|
|
||||||
|
### 4.2.1 - 3 Jul 2016
|
||||||
|
- Fix migration bug
|
||||||
|
|
||||||
|
This is hotfix for a critical bug in migration. If you are new installation, use 4.2.0. But if you have an exisiting installation and it had been updated to 4.0 from 3.x, you must update to 4.2.1.
|
||||||
|
|
||||||
|
### 4.2 - 2 Jul 2016
|
||||||
|
- New UI based on [AdminLTE](https://github.com/almasaeed2010/AdminLTE)
|
||||||
|
- git gc
|
||||||
|
- Issues and Wiki have been possible to be disabled
|
||||||
|
- SMTP configuration test mail
|
||||||
|
|
||||||
|
### 4.1 - 4 Jun 2016
|
||||||
|
- Generic ssh user
|
||||||
|
- Improve branch protection UI
|
||||||
|
- Default value of pull request title
|
||||||
|
|
||||||
|
### 4.0 - 30 Apr 2016
|
||||||
|
- MySQL and PostgreSQL support
|
||||||
|
- Data export and import
|
||||||
|
- Migration system has been switched to [solidbase](https://github.com/gitbucket/solidbase)
|
||||||
|
|
||||||
|
**Note:** You can upgrade to GitBucket 4.0 from 3.14. If your GitBucket is 3.13 or before, you have to upgrade 3.14 at first.
|
||||||
|
|
||||||
|
### 3.14 - 30 Apr 2016
|
||||||
|
- File attachment and search for wiki pages
|
||||||
|
- New extension points to add menus
|
||||||
|
- Content-Type of webhooks has been choosable
|
||||||
|
|
||||||
|
### 3.13 - 1 Apr 2016
|
||||||
|
- Refresh user interface for wide screen
|
||||||
|
- Add `pull_request` key in list issues API for pull requests
|
||||||
|
- Add `X-Hub-Signature` security to webhooks
|
||||||
|
- Provide SHA-256 checksum for `gitbucket.war`
|
||||||
|
|
||||||
|
### 3.12 - 27 Feb 2016
|
||||||
|
- New GitHub UI
|
||||||
|
- Improve mobile view
|
||||||
|
- Improve printing style
|
||||||
|
- Individual URL for pull request tabs
|
||||||
|
- SSH host configuration is separated from HTTP base URL
|
||||||
|
|
||||||
|
### 3.11 - 30 Jan 2016
|
||||||
|
- Upgrade Scalatra to 2.4
|
||||||
|
- Sidebar and Footer for Wiki
|
||||||
|
- Branch protection and receive hook extension point for plug-in
|
||||||
|
- Limit recent updated repositories list
|
||||||
|
- Issue actions look-alike GitHub
|
||||||
|
- Web API for labels
|
||||||
|
- Requires Java 8
|
||||||
|
|
||||||
|
### 3.10 - 30 Dec 2015
|
||||||
|
- Move to Bootstrap3
|
||||||
|
- New URL for raw contents (`raw/master/doc/activity.md` instead of `blob/master/doc/activity.md?raw=true`)
|
||||||
|
- Update xsbt-web-plugin
|
||||||
|
- Update H2 database
|
||||||
|
|
||||||
|
### 3.9 - 5 Dec 2015
|
||||||
|
- GFM inline breaks support in Markdown
|
||||||
|
- WebHook on create review comment is available
|
||||||
|
- WebHook event trigger is selectable
|
||||||
|
|
||||||
### 3.8 - 31 Oct 2015
|
### 3.8 - 31 Oct 2015
|
||||||
- Moved to organization
|
- Moved to GitHub organization
|
||||||
- Omit diff view for large differences
|
- Omit diff view for large differences
|
||||||
- Repository creation API
|
- Repository creation API
|
||||||
- Render url as link in repository description
|
- Render url as link in repository description
|
||||||
@@ -331,7 +431,3 @@ Release Notes
|
|||||||
|
|
||||||
### 1.0 - 04 Jul 2013
|
### 1.0 - 04 Jul 2013
|
||||||
- This is a first public release
|
- This is a first public release
|
||||||
|
|
||||||
Sponsors
|
|
||||||
--------
|
|
||||||
[](https://www.jetbrains.com/idea/)
|
|
||||||
|
|||||||
220
build.sbt
Normal file
220
build.sbt
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
val Organization = "io.github.gitbucket"
|
||||||
|
val Name = "gitbucket"
|
||||||
|
val GitBucketVersion = "4.9.0"
|
||||||
|
val ScalatraVersion = "2.4.1"
|
||||||
|
val JettyVersion = "9.3.9.v20160517"
|
||||||
|
|
||||||
|
lazy val root = (project in file(".")).enablePlugins(SbtTwirl, JettyPlugin)
|
||||||
|
|
||||||
|
sourcesInBase := false
|
||||||
|
organization := Organization
|
||||||
|
name := Name
|
||||||
|
version := GitBucketVersion
|
||||||
|
scalaVersion := "2.11.8"
|
||||||
|
|
||||||
|
// dependency settings
|
||||||
|
resolvers ++= Seq(
|
||||||
|
Classpaths.typesafeReleases,
|
||||||
|
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(
|
||||||
|
"org.scala-lang.modules" %% "scala-java8-compat" % "0.7.0",
|
||||||
|
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % "4.6.0.201612231935-r",
|
||||||
|
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % "4.6.0.201612231935-r",
|
||||||
|
"org.scalatra" %% "scalatra" % ScalatraVersion,
|
||||||
|
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
|
||||||
|
"org.json4s" %% "json4s-jackson" % "3.3.0",
|
||||||
|
"io.github.gitbucket" %% "scalatra-forms" % "1.0.0",
|
||||||
|
"commons-io" % "commons-io" % "2.4",
|
||||||
|
"io.github.gitbucket" % "solidbase" % "1.0.0",
|
||||||
|
"io.github.gitbucket" % "markedj" % "1.0.9",
|
||||||
|
"org.apache.commons" % "commons-compress" % "1.11",
|
||||||
|
"org.apache.commons" % "commons-email" % "1.4",
|
||||||
|
"org.apache.httpcomponents" % "httpclient" % "4.5.1",
|
||||||
|
"org.apache.sshd" % "apache-sshd" % "1.2.0",
|
||||||
|
"org.apache.tika" % "tika-core" % "1.13",
|
||||||
|
"com.typesafe.slick" %% "slick" % "2.1.0",
|
||||||
|
"com.novell.ldap" % "jldap" % "2009-10-07",
|
||||||
|
"com.h2database" % "h2" % "1.4.192",
|
||||||
|
"mysql" % "mysql-connector-java" % "5.1.39",
|
||||||
|
"org.postgresql" % "postgresql" % "9.4.1208",
|
||||||
|
"ch.qos.logback" % "logback-classic" % "1.1.7",
|
||||||
|
"com.zaxxer" % "HikariCP" % "2.4.6",
|
||||||
|
"com.typesafe" % "config" % "1.3.0",
|
||||||
|
"com.typesafe.akka" %% "akka-actor" % "2.3.15",
|
||||||
|
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.0.0",
|
||||||
|
"com.github.bkromhout" % "java-diff-utils" % "2.1.1",
|
||||||
|
"org.cache2k" % "cache2k-all" % "1.0.0.CR1",
|
||||||
|
"com.enragedginger" %% "akka-quartz-scheduler" % "1.4.0-akka-2.3.x" exclude("c3p0","c3p0"),
|
||||||
|
"net.coobird" % "thumbnailator" % "0.4.8",
|
||||||
|
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
|
||||||
|
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
|
||||||
|
"junit" % "junit" % "4.12" % "test",
|
||||||
|
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
|
||||||
|
"com.wix" % "wix-embedded-mysql" % "2.1.4" % "test",
|
||||||
|
"ru.yandex.qatools.embed" % "postgresql-embedded" % "1.14" % "test"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Compiler settings
|
||||||
|
scalacOptions := Seq("-deprecation", "-language:postfixOps", "-Ybackend:GenBCode", "-Ydelambdafy:method", "-target:jvm-1.8")
|
||||||
|
javacOptions in compile ++= Seq("-target", "8", "-source", "8")
|
||||||
|
javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml"
|
||||||
|
|
||||||
|
// Test settings
|
||||||
|
//testOptions in Test += Tests.Argument("-l", "ExternalDBTest")
|
||||||
|
javaOptions in Test += "-Dgitbucket.home=target/gitbucket_home_for_test"
|
||||||
|
testOptions in Test += Tests.Setup( () => new java.io.File("target/gitbucket_home_for_test").mkdir() )
|
||||||
|
fork in Test := true
|
||||||
|
|
||||||
|
// Packaging options
|
||||||
|
packageOptions += Package.MainClass("JettyLauncher")
|
||||||
|
|
||||||
|
// Assembly settings
|
||||||
|
test in assembly := {}
|
||||||
|
assemblyMergeStrategy in assembly := {
|
||||||
|
case PathList("META-INF", xs @ _*) =>
|
||||||
|
(xs map {_.toLowerCase}) match {
|
||||||
|
case ("manifest.mf" :: Nil) => MergeStrategy.discard
|
||||||
|
case _ => MergeStrategy.discard
|
||||||
|
}
|
||||||
|
case x => MergeStrategy.first
|
||||||
|
}
|
||||||
|
|
||||||
|
// JRebel
|
||||||
|
Seq(jrebelSettings: _*)
|
||||||
|
|
||||||
|
jrebel.webLinks += (target in webappPrepare).value
|
||||||
|
jrebel.enabled := System.getenv().get("JREBEL") != null
|
||||||
|
javaOptions in Jetty ++= Option(System.getenv().get("JREBEL")).toSeq.flatMap { path =>
|
||||||
|
Seq("-noverify", "-XX:+UseConcMarkSweepGC", "-XX:+CMSClassUnloadingEnabled", s"-javaagent:${path}")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create executable war file
|
||||||
|
val executableConfig = config("executable").hide
|
||||||
|
Keys.ivyConfigurations += executableConfig
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"org.eclipse.jetty" % "jetty-security" % 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-xml" % JettyVersion % "executable",
|
||||||
|
"org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
|
||||||
|
"org.eclipse.jetty" % "jetty-servlet" % JettyVersion % "executable",
|
||||||
|
"org.eclipse.jetty" % "jetty-io" % JettyVersion % "executable",
|
||||||
|
"org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
|
||||||
|
)
|
||||||
|
|
||||||
|
val executableKey = TaskKey[File]("executable")
|
||||||
|
executableKey := {
|
||||||
|
import java.util.jar.{ Manifest => JarManifest }
|
||||||
|
import java.util.jar.Attributes.{ Name => AttrName }
|
||||||
|
|
||||||
|
val workDir = Keys.target.value / "executable"
|
||||||
|
val warName = Keys.name.value + ".war"
|
||||||
|
|
||||||
|
val log = streams.value.log
|
||||||
|
log info s"building executable webapp in ${workDir}"
|
||||||
|
|
||||||
|
// initialize temp directory
|
||||||
|
val temp = workDir / "webapp"
|
||||||
|
IO delete temp
|
||||||
|
|
||||||
|
// include jetty classes
|
||||||
|
val jettyJars = Keys.update.value select configurationFilter(name = executableConfig.name)
|
||||||
|
jettyJars foreach { jar =>
|
||||||
|
IO unzip (jar, temp, (name:String) =>
|
||||||
|
(name startsWith "javax/") ||
|
||||||
|
(name startsWith "org/")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// include original war file
|
||||||
|
val warFile = (Keys.`package`).value
|
||||||
|
IO unzip (warFile, temp)
|
||||||
|
|
||||||
|
// include launcher classes
|
||||||
|
val classDir = (Keys.classDirectory in Compile).value
|
||||||
|
val launchClasses = Seq("JettyLauncher.class" /*, "HttpsSupportConnector.class" */)
|
||||||
|
launchClasses foreach { name =>
|
||||||
|
IO copyFile (classDir / name, temp / name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// zip it up
|
||||||
|
IO delete (temp / "META-INF" / "MANIFEST.MF")
|
||||||
|
val contentMappings = (temp.*** --- PathFinder(temp)).get pair relativeTo(temp)
|
||||||
|
val manifest = new JarManifest
|
||||||
|
manifest.getMainAttributes put (AttrName.MANIFEST_VERSION, "1.0")
|
||||||
|
manifest.getMainAttributes put (AttrName.MAIN_CLASS, "JettyLauncher")
|
||||||
|
val outputFile = workDir / warName
|
||||||
|
IO jar (contentMappings, outputFile, manifest)
|
||||||
|
|
||||||
|
// generate checksums
|
||||||
|
Seq(
|
||||||
|
"md5" -> "MD5",
|
||||||
|
"sha1" -> "SHA-1",
|
||||||
|
"sha256" -> "SHA-256"
|
||||||
|
)
|
||||||
|
.foreach { case (extension, algorithm) =>
|
||||||
|
val checksumFile = workDir / (warName + "." + extension)
|
||||||
|
Checksums generate (outputFile, checksumFile, algorithm)
|
||||||
|
}
|
||||||
|
|
||||||
|
// done
|
||||||
|
log info s"built executable webapp ${outputFile}"
|
||||||
|
outputFile
|
||||||
|
}
|
||||||
|
publishTo := {
|
||||||
|
val nexus = "https://oss.sonatype.org/"
|
||||||
|
if (version.value.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
|
||||||
|
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
|
||||||
|
}
|
||||||
|
publishMavenStyle := true
|
||||||
|
pomIncludeRepository := { _ => false }
|
||||||
|
pomExtra := (
|
||||||
|
<url>https://github.com/gitbucket/gitbucket</url>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>The Apache Software License, Version 2.0</name>
|
||||||
|
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<scm>
|
||||||
|
<url>https://github.com/gitbucket/gitbucket</url>
|
||||||
|
<connection>scm:git:https://github.com/gitbucket/gitbucket.git</connection>
|
||||||
|
</scm>
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>takezoe</id>
|
||||||
|
<name>Naoki Takezoe</name>
|
||||||
|
<url>https://github.com/takezoe</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>shimamoto</id>
|
||||||
|
<name>Takako Shimamoto</name>
|
||||||
|
<url>https://github.com/shimamoto</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>tanacasino</id>
|
||||||
|
<name>Tomofumi Tanaka</name>
|
||||||
|
<url>https://github.com/tanacasino</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>mrkm4ntr</id>
|
||||||
|
<name>Shintaro Murakami</name>
|
||||||
|
<url>https://github.com/mrkm4ntr</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>nazoking</id>
|
||||||
|
<name>nazoking</name>
|
||||||
|
<url>https://github.com/nazoking</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>McFoggy</id>
|
||||||
|
<name>Matthieu Brouillard</name>
|
||||||
|
<url>https://github.com/McFoggy</url>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
)
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
RPM spec file and init script for Red Hat Enterprise Linux 6.x.
|
RPM spec file and init script for Red Hat Enterprise Linux 6.x.
|
||||||
|
|
||||||
To create RPM:
|
To create RPM:
|
||||||
|
|
||||||
1. Edit `../../gitbucket.conf` to suit.
|
1. Edit `../../gitbucket.conf` to suit.
|
||||||
2. Edit `gitbucket.init` to suit.
|
2. Edit `gitbucket.init` to suit.
|
||||||
3. Edit `gitbucket.spec` to suit.
|
3. Edit `gitbucket.spec` to suit.
|
||||||
|
|||||||
60
doc/authenticator.md
Normal file
60
doc/authenticator.md
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
|
For example, in the case of `RepositoryViwerController`,
|
||||||
|
it references three authenticators: `ReadableUsersAuthenticator`, `ReferrerAuthenticator` and `CollaboratorsAuthenticator`.
|
||||||
|
|
||||||
|
```scala
|
||||||
|
class RepositoryViewerController extends RepositoryViewerControllerBase
|
||||||
|
with RepositoryService with AccountService with ActivityService with IssuesService with WebHookService with CommitsService
|
||||||
|
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator with PullRequestService with CommitStatusService
|
||||||
|
with WebHookPullRequestService with WebHookPullRequestReviewCommentService
|
||||||
|
|
||||||
|
trait RepositoryViewerControllerBase extends ControllerBase {
|
||||||
|
self: RepositoryService with AccountService with ActivityService with IssuesService with WebHookService with CommitsService
|
||||||
|
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator with PullRequestService with CommitStatusService
|
||||||
|
with WebHookPullRequestService with WebHookPullRequestReviewCommentService =>
|
||||||
|
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Authenticators provides a method to add guard to actions in the controller:
|
||||||
|
|
||||||
|
- `ReadableUsersAuthenticator` provides `readableUsersOnly` method
|
||||||
|
- `ReferrerAuthenticator` provides `referrersOnly` method
|
||||||
|
- `CollaboratorsAuthenticator` provides `collaboratorsOnly` method
|
||||||
|
|
||||||
|
These methods are available in each actions as below:
|
||||||
|
|
||||||
|
```scala
|
||||||
|
// Allows only the repository owner (or manager for group repository) and administrators.
|
||||||
|
get("/:owner/:repository/tree/*")(referrersOnly { repository =>
|
||||||
|
...
|
||||||
|
})
|
||||||
|
|
||||||
|
// Allows only collaborators and administrators.
|
||||||
|
get("/:owner/:repository/new/*")(collaboratorsOnly { repository =>
|
||||||
|
...
|
||||||
|
})
|
||||||
|
|
||||||
|
// Allows only signed in users which can access the repository.
|
||||||
|
post("/:owner/:repository/commit/:id/comment/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
|
...
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Currently, GitBucket provides below authenticators:
|
||||||
|
|
||||||
|
|Trait | Method | Description |
|
||||||
|
|--------------------------|-----------------|--------------------------------------------------------------------------------------|
|
||||||
|
|OneselfAuthenticator |oneselfOnly |Allows only oneself and administrators. |
|
||||||
|
|OwnerAuthenticator |ownerOnly |Allows only the repository owner and administrators. |
|
||||||
|
|UsersAuthenticator |usersOnly |Allows only signed in users. |
|
||||||
|
|AdminAuthenticator |adminOnly |Allows only administrators. |
|
||||||
|
|CollaboratorsAuthenticator|collaboratorsOnly|Allows only collaborators 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. |
|
||||||
|
|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.
|
||||||
@@ -1,37 +1,54 @@
|
|||||||
Automatic Schema Updating
|
Automatic Schema Updating
|
||||||
========
|
========
|
||||||
GitBucket uses H2 database to manage project and account data. GitBucket updates database schema automatically 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.servlet.AutoUpdate](https://github.com/gitbucket/gitbucket/blob/master/src/main/scala/gitbucket/core/servlet/AutoUpdate.scala) at first.
|
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.
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
object AutoUpdate {
|
object GitBucketCoreModule extends Module("gitbucket-core",
|
||||||
...
|
new Version("4.0.0",
|
||||||
/**
|
new LiquibaseMigration("update/gitbucket-core_4.0.xml"),
|
||||||
* The history of versions. A head of this sequence is the current BitBucket version.
|
new SqlMigration("update/gitbucket-core_4.0.sql")
|
||||||
*/
|
),
|
||||||
val versions = Seq(
|
new Version("4.1.0"),
|
||||||
Version(1, 0)
|
new Version("4.2.0",
|
||||||
|
new LiquibaseMigration("update/gitbucket-core_4.2.xml")
|
||||||
)
|
)
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
Next, add a SQL file which updates database schema into [/src/main/resources/update/](https://github.com/gitbucket/gitbucket/tree/master/src/main/resources/update) as ```MAJOR_MINOR.sql```.
|
|
||||||
|
|
||||||
GitBucket stores the current version to ```GITBUCKET_HOME/version``` and checks it at start-up. If the stored version differs from the actual version, it executes differences of SQL files between the stored version and the actual version. And ```GITBUCKET_HOME/version``` is updated by the actual version.
|
|
||||||
|
|
||||||
We can also add any Scala code for upgrade GitBucket which modifies resources other than database. Override ```Version.update``` like below:
|
|
||||||
|
|
||||||
```scala
|
|
||||||
val versions = Seq(
|
|
||||||
new Version(1, 3){
|
|
||||||
override def update(conn: Connection): Unit = {
|
|
||||||
super.update(conn)
|
|
||||||
// Add any code here!
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Version(1, 2),
|
|
||||||
Version(1, 1),
|
|
||||||
Version(1, 0)
|
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
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`.
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="REPOSITORY">
|
||||||
|
<column name="ENABLE_WIKI" type="boolean" nullable="false" defaultValueBoolean="true"/>
|
||||||
|
<column name="ENABLE_ISSUES" type="boolean" nullable="false" defaultValueBoolean="true"/>
|
||||||
|
<column name="EXTERNAL_WIKI_URL" type="varchar(200)" nullable="true"/>
|
||||||
|
<column name="EXTERNAL_ISSUES_URL" type="varchar(200)" nullable="true"/>
|
||||||
|
</addColumn>
|
||||||
|
</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.
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
1. Specified path (if specified)
|
||||||
|
2. `${moduleId}_${version}_${database}.sql`
|
||||||
|
3. `${moduleId}_${version}.sql`
|
||||||
|
|
||||||
|
Also we can add any code by extending `Migration`:
|
||||||
|
|
||||||
|
```scala
|
||||||
|
object GitBucketCoreModule extends Module("gitbucket-core",
|
||||||
|
new Version("4.0.0", new Migration(){
|
||||||
|
override def migrate(moduleId: String, version: String, context: java.util.Map[String, String]): Unit = {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
See more details [README of Solidbase](https://github.com/gitbucket/solidbase).
|
||||||
|
|||||||
@@ -1,48 +1,56 @@
|
|||||||
About Action in Issue Comment
|
About Action in Issue Comment
|
||||||
========
|
========
|
||||||
After the issue creation at GitBucket, users can add comments or close it.
|
After the issue creation at GitBucket, users can add comments or close it.
|
||||||
The details are saved at ```ISSUE_COMMENT``` table.
|
The details are saved at `ISSUE_COMMENT` table.
|
||||||
|
|
||||||
To determine if it was any operation, you see the ```ACTION``` column.
|
To determine if it was any operation, you see the `ACTION` column.
|
||||||
|
And in the case of some actions, `CONTENT` column value contains additional information.
|
||||||
|
|
||||||
|ACTION|
|
|ACTION |CONTENT |
|
||||||
|--------|
|
|---------------|-----------------|
|
||||||
|comment|
|
|comment |comment |
|
||||||
|close_comment|
|
|close_comment |comment |
|
||||||
|reopen_comment|
|
|reopen_comment |comment |
|
||||||
|close|
|
|close |"Close" |
|
||||||
|reopen|
|
|reopen |"Reopen" |
|
||||||
|commit|
|
|commit |comment commitId |
|
||||||
|merge|
|
|merge |comment |
|
||||||
|delete_branch|
|
|delete_branch |branchName |
|
||||||
|refer|
|
|refer |issueId:title |
|
||||||
|
|
||||||
|
### comment
|
||||||
|
|
||||||
#####comment
|
|
||||||
This value is saved when users have made a normal comment.
|
This value is saved when users have made a normal comment.
|
||||||
|
|
||||||
#####close_comment, reopen_comment
|
### close_comment, reopen_comment
|
||||||
|
|
||||||
These values are saved when users have reopened or closed the issue with comments.
|
These values are saved when users have reopened or closed the issue with comments.
|
||||||
|
|
||||||
#####close, reopen
|
### close, reopen
|
||||||
|
|
||||||
These values are saved when users have reopened or closed the issue.
|
These values are saved when users have reopened or closed the issue.
|
||||||
At the same time, store the fixed value(i.e. "Close" or "Reopen") to the ```CONTENT``` column.
|
At the same time, store the fixed value(i.e. "Close" or "Reopen") to the `CONTENT` column.
|
||||||
Therefore, this comment is not displayed, and not counted as a comment.
|
Therefore, this comment is not displayed, and not counted as a comment.
|
||||||
|
|
||||||
#####commit
|
### commit
|
||||||
This value is saved when users have pushed including the ```#issueId``` to the commit message.
|
|
||||||
At the same time, store it to the ```CONTENT``` column with its commit id.
|
This value is saved when users have pushed including the `#issueId` to the commit message.
|
||||||
|
At the same time, store it to the `CONTENT` column with its commit id.
|
||||||
This comment is displayed. But it can not be edited by all users, and also not counted as a comment.
|
This comment is displayed. But it can not be edited by all users, and also not counted as a comment.
|
||||||
|
|
||||||
#####merge
|
### merge
|
||||||
|
|
||||||
This value is saved when users have merged the pull request.
|
This value is saved when users have merged the pull request.
|
||||||
At the same time, store the message to the ```CONTENT``` column.
|
At the same time, store the message to the `CONTENT` column.
|
||||||
This comment is displayed. But it can not be edited by all users, and also not counted as a comment.
|
This comment is displayed. But it can not be edited by all users, and also not counted as a comment.
|
||||||
|
|
||||||
#####delete_branch
|
### delete_branch
|
||||||
|
|
||||||
This value is saved when users have deleted the branch. Users can delete branch after merging pull request which is requested from the same repository.
|
This value is saved when users have deleted the branch. Users can delete branch after merging pull request which is requested from the same repository.
|
||||||
At the same time, store it to the ```CONTENT``` column with the deleted branch name.
|
At the same time, store it to the `CONTENT` column with the deleted branch name.
|
||||||
Therefore, this comment is not displayed, and not counted as a comment.
|
Therefore, this comment is not displayed, and not counted as a comment.
|
||||||
|
|
||||||
#####refer
|
### refer
|
||||||
This value is saved when other issue or issue comment contains reference to the issue like ```#issueId```.
|
|
||||||
At the same time, store id and title of the referrer issue as ```id:title```.
|
This value is saved when other issue or issue comment contains reference to the issue like `#issueId`.
|
||||||
|
At the same time, store id and title of the referrer issue as `id:title`.
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ This directory has following structure:
|
|||||||
* /HOME/gitbucket
|
* /HOME/gitbucket
|
||||||
* /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
|
* /REPO_NAME
|
||||||
* /issues (files which are attached to issue)
|
* /issues (files which are attached to issue)
|
||||||
* / REPO_NAME.wiki.git (wiki repository)
|
* /REPO_NAME.wiki.git (wiki repository)
|
||||||
* /data
|
* /data
|
||||||
* /USER_NAME
|
* /USER_NAME
|
||||||
* /files
|
* /files
|
||||||
|
|||||||
@@ -1,63 +1,42 @@
|
|||||||
How to run from the source tree
|
How to run from the source tree
|
||||||
========
|
========
|
||||||
|
|
||||||
for Testers
|
Run for Development
|
||||||
--------
|
--------
|
||||||
|
|
||||||
If you want to test GitBucket, input following command at the root directory of the source tree.
|
If you want to test GitBucket, input following command at the root directory of the source tree.
|
||||||
|
|
||||||
```
|
```
|
||||||
C:\gitbucket> sbt ~container:start
|
$ sbt ~jetty:start
|
||||||
```
|
```
|
||||||
|
|
||||||
Then access to `http://localhost:8080/` by your browser. The default administrator account is `root` and password is `root`.
|
Then access to `http://localhost:8080/` by your browser. The default administrator account is `root` and password is `root`.
|
||||||
|
|
||||||
for Developers
|
Source code modification is detected and reloaded automatically. You can modify logging configuration by editing `src/main/resources/logback-dev.xml`.
|
||||||
--------
|
|
||||||
If you want to modify source code and confirm it, you can run GitBucket in auto reloading mode as following:
|
|
||||||
|
|
||||||
Windows:
|
|
||||||
|
|
||||||
```
|
|
||||||
C:\gitbucket> sbt
|
|
||||||
...
|
|
||||||
> container:start
|
|
||||||
...
|
|
||||||
> ~ ;copy-resources;aux-compile
|
|
||||||
```
|
|
||||||
|
|
||||||
Linux:
|
|
||||||
|
|
||||||
```
|
|
||||||
~/gitbucket$ ./sbt.sh
|
|
||||||
...
|
|
||||||
> container:start
|
|
||||||
...
|
|
||||||
> ~ ;copy-resources;aux-compile
|
|
||||||
```
|
|
||||||
|
|
||||||
Build war file
|
Build war file
|
||||||
--------
|
--------
|
||||||
|
|
||||||
To build war file, run the following command:
|
To build war file, run the following command:
|
||||||
|
|
||||||
Windows:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
C:\gitbucket> sbt package
|
$ sbt package
|
||||||
```
|
|
||||||
|
|
||||||
Linux:
|
|
||||||
|
|
||||||
```
|
|
||||||
~/gitbucket$ ./sbt.sh package
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`gitbucket_2.11-x.x.x.war` is generated into `target/scala-2.11`.
|
`gitbucket_2.11-x.x.x.war` is generated into `target/scala-2.11`.
|
||||||
|
|
||||||
To build executable war file, run
|
To build executable war file, run
|
||||||
|
|
||||||
* Windows: Not available
|
```
|
||||||
* Linux: `./release/make-release-war.sh`
|
$ sbt executable
|
||||||
|
```
|
||||||
|
|
||||||
at the top of the source tree. It generates executable `gitbucket.war` into `target/scala-2.11`. We release this war file as release artifact.
|
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 serie of tests, run the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
sbt test
|
||||||
|
```
|
||||||
|
|||||||
148
doc/jrebel.md
Normal file
148
doc/jrebel.md
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
JRebel integration (optional)
|
||||||
|
=============================
|
||||||
|
|
||||||
|
[JRebel](http://zeroturnaround.com/software/jrebel/) is a JVM plugin that makes developing web apps much faster.
|
||||||
|
JRebel is generally able to eliminate the need for the following slow "app restart" in sbt following a code change:
|
||||||
|
|
||||||
|
```
|
||||||
|
> jetty:start
|
||||||
|
```
|
||||||
|
|
||||||
|
While JRebel is not open source, it does reload your code faster than the `~;copy-resources;aux-compile` way of doing things using `sbt`.
|
||||||
|
|
||||||
|
It's only used during development, and doesn't change your deployed app in any way.
|
||||||
|
|
||||||
|
JRebel used to be free for Scala developers, but that changed recently, and now there's a cost associated with usage for Scala. There are trial plans and free non-commercial licenses available if you just want to try it out.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## 1. Get a JRebel license
|
||||||
|
|
||||||
|
Sign up for a [usage plan](https://my.jrebel.com/). You will need to create an account.
|
||||||
|
|
||||||
|
## 2. Download JRebel
|
||||||
|
|
||||||
|
Download the most recent ["nosetup" JRebel zip](http://zeroturnaround.com/software/jrebel/download/prev-releases/).
|
||||||
|
Next, unzip the downloaded file.
|
||||||
|
|
||||||
|
## 3. Activate
|
||||||
|
|
||||||
|
Follow the [instructions on the JRebel website](http://zeroturnaround.com/software/jrebel/download/prev-releases/) to activate your downloaded JRebel.
|
||||||
|
|
||||||
|
You can use the default settings for all the configurations.
|
||||||
|
|
||||||
|
You don't need to integrate with your IDE, since we're using sbt to do the servlet deployment.
|
||||||
|
|
||||||
|
## 4. Tell jvm where JRebel is
|
||||||
|
|
||||||
|
Fortunately, the gitbucket project is already set up to use JRebel.
|
||||||
|
You only need to tell jvm where to find the jrebel jar.
|
||||||
|
|
||||||
|
To do so, edit your shell resource file (usually `~/.bash_profile` on Mac, and `~/.bashrc` on Linux), and add the following line:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export JREBEL=/path/to/jrebel/jrebel.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
For example, if you unzipped your JRebel download in your home directory, you whould use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export JREBEL=~/jrebel/jrebel.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
Now reload your shell:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ source ~/.bash_profile # on Mac
|
||||||
|
$ source ~/.bashrc # on Linux
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. See it in action!
|
||||||
|
|
||||||
|
Now you're ready to use JRebel with the gitbucket.
|
||||||
|
When you run sbt as normal, you will see a long message from JRebel, indicating it has loaded.
|
||||||
|
Here's an abbreviated version of what you will see:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ./sbt
|
||||||
|
[info] Loading project definition from /git/gitbucket/project
|
||||||
|
[info] Set current project to gitbucket (in build file:/git/gitbucket/)
|
||||||
|
>
|
||||||
|
```
|
||||||
|
|
||||||
|
You will start the servlet container slightly differently now that you're using sbt.
|
||||||
|
|
||||||
|
```
|
||||||
|
> jetty:start
|
||||||
|
:
|
||||||
|
[info] starting server ...
|
||||||
|
[success] Total time: 3 s, completed Jan 3, 2016 9:47:55 PM
|
||||||
|
2016-01-03 21:47:57 JRebel:
|
||||||
|
2016-01-03 21:47:57 JRebel: A newer version '6.3.1' is available for download
|
||||||
|
2016-01-03 21:47:57 JRebel: from http://zeroturnaround.com/software/jrebel/download/
|
||||||
|
2016-01-03 21:47:57 JRebel:
|
||||||
|
2016-01-03 21:47:58 JRebel: Contacting myJRebel server ..
|
||||||
|
2016-01-03 21:47:59 JRebel: Directory '/git/gitbucket/target/scala-2.11/classes' will be monitored for changes.
|
||||||
|
2016-01-03 21:47:59 JRebel: Directory '/git/gitbucket/target/scala-2.11/test-classes' will be monitored for changes.
|
||||||
|
2016-01-03 21:47:59 JRebel: Directory '/git/gitbucket/target/webapp' will be monitored for changes.
|
||||||
|
2016-01-03 21:48:00 JRebel:
|
||||||
|
2016-01-03 21:48:00 JRebel: #############################################################
|
||||||
|
2016-01-03 21:48:00 JRebel:
|
||||||
|
2016-01-03 21:48:00 JRebel: JRebel Legacy Agent 6.2.5 (201509291538)
|
||||||
|
2016-01-03 21:48:00 JRebel: (c) Copyright ZeroTurnaround AS, Estonia, Tartu.
|
||||||
|
2016-01-03 21:48:00 JRebel:
|
||||||
|
2016-01-03 21:48:00 JRebel: Over the last 30 days JRebel prevented
|
||||||
|
2016-01-03 21:48:00 JRebel: at least 182 redeploys/restarts saving you about 7.4 hours.
|
||||||
|
2016-01-03 21:48:00 JRebel:
|
||||||
|
2016-01-03 21:48:00 JRebel: Over the last 324 days JRebel prevented
|
||||||
|
2016-01-03 21:48:00 JRebel: at least 1538 redeploys/restarts saving you about 62.4 hours.
|
||||||
|
2016-01-03 21:48:00 JRebel:
|
||||||
|
2016-01-03 21:48:00 JRebel: Licensed to nazo king (using myJRebel).
|
||||||
|
2016-01-03 21:48:00 JRebel:
|
||||||
|
2016-01-03 21:48:00 JRebel:
|
||||||
|
2016-01-03 21:48:00 JRebel: #############################################################
|
||||||
|
2016-01-03 21:48:00 JRebel:
|
||||||
|
:
|
||||||
|
|
||||||
|
> ~ copy-resources
|
||||||
|
[success] Total time: 0 s, completed Jan 3, 2016 9:13:54 PM
|
||||||
|
1. Waiting for source changes... (press enter to interrupt)
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, change your code.
|
||||||
|
For example, you can change the title on `src/main/twirl/gitbucket/core/main.scala.html` like this:
|
||||||
|
|
||||||
|
```html
|
||||||
|
:
|
||||||
|
<a class="navbar-brand" href="@path/">
|
||||||
|
<img src="@assets/common/images/gitbucket.png" style="width: 24px; height: 24px;"/>GitBucket
|
||||||
|
@defining(AutoUpdate.getCurrentVersion){ version =>
|
||||||
|
<span class="header-version">@version.majorVersion.@version.minorVersion</span>
|
||||||
|
}
|
||||||
|
change code !!!!!!!!!!!!!!!!
|
||||||
|
</a>
|
||||||
|
:
|
||||||
|
```
|
||||||
|
|
||||||
|
If JRebel is doing is correctly installed you will see a notice for you:
|
||||||
|
|
||||||
|
```
|
||||||
|
1. Waiting for source changes... (press enter to interrupt)
|
||||||
|
2016-01-03 21:48:42 JRebel: Reloading class 'gitbucket.core.html.main$'.
|
||||||
|
[info] Wrote rebel.xml to /git/gitbucket/target/scala-2.11/resource_managed/main/rebel.xml
|
||||||
|
[info] Compiling 1 Scala source to /git/gitbucket/target/scala-2.11/classes...
|
||||||
|
[success] Total time: 3 s, completed Jan 3, 2016 9:48:55 PM
|
||||||
|
2. Waiting for source changes... (press enter to interrupt)
|
||||||
|
```
|
||||||
|
|
||||||
|
And you reload browser, JRebel give notice of that it has reloaded classes:
|
||||||
|
|
||||||
|
```
|
||||||
|
[success] Total time: 3 s, completed Jan 3, 2016 9:48:55 PM
|
||||||
|
2. Waiting for source changes... (press enter to interrupt)
|
||||||
|
2016-01-03 21:49:13 JRebel: Reloading class 'gitbucket.core.html.main$'.
|
||||||
|
```
|
||||||
|
|
||||||
|
## 6. Limitations
|
||||||
|
|
||||||
|
JRebel is nearly always able to eliminate the need to explicitly reload your container after a code change. However, if you change any of your routes patterns, there is nothing JRebel can do, you will have to run `jetty:start`.
|
||||||
@@ -3,9 +3,10 @@ Developer's Guide
|
|||||||
* [How to run from source tree](how_to_run.md)
|
* [How to run from source tree](how_to_run.md)
|
||||||
* [Directory Structure](directory.md)
|
* [Directory Structure](directory.md)
|
||||||
* [Mapping and Validation](validation.md)
|
* [Mapping and Validation](validation.md)
|
||||||
* Authentication in Controller (not yet)
|
* [Authentication in Controller](authenticator.md)
|
||||||
* [About Action in Issue Comment](comment_action.md)
|
* [About Action in Issue Comment](comment_action.md)
|
||||||
* [Activity Types](activity.md)
|
* [Activity Types](activity.md)
|
||||||
* [Notification Email](notification.md)
|
* [Notification Email](notification.md)
|
||||||
* [Automatic Schema Updating](auto_update.md)
|
* [Automatic Schema Updating](auto_update.md)
|
||||||
* [Release Operation](release.md)
|
* [Release Operation](release.md)
|
||||||
|
* [JRebel integration (optional)](jrebel.md)
|
||||||
|
|||||||
@@ -6,28 +6,29 @@ Update version number
|
|||||||
|
|
||||||
Note to update version number in files below:
|
Note to update version number in files below:
|
||||||
|
|
||||||
### project/build.scala
|
### build.sbt
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
object MyBuild extends Build {
|
val Organization = "gitbucket"
|
||||||
val Organization = "gitbucket"
|
val Name = "gitbucket"
|
||||||
val Name = "gitbucket"
|
val GitBucketVersion = "4.0.0" // <---- update version!!
|
||||||
val Version = "3.3.0" // <---- update version!!
|
val ScalatraVersion = "2.4.0"
|
||||||
val ScalaVersion = "2.11.6"
|
val JettyVersion = "9.3.6.v20151106"
|
||||||
val ScalatraVersion = "2.3.1"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### src/main/scala/gitbucket/core/servlet/AutoUpdate.scala
|
### src/main/scala/gitbucket/core/GitBucketCoreModule.scala
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
object AutoUpdate {
|
object GitBucketCoreModule extends Module("gitbucket-core",
|
||||||
|
new Version("4.0.0",
|
||||||
/**
|
new LiquibaseMigration("update/gitbucket-core_4.0.xml"),
|
||||||
* The history of versions. A head of this sequence is the current BitBucket version.
|
new SqlMigration("update/gitbucket-core_4.0.sql")
|
||||||
*/
|
),
|
||||||
val versions = Seq(
|
// add new version definition
|
||||||
new Version(3, 3), // <---- add this line!!
|
new Version("4.1.0",
|
||||||
new Version(3, 2),
|
new LiquibaseMigration("update/gitbucket-core_4.1.xml")
|
||||||
|
)
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Generate release files
|
Generate release files
|
||||||
@@ -37,18 +38,18 @@ Note: Release operation requires [Ant](http://ant.apache.org/) and [Maven](https
|
|||||||
|
|
||||||
### Make release war file
|
### Make release war file
|
||||||
|
|
||||||
Run `release/make-release-war.sh`. The release war file is generated into `target/scala-2.11/gitbucket.war`.
|
Run `sbt executable`. The release war file and fingerprint are generated into `target/executable/gitbucket.war`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ cd release
|
$ sbt executable
|
||||||
$ ./make-release-war.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deploy assembly jar file
|
### Deploy assembly jar file
|
||||||
|
|
||||||
For plug-in development, we have to publish the assembly jar file to the public Maven repository by `release/deploy-assembly-jar.sh`.
|
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
|
```bash
|
||||||
$ cd release/
|
$ sbt publish-signed
|
||||||
$ ./deploy-assembly-jar.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Then operate release sequence at https://oss.sonatype.org/.
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,11 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
version=$1
|
|
||||||
output_dir=`dirname $0`
|
|
||||||
git rm -f ${output_dir}/jetty-*.jar
|
|
||||||
for name in 'io' 'servlet' 'xml' 'continuation' 'security' 'util' 'http' 'server' 'webapp'
|
|
||||||
do
|
|
||||||
jar_filename="jetty-${name}-${version}.jar"
|
|
||||||
wget "http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-${name}/${version}/${jar_filename}" -O ${output_dir}/${jar_filename}
|
|
||||||
done
|
|
||||||
git add ${output_dir}/*.jar
|
|
||||||
git commit
|
|
||||||
34
project/Checksums.scala
Normal file
34
project/Checksums.scala
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import java.security.MessageDigest;
|
||||||
|
import scala.annotation._
|
||||||
|
import sbt._
|
||||||
|
import sbt.Using._
|
||||||
|
|
||||||
|
object Checksums {
|
||||||
|
private val bufferSize = 2048
|
||||||
|
|
||||||
|
def generate(source:File, target:File, algorithm:String):Unit =
|
||||||
|
IO write (target, compute(source, algorithm))
|
||||||
|
|
||||||
|
def compute(file:File, algorithm:String):String =
|
||||||
|
hex(raw(file, algorithm))
|
||||||
|
|
||||||
|
def raw(file:File, algorithm:String):Array[Byte] =
|
||||||
|
(Using fileInputStream file) { is =>
|
||||||
|
val md = MessageDigest getInstance algorithm
|
||||||
|
val buf = new Array[Byte](bufferSize)
|
||||||
|
md.reset()
|
||||||
|
@tailrec
|
||||||
|
def loop() {
|
||||||
|
val len = is read buf
|
||||||
|
if (len != -1) {
|
||||||
|
md update (buf, 0, len)
|
||||||
|
loop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loop()
|
||||||
|
md.digest()
|
||||||
|
}
|
||||||
|
|
||||||
|
def hex(bytes:Array[Byte]):String =
|
||||||
|
bytes map { it => "%02x" format (it.toInt & 0xff) } mkString ""
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
sbt.version=0.13.8
|
sbt.version=0.13.12
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
import sbt._
|
|
||||||
import Keys._
|
|
||||||
import org.scalatra.sbt._
|
|
||||||
import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys
|
|
||||||
import play.twirl.sbt.SbtTwirl
|
|
||||||
import play.twirl.sbt.Import.TwirlKeys._
|
|
||||||
import sbtassembly._
|
|
||||||
import sbtassembly.AssemblyKeys._
|
|
||||||
|
|
||||||
object MyBuild extends Build {
|
|
||||||
val Organization = "gitbucket"
|
|
||||||
val Name = "gitbucket"
|
|
||||||
val Version = "3.8.0"
|
|
||||||
val ScalaVersion = "2.11.6"
|
|
||||||
val ScalatraVersion = "2.3.1"
|
|
||||||
|
|
||||||
lazy val project = Project (
|
|
||||||
"gitbucket",
|
|
||||||
file(".")
|
|
||||||
)
|
|
||||||
.settings(ScalatraPlugin.scalatraWithJRebel: _*)
|
|
||||||
.settings(
|
|
||||||
test in assembly := {},
|
|
||||||
assemblyMergeStrategy in assembly := {
|
|
||||||
case PathList("META-INF", xs @ _*) =>
|
|
||||||
(xs map {_.toLowerCase}) match {
|
|
||||||
case ("manifest.mf" :: Nil) => MergeStrategy.discard
|
|
||||||
case _ => MergeStrategy.discard
|
|
||||||
}
|
|
||||||
case x => MergeStrategy.first
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.settings(
|
|
||||||
sourcesInBase := false,
|
|
||||||
organization := Organization,
|
|
||||||
name := Name,
|
|
||||||
version := Version,
|
|
||||||
scalaVersion := ScalaVersion,
|
|
||||||
resolvers ++= Seq(
|
|
||||||
Classpaths.typesafeReleases,
|
|
||||||
"amateras-repo" at "http://amateras.sourceforge.jp/mvn/",
|
|
||||||
"amateras-snapshot-repo" at "http://amateras.sourceforge.jp/mvn-snapshot/"
|
|
||||||
),
|
|
||||||
scalacOptions := Seq("-deprecation", "-language:postfixOps"),
|
|
||||||
libraryDependencies ++= Seq(
|
|
||||||
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % "3.4.2.201412180340-r",
|
|
||||||
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % "3.4.2.201412180340-r",
|
|
||||||
"org.scalatra" %% "scalatra" % ScalatraVersion,
|
|
||||||
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
|
|
||||||
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
|
|
||||||
"org.json4s" %% "json4s-jackson" % "3.2.11",
|
|
||||||
"jp.sf.amateras" %% "scalatra-forms" % "0.1.0",
|
|
||||||
"commons-io" % "commons-io" % "2.4",
|
|
||||||
"io.github.gitbucket" % "markedj" % "1.0.4-SNAPSHOT",
|
|
||||||
"org.apache.commons" % "commons-compress" % "1.9",
|
|
||||||
"org.apache.commons" % "commons-email" % "1.3.3",
|
|
||||||
"org.apache.httpcomponents" % "httpclient" % "4.3.6",
|
|
||||||
"org.apache.sshd" % "apache-sshd" % "0.11.0",
|
|
||||||
"org.apache.tika" % "tika-core" % "1.10",
|
|
||||||
"com.typesafe.slick" %% "slick" % "2.1.0",
|
|
||||||
"com.novell.ldap" % "jldap" % "2009-10-07",
|
|
||||||
"com.h2database" % "h2" % "1.4.180",
|
|
||||||
// "ch.qos.logback" % "logback-classic" % "1.0.13" % "runtime",
|
|
||||||
"org.eclipse.jetty" % "jetty-webapp" % "8.1.16.v20140903" % "container;provided",
|
|
||||||
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts Artifact("javax.servlet", "jar", "jar"),
|
|
||||||
"junit" % "junit" % "4.12" % "test",
|
|
||||||
"com.mchange" % "c3p0" % "0.9.5",
|
|
||||||
"com.typesafe" % "config" % "1.2.1",
|
|
||||||
"com.typesafe.akka" %% "akka-actor" % "2.3.10",
|
|
||||||
"com.enragedginger" %% "akka-quartz-scheduler" % "1.3.0-akka-2.3.x" exclude("c3p0","c3p0")
|
|
||||||
),
|
|
||||||
play.twirl.sbt.Import.TwirlKeys.templateImports += "gitbucket.core._",
|
|
||||||
EclipseKeys.withSource := true,
|
|
||||||
javacOptions in compile ++= Seq("-target", "7", "-source", "7"),
|
|
||||||
testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "junitxml", "console"),
|
|
||||||
javaOptions in Test += "-Dgitbucket.home=target/gitbucket_home_for_test",
|
|
||||||
testOptions in Test += Tests.Setup( () => new java.io.File("target/gitbucket_home_for_test").mkdir() ),
|
|
||||||
fork in Test := true,
|
|
||||||
packageOptions += Package.MainClass("JettyLauncher")
|
|
||||||
).enablePlugins(SbtTwirl)
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
|
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
|
||||||
|
|
||||||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")
|
|
||||||
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
|
|
||||||
addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.3.5")
|
|
||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.4")
|
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.4")
|
||||||
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.8")
|
|
||||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
|
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
|
||||||
|
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "2.1.0")
|
||||||
|
addSbtPlugin("fi.gekkio.sbtplugins" % "sbt-jrebel-plugin" % "0.10.0")
|
||||||
|
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")
|
||||||
|
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15")
|
||||||
|
|||||||
1
project/project/plugins.sbt
Normal file
1
project/project/plugins.sbt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15")
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<project name="gitbucket" default="all" basedir="..">
|
|
||||||
|
|
||||||
<property environment="env"/>
|
|
||||||
<property name="target.dir" value="target"/>
|
|
||||||
<property name="embed.classes.dir" value="${target.dir}/embed-classes"/>
|
|
||||||
<property name="jetty.dir" value="embed-jetty"/>
|
|
||||||
<property name="scala.version" value="2.11"/>
|
|
||||||
<property name="gitbucket.version" value="${env.GITBUCKET_VERSION}"/>
|
|
||||||
<property name="jetty.version" value="8.1.16.v20140903"/>
|
|
||||||
<property name="servlet.version" value="3.0.0.v201112011016"/>
|
|
||||||
|
|
||||||
<condition property="sbt.exec" value="sbt.bat" else="sbt.sh">
|
|
||||||
<os family="windows" />
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<target name="clean">
|
|
||||||
<delete dir="${embed.classes.dir}"/>
|
|
||||||
<delete file="${target.dir}/scala-${scala.version}/gitbucket.war"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="war" depends="clean">
|
|
||||||
<exec executable="${sbt.exec}" resolveexecutable="true" failonerror="true">
|
|
||||||
<arg line="clean compile test package" />
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="embed" depends="war">
|
|
||||||
<mkdir dir="${embed.classes.dir}"/>
|
|
||||||
|
|
||||||
<unzip dest="${embed.classes.dir}" src="${jetty.dir}/javax.servlet-${servlet.version}.jar" />
|
|
||||||
<unzip dest="${embed.classes.dir}" src="${jetty.dir}/jetty-continuation-${jetty.version}.jar" />
|
|
||||||
<unzip dest="${embed.classes.dir}" src="${jetty.dir}/jetty-http-${jetty.version}.jar" />
|
|
||||||
<unzip dest="${embed.classes.dir}" src="${jetty.dir}/jetty-io-${jetty.version}.jar" />
|
|
||||||
<unzip dest="${embed.classes.dir}" src="${jetty.dir}/jetty-security-${jetty.version}.jar" />
|
|
||||||
<unzip dest="${embed.classes.dir}" src="${jetty.dir}/jetty-server-${jetty.version}.jar" />
|
|
||||||
<unzip dest="${embed.classes.dir}" src="${jetty.dir}/jetty-servlet-${jetty.version}.jar" />
|
|
||||||
<unzip dest="${embed.classes.dir}" src="${jetty.dir}/jetty-util-${jetty.version}.jar" />
|
|
||||||
<unzip dest="${embed.classes.dir}" src="${jetty.dir}/jetty-webapp-${jetty.version}.jar" />
|
|
||||||
<unzip dest="${embed.classes.dir}" src="${jetty.dir}/jetty-xml-${jetty.version}.jar" />
|
|
||||||
|
|
||||||
<zip destfile="${target.dir}/scala-${scala.version}/gitbucket_${scala.version}-${gitbucket.version}.war"
|
|
||||||
basedir="${embed.classes.dir}"
|
|
||||||
update = "true"
|
|
||||||
includes="javax/**,org/**"/>
|
|
||||||
|
|
||||||
<zip destfile="${target.dir}/scala-${scala.version}/gitbucket_${scala.version}-${gitbucket.version}.war"
|
|
||||||
basedir="${target.dir}/scala-${scala.version}/classes"
|
|
||||||
update = "true"
|
|
||||||
includes="JettyLauncher.class,HttpsSupportConnector.class"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="rename" depends="embed">
|
|
||||||
<move file="${target.dir}/scala-${scala.version}/gitbucket_${scala.version}-${gitbucket.version}.war"
|
|
||||||
tofile="${target.dir}/scala-${scala.version}/gitbucket.war"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="checksum" depends="rename">
|
|
||||||
<checksum file="${target.dir}/scala-${scala.version}/gitbucket.war" algorithm="MD5" format="MD5SUM" forceOverwrite="yes" fileext=".md5"/>
|
|
||||||
<checksum file="${target.dir}/scala-${scala.version}/gitbucket.war" algorithm="SHA" format="MD5SUM" forceOverwrite="yes" fileext=".sha1"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="all" depends="checksum">
|
|
||||||
</target>
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
. ./env.sh
|
|
||||||
|
|
||||||
cd ../
|
|
||||||
./sbt.sh clean assembly
|
|
||||||
|
|
||||||
cd release
|
|
||||||
mvn deploy:deploy-file \
|
|
||||||
-DgroupId=gitbucket\
|
|
||||||
-DartifactId=gitbucket-assembly\
|
|
||||||
-Dversion=$GITBUCKET_VERSION\
|
|
||||||
-Dpackaging=jar\
|
|
||||||
-Dfile=../target/scala-2.11/gitbucket-assembly-$GITBUCKET_VERSION.jar\
|
|
||||||
-DrepositoryId=sourceforge.jp\
|
|
||||||
-Durl=scp://shell.sourceforge.jp/home/groups/a/am/amateras/htdocs/mvn/
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
export GITBUCKET_VERSION=`cat ../project/build.scala | grep 'val Version' | cut -d \" -f 2`
|
|
||||||
echo "GITBUCKET_VERSION: $GITBUCKET_VERSION"
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
D="$(dirname "$0")"
|
|
||||||
D="$(cd "${D}"; pwd)"
|
|
||||||
DD="$(dirname "${D}")"
|
|
||||||
(
|
|
||||||
for f in "${D}/env.sh" "${D}/build.xml"; do
|
|
||||||
if [ ! -s "${f}" ]; then
|
|
||||||
echo >&2 "$0: Unable to access file '${f}'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
. "${D}/env.sh"
|
|
||||||
cd "${DD}"
|
|
||||||
ant -f "${D}/build.xml" all
|
|
||||||
)
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>jp.sf.amateras</groupId>
|
|
||||||
<artifactId>gitbucket-assembly</artifactId>
|
|
||||||
<version>0.0.1</version>
|
|
||||||
<build>
|
|
||||||
<extensions>
|
|
||||||
<extension>
|
|
||||||
<groupId>org.apache.maven.wagon</groupId>
|
|
||||||
<artifactId>wagon-ssh</artifactId>
|
|
||||||
<version>1.0-beta-6</version>
|
|
||||||
</extension>
|
|
||||||
</extensions>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
Binary file not shown.
2
sbt.bat
2
sbt.bat
@@ -1,2 +1,2 @@
|
|||||||
set SCRIPT_DIR=%~dp0
|
set SCRIPT_DIR=%~dp0
|
||||||
java %JAVA_OPTS% -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar "%SCRIPT_DIR%\sbt-launch-0.13.8.jar" %*
|
java %JAVA_OPTS% -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar "%SCRIPT_DIR%\sbt-launch-0.13.12.jar" %*
|
||||||
|
|||||||
2
sbt.sh
2
sbt.sh
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
java $JAVA_OPTS -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar `dirname $0`/sbt-launch-0.13.8.jar "$@"
|
java $JAVA_OPTS -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar `dirname $0`/sbt-launch-0.13.12.jar "$@"
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.security.ProtectionDomain;
|
import java.security.ProtectionDomain;
|
||||||
|
|
||||||
public class JettyLauncher {
|
public class JettyLauncher {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
String host = null;
|
String host = null;
|
||||||
int port = 8080;
|
int port = 8080;
|
||||||
|
InetSocketAddress address = null;
|
||||||
String contextPath = "/";
|
String contextPath = "/";
|
||||||
|
String tmpDirPath="";
|
||||||
boolean forceHttps = false;
|
boolean forceHttps = false;
|
||||||
|
|
||||||
for(String arg: args) {
|
for(String arg: args) {
|
||||||
@@ -23,31 +25,53 @@ public class JettyLauncher {
|
|||||||
port = Integer.parseInt(dim[1]);
|
port = Integer.parseInt(dim[1]);
|
||||||
} else if(dim[0].equals("--prefix")) {
|
} else if(dim[0].equals("--prefix")) {
|
||||||
contextPath = dim[1];
|
contextPath = dim[1];
|
||||||
|
if(!contextPath.startsWith("/")){
|
||||||
|
contextPath = "/" + contextPath;
|
||||||
|
}
|
||||||
} else if(dim[0].equals("--gitbucket.home")){
|
} else if(dim[0].equals("--gitbucket.home")){
|
||||||
System.setProperty("gitbucket.home", dim[1]);
|
System.setProperty("gitbucket.home", dim[1]);
|
||||||
|
} else if(dim[0].equals("--temp_dir")){
|
||||||
|
tmpDirPath = dim[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Server server = new Server();
|
|
||||||
|
|
||||||
SelectChannelConnector connector = new SelectChannelConnector();
|
|
||||||
if(host != null) {
|
if(host != null) {
|
||||||
connector.setHost(host);
|
address = new InetSocketAddress(host, port);
|
||||||
|
} else {
|
||||||
|
address = new InetSocketAddress(port);
|
||||||
}
|
}
|
||||||
connector.setMaxIdleTime(1000 * 60 * 60);
|
|
||||||
connector.setSoLingerTime(-1);
|
Server server = new Server(address);
|
||||||
connector.setPort(port);
|
|
||||||
server.addConnector(connector);
|
// SelectChannelConnector connector = new SelectChannelConnector();
|
||||||
|
// if(host != null) {
|
||||||
|
// connector.setHost(host);
|
||||||
|
// }
|
||||||
|
// connector.setMaxIdleTime(1000 * 60 * 60);
|
||||||
|
// connector.setSoLingerTime(-1);
|
||||||
|
// connector.setPort(port);
|
||||||
|
// server.addConnector(connector);
|
||||||
|
|
||||||
WebAppContext context = new WebAppContext();
|
WebAppContext context = new WebAppContext();
|
||||||
|
|
||||||
File tmpDir = new File(getGitBucketHome(), "tmp");
|
File tmpDir;
|
||||||
if(tmpDir.exists()){
|
if(tmpDirPath.equals("")){
|
||||||
deleteDirectory(tmpDir);
|
tmpDir = new File(getGitBucketHome(), "tmp");
|
||||||
}
|
if(!tmpDir.exists()){
|
||||||
tmpDir.mkdirs();
|
tmpDir.mkdirs();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tmpDir = new File(tmpDirPath);
|
||||||
|
if(!tmpDir.exists()){
|
||||||
|
throw new java.io.FileNotFoundException(
|
||||||
|
String.format("temp_dir \"%s\" not found", tmpDirPath));
|
||||||
|
} else if(!tmpDir.isDirectory()) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("temp_dir \"%s\" is not a directory", tmpDirPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
context.setTempDirectory(tmpDir);
|
context.setTempDirectory(tmpDir);
|
||||||
|
|
||||||
ProtectionDomain domain = JettyLauncher.class.getProtectionDomain();
|
ProtectionDomain domain = JettyLauncher.class.getProtectionDomain();
|
||||||
@@ -62,6 +86,8 @@ public class JettyLauncher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server.setHandler(context);
|
server.setHandler(context);
|
||||||
|
server.setStopAtShutdown(true);
|
||||||
|
server.setStopTimeout(7_000);
|
||||||
server.start();
|
server.start();
|
||||||
server.join();
|
server.join();
|
||||||
}
|
}
|
||||||
|
|||||||
52
src/main/java/org/postgresql/Driver2.java
Normal file
52
src/main/java/org/postgresql/Driver2.java
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package org.postgresql;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationHandler;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Proxy;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps the PostgreSQL JDBC driver to convert the returning column names to lower case.
|
||||||
|
*/
|
||||||
|
public class Driver2 extends Driver {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public java.sql.Connection connect(String url, Properties info) throws SQLException {
|
||||||
|
Connection conn = super.connect(url, info);
|
||||||
|
|
||||||
|
Object proxy = Proxy.newProxyInstance(
|
||||||
|
conn.getClass().getClassLoader(),
|
||||||
|
new Class[]{ Connection.class },
|
||||||
|
new ConnectionProxyHandler(conn)
|
||||||
|
);
|
||||||
|
|
||||||
|
return Connection.class.cast(proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static class ConnectionProxyHandler implements InvocationHandler {
|
||||||
|
|
||||||
|
private Connection conn;
|
||||||
|
|
||||||
|
public ConnectionProxyHandler(Connection conn){
|
||||||
|
this.conn = conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
|
if(method.getName().equals("prepareStatement")){
|
||||||
|
if(args != null && args.length == 2 && args[1].getClass().isArray()){
|
||||||
|
String[] keys = (String[]) args[1];
|
||||||
|
for(int i = 0; i < keys.length; i++){
|
||||||
|
keys[i] = keys[i].toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return method.invoke(conn, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
db {
|
|
||||||
driver = "org.h2.Driver"
|
|
||||||
url = "jdbc:h2:${DatabaseHome};MVCC=true"
|
|
||||||
user = "sa"
|
|
||||||
password = "sa"
|
|
||||||
}
|
|
||||||
26
src/main/resources/logback-dev.xml
Normal file
26
src/main/resources/logback-dev.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
|
<file>gitbucket.log</file>
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<logger name="service.WebHookService" level="DEBUG" />
|
||||||
|
<logger name="servlet" level="DEBUG" />
|
||||||
|
<logger name="scala.slick.jdbc.JdbcBackend.statement" level="DEBUG" />
|
||||||
|
-->
|
||||||
|
|
||||||
|
</configuration>
|
||||||
@@ -6,6 +6,15 @@
|
|||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
|
<file>gitbucket.log</file>
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
-->
|
||||||
|
|
||||||
<root level="INFO">
|
<root level="INFO">
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
</root>
|
</root>
|
||||||
@@ -13,5 +22,7 @@
|
|||||||
<!--
|
<!--
|
||||||
<logger name="service.WebHookService" level="DEBUG" />
|
<logger name="service.WebHookService" level="DEBUG" />
|
||||||
<logger name="servlet" level="DEBUG" />
|
<logger name="servlet" level="DEBUG" />
|
||||||
|
<logger name="scala.slick.jdbc.JdbcBackend.statement" level="DEBUG" />
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
CREATE TABLE ACCOUNT(
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
MAIL_ADDRESS VARCHAR(100) NOT NULL,
|
|
||||||
PASSWORD VARCHAR(40) NOT NULL,
|
|
||||||
ADMINISTRATOR BOOLEAN NOT NULL,
|
|
||||||
URL VARCHAR(200),
|
|
||||||
REGISTERED_DATE TIMESTAMP NOT NULL,
|
|
||||||
UPDATED_DATE TIMESTAMP NOT NULL,
|
|
||||||
LAST_LOGIN_DATE TIMESTAMP
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE REPOSITORY(
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
PRIVATE BOOLEAN NOT NULL,
|
|
||||||
DESCRIPTION TEXT,
|
|
||||||
DEFAULT_BRANCH VARCHAR(100),
|
|
||||||
REGISTERED_DATE TIMESTAMP NOT NULL,
|
|
||||||
UPDATED_DATE TIMESTAMP NOT NULL,
|
|
||||||
LAST_ACTIVITY_DATE TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE COLLABORATOR(
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
COLLABORATOR_NAME VARCHAR(100) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE ISSUE(
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
ISSUE_ID INT NOT NULL,
|
|
||||||
OPENED_USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
MILESTONE_ID INT,
|
|
||||||
ASSIGNED_USER_NAME VARCHAR(100),
|
|
||||||
TITLE TEXT NOT NULL,
|
|
||||||
CONTENT TEXT,
|
|
||||||
CLOSED BOOLEAN NOT NULL,
|
|
||||||
REGISTERED_DATE TIMESTAMP NOT NULL,
|
|
||||||
UPDATED_DATE TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE ISSUE_ID(
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
ISSUE_ID INT NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE ISSUE_COMMENT(
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
ISSUE_ID INT NOT NULL,
|
|
||||||
COMMENT_ID INT AUTO_INCREMENT,
|
|
||||||
ACTION VARCHAR(10),
|
|
||||||
COMMENTED_USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
CONTENT TEXT NOT NULL,
|
|
||||||
REGISTERED_DATE TIMESTAMP NOT NULL,
|
|
||||||
UPDATED_DATE TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE LABEL(
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
LABEL_ID INT AUTO_INCREMENT,
|
|
||||||
LABEL_NAME VARCHAR(100) NOT NULL,
|
|
||||||
COLOR CHAR(6) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE ISSUE_LABEL(
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
ISSUE_ID INT NOT NULL,
|
|
||||||
LABEL_ID INT NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE MILESTONE(
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
MILESTONE_ID INT AUTO_INCREMENT,
|
|
||||||
TITLE VARCHAR(100) NOT NULL,
|
|
||||||
DESCRIPTION TEXT,
|
|
||||||
DUE_DATE TIMESTAMP,
|
|
||||||
CLOSED_DATE TIMESTAMP
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE ACCOUNT ADD CONSTRAINT IDX_ACCOUNT_PK PRIMARY KEY (USER_NAME);
|
|
||||||
ALTER TABLE ACCOUNT ADD CONSTRAINT IDX_ACCOUNT_1 UNIQUE (MAIL_ADDRESS);
|
|
||||||
|
|
||||||
ALTER TABLE REPOSITORY ADD CONSTRAINT IDX_REPOSITORY_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
ALTER TABLE REPOSITORY ADD CONSTRAINT IDX_REPOSITORY_FK0 FOREIGN KEY (USER_NAME) REFERENCES ACCOUNT (USER_NAME);
|
|
||||||
|
|
||||||
ALTER TABLE COLLABORATOR ADD CONSTRAINT IDX_COLLABORATOR_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
ALTER TABLE COLLABORATOR ADD CONSTRAINT IDX_COLLABORATOR_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
ALTER TABLE COLLABORATOR ADD CONSTRAINT IDX_COLLABORATOR_FK1 FOREIGN KEY (COLLABORATOR_NAME) REFERENCES ACCOUNT (USER_NAME);
|
|
||||||
|
|
||||||
ALTER TABLE ISSUE ADD CONSTRAINT IDX_ISSUE_PK PRIMARY KEY (ISSUE_ID, USER_NAME, REPOSITORY_NAME);
|
|
||||||
ALTER TABLE ISSUE ADD CONSTRAINT IDX_ISSUE_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
ALTER TABLE ISSUE ADD CONSTRAINT IDX_ISSUE_FK1 FOREIGN KEY (OPENED_USER_NAME) REFERENCES ACCOUNT (USER_NAME);
|
|
||||||
ALTER TABLE ISSUE ADD CONSTRAINT IDX_ISSUE_FK2 FOREIGN KEY (MILESTONE_ID) REFERENCES MILESTONE (MILESTONE_ID);
|
|
||||||
|
|
||||||
ALTER TABLE ISSUE_ID ADD CONSTRAINT IDX_ISSUE_ID_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
ALTER TABLE ISSUE_ID ADD CONSTRAINT IDX_ISSUE_ID_FK1 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
|
|
||||||
ALTER TABLE ISSUE_COMMENT ADD CONSTRAINT IDX_ISSUE_COMMENT_PK PRIMARY KEY (COMMENT_ID);
|
|
||||||
ALTER TABLE ISSUE_COMMENT ADD CONSTRAINT IDX_ISSUE_COMMENT_1 UNIQUE (USER_NAME, REPOSITORY_NAME, ISSUE_ID, COMMENT_ID);
|
|
||||||
ALTER TABLE ISSUE_COMMENT ADD CONSTRAINT IDX_ISSUE_COMMENT_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID) REFERENCES ISSUE (USER_NAME, REPOSITORY_NAME, ISSUE_ID);
|
|
||||||
|
|
||||||
ALTER TABLE LABEL ADD CONSTRAINT IDX_LABEL_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, LABEL_ID);
|
|
||||||
ALTER TABLE LABEL ADD CONSTRAINT IDX_LABEL_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
|
|
||||||
ALTER TABLE ISSUE_LABEL ADD CONSTRAINT IDX_ISSUE_LABEL_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID, LABEL_ID);
|
|
||||||
ALTER TABLE ISSUE_LABEL ADD CONSTRAINT IDX_ISSUE_LABEL_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID) REFERENCES ISSUE (USER_NAME, REPOSITORY_NAME, ISSUE_ID);
|
|
||||||
|
|
||||||
ALTER TABLE MILESTONE ADD CONSTRAINT IDX_MILESTONE_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, MILESTONE_ID);
|
|
||||||
ALTER TABLE MILESTONE ADD CONSTRAINT IDX_MILESTONE_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
|
|
||||||
INSERT INTO ACCOUNT (
|
|
||||||
USER_NAME,
|
|
||||||
MAIL_ADDRESS,
|
|
||||||
PASSWORD,
|
|
||||||
ADMINISTRATOR,
|
|
||||||
URL,
|
|
||||||
REGISTERED_DATE,
|
|
||||||
UPDATED_DATE,
|
|
||||||
LAST_LOGIN_DATE
|
|
||||||
) VALUES (
|
|
||||||
'root',
|
|
||||||
'root@localhost',
|
|
||||||
'dc76e9f0c0006e8f919e0c515c66dbba3982f785',
|
|
||||||
true,
|
|
||||||
'https://github.com/gitbucket/gitbucket',
|
|
||||||
SYSDATE,
|
|
||||||
SYSDATE,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
-- Fix COLLABORATOR constraints
|
|
||||||
ALTER TABLE COLLABORATOR DROP CONSTRAINT IDX_COLLABORATOR_FK1 IF EXISTS;
|
|
||||||
ALTER TABLE COLLABORATOR DROP CONSTRAINT IDX_COLLABORATOR_FK0 IF EXISTS;
|
|
||||||
ALTER TABLE COLLABORATOR DROP CONSTRAINT IDX_COLLABORATOR_PK IF EXISTS;
|
|
||||||
|
|
||||||
ALTER TABLE COLLABORATOR ADD CONSTRAINT IDX_COLLABORATOR_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, COLLABORATOR_NAME);
|
|
||||||
ALTER TABLE COLLABORATOR ADD CONSTRAINT IDX_COLLABORATOR_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
ALTER TABLE COLLABORATOR ADD CONSTRAINT IDX_COLLABORATOR_FK1 FOREIGN KEY (COLLABORATOR_NAME) REFERENCES ACCOUNT (USER_NAME);
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
ALTER TABLE GROUP_MEMBER ADD COLUMN MANAGER BOOLEAN DEFAULT FALSE;
|
|
||||||
|
|
||||||
CREATE TABLE SSH_KEY (
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
SSH_KEY_ID INT AUTO_INCREMENT,
|
|
||||||
TITLE VARCHAR(100) NOT NULL,
|
|
||||||
PUBLIC_KEY TEXT NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE SSH_KEY ADD CONSTRAINT IDX_SSH_KEY_PK PRIMARY KEY (USER_NAME, SSH_KEY_ID);
|
|
||||||
ALTER TABLE SSH_KEY ADD CONSTRAINT IDX_SSH_KEY_FK0 FOREIGN KEY (USER_NAME) REFERENCES ACCOUNT (USER_NAME);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
DROP TABLE COMMIT_LOG;
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
CREATE TABLE ACTIVITY(
|
|
||||||
ACTIVITY_ID INT AUTO_INCREMENT,
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
ACTIVITY_USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
ACTIVITY_TYPE VARCHAR(100) NOT NULL,
|
|
||||||
MESSAGE TEXT NOT NULL,
|
|
||||||
ADDITIONAL_INFO TEXT,
|
|
||||||
ACTIVITY_DATE TIMESTAMP NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE COMMIT_LOG (
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
COMMIT_ID VARCHAR(40) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE ACTIVITY ADD CONSTRAINT IDX_ACTIVITY_PK PRIMARY KEY (ACTIVITY_ID);
|
|
||||||
ALTER TABLE ACTIVITY ADD CONSTRAINT IDX_ACTIVITY_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
ALTER TABLE ACTIVITY ADD CONSTRAINT IDX_ACTIVITY_FK1 FOREIGN KEY (ACTIVITY_USER_NAME) REFERENCES ACCOUNT (USER_NAME);
|
|
||||||
|
|
||||||
ALTER TABLE COMMIT_LOG ADD CONSTRAINT IDX_COMMIT_LOG_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, COMMIT_ID);
|
|
||||||
ALTER TABLE COMMIT_LOG ADD CONSTRAINT IDX_COMMIT_LOG_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
ALTER TABLE ACCOUNT ADD COLUMN IMAGE VARCHAR(100);
|
|
||||||
|
|
||||||
UPDATE ISSUE_COMMENT SET ACTION = 'comment' WHERE ACTION IS NULL;
|
|
||||||
|
|
||||||
ALTER TABLE ISSUE_COMMENT ALTER COLUMN ACTION VARCHAR(20) NOT NULL;
|
|
||||||
|
|
||||||
UPDATE ISSUE_COMMENT SET ACTION = 'close_comment' WHERE ACTION = 'close';
|
|
||||||
UPDATE ISSUE_COMMENT SET ACTION = 'reopen_comment' WHERE ACTION = 'reopen';
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
CREATE TABLE GROUP_MEMBER(
|
|
||||||
GROUP_NAME VARCHAR(100) NOT NULL,
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE GROUP_MEMBER ADD CONSTRAINT IDX_GROUP_MEMBER_PK PRIMARY KEY (GROUP_NAME, USER_NAME);
|
|
||||||
ALTER TABLE GROUP_MEMBER ADD CONSTRAINT IDX_GROUP_MEMBER_FK0 FOREIGN KEY (GROUP_NAME) REFERENCES ACCOUNT (USER_NAME);
|
|
||||||
ALTER TABLE GROUP_MEMBER ADD CONSTRAINT IDX_GROUP_MEMBER_FK1 FOREIGN KEY (USER_NAME) REFERENCES ACCOUNT (USER_NAME);
|
|
||||||
|
|
||||||
ALTER TABLE ACCOUNT ADD COLUMN GROUP_ACCOUNT BOOLEAN NOT NULL DEFAULT FALSE;
|
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW ISSUE_OUTLINE_VIEW AS
|
|
||||||
SELECT
|
|
||||||
A.USER_NAME,
|
|
||||||
A.REPOSITORY_NAME,
|
|
||||||
A.ISSUE_ID,
|
|
||||||
NVL(B.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);
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
ALTER TABLE REPOSITORY ADD COLUMN ORIGIN_USER_NAME VARCHAR(100);
|
|
||||||
ALTER TABLE REPOSITORY ADD COLUMN ORIGIN_REPOSITORY_NAME VARCHAR(100);
|
|
||||||
ALTER TABLE REPOSITORY ADD COLUMN PARENT_USER_NAME VARCHAR(100);
|
|
||||||
ALTER TABLE REPOSITORY ADD COLUMN PARENT_REPOSITORY_NAME VARCHAR(100);
|
|
||||||
|
|
||||||
CREATE TABLE PULL_REQUEST(
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
ISSUE_ID INT NOT NULL,
|
|
||||||
BRANCH VARCHAR(100) NOT NULL,
|
|
||||||
REQUEST_USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REQUEST_REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REQUEST_BRANCH VARCHAR(100) NOT NULL,
|
|
||||||
COMMIT_ID_FROM VARCHAR(40) NOT NULL,
|
|
||||||
COMMIT_ID_TO VARCHAR(40) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE PULL_REQUEST ADD CONSTRAINT IDX_PULL_REQUEST_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID);
|
|
||||||
ALTER TABLE PULL_REQUEST ADD CONSTRAINT IDX_PULL_REQUEST_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME, ISSUE_ID) REFERENCES ISSUE (USER_NAME, REPOSITORY_NAME, ISSUE_ID);
|
|
||||||
|
|
||||||
ALTER TABLE ISSUE ADD COLUMN PULL_REQUEST BOOLEAN NOT NULL DEFAULT FALSE;
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
CREATE TABLE WEB_HOOK (
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
URL VARCHAR(200) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE WEB_HOOK ADD CONSTRAINT IDX_WEB_HOOK_PK PRIMARY KEY (USER_NAME, REPOSITORY_NAME, URL);
|
|
||||||
ALTER TABLE WEB_HOOK ADD CONSTRAINT IDX_WEB_HOOK_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
ALTER TABLE ACCOUNT ADD COLUMN FULL_NAME VARCHAR(100);
|
|
||||||
|
|
||||||
UPDATE ACCOUNT SET FULL_NAME = USER_NAME WHERE FULL_NAME IS NULL;
|
|
||||||
|
|
||||||
ALTER TABLE ACCOUNT ALTER COLUMN FULL_NAME SET NOT NULL;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
ALTER TABLE ACCOUNT ADD COLUMN REMOVED BOOLEAN DEFAULT FALSE;
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
CREATE TABLE PLUGIN (
|
|
||||||
PLUGIN_ID VARCHAR(100) NOT NULL,
|
|
||||||
VERSION VARCHAR(100) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE PLUGIN ADD CONSTRAINT IDX_PLUGIN_PK PRIMARY KEY (PLUGIN_ID);
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
CREATE TABLE COMMIT_COMMENT (
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
COMMIT_ID VARCHAR(100) NOT NULL,
|
|
||||||
COMMENT_ID INT AUTO_INCREMENT,
|
|
||||||
COMMENTED_USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
CONTENT TEXT NOT NULL,
|
|
||||||
FILE_NAME NVARCHAR(100),
|
|
||||||
OLD_LINE_NUMBER INT,
|
|
||||||
NEW_LINE_NUMBER INT,
|
|
||||||
REGISTERED_DATE TIMESTAMP NOT NULL,
|
|
||||||
UPDATED_DATE TIMESTAMP NOT NULL,
|
|
||||||
PULL_REQUEST BOOLEAN NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE COMMIT_COMMENT ADD CONSTRAINT IDX_COMMIT_COMMENT_PK PRIMARY KEY (COMMENT_ID);
|
|
||||||
ALTER TABLE COMMIT_COMMENT ADD CONSTRAINT IDX_COMMIT_COMMENT_FK0 FOREIGN KEY (USER_NAME, REPOSITORY_NAME) REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME);
|
|
||||||
ALTER TABLE COMMIT_COMMENT ADD CONSTRAINT IDX_COMMIT_COMMENT_1 UNIQUE (USER_NAME, REPOSITORY_NAME, COMMIT_ID, COMMENT_ID);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
ALTER TABLE COMMIT_COMMENT ALTER COLUMN FILE_NAME NVARCHAR(260);
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
DROP TABLE IF EXISTS ACCESS_TOKEN;
|
|
||||||
|
|
||||||
CREATE TABLE ACCESS_TOKEN (
|
|
||||||
ACCESS_TOKEN_ID INT NOT NULL AUTO_INCREMENT,
|
|
||||||
TOKEN_HASH VARCHAR(40) NOT NULL,
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
NOTE TEXT NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE ACCESS_TOKEN ADD CONSTRAINT IDX_ACCESS_TOKEN_PK PRIMARY KEY (ACCESS_TOKEN_ID);
|
|
||||||
ALTER TABLE ACCESS_TOKEN ADD CONSTRAINT IDX_ACCESS_TOKEN_FK0 FOREIGN KEY (USER_NAME) REFERENCES ACCOUNT (USER_NAME)
|
|
||||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
ALTER TABLE ACCESS_TOKEN ADD CONSTRAINT IDX_ACCESS_TOKEN_TOKEN_HASH UNIQUE(TOKEN_HASH);
|
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS COMMIT_STATUS;
|
|
||||||
CREATE TABLE COMMIT_STATUS(
|
|
||||||
COMMIT_STATUS_ID INT AUTO_INCREMENT,
|
|
||||||
USER_NAME VARCHAR(100) NOT NULL,
|
|
||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
|
||||||
COMMIT_ID VARCHAR(40) NOT NULL,
|
|
||||||
CONTEXT VARCHAR(255) NOT NULL, -- context is too long (maximum is 255 characters)
|
|
||||||
STATE VARCHAR(10) NOT NULL, -- pending, success, error, or failure
|
|
||||||
TARGET_URL VARCHAR(200),
|
|
||||||
DESCRIPTION TEXT,
|
|
||||||
CREATOR VARCHAR(100) NOT NULL,
|
|
||||||
REGISTERED_DATE TIMESTAMP NOT NULL, -- CREATED_AT
|
|
||||||
UPDATED_DATE TIMESTAMP NOT NULL -- UPDATED_AT
|
|
||||||
);
|
|
||||||
ALTER TABLE COMMIT_STATUS ADD CONSTRAINT IDX_COMMIT_STATUS_PK PRIMARY KEY (COMMIT_STATUS_ID);
|
|
||||||
ALTER TABLE COMMIT_STATUS ADD CONSTRAINT IDX_COMMIT_STATUS_1
|
|
||||||
UNIQUE (USER_NAME, REPOSITORY_NAME, COMMIT_ID, CONTEXT);
|
|
||||||
ALTER TABLE COMMIT_STATUS ADD CONSTRAINT IDX_COMMIT_STATUS_FK1
|
|
||||||
FOREIGN KEY (USER_NAME, REPOSITORY_NAME)
|
|
||||||
REFERENCES REPOSITORY (USER_NAME, REPOSITORY_NAME)
|
|
||||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
ALTER TABLE COMMIT_STATUS ADD CONSTRAINT IDX_COMMIT_STATUS_FK2
|
|
||||||
FOREIGN KEY (USER_NAME) REFERENCES ACCOUNT (USER_NAME)
|
|
||||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
ALTER TABLE COMMIT_STATUS ADD CONSTRAINT IDX_COMMIT_STATUS_FK3
|
|
||||||
FOREIGN KEY (CREATOR) REFERENCES ACCOUNT (USER_NAME)
|
|
||||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
18
src/main/resources/update/gitbucket-core_4.0.sql
Normal file
18
src/main/resources/update/gitbucket-core_4.0.sql
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
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);
|
||||||
351
src/main/resources/update/gitbucket-core_4.0.xml
Normal file
351
src/main/resources/update/gitbucket-core_4.0.xml
Normal file
@@ -0,0 +1,351 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ACCOUNT -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ACCOUNT">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="MAIL_ADDRESS" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="PASSWORD" type="varchar(40)" nullable="false"/>
|
||||||
|
<column name="ADMINISTRATOR" type="boolean" nullable="false"/>
|
||||||
|
<column name="URL" type="varchar(200)" nullable="true"/>
|
||||||
|
<column name="REGISTERED_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="LAST_LOGIN_DATE" type="datetime" nullable="true"/>
|
||||||
|
<column name="IMAGE" type="varchar(100)" nullable="true"/>
|
||||||
|
<column name="GROUP_ACCOUNT" type="boolean" nullable="false"/>
|
||||||
|
<column name="FULL_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REMOVED" type="boolean" nullable="true"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_ACCOUNT_PK" tableName="ACCOUNT" columnNames="USER_NAME"/>
|
||||||
|
<addUniqueConstraint constraintName="IDX_ACCOUNT_1" tableName="ACCOUNT" columnNames="MAIL_ADDRESS"/>
|
||||||
|
|
||||||
|
<insert tableName="ACCOUNT">
|
||||||
|
<column name="USER_NAME" value="root"/>
|
||||||
|
<column name="FULL_NAME" value="root"/>
|
||||||
|
<column name="MAIL_ADDRESS" value="root@localhost"/>
|
||||||
|
<column name="PASSWORD" value="dc76e9f0c0006e8f919e0c515c66dbba3982f785"/>
|
||||||
|
<column name="ADMINISTRATOR" valueBoolean="true"/>
|
||||||
|
<column name="URL" value="https://github.com/gitbucket/gitbucket"/>
|
||||||
|
<column name="GROUP_ACCOUNT" valueBoolean="false"/>
|
||||||
|
<column name="REMOVED" valueBoolean="false"/>
|
||||||
|
<column name="REGISTERED_DATE" valueDate="${currentDateTime}"/>
|
||||||
|
<column name="UPDATED_DATE" valueDate="${currentDateTime}"/>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- REPOSITORY -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="REPOSITORY">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="PRIVATE" type="boolean" nullable="false"/>
|
||||||
|
<column name="DESCRIPTION" type="text" nullable="true"/>
|
||||||
|
<column name="DEFAULT_BRANCH" type="varchar(100)" nullable="true"/>
|
||||||
|
<column name="REGISTERED_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="LAST_ACTIVITY_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="ORIGIN_USER_NAME" type="varchar(100)" nullable="true"/>
|
||||||
|
<column name="ORIGIN_REPOSITORY_NAME" type="varchar(100)" nullable="true"/>
|
||||||
|
<column name="PARENT_USER_NAME" type="varchar(100)" nullable="true"/>
|
||||||
|
<column name="PARENT_REPOSITORY_NAME" type="varchar(100)" nullable="true"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_REPOSITORY_PK" tableName="REPOSITORY" columnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_REPOSITORY_FK0" baseTableName="REPOSITORY" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ACCESS_TOKEN -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ACCESS_TOKEN">
|
||||||
|
<column name="ACCESS_TOKEN_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="TOKEN_HASH" type="varchar(40)" nullable="false"/>
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="NOTE" type="text" nullable="false"/>
|
||||||
|
</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"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ACCESS_TOKEN_FK0" baseTableName="ACCESS_TOKEN" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ACTIVITY -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ACTIVITY">
|
||||||
|
<column name="ACTIVITY_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="USER_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_TYPE" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="MESSAGE" type="text" nullable="false"/>
|
||||||
|
<column name="ADDITIONAL_INFO" type="text" nullable="true"/>
|
||||||
|
<column name="ACTIVITY_DATE" type="datetime" nullable="false"/>
|
||||||
|
</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_FK0" baseTableName="ACTIVITY" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- COLLABORATOR -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="COLLABORATOR">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="COLLABORATOR_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_COLLABORATOR_PK" tableName="COLLABORATOR" columnNames="USER_NAME, REPOSITORY_NAME, COLLABORATOR_NAME"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_COLLABORATOR_FK1" baseTableName="COLLABORATOR" baseColumnNames="COLLABORATOR_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_COLLABORATOR_FK0" baseTableName="COLLABORATOR" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- COMMIT_COMMENT -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="COMMIT_COMMENT">
|
||||||
|
<column name="USER_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="COMMENT_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="COMMENTED_USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="CONTENT" type="text" nullable="false"/>
|
||||||
|
<column name="FILE_NAME" type="varchar(260)" nullable="true"/>
|
||||||
|
<column name="OLD_LINE_NUMBER" type="int" nullable="true"/>
|
||||||
|
<column name="NEW_LINE_NUMBER" type="int" nullable="true"/>
|
||||||
|
<column name="REGISTERED_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="ISSUE_ID" type="int" nullable="true"/>
|
||||||
|
</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"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- COMMIT_STATUS -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="COMMIT_STATUS">
|
||||||
|
<column name="COMMIT_STATUS_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="USER_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="CONTEXT" type="varchar(255)" nullable="false"/>
|
||||||
|
<column name="STATE" type="varchar(10)" nullable="false"/>
|
||||||
|
<column name="TARGET_URL" type="varchar(200)" nullable="true"/>
|
||||||
|
<column name="DESCRIPTION" type="text" nullable="true"/>
|
||||||
|
<column name="CREATOR" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REGISTERED_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
|
||||||
|
</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"/>
|
||||||
|
<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_FK1" baseTableName="COMMIT_STATUS" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- GROUP_MEMBER -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="GROUP_MEMBER">
|
||||||
|
<column name="GROUP_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="MANAGER" type="boolean" nullable="true"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_GROUP_MEMBER_PK" tableName="GROUP_MEMBER" columnNames="GROUP_NAME, USER_NAME"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_GROUP_MEMBER_FK1" baseTableName="GROUP_MEMBER" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_GROUP_MEMBER_FK0" baseTableName="GROUP_MEMBER" baseColumnNames="GROUP_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- LABEL -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="LABEL">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="LABEL_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="LABEL_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="COLOR" type="char(6)" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_LABEL_PK" tableName="LABEL" columnNames="USER_NAME, REPOSITORY_NAME, LABEL_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_LABEL_FK0" baseTableName="LABEL" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- MILESTONE -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="MILESTONE">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="MILESTONE_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="TITLE" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="DESCRIPTION" type="text" nullable="true"/>
|
||||||
|
<column name="DUE_DATE" type="datetime" nullable="true"/>
|
||||||
|
<column name="CLOSED_DATE" type="datetime" nullable="true"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_MILESTONE_PK" tableName="MILESTONE" columnNames="USER_NAME, REPOSITORY_NAME, MILESTONE_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_MILESTONE_FK0" baseTableName="MILESTONE" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ISSUE -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ISSUE">
|
||||||
|
<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="OPENED_USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="MILESTONE_ID" type="int" nullable="true"/>
|
||||||
|
<column name="ASSIGNED_USER_NAME" type="varchar(100)" nullable="true"/>
|
||||||
|
<column name="TITLE" type="text" nullable="false"/>
|
||||||
|
<column name="CONTENT" type="text" nullable="true"/>
|
||||||
|
<column name="CLOSED" type="boolean" nullable="false"/>
|
||||||
|
<column name="REGISTERED_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="PULL_REQUEST" type="boolean" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_ISSUE_PK" tableName="ISSUE" columnNames="ISSUE_ID, 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_FK1" baseTableName="ISSUE" baseColumnNames="OPENED_USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ISSUE_COMMENT -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ISSUE_COMMENT">
|
||||||
|
<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="COMMENT_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="ACTION" type="varchar(20)" nullable="false"/>
|
||||||
|
<column name="COMMENTED_USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="CONTENT" type="text" nullable="false"/>
|
||||||
|
<column name="REGISTERED_DATE" type="datetime" nullable="false"/>
|
||||||
|
<column name="UPDATED_DATE" type="datetime" nullable="false"/>
|
||||||
|
</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"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ISSUE_ID -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ISSUE_ID">
|
||||||
|
<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"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_ISSUE_ID_PK" tableName="ISSUE_ID" columnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_ID_FK1" baseTableName="ISSUE_ID" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ISSUE_ID -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ISSUE_LABEL">
|
||||||
|
<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="LABEL_ID" type="int" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_ISSUE_LABEL_PK" tableName="ISSUE_LABEL" columnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID, LABEL_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_LABEL_FK0" baseTableName="ISSUE_LABEL" baseColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID" referencedTableName="ISSUE" referencedColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- PLUGIN -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="PLUGIN">
|
||||||
|
<column name="PLUGIN_ID" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="VERSION" type="varchar(100)" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_PLUGIN_PK" tableName="PLUGIN" columnNames="PLUGIN_ID"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- PULL_REQUEST -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="PULL_REQUEST">
|
||||||
|
<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="BRANCH" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REQUEST_USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REQUEST_REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REQUEST_BRANCH" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="COMMIT_ID_FROM" type="varchar(40)" nullable="false"/>
|
||||||
|
<column name="COMMIT_ID_TO" type="varchar(40)" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_PULL_REQUEST_PK" tableName="PULL_REQUEST" columnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_PULL_REQUEST_FK0" baseTableName="PULL_REQUEST" baseColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID" referencedTableName="ISSUE" referencedColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- SSH_KEY -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="SSH_KEY">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="SSH_KEY_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="TITLE" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="PUBLIC_KEY" type="text" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_SSH_KEY_PK" tableName="SSH_KEY" columnNames="USER_NAME, SSH_KEY_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_SSH_KEY_FK0" baseTableName="SSH_KEY" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- WEB_HOOK -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="WEB_HOOK">
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_WEB_HOOK_PK" 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"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- WEB_HOOK_EVENT -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="WEB_HOOK_EVENT">
|
||||||
|
<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="EVENT" type="varchar(30)" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_WEB_HOOK_EVENT_PK" tableName="WEB_HOOK_EVENT" columnNames="USER_NAME, REPOSITORY_NAME, URL, EVENT"/>
|
||||||
|
<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"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- PROTECTED_BRANCH -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="PROTECTED_BRANCH">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="BRANCH" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="STATUS_CHECK_ADMIN" type="boolean" nullable="false" defaultValueBoolean="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey constraintName="IDX_PROTECTED_BRANCH_PK" tableName="PROTECTED_BRANCH" columnNames="USER_NAME, REPOSITORY_NAME, BRANCH"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_FK0" baseTableName="PROTECTED_BRANCH" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- PROTECTED_BRANCH_REQUIRE_CONTEXT -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="PROTECTED_BRANCH_REQUIRE_CONTEXT">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="BRANCH" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="CONTEXT" type="varchar(255)" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<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"/>
|
||||||
|
|
||||||
|
</changeSet>
|
||||||
10
src/main/resources/update/gitbucket-core_4.2.xml
Normal file
10
src/main/resources/update/gitbucket-core_4.2.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="REPOSITORY">
|
||||||
|
<column name="ENABLE_ISSUES" type="boolean" nullable="false" defaultValueBoolean="true"/>
|
||||||
|
<column name="EXTERNAL_ISSUES_URL" type="varchar(200)" nullable="true"/>
|
||||||
|
<column name="ENABLE_WIKI" type="boolean" nullable="false" defaultValueBoolean="true"/>
|
||||||
|
<column name="ALLOW_WIKI_EDITING" type="boolean" nullable="false" defaultValueBoolean="false"/>
|
||||||
|
<column name="EXTERNAL_WIKI_URL" type="varchar(200)" nullable="true"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
6
src/main/resources/update/gitbucket-core_4.6.xml
Normal file
6
src/main/resources/update/gitbucket-core_4.6.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="REPOSITORY">
|
||||||
|
<column name="ALLOW_FORK" type="boolean" nullable="false" defaultValueBoolean="true"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
2
src/main/resources/update/gitbucket-core_4.7.sql
Normal file
2
src/main/resources/update/gitbucket-core_4.7.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- DELETE COLLABORATORS IN GROUP REPOSITORIES
|
||||||
|
DELETE FROM COLLABORATOR WHERE USER_NAME IN (SELECT USER_NAME FROM ACCOUNT WHERE GROUP_ACCOUNT = TRUE)
|
||||||
33
src/main/resources/update/gitbucket-core_4.7.xml
Normal file
33
src/main/resources/update/gitbucket-core_4.7.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="COLLABORATOR">
|
||||||
|
<column name="ROLE" type="varchar(10)" nullable="false" defaultValue="ADMIN"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="REPOSITORY">
|
||||||
|
<column name="WIKI_OPTION" type="varchar(10)" nullable="false" defaultValue="DISABLE"/>
|
||||||
|
<column name="ISSUES_OPTION" type="varchar(10)" nullable="false" defaultValue="DISABLE"/>
|
||||||
|
</addColumn>
|
||||||
|
<update tableName="REPOSITORY">
|
||||||
|
<column name="WIKI_OPTION" value="DISABLE"/>
|
||||||
|
<where>ENABLE_WIKI = FALSE</where>
|
||||||
|
</update>
|
||||||
|
<update tableName="REPOSITORY">
|
||||||
|
<column name="WIKI_OPTION" value="PRIVATE"/>
|
||||||
|
<where>ENABLE_WIKI = TRUE AND ALLOW_WIKI_EDITING = FALSE</where>
|
||||||
|
</update>
|
||||||
|
<update tableName="REPOSITORY">
|
||||||
|
<column name="WIKI_OPTION" value="PUBLIC"/>
|
||||||
|
<where>ENABLE_WIKI = TRUE AND ALLOW_WIKI_EDITING = TRUE</where>
|
||||||
|
</update>
|
||||||
|
<update tableName="REPOSITORY">
|
||||||
|
<column name="ISSUES_OPTION" value="DISABLE"/>
|
||||||
|
<where>ENABLE_ISSUES = FALSE</where>
|
||||||
|
</update>
|
||||||
|
<update tableName="REPOSITORY">
|
||||||
|
<column name="ISSUES_OPTION" value="PUBLIC"/>
|
||||||
|
<where>ENABLE_ISSUES = TRUE</where>
|
||||||
|
</update>
|
||||||
|
<dropColumn tableName="REPOSITORY" columnName="ENABLE_WIKI"/>
|
||||||
|
<dropColumn tableName="REPOSITORY" columnName="ALLOW_WIKI_EDITING"/>
|
||||||
|
<dropColumn tableName="REPOSITORY" columnName="ENABLE_ISSUES"/>
|
||||||
|
</changeSet>
|
||||||
6
src/main/resources/update/gitbucket-core_4.9.xml
Normal file
6
src/main/resources/update/gitbucket-core_4.9.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="ACCOUNT">
|
||||||
|
<column name="DESCRIPTION" type="text" nullable="true" />
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
@@ -1,24 +1,33 @@
|
|||||||
|
|
||||||
import gitbucket.core.controller._
|
|
||||||
import gitbucket.core.plugin.PluginRegistry
|
|
||||||
import gitbucket.core.servlet.{AccessTokenAuthenticationFilter, BasicAuthenticationFilter, Database, TransactionFilter}
|
|
||||||
import gitbucket.core.util.Directory
|
|
||||||
|
|
||||||
import java.util.EnumSet
|
import java.util.EnumSet
|
||||||
import javax.servlet._
|
import javax.servlet._
|
||||||
|
|
||||||
|
import gitbucket.core.controller._
|
||||||
|
import gitbucket.core.plugin.PluginRegistry
|
||||||
|
import gitbucket.core.service.SystemSettingsService
|
||||||
|
import gitbucket.core.servlet._
|
||||||
|
import gitbucket.core.util.Directory
|
||||||
import org.scalatra._
|
import org.scalatra._
|
||||||
|
|
||||||
|
|
||||||
class ScalatraBootstrap extends LifeCycle {
|
class ScalatraBootstrap extends LifeCycle with SystemSettingsService {
|
||||||
override def init(context: ServletContext) {
|
override def init(context: ServletContext) {
|
||||||
|
|
||||||
|
val settings = loadSystemSettings()
|
||||||
|
if(settings.baseUrl.exists(_.startsWith("https://"))) {
|
||||||
|
context.getSessionCookieConfig.setSecure(true)
|
||||||
|
}
|
||||||
|
|
||||||
// Register TransactionFilter and BasicAuthenticationFilter at first
|
// Register TransactionFilter and BasicAuthenticationFilter at first
|
||||||
context.addFilter("transactionFilter", new TransactionFilter)
|
context.addFilter("transactionFilter", new TransactionFilter)
|
||||||
context.getFilterRegistration("transactionFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/*")
|
context.getFilterRegistration("transactionFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/*")
|
||||||
context.addFilter("basicAuthenticationFilter", new BasicAuthenticationFilter)
|
context.addFilter("gitAuthenticationFilter", new GitAuthenticationFilter)
|
||||||
context.getFilterRegistration("basicAuthenticationFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/git/*")
|
context.getFilterRegistration("gitAuthenticationFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/git/*")
|
||||||
context.addFilter("accessTokenAuthenticationFilter", new AccessTokenAuthenticationFilter)
|
context.addFilter("apiAuthenticationFilter", new ApiAuthenticationFilter)
|
||||||
context.getFilterRegistration("accessTokenAuthenticationFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/api/v3/*")
|
context.getFilterRegistration("apiAuthenticationFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/api/v3/*")
|
||||||
|
context.addFilter("ghCompatRepositoryAccessFilter", new GHCompatRepositoryAccessFilter)
|
||||||
|
context.getFilterRegistration("ghCompatRepositoryAccessFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/*")
|
||||||
|
|
||||||
// Register controllers
|
// Register controllers
|
||||||
context.mount(new AnonymousAccessController, "/*")
|
context.mount(new AnonymousAccessController, "/*")
|
||||||
|
|
||||||
@@ -27,12 +36,10 @@ class ScalatraBootstrap extends LifeCycle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.mount(new IndexController, "/")
|
context.mount(new IndexController, "/")
|
||||||
context.mount(new SearchController, "/")
|
context.mount(new ApiController, "/api/v3")
|
||||||
context.mount(new FileUploadController, "/upload")
|
context.mount(new FileUploadController, "/upload")
|
||||||
|
context.mount(new SystemSettingsController, "/admin")
|
||||||
context.mount(new DashboardController, "/*")
|
context.mount(new DashboardController, "/*")
|
||||||
context.mount(new UserManagementController, "/*")
|
|
||||||
context.mount(new SystemSettingsController, "/*")
|
|
||||||
context.mount(new PluginsController, "/*")
|
|
||||||
context.mount(new AccountController, "/*")
|
context.mount(new AccountController, "/*")
|
||||||
context.mount(new RepositoryViewerController, "/*")
|
context.mount(new RepositoryViewerController, "/*")
|
||||||
context.mount(new WikiController, "/*")
|
context.mount(new WikiController, "/*")
|
||||||
|
|||||||
31
src/main/scala/gitbucket/core/GitBucketCoreModule.scala
Normal file
31
src/main/scala/gitbucket/core/GitBucketCoreModule.scala
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package gitbucket.core
|
||||||
|
|
||||||
|
import io.github.gitbucket.solidbase.migration.{SqlMigration, LiquibaseMigration}
|
||||||
|
import io.github.gitbucket.solidbase.model.{Version, Module}
|
||||||
|
|
||||||
|
object GitBucketCoreModule extends Module("gitbucket-core",
|
||||||
|
new Version("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.2.0",
|
||||||
|
new LiquibaseMigration("update/gitbucket-core_4.2.xml")
|
||||||
|
),
|
||||||
|
new Version("4.2.1"),
|
||||||
|
new Version("4.3.0"),
|
||||||
|
new Version("4.4.0"),
|
||||||
|
new Version("4.5.0"),
|
||||||
|
new Version("4.6.0",
|
||||||
|
new LiquibaseMigration("update/gitbucket-core_4.6.xml")
|
||||||
|
),
|
||||||
|
new Version("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.8"),
|
||||||
|
new Version("4.9.0",
|
||||||
|
new LiquibaseMigration("update/gitbucket-core_4.9.xml")
|
||||||
|
)
|
||||||
|
)
|
||||||
23
src/main/scala/gitbucket/core/api/ApiBranch.scala
Normal file
23
src/main/scala/gitbucket/core/api/ApiBranch.scala
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
import gitbucket.core.util.RepositoryName
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/#get-branch
|
||||||
|
* https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
|
||||||
|
*/
|
||||||
|
case class ApiBranch(
|
||||||
|
name: String,
|
||||||
|
// commit: ApiBranchCommit,
|
||||||
|
protection: ApiBranchProtection)(repositoryName:RepositoryName) extends FieldSerializable {
|
||||||
|
def _links = Map(
|
||||||
|
"self" -> ApiPath(s"/api/v3/repos/${repositoryName.fullName}/branches/${name}"),
|
||||||
|
"html" -> ApiPath(s"/${repositoryName.fullName}/tree/${name}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
case class ApiBranchCommit(sha: String)
|
||||||
|
|
||||||
|
case class ApiBranchForList(
|
||||||
|
name: String,
|
||||||
|
commit: ApiBranchCommit
|
||||||
|
)
|
||||||
46
src/main/scala/gitbucket/core/api/ApiBranchProtection.scala
Normal file
46
src/main/scala/gitbucket/core/api/ApiBranchProtection.scala
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
import gitbucket.core.service.ProtectedBranchService
|
||||||
|
import org.json4s._
|
||||||
|
|
||||||
|
/** https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection */
|
||||||
|
case class ApiBranchProtection(enabled: Boolean, required_status_checks: Option[ApiBranchProtection.Status]){
|
||||||
|
def status: ApiBranchProtection.Status = required_status_checks.getOrElse(ApiBranchProtection.statusNone)
|
||||||
|
}
|
||||||
|
|
||||||
|
object ApiBranchProtection{
|
||||||
|
/** form for enabling-and-disabling-branch-protection */
|
||||||
|
case class EnablingAndDisabling(protection: ApiBranchProtection)
|
||||||
|
|
||||||
|
def apply(info: ProtectedBranchService.ProtectedBranchInfo): ApiBranchProtection = ApiBranchProtection(
|
||||||
|
enabled = info.enabled,
|
||||||
|
required_status_checks = Some(Status(EnforcementLevel(info.enabled && info.contexts.nonEmpty, info.includeAdministrators), info.contexts)))
|
||||||
|
val statusNone = Status(Off, Seq.empty)
|
||||||
|
case class Status(enforcement_level: EnforcementLevel, contexts: Seq[String])
|
||||||
|
sealed class EnforcementLevel(val name: String)
|
||||||
|
case object Off extends EnforcementLevel("off")
|
||||||
|
case object NonAdmins extends EnforcementLevel("non_admins")
|
||||||
|
case object Everyone extends EnforcementLevel("everyone")
|
||||||
|
object EnforcementLevel {
|
||||||
|
def apply(enabled: Boolean, includeAdministrators: Boolean): EnforcementLevel = if(enabled){
|
||||||
|
if(includeAdministrators){
|
||||||
|
Everyone
|
||||||
|
}else{
|
||||||
|
NonAdmins
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Off
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
implicit val enforcementLevelSerializer = new CustomSerializer[EnforcementLevel](format => (
|
||||||
|
{
|
||||||
|
case JString("off") => Off
|
||||||
|
case JString("non_admins") => NonAdmins
|
||||||
|
case JString("everyone") => Everyone
|
||||||
|
},
|
||||||
|
{
|
||||||
|
case x: EnforcementLevel => JString(x.name)
|
||||||
|
}
|
||||||
|
))
|
||||||
|
}
|
||||||
18
src/main/scala/gitbucket/core/api/ApiContents.scala
Normal file
18
src/main/scala/gitbucket/core/api/ApiContents.scala
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
import gitbucket.core.util.JGitUtil.FileInfo
|
||||||
|
import org.apache.commons.codec.binary.Base64
|
||||||
|
|
||||||
|
case class ApiContents(`type`: String, name: String, content: Option[String], encoding: Option[String])
|
||||||
|
|
||||||
|
object ApiContents{
|
||||||
|
def apply(fileInfo: FileInfo, content: Option[Array[Byte]]): ApiContents = {
|
||||||
|
if(fileInfo.isDirectory) {
|
||||||
|
ApiContents("dir", fileInfo.name, None, None)
|
||||||
|
} else {
|
||||||
|
content.map(arr =>
|
||||||
|
ApiContents("file", fileInfo.name, Some(Base64.encodeBase64String(arr)), Some("base64"))
|
||||||
|
).getOrElse(ApiContents("file", fileInfo.name, None, None))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
src/main/scala/gitbucket/core/api/ApiEndPoint.scala
Normal file
3
src/main/scala/gitbucket/core/api/ApiEndPoint.scala
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
case class ApiEndPoint(rate_limit_url: ApiPath = ApiPath("/api/v3/rate_limit"))
|
||||||
@@ -20,6 +20,16 @@ case class ApiIssue(
|
|||||||
body: String)(repositoryName: RepositoryName, isPullRequest: Boolean){
|
body: String)(repositoryName: RepositoryName, isPullRequest: Boolean){
|
||||||
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) {
|
||||||
|
Some(Map(
|
||||||
|
"url" -> ApiPath(s"/api/v3/repos/${repositoryName.fullName}/pulls/${number}"),
|
||||||
|
"html_url" -> ApiPath(s"/${repositoryName.fullName}/pull/${number}")
|
||||||
|
// "diff_url" -> ApiPath(s"/${repositoryName.fullName}/pull/${number}.diff"),
|
||||||
|
// "patch_url" -> ApiPath(s"/${repositoryName.fullName}/pull/${number}.patch")
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object ApiIssue{
|
object ApiIssue{
|
||||||
|
|||||||
21
src/main/scala/gitbucket/core/api/ApiLabel.scala
Normal file
21
src/main/scala/gitbucket/core/api/ApiLabel.scala
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
import gitbucket.core.model.Label
|
||||||
|
import gitbucket.core.util.RepositoryName
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/labels/
|
||||||
|
*/
|
||||||
|
case class ApiLabel(
|
||||||
|
name: String,
|
||||||
|
color: String)(repositoryName: RepositoryName){
|
||||||
|
var url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/labels/${name}")
|
||||||
|
}
|
||||||
|
|
||||||
|
object ApiLabel{
|
||||||
|
def apply(label:Label, repositoryName: RepositoryName): ApiLabel =
|
||||||
|
ApiLabel(
|
||||||
|
name = label.labelName,
|
||||||
|
color = label.color
|
||||||
|
)(repositoryName)
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package gitbucket.core.api
|
package gitbucket.core.api
|
||||||
|
|
||||||
import gitbucket.core.model.{Issue, PullRequest}
|
import gitbucket.core.model.{Account, Issue, IssueComment, PullRequest}
|
||||||
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
|
|
||||||
@@ -15,6 +14,9 @@ case class ApiPullRequest(
|
|||||||
head: ApiPullRequest.Commit,
|
head: ApiPullRequest.Commit,
|
||||||
base: ApiPullRequest.Commit,
|
base: ApiPullRequest.Commit,
|
||||||
mergeable: Option[Boolean],
|
mergeable: Option[Boolean],
|
||||||
|
merged: Boolean,
|
||||||
|
merged_at: Option[Date],
|
||||||
|
merged_by: Option[ApiUser],
|
||||||
title: String,
|
title: String,
|
||||||
body: String,
|
body: String,
|
||||||
user: ApiUser) {
|
user: ApiUser) {
|
||||||
@@ -31,7 +33,15 @@ case class ApiPullRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
object ApiPullRequest{
|
object ApiPullRequest{
|
||||||
def apply(issue: Issue, pullRequest: PullRequest, headRepo: ApiRepository, baseRepo: ApiRepository, user: ApiUser): ApiPullRequest = ApiPullRequest(
|
def apply(
|
||||||
|
issue: Issue,
|
||||||
|
pullRequest: PullRequest,
|
||||||
|
headRepo: ApiRepository,
|
||||||
|
baseRepo: ApiRepository,
|
||||||
|
user: ApiUser,
|
||||||
|
mergedComment: Option[(IssueComment, Account)]
|
||||||
|
): ApiPullRequest =
|
||||||
|
ApiPullRequest(
|
||||||
number = issue.issueId,
|
number = issue.issueId,
|
||||||
updated_at = issue.updatedDate,
|
updated_at = issue.updatedDate,
|
||||||
created_at = issue.registeredDate,
|
created_at = issue.registeredDate,
|
||||||
@@ -44,6 +54,9 @@ object ApiPullRequest{
|
|||||||
ref = pullRequest.branch,
|
ref = pullRequest.branch,
|
||||||
repo = baseRepo)(issue.userName),
|
repo = baseRepo)(issue.userName),
|
||||||
mergeable = None, // TODO: need check mergeable.
|
mergeable = None, // TODO: need check mergeable.
|
||||||
|
merged = mergedComment.isDefined,
|
||||||
|
merged_at = mergedComment.map { case (comment, _) => comment.registeredDate },
|
||||||
|
merged_by = mergedComment.map { case (_, account) => ApiUser(account) },
|
||||||
title = issue.title,
|
title = issue.title,
|
||||||
body = issue.content.getOrElse(""),
|
body = issue.content.getOrElse(""),
|
||||||
user = user
|
user = user
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
import gitbucket.core.util.RepositoryName
|
||||||
|
import gitbucket.core.model.CommitComment
|
||||||
|
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/activity/events/types/#pullrequestreviewcommentevent
|
||||||
|
*/
|
||||||
|
case class ApiPullRequestReviewComment(
|
||||||
|
id: Int, // 29724692
|
||||||
|
// "diff_hunk": "@@ -1 +1 @@\n-# public-repo",
|
||||||
|
path: String, // "README.md",
|
||||||
|
// "position": 1,
|
||||||
|
// "original_position": 1,
|
||||||
|
commit_id: String, // "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
|
||||||
|
// "original_commit_id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
|
||||||
|
user: ApiUser,
|
||||||
|
body: String, // "Maybe you should use more emojji on this line.",
|
||||||
|
created_at: Date, // "2015-05-05T23:40:27Z",
|
||||||
|
updated_at: Date // "2015-05-05T23:40:27Z",
|
||||||
|
)(repositoryName:RepositoryName, issueId: Int) extends FieldSerializable {
|
||||||
|
// "url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments/29724692",
|
||||||
|
val url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/pulls/comments/${id}")
|
||||||
|
// "html_url": "https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692",
|
||||||
|
val html_url = ApiPath(s"/${repositoryName.fullName}/pull/${issueId}#discussion_r${id}")
|
||||||
|
// "pull_request_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1",
|
||||||
|
val pull_request_url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/pulls/${issueId}")
|
||||||
|
|
||||||
|
/*
|
||||||
|
"_links": {
|
||||||
|
"self": {
|
||||||
|
"href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments/29724692"
|
||||||
|
},
|
||||||
|
"html": {
|
||||||
|
"href": "https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692"
|
||||||
|
},
|
||||||
|
"pull_request": {
|
||||||
|
"href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
val _links = Map(
|
||||||
|
"self" -> Map("href" -> url),
|
||||||
|
"html" -> Map("href" -> html_url),
|
||||||
|
"pull_request" -> Map("href" -> pull_request_url))
|
||||||
|
}
|
||||||
|
|
||||||
|
object ApiPullRequestReviewComment{
|
||||||
|
def apply(comment: CommitComment, commentedUser: ApiUser, repositoryName: RepositoryName, issueId: Int): ApiPullRequestReviewComment =
|
||||||
|
new ApiPullRequestReviewComment(
|
||||||
|
id = comment.commentId,
|
||||||
|
path = comment.fileName.getOrElse(""),
|
||||||
|
commit_id = comment.commitId,
|
||||||
|
user = commentedUser,
|
||||||
|
body = comment.content,
|
||||||
|
created_at = comment.registeredDate,
|
||||||
|
updated_at = comment.updatedDate
|
||||||
|
)(repositoryName, issueId)
|
||||||
|
}
|
||||||
11
src/main/scala/gitbucket/core/api/ApiPusher.scala
Normal file
11
src/main/scala/gitbucket/core/api/ApiPusher.scala
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
import gitbucket.core.model.Account
|
||||||
|
|
||||||
|
case class ApiPusher(name: String, email: String)
|
||||||
|
|
||||||
|
object ApiPusher {
|
||||||
|
def apply(user: Account): ApiPusher = ApiPusher(
|
||||||
|
name = user.userName,
|
||||||
|
email = user.mailAddress)
|
||||||
|
}
|
||||||
5
src/main/scala/gitbucket/core/api/ApiRef.scala
Normal file
5
src/main/scala/gitbucket/core/api/ApiRef.scala
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
case class ApiObject(sha: String)
|
||||||
|
|
||||||
|
case class ApiRef(ref: String, `object`: ApiObject)
|
||||||
@@ -18,7 +18,7 @@ case class ApiRepository(
|
|||||||
val watchers_count = watchers
|
val watchers_count = watchers
|
||||||
val url = if(urlIsHtmlUrl){
|
val url = if(urlIsHtmlUrl){
|
||||||
ApiPath(s"/${full_name}")
|
ApiPath(s"/${full_name}")
|
||||||
}else{
|
} else {
|
||||||
ApiPath(s"/api/v3/repos/${full_name}")
|
ApiPath(s"/api/v3/repos/${full_name}")
|
||||||
}
|
}
|
||||||
val http_url = ApiPath(s"/git/${full_name}.git")
|
val http_url = ApiPath(s"/git/${full_name}.git")
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ case class ApiUser(
|
|||||||
created_at: Date) {
|
created_at: Date) {
|
||||||
val url = ApiPath(s"/api/v3/users/${login}")
|
val url = ApiPath(s"/api/v3/users/${login}")
|
||||||
val html_url = ApiPath(s"/${login}")
|
val html_url = ApiPath(s"/${login}")
|
||||||
|
val avatar_url = ApiPath(s"/${login}/_avatar")
|
||||||
// val followers_url = ApiPath(s"/api/v3/users/${login}/followers")
|
// val followers_url = ApiPath(s"/api/v3/users/${login}/followers")
|
||||||
// val following_url = ApiPath(s"/api/v3/users/${login}/following{/other_user}")
|
// val following_url = ApiPath(s"/api/v3/users/${login}/following{/other_user}")
|
||||||
// val gists_url = ApiPath(s"/api/v3/users/${login}/gists{/gist_id}")
|
// val gists_url = ApiPath(s"/api/v3/users/${login}/gists{/gist_id}")
|
||||||
@@ -29,7 +30,7 @@ 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
|
||||||
)
|
)
|
||||||
|
|||||||
18
src/main/scala/gitbucket/core/api/CreateALabel.scala
Normal file
18
src/main/scala/gitbucket/core/api/CreateALabel.scala
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/labels/#create-a-label
|
||||||
|
* api form
|
||||||
|
*/
|
||||||
|
case class CreateALabel(
|
||||||
|
name: String,
|
||||||
|
color: String
|
||||||
|
) {
|
||||||
|
def isValid: Boolean = {
|
||||||
|
name.length<=100 &&
|
||||||
|
!name.startsWith("_") &&
|
||||||
|
!name.startsWith("-") &&
|
||||||
|
color.length==6 &&
|
||||||
|
color.matches("[a-fA-F0-9+_.]+")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ case class CreateARepository(
|
|||||||
auto_init: Boolean = false
|
auto_init: Boolean = false
|
||||||
) {
|
) {
|
||||||
def isValid: Boolean = {
|
def isValid: Boolean = {
|
||||||
name.length<=40 &&
|
name.length <= 100 &&
|
||||||
name.matches("[a-zA-Z0-9\\-\\+_.]+") &&
|
name.matches("[a-zA-Z0-9\\-\\+_.]+") &&
|
||||||
!name.startsWith("_") &&
|
!name.startsWith("_") &&
|
||||||
!name.startsWith("-")
|
!name.startsWith("-")
|
||||||
|
|||||||
11
src/main/scala/gitbucket/core/api/CreateAnIssue.scala
Normal file
11
src/main/scala/gitbucket/core/api/CreateAnIssue.scala
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/#create-an-issue
|
||||||
|
*/
|
||||||
|
case class CreateAnIssue(
|
||||||
|
title: String,
|
||||||
|
body: Option[String],
|
||||||
|
assignees: List[String],
|
||||||
|
milestone: Option[Int],
|
||||||
|
labels: List[String])
|
||||||
@@ -5,26 +5,34 @@ import org.joda.time.DateTimeZone
|
|||||||
import org.joda.time.format._
|
import org.joda.time.format._
|
||||||
import org.json4s._
|
import org.json4s._
|
||||||
import org.json4s.jackson.Serialization
|
import org.json4s.jackson.Serialization
|
||||||
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
import scala.util.Try
|
import scala.util.Try
|
||||||
|
|
||||||
|
|
||||||
object JsonFormat {
|
object JsonFormat {
|
||||||
case class Context(baseUrl:String)
|
|
||||||
|
case class Context(baseUrl: String)
|
||||||
|
|
||||||
val parserISO = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
val parserISO = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||||
|
|
||||||
val jsonFormats = Serialization.formats(NoTypeHints) + new CustomSerializer[Date](format =>
|
val jsonFormats = Serialization.formats(NoTypeHints) + new CustomSerializer[Date](format =>
|
||||||
(
|
(
|
||||||
{ case JString(s) => Try(parserISO.parseDateTime(s)).toOption.map(_.toDate)
|
{ case JString(s) => Try(parserISO.parseDateTime(s)).toOption.map(_.toDate).getOrElse(throw new MappingException("Can't convert " + s + " to Date")) },
|
||||||
.getOrElse(throw new MappingException("Can't convert " + s + " to Date")) },
|
|
||||||
{ case x: Date => JString(parserISO.print(new DateTime(x).withZone(DateTimeZone.UTC))) }
|
{ case x: Date => JString(parserISO.print(new DateTime(x).withZone(DateTimeZone.UTC))) }
|
||||||
)
|
)
|
||||||
) + FieldSerializer[ApiUser]() + FieldSerializer[ApiPullRequest]() + FieldSerializer[ApiRepository]() +
|
) + FieldSerializer[ApiUser]() +
|
||||||
FieldSerializer[ApiCommitListItem.Parent]() + FieldSerializer[ApiCommitListItem]() + FieldSerializer[ApiCommitListItem.Commit]() +
|
FieldSerializer[ApiPullRequest]() +
|
||||||
FieldSerializer[ApiCommitStatus]() + FieldSerializer[FieldSerializable]() + FieldSerializer[ApiCombinedCommitStatus]() +
|
FieldSerializer[ApiRepository]() +
|
||||||
FieldSerializer[ApiPullRequest.Commit]() + FieldSerializer[ApiIssue]() + FieldSerializer[ApiComment]()
|
FieldSerializer[ApiCommitListItem.Parent]() +
|
||||||
|
FieldSerializer[ApiCommitListItem]() +
|
||||||
|
FieldSerializer[ApiCommitListItem.Commit]() +
|
||||||
|
FieldSerializer[ApiCommitStatus]() +
|
||||||
|
FieldSerializer[FieldSerializable]() +
|
||||||
|
FieldSerializer[ApiCombinedCommitStatus]() +
|
||||||
|
FieldSerializer[ApiPullRequest.Commit]() +
|
||||||
|
FieldSerializer[ApiIssue]() +
|
||||||
|
FieldSerializer[ApiComment]() +
|
||||||
|
FieldSerializer[ApiLabel]() +
|
||||||
|
ApiBranchProtection.enforcementLevelSerializer
|
||||||
|
|
||||||
def apiPathSerializer(c: Context) = new CustomSerializer[ApiPath](format =>
|
def apiPathSerializer(c: Context) = new CustomSerializer[ApiPath](format =>
|
||||||
(
|
(
|
||||||
@@ -33,12 +41,14 @@ object JsonFormat {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convert object to json string
|
* convert object to json string
|
||||||
*/
|
*/
|
||||||
def apply(obj: AnyRef)(implicit c: Context): String = Serialization.write(obj)(jsonFormats + apiPathSerializer(c))
|
def apply(obj: AnyRef)(implicit c: Context): String = Serialization.write(obj)(jsonFormats + apiPathSerializer(c))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.account.html
|
import gitbucket.core.account.html
|
||||||
import gitbucket.core.api._
|
|
||||||
import gitbucket.core.helper
|
import gitbucket.core.helper
|
||||||
import gitbucket.core.model.GroupMember
|
import gitbucket.core.model.GroupMember
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
@@ -12,40 +11,39 @@ import gitbucket.core.util.Implicits._
|
|||||||
import gitbucket.core.util.StringUtil._
|
import gitbucket.core.util.StringUtil._
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
|
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
import org.eclipse.jgit.api.Git
|
|
||||||
import org.eclipse.jgit.dircache.DirCache
|
|
||||||
import org.eclipse.jgit.lib.{FileMode, Constants}
|
|
||||||
import org.scalatra.i18n.Messages
|
import org.scalatra.i18n.Messages
|
||||||
|
import org.scalatra.BadRequest
|
||||||
|
|
||||||
|
|
||||||
class AccountController extends AccountControllerBase
|
class AccountController extends AccountControllerBase
|
||||||
with AccountService with RepositoryService with ActivityService with WikiService with LabelsService with SshKeyService
|
with AccountService with RepositoryService with ActivityService with WikiService with LabelsService with SshKeyService
|
||||||
with OneselfAuthenticator with UsersAuthenticator with GroupManagerAuthenticator with ReadableUsersAuthenticator
|
with OneselfAuthenticator with UsersAuthenticator with GroupManagerAuthenticator with ReadableUsersAuthenticator
|
||||||
with AccessTokenService with WebHookService
|
with AccessTokenService with WebHookService with RepositoryCreationService
|
||||||
|
|
||||||
|
|
||||||
trait AccountControllerBase extends AccountManagementControllerBase {
|
trait AccountControllerBase extends AccountManagementControllerBase {
|
||||||
self: AccountService with RepositoryService with ActivityService with WikiService with LabelsService with SshKeyService
|
self: AccountService with RepositoryService with ActivityService with WikiService with LabelsService with SshKeyService
|
||||||
with OneselfAuthenticator with UsersAuthenticator with GroupManagerAuthenticator with ReadableUsersAuthenticator
|
with OneselfAuthenticator with UsersAuthenticator with GroupManagerAuthenticator with ReadableUsersAuthenticator
|
||||||
with AccessTokenService with WebHookService =>
|
with AccessTokenService with WebHookService with RepositoryCreationService =>
|
||||||
|
|
||||||
case class AccountNewForm(userName: String, password: String, fullName: String, mailAddress: String,
|
case class AccountNewForm(userName: String, password: String, fullName: String, mailAddress: String,
|
||||||
url: Option[String], fileId: Option[String])
|
description: Option[String], url: Option[String], fileId: Option[String])
|
||||||
|
|
||||||
case class AccountEditForm(password: Option[String], fullName: String, mailAddress: String,
|
case class AccountEditForm(password: Option[String], fullName: String, mailAddress: String,
|
||||||
url: Option[String], fileId: Option[String], clearImage: Boolean)
|
description: Option[String], url: Option[String], fileId: Option[String], clearImage: Boolean)
|
||||||
|
|
||||||
case class SshKeyForm(title: String, publicKey: String)
|
case class SshKeyForm(title: String, publicKey: String)
|
||||||
|
|
||||||
case class PersonalTokenForm(note: String)
|
case class PersonalTokenForm(note: String)
|
||||||
|
|
||||||
val newForm = mapping(
|
val newForm = mapping(
|
||||||
"userName" -> trim(label("User name" , text(required, maxlength(100), identifier, uniqueUserName))),
|
"userName" -> trim(label("User name" , text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
||||||
"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()))),
|
||||||
|
"description" -> trim(label("bio" , optional(text()))),
|
||||||
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" , optional(text())))
|
"fileId" -> trim(label("File ID" , optional(text())))
|
||||||
)(AccountNewForm.apply)
|
)(AccountNewForm.apply)
|
||||||
@@ -54,6 +52,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"password" -> trim(label("Password" , optional(text(maxlength(20))))),
|
"password" -> trim(label("Password" , optional(text(maxlength(20))))),
|
||||||
"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")))),
|
||||||
|
"description" -> trim(label("bio" , optional(text()))),
|
||||||
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" , optional(text()))),
|
"fileId" -> trim(label("File ID" , optional(text()))),
|
||||||
"clearImage" -> trim(label("Clear image" , boolean()))
|
"clearImage" -> trim(label("Clear image" , boolean()))
|
||||||
@@ -68,11 +67,12 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"note" -> trim(label("Token", text(required, maxlength(100))))
|
"note" -> trim(label("Token", text(required, maxlength(100))))
|
||||||
)(PersonalTokenForm.apply)
|
)(PersonalTokenForm.apply)
|
||||||
|
|
||||||
case class NewGroupForm(groupName: String, url: Option[String], fileId: Option[String], members: String)
|
case class NewGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String], members: String)
|
||||||
case class EditGroupForm(groupName: String, url: Option[String], fileId: Option[String], members: String, clearImage: Boolean)
|
case class EditGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String], members: String, clearImage: Boolean)
|
||||||
|
|
||||||
val newGroupForm = mapping(
|
val newGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
|
"description" -> trim(label("Group description", optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members)))
|
"members" -> trim(label("Members" ,text(required, members)))
|
||||||
@@ -80,6 +80,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
val editGroupForm = mapping(
|
val editGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
||||||
|
"description" -> trim(label("Group description", optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members))),
|
"members" -> trim(label("Members" ,text(required, members))),
|
||||||
@@ -90,8 +91,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
case class ForkRepositoryForm(owner: String, name: String)
|
case class ForkRepositoryForm(owner: String, name: String)
|
||||||
|
|
||||||
val newRepositoryForm = mapping(
|
val newRepositoryForm = mapping(
|
||||||
"owner" -> trim(label("Owner" , text(required, maxlength(40), identifier, existsAccount))),
|
"owner" -> trim(label("Owner" , text(required, maxlength(100), identifier, existsAccount))),
|
||||||
"name" -> trim(label("Repository name", text(required, maxlength(40), repository, uniqueRepository))),
|
"name" -> trim(label("Repository name", text(required, maxlength(100), repository, uniqueRepository))),
|
||||||
"description" -> trim(label("Description" , optional(text()))),
|
"description" -> trim(label("Description" , optional(text()))),
|
||||||
"isPrivate" -> trim(label("Repository Type", boolean())),
|
"isPrivate" -> trim(label("Repository Type", boolean())),
|
||||||
"createReadme" -> trim(label("Create README" , boolean()))
|
"createReadme" -> trim(label("Create README" , boolean()))
|
||||||
@@ -124,7 +125,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
// Members
|
// Members
|
||||||
case "members" if(account.isGroupAccount) => {
|
case "members" if(account.isGroupAccount) => {
|
||||||
val members = getGroupMembers(account.userName)
|
val members = getGroupMembers(account.userName)
|
||||||
gitbucket.core.account.html.members(account, members.map(_.userName),
|
gitbucket.core.account.html.members(account, members,
|
||||||
context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager }))
|
context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager }))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,11 +134,11 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
val members = getGroupMembers(account.userName)
|
val members = getGroupMembers(account.userName)
|
||||||
gitbucket.core.account.html.repositories(account,
|
gitbucket.core.account.html.repositories(account,
|
||||||
if(account.isGroupAccount) Nil else getGroupsByUserName(userName),
|
if(account.isGroupAccount) Nil else getGroupsByUserName(userName),
|
||||||
getVisibleRepositories(context.loginAccount, context.baseUrl, Some(userName)),
|
getVisibleRepositories(context.loginAccount, Some(userName)),
|
||||||
context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager }))
|
context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
get("/:userName.atom") {
|
get("/:userName.atom") {
|
||||||
@@ -156,30 +157,11 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* https://developer.github.com/v3/users/#get-a-single-user
|
|
||||||
*/
|
|
||||||
get("/api/v3/users/:userName") {
|
|
||||||
getAccountByUserName(params("userName")).map { account =>
|
|
||||||
JsonFormat(ApiUser(account))
|
|
||||||
} getOrElse NotFound
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* https://developer.github.com/v3/users/#get-the-authenticated-user
|
|
||||||
*/
|
|
||||||
get("/api/v3/user") {
|
|
||||||
context.loginAccount.map { account =>
|
|
||||||
JsonFormat(ApiUser(account))
|
|
||||||
} getOrElse Unauthorized
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
get("/:userName/_edit")(oneselfOnly {
|
get("/:userName/_edit")(oneselfOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map { x =>
|
getAccountByUserName(userName).map { x =>
|
||||||
html.edit(x, flash.get("info"))
|
html.edit(x, flash.get("info"), flash.get("error"))
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:userName/_edit", editForm)(oneselfOnly { form =>
|
post("/:userName/_edit", editForm)(oneselfOnly { form =>
|
||||||
@@ -189,19 +171,24 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
password = form.password.map(sha1).getOrElse(account.password),
|
password = form.password.map(sha1).getOrElse(account.password),
|
||||||
fullName = form.fullName,
|
fullName = form.fullName,
|
||||||
mailAddress = form.mailAddress,
|
mailAddress = form.mailAddress,
|
||||||
|
description = form.description,
|
||||||
url = form.url))
|
url = form.url))
|
||||||
|
|
||||||
updateImage(userName, form.fileId, form.clearImage)
|
updateImage(userName, form.fileId, form.clearImage)
|
||||||
flash += "info" -> "Account information has been updated."
|
flash += "info" -> "Account information has been updated."
|
||||||
redirect(s"/${userName}/_edit")
|
redirect(s"/${userName}/_edit")
|
||||||
|
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:userName/_delete")(oneselfOnly {
|
get("/:userName/_delete")(oneselfOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
|
|
||||||
getAccountByUserName(userName, true).foreach { account =>
|
getAccountByUserName(userName, true).map { account =>
|
||||||
|
if(isLastAdministrator(account)){
|
||||||
|
flash += "error" -> "Account can't be removed because this is last one administrator."
|
||||||
|
redirect(s"/${userName}/_edit")
|
||||||
|
} else {
|
||||||
// // Remove repositories
|
// // Remove repositories
|
||||||
// getRepositoryNamesOfUser(userName).foreach { repositoryName =>
|
// getRepositoryNamesOfUser(userName).foreach { repositoryName =>
|
||||||
// deleteRepository(userName, repositoryName)
|
// deleteRepository(userName, repositoryName)
|
||||||
@@ -210,20 +197,19 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
// FileUtils.deleteDirectory(getTemporaryDir(userName, repositoryName))
|
// FileUtils.deleteDirectory(getTemporaryDir(userName, repositoryName))
|
||||||
// }
|
// }
|
||||||
// // Remove from GROUP_MEMBER, COLLABORATOR and REPOSITORY
|
// // Remove from GROUP_MEMBER, COLLABORATOR and REPOSITORY
|
||||||
// removeUserRelatedData(userName)
|
removeUserRelatedData(userName)
|
||||||
|
|
||||||
updateAccount(account.copy(isRemoved = true))
|
updateAccount(account.copy(isRemoved = true))
|
||||||
}
|
|
||||||
|
|
||||||
session.invalidate
|
session.invalidate
|
||||||
redirect("/")
|
redirect("/")
|
||||||
|
}
|
||||||
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:userName/_ssh")(oneselfOnly {
|
get("/:userName/_ssh")(oneselfOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map { x =>
|
getAccountByUserName(userName).map { x =>
|
||||||
html.ssh(x, getPublicKeys(x.userName))
|
html.ssh(x, getPublicKeys(x.userName))
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:userName/_ssh", sshKeyForm)(oneselfOnly { form =>
|
post("/:userName/_ssh", sshKeyForm)(oneselfOnly { form =>
|
||||||
@@ -254,7 +240,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
case _ => None
|
case _ => None
|
||||||
}
|
}
|
||||||
html.application(x, tokens, generatedToken)
|
html.application(x, tokens, generatedToken)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:userName/_personalToken", personalTokenForm)(oneselfOnly { form =>
|
post("/:userName/_personalToken", personalTokenForm)(oneselfOnly { form =>
|
||||||
@@ -280,15 +266,15 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
} else {
|
} else {
|
||||||
html.register()
|
html.register()
|
||||||
}
|
}
|
||||||
} else NotFound
|
} else NotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
post("/register", newForm){ form =>
|
post("/register", newForm){ form =>
|
||||||
if(context.settings.allowAccountRegistration){
|
if(context.settings.allowAccountRegistration){
|
||||||
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.url)
|
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.description, form.url)
|
||||||
updateImage(form.userName, form.fileId, false)
|
updateImage(form.userName, form.fileId, false)
|
||||||
redirect("/signin")
|
redirect("/signin")
|
||||||
} else NotFound
|
} else NotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
get("/groups/new")(usersOnly {
|
get("/groups/new")(usersOnly {
|
||||||
@@ -296,7 +282,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/groups/new", newGroupForm)(usersOnly { form =>
|
post("/groups/new", newGroupForm)(usersOnly { form =>
|
||||||
createGroup(form.groupName, form.url)
|
createGroup(form.groupName, form.description, form.url)
|
||||||
updateGroupMembers(form.groupName, form.members.split(",").map {
|
updateGroupMembers(form.groupName, form.members.split(",").map {
|
||||||
_.split(":") match {
|
_.split(":") match {
|
||||||
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
||||||
@@ -334,22 +320,22 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
}.toList){ case (groupName, members) =>
|
}.toList){ case (groupName, members) =>
|
||||||
getAccountByUserName(groupName, true).map { account =>
|
getAccountByUserName(groupName, true).map { account =>
|
||||||
updateGroup(groupName, form.url, false)
|
updateGroup(groupName, form.description, form.url, false)
|
||||||
|
|
||||||
// Update GROUP_MEMBER
|
// Update GROUP_MEMBER
|
||||||
updateGroupMembers(form.groupName, members)
|
updateGroupMembers(form.groupName, members)
|
||||||
// Update COLLABORATOR for group repositories
|
// // Update COLLABORATOR for group repositories
|
||||||
getRepositoryNamesOfUser(form.groupName).foreach { repositoryName =>
|
// getRepositoryNamesOfUser(form.groupName).foreach { repositoryName =>
|
||||||
removeCollaborators(form.groupName, repositoryName)
|
// removeCollaborators(form.groupName, repositoryName)
|
||||||
members.foreach { case (userName, isManager) =>
|
// members.foreach { case (userName, isManager) =>
|
||||||
addCollaborator(form.groupName, repositoryName, userName)
|
// addCollaborator(form.groupName, repositoryName, userName)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
updateImage(form.groupName, form.fileId, form.clearImage)
|
updateImage(form.groupName, form.fileId, form.clearImage)
|
||||||
redirect(s"/${form.groupName}")
|
redirect(s"/${form.groupName}")
|
||||||
|
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -365,8 +351,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
*/
|
*/
|
||||||
post("/new", newRepositoryForm)(usersOnly { form =>
|
post("/new", newRepositoryForm)(usersOnly { form =>
|
||||||
LockUtil.lock(s"${form.owner}/${form.name}"){
|
LockUtil.lock(s"${form.owner}/${form.name}"){
|
||||||
if(getRepository(form.owner, form.name, context.baseUrl).isEmpty){
|
if(getRepository(form.owner, form.name).isEmpty){
|
||||||
createRepository(form.owner, form.name, form.description, form.isPrivate, form.createReadme)
|
createRepository(context.loginAccount.get, form.owner, form.name, form.description, form.isPrivate, form.createReadme)
|
||||||
}
|
}
|
||||||
|
|
||||||
// redirect to the repository
|
// redirect to the repository
|
||||||
@@ -374,55 +360,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
|
||||||
* Create user repository
|
|
||||||
* https://developer.github.com/v3/repos/#create
|
|
||||||
*/
|
|
||||||
post("/api/v3/user/repos")(usersOnly {
|
|
||||||
val owner = context.loginAccount.get.userName
|
|
||||||
(for {
|
|
||||||
data <- extractFromJsonBody[CreateARepository] if data.isValid
|
|
||||||
} yield {
|
|
||||||
LockUtil.lock(s"${owner}/${data.name}") {
|
|
||||||
if(getRepository(owner, data.name, context.baseUrl).isEmpty){
|
|
||||||
createRepository(owner, data.name, data.description, data.`private`, data.auto_init)
|
|
||||||
val repository = getRepository(owner, data.name, context.baseUrl).get
|
|
||||||
JsonFormat(ApiRepository(repository, ApiUser(getAccountByUserName(owner).get)))
|
|
||||||
} else {
|
|
||||||
ApiError(
|
|
||||||
"A repository with this name already exists on this account",
|
|
||||||
Some("https://developer.github.com/v3/repos/#create")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) getOrElse NotFound
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create group repository
|
|
||||||
* https://developer.github.com/v3/repos/#create
|
|
||||||
*/
|
|
||||||
post("/api/v3/orgs/:org/repos")(managersOnly {
|
|
||||||
val groupName = params("org")
|
|
||||||
(for {
|
|
||||||
data <- extractFromJsonBody[CreateARepository] if data.isValid
|
|
||||||
} yield {
|
|
||||||
LockUtil.lock(s"${groupName}/${data.name}") {
|
|
||||||
if(getRepository(groupName, data.name, context.baseUrl).isEmpty){
|
|
||||||
createRepository(groupName, data.name, data.description, data.`private`, data.auto_init)
|
|
||||||
val repository = getRepository(groupName, data.name, context.baseUrl).get
|
|
||||||
JsonFormat(ApiRepository(repository, ApiUser(getAccountByUserName(groupName).get)))
|
|
||||||
} else {
|
|
||||||
ApiError(
|
|
||||||
"A repository with this name already exists for this group",
|
|
||||||
Some("https://developer.github.com/v3/repos/#create")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) getOrElse NotFound
|
|
||||||
})
|
|
||||||
|
|
||||||
get("/:owner/:repository/fork")(readableUsersOnly { repository =>
|
get("/:owner/:repository/fork")(readableUsersOnly { repository =>
|
||||||
|
if(repository.repository.options.allowFork){
|
||||||
val loginAccount = context.loginAccount.get
|
val loginAccount = context.loginAccount.get
|
||||||
val loginUserName = loginAccount.userName
|
val loginUserName = loginAccount.userName
|
||||||
val groups = getGroupsByUserName(loginUserName)
|
val groups = getGroupsByUserName(loginUserName)
|
||||||
@@ -438,15 +377,17 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
)
|
)
|
||||||
case _ => redirect(s"/${loginUserName}")
|
case _ => redirect(s"/${loginUserName}")
|
||||||
}
|
}
|
||||||
|
} else BadRequest()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/fork", accountForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/fork", accountForm)(readableUsersOnly { (form, repository) =>
|
||||||
|
if(repository.repository.options.allowFork){
|
||||||
val loginAccount = context.loginAccount.get
|
val loginAccount = context.loginAccount.get
|
||||||
val loginUserName = loginAccount.userName
|
val loginUserName = loginAccount.userName
|
||||||
val accountName = form.accountName
|
val accountName = form.accountName
|
||||||
|
|
||||||
LockUtil.lock(s"${accountName}/${repository.name}"){
|
LockUtil.lock(s"${accountName}/${repository.name}"){
|
||||||
if(getRepository(accountName, repository.name, baseUrl).isDefined ||
|
if(getRepository(accountName, repository.name).isDefined ||
|
||||||
(accountName != loginUserName && !getGroupsByUserName(loginUserName).contains(accountName))){
|
(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}")
|
||||||
@@ -455,7 +396,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
val originUserName = repository.repository.originUserName.getOrElse(repository.owner)
|
val originUserName = repository.repository.originUserName.getOrElse(repository.owner)
|
||||||
val originRepositoryName = repository.repository.originRepositoryName.getOrElse(repository.name)
|
val originRepositoryName = repository.repository.originRepositoryName.getOrElse(repository.name)
|
||||||
|
|
||||||
createRepository(
|
insertRepository(
|
||||||
repositoryName = repository.name,
|
repositoryName = repository.name,
|
||||||
userName = accountName,
|
userName = accountName,
|
||||||
description = repository.repository.description,
|
description = repository.repository.description,
|
||||||
@@ -466,13 +407,13 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
parentUserName = Some(repository.owner)
|
parentUserName = Some(repository.owner)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Add collaborators for group repository
|
// // Add collaborators for group repository
|
||||||
val ownerAccount = getAccountByUserName(accountName).get
|
// val ownerAccount = getAccountByUserName(accountName).get
|
||||||
if(ownerAccount.isGroupAccount){
|
// if(ownerAccount.isGroupAccount){
|
||||||
getGroupMembers(accountName).foreach { member =>
|
// getGroupMembers(accountName).foreach { member =>
|
||||||
addCollaborator(accountName, repository.name, member.userName)
|
// addCollaborator(accountName, repository.name, member.userName)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Insert default labels
|
// Insert default labels
|
||||||
insertDefaultLabels(accountName, repository.name)
|
insertDefaultLabels(accountName, repository.name)
|
||||||
@@ -493,70 +434,9 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
redirect(s"/${accountName}/${repository.name}")
|
redirect(s"/${accountName}/${repository.name}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else BadRequest()
|
||||||
})
|
})
|
||||||
|
|
||||||
private def createRepository(owner: String, name: String, description: Option[String], isPrivate: Boolean, createReadme: Boolean) {
|
|
||||||
val ownerAccount = getAccountByUserName(owner).get
|
|
||||||
val loginAccount = context.loginAccount.get
|
|
||||||
val loginUserName = loginAccount.userName
|
|
||||||
|
|
||||||
// Insert to the database at first
|
|
||||||
createRepository(name, owner, description, isPrivate)
|
|
||||||
|
|
||||||
// Add collaborators for group repository
|
|
||||||
if(ownerAccount.isGroupAccount){
|
|
||||||
getGroupMembers(owner).foreach { member =>
|
|
||||||
addCollaborator(owner, name, member.userName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert default labels
|
|
||||||
insertDefaultLabels(owner, name)
|
|
||||||
|
|
||||||
// Create the actual repository
|
|
||||||
val gitdir = getRepositoryDir(owner, name)
|
|
||||||
JGitUtil.initRepository(gitdir)
|
|
||||||
|
|
||||||
if(createReadme){
|
|
||||||
using(Git.open(gitdir)){ git =>
|
|
||||||
val builder = DirCache.newInCore.builder()
|
|
||||||
val inserter = git.getRepository.newObjectInserter()
|
|
||||||
val headId = git.getRepository.resolve(Constants.HEAD + "^{commit}")
|
|
||||||
val content = if(description.nonEmpty){
|
|
||||||
name + "\n" +
|
|
||||||
"===============\n" +
|
|
||||||
"\n" +
|
|
||||||
description.get
|
|
||||||
} else {
|
|
||||||
name + "\n" +
|
|
||||||
"===============\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.add(JGitUtil.createDirCacheEntry("README.md", FileMode.REGULAR_FILE,
|
|
||||||
inserter.insert(Constants.OBJ_BLOB, content.getBytes("UTF-8"))))
|
|
||||||
builder.finish()
|
|
||||||
|
|
||||||
JGitUtil.createNewCommit(git, inserter, headId, builder.getDirCache.writeTree(inserter),
|
|
||||||
Constants.HEAD, loginAccount.fullName, loginAccount.mailAddress, "Initial commit")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create Wiki repository
|
|
||||||
createWikiRepository(loginAccount, owner, name)
|
|
||||||
|
|
||||||
// Record activity
|
|
||||||
recordCreateRepositoryActivity(owner, name, loginUserName)
|
|
||||||
}
|
|
||||||
|
|
||||||
private def insertDefaultLabels(userName: String, repositoryName: String): Unit = {
|
|
||||||
createLabel(userName, repositoryName, "bug", "fc2929")
|
|
||||||
createLabel(userName, repositoryName, "duplicate", "cccccc")
|
|
||||||
createLabel(userName, repositoryName, "enhancement", "84b6eb")
|
|
||||||
createLabel(userName, repositoryName, "invalid", "e6e6e6")
|
|
||||||
createLabel(userName, repositoryName, "question", "cc317c")
|
|
||||||
createLabel(userName, repositoryName, "wontfix", "ffffff")
|
|
||||||
}
|
|
||||||
|
|
||||||
private def existsAccount: Constraint = new Constraint(){
|
private def existsAccount: 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(getAccountByUserName(value).isEmpty) Some("User or group does not exist.") else None
|
if(getAccountByUserName(value).isEmpty) Some("User or group does not exist.") else None
|
||||||
@@ -579,8 +459,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
private def validPublicKey: Constraint = new Constraint(){
|
private def validPublicKey: Constraint = new Constraint(){
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] = SshUtil.str2PublicKey(value) match {
|
override def validate(name: String, value: String, messages: Messages): Option[String] = SshUtil.str2PublicKey(value) match {
|
||||||
case Some(_) => None
|
case Some(_) if !getAllKeys().exists(_.publicKey == value) => None
|
||||||
case None => Some("Key is invalid.")
|
case _ => Some("Key is invalid.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
608
src/main/scala/gitbucket/core/controller/ApiController.scala
Normal file
608
src/main/scala/gitbucket/core/controller/ApiController.scala
Normal file
@@ -0,0 +1,608 @@
|
|||||||
|
package gitbucket.core.controller
|
||||||
|
|
||||||
|
import gitbucket.core.api._
|
||||||
|
import gitbucket.core.model._
|
||||||
|
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
||||||
|
import gitbucket.core.service.PullRequestService._
|
||||||
|
import gitbucket.core.service._
|
||||||
|
import gitbucket.core.util.ControlUtil._
|
||||||
|
import gitbucket.core.util.Directory._
|
||||||
|
import gitbucket.core.util.JGitUtil._
|
||||||
|
import gitbucket.core.util._
|
||||||
|
import gitbucket.core.util.Implicits._
|
||||||
|
import gitbucket.core.view.helpers.{renderMarkup, isRenderable}
|
||||||
|
import org.eclipse.jgit.api.Git
|
||||||
|
import org.scalatra.{NoContent, UnprocessableEntity, Created}
|
||||||
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
|
class ApiController extends ApiControllerBase
|
||||||
|
with RepositoryService
|
||||||
|
with AccountService
|
||||||
|
with ProtectedBranchService
|
||||||
|
with IssuesService
|
||||||
|
with LabelsService
|
||||||
|
with MilestonesService
|
||||||
|
with PullRequestService
|
||||||
|
with CommitsService
|
||||||
|
with CommitStatusService
|
||||||
|
with RepositoryCreationService
|
||||||
|
with IssueCreationService
|
||||||
|
with HandleCommentService
|
||||||
|
with WebHookService
|
||||||
|
with WebHookPullRequestService
|
||||||
|
with WebHookIssueCommentService
|
||||||
|
with WikiService
|
||||||
|
with ActivityService
|
||||||
|
with OwnerAuthenticator
|
||||||
|
with UsersAuthenticator
|
||||||
|
with GroupManagerAuthenticator
|
||||||
|
with ReferrerAuthenticator
|
||||||
|
with ReadableUsersAuthenticator
|
||||||
|
with WritableUsersAuthenticator
|
||||||
|
|
||||||
|
trait ApiControllerBase extends ControllerBase {
|
||||||
|
self: RepositoryService
|
||||||
|
with AccountService
|
||||||
|
with ProtectedBranchService
|
||||||
|
with IssuesService
|
||||||
|
with LabelsService
|
||||||
|
with MilestonesService
|
||||||
|
with PullRequestService
|
||||||
|
with CommitStatusService
|
||||||
|
with RepositoryCreationService
|
||||||
|
with IssueCreationService
|
||||||
|
with HandleCommentService
|
||||||
|
with OwnerAuthenticator
|
||||||
|
with UsersAuthenticator
|
||||||
|
with GroupManagerAuthenticator
|
||||||
|
with ReferrerAuthenticator
|
||||||
|
with ReadableUsersAuthenticator
|
||||||
|
with WritableUsersAuthenticator =>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/#root-endpoint
|
||||||
|
*/
|
||||||
|
get("/api/v3/") {
|
||||||
|
JsonFormat(ApiEndPoint())
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/orgs/#get-an-organization
|
||||||
|
*/
|
||||||
|
get("/api/v3/orgs/:groupName") {
|
||||||
|
getAccountByUserName(params("groupName")).filter(account => account.isGroupAccount).map { account =>
|
||||||
|
JsonFormat(ApiUser(account))
|
||||||
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/users/#get-a-single-user
|
||||||
|
*/
|
||||||
|
get("/api/v3/users/:userName") {
|
||||||
|
getAccountByUserName(params("userName")).filterNot(account => account.isGroupAccount).map { account =>
|
||||||
|
JsonFormat(ApiUser(account))
|
||||||
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/#list-organization-repositories
|
||||||
|
*/
|
||||||
|
get("/api/v3/orgs/:orgName/repos") {
|
||||||
|
JsonFormat(getVisibleRepositories(context.loginAccount, Some(params("orgName"))).map{ r => ApiRepository(r, getAccountByUserName(r.owner).get)})
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/#list-user-repositories
|
||||||
|
*/
|
||||||
|
get("/api/v3/users/:userName/repos") {
|
||||||
|
JsonFormat(getVisibleRepositories(context.loginAccount, Some(params("userName"))).map{ r => ApiRepository(r, getAccountByUserName(r.owner).get)})
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://developer.github.com/v3/repos/branches/#list-branches
|
||||||
|
*/
|
||||||
|
get ("/api/v3/repos/:owner/:repo/branches")(referrersOnly { repository =>
|
||||||
|
JsonFormat(JGitUtil.getBranches(
|
||||||
|
owner = repository.owner,
|
||||||
|
name = repository.name,
|
||||||
|
defaultBranch = repository.repository.defaultBranch,
|
||||||
|
origin = repository.repository.originUserName.isEmpty
|
||||||
|
).map { br =>
|
||||||
|
ApiBranchForList(br.name, ApiBranchCommit(br.commitId))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://developer.github.com/v3/repos/contents/#get-contents
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repo/contents/*")(referrersOnly { repository =>
|
||||||
|
def getFileInfo(git: Git, revision: String, pathStr: String): Option[FileInfo] = {
|
||||||
|
val path = new java.io.File(pathStr)
|
||||||
|
val dirName = path.getParent match {
|
||||||
|
case null => "."
|
||||||
|
case s => s
|
||||||
|
}
|
||||||
|
getFileList(git, revision, dirName).find(f => f.name.equals(path.getName))
|
||||||
|
}
|
||||||
|
|
||||||
|
val path = multiParams("splat").head match {
|
||||||
|
case s if s.isEmpty => "."
|
||||||
|
case s => s
|
||||||
|
}
|
||||||
|
val refStr = params.getOrElse("ref", repository.repository.defaultBranch)
|
||||||
|
|
||||||
|
using(Git.open(getRepositoryDir(params("owner"), params("repo")))){ git =>
|
||||||
|
val fileList = getFileList(git, refStr, path)
|
||||||
|
if (fileList.isEmpty) { // file or NotFound
|
||||||
|
getFileInfo(git, refStr, path).flatMap(f => {
|
||||||
|
val largeFile = params.get("large_file").exists(s => s.equals("true"))
|
||||||
|
val content = getContentFromId(git, f.id, largeFile)
|
||||||
|
request.getHeader("Accept") match {
|
||||||
|
case "application/vnd.github.v3.raw" => {
|
||||||
|
contentType = "application/vnd.github.v3.raw"
|
||||||
|
content
|
||||||
|
}
|
||||||
|
case "application/vnd.github.v3.html" if isRenderable(f.name) => {
|
||||||
|
contentType = "application/vnd.github.v3.html"
|
||||||
|
content.map(c =>
|
||||||
|
List(
|
||||||
|
"<div data-path=\"", path, "\" id=\"file\">", "<article>",
|
||||||
|
renderMarkup(path.split("/").toList, new String(c), refStr, repository, false, false, true).body,
|
||||||
|
"</article>", "</div>"
|
||||||
|
).mkString
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case "application/vnd.github.v3.html" => {
|
||||||
|
contentType = "application/vnd.github.v3.html"
|
||||||
|
content.map(c =>
|
||||||
|
List(
|
||||||
|
"<div data-path=\"", path, "\" id=\"file\">", "<div class=\"plain\">", "<pre>",
|
||||||
|
play.twirl.api.HtmlFormat.escape(new String(c)).body,
|
||||||
|
"</pre>", "</div>", "</div>"
|
||||||
|
).mkString
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case _ =>
|
||||||
|
Some(JsonFormat(ApiContents(f, content)))
|
||||||
|
}
|
||||||
|
}).getOrElse(NotFound())
|
||||||
|
} else { // directory
|
||||||
|
JsonFormat(fileList.map{f => ApiContents(f, None)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://developer.github.com/v3/git/refs/#get-a-reference
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repo/git/*") (referrersOnly { repository =>
|
||||||
|
val revstr = multiParams("splat").head
|
||||||
|
using(Git.open(getRepositoryDir(params("owner"), params("repo")))) { git =>
|
||||||
|
//JsonFormat( (revstr, git.getRepository().resolve(revstr)) )
|
||||||
|
// getRef is deprecated by jgit-4.2. use exactRef() or findRef()
|
||||||
|
val sha = git.getRepository().exactRef(revstr).getObjectId().name()
|
||||||
|
JsonFormat(ApiRef(revstr, ApiObject(sha)))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/collaborators/#list-collaborators
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repo/collaborators") (referrersOnly { repository =>
|
||||||
|
// TODO Should ApiUser take permission? getCollaboratorUserNames does not return owner group members.
|
||||||
|
JsonFormat(getCollaboratorUserNames(params("owner"), params("repo")).map(u => ApiUser(getAccountByUserName(u).get)))
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/users/#get-the-authenticated-user
|
||||||
|
*/
|
||||||
|
get("/api/v3/user") {
|
||||||
|
context.loginAccount.map { account =>
|
||||||
|
JsonFormat(ApiUser(account))
|
||||||
|
} getOrElse Unauthorized()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List user's own repository
|
||||||
|
* https://developer.github.com/v3/repos/#list-your-repositories
|
||||||
|
*/
|
||||||
|
get("/api/v3/user/repos")(usersOnly{
|
||||||
|
JsonFormat(getVisibleRepositories(context.loginAccount, Option(context.loginAccount.get.userName)).map{
|
||||||
|
r => ApiRepository(r, getAccountByUserName(r.owner).get)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create user repository
|
||||||
|
* https://developer.github.com/v3/repos/#create
|
||||||
|
*/
|
||||||
|
post("/api/v3/user/repos")(usersOnly {
|
||||||
|
val owner = context.loginAccount.get.userName
|
||||||
|
(for {
|
||||||
|
data <- extractFromJsonBody[CreateARepository] if data.isValid
|
||||||
|
} yield {
|
||||||
|
LockUtil.lock(s"${owner}/${data.name}") {
|
||||||
|
if(getRepository(owner, data.name).isEmpty){
|
||||||
|
createRepository(context.loginAccount.get, owner, data.name, data.description, data.`private`, data.auto_init)
|
||||||
|
val repository = getRepository(owner, data.name).get
|
||||||
|
JsonFormat(ApiRepository(repository, ApiUser(getAccountByUserName(owner).get)))
|
||||||
|
} else {
|
||||||
|
ApiError(
|
||||||
|
"A repository with this name already exists on this account",
|
||||||
|
Some("https://developer.github.com/v3/repos/#create")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create group repository
|
||||||
|
* https://developer.github.com/v3/repos/#create
|
||||||
|
*/
|
||||||
|
post("/api/v3/orgs/:org/repos")(managersOnly {
|
||||||
|
val groupName = params("org")
|
||||||
|
(for {
|
||||||
|
data <- extractFromJsonBody[CreateARepository] if data.isValid
|
||||||
|
} yield {
|
||||||
|
LockUtil.lock(s"${groupName}/${data.name}") {
|
||||||
|
if(getRepository(groupName, data.name).isEmpty){
|
||||||
|
createRepository(context.loginAccount.get, groupName, data.name, data.description, data.`private`, data.auto_init)
|
||||||
|
val repository = getRepository(groupName, data.name).get
|
||||||
|
JsonFormat(ApiRepository(repository, ApiUser(getAccountByUserName(groupName).get)))
|
||||||
|
} else {
|
||||||
|
ApiError(
|
||||||
|
"A repository with this name already exists for this group",
|
||||||
|
Some("https://developer.github.com/v3/repos/#create")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
|
||||||
|
*/
|
||||||
|
patch("/api/v3/repos/:owner/:repo/branches/:branch")(ownerOnly { repository =>
|
||||||
|
import gitbucket.core.api._
|
||||||
|
(for{
|
||||||
|
branch <- params.get("branch") if repository.branchList.find(_ == branch).isDefined
|
||||||
|
protection <- extractFromJsonBody[ApiBranchProtection.EnablingAndDisabling].map(_.protection)
|
||||||
|
} yield {
|
||||||
|
if(protection.enabled){
|
||||||
|
enableBranchProtection(repository.owner, repository.name, branch, protection.status.enforcement_level == ApiBranchProtection.Everyone, protection.status.contexts)
|
||||||
|
} else {
|
||||||
|
disableBranchProtection(repository.owner, repository.name, branch)
|
||||||
|
}
|
||||||
|
JsonFormat(ApiBranch(branch, protection)(RepositoryName(repository)))
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://developer.github.com/v3/rate_limit/#get-your-current-rate-limit-status
|
||||||
|
* but not enabled.
|
||||||
|
*/
|
||||||
|
get("/api/v3/rate_limit"){
|
||||||
|
contentType = formats("json")
|
||||||
|
// this message is same as github enterprise...
|
||||||
|
org.scalatra.NotFound(ApiError("Rate limiting is not enabled."))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/#list-issues-for-a-repository
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/issues")(referrersOnly { repository =>
|
||||||
|
val page = IssueSearchCondition.page(request)
|
||||||
|
// TODO: more api spec condition
|
||||||
|
val condition = IssueSearchCondition(request)
|
||||||
|
val baseOwner = getAccountByUserName(repository.owner).get
|
||||||
|
|
||||||
|
val issues: List[(Issue, Account)] =
|
||||||
|
searchIssueByApi(
|
||||||
|
condition = condition,
|
||||||
|
offset = (page - 1) * PullRequestLimit,
|
||||||
|
limit = PullRequestLimit,
|
||||||
|
repos = repository.owner -> repository.name
|
||||||
|
)
|
||||||
|
|
||||||
|
JsonFormat(issues.map { case (issue, issueUser) =>
|
||||||
|
ApiIssue(
|
||||||
|
issue = issue,
|
||||||
|
repositoryName = RepositoryName(repository),
|
||||||
|
user = ApiUser(issueUser)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/#get-a-single-issue
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/issues/:id")(referrersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
issueId <- params("id").toIntOpt
|
||||||
|
issue <- getIssue(repository.owner, repository.name, issueId.toString)
|
||||||
|
openedUser <- getAccountByUserName(issue.openedUserName)
|
||||||
|
} yield {
|
||||||
|
JsonFormat(ApiIssue(issue, RepositoryName(repository), ApiUser(openedUser)))
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/#create-an-issue
|
||||||
|
*/
|
||||||
|
post("/api/v3/repos/:owner/:repository/issues")(readableUsersOnly { repository =>
|
||||||
|
if(isIssueEditable(repository)){ // TODO Should this check is provided by authenticator?
|
||||||
|
(for{
|
||||||
|
data <- extractFromJsonBody[CreateAnIssue]
|
||||||
|
loginAccount <- context.loginAccount
|
||||||
|
} yield {
|
||||||
|
val milestone = data.milestone.flatMap(getMilestone(repository.owner, repository.name, _))
|
||||||
|
val issue = createIssue(
|
||||||
|
repository,
|
||||||
|
data.title,
|
||||||
|
data.body,
|
||||||
|
data.assignees.headOption,
|
||||||
|
milestone.map(_.milestoneId),
|
||||||
|
data.labels,
|
||||||
|
loginAccount)
|
||||||
|
JsonFormat(ApiIssue(issue, RepositoryName(repository), ApiUser(loginAccount)))
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
} else Unauthorized()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/issues/:id/comments")(referrersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
issueId <- params("id").toIntOpt
|
||||||
|
comments = getCommentsForApi(repository.owner, repository.name, issueId.toInt)
|
||||||
|
} yield {
|
||||||
|
JsonFormat(comments.map{ case (issueComment, user, issue) => ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(user), issue.isPullRequest) })
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/comments/#create-a-comment
|
||||||
|
*/
|
||||||
|
post("/api/v3/repos/:owner/:repository/issues/:id/comments")(readableUsersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
issueId <- params("id").toIntOpt
|
||||||
|
issue <- getIssue(repository.owner, repository.name, issueId.toString)
|
||||||
|
body <- extractFromJsonBody[CreateAComment].map(_.body) if ! body.isEmpty
|
||||||
|
action = params.get("action").filter(_ => isEditable(issue.userName, issue.repositoryName, issue.openedUserName))
|
||||||
|
(issue, id) <- handleComment(issue, Some(body), repository, action)
|
||||||
|
issueComment <- getComment(repository.owner, repository.name, id.toString())
|
||||||
|
} yield {
|
||||||
|
JsonFormat(ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(context.loginAccount.get), issue.isPullRequest))
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all labels for this repository
|
||||||
|
* https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/labels")(referrersOnly { repository =>
|
||||||
|
JsonFormat(getLabels(repository.owner, repository.name).map { label =>
|
||||||
|
ApiLabel(label, RepositoryName(repository))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a single label
|
||||||
|
* https://developer.github.com/v3/issues/labels/#get-a-single-label
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/labels/:labelName")(referrersOnly { repository =>
|
||||||
|
getLabel(repository.owner, repository.name, params("labelName")).map { label =>
|
||||||
|
JsonFormat(ApiLabel(label, RepositoryName(repository)))
|
||||||
|
} getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a label
|
||||||
|
* https://developer.github.com/v3/issues/labels/#create-a-label
|
||||||
|
*/
|
||||||
|
post("/api/v3/repos/:owner/:repository/labels")(writableUsersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
data <- extractFromJsonBody[CreateALabel] if data.isValid
|
||||||
|
} yield {
|
||||||
|
LockUtil.lock(RepositoryName(repository).fullName) {
|
||||||
|
if (getLabel(repository.owner, repository.name, data.name).isEmpty) {
|
||||||
|
val labelId = createLabel(repository.owner, repository.name, data.name, data.color)
|
||||||
|
getLabel(repository.owner, repository.name, labelId).map { label =>
|
||||||
|
Created(JsonFormat(ApiLabel(label, RepositoryName(repository))))
|
||||||
|
} getOrElse NotFound()
|
||||||
|
} else {
|
||||||
|
// TODO ApiError should support errors field to enhance compatibility of GitHub API
|
||||||
|
UnprocessableEntity(ApiError(
|
||||||
|
"Validation Failed",
|
||||||
|
Some("https://developer.github.com/v3/issues/labels/#create-a-label")
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a label
|
||||||
|
* https://developer.github.com/v3/issues/labels/#update-a-label
|
||||||
|
*/
|
||||||
|
patch("/api/v3/repos/:owner/:repository/labels/:labelName")(writableUsersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
data <- extractFromJsonBody[CreateALabel] if data.isValid
|
||||||
|
} yield {
|
||||||
|
LockUtil.lock(RepositoryName(repository).fullName) {
|
||||||
|
getLabel(repository.owner, repository.name, params("labelName")).map { label =>
|
||||||
|
if (getLabel(repository.owner, repository.name, data.name).isEmpty) {
|
||||||
|
updateLabel(repository.owner, repository.name, label.labelId, data.name, data.color)
|
||||||
|
JsonFormat(ApiLabel(
|
||||||
|
getLabel(repository.owner, repository.name, label.labelId).get,
|
||||||
|
RepositoryName(repository)
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
// TODO ApiError should support errors field to enhance compatibility of GitHub API
|
||||||
|
UnprocessableEntity(ApiError(
|
||||||
|
"Validation Failed",
|
||||||
|
Some("https://developer.github.com/v3/issues/labels/#create-a-label")
|
||||||
|
))
|
||||||
|
}
|
||||||
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a label
|
||||||
|
* https://developer.github.com/v3/issues/labels/#delete-a-label
|
||||||
|
*/
|
||||||
|
delete("/api/v3/repos/:owner/:repository/labels/:labelName")(writableUsersOnly { repository =>
|
||||||
|
LockUtil.lock(RepositoryName(repository).fullName) {
|
||||||
|
getLabel(repository.owner, repository.name, params("labelName")).map { label =>
|
||||||
|
deleteLabel(repository.owner, repository.name, label.labelId)
|
||||||
|
NoContent()
|
||||||
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/pulls/#list-pull-requests
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/pulls")(referrersOnly { repository =>
|
||||||
|
val page = IssueSearchCondition.page(request)
|
||||||
|
// TODO: more api spec condition
|
||||||
|
val condition = IssueSearchCondition(request)
|
||||||
|
val baseOwner = getAccountByUserName(repository.owner).get
|
||||||
|
|
||||||
|
val issues: List[(Issue, Account, Int, PullRequest, Repository, Account)] =
|
||||||
|
searchPullRequestByApi(
|
||||||
|
condition = condition,
|
||||||
|
offset = (page - 1) * PullRequestLimit,
|
||||||
|
limit = PullRequestLimit,
|
||||||
|
repos = repository.owner -> repository.name
|
||||||
|
)
|
||||||
|
|
||||||
|
JsonFormat(issues.map { case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner) =>
|
||||||
|
ApiPullRequest(
|
||||||
|
issue = issue,
|
||||||
|
pullRequest = pullRequest,
|
||||||
|
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
|
||||||
|
baseRepo = ApiRepository(repository, ApiUser(baseOwner)),
|
||||||
|
user = ApiUser(issueUser),
|
||||||
|
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/pulls/#get-a-single-pull-request
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/pulls/:id")(referrersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
issueId <- params("id").toIntOpt
|
||||||
|
(issue, pullRequest) <- getPullRequest(repository.owner, repository.name, issueId)
|
||||||
|
users = getAccountsByUserNames(Set(repository.owner, pullRequest.requestUserName, issue.openedUserName), Set.empty)
|
||||||
|
baseOwner <- users.get(repository.owner)
|
||||||
|
headOwner <- users.get(pullRequest.requestUserName)
|
||||||
|
issueUser <- users.get(issue.openedUserName)
|
||||||
|
headRepo <- getRepository(pullRequest.requestUserName, pullRequest.requestRepositoryName)
|
||||||
|
} yield {
|
||||||
|
JsonFormat(ApiPullRequest(
|
||||||
|
issue = issue,
|
||||||
|
pullRequest = pullRequest,
|
||||||
|
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
|
||||||
|
baseRepo = ApiRepository(repository, ApiUser(baseOwner)),
|
||||||
|
user = ApiUser(issueUser),
|
||||||
|
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||||
|
))
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/pulls/:id/commits")(referrersOnly { repository =>
|
||||||
|
val owner = repository.owner
|
||||||
|
val name = repository.name
|
||||||
|
params("id").toIntOpt.flatMap{ issueId =>
|
||||||
|
getPullRequest(owner, name, issueId) map { case(issue, pullreq) =>
|
||||||
|
using(Git.open(getRepositoryDir(owner, name))){ git =>
|
||||||
|
val oldId = git.getRepository.resolve(pullreq.commitIdFrom)
|
||||||
|
val newId = git.getRepository.resolve(pullreq.commitIdTo)
|
||||||
|
val repoFullName = RepositoryName(repository)
|
||||||
|
val commits = git.log.addRange(oldId, newId).call.iterator.asScala.map { c => ApiCommitListItem(new CommitInfo(c), repoFullName) }.toList
|
||||||
|
JsonFormat(commits)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/#get
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository")(referrersOnly { repository =>
|
||||||
|
JsonFormat(ApiRepository(repository, ApiUser(getAccountByUserName(repository.owner).get)))
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/statuses/#create-a-status
|
||||||
|
*/
|
||||||
|
post("/api/v3/repos/:owner/:repo/statuses/:sha")(writableUsersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
ref <- params.get("sha")
|
||||||
|
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
||||||
|
data <- extractFromJsonBody[CreateAStatus] if data.isValid
|
||||||
|
creator <- context.loginAccount
|
||||||
|
state <- CommitState.valueOf(data.state)
|
||||||
|
statusId = createCommitStatus(repository.owner, repository.name, sha, data.context.getOrElse("default"),
|
||||||
|
state, data.target_url, data.description, new java.util.Date(), creator)
|
||||||
|
status <- getCommitStatus(repository.owner, repository.name, statusId)
|
||||||
|
} yield {
|
||||||
|
JsonFormat(ApiCommitStatus(status, ApiUser(creator)))
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref
|
||||||
|
*
|
||||||
|
* ref is Ref to list the statuses from. It can be a SHA, a branch name, or a tag name.
|
||||||
|
*/
|
||||||
|
val listStatusesRoute = get("/api/v3/repos/:owner/:repo/commits/:ref/statuses")(referrersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
ref <- params.get("ref")
|
||||||
|
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
||||||
|
} yield {
|
||||||
|
JsonFormat(getCommitStatuesWithCreator(repository.owner, repository.name, sha).map{ case(status, creator) =>
|
||||||
|
ApiCommitStatus(status, ApiUser(creator))
|
||||||
|
})
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref
|
||||||
|
*
|
||||||
|
* legacy route
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repo/statuses/:ref"){
|
||||||
|
listStatusesRoute.action()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
|
||||||
|
*
|
||||||
|
* ref is Ref to list the statuses from. It can be a SHA, a branch name, or a tag name.
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repo/commits/:ref/status")(referrersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
ref <- params.get("ref")
|
||||||
|
owner <- getAccountByUserName(repository.owner)
|
||||||
|
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
||||||
|
} yield {
|
||||||
|
val statuses = getCommitStatuesWithCreator(repository.owner, repository.name, sha)
|
||||||
|
JsonFormat(ApiCombinedCommitStatus(sha, statuses, ApiRepository(repository, owner)))
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean =
|
||||||
|
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -8,8 +8,7 @@ import gitbucket.core.util.Directory._
|
|||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
|
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.apache.commons.io.FileUtils
|
|
||||||
import org.json4s._
|
import org.json4s._
|
||||||
import org.scalatra._
|
import org.scalatra._
|
||||||
import org.scalatra.i18n._
|
import org.scalatra.i18n._
|
||||||
@@ -20,6 +19,8 @@ import javax.servlet.{FilterChain, ServletResponse, ServletRequest}
|
|||||||
|
|
||||||
import scala.util.Try
|
import scala.util.Try
|
||||||
|
|
||||||
|
import net.coobird.thumbnailator.Thumbnails
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides generic features for controller implementations.
|
* Provides generic features for controller implementations.
|
||||||
@@ -28,7 +29,11 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
with ClientSideValidationFormSupport with JacksonJsonSupport with I18nSupport with FlashMapSupport with Validations
|
with ClientSideValidationFormSupport with JacksonJsonSupport with I18nSupport with FlashMapSupport with Validations
|
||||||
with SystemSettingsService {
|
with SystemSettingsService {
|
||||||
|
|
||||||
implicit val jsonFormats = DefaultFormats
|
implicit val jsonFormats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||||
|
|
||||||
|
before("/api/v3/*") {
|
||||||
|
contentType = formats("json")
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Scala 2.11
|
// TODO Scala 2.11
|
||||||
// // Don't set content type via Accept header.
|
// // Don't set content type via Accept header.
|
||||||
@@ -53,7 +58,7 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
// Redirect to dashboard
|
// Redirect to dashboard
|
||||||
httpResponse.sendRedirect(baseUrl + "/")
|
httpResponse.sendRedirect(baseUrl + "/")
|
||||||
}
|
}
|
||||||
} else if(path.startsWith("/git/")){
|
} else if(path.startsWith("/git/") || path.startsWith("/git-lfs/")){
|
||||||
// Git repository
|
// Git repository
|
||||||
chain.doFilter(request, response)
|
chain.doFilter(request, response)
|
||||||
} else {
|
} else {
|
||||||
@@ -176,7 +181,6 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
* Context object for the current request.
|
* Context object for the current request.
|
||||||
*/
|
*/
|
||||||
case class Context(settings: SystemSettingsService.SystemSettings, loginAccount: Option[Account], request: HttpServletRequest){
|
case class Context(settings: SystemSettingsService.SystemSettings, loginAccount: Option[Account], request: HttpServletRequest){
|
||||||
|
|
||||||
val path = settings.baseUrl.getOrElse(request.getContextPath)
|
val path = settings.baseUrl.getOrElse(request.getContextPath)
|
||||||
val currentPath = request.getRequestURI.substring(request.getContextPath.length)
|
val currentPath = request.getRequestURI.substring(request.getContextPath.length)
|
||||||
val baseUrl = settings.baseUrl(request)
|
val baseUrl = settings.baseUrl(request)
|
||||||
@@ -188,6 +192,7 @@ case class Context(settings: SystemSettingsService.SystemSettings, loginAccount:
|
|||||||
case agent if agent.contains("Win") => "windows"
|
case agent if agent.contains("Win") => "windows"
|
||||||
case _ => null
|
case _ => null
|
||||||
}
|
}
|
||||||
|
val sidebarCollapse = request.getSession.getAttribute("sidebar-collapse") != null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get object from cache.
|
* Get object from cache.
|
||||||
@@ -221,10 +226,13 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
} else {
|
} else {
|
||||||
fileId.map { fileId =>
|
fileId.map { 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)
|
||||||
FileUtils.moveFile(
|
val uploadDir = getUserUploadDir(userName)
|
||||||
new java.io.File(getTemporaryDir(session.getId), fileId),
|
if(!uploadDir.exists){
|
||||||
new java.io.File(getUserUploadDir(userName), filename)
|
uploadDir.mkdirs()
|
||||||
)
|
}
|
||||||
|
Thumbnails.of(new java.io.File(getTemporaryDir(session.getId), fileId))
|
||||||
|
.size(324, 324)
|
||||||
|
.toFile(new java.io.File(uploadDir, filename))
|
||||||
updateAvatarImage(userName, Some(filename))
|
updateAvatarImage(userName, Some(filename))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,4 +249,13 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
.map { _ => "Mail address is already registered." }
|
.map { _ => "Mail address is already registered." }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val allReservedNames = Set("git", "admin", "upload", "api")
|
||||||
|
protected def reservedNames(): Constraint = new Constraint(){
|
||||||
|
override def validate(name: String, value: String, messages: Messages): Option[String] = if(allReservedNames.contains(value)){
|
||||||
|
Some(s"${value} is reserved")
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.dashboard.html
|
import gitbucket.core.dashboard.html
|
||||||
import gitbucket.core.service.{RepositoryService, PullRequestService, AccountService, IssuesService}
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.{StringUtil, 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._
|
||||||
|
|
||||||
class DashboardController extends DashboardControllerBase
|
class DashboardController extends DashboardControllerBase
|
||||||
with IssuesService with PullRequestService with RepositoryService with AccountService
|
with IssuesService with PullRequestService with RepositoryService with AccountService with CommitsService
|
||||||
with UsersAuthenticator
|
with UsersAuthenticator
|
||||||
|
|
||||||
trait DashboardControllerBase extends ControllerBase {
|
trait DashboardControllerBase extends ControllerBase {
|
||||||
@@ -15,20 +15,7 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
with UsersAuthenticator =>
|
with UsersAuthenticator =>
|
||||||
|
|
||||||
get("/dashboard/issues")(usersOnly {
|
get("/dashboard/issues")(usersOnly {
|
||||||
val q = request.getParameter("q")
|
|
||||||
val account = context.loginAccount.get
|
|
||||||
Option(q).map { q =>
|
|
||||||
val condition = IssueSearchCondition(q, Map[String, Int]())
|
|
||||||
q match {
|
|
||||||
case q if(q.contains("is:pr")) => redirect(s"/dashboard/pulls?q=${StringUtil.urlEncode(q)}")
|
|
||||||
case q if(q.contains(s"author:${account.userName}")) => redirect(s"/dashboard/issues/created_by${condition.toURL}")
|
|
||||||
case q if(q.contains(s"assignee:${account.userName}")) => redirect(s"/dashboard/issues/assigned${condition.toURL}")
|
|
||||||
case q if(q.contains(s"mentions:${account.userName}")) => redirect(s"/dashboard/issues/mentioned${condition.toURL}")
|
|
||||||
case _ => searchIssues("created_by")
|
|
||||||
}
|
|
||||||
} getOrElse {
|
|
||||||
searchIssues("created_by")
|
searchIssues("created_by")
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/issues/assigned")(usersOnly {
|
get("/dashboard/issues/assigned")(usersOnly {
|
||||||
@@ -44,20 +31,7 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/pulls")(usersOnly {
|
get("/dashboard/pulls")(usersOnly {
|
||||||
val q = request.getParameter("q")
|
|
||||||
val account = context.loginAccount.get
|
|
||||||
Option(q).map { q =>
|
|
||||||
val condition = IssueSearchCondition(q, Map[String, Int]())
|
|
||||||
q match {
|
|
||||||
case q if(q.contains("is:issue")) => redirect(s"/dashboard/issues?q=${StringUtil.urlEncode(q)}")
|
|
||||||
case q if(q.contains(s"author:${account.userName}")) => redirect(s"/dashboard/pulls/created_by${condition.toURL}")
|
|
||||||
case q if(q.contains(s"assignee:${account.userName}")) => redirect(s"/dashboard/pulls/assigned${condition.toURL}")
|
|
||||||
case q if(q.contains(s"mentions:${account.userName}")) => redirect(s"/dashboard/pulls/mentioned${condition.toURL}")
|
|
||||||
case _ => searchPullRequests("created_by")
|
|
||||||
}
|
|
||||||
} getOrElse {
|
|
||||||
searchPullRequests("created_by")
|
searchPullRequests("created_by")
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/pulls/created_by")(usersOnly {
|
get("/dashboard/pulls/created_by")(usersOnly {
|
||||||
@@ -73,19 +47,12 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
private def getOrCreateCondition(key: String, filter: String, userName: String) = {
|
private def getOrCreateCondition(key: String, filter: String, userName: String) = {
|
||||||
val condition = session.putAndGet(key, if(request.hasQueryString){
|
val condition = IssueSearchCondition(request)
|
||||||
val q = request.getParameter("q")
|
|
||||||
if(q == null){
|
|
||||||
IssueSearchCondition(request)
|
|
||||||
} else {
|
|
||||||
IssueSearchCondition(q, Map[String, Int]())
|
|
||||||
}
|
|
||||||
} else session.getAs[IssueSearchCondition](key).getOrElse(IssueSearchCondition()))
|
|
||||||
|
|
||||||
filter match {
|
filter match {
|
||||||
case "assigned" => condition.copy(assigned = Some(userName), author = None , mentioned = None)
|
case "assigned" => condition.copy(assigned = Some(Some(userName)), author = None, mentioned = None)
|
||||||
case "mentioned" => condition.copy(assigned = None , author = None , mentioned = Some(userName))
|
case "mentioned" => condition.copy(assigned = None, author = None, mentioned = Some(userName))
|
||||||
case _ => condition.copy(assigned = None , author = Some(userName), mentioned = None)
|
case _ => condition.copy(assigned = None, author = Some(userName), mentioned = None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +61,7 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
val userName = context.loginAccount.get.userName
|
val userName = context.loginAccount.get.userName
|
||||||
val condition = getOrCreateCondition(Keys.Session.DashboardIssues, filter, userName)
|
val condition = getOrCreateCondition(Keys.Session.DashboardIssues, filter, userName)
|
||||||
val userRepos = getUserRepositories(userName, context.baseUrl, 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)
|
||||||
|
|
||||||
html.issues(
|
html.issues(
|
||||||
@@ -103,12 +70,14 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
countIssue(condition.copy(state = "open" ), false, userRepos: _*),
|
countIssue(condition.copy(state = "open" ), false, userRepos: _*),
|
||||||
countIssue(condition.copy(state = "closed"), false, userRepos: _*),
|
countIssue(condition.copy(state = "closed"), false, userRepos: _*),
|
||||||
filter match {
|
filter match {
|
||||||
case "assigned" => condition.copy(assigned = Some(userName))
|
case "assigned" => condition.copy(assigned = Some(Some(userName)))
|
||||||
case "mentioned" => condition.copy(mentioned = Some(userName))
|
case "mentioned" => condition.copy(mentioned = Some(userName))
|
||||||
case _ => condition.copy(author = Some(userName))
|
case _ => condition.copy(author = Some(userName))
|
||||||
},
|
},
|
||||||
filter,
|
filter,
|
||||||
getGroupNames(userName))
|
getGroupNames(userName),
|
||||||
|
Nil,
|
||||||
|
getUserRepositories(userName, withoutPhysicalInfo = true))
|
||||||
}
|
}
|
||||||
|
|
||||||
private def searchPullRequests(filter: String) = {
|
private def searchPullRequests(filter: String) = {
|
||||||
@@ -126,12 +95,14 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
countIssue(condition.copy(state = "open" ), true, allRepos: _*),
|
countIssue(condition.copy(state = "open" ), true, allRepos: _*),
|
||||||
countIssue(condition.copy(state = "closed"), true, allRepos: _*),
|
countIssue(condition.copy(state = "closed"), true, allRepos: _*),
|
||||||
filter match {
|
filter match {
|
||||||
case "assigned" => condition.copy(assigned = Some(userName))
|
case "assigned" => condition.copy(assigned = Some(Some(userName)))
|
||||||
case "mentioned" => condition.copy(mentioned = Some(userName))
|
case "mentioned" => condition.copy(mentioned = Some(userName))
|
||||||
case _ => condition.copy(author = Some(userName))
|
case _ => condition.copy(author = Some(userName))
|
||||||
},
|
},
|
||||||
filter,
|
filter,
|
||||||
getGroupNames(userName))
|
getGroupNames(userName),
|
||||||
|
Nil,
|
||||||
|
getUserRepositories(userName, withoutPhysicalInfo = true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,25 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.util.{Keys, FileUtil}
|
import gitbucket.core.model.Account
|
||||||
|
import gitbucket.core.service.{AccountService, RepositoryService}
|
||||||
|
import gitbucket.core.servlet.Database
|
||||||
|
import gitbucket.core.util._
|
||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
|
import gitbucket.core.util.Implicits._
|
||||||
|
import org.eclipse.jgit.api.Git
|
||||||
|
import org.eclipse.jgit.dircache.DirCache
|
||||||
|
import org.eclipse.jgit.lib.{FileMode, Constants}
|
||||||
import org.scalatra._
|
import org.scalatra._
|
||||||
import org.scalatra.servlet.{MultipartConfig, FileUploadSupport, FileItem}
|
import org.scalatra.servlet.{MultipartConfig, FileUploadSupport, FileItem}
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.{IOUtils, FileUtils}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Ajax based file upload functionality.
|
* Provides Ajax based file upload functionality.
|
||||||
*
|
*
|
||||||
* This servlet saves uploaded file.
|
* This servlet saves uploaded file.
|
||||||
*/
|
*/
|
||||||
class FileUploadController extends ScalatraServlet with FileUploadSupport {
|
class FileUploadController extends ScalatraServlet with FileUploadSupport with RepositoryService with AccountService {
|
||||||
|
|
||||||
configureMultipartHandling(MultipartConfig(maxFileSize = Some(3 * 1024 * 1024)))
|
configureMultipartHandling(MultipartConfig(maxFileSize = Some(3 * 1024 * 1024)))
|
||||||
|
|
||||||
@@ -31,14 +38,71 @@ class FileUploadController extends ScalatraServlet with FileUploadSupport {
|
|||||||
}, FileUtil.isUploadableType)
|
}, FileUtil.isUploadableType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post("/wiki/:owner/:repository"){
|
||||||
|
// Don't accept not logged-in users
|
||||||
|
session.get(Keys.Session.LoginAccount).collect { case loginAccount: Account =>
|
||||||
|
val owner = params("owner")
|
||||||
|
val repository = params("repository")
|
||||||
|
|
||||||
|
// Check whether logged-in user is collaborator
|
||||||
|
collaboratorsOnly(owner, repository, loginAccount){
|
||||||
|
execute({ (file, fileId) =>
|
||||||
|
val fileName = file.getName
|
||||||
|
LockUtil.lock(s"${owner}/${repository}/wiki") {
|
||||||
|
using(Git.open(Directory.getWikiRepositoryDir(owner, repository))) { git =>
|
||||||
|
val builder = DirCache.newInCore.builder()
|
||||||
|
val inserter = git.getRepository.newObjectInserter()
|
||||||
|
val headId = git.getRepository.resolve(Constants.HEAD + "^{commit}")
|
||||||
|
|
||||||
|
if(headId != null){
|
||||||
|
JGitUtil.processTree(git, headId){ (path, tree) =>
|
||||||
|
if(path != fileName){
|
||||||
|
builder.add(JGitUtil.createDirCacheEntry(path, tree.getEntryFileMode, tree.getEntryObjectId))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val bytes = IOUtils.toByteArray(file.getInputStream)
|
||||||
|
builder.add(JGitUtil.createDirCacheEntry(fileName, FileMode.REGULAR_FILE, inserter.insert(Constants.OBJ_BLOB, bytes)))
|
||||||
|
builder.finish()
|
||||||
|
|
||||||
|
val newHeadId = JGitUtil.createNewCommit(git, inserter, headId, builder.getDirCache.writeTree(inserter),
|
||||||
|
Constants.HEAD, loginAccount.userName, loginAccount.mailAddress, s"Uploaded ${fileName}")
|
||||||
|
|
||||||
|
fileName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, FileUtil.isUploadableType)
|
||||||
|
}
|
||||||
|
} getOrElse BadRequest()
|
||||||
|
}
|
||||||
|
|
||||||
|
post("/import") {
|
||||||
|
import JDBCUtil._
|
||||||
|
session.get(Keys.Session.LoginAccount).collect { case loginAccount: Account if loginAccount.isAdmin =>
|
||||||
|
execute({ (file, fileId) =>
|
||||||
|
request2Session(request).conn.importAsSQL(file.getInputStream)
|
||||||
|
}, _ => true)
|
||||||
|
}
|
||||||
|
redirect("/admin/data")
|
||||||
|
}
|
||||||
|
|
||||||
|
private def collaboratorsOnly(owner: String, repository: String, loginAccount: Account)(action: => Any): Any = {
|
||||||
|
implicit val session = Database.getSession(request)
|
||||||
|
loginAccount match {
|
||||||
|
case x if(x.isAdmin) => action
|
||||||
|
case x if(getCollaborators(owner, repository).contains(x.userName)) => action
|
||||||
|
case _ => BadRequest()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private def execute(f: (FileItem, String) => Unit, mimeTypeChcker: (String) => Boolean) = fileParams.get("file") match {
|
private def execute(f: (FileItem, String) => Unit, mimeTypeChcker: (String) => Boolean) = fileParams.get("file") match {
|
||||||
case Some(file) if(mimeTypeChcker(file.name)) =>
|
case Some(file) if(mimeTypeChcker(file.name)) =>
|
||||||
defining(FileUtil.generateFileId){ fileId =>
|
defining(FileUtil.generateFileId){ fileId =>
|
||||||
f(file, fileId)
|
f(file, fileId)
|
||||||
|
|
||||||
Ok(fileId)
|
Ok(fileId)
|
||||||
}
|
}
|
||||||
case _ => BadRequest
|
case _ => BadRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +1,46 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.api._
|
|
||||||
import gitbucket.core.helper.xml
|
import gitbucket.core.helper.xml
|
||||||
import gitbucket.core.html
|
|
||||||
import gitbucket.core.model.Account
|
import gitbucket.core.model.Account
|
||||||
import gitbucket.core.service.{RepositoryService, ActivityService, AccountService}
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.{LDAPUtil, Keys, UsersAuthenticator}
|
import gitbucket.core.util.ControlUtil._
|
||||||
|
import gitbucket.core.util.{Keys, LDAPUtil, ReferrerAuthenticator, UsersAuthenticator}
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
|
import org.scalatra.Ok
|
||||||
|
|
||||||
|
|
||||||
class IndexController extends IndexControllerBase
|
class IndexController extends IndexControllerBase
|
||||||
with RepositoryService with ActivityService with AccountService with UsersAuthenticator
|
with RepositoryService with ActivityService with AccountService with RepositorySearchService with IssuesService
|
||||||
|
with UsersAuthenticator with ReferrerAuthenticator
|
||||||
|
|
||||||
|
|
||||||
trait IndexControllerBase extends ControllerBase {
|
trait IndexControllerBase extends ControllerBase {
|
||||||
self: RepositoryService with ActivityService with AccountService with UsersAuthenticator =>
|
self: RepositoryService with ActivityService with AccountService with RepositorySearchService
|
||||||
|
with UsersAuthenticator with ReferrerAuthenticator =>
|
||||||
|
|
||||||
case class SignInForm(userName: String, password: String)
|
case class SignInForm(userName: String, password: String)
|
||||||
|
|
||||||
val form = mapping(
|
val signinForm = mapping(
|
||||||
"userName" -> trim(label("Username", text(required))),
|
"userName" -> trim(label("Username", text(required))),
|
||||||
"password" -> trim(label("Password", text(required)))
|
"password" -> trim(label("Password", text(required)))
|
||||||
)(SignInForm.apply)
|
)(SignInForm.apply)
|
||||||
|
|
||||||
|
val searchForm = mapping(
|
||||||
|
"query" -> trim(text(required)),
|
||||||
|
"owner" -> trim(text(required)),
|
||||||
|
"repository" -> trim(text(required))
|
||||||
|
)(SearchForm.apply)
|
||||||
|
|
||||||
|
case class SearchForm(query: String, owner: String, repository: String)
|
||||||
|
|
||||||
|
|
||||||
get("/"){
|
get("/"){
|
||||||
val loginAccount = context.loginAccount
|
context.loginAccount.map { account =>
|
||||||
if(loginAccount.isEmpty) {
|
val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName)
|
||||||
html.index(getRecentActivities(),
|
gitbucket.core.html.index(getRecentActivitiesByOwners(visibleOwnerSet), Nil, getUserRepositories(account.userName, withoutPhysicalInfo = true))
|
||||||
getVisibleRepositories(loginAccount, context.baseUrl, withoutPhysicalInfo = true),
|
}.getOrElse {
|
||||||
loginAccount.map{ account => getUserRepositories(account.userName, context.baseUrl, withoutPhysicalInfo = true) }.getOrElse(Nil)
|
gitbucket.core.html.index(getRecentActivities(), getVisibleRepositories(None, withoutPhysicalInfo = true), Nil)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
val loginUserName = loginAccount.get.userName
|
|
||||||
val loginUserGroups = getGroupsByUserName(loginUserName)
|
|
||||||
var visibleOwnerSet : Set[String] = Set(loginUserName)
|
|
||||||
|
|
||||||
visibleOwnerSet ++= loginUserGroups
|
|
||||||
|
|
||||||
html.index(getRecentActivitiesByOwners(visibleOwnerSet),
|
|
||||||
getVisibleRepositories(loginAccount, context.baseUrl, withoutPhysicalInfo = true),
|
|
||||||
loginAccount.map{ account => getUserRepositories(account.userName, context.baseUrl, withoutPhysicalInfo = true) }.getOrElse(Nil)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,13 +49,18 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
if(redirect.isDefined && redirect.get.startsWith("/")){
|
if(redirect.isDefined && redirect.get.startsWith("/")){
|
||||||
flash += Keys.Flash.Redirect -> redirect.get
|
flash += Keys.Flash.Redirect -> redirect.get
|
||||||
}
|
}
|
||||||
html.signin()
|
gitbucket.core.html.signin(flash.get("userName"), flash.get("password"), flash.get("error"))
|
||||||
}
|
}
|
||||||
|
|
||||||
post("/signin", form){ form =>
|
post("/signin", signinForm){ form =>
|
||||||
authenticate(context.settings, form.userName, form.password) match {
|
authenticate(context.settings, form.userName, form.password) match {
|
||||||
case Some(account) => signin(account)
|
case Some(account) => signin(account)
|
||||||
case None => redirect("/signin")
|
case None => {
|
||||||
|
flash += "userName" -> form.userName
|
||||||
|
flash += "password" -> form.password
|
||||||
|
flash += "error" -> "Sorry, your Username and/or Password is incorrect. Please try again."
|
||||||
|
redirect("/signin")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +74,15 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
xml.feed(getRecentActivities())
|
xml.feed(getRecentActivities())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get("/sidebar-collapse"){
|
||||||
|
if(params("collapse") == "true"){
|
||||||
|
session.setAttribute("sidebar-collapse", "true")
|
||||||
|
} else {
|
||||||
|
session.setAttribute("sidebar-collapse", null)
|
||||||
|
}
|
||||||
|
Ok()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set account information into HttpSession and redirect.
|
* Set account information into HttpSession and redirect.
|
||||||
*/
|
*/
|
||||||
@@ -98,25 +110,68 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
get("/_user/proposals")(usersOnly {
|
get("/_user/proposals")(usersOnly {
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
|
val user = params("user").toBoolean
|
||||||
|
val group = params("group").toBoolean
|
||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
Map("options" -> getAllUsers(false).filter(!_.isGroupAccount).map(_.userName).toArray)
|
Map("options" -> (
|
||||||
|
getAllUsers(false)
|
||||||
|
.withFilter { t => (user, group) match {
|
||||||
|
case (true, true) => true
|
||||||
|
case (true, false) => !t.isGroupAccount
|
||||||
|
case (false, true) => t.isGroupAccount
|
||||||
|
case (false, false) => false
|
||||||
|
}}.map { t => t.userName }
|
||||||
|
))
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON APU for checking user existence.
|
* JSON API for checking user or group existence.
|
||||||
|
* Returns a single string which is any of "group", "user" or "".
|
||||||
*/
|
*/
|
||||||
post("/_user/existence")(usersOnly {
|
post("/_user/existence")(usersOnly {
|
||||||
getAccountByUserName(params("userName")).isDefined
|
getAccountByUserName(params("userName")).map { account =>
|
||||||
|
if(account.isGroupAccount) "group" else "user"
|
||||||
|
} getOrElse ""
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
// TODO Move to RepositoryViwerController?
|
||||||
* @see https://developer.github.com/v3/rate_limit/#get-your-current-rate-limit-status
|
get("/:owner/:repository/search")(referrersOnly { repository =>
|
||||||
* but not enabled.
|
defining(params.getOrElse("q", "").trim, params.getOrElse("type", "code")){ case (query, target) =>
|
||||||
*/
|
val page = try {
|
||||||
get("/api/v3/rate_limit"){
|
val i = params.getOrElse("page", "1").toInt
|
||||||
contentType = formats("json")
|
if(i <= 0) 1 else i
|
||||||
// this message is same as github enterprise...
|
} catch {
|
||||||
org.scalatra.NotFound(ApiError("Rate limiting is not enabled."))
|
case e: NumberFormatException => 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target.toLowerCase match {
|
||||||
|
case "issue" => gitbucket.core.search.html.issues(
|
||||||
|
if(query.nonEmpty) searchIssues(repository.owner, repository.name, query) else Nil,
|
||||||
|
query, page, repository)
|
||||||
|
|
||||||
|
case "wiki" => gitbucket.core.search.html.wiki(
|
||||||
|
if(query.nonEmpty) searchWikiPages(repository.owner, repository.name, query) else Nil,
|
||||||
|
query, page, repository)
|
||||||
|
|
||||||
|
case _ => gitbucket.core.search.html.code(
|
||||||
|
if(query.nonEmpty) searchFiles(repository.owner, repository.name, query) else Nil,
|
||||||
|
query, page, repository)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
get("/search"){
|
||||||
|
val query = params.getOrElse("query", "").trim.toLowerCase
|
||||||
|
val visibleRepositories = getVisibleRepositories(context.loginAccount, None)
|
||||||
|
val repositories = visibleRepositories.filter { repository =>
|
||||||
|
repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0
|
||||||
|
}
|
||||||
|
context.loginAccount.map { account =>
|
||||||
|
gitbucket.core.search.html.repositories(query, repositories, Nil, getUserRepositories(account.userName, withoutPhysicalInfo = true))
|
||||||
|
}.getOrElse {
|
||||||
|
gitbucket.core.search.html.repositories(query, repositories, visibleRepositories, Nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.api._
|
|
||||||
import gitbucket.core.issues.html
|
import gitbucket.core.issues.html
|
||||||
import gitbucket.core.model.Issue
|
|
||||||
import gitbucket.core.service.IssuesService._
|
import gitbucket.core.service.IssuesService._
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
@@ -10,18 +8,40 @@ import gitbucket.core.util.Implicits._
|
|||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
import gitbucket.core.view
|
import gitbucket.core.view
|
||||||
import gitbucket.core.view.Markdown
|
import gitbucket.core.view.Markdown
|
||||||
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import org.scalatra.{BadRequest, Ok}
|
||||||
import org.scalatra.Ok
|
|
||||||
|
|
||||||
|
|
||||||
class IssuesController extends IssuesControllerBase
|
class IssuesController extends IssuesControllerBase
|
||||||
with IssuesService with RepositoryService with AccountService with LabelsService with MilestonesService with ActivityService
|
with IssuesService
|
||||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator with PullRequestService with WebHookIssueCommentService
|
with RepositoryService
|
||||||
|
with AccountService
|
||||||
|
with LabelsService
|
||||||
|
with MilestonesService
|
||||||
|
with ActivityService
|
||||||
|
with HandleCommentService
|
||||||
|
with IssueCreationService
|
||||||
|
with ReadableUsersAuthenticator
|
||||||
|
with ReferrerAuthenticator
|
||||||
|
with WritableUsersAuthenticator
|
||||||
|
with PullRequestService
|
||||||
|
with WebHookIssueCommentService
|
||||||
|
with CommitsService
|
||||||
|
|
||||||
trait IssuesControllerBase extends ControllerBase {
|
trait IssuesControllerBase extends ControllerBase {
|
||||||
self: IssuesService with RepositoryService with AccountService with LabelsService with MilestonesService with ActivityService
|
self: IssuesService
|
||||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator with PullRequestService with WebHookIssueCommentService =>
|
with RepositoryService
|
||||||
|
with AccountService
|
||||||
|
with LabelsService
|
||||||
|
with MilestonesService
|
||||||
|
with ActivityService
|
||||||
|
with HandleCommentService
|
||||||
|
with IssueCreationService
|
||||||
|
with ReadableUsersAuthenticator
|
||||||
|
with ReferrerAuthenticator
|
||||||
|
with WritableUsersAuthenticator
|
||||||
|
with PullRequestService
|
||||||
|
with WebHookIssueCommentService =>
|
||||||
|
|
||||||
case class IssueCreateForm(title: String, content: Option[String],
|
case class IssueCreateForm(title: String, content: Option[String],
|
||||||
assignedUserName: Option[String], milestoneId: Option[Int], labelNames: Option[String])
|
assignedUserName: Option[String], milestoneId: Option[Int], labelNames: Option[String])
|
||||||
@@ -69,250 +89,233 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
_,
|
_,
|
||||||
getComments(owner, name, issueId.toInt),
|
getComments(owner, name, issueId.toInt),
|
||||||
getIssueLabels(owner, name, issueId.toInt),
|
getIssueLabels(owner, name, issueId.toInt),
|
||||||
(getCollaborators(owner, name) ::: (if(getAccountByUserName(owner).get.isGroupAccount) Nil else List(owner))).sorted,
|
getAssignableUserNames(owner, name),
|
||||||
getMilestonesWithIssueCount(owner, name),
|
getMilestonesWithIssueCount(owner, name),
|
||||||
getLabels(owner, name),
|
getLabels(owner, name),
|
||||||
hasWritePermission(owner, name, context.loginAccount),
|
isIssueEditable(repository),
|
||||||
|
isIssueManageable(repository),
|
||||||
repository)
|
repository)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
|
||||||
* https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
|
|
||||||
*/
|
|
||||||
get("/api/v3/repos/:owner/:repository/issues/:id/comments")(referrersOnly { repository =>
|
|
||||||
(for{
|
|
||||||
issueId <- params("id").toIntOpt
|
|
||||||
comments = getCommentsForApi(repository.owner, repository.name, issueId.toInt)
|
|
||||||
} yield {
|
|
||||||
JsonFormat(comments.map{ case (issueComment, user, issue) => ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(user), issue.isPullRequest) })
|
|
||||||
}).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?
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
html.create(
|
html.create(
|
||||||
(getCollaborators(owner, name) ::: (if(getAccountByUserName(owner).get.isGroupAccount) Nil else List(owner))).sorted,
|
getAssignableUserNames(owner, name),
|
||||||
getMilestones(owner, name),
|
getMilestones(owner, name),
|
||||||
getLabels(owner, name),
|
getLabels(owner, name),
|
||||||
hasWritePermission(owner, name, context.loginAccount),
|
isIssueManageable(repository),
|
||||||
|
getContentTemplate(repository, "ISSUE_TEMPLATE"),
|
||||||
repository)
|
repository)
|
||||||
}
|
}
|
||||||
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
if(isIssueEditable(repository)){ // TODO Should this check is provided by authenticator?
|
||||||
val writable = hasWritePermission(owner, name, context.loginAccount)
|
val issue = createIssue(
|
||||||
val userName = context.loginAccount.get.userName
|
repository,
|
||||||
|
form.title,
|
||||||
|
form.content,
|
||||||
|
form.assignedUserName,
|
||||||
|
form.milestoneId,
|
||||||
|
form.labelNames.toArray.flatMap(_.split(",")),
|
||||||
|
context.loginAccount.get)
|
||||||
|
|
||||||
// insert issue
|
redirect(s"/${issue.userName}/${issue.repositoryName}/issues/${issue.issueId}")
|
||||||
val issueId = createIssue(owner, name, userName, form.title, form.content,
|
} else Unauthorized()
|
||||||
if(writable) form.assignedUserName else None,
|
|
||||||
if(writable) form.milestoneId else None)
|
|
||||||
|
|
||||||
// insert labels
|
|
||||||
if(writable){
|
|
||||||
form.labelNames.map { value =>
|
|
||||||
val labels = getLabels(owner, name)
|
|
||||||
value.split(",").foreach { labelName =>
|
|
||||||
labels.find(_.labelName == labelName).map { label =>
|
|
||||||
registerIssueLabel(owner, name, issueId, label.labelId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// record activity
|
|
||||||
recordCreateIssueActivity(owner, name, userName, issueId, form.title)
|
|
||||||
|
|
||||||
getIssue(owner, name, issueId.toString).foreach { issue =>
|
|
||||||
// extract references and create refer comment
|
|
||||||
createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse(""))
|
|
||||||
|
|
||||||
// call web hooks
|
|
||||||
callIssuesWebHook("opened", repository, issue, context.baseUrl, context.loginAccount.get)
|
|
||||||
|
|
||||||
// notifications
|
|
||||||
Notifier().toNotify(repository, issue, form.content.getOrElse("")){
|
|
||||||
Notifier.msgIssue(s"${context.baseUrl}/${owner}/${name}/issues/${issueId}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/issues/${issueId}")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
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){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
getIssue(owner, name, params("id")).map { issue =>
|
getIssue(owner, name, params("id")).map { issue =>
|
||||||
if(isEditable(owner, name, issue.openedUserName)){
|
if(isEditableContent(owner, name, issue.openedUserName)){
|
||||||
// update issue
|
// update issue
|
||||||
updateIssue(owner, name, issue.issueId, title, issue.content)
|
updateIssue(owner, 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)
|
createReferComment(owner, name, issue.copy(title = title), title, context.loginAccount.get)
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
|
redirect(s"/${owner}/${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){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
getIssue(owner, name, params("id")).map { issue =>
|
getIssue(owner, name, params("id")).map { issue =>
|
||||||
if(isEditable(owner, name, issue.openedUserName)){
|
if(isEditableContent(owner, name, issue.openedUserName)){
|
||||||
// update issue
|
// update issue
|
||||||
updateIssue(owner, name, issue.issueId, issue.title, content)
|
updateIssue(owner, name, issue.issueId, issue.title, content)
|
||||||
// extract references and create refer comment
|
// extract references and create refer comment
|
||||||
createReferComment(owner, name, issue, content.getOrElse(""))
|
createReferComment(owner, name, issue, content.getOrElse(""), context.loginAccount.get)
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
|
redirect(s"/${owner}/${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) =>
|
||||||
handleComment(form.issueId, Some(form.content), repository)() map { case (issue, id) =>
|
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
||||||
|
val actionOpt = params.get("action").filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName))
|
||||||
|
handleComment(issue, Some(form.content), repository, actionOpt) map { case (issue, id) =>
|
||||||
redirect(s"/${repository.owner}/${repository.name}/${
|
redirect(s"/${repository.owner}/${repository.name}/${
|
||||||
if(issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}")
|
if(issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}")
|
||||||
} getOrElse NotFound
|
}
|
||||||
})
|
} getOrElse NotFound()
|
||||||
|
|
||||||
/**
|
|
||||||
* https://developer.github.com/v3/issues/comments/#create-a-comment
|
|
||||||
*/
|
|
||||||
post("/api/v3/repos/:owner/:repository/issues/:id/comments")(readableUsersOnly { repository =>
|
|
||||||
(for{
|
|
||||||
issueId <- params("id").toIntOpt
|
|
||||||
body <- extractFromJsonBody[CreateAComment].map(_.body) if ! body.isEmpty
|
|
||||||
(issue, id) <- handleComment(issueId, Some(body), repository)()
|
|
||||||
issueComment <- getComment(repository.owner, repository.name, id.toString())
|
|
||||||
} yield {
|
|
||||||
JsonFormat(ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(context.loginAccount.get), issue.isPullRequest))
|
|
||||||
}) getOrElse NotFound
|
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issue_comments/state", issueStateForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issue_comments/state", issueStateForm)(readableUsersOnly { (form, repository) =>
|
||||||
handleComment(form.issueId, form.content, repository)() map { case (issue, id) =>
|
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
||||||
|
val actionOpt = params.get("action").filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName))
|
||||||
|
handleComment(issue, form.content, repository, actionOpt) map { case (issue, id) =>
|
||||||
redirect(s"/${repository.owner}/${repository.name}/${
|
redirect(s"/${repository.owner}/${repository.name}/${
|
||||||
if(issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}")
|
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){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
getComment(owner, name, params("id")).map { comment =>
|
getComment(owner, name, params("id")).map { comment =>
|
||||||
if(isEditable(owner, name, comment.commentedUserName)){
|
if(isEditableContent(owner, name, comment.commentedUserName)){
|
||||||
updateComment(comment.commentId, form.content)
|
updateComment(comment.commentId, form.content)
|
||||||
redirect(s"/${owner}/${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){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
getComment(owner, name, params("id")).map { comment =>
|
getComment(owner, name, params("id")).map { comment =>
|
||||||
if(isEditable(owner, name, comment.commentedUserName)){
|
if(isEditableContent(owner, name, comment.commentedUserName)){
|
||||||
Ok(deleteComment(comment.commentId))
|
Ok(deleteComment(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 { x =>
|
getIssue(repository.owner, repository.name, params("id")) map { x =>
|
||||||
if(isEditable(x.userName, x.repositoryName, x.openedUserName)){
|
if(isEditableContent(x.userName, x.repositoryName, x.openedUserName)){
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editissue(
|
case t if t == "html" => html.editissue(x.content, x.issueId, repository)
|
||||||
x.content, x.issueId, x.userName, x.repositoryName)
|
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
Map("title" -> x.title,
|
Map(
|
||||||
"content" -> Markdown.toHtml(x.content getOrElse "No description given.",
|
"title" -> x.title,
|
||||||
repository, false, true, true, true, isEditable(x.userName, x.repositoryName, x.openedUserName))
|
"content" -> Markdown.toHtml(
|
||||||
))
|
markdown = x.content getOrElse "No description given.",
|
||||||
|
repository = repository,
|
||||||
|
enableWikiLink = false,
|
||||||
|
enableRefsLink = true,
|
||||||
|
enableAnchor = true,
|
||||||
|
enableLineBreaks = true,
|
||||||
|
enableTaskList = true,
|
||||||
|
hasWritePermission = true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} 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 { x =>
|
getComment(repository.owner, repository.name, params("id")) map { x =>
|
||||||
if(isEditable(x.userName, x.repositoryName, x.commentedUserName)){
|
if(isEditableContent(x.userName, x.repositoryName, x.commentedUserName)){
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editcomment(
|
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
|
||||||
x.content, x.commentId, x.userName, x.repositoryName)
|
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
Map("content" -> view.Markdown.toHtml(x.content,
|
Map(
|
||||||
repository, false, true, true, isEditable(x.userName, x.repositoryName, x.commentedUserName))
|
"content" -> view.Markdown.toHtml(
|
||||||
))
|
markdown = x.content,
|
||||||
|
repository = repository,
|
||||||
|
enableWikiLink = false,
|
||||||
|
enableRefsLink = true,
|
||||||
|
enableAnchor = true,
|
||||||
|
enableLineBreaks = true,
|
||||||
|
enableTaskList = true,
|
||||||
|
hasWritePermission = true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/new/label")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/new/label")(writableUsersOnly { repository =>
|
||||||
val labelNames = params("labelNames").split(",")
|
val labelNames = params("labelNames").split(",")
|
||||||
val labels = getLabels(repository.owner, repository.name).filter(x => labelNames.contains(x.labelName))
|
val labels = getLabels(repository.owner, repository.name).filter(x => labelNames.contains(x.labelName))
|
||||||
html.labellist(labels)
|
html.labellist(labels)
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/label/new")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/label/new")(writableUsersOnly { repository =>
|
||||||
defining(params("id").toInt){ issueId =>
|
defining(params("id").toInt){ issueId =>
|
||||||
registerIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt)
|
registerIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt)
|
||||||
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/label/delete")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/label/delete")(writableUsersOnly { repository =>
|
||||||
defining(params("id").toInt){ issueId =>
|
defining(params("id").toInt){ issueId =>
|
||||||
deleteIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt)
|
deleteIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt)
|
||||||
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/assign")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/assign")(writableUsersOnly { repository =>
|
||||||
updateAssignedUserName(repository.owner, repository.name, params("id").toInt, assignedUserName("assignedUserName"))
|
updateAssignedUserName(repository.owner, repository.name, params("id").toInt, assignedUserName("assignedUserName"))
|
||||||
Ok("updated")
|
Ok("updated")
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/milestone")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/milestone")(writableUsersOnly { repository =>
|
||||||
updateMilestoneId(repository.owner, repository.name, params("id").toInt, milestoneId("milestoneId"))
|
updateMilestoneId(repository.owner, repository.name, params("id").toInt, milestoneId("milestoneId"))
|
||||||
milestoneId("milestoneId").map { milestoneId =>
|
milestoneId("milestoneId").map { milestoneId =>
|
||||||
getMilestonesWithIssueCount(repository.owner, repository.name)
|
getMilestonesWithIssueCount(repository.owner, repository.name)
|
||||||
.find(_._1.milestoneId == milestoneId).map { case (_, openCount, closeCount) =>
|
.find(_._1.milestoneId == milestoneId).map { 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()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/state")(collaboratorsOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/state")(writableUsersOnly { repository =>
|
||||||
defining(params.get("value")){ action =>
|
defining(params.get("value")){ action =>
|
||||||
action match {
|
action match {
|
||||||
case Some("open") => executeBatch(repository) { handleComment(_, None, repository)( _ => Some("reopen")) }
|
case Some("open") => executeBatch(repository) { issueId =>
|
||||||
case Some("close") => executeBatch(repository) { handleComment(_, None, repository)( _ => Some("close")) }
|
getIssue(repository.owner, repository.name, issueId.toString).foreach { issue =>
|
||||||
case _ => // TODO BadRequest
|
handleComment(issue, None, repository, Some("reopen"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case Some("close") => executeBatch(repository) { issueId =>
|
||||||
|
getIssue(repository.owner, repository.name, issueId.toString).foreach { issue =>
|
||||||
|
handleComment(issue, None, repository, Some("close"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case _ => BadRequest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/label")(collaboratorsOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/label")(writableUsersOnly { repository =>
|
||||||
params("value").toIntOpt.map{ labelId =>
|
params("value").toIntOpt.map{ labelId =>
|
||||||
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)
|
registerIssueLabel(repository.owner, repository.name, issueId, labelId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/assign")(collaboratorsOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/assign")(writableUsersOnly { repository =>
|
||||||
defining(assignedUserName("value")){ value =>
|
defining(assignedUserName("value")){ value =>
|
||||||
executeBatch(repository) {
|
executeBatch(repository) {
|
||||||
updateAssignedUserName(repository.owner, repository.name, _, value)
|
updateAssignedUserName(repository.owner, repository.name, _, value)
|
||||||
@@ -320,7 +323,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/milestone")(collaboratorsOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/milestone")(writableUsersOnly { repository =>
|
||||||
defining(milestoneId("value")){ value =>
|
defining(milestoneId("value")){ value =>
|
||||||
executeBatch(repository) {
|
executeBatch(repository) {
|
||||||
updateMilestoneId(repository.owner, repository.name, _, value)
|
updateMilestoneId(repository.owner, repository.name, _, value)
|
||||||
@@ -336,15 +339,12 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
RawData(FileUtil.getMimeType(file.getName), file)
|
RawData(FileUtil.getMimeType(file.getName), file)
|
||||||
}
|
}
|
||||||
case _ => None
|
case _ => None
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean =
|
|
||||||
hasWritePermission(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
|
||||||
|
|
||||||
private def executeBatch(repository: RepositoryService.RepositoryInfo)(execute: Int => Unit) = {
|
private def executeBatch(repository: RepositoryService.RepositoryInfo)(execute: Int => Unit) = {
|
||||||
params("checked").split(',') map(_.toInt) foreach execute
|
params("checked").split(',') map(_.toInt) foreach execute
|
||||||
params("from") match {
|
params("from") match {
|
||||||
@@ -353,132 +353,33 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Same method exists in PullRequestController. Should it moved to IssueService?
|
|
||||||
private def createReferComment(owner: String, repository: String, fromIssue: Issue, message: String) = {
|
|
||||||
StringUtil.extractIssueId(message).foreach { issueId =>
|
|
||||||
val content = fromIssue.issueId + ":" + fromIssue.title
|
|
||||||
if(getIssue(owner, repository, issueId).isDefined){
|
|
||||||
// Not add if refer comment already exist.
|
|
||||||
if(!getComments(owner, repository, issueId.toInt).exists { x => x.action == "refer" && x.content == content }) {
|
|
||||||
createComment(owner, repository, context.loginAccount.get.userName, issueId.toInt, content, "refer")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see [[https://github.com/takezoe/gitbucket/wiki/CommentAction]]
|
|
||||||
*/
|
|
||||||
private def handleComment(issueId: Int, content: Option[String], repository: RepositoryService.RepositoryInfo)
|
|
||||||
(getAction: Issue => Option[String] =
|
|
||||||
p1 => params.get("action").filter(_ => isEditable(p1.userName, p1.repositoryName, p1.openedUserName))) = {
|
|
||||||
|
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
|
||||||
val userName = context.loginAccount.get.userName
|
|
||||||
|
|
||||||
getIssue(owner, name, issueId.toString) flatMap { issue =>
|
|
||||||
val (action, recordActivity) =
|
|
||||||
getAction(issue)
|
|
||||||
.collect {
|
|
||||||
case "close" if(!issue.closed) => true ->
|
|
||||||
(Some("close") -> Some(if(issue.isPullRequest) recordClosePullRequestActivity _ else recordCloseIssueActivity _))
|
|
||||||
case "reopen" if(issue.closed) => false ->
|
|
||||||
(Some("reopen") -> Some(recordReopenIssueActivity _))
|
|
||||||
}
|
|
||||||
.map { case (closed, t) =>
|
|
||||||
updateClosed(owner, name, issueId, closed)
|
|
||||||
t
|
|
||||||
}
|
|
||||||
.getOrElse(None -> None)
|
|
||||||
|
|
||||||
val commentId = (content, action) match {
|
|
||||||
case (None, None) => None
|
|
||||||
case (None, Some(action)) => Some(createComment(owner, name, userName, issueId, action.capitalize, action))
|
|
||||||
case (Some(content), _) => Some(createComment(owner, name, userName, issueId, content, action.map(_+ "_comment").getOrElse("comment")))
|
|
||||||
}
|
|
||||||
|
|
||||||
// record comment activity if comment is entered
|
|
||||||
content foreach {
|
|
||||||
(if(issue.isPullRequest) recordCommentPullRequestActivity _ else recordCommentIssueActivity _)
|
|
||||||
(owner, name, userName, issueId, _)
|
|
||||||
}
|
|
||||||
recordActivity foreach ( _ (owner, name, userName, issueId, issue.title) )
|
|
||||||
|
|
||||||
// extract references and create refer comment
|
|
||||||
content.map { content =>
|
|
||||||
createReferComment(owner, name, issue, content)
|
|
||||||
}
|
|
||||||
|
|
||||||
// call web hooks
|
|
||||||
action match {
|
|
||||||
case None => commentId.map{ commentIdSome => callIssueCommentWebHook(repository, issue, commentIdSome, context.loginAccount.get) }
|
|
||||||
case Some(act) => val webHookAction = act match {
|
|
||||||
case "open" => "opened"
|
|
||||||
case "reopen" => "reopened"
|
|
||||||
case "close" => "closed"
|
|
||||||
case _ => act
|
|
||||||
}
|
|
||||||
if(issue.isPullRequest){
|
|
||||||
callPullRequestWebHook(webHookAction, repository, issue.issueId, context.baseUrl, context.loginAccount.get)
|
|
||||||
} else {
|
|
||||||
callIssuesWebHook(webHookAction, repository, issue, context.baseUrl, context.loginAccount.get)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// notifications
|
|
||||||
Notifier() match {
|
|
||||||
case f =>
|
|
||||||
content foreach {
|
|
||||||
f.toNotify(repository, issue, _){
|
|
||||||
Notifier.msgComment(s"${context.baseUrl}/${owner}/${name}/${
|
|
||||||
if(issue.isPullRequest) "pull" else "issues"}/${issueId}#comment-${commentId.get}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
action foreach {
|
|
||||||
f.toNotify(repository, issue, _){
|
|
||||||
Notifier.msgStatus(s"${context.baseUrl}/${owner}/${name}/issues/${issueId}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
commentId.map( issue -> _ )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private def searchIssues(repository: RepositoryService.RepositoryInfo) = {
|
private def searchIssues(repository: RepositoryService.RepositoryInfo) = {
|
||||||
defining(repository.owner, repository.name){ case (owner, repoName) =>
|
defining(repository.owner, repository.name){ case (owner, repoName) =>
|
||||||
val page = IssueSearchCondition.page(request)
|
val page = IssueSearchCondition.page(request)
|
||||||
val sessionKey = Keys.Session.Issues(owner, repoName)
|
|
||||||
|
|
||||||
// retrieve search condition
|
// retrieve search condition
|
||||||
val condition = session.putAndGet(sessionKey,
|
val condition = IssueSearchCondition(request)
|
||||||
if(request.hasQueryString){
|
|
||||||
val q = request.getParameter("q")
|
|
||||||
if(q == null || q.trim.isEmpty){
|
|
||||||
IssueSearchCondition(request)
|
|
||||||
} else {
|
|
||||||
IssueSearchCondition(q, getMilestones(owner, repoName).map(x => (x.title, x.milestoneId)).toMap)
|
|
||||||
}
|
|
||||||
} else session.getAs[IssueSearchCondition](sessionKey).getOrElse(IssueSearchCondition())
|
|
||||||
)
|
|
||||||
|
|
||||||
html.list(
|
html.list(
|
||||||
"issues",
|
"issues",
|
||||||
searchIssue(condition, false, (page - 1) * IssueLimit, IssueLimit, owner -> repoName),
|
searchIssue(condition, false, (page - 1) * IssueLimit, IssueLimit, owner -> repoName),
|
||||||
page,
|
page,
|
||||||
if(!getAccountByUserName(owner).exists(_.isGroupAccount)){
|
getAssignableUserNames(owner, repoName),
|
||||||
(getCollaborators(owner, repoName) :+ owner).sorted
|
|
||||||
} else {
|
|
||||||
getCollaborators(owner, repoName)
|
|
||||||
},
|
|
||||||
getMilestones(owner, repoName),
|
getMilestones(owner, repoName),
|
||||||
getLabels(owner, repoName),
|
getLabels(owner, repoName),
|
||||||
countIssue(condition.copy(state = "open" ), false, owner -> repoName),
|
countIssue(condition.copy(state = "open" ), false, owner -> repoName),
|
||||||
countIssue(condition.copy(state = "closed"), false, owner -> repoName),
|
countIssue(condition.copy(state = "closed"), false, owner -> repoName),
|
||||||
condition,
|
condition,
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(owner, repoName, context.loginAccount))
|
isIssueEditable(repository),
|
||||||
|
isIssueManageable(repository))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an issue or a comment is editable by a logged-in user.
|
||||||
|
*/
|
||||||
|
private def isEditableContent(owner: String, repository: String, author: String)(implicit context: Context): Boolean = {
|
||||||
|
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,66 +2,67 @@ package gitbucket.core.controller
|
|||||||
|
|
||||||
import gitbucket.core.issues.labels.html
|
import gitbucket.core.issues.labels.html
|
||||||
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, LabelsService}
|
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, LabelsService}
|
||||||
import gitbucket.core.util.{ReferrerAuthenticator, CollaboratorsAuthenticator}
|
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.scalatra.i18n.Messages
|
import org.scalatra.i18n.Messages
|
||||||
import org.scalatra.Ok
|
import org.scalatra.Ok
|
||||||
|
|
||||||
class LabelsController extends LabelsControllerBase
|
class LabelsController extends LabelsControllerBase
|
||||||
with LabelsService with IssuesService with RepositoryService with AccountService
|
with LabelsService with IssuesService with RepositoryService with AccountService
|
||||||
with ReferrerAuthenticator with CollaboratorsAuthenticator
|
with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||||
|
|
||||||
trait LabelsControllerBase extends ControllerBase {
|
trait LabelsControllerBase extends ControllerBase {
|
||||||
self: LabelsService with IssuesService with RepositoryService
|
self: LabelsService with IssuesService with RepositoryService
|
||||||
with ReferrerAuthenticator with CollaboratorsAuthenticator =>
|
with ReferrerAuthenticator with WritableUsersAuthenticator =>
|
||||||
|
|
||||||
case class LabelForm(labelName: String, color: String)
|
case class LabelForm(labelName: String, color: String)
|
||||||
|
|
||||||
val labelForm = mapping(
|
val labelForm = mapping(
|
||||||
"labelName" -> trim(label("Label name", text(required, labelName, maxlength(100)))),
|
"labelName" -> trim(label("Label name", text(required, labelName, uniqueLabelName, maxlength(100)))),
|
||||||
"labelColor" -> trim(label("Color", text(required, color)))
|
"labelColor" -> trim(label("Color", text(required, color)))
|
||||||
)(LabelForm.apply)
|
)(LabelForm.apply)
|
||||||
|
|
||||||
|
|
||||||
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(), Map.empty),
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issues/labels/new")(collaboratorsOnly { repository =>
|
ajaxGet("/:owner/:repository/issues/labels/new")(writableUsersOnly { repository =>
|
||||||
html.edit(None, repository)
|
html.edit(None, repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/labels/new", labelForm)(collaboratorsOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/issues/labels/new", labelForm)(writableUsersOnly { (form, repository) =>
|
||||||
val labelId = createLabel(repository.owner, repository.name, form.labelName, form.color.substring(1))
|
val labelId = createLabel(repository.owner, repository.name, form.labelName, form.color.substring(1))
|
||||||
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(), Map.empty),
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issues/labels/:labelId/edit")(collaboratorsOnly { repository =>
|
ajaxGet("/:owner/:repository/issues/labels/:labelId/edit")(writableUsersOnly { repository =>
|
||||||
getLabel(repository.owner, repository.name, params("labelId").toInt).map { label =>
|
getLabel(repository.owner, repository.name, params("labelId").toInt).map { label =>
|
||||||
html.edit(Some(label), repository)
|
html.edit(Some(label), repository)
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/labels/:labelId/edit", labelForm)(collaboratorsOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/issues/labels/:labelId/edit", labelForm)(writableUsersOnly { (form, repository) =>
|
||||||
updateLabel(repository.owner, repository.name, params("labelId").toInt, form.labelName, form.color.substring(1))
|
updateLabel(repository.owner, repository.name, params("labelId").toInt, form.labelName, form.color.substring(1))
|
||||||
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(), Map.empty),
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/labels/:labelId/delete")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/labels/:labelId/delete")(writableUsersOnly { repository =>
|
||||||
deleteLabel(repository.owner, repository.name, params("labelId").toInt)
|
deleteLabel(repository.owner, repository.name, params("labelId").toInt)
|
||||||
Ok()
|
Ok()
|
||||||
})
|
})
|
||||||
@@ -80,4 +81,16 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def uniqueLabelName: Constraint = new Constraint(){
|
||||||
|
override def validate(name: String, value: String, params: Map[String, String], messages: Messages): Option[String] = {
|
||||||
|
val owner = params("owner")
|
||||||
|
val repository = params("repository")
|
||||||
|
params.get("labelId").map { labelId =>
|
||||||
|
getLabel(owner, repository, value).filter(_.labelId != labelId.toInt).map(_ => "Name has already been taken.")
|
||||||
|
}.getOrElse {
|
||||||
|
getLabel(owner, repository, value).map(_ => "Name has already been taken.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ 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.{RepositoryService, MilestonesService, AccountService}
|
||||||
import gitbucket.core.util.{ReferrerAuthenticator, CollaboratorsAuthenticator}
|
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
|
|
||||||
class MilestonesController extends MilestonesControllerBase
|
class MilestonesController extends MilestonesControllerBase
|
||||||
with MilestonesService with RepositoryService with AccountService
|
with MilestonesService with RepositoryService with AccountService
|
||||||
with ReferrerAuthenticator with CollaboratorsAuthenticator
|
with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||||
|
|
||||||
trait MilestonesControllerBase extends ControllerBase {
|
trait MilestonesControllerBase extends ControllerBase {
|
||||||
self: MilestonesService with RepositoryService
|
self: MilestonesService with RepositoryService
|
||||||
with ReferrerAuthenticator with CollaboratorsAuthenticator =>
|
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])
|
||||||
|
|
||||||
@@ -27,58 +27,58 @@ trait MilestonesControllerBase extends ControllerBase {
|
|||||||
params.getOrElse("state", "open"),
|
params.getOrElse("state", "open"),
|
||||||
getMilestonesWithIssueCount(repository.owner, repository.name),
|
getMilestonesWithIssueCount(repository.owner, repository.name),
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/new")(collaboratorsOnly {
|
get("/:owner/:repository/issues/milestones/new")(writableUsersOnly {
|
||||||
html.edit(None, _)
|
html.edit(None, _)
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/milestones/new", milestoneForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/issues/milestones/new", milestoneForm)(writableUsersOnly { (form, repository) =>
|
||||||
createMilestone(repository.owner, repository.name, form.title, form.description, form.dueDate)
|
createMilestone(repository.owner, repository.name, form.title, form.description, form.dueDate)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/:milestoneId/edit")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/issues/milestones/:milestoneId/edit")(writableUsersOnly { repository =>
|
||||||
params("milestoneId").toIntOpt.map{ milestoneId =>
|
params("milestoneId").toIntOpt.map{ milestoneId =>
|
||||||
html.edit(getMilestone(repository.owner, repository.name, milestoneId), repository)
|
html.edit(getMilestone(repository.owner, repository.name, milestoneId), repository)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/milestones/:milestoneId/edit", milestoneForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/issues/milestones/:milestoneId/edit", milestoneForm)(writableUsersOnly { (form, repository) =>
|
||||||
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
||||||
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
||||||
updateMilestone(milestone.copy(title = form.title, description = form.description, dueDate = form.dueDate))
|
updateMilestone(milestone.copy(title = form.title, description = form.description, dueDate = form.dueDate))
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/:milestoneId/close")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/issues/milestones/:milestoneId/close")(writableUsersOnly { repository =>
|
||||||
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
||||||
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
||||||
closeMilestone(milestone)
|
closeMilestone(milestone)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/:milestoneId/open")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/issues/milestones/:milestoneId/open")(writableUsersOnly { repository =>
|
||||||
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
||||||
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
||||||
openMilestone(milestone)
|
openMilestone(milestone)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/:milestoneId/delete")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/issues/milestones/:milestoneId/delete")(writableUsersOnly { repository =>
|
||||||
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
||||||
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
||||||
deleteMilestone(repository.owner, repository.name, milestone.milestoneId)
|
deleteMilestone(repository.owner, repository.name, milestone.milestoneId)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package gitbucket.core.controller
|
|
||||||
|
|
||||||
import gitbucket.core.admin.plugins.html
|
|
||||||
import gitbucket.core.plugin.PluginRegistry
|
|
||||||
import gitbucket.core.util.AdminAuthenticator
|
|
||||||
|
|
||||||
class PluginsController extends ControllerBase with AdminAuthenticator {
|
|
||||||
get("/admin/plugins")(adminOnly {
|
|
||||||
html.plugins(PluginRegistry().getPlugins())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,41 +1,36 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.api._
|
import gitbucket.core.model.WebHook
|
||||||
import gitbucket.core.model.{Account, CommitState, Repository, PullRequest, Issue}
|
|
||||||
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
|
||||||
import gitbucket.core.service.IssuesService._
|
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._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.JGitUtil._
|
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
import gitbucket.core.view
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import gitbucket.core.view.helpers
|
|
||||||
|
|
||||||
import jp.sf.amateras.scalatra.forms._
|
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.lib.PersonIdent
|
import org.eclipse.jgit.lib.PersonIdent
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
|
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
|
|
||||||
class PullRequestsController extends PullRequestsControllerBase
|
class PullRequestsController extends PullRequestsControllerBase
|
||||||
with RepositoryService with AccountService with IssuesService with PullRequestService with MilestonesService with LabelsService
|
with RepositoryService with AccountService with IssuesService with PullRequestService with MilestonesService with LabelsService
|
||||||
with CommitsService with ActivityService with WebHookPullRequestService with ReferrerAuthenticator with CollaboratorsAuthenticator
|
with CommitsService with ActivityService with WebHookPullRequestService
|
||||||
with CommitStatusService with MergeService
|
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||||
|
with CommitStatusService with MergeService with ProtectedBranchService
|
||||||
|
|
||||||
|
|
||||||
trait PullRequestsControllerBase extends ControllerBase {
|
trait PullRequestsControllerBase extends ControllerBase {
|
||||||
self: RepositoryService with AccountService with IssuesService with MilestonesService with LabelsService
|
self: RepositoryService with AccountService with IssuesService with MilestonesService with LabelsService
|
||||||
with CommitsService with ActivityService with PullRequestService with WebHookPullRequestService with ReferrerAuthenticator with CollaboratorsAuthenticator
|
with CommitsService with ActivityService with PullRequestService with WebHookPullRequestService
|
||||||
with CommitStatusService with MergeService =>
|
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||||
|
with CommitStatusService with MergeService with ProtectedBranchService =>
|
||||||
private val logger = LoggerFactory.getLogger(classOf[PullRequestsControllerBase])
|
|
||||||
|
|
||||||
val pullRequestForm = mapping(
|
val pullRequestForm = mapping(
|
||||||
"title" -> trim(label("Title" , text(required, maxlength(100)))),
|
"title" -> trim(label("Title" , text(required, maxlength(100)))),
|
||||||
@@ -82,24 +77,6 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
|
||||||
* https://developer.github.com/v3/pulls/#list-pull-requests
|
|
||||||
*/
|
|
||||||
get("/api/v3/repos/:owner/:repository/pulls")(referrersOnly { repository =>
|
|
||||||
val page = IssueSearchCondition.page(request)
|
|
||||||
// TODO: more api spec condition
|
|
||||||
val condition = IssueSearchCondition(request)
|
|
||||||
val baseOwner = getAccountByUserName(repository.owner).get
|
|
||||||
val issues:List[(Issue, Account, Int, PullRequest, Repository, Account)] = searchPullRequestByApi(condition, (page - 1) * PullRequestLimit, PullRequestLimit, repository.owner -> repository.name)
|
|
||||||
JsonFormat(issues.map{case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner) =>
|
|
||||||
ApiPullRequest(
|
|
||||||
issue,
|
|
||||||
pullRequest,
|
|
||||||
ApiRepository(headRepo, ApiUser(headOwner)),
|
|
||||||
ApiRepository(repository, ApiUser(baseOwner)),
|
|
||||||
ApiUser(issueUser)) })
|
|
||||||
})
|
|
||||||
|
|
||||||
get("/:owner/:repository/pull/:id")(referrersOnly { repository =>
|
get("/:owner/:repository/pull/:id")(referrersOnly { repository =>
|
||||||
params("id").toIntOpt.flatMap{ issueId =>
|
params("id").toIntOpt.flatMap{ issueId =>
|
||||||
val owner = repository.owner
|
val owner = repository.owner
|
||||||
@@ -113,82 +90,55 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
(commits.flatten.map(commit => getCommitComments(owner, name, commit.id, true)).flatten.toList ::: getComments(owner, name, issueId))
|
(commits.flatten.map(commit => getCommitComments(owner, name, commit.id, true)).flatten.toList ::: getComments(owner, name, issueId))
|
||||||
.sortWith((a, b) => a.registeredDate before b.registeredDate),
|
.sortWith((a, b) => a.registeredDate before b.registeredDate),
|
||||||
getIssueLabels(owner, name, issueId),
|
getIssueLabels(owner, name, issueId),
|
||||||
(getCollaborators(owner, name) ::: (if(getAccountByUserName(owner).get.isGroupAccount) Nil else List(owner))).sorted,
|
getAssignableUserNames(owner, name),
|
||||||
getMilestonesWithIssueCount(owner, name),
|
getMilestonesWithIssueCount(owner, name),
|
||||||
getLabels(owner, name),
|
getLabels(owner, name),
|
||||||
commits,
|
commits,
|
||||||
diffs,
|
diffs,
|
||||||
hasWritePermission(owner, name, context.loginAccount),
|
isEditable(repository),
|
||||||
repository)
|
isManageable(repository),
|
||||||
|
repository,
|
||||||
|
flash.toMap.map(f => f._1 -> f._2.toString))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
ajaxGet("/:owner/:repository/pull/:id/mergeguide")(referrersOnly { repository =>
|
||||||
* https://developer.github.com/v3/pulls/#get-a-single-pull-request
|
|
||||||
*/
|
|
||||||
get("/api/v3/repos/:owner/:repository/pulls/:id")(referrersOnly { repository =>
|
|
||||||
(for{
|
|
||||||
issueId <- params("id").toIntOpt
|
|
||||||
(issue, pullRequest) <- getPullRequest(repository.owner, repository.name, issueId)
|
|
||||||
users = getAccountsByUserNames(Set(repository.owner, pullRequest.requestUserName, issue.openedUserName), Set())
|
|
||||||
baseOwner <- users.get(repository.owner)
|
|
||||||
headOwner <- users.get(pullRequest.requestUserName)
|
|
||||||
issueUser <- users.get(issue.openedUserName)
|
|
||||||
headRepo <- getRepository(pullRequest.requestUserName, pullRequest.requestRepositoryName, baseUrl)
|
|
||||||
} yield {
|
|
||||||
JsonFormat(ApiPullRequest(
|
|
||||||
issue,
|
|
||||||
pullRequest,
|
|
||||||
ApiRepository(headRepo, ApiUser(headOwner)),
|
|
||||||
ApiRepository(repository, ApiUser(baseOwner)),
|
|
||||||
ApiUser(issueUser)))
|
|
||||||
}).getOrElse(NotFound)
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request
|
|
||||||
*/
|
|
||||||
get("/api/v3/repos/:owner/:repository/pulls/:id/commits")(referrersOnly { repository =>
|
|
||||||
val owner = repository.owner
|
|
||||||
val name = repository.name
|
|
||||||
params("id").toIntOpt.flatMap{ issueId =>
|
|
||||||
getPullRequest(owner, name, issueId) map { case(issue, pullreq) =>
|
|
||||||
using(Git.open(getRepositoryDir(owner, name))){ git =>
|
|
||||||
val oldId = git.getRepository.resolve(pullreq.commitIdFrom)
|
|
||||||
val newId = git.getRepository.resolve(pullreq.commitIdTo)
|
|
||||||
val repoFullName = RepositoryName(repository)
|
|
||||||
val commits = git.log.addRange(oldId, newId).call.iterator.asScala.map(c => ApiCommitListItem(new CommitInfo(c), repoFullName)).toList
|
|
||||||
JsonFormat(commits)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} getOrElse NotFound
|
|
||||||
})
|
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/pull/:id/mergeguide")(collaboratorsOnly { repository =>
|
|
||||||
params("id").toIntOpt.flatMap{ issueId =>
|
params("id").toIntOpt.flatMap{ issueId =>
|
||||||
val owner = repository.owner
|
val owner = repository.owner
|
||||||
val name = repository.name
|
val name = repository.name
|
||||||
getPullRequest(owner, name, issueId) map { case(issue, pullreq) =>
|
getPullRequest(owner, name, issueId) map { case(issue, pullreq) =>
|
||||||
val statuses = getCommitStatues(owner, name, pullreq.commitIdTo)
|
val hasConflict = LockUtil.lock(s"${owner}/${name}"){
|
||||||
val hasConfrict = LockUtil.lock(s"${owner}/${name}"){
|
|
||||||
checkConflict(owner, name, pullreq.branch, issueId)
|
checkConflict(owner, name, pullreq.branch, issueId)
|
||||||
}
|
}
|
||||||
val hasProblem = hasConfrict || (!statuses.isEmpty && CommitState.combine(statuses.map(_.state).toSet) != CommitState.SUCCESS)
|
val hasMergePermission = hasDeveloperRole(owner, name, context.loginAccount)
|
||||||
|
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.branch)
|
||||||
|
val mergeStatus = PullRequestService.MergeStatus(
|
||||||
|
hasConflict = hasConflict,
|
||||||
|
commitStatues = getCommitStatues(owner, name, pullreq.commitIdTo),
|
||||||
|
branchProtection = branchProtection,
|
||||||
|
branchIsOutOfDate = JGitUtil.getShaByRef(owner, name, pullreq.branch) != Some(pullreq.commitIdFrom),
|
||||||
|
needStatusCheck = context.loginAccount.map{ u =>
|
||||||
|
branchProtection.needStatusCheck(u.userName)
|
||||||
|
}.getOrElse(true),
|
||||||
|
hasUpdatePermission = hasDeveloperRole(pullreq.requestUserName, pullreq.requestRepositoryName, context.loginAccount) &&
|
||||||
|
context.loginAccount.map{ u =>
|
||||||
|
!getProtectedBranchInfo(pullreq.requestUserName, pullreq.requestRepositoryName, pullreq.requestBranch).needStatusCheck(u.userName)
|
||||||
|
}.getOrElse(false),
|
||||||
|
hasMergePermission = hasMergePermission,
|
||||||
|
commitIdTo = pullreq.commitIdTo)
|
||||||
html.mergeguide(
|
html.mergeguide(
|
||||||
hasConfrict,
|
mergeStatus,
|
||||||
hasProblem,
|
|
||||||
issue,
|
issue,
|
||||||
pullreq,
|
pullreq,
|
||||||
statuses,
|
|
||||||
repository,
|
repository,
|
||||||
getRepository(pullreq.requestUserName, pullreq.requestRepositoryName, context.baseUrl).get)
|
getRepository(pullreq.requestUserName, pullreq.requestRepositoryName).get)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/pull/:id/delete/*")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/pull/:id/delete/*")(writableUsersOnly { repository =>
|
||||||
params("id").toIntOpt.map { issueId =>
|
params("id").toIntOpt.map { issueId =>
|
||||||
val branchName = multiParams("splat").head
|
val branchName = multiParams("splat").head
|
||||||
val userName = context.loginAccount.get.userName
|
val userName = context.loginAccount.get.userName
|
||||||
@@ -200,10 +150,79 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
createComment(repository.owner, repository.name, userName, issueId, branchName, "delete_branch")
|
createComment(repository.owner, repository.name, userName, issueId, branchName, "delete_branch")
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/pull/:id/merge", mergeForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/pull/:id/update_branch")(writableUsersOnly { baseRepository =>
|
||||||
|
(for {
|
||||||
|
issueId <- params("id").toIntOpt
|
||||||
|
loginAccount <- context.loginAccount
|
||||||
|
(issue, pullreq) <- getPullRequest(baseRepository.owner, baseRepository.name, issueId)
|
||||||
|
owner = pullreq.requestUserName
|
||||||
|
name = pullreq.requestRepositoryName
|
||||||
|
if hasDeveloperRole(owner, name, context.loginAccount)
|
||||||
|
} yield {
|
||||||
|
val repository = getRepository(owner, name).get
|
||||||
|
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.requestBranch)
|
||||||
|
if(branchProtection.needStatusCheck(loginAccount.userName)){
|
||||||
|
flash += "error" -> s"branch ${pullreq.requestBranch} is protected need status check."
|
||||||
|
} else {
|
||||||
|
LockUtil.lock(s"${owner}/${name}"){
|
||||||
|
val alias = if(pullreq.repositoryName == pullreq.requestRepositoryName && pullreq.userName == pullreq.requestUserName){
|
||||||
|
pullreq.branch
|
||||||
|
} else {
|
||||||
|
s"${pullreq.userName}:${pullreq.branch}"
|
||||||
|
}
|
||||||
|
val existIds = using(Git.open(Directory.getRepositoryDir(owner, name))) { git => JGitUtil.getAllCommitIds(git) }.toSet
|
||||||
|
pullRemote(owner, name, pullreq.requestBranch, pullreq.userName, pullreq.repositoryName, pullreq.branch, loginAccount,
|
||||||
|
s"Merge branch '${alias}' into ${pullreq.requestBranch}") match {
|
||||||
|
case None => // conflict
|
||||||
|
flash += "error" -> s"Can't automatic merging branch '${alias}' into ${pullreq.requestBranch}."
|
||||||
|
case Some(oldId) =>
|
||||||
|
// update pull request
|
||||||
|
updatePullRequests(owner, name, pullreq.requestBranch)
|
||||||
|
|
||||||
|
using(Git.open(Directory.getRepositoryDir(owner, name))) { git =>
|
||||||
|
// after update branch
|
||||||
|
val newCommitId = git.getRepository.resolve(s"refs/heads/${pullreq.requestBranch}")
|
||||||
|
val commits = git.log.addRange(oldId, newCommitId).call.iterator.asScala.map(c => new JGitUtil.CommitInfo(c)).toList
|
||||||
|
|
||||||
|
commits.foreach { commit =>
|
||||||
|
if(!existIds.contains(commit.id)){
|
||||||
|
createIssueComment(owner, name, commit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// record activity
|
||||||
|
recordPushActivity(owner, name, loginAccount.userName, pullreq.branch, commits)
|
||||||
|
|
||||||
|
// close issue by commit message
|
||||||
|
if(pullreq.requestBranch == repository.repository.defaultBranch){
|
||||||
|
commits.map { commit =>
|
||||||
|
closeIssuesFromMessage(commit.fullMessage, loginAccount.userName, owner, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// call web hook
|
||||||
|
callPullRequestWebHookByRequestBranch("synchronize", repository, pullreq.requestBranch, baseUrl, loginAccount)
|
||||||
|
callWebHookOf(owner, name, WebHook.Push) {
|
||||||
|
for {
|
||||||
|
ownerAccount <- getAccountByUserName(owner)
|
||||||
|
} yield {
|
||||||
|
WebHookService.WebHookPushPayload(git, loginAccount, pullreq.requestBranch, repository, commits, ownerAccount, oldId = oldId, newId = newCommitId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flash += "info" -> s"Merge branch '${alias}' into ${pullreq.requestBranch}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
|
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
post("/:owner/:repository/pull/:id/merge", mergeForm)(writableUsersOnly { (form, repository) =>
|
||||||
params("id").toIntOpt.flatMap { issueId =>
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
val owner = repository.owner
|
val owner = repository.owner
|
||||||
val name = repository.name
|
val name = repository.name
|
||||||
@@ -228,15 +247,12 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
pullreq.requestUserName, pullreq.requestRepositoryName, pullreq.commitIdTo)
|
pullreq.requestUserName, pullreq.requestRepositoryName, pullreq.commitIdTo)
|
||||||
|
|
||||||
// close issue by content of pull request
|
// close issue by content of pull request
|
||||||
val defaultBranch = getRepository(owner, name, context.baseUrl).get.repository.defaultBranch
|
val defaultBranch = getRepository(owner, name).get.repository.defaultBranch
|
||||||
if(pullreq.branch == defaultBranch){
|
if(pullreq.branch == defaultBranch){
|
||||||
commits.flatten.foreach { commit =>
|
commits.flatten.foreach { commit =>
|
||||||
closeIssuesFromMessage(commit.fullMessage, loginAccount.userName, owner, name)
|
closeIssuesFromMessage(commit.fullMessage, loginAccount.userName, owner, name)
|
||||||
}
|
}
|
||||||
issue.content match {
|
closeIssuesFromMessage(issue.title + " " + issue.content.getOrElse(""), loginAccount.userName, owner, name)
|
||||||
case Some(content) => closeIssuesFromMessage(content, loginAccount.userName, owner, name)
|
|
||||||
case _ =>
|
|
||||||
}
|
|
||||||
closeIssuesFromMessage(form.message, loginAccount.userName, owner, name)
|
closeIssuesFromMessage(form.message, loginAccount.userName, owner, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,14 +270,14 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} 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:Option[String] = 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, context.baseUrl).map { originRepository =>
|
getRepository(originUserName, originRepositoryName).map { originRepository =>
|
||||||
using(
|
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))
|
||||||
@@ -271,7 +287,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
redirect(s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${originUserName}:${oldBranch}...${newBranch}")
|
redirect(s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${originUserName}:${oldBranch}...${newBranch}")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
case _ => {
|
case _ => {
|
||||||
using(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))){ git =>
|
using(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))){ git =>
|
||||||
@@ -302,12 +318,12 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
forkedRepository.repository.originRepositoryName
|
forkedRepository.repository.originRepositoryName
|
||||||
} else {
|
} else {
|
||||||
// Sibling repository
|
// Sibling repository
|
||||||
getUserRepositories(originOwner, context.baseUrl).find { x =>
|
getUserRepositories(originOwner).find { x =>
|
||||||
x.repository.originUserName == forkedRepository.repository.originUserName &&
|
x.repository.originUserName == forkedRepository.repository.originUserName &&
|
||||||
x.repository.originRepositoryName == forkedRepository.repository.originRepositoryName
|
x.repository.originRepositoryName == forkedRepository.repository.originRepositoryName
|
||||||
}.map(_.repository.repositoryName)
|
}.map(_.repository.repositoryName)
|
||||||
};
|
};
|
||||||
originRepository <- getRepository(originOwner, originRepositoryName, context.baseUrl)
|
originRepository <- getRepository(originOwner, originRepositoryName)
|
||||||
) yield {
|
) yield {
|
||||||
using(
|
using(
|
||||||
Git.open(getRepositoryDir(originRepository.owner, originRepository.name)),
|
Git.open(getRepositoryDir(originRepository.owner, originRepository.name)),
|
||||||
@@ -332,7 +348,15 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
originRepository.owner, originRepository.name, oldId.getName,
|
originRepository.owner, originRepository.name, oldId.getName,
|
||||||
forkedRepository.owner, forkedRepository.name, newId.getName)
|
forkedRepository.owner, forkedRepository.name, newId.getName)
|
||||||
|
|
||||||
|
val title = if(commits.flatten.length == 1){
|
||||||
|
commits.flatten.head.shortMessage
|
||||||
|
} else {
|
||||||
|
val text = forkedId.replaceAll("[\\-_]", " ")
|
||||||
|
text.substring(0, 1).toUpperCase + text.substring(1)
|
||||||
|
}
|
||||||
|
|
||||||
html.compare(
|
html.compare(
|
||||||
|
title,
|
||||||
commits,
|
commits,
|
||||||
diffs,
|
diffs,
|
||||||
(forkedRepository.repository.originUserName, forkedRepository.repository.originRepositoryName) match {
|
(forkedRepository.repository.originUserName, forkedRepository.repository.originRepositoryName) match {
|
||||||
@@ -344,11 +368,12 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
forkedId,
|
forkedId,
|
||||||
oldId.getName,
|
oldId.getName,
|
||||||
newId.getName,
|
newId.getName,
|
||||||
|
getContentTemplate(originRepository, "PULL_REQUEST_TEMPLATE"),
|
||||||
forkedRepository,
|
forkedRepository,
|
||||||
originRepository,
|
originRepository,
|
||||||
forkedRepository,
|
forkedRepository,
|
||||||
hasWritePermission(originRepository.owner, originRepository.name, context.loginAccount),
|
hasDeveloperRole(originRepository.owner, originRepository.name, context.loginAccount),
|
||||||
(getCollaborators(originRepository.owner, originRepository.name) ::: (if(getAccountByUserName(originRepository.owner).get.isGroupAccount) Nil else List(originRepository.owner))).sorted,
|
getAssignableUserNames(originRepository.owner, originRepository.name),
|
||||||
getMilestones(originRepository.owner, originRepository.name),
|
getMilestones(originRepository.owner, originRepository.name),
|
||||||
getLabels(originRepository.owner, originRepository.name)
|
getLabels(originRepository.owner, originRepository.name)
|
||||||
)
|
)
|
||||||
@@ -359,10 +384,10 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
s"${forkedOwner}:${newId.map(_ => forkedId).getOrElse(forkedRepository.repository.defaultBranch)}")
|
s"${forkedOwner}:${newId.map(_ => forkedId).getOrElse(forkedRepository.repository.defaultBranch)}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/compare/*...*/mergecheck")(collaboratorsOnly { forkedRepository =>
|
ajaxGet("/:owner/:repository/compare/*...*/mergecheck")(readableUsersOnly { forkedRepository =>
|
||||||
val Seq(origin, forked) = multiParams("splat")
|
val Seq(origin, forked) = multiParams("splat")
|
||||||
val (originOwner, tmpOriginBranch) = parseCompareIdentifie(origin, forkedRepository.owner)
|
val (originOwner, tmpOriginBranch) = parseCompareIdentifie(origin, forkedRepository.owner)
|
||||||
val (forkedOwner, tmpForkedBranch) = parseCompareIdentifie(forked, forkedRepository.owner)
|
val (forkedOwner, tmpForkedBranch) = parseCompareIdentifie(forked, forkedRepository.owner)
|
||||||
@@ -375,7 +400,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
getForkedRepositories(forkedRepository.owner, forkedRepository.name).find(_._1 == originOwner).map(_._2)
|
getForkedRepositories(forkedRepository.owner, forkedRepository.name).find(_._1 == originOwner).map(_._2)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
originRepository <- getRepository(originOwner, originRepositoryName, context.baseUrl)
|
originRepository <- getRepository(originOwner, originRepositoryName)
|
||||||
) yield {
|
) yield {
|
||||||
using(
|
using(
|
||||||
Git.open(getRepositoryDir(originRepository.owner, originRepository.name)),
|
Git.open(getRepositoryDir(originRepository.owner, originRepository.name)),
|
||||||
@@ -389,22 +414,25 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
html.mergecheck(conflict)
|
html.mergecheck(conflict)
|
||||||
}
|
}
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/pulls/new", pullRequestForm)(referrersOnly { (form, repository) =>
|
post("/:owner/:repository/pulls/new", pullRequestForm)(readableUsersOnly { (form, repository) =>
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
val writable = hasWritePermission(owner, name, context.loginAccount)
|
val manageable = isManageable(repository)
|
||||||
|
val editable = isEditable(repository)
|
||||||
|
|
||||||
|
if(editable) {
|
||||||
val loginUserName = context.loginAccount.get.userName
|
val loginUserName = context.loginAccount.get.userName
|
||||||
|
|
||||||
val issueId = createIssue(
|
val issueId = insertIssue(
|
||||||
owner = repository.owner,
|
owner = repository.owner,
|
||||||
repository = repository.name,
|
repository = repository.name,
|
||||||
loginUser = loginUserName,
|
loginUser = loginUserName,
|
||||||
title = form.title,
|
title = form.title,
|
||||||
content = form.content,
|
content = form.content,
|
||||||
assignedUserName = if(writable) form.assignedUserName else None,
|
assignedUserName = if (manageable) form.assignedUserName else None,
|
||||||
milestoneId = if(writable) form.milestoneId else None,
|
milestoneId = if (manageable) form.milestoneId else None,
|
||||||
isPullRequest = true)
|
isPullRequest = true)
|
||||||
|
|
||||||
createPullRequest(
|
createPullRequest(
|
||||||
@@ -419,7 +447,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
commitIdTo = form.commitIdTo)
|
commitIdTo = form.commitIdTo)
|
||||||
|
|
||||||
// insert labels
|
// insert labels
|
||||||
if(writable){
|
if (manageable) {
|
||||||
form.labelNames.map { value =>
|
form.labelNames.map { value =>
|
||||||
val labels = getLabels(owner, name)
|
val labels = getLabels(owner, name)
|
||||||
value.split(",").foreach { labelName =>
|
value.split(",").foreach { labelName =>
|
||||||
@@ -441,31 +469,19 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
getIssue(owner, name, issueId.toString) foreach { issue =>
|
getIssue(owner, name, issueId.toString) foreach { issue =>
|
||||||
// extract references and create refer comment
|
// extract references and create refer comment
|
||||||
createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse(""))
|
createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse(""), context.loginAccount.get)
|
||||||
|
|
||||||
// notifications
|
// notifications
|
||||||
Notifier().toNotify(repository, issue, form.content.getOrElse("")){
|
Notifier().toNotify(repository, issue, form.content.getOrElse("")) {
|
||||||
Notifier.msgPullRequest(s"${context.baseUrl}/${owner}/${name}/pull/${issueId}")
|
Notifier.msgPullRequest(s"${context.baseUrl}/${owner}/${name}/pull/${issueId}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/pull/${issueId}")
|
redirect(s"/${owner}/${name}/pull/${issueId}")
|
||||||
|
} else Unauthorized()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO Same method exists in IssueController. Should it moved to IssueService?
|
|
||||||
private def createReferComment(owner: String, repository: String, fromIssue: Issue, message: String) = {
|
|
||||||
StringUtil.extractIssueId(message).foreach { issueId =>
|
|
||||||
val content = fromIssue.issueId + ":" + fromIssue.title
|
|
||||||
if(getIssue(owner, repository, issueId).isDefined){
|
|
||||||
// Not add if refer comment already exist.
|
|
||||||
if(!getComments(owner, repository, issueId.toInt).exists { x => x.action == "refer" && x.content == content }) {
|
|
||||||
createComment(owner, repository, context.loginAccount.get.userName, issueId.toInt, content, "refer")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses branch identifier and extracts owner and branch name as tuple.
|
* Parses branch identifier and extracts owner and branch name as tuple.
|
||||||
*
|
*
|
||||||
@@ -480,52 +496,45 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
(defaultOwner, value)
|
(defaultOwner, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def getRequestCompareInfo(userName: String, repositoryName: String, branch: String,
|
|
||||||
requestUserName: String, requestRepositoryName: String, requestCommitId: String): (Seq[Seq[CommitInfo]], Seq[DiffInfo]) =
|
|
||||||
using(
|
|
||||||
Git.open(getRepositoryDir(userName, repositoryName)),
|
|
||||||
Git.open(getRepositoryDir(requestUserName, requestRepositoryName))
|
|
||||||
){ (oldGit, newGit) =>
|
|
||||||
val oldId = oldGit.getRepository.resolve(branch)
|
|
||||||
val newId = newGit.getRepository.resolve(requestCommitId)
|
|
||||||
|
|
||||||
val commits = newGit.log.addRange(oldId, newId).call.iterator.asScala.map { revCommit =>
|
|
||||||
new CommitInfo(revCommit)
|
|
||||||
}.toList.splitWith { (commit1, commit2) =>
|
|
||||||
helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
|
||||||
}
|
|
||||||
|
|
||||||
val diffs = JGitUtil.getDiffs(newGit, oldId.getName, newId.getName, true)
|
|
||||||
|
|
||||||
(commits, diffs)
|
|
||||||
}
|
|
||||||
|
|
||||||
private def searchPullRequests(userName: Option[String], repository: RepositoryService.RepositoryInfo) =
|
private def searchPullRequests(userName: Option[String], repository: RepositoryService.RepositoryInfo) =
|
||||||
defining(repository.owner, repository.name){ case (owner, repoName) =>
|
defining(repository.owner, repository.name){ case (owner, repoName) =>
|
||||||
val page = IssueSearchCondition.page(request)
|
val page = IssueSearchCondition.page(request)
|
||||||
val sessionKey = Keys.Session.Pulls(owner, repoName)
|
|
||||||
|
|
||||||
// retrieve search condition
|
// retrieve search condition
|
||||||
val condition = session.putAndGet(sessionKey,
|
val condition = IssueSearchCondition(request)
|
||||||
if(request.hasQueryString) IssueSearchCondition(request)
|
|
||||||
else session.getAs[IssueSearchCondition](sessionKey).getOrElse(IssueSearchCondition())
|
|
||||||
)
|
|
||||||
|
|
||||||
gitbucket.core.issues.html.list(
|
gitbucket.core.issues.html.list(
|
||||||
"pulls",
|
"pulls",
|
||||||
searchIssue(condition, true, (page - 1) * PullRequestLimit, PullRequestLimit, owner -> repoName),
|
searchIssue(condition, true, (page - 1) * PullRequestLimit, PullRequestLimit, owner -> repoName),
|
||||||
page,
|
page,
|
||||||
if(!getAccountByUserName(owner).exists(_.isGroupAccount)){
|
getAssignableUserNames(owner, repoName),
|
||||||
(getCollaborators(owner, repoName) :+ owner).sorted
|
|
||||||
} else {
|
|
||||||
getCollaborators(owner, repoName)
|
|
||||||
},
|
|
||||||
getMilestones(owner, repoName),
|
getMilestones(owner, repoName),
|
||||||
getLabels(owner, repoName),
|
getLabels(owner, repoName),
|
||||||
countIssue(condition.copy(state = "open" ), true, owner -> repoName),
|
countIssue(condition.copy(state = "open" ), true, owner -> repoName),
|
||||||
countIssue(condition.copy(state = "closed"), true, owner -> repoName),
|
countIssue(condition.copy(state = "closed"), true, owner -> repoName),
|
||||||
condition,
|
condition,
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(owner, repoName, context.loginAccount))
|
isEditable(repository),
|
||||||
|
isManageable(repository))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an logged-in user can manage pull requests.
|
||||||
|
*/
|
||||||
|
private def isManageable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||||
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an logged-in user can post pull requests.
|
||||||
|
*/
|
||||||
|
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||||
|
repository.repository.options.issuesOption match {
|
||||||
|
case "ALL" => !repository.repository.isPrivate && context.loginAccount.isDefined
|
||||||
|
case "PUBLIC" => hasGuestRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
case "PRIVATE" => hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
case "DISABLE" => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,52 +2,78 @@ package gitbucket.core.controller
|
|||||||
|
|
||||||
import gitbucket.core.settings.html
|
import gitbucket.core.settings.html
|
||||||
import gitbucket.core.model.WebHook
|
import gitbucket.core.model.WebHook
|
||||||
import gitbucket.core.service.{RepositoryService, AccountService, WebHookService}
|
import gitbucket.core.service.{RepositoryService, AccountService, WebHookService, ProtectedBranchService, CommitStatusService}
|
||||||
import gitbucket.core.service.WebHookService._
|
import gitbucket.core.service.WebHookService._
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
import gitbucket.core.util.JGitUtil._
|
import gitbucket.core.util.JGitUtil._
|
||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
class RepositorySettingsController extends RepositorySettingsControllerBase
|
class RepositorySettingsController extends RepositorySettingsControllerBase
|
||||||
with RepositoryService with AccountService with WebHookService
|
with RepositoryService with AccountService with WebHookService with ProtectedBranchService with CommitStatusService
|
||||||
with OwnerAuthenticator with UsersAuthenticator
|
with OwnerAuthenticator with UsersAuthenticator
|
||||||
|
|
||||||
trait RepositorySettingsControllerBase extends ControllerBase {
|
trait RepositorySettingsControllerBase extends ControllerBase {
|
||||||
self: RepositoryService with AccountService with WebHookService
|
self: RepositoryService with AccountService with WebHookService with ProtectedBranchService with CommitStatusService
|
||||||
with OwnerAuthenticator with UsersAuthenticator =>
|
with OwnerAuthenticator with UsersAuthenticator =>
|
||||||
|
|
||||||
// for repository options
|
// for repository options
|
||||||
case class OptionsForm(repositoryName: String, description: Option[String], defaultBranch: String, isPrivate: Boolean)
|
case class OptionsForm(
|
||||||
|
repositoryName: String,
|
||||||
|
description: Option[String],
|
||||||
|
isPrivate: Boolean,
|
||||||
|
issuesOption: String,
|
||||||
|
externalIssuesUrl: Option[String],
|
||||||
|
wikiOption: String,
|
||||||
|
externalWikiUrl: Option[String],
|
||||||
|
allowFork: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
val optionsForm = mapping(
|
val optionsForm = mapping(
|
||||||
"repositoryName" -> trim(label("Description" , text(required, maxlength(40), identifier, renameRepositoryName))),
|
"repositoryName" -> trim(label("Repository Name" , text(required, maxlength(100), identifier, renameRepositoryName))),
|
||||||
"description" -> trim(label("Description" , optional(text()))),
|
"description" -> trim(label("Description" , optional(text()))),
|
||||||
"defaultBranch" -> trim(label("Default Branch" , text(required, maxlength(100)))),
|
"isPrivate" -> trim(label("Repository Type" , boolean())),
|
||||||
"isPrivate" -> trim(label("Repository Type", boolean()))
|
"issuesOption" -> trim(label("Issues Option" , text(required, featureOption))),
|
||||||
|
"externalIssuesUrl" -> trim(label("External Issues URL", optional(text(maxlength(200))))),
|
||||||
|
"wikiOption" -> trim(label("Wiki Option" , text(required, featureOption))),
|
||||||
|
"externalWikiUrl" -> trim(label("External Wiki URL" , optional(text(maxlength(200))))),
|
||||||
|
"allowFork" -> trim(label("Allow Forking" , boolean()))
|
||||||
)(OptionsForm.apply)
|
)(OptionsForm.apply)
|
||||||
|
|
||||||
// for collaborator addition
|
// for default branch
|
||||||
case class CollaboratorForm(userName: String)
|
case class DefaultBranchForm(defaultBranch: String)
|
||||||
|
|
||||||
val collaboratorForm = mapping(
|
val defaultBranchForm = mapping(
|
||||||
"userName" -> trim(label("Username", text(required, collaborator)))
|
"defaultBranch" -> trim(label("Default Branch" , text(required, maxlength(100))))
|
||||||
)(CollaboratorForm.apply)
|
)(DefaultBranchForm.apply)
|
||||||
|
|
||||||
|
// // for collaborator addition
|
||||||
|
// case class CollaboratorForm(userName: String)
|
||||||
|
//
|
||||||
|
// val collaboratorForm = mapping(
|
||||||
|
// "userName" -> trim(label("Username", text(required, collaborator)))
|
||||||
|
// )(CollaboratorForm.apply)
|
||||||
|
|
||||||
// for web hook url addition
|
// for web hook url addition
|
||||||
case class WebHookForm(url: String)
|
case class WebHookForm(url: String, events: Set[WebHook.Event], ctype: WebHookContentType, token: Option[String])
|
||||||
|
|
||||||
val webHookForm = mapping(
|
def webHookForm(update:Boolean) = mapping(
|
||||||
"url" -> trim(label("url", text(required, webHook)))
|
"url" -> trim(label("url", text(required, webHook(update)))),
|
||||||
)(WebHookForm.apply)
|
"events" -> webhookEvents,
|
||||||
|
"ctype" -> label("ctype", text()),
|
||||||
|
"token" -> optional(trim(label("token", text(maxlength(100)))))
|
||||||
|
)(
|
||||||
|
(url, events, ctype, token) => WebHookForm(url, events, WebHookContentType.valueOf(ctype), token)
|
||||||
|
)
|
||||||
|
|
||||||
// for transfer ownership
|
// for transfer ownership
|
||||||
case class TransferOwnerShipForm(newOwner: String)
|
case class TransferOwnerShipForm(newOwner: String)
|
||||||
@@ -74,15 +100,18 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
* Save the repository options.
|
* Save the repository options.
|
||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/options", optionsForm)(ownerOnly { (form, repository) =>
|
post("/:owner/:repository/settings/options", optionsForm)(ownerOnly { (form, repository) =>
|
||||||
val defaultBranch = if(repository.branchList.isEmpty) "master" else form.defaultBranch
|
|
||||||
saveRepositoryOptions(
|
saveRepositoryOptions(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
repository.name,
|
repository.name,
|
||||||
form.description,
|
form.description,
|
||||||
defaultBranch,
|
|
||||||
repository.repository.parentUserName.map { _ =>
|
repository.repository.parentUserName.map { _ =>
|
||||||
repository.repository.isPrivate
|
repository.repository.isPrivate
|
||||||
} getOrElse form.isPrivate
|
} getOrElse form.isPrivate,
|
||||||
|
form.issuesOption,
|
||||||
|
form.externalIssuesUrl,
|
||||||
|
form.wikiOption,
|
||||||
|
form.externalWikiUrl,
|
||||||
|
form.allowFork
|
||||||
)
|
)
|
||||||
// Change repository name
|
// Change repository name
|
||||||
if(repository.name != form.repositoryName){
|
if(repository.name != form.repositoryName){
|
||||||
@@ -97,14 +126,45 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
FileUtils.moveDirectory(dir, getWikiRepositoryDir(repository.owner, form.repositoryName))
|
FileUtils.moveDirectory(dir, getWikiRepositoryDir(repository.owner, form.repositoryName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Change repository HEAD
|
|
||||||
using(Git.open(getRepositoryDir(repository.owner, form.repositoryName))) { git =>
|
|
||||||
git.getRepository.updateRef(Constants.HEAD, true).link(Constants.R_HEADS + defaultBranch)
|
|
||||||
}
|
|
||||||
flash += "info" -> "Repository settings has been updated."
|
flash += "info" -> "Repository settings has been updated."
|
||||||
redirect(s"/${repository.owner}/${form.repositoryName}/settings/options")
|
redirect(s"/${repository.owner}/${form.repositoryName}/settings/options")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** branch settings */
|
||||||
|
get("/:owner/:repository/settings/branches")(ownerOnly { repository =>
|
||||||
|
val protecteions = getProtectedBranchList(repository.owner, repository.name)
|
||||||
|
html.branches(repository, protecteions, flash.get("info"))
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Update default branch */
|
||||||
|
post("/:owner/:repository/settings/update_default_branch", defaultBranchForm)(ownerOnly { (form, repository) =>
|
||||||
|
if(repository.branchList.find(_ == form.defaultBranch).isEmpty){
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/settings/options")
|
||||||
|
} else {
|
||||||
|
saveRepositoryDefaultBranch(repository.owner, repository.name, form.defaultBranch)
|
||||||
|
// Change repository HEAD
|
||||||
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
|
git.getRepository.updateRef(Constants.HEAD, true).link(Constants.R_HEADS + form.defaultBranch)
|
||||||
|
}
|
||||||
|
flash += "info" -> "Repository default branch has been updated."
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/settings/branches")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/** Branch protection for branch */
|
||||||
|
get("/:owner/:repository/settings/branches/:branch")(ownerOnly { repository =>
|
||||||
|
import gitbucket.core.api._
|
||||||
|
val branch = params("branch")
|
||||||
|
if(repository.branchList.find(_ == branch).isEmpty){
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/settings/branches")
|
||||||
|
} else {
|
||||||
|
val protection = ApiBranchProtection(getProtectedBranchInfo(repository.owner, repository.name, branch))
|
||||||
|
val lastWeeks = getRecentStatuesContexts(repository.owner, repository.name, org.joda.time.LocalDateTime.now.minusWeeks(1).toDate).toSet
|
||||||
|
val knownContexts = (lastWeeks ++ protection.status.contexts).toSeq.sortBy(identity)
|
||||||
|
html.branchprotection(repository, branch, protection, knownContexts, flash.get("info"))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the Collaborators page.
|
* Display the Collaborators page.
|
||||||
*/
|
*/
|
||||||
@@ -115,22 +175,12 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
repository)
|
repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
post("/:owner/:repository/settings/collaborators")(ownerOnly { repository =>
|
||||||
* Add the collaborator.
|
val collaborators = params("collaborators")
|
||||||
*/
|
removeCollaborators(repository.owner, repository.name)
|
||||||
post("/:owner/:repository/settings/collaborators/add", collaboratorForm)(ownerOnly { (form, repository) =>
|
collaborators.split(",").withFilter(_.nonEmpty).map { collaborator =>
|
||||||
if(!getAccountByUserName(repository.owner).get.isGroupAccount){
|
val userName :: role :: Nil = collaborator.split(":").toList
|
||||||
addCollaborator(repository.owner, repository.name, form.userName)
|
addCollaborator(repository.owner, repository.name, userName, role)
|
||||||
}
|
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/collaborators")
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the collaborator.
|
|
||||||
*/
|
|
||||||
get("/:owner/:repository/settings/collaborators/remove")(ownerOnly { repository =>
|
|
||||||
if(!getAccountByUserName(repository.owner).get.isGroupAccount){
|
|
||||||
removeCollaborator(repository.owner, repository.name, params("name"))
|
|
||||||
}
|
}
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/collaborators")
|
redirect(s"/${repository.owner}/${repository.name}/settings/collaborators")
|
||||||
})
|
})
|
||||||
@@ -139,14 +189,23 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
* Display the web hook page.
|
* Display the web hook page.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/settings/hooks")(ownerOnly { repository =>
|
get("/:owner/:repository/settings/hooks")(ownerOnly { repository =>
|
||||||
html.hooks(getWebHookURLs(repository.owner, repository.name), flash.get("url"), repository, flash.get("info"))
|
html.hooks(getWebHooks(repository.owner, repository.name), repository, flash.get("info"))
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the web hook edit page.
|
||||||
|
*/
|
||||||
|
get("/:owner/:repository/settings/hooks/new")(ownerOnly { repository =>
|
||||||
|
val webhook = WebHook(repository.owner, repository.name, "", WebHookContentType.FORM, None)
|
||||||
|
html.edithooks(webhook, Set(WebHook.Push), repository, flash.get("info"), true)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the web hook URL.
|
* Add the web hook URL.
|
||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/hooks/add", webHookForm)(ownerOnly { (form, repository) =>
|
post("/:owner/:repository/settings/hooks/new", webHookForm(false))(ownerOnly { (form, repository) =>
|
||||||
addWebHookURL(repository.owner, repository.name, form.url)
|
addWebHook(repository.owner, repository.name, form.url, form.events, form.ctype, form.token)
|
||||||
|
flash += "info" -> s"Webhook ${form.url} created"
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -154,32 +213,89 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
* Delete the web hook URL.
|
* Delete the web hook URL.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/settings/hooks/delete")(ownerOnly { repository =>
|
get("/:owner/:repository/settings/hooks/delete")(ownerOnly { repository =>
|
||||||
deleteWebHookURL(repository.owner, repository.name, params("url"))
|
deleteWebHook(repository.owner, repository.name, params("url"))
|
||||||
|
flash += "info" -> s"Webhook ${params("url")} deleted"
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the test request to registered web hook URLs.
|
* Send the test request to registered web hook URLs.
|
||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/hooks/test", webHookForm)(ownerOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/settings/hooks/test")(ownerOnly { repository =>
|
||||||
|
def _headers(h: Array[org.apache.http.Header]): Array[Array[String]] = h.map { h => Array(h.getName, h.getValue) }
|
||||||
|
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
val commits = if(repository.commitCount == 0) List.empty else git.log
|
import scala.concurrent.duration._
|
||||||
|
import scala.concurrent._
|
||||||
|
import scala.util.control.NonFatal
|
||||||
|
import org.apache.http.util.EntityUtils
|
||||||
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
|
|
||||||
|
val url = params("url")
|
||||||
|
val token = Some(params("token"))
|
||||||
|
val ctype = WebHookContentType.valueOf(params("ctype"))
|
||||||
|
val dummyWebHookInfo = WebHook(repository.owner, repository.name, url, ctype, token)
|
||||||
|
val dummyPayload = {
|
||||||
|
val ownerAccount = getAccountByUserName(repository.owner).get
|
||||||
|
val commits = if(JGitUtil.isEmpty(git)) List.empty else git.log
|
||||||
.add(git.getRepository.resolve(repository.repository.defaultBranch))
|
.add(git.getRepository.resolve(repository.repository.defaultBranch))
|
||||||
.setMaxCount(4)
|
.setMaxCount(4)
|
||||||
.call.iterator.asScala.map(new CommitInfo(_)).toList
|
.call.iterator.asScala.map(new CommitInfo(_)).toList
|
||||||
|
val pushedCommit = commits.drop(1)
|
||||||
|
|
||||||
getAccountByUserName(repository.owner).foreach { ownerAccount =>
|
WebHookPushPayload(
|
||||||
callWebHook("push",
|
git = git,
|
||||||
List(WebHook(repository.owner, repository.name, form.url)),
|
sender = ownerAccount,
|
||||||
WebHookPushPayload(git, ownerAccount, "refs/heads/" + repository.repository.defaultBranch, repository, (if(commits.isEmpty){Nil}else{commits.tail}), ownerAccount,
|
refName = "refs/heads/" + repository.repository.defaultBranch,
|
||||||
|
repositoryInfo = repository,
|
||||||
|
commits = pushedCommit,
|
||||||
|
repositoryOwner = ownerAccount,
|
||||||
oldId = commits.lastOption.map(_.id).map(ObjectId.fromString).getOrElse(ObjectId.zeroId()),
|
oldId = commits.lastOption.map(_.id).map(ObjectId.fromString).getOrElse(ObjectId.zeroId()),
|
||||||
newId = commits.headOption.map(_.id).map(ObjectId.fromString).getOrElse(ObjectId.zeroId()))
|
newId = commits.headOption.map(_.id).map(ObjectId.fromString).getOrElse(ObjectId.zeroId())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
flash += "url" -> form.url
|
|
||||||
flash += "info" -> "Test payload deployed!"
|
val (webHook, json, reqFuture, resFuture) = callWebHook(WebHook.Push, List(dummyWebHookInfo), dummyPayload).head
|
||||||
|
|
||||||
|
val toErrorMap: PartialFunction[Throwable, Map[String,String]] = {
|
||||||
|
case e: java.net.UnknownHostException => Map("error"-> ("Unknown host " + e.getMessage))
|
||||||
|
case e: java.lang.IllegalArgumentException => Map("error"-> ("invalid url"))
|
||||||
|
case e: org.apache.http.client.ClientProtocolException => Map("error"-> ("invalid url"))
|
||||||
|
case NonFatal(e) => Map("error"-> (e.getClass + " "+ e.getMessage))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contentType = formats("json")
|
||||||
|
org.json4s.jackson.Serialization.write(Map(
|
||||||
|
"url" -> url,
|
||||||
|
"request" -> Await.result(reqFuture.map(req => Map(
|
||||||
|
"headers" -> _headers(req.getAllHeaders),
|
||||||
|
"payload" -> json
|
||||||
|
)).recover(toErrorMap), 20 seconds),
|
||||||
|
"responce" -> Await.result(resFuture.map(res => Map(
|
||||||
|
"status" -> res.getStatusLine(),
|
||||||
|
"body" -> EntityUtils.toString(res.getEntity()),
|
||||||
|
"headers" -> _headers(res.getAllHeaders())
|
||||||
|
)).recover(toErrorMap), 20 seconds)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the web hook edit page.
|
||||||
|
*/
|
||||||
|
get("/:owner/:repository/settings/hooks/edit")(ownerOnly { repository =>
|
||||||
|
getWebHook(repository.owner, repository.name, params("url")).map{ case (webhook, events) =>
|
||||||
|
html.edithooks(webhook, events, repository, flash.get("info"), false)
|
||||||
|
} getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update web hook settings.
|
||||||
|
*/
|
||||||
|
post("/:owner/:repository/settings/hooks/edit", webHookForm(true))(ownerOnly { (form, repository) =>
|
||||||
|
updateWebHook(repository.owner, repository.name, form.url, form.events, form.ctype, form.token)
|
||||||
|
flash += "info" -> s"webhook ${form.url} updated"
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
redirect(s"/${repository.owner}/${repository.name}/settings/hooks")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -187,7 +303,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
* Display the danger zone.
|
* Display the danger zone.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/settings/danger")(ownerOnly {
|
get("/:owner/:repository/settings/danger")(ownerOnly {
|
||||||
html.danger(_)
|
html.danger(_, flash.get("info"))
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,28 +343,62 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides duplication check for web hook url.
|
* Run GC
|
||||||
*/
|
*/
|
||||||
private def webHook: Constraint = new Constraint(){
|
post("/:owner/:repository/settings/gc")(ownerOnly { repository =>
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
LockUtil.lock(s"${repository.owner}/${repository.name}") {
|
||||||
getWebHookURLs(params("owner"), params("repository")).map(_.url).find(_ == value).map(_ => "URL had been registered already.")
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
|
git.gc();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
flash += "info" -> "Garbage collection has been executed."
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/settings/danger")
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Constraint to validate the collaborator name.
|
* Provides duplication check for web hook url.
|
||||||
*/
|
*/
|
||||||
private def collaborator: 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] =
|
||||||
getAccountByUserName(value) match {
|
if(getWebHook(params("owner"), params("repository"), value).isDefined != needExists){
|
||||||
case None => Some("User does not exist.")
|
Some(if(needExists){
|
||||||
case Some(x) if(x.isGroupAccount)
|
"URL had not been registered yet."
|
||||||
=> Some("User does not exist.")
|
} else {
|
||||||
case Some(x) if(x.userName == params("owner") || getCollaborators(params("owner"), params("repository")).contains(x.userName))
|
"URL had been registered already."
|
||||||
=> Some("User can access this repository already.")
|
})
|
||||||
case _ => None
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def webhookEvents = new ValueType[Set[WebHook.Event]]{
|
||||||
|
def convert(name: String, params: Map[String, String], messages: Messages): Set[WebHook.Event] = {
|
||||||
|
WebHook.Event.values.flatMap { t =>
|
||||||
|
params.get(name + "." + t.name).map(_ => t)
|
||||||
|
}.toSet
|
||||||
|
}
|
||||||
|
def validate(name: String, params: Map[String, String], messages: Messages): Seq[(String, String)] = if(convert(name,params,messages).isEmpty){
|
||||||
|
Seq(name -> messages("error.required").format(name))
|
||||||
|
} else {
|
||||||
|
Nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Provides Constraint to validate the collaborator name.
|
||||||
|
// */
|
||||||
|
// private def collaborator: Constraint = new Constraint(){
|
||||||
|
// override def validate(name: String, value: String, messages: Messages): Option[String] =
|
||||||
|
// getAccountByUserName(value) match {
|
||||||
|
// case None => Some("User does not exist.")
|
||||||
|
//// case Some(x) if(x.isGroupAccount)
|
||||||
|
//// => Some("User does not exist.")
|
||||||
|
// case Some(x) if(x.userName == params("owner") || getCollaborators(params("owner"), params("repository")).contains(x.userName))
|
||||||
|
// => Some(value + " is repository owner.") // TODO also group members?
|
||||||
|
// case _ => None
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicate check for the rename repository name.
|
* Duplicate check for the rename repository name.
|
||||||
*/
|
*/
|
||||||
@@ -261,6 +411,15 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private def featureOption: Constraint = new Constraint(){
|
||||||
|
override def validate(name: String, value: String, params: Map[String, String], messages: Messages): Option[String] =
|
||||||
|
if(Seq("DISABLE", "PRIVATE", "PUBLIC", "ALL").contains(value)) None else Some("Option is invalid.")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Constraint to validate the repository transfer user.
|
* Provides Constraint to validate the repository transfer user.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.api._
|
import java.io.FileInputStream
|
||||||
|
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
||||||
|
|
||||||
import gitbucket.core.plugin.PluginRegistry
|
import gitbucket.core.plugin.PluginRegistry
|
||||||
import gitbucket.core.repo.html
|
import gitbucket.core.repo.html
|
||||||
import gitbucket.core.helper
|
import gitbucket.core.helper
|
||||||
@@ -11,14 +13,12 @@ import gitbucket.core.util.StringUtil._
|
|||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import gitbucket.core.model.{Account, CommitState}
|
import gitbucket.core.model.{Account, WebHook}
|
||||||
import gitbucket.core.service.CommitStatusService
|
|
||||||
import gitbucket.core.service.WebHookService._
|
import gitbucket.core.service.WebHookService._
|
||||||
import gitbucket.core.view
|
import gitbucket.core.view
|
||||||
import gitbucket.core.view.helpers
|
import gitbucket.core.view.helpers
|
||||||
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import org.apache.commons.io.IOUtils
|
||||||
import org.apache.commons.io.FileUtils
|
|
||||||
import org.eclipse.jgit.api.{ArchiveCommand, Git}
|
import org.eclipse.jgit.api.{ArchiveCommand, Git}
|
||||||
import org.eclipse.jgit.archive.{TgzFormat, ZipFormat}
|
import org.eclipse.jgit.archive.{TgzFormat, ZipFormat}
|
||||||
import org.eclipse.jgit.dircache.DirCache
|
import org.eclipse.jgit.dircache.DirCache
|
||||||
@@ -31,16 +31,16 @@ import org.scalatra._
|
|||||||
|
|
||||||
class RepositoryViewerController extends RepositoryViewerControllerBase
|
class RepositoryViewerController extends RepositoryViewerControllerBase
|
||||||
with RepositoryService with AccountService with ActivityService with IssuesService with WebHookService with CommitsService
|
with RepositoryService with AccountService with ActivityService with IssuesService with WebHookService with CommitsService
|
||||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator with PullRequestService with CommitStatusService
|
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator with PullRequestService with CommitStatusService
|
||||||
with WebHookPullRequestService
|
with WebHookPullRequestService with WebHookPullRequestReviewCommentService with ProtectedBranchService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The repository viewer.
|
* The repository viewer.
|
||||||
*/
|
*/
|
||||||
trait RepositoryViewerControllerBase extends ControllerBase {
|
trait RepositoryViewerControllerBase extends ControllerBase {
|
||||||
self: RepositoryService with AccountService with ActivityService with IssuesService with WebHookService with CommitsService
|
self: RepositoryService with AccountService with ActivityService with IssuesService with WebHookService with CommitsService
|
||||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator with PullRequestService with CommitStatusService
|
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator with PullRequestService with CommitStatusService
|
||||||
with WebHookPullRequestService =>
|
with WebHookPullRequestService with WebHookPullRequestReviewCommentService with ProtectedBranchService =>
|
||||||
|
|
||||||
ArchiveCommand.registerFormat("zip", new ZipFormat)
|
ArchiveCommand.registerFormat("zip", new ZipFormat)
|
||||||
ArchiveCommand.registerFormat("tar.gz", new TgzFormat)
|
ArchiveCommand.registerFormat("tar.gz", new TgzFormat)
|
||||||
@@ -102,32 +102,47 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
post("/:owner/:repository/_preview")(referrersOnly { repository =>
|
post("/:owner/:repository/_preview")(referrersOnly { repository =>
|
||||||
contentType = "text/html"
|
contentType = "text/html"
|
||||||
helpers.markdown(params("content"), repository,
|
val filename = params.get("filename")
|
||||||
params("enableWikiLink").toBoolean,
|
filename match {
|
||||||
params("enableRefsLink").toBoolean,
|
case Some(f) => helpers.renderMarkup(
|
||||||
params("enableTaskList").toBoolean,
|
filePath = List(f),
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
fileContent = params("content"),
|
||||||
|
branch = "master",
|
||||||
|
repository = repository,
|
||||||
|
enableWikiLink = params("enableWikiLink").toBoolean,
|
||||||
|
enableRefsLink = params("enableRefsLink").toBoolean,
|
||||||
|
enableAnchor = false
|
||||||
|
)
|
||||||
|
case None => helpers.markdown(
|
||||||
|
markdown = params("content"),
|
||||||
|
repository = repository,
|
||||||
|
enableWikiLink = params("enableWikiLink").toBoolean,
|
||||||
|
enableRefsLink = params("enableRefsLink").toBoolean,
|
||||||
|
enableLineBreaks = params("enableLineBreaks").toBoolean,
|
||||||
|
enableTaskList = params("enableTaskList").toBoolean,
|
||||||
|
enableAnchor = false,
|
||||||
|
hasWritePermission = hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the file list of the repository root and the default branch.
|
* Displays the file list of the repository root and the default branch.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository")(referrersOnly {
|
get("/:owner/:repository") {
|
||||||
fileList(_)
|
params.get("go-get") match {
|
||||||
})
|
case Some("1") => defining(request.paths){ paths =>
|
||||||
|
getRepository(paths(0), paths(1)).map(gitbucket.core.html.goget(_))getOrElse NotFound()
|
||||||
/**
|
}
|
||||||
* https://developer.github.com/v3/repos/#get
|
case _ => referrersOnly(fileList(_))
|
||||||
*/
|
}
|
||||||
get("/api/v3/repos/:owner/:repository")(referrersOnly { repository =>
|
}
|
||||||
JsonFormat(ApiRepository(repository, ApiUser(getAccountByUserName(repository.owner).get)))
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the file list of the specified path and branch.
|
* Displays the file list of the specified path and branch.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/tree/*")(referrersOnly { repository =>
|
get("/:owner/:repository/tree/*")(referrersOnly { repository =>
|
||||||
val (id, path) = splitPath(repository, multiParams("splat").head)
|
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||||
if(path.isEmpty){
|
if(path.isEmpty){
|
||||||
fileList(repository, id)
|
fileList(repository, id)
|
||||||
} else {
|
} else {
|
||||||
@@ -139,7 +154,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
* Displays the commit list of the specified resource.
|
* Displays the commit list of the specified resource.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/commits/*")(referrersOnly { repository =>
|
get("/:owner/:repository/commits/*")(referrersOnly { repository =>
|
||||||
val (branchName, path) = splitPath(repository, multiParams("splat").head)
|
val (branchName, path) = repository.splitPath(multiParams("splat").head)
|
||||||
val page = params.get("page").flatMap(_.toIntOpt).getOrElse(1)
|
val page = params.get("page").flatMap(_.toIntOpt).getOrElse(1)
|
||||||
|
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
@@ -148,70 +163,23 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
html.commits(if(path.isEmpty) Nil else path.split("/").toList, branchName, repository,
|
html.commits(if(path.isEmpty) Nil else path.split("/").toList, branchName, repository,
|
||||||
logs.splitWith{ (commit1, commit2) =>
|
logs.splitWith{ (commit1, commit2) =>
|
||||||
view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
||||||
}, page, hasNext, hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
}, page, hasNext, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
case Left(_) => NotFound
|
case Left(_) => NotFound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
get("/:owner/:repository/new/*")(writableUsersOnly { repository =>
|
||||||
* https://developer.github.com/v3/repos/statuses/#create-a-status
|
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
||||||
*/
|
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch).needStatusCheck(context.loginAccount.get.userName)
|
||||||
post("/api/v3/repos/:owner/:repo/statuses/:sha")(collaboratorsOnly { repository =>
|
|
||||||
(for{
|
|
||||||
ref <- params.get("sha")
|
|
||||||
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
|
||||||
data <- extractFromJsonBody[CreateAStatus] if data.isValid
|
|
||||||
creator <- context.loginAccount
|
|
||||||
state <- CommitState.valueOf(data.state)
|
|
||||||
statusId = createCommitStatus(repository.owner, repository.name, sha, data.context.getOrElse("default"),
|
|
||||||
state, data.target_url, data.description, new java.util.Date(), creator)
|
|
||||||
status <- getCommitStatus(repository.owner, repository.name, statusId)
|
|
||||||
} yield {
|
|
||||||
JsonFormat(ApiCommitStatus(status, ApiUser(creator)))
|
|
||||||
}) getOrElse NotFound
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref
|
|
||||||
*
|
|
||||||
* ref is Ref to list the statuses from. It can be a SHA, a branch name, or a tag name.
|
|
||||||
*/
|
|
||||||
get("/api/v3/repos/:owner/:repo/commits/:ref/statuses")(referrersOnly { repository =>
|
|
||||||
(for{
|
|
||||||
ref <- params.get("ref")
|
|
||||||
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
|
||||||
} yield {
|
|
||||||
JsonFormat(getCommitStatuesWithCreator(repository.owner, repository.name, sha).map{ case(status, creator) =>
|
|
||||||
ApiCommitStatus(status, ApiUser(creator))
|
|
||||||
})
|
|
||||||
}) getOrElse NotFound
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
|
|
||||||
*
|
|
||||||
* ref is Ref to list the statuses from. It can be a SHA, a branch name, or a tag name.
|
|
||||||
*/
|
|
||||||
get("/api/v3/repos/:owner/:repo/commits/:ref/status")(referrersOnly { repository =>
|
|
||||||
(for{
|
|
||||||
ref <- params.get("ref")
|
|
||||||
owner <- getAccountByUserName(repository.owner)
|
|
||||||
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
|
||||||
} yield {
|
|
||||||
val statuses = getCommitStatuesWithCreator(repository.owner, repository.name, sha)
|
|
||||||
JsonFormat(ApiCombinedCommitStatus(sha, statuses, ApiRepository(repository, owner)))
|
|
||||||
}) getOrElse NotFound
|
|
||||||
})
|
|
||||||
|
|
||||||
get("/:owner/:repository/new/*")(collaboratorsOnly { repository =>
|
|
||||||
val (branch, path) = splitPath(repository, multiParams("splat").head)
|
|
||||||
html.editor(branch, repository, if(path.length == 0) Nil else path.split("/").toList,
|
html.editor(branch, repository, if(path.length == 0) Nil else path.split("/").toList,
|
||||||
None, JGitUtil.ContentInfo("text", None, Some("UTF-8")))
|
None, JGitUtil.ContentInfo("text", None, Some("UTF-8")),
|
||||||
|
protectedBranch)
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/edit/*")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/edit/*")(writableUsersOnly { repository =>
|
||||||
val (branch, path) = splitPath(repository, multiParams("splat").head)
|
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
||||||
|
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch).needStatusCheck(context.loginAccount.get.userName)
|
||||||
|
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(branch))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(branch))
|
||||||
@@ -219,13 +187,14 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
getPathObjectId(git, path, revCommit).map { objectId =>
|
getPathObjectId(git, path, revCommit).map { objectId =>
|
||||||
val paths = path.split("/")
|
val paths = path.split("/")
|
||||||
html.editor(branch, repository, paths.take(paths.size - 1).toList, Some(paths.last),
|
html.editor(branch, repository, paths.take(paths.size - 1).toList, Some(paths.last),
|
||||||
JGitUtil.getContentInfo(git, path, objectId))
|
JGitUtil.getContentInfo(git, path, objectId),
|
||||||
} getOrElse NotFound
|
protectedBranch)
|
||||||
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/remove/*")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/remove/*")(writableUsersOnly { repository =>
|
||||||
val (branch, path) = splitPath(repository, multiParams("splat").head)
|
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(branch))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(branch))
|
||||||
|
|
||||||
@@ -233,11 +202,11 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val paths = path.split("/")
|
val paths = path.split("/")
|
||||||
html.delete(branch, repository, paths.take(paths.size - 1).toList, paths.last,
|
html.delete(branch, repository, paths.take(paths.size - 1).toList, paths.last,
|
||||||
JGitUtil.getContentInfo(git, path, objectId))
|
JGitUtil.getContentInfo(git, path, objectId))
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/create", editorForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/create", editorForm)(writableUsersOnly { (form, repository) =>
|
||||||
commitFile(
|
commitFile(
|
||||||
repository = repository,
|
repository = repository,
|
||||||
branch = form.branch,
|
branch = form.branch,
|
||||||
@@ -254,7 +223,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
}")
|
}")
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/update", editorForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/update", editorForm)(writableUsersOnly { (form, repository) =>
|
||||||
commitFile(
|
commitFile(
|
||||||
repository = repository,
|
repository = repository,
|
||||||
branch = form.branch,
|
branch = form.branch,
|
||||||
@@ -275,42 +244,91 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
}")
|
}")
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/remove", deleteForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/remove", deleteForm)(writableUsersOnly { (form, repository) =>
|
||||||
commitFile(repository, form.branch, form.path, None, Some(form.fileName), "", "",
|
commitFile(repository, form.branch, form.path, None, Some(form.fileName), "", "",
|
||||||
form.message.getOrElse(s"Delete ${form.fileName}"))
|
form.message.getOrElse(s"Delete ${form.fileName}"))
|
||||||
|
|
||||||
redirect(s"/${repository.owner}/${repository.name}/tree/${form.branch}${if(form.path.length == 0) "" else form.path}")
|
redirect(s"/${repository.owner}/${repository.name}/tree/${form.branch}${if(form.path.length == 0) "" else form.path}")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
get("/:owner/:repository/raw/*")(referrersOnly { repository =>
|
||||||
|
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||||
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||||
|
|
||||||
|
getPathObjectId(git, path, revCommit).map { objectId =>
|
||||||
|
responseRawFile(git, objectId, path, repository)
|
||||||
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the file content of the specified branch or commit.
|
* Displays the file content of the specified branch or commit.
|
||||||
*/
|
*/
|
||||||
val blobRoute = get("/:owner/:repository/blob/*")(referrersOnly { repository =>
|
val blobRoute = get("/:owner/:repository/blob/*")(referrersOnly { repository =>
|
||||||
val (id, path) = splitPath(repository, multiParams("splat").head)
|
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||||
val raw = params.get("raw").getOrElse("false").toBoolean
|
val raw = params.get("raw").getOrElse("false").toBoolean
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||||
getPathObjectId(git, path, revCommit).map { objectId =>
|
getPathObjectId(git, path, revCommit).map { objectId =>
|
||||||
if(raw){
|
if(raw){
|
||||||
// Download
|
// Download (This route is left for backword compatibility)
|
||||||
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
responseRawFile(git, objectId, path, repository)
|
||||||
//RawData("application/octet-stream", bytes)
|
|
||||||
contentType = "application/octet-stream"
|
|
||||||
response.setContentLength(loader.getSize.toInt)
|
|
||||||
loader.copyTo(response.getOutputStream)
|
|
||||||
()
|
|
||||||
} getOrElse NotFound
|
|
||||||
} else {
|
} else {
|
||||||
html.blob(id, repository, path.split("/").toList,
|
html.blob(id, repository, path.split("/").toList,
|
||||||
JGitUtil.getContentInfo(git, path, objectId),
|
JGitUtil.getContentInfo(git, path, objectId),
|
||||||
new JGitUtil.CommitInfo(JGitUtil.getLastModifiedCommit(git, revCommit, path)),
|
new JGitUtil.CommitInfo(JGitUtil.getLastModifiedCommit(git, revCommit, path)),
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount),
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||||
request.paths(2) == "blame")
|
request.paths(2) == "blame",
|
||||||
|
isLfsFile(git, objectId))
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
private def isLfsFile(git: Git, objectId: ObjectId): Boolean = {
|
||||||
|
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
||||||
|
if(loader.isLarge){
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
new String(loader.getCachedBytes, "UTF-8").startsWith("version https://git-lfs.github.com/spec/v1")
|
||||||
|
}
|
||||||
|
}.getOrElse(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private def responseRawFile(git: Git, objectId: ObjectId, path: String,
|
||||||
|
repository: RepositoryService.RepositoryInfo): Unit = {
|
||||||
|
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
||||||
|
contentType = FileUtil.getMimeType(path)
|
||||||
|
|
||||||
|
if(loader.isLarge){
|
||||||
|
response.setContentLength(loader.getSize.toInt)
|
||||||
|
loader.copyTo(response.outputStream)
|
||||||
|
} else {
|
||||||
|
val bytes = loader.getCachedBytes
|
||||||
|
val text = new String(bytes, "UTF-8")
|
||||||
|
|
||||||
|
if(text.startsWith("version https://git-lfs.github.com/spec/v1")){
|
||||||
|
// LFS objects
|
||||||
|
val attrs = text.split("\n").map { line =>
|
||||||
|
val dim = line.split(" ")
|
||||||
|
dim(0) -> dim(1)
|
||||||
|
}.toMap
|
||||||
|
|
||||||
|
response.setContentLength(attrs("size").toInt)
|
||||||
|
val oid = attrs("oid").split(":")(1)
|
||||||
|
|
||||||
|
using(new FileInputStream(FileUtil.getLfsFilePath(repository.owner, repository.name, oid))){ in =>
|
||||||
|
IOUtils.copy(in, response.getOutputStream)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
response.setContentLength(loader.getSize.toInt)
|
||||||
|
response.getOutputStream.write(bytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get("/:owner/:repository/blame/*"){
|
get("/:owner/:repository/blame/*"){
|
||||||
blobRoute.action()
|
blobRoute.action()
|
||||||
}
|
}
|
||||||
@@ -319,7 +337,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
* Blame data.
|
* Blame data.
|
||||||
*/
|
*/
|
||||||
ajaxGet("/:owner/:repository/get-blame/*")(referrersOnly { repository =>
|
ajaxGet("/:owner/:repository/get-blame/*")(referrersOnly { repository =>
|
||||||
val (id, path) = splitPath(repository, multiParams("splat").head)
|
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
val last = git.log.add(git.getRepository.resolve(id)).addPath(path).setMaxCount(1).call.iterator.next.name
|
val last = git.log.add(git.getRepository.resolve(id)).addPath(path).setMaxCount(1).call.iterator.next.name
|
||||||
@@ -357,20 +375,20 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
html.commit(id, new JGitUtil.CommitInfo(revCommit),
|
html.commit(id, new JGitUtil.CommitInfo(revCommit),
|
||||||
JGitUtil.getBranchesOfCommit(git, revCommit.getName),
|
JGitUtil.getBranchesOfCommit(git, revCommit.getName),
|
||||||
JGitUtil.getTagsOfCommit(git, revCommit.getName),
|
JGitUtil.getTagsOfCommit(git, revCommit.getName),
|
||||||
getCommitComments(repository.owner, repository.name, id, false),
|
getCommitComments(repository.owner, repository.name, id, true),
|
||||||
repository, diffs, oldCommitId, hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
repository, diffs, oldCommitId, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
case e:MissingObjectException => NotFound
|
case e:MissingObjectException => NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/commit/:id/comment/new", commentForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/commit/:id/comment/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
val id = params("id")
|
val id = params("id")
|
||||||
createCommitComment(repository.owner, repository.name, id, context.loginAccount.get.userName, form.content,
|
createCommitComment(repository.owner, repository.name, id, context.loginAccount.get.userName, form.content,
|
||||||
form.fileName, form.oldLineNumber, form.newLineNumber, form.issueId.isDefined)
|
form.fileName, form.oldLineNumber, form.newLineNumber, form.issueId)
|
||||||
form.issueId match {
|
form.issueId match {
|
||||||
case Some(issueId) => recordCommentPullRequestActivity(repository.owner, repository.name, context.loginAccount.get.userName, issueId, form.content)
|
case Some(issueId) => recordCommentPullRequestActivity(repository.owner, repository.name, context.loginAccount.get.userName, issueId, form.content)
|
||||||
case None => recordCommentCommitActivity(repository.owner, repository.name, context.loginAccount.get.userName, id, form.content)
|
case None => recordCommentCommitActivity(repository.owner, repository.name, context.loginAccount.get.userName, id, form.content)
|
||||||
@@ -387,7 +405,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
html.commentform(
|
html.commentform(
|
||||||
commitId = id,
|
commitId = id,
|
||||||
fileName, oldLineNumber, newLineNumber, issueId,
|
fileName, oldLineNumber, newLineNumber, issueId,
|
||||||
hasWritePermission = hasWritePermission(repository.owner, repository.name, context.loginAccount),
|
hasWritePermission = hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||||
repository = repository
|
repository = repository
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -395,30 +413,39 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
ajaxPost("/:owner/:repository/commit/:id/comment/_data/new", commentForm)(readableUsersOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/commit/:id/comment/_data/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
val id = params("id")
|
val id = params("id")
|
||||||
val commentId = createCommitComment(repository.owner, repository.name, id, context.loginAccount.get.userName,
|
val commentId = createCommitComment(repository.owner, repository.name, id, context.loginAccount.get.userName,
|
||||||
form.content, form.fileName, form.oldLineNumber, form.newLineNumber, form.issueId.isDefined)
|
form.content, form.fileName, form.oldLineNumber, form.newLineNumber, form.issueId)
|
||||||
|
val comment = getCommitComment(repository.owner, repository.name, commentId.toString).get
|
||||||
form.issueId match {
|
form.issueId match {
|
||||||
case Some(issueId) => recordCommentPullRequestActivity(repository.owner, repository.name, context.loginAccount.get.userName, issueId, form.content)
|
case Some(issueId) =>
|
||||||
|
recordCommentPullRequestActivity(repository.owner, repository.name, context.loginAccount.get.userName, issueId, form.content)
|
||||||
|
callPullRequestReviewCommentWebHook("create", comment, repository, issueId, context.baseUrl, context.loginAccount.get)
|
||||||
case None => recordCommentCommitActivity(repository.owner, repository.name, context.loginAccount.get.userName, id, form.content)
|
case None => recordCommentCommitActivity(repository.owner, repository.name, context.loginAccount.get.userName, id, form.content)
|
||||||
}
|
}
|
||||||
helper.html.commitcomment(getCommitComment(repository.owner, repository.name, commentId.toString).get,
|
helper.html.commitcomment(comment, hasDeveloperRole(repository.owner, repository.name, context.loginAccount), repository)
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount), repository)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/commit_comments/_data/:id")(readableUsersOnly { repository =>
|
ajaxGet("/:owner/:repository/commit_comments/_data/:id")(readableUsersOnly { repository =>
|
||||||
getCommitComment(repository.owner, repository.name, params("id")) map { x =>
|
getCommitComment(repository.owner, repository.name, params("id")) map { x =>
|
||||||
if(isEditable(x.userName, x.repositoryName, x.commentedUserName)){
|
if(isEditable(x.userName, x.repositoryName, x.commentedUserName)){
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editcomment(
|
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
|
||||||
x.content, x.commentId, x.userName, x.repositoryName)
|
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
Map("content" -> view.Markdown.toHtml(x.content,
|
Map(
|
||||||
repository, false, true, true, isEditable(x.userName, x.repositoryName, x.commentedUserName))
|
"content" -> view.Markdown.toHtml(
|
||||||
|
markdown = x.content,
|
||||||
|
repository = repository,
|
||||||
|
enableWikiLink = false,
|
||||||
|
enableRefsLink = true,
|
||||||
|
enableAnchor = true,
|
||||||
|
enableLineBreaks = true,
|
||||||
|
hasWritePermission = true
|
||||||
|
)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/commit_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/commit_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
@@ -427,8 +454,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
if(isEditable(owner, name, comment.commentedUserName)){
|
if(isEditable(owner, name, comment.commentedUserName)){
|
||||||
updateCommitComment(comment.commentId, form.content)
|
updateCommitComment(comment.commentId, form.content)
|
||||||
redirect(s"/${owner}/${name}/commit_comments/_data/${comment.commentId}")
|
redirect(s"/${owner}/${name}/commit_comments/_data/${comment.commentId}")
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -437,8 +464,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
getCommitComment(owner, name, params("id")).map { comment =>
|
getCommitComment(owner, name, params("id")).map { comment =>
|
||||||
if(isEditable(owner, name, comment.commentedUserName)){
|
if(isEditable(owner, name, comment.commentedUserName)){
|
||||||
Ok(deleteCommitComment(comment.commentId))
|
Ok(deleteCommitComment(comment.commentId))
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -446,6 +473,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
* Displays branches.
|
* Displays branches.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/branches")(referrersOnly { repository =>
|
get("/:owner/:repository/branches")(referrersOnly { repository =>
|
||||||
|
val protectedBranches = getProtectedBranchList(repository.owner, repository.name).toSet
|
||||||
val branches = JGitUtil.getBranches(
|
val branches = JGitUtil.getBranches(
|
||||||
owner = repository.owner,
|
owner = repository.owner,
|
||||||
name = repository.name,
|
name = repository.name,
|
||||||
@@ -453,16 +481,16 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
origin = repository.repository.originUserName.isEmpty
|
origin = repository.repository.originUserName.isEmpty
|
||||||
)
|
)
|
||||||
.sortBy(br => (br.mergeInfo.isEmpty, br.commitTime))
|
.sortBy(br => (br.mergeInfo.isEmpty, br.commitTime))
|
||||||
.map(br => br -> getPullRequestByRequestCommit(repository.owner, repository.name, repository.repository.defaultBranch, br.name, br.commitId))
|
.map(br => (br, getPullRequestByRequestCommit(repository.owner, repository.name, repository.repository.defaultBranch, br.name, br.commitId), protectedBranches.contains(br.name)))
|
||||||
.reverse
|
.reverse
|
||||||
|
|
||||||
html.branches(branches, hasWritePermission(repository.owner, repository.name, context.loginAccount), repository)
|
html.branches(branches, hasDeveloperRole(repository.owner, repository.name, context.loginAccount), repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a branch.
|
* Creates a branch.
|
||||||
*/
|
*/
|
||||||
post("/:owner/:repository/branches")(collaboratorsOnly { repository =>
|
post("/:owner/:repository/branches")(writableUsersOnly { repository =>
|
||||||
val newBranchName = params.getOrElse("new", halt(400))
|
val newBranchName = params.getOrElse("new", halt(400))
|
||||||
val fromBranchName = params.getOrElse("from", halt(400))
|
val fromBranchName = params.getOrElse("from", halt(400))
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
@@ -480,7 +508,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
/**
|
/**
|
||||||
* Deletes branch.
|
* Deletes branch.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/delete/*")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/delete/*")(writableUsersOnly { repository =>
|
||||||
val branchName = multiParams("splat").head
|
val branchName = multiParams("splat").head
|
||||||
val userName = context.loginAccount.get.userName
|
val userName = context.loginAccount.get.userName
|
||||||
if(repository.repository.defaultBranch != branchName){
|
if(repository.repository.defaultBranch != branchName){
|
||||||
@@ -508,20 +536,25 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
archiveRepository(name, ".zip", repository)
|
archiveRepository(name, ".zip", repository)
|
||||||
case name if name.endsWith(".tar.gz") =>
|
case name if name.endsWith(".tar.gz") =>
|
||||||
archiveRepository(name, ".tar.gz", repository)
|
archiveRepository(name, ".tar.gz", repository)
|
||||||
case _ => BadRequest
|
case _ => BadRequest()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/network/members")(referrersOnly { repository =>
|
get("/:owner/:repository/network/members")(referrersOnly { repository =>
|
||||||
|
if(repository.repository.options.allowFork) {
|
||||||
html.forked(
|
html.forked(
|
||||||
getRepository(
|
getRepository(
|
||||||
repository.repository.originUserName.getOrElse(repository.owner),
|
repository.repository.originUserName.getOrElse(repository.owner),
|
||||||
repository.repository.originRepositoryName.getOrElse(repository.name),
|
repository.repository.originRepositoryName.getOrElse(repository.name)),
|
||||||
context.baseUrl),
|
|
||||||
getForkedRepositories(
|
getForkedRepositories(
|
||||||
repository.repository.originUserName.getOrElse(repository.owner),
|
repository.repository.originUserName.getOrElse(repository.owner),
|
||||||
repository.repository.originRepositoryName.getOrElse(repository.name)),
|
repository.repository.originRepositoryName.getOrElse(repository.name)),
|
||||||
|
context.loginAccount match {
|
||||||
|
case None => List()
|
||||||
|
case account: Option[Account] => getGroupsByUserName(account.get.userName)
|
||||||
|
}, // groups of current user
|
||||||
repository)
|
repository)
|
||||||
|
} else BadRequest()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -531,14 +564,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
val ref = multiParams("splat").head
|
val ref = multiParams("splat").head
|
||||||
JGitUtil.getTreeId(git, ref).map{ treeId =>
|
JGitUtil.getTreeId(git, ref).map{ treeId =>
|
||||||
html.find(ref,
|
html.find(ref, treeId, repository)
|
||||||
treeId,
|
} getOrElse NotFound()
|
||||||
repository,
|
|
||||||
context.loginAccount match {
|
|
||||||
case None => List()
|
|
||||||
case account: Option[Account] => getGroupsByUserName(account.get.userName)
|
|
||||||
})
|
|
||||||
} getOrElse NotFound
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -553,17 +580,6 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
private def splitPath(repository: RepositoryService.RepositoryInfo, path: String): (String, String) = {
|
|
||||||
val id = repository.branchList.collectFirst {
|
|
||||||
case branch if(path == branch || path.startsWith(branch + "/")) => branch
|
|
||||||
} orElse repository.tags.collectFirst {
|
|
||||||
case tag if(path == tag.name || path.startsWith(tag.name + "/")) => tag.name
|
|
||||||
} getOrElse path.split("/")(0)
|
|
||||||
|
|
||||||
(id, path.substring(id.length).stripPrefix("/"))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private val readmeFiles = PluginRegistry().renderableExtensions.map { extension =>
|
private val readmeFiles = PluginRegistry().renderableExtensions.map { extension =>
|
||||||
s"readme.${extension}"
|
s"readme.${extension}"
|
||||||
} ++ Seq("readme.txt", "readme")
|
} ++ Seq("readme.txt", "readme")
|
||||||
@@ -577,10 +593,10 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
* @return HTML of the file list
|
* @return HTML of the file list
|
||||||
*/
|
*/
|
||||||
private def fileList(repository: RepositoryService.RepositoryInfo, revstr: String = "", path: String = ".") = {
|
private def fileList(repository: RepositoryService.RepositoryInfo, revstr: String = "", path: String = ".") = {
|
||||||
if(repository.commitCount == 0){
|
|
||||||
html.guide(repository, hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
|
||||||
} else {
|
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
|
if(JGitUtil.isEmpty(git)){
|
||||||
|
html.guide(repository, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
|
} else {
|
||||||
// get specified commit
|
// get specified commit
|
||||||
JGitUtil.getDefaultBranch(git, repository, revstr).map { case (objectId, revision) =>
|
JGitUtil.getDefaultBranch(git, repository, revstr).map { case (objectId, revision) =>
|
||||||
defining(JGitUtil.getRevCommitFromId(git, objectId)) { revCommit =>
|
defining(JGitUtil.getRevCommitFromId(git, objectId)) { revCommit =>
|
||||||
@@ -590,7 +606,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val parentPath = if (path == ".") Nil else path.split("/").toList
|
val parentPath = if (path == ".") Nil else path.split("/").toList
|
||||||
// process README.md or README.markdown
|
// process README.md or README.markdown
|
||||||
val readme = files.find { file =>
|
val readme = files.find { file =>
|
||||||
readmeFiles.contains(file.name.toLowerCase)
|
!file.isDirectory && readmeFiles.contains(file.name.toLowerCase)
|
||||||
}.map { file =>
|
}.map { file =>
|
||||||
val path = (file.name :: parentPath.reverse).reverse
|
val path = (file.name :: parentPath.reverse).reverse
|
||||||
path -> StringUtil.convertFromByteArray(JGitUtil.getContentFromId(
|
path -> StringUtil.convertFromByteArray(JGitUtil.getContentFromId(
|
||||||
@@ -599,16 +615,17 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
html.files(revision, repository,
|
html.files(revision, repository,
|
||||||
if(path == ".") Nil else path.split("/").toList, // current path
|
if(path == ".") Nil else path.split("/").toList, // current path
|
||||||
context.loginAccount match {
|
|
||||||
case None => List()
|
|
||||||
case account: Option[Account] => getGroupsByUserName(account.get.userName)
|
|
||||||
}, // groups of current user
|
|
||||||
new JGitUtil.CommitInfo(lastModifiedCommit), // last modified commit
|
new JGitUtil.CommitInfo(lastModifiedCommit), // last modified commit
|
||||||
files, readme, hasWritePermission(repository.owner, repository.name, context.loginAccount),
|
JGitUtil.getCommitCount(repository.owner, repository.name, revision),
|
||||||
|
files,
|
||||||
|
readme,
|
||||||
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||||
getPullRequestFromBranch(repository.owner, repository.name, revstr, repository.repository.defaultBranch),
|
getPullRequestFromBranch(repository.owner, repository.name, revstr, repository.repository.defaultBranch),
|
||||||
flash.get("info"), flash.get("error"))
|
flash.get("info"),
|
||||||
|
flash.get("error")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -628,14 +645,18 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val headName = s"refs/heads/${branch}"
|
val headName = s"refs/heads/${branch}"
|
||||||
val headTip = git.getRepository.resolve(headName)
|
val headTip = git.getRepository.resolve(headName)
|
||||||
|
|
||||||
JGitUtil.processTree(git, headTip){ (path, tree) =>
|
val permission = JGitUtil.processTree(git, headTip){ (path, tree) =>
|
||||||
|
// Add all entries except the editing file
|
||||||
if(!newPath.exists(_ == path) && !oldPath.exists(_ == path)){
|
if(!newPath.exists(_ == path) && !oldPath.exists(_ == path)){
|
||||||
builder.add(JGitUtil.createDirCacheEntry(path, tree.getEntryFileMode, tree.getEntryObjectId))
|
builder.add(JGitUtil.createDirCacheEntry(path, tree.getEntryFileMode, tree.getEntryObjectId))
|
||||||
}
|
}
|
||||||
}
|
// Retrieve permission if file exists to keep it
|
||||||
|
oldPath.collect { case x if x == path => tree.getEntryFileMode.getBits }
|
||||||
|
}.flatten.headOption
|
||||||
|
|
||||||
newPath.foreach { newPath =>
|
newPath.foreach { newPath =>
|
||||||
builder.add(JGitUtil.createDirCacheEntry(newPath, FileMode.REGULAR_FILE,
|
builder.add(JGitUtil.createDirCacheEntry(newPath,
|
||||||
|
permission.map { bits => FileMode.fromBits(bits) } getOrElse FileMode.REGULAR_FILE,
|
||||||
inserter.insert(Constants.OBJ_BLOB, content.getBytes(charset))))
|
inserter.insert(Constants.OBJ_BLOB, content.getBytes(charset))))
|
||||||
}
|
}
|
||||||
builder.finish()
|
builder.finish()
|
||||||
@@ -644,7 +665,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
headName, loginAccount.fullName, loginAccount.mailAddress, message)
|
headName, loginAccount.fullName, loginAccount.mailAddress, message)
|
||||||
|
|
||||||
inserter.flush()
|
inserter.flush()
|
||||||
inserter.release()
|
inserter.close()
|
||||||
|
|
||||||
// update refs
|
// update refs
|
||||||
val refUpdate = git.getRepository.updateRef(headName)
|
val refUpdate = git.getRepository.updateRef(headName)
|
||||||
@@ -658,8 +679,11 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
updatePullRequests(repository.owner, repository.name, branch)
|
updatePullRequests(repository.owner, repository.name, branch)
|
||||||
|
|
||||||
// record activity
|
// record activity
|
||||||
recordPushActivity(repository.owner, repository.name, loginAccount.userName, branch,
|
val commitInfo = new CommitInfo(JGitUtil.getRevCommitFromId(git, commitId))
|
||||||
List(new CommitInfo(JGitUtil.getRevCommitFromId(git, commitId))))
|
recordPushActivity(repository.owner, repository.name, loginAccount.userName, branch, List(commitInfo))
|
||||||
|
|
||||||
|
// create issue comment by commit message
|
||||||
|
createIssueComment(repository.owner, repository.name, commitInfo)
|
||||||
|
|
||||||
// close issue by commit message
|
// close issue by commit message
|
||||||
closeIssuesFromMessage(message, loginAccount.userName, repository.owner, repository.name)
|
closeIssuesFromMessage(message, loginAccount.userName, repository.owner, repository.name)
|
||||||
@@ -667,7 +691,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
// call web hook
|
// call web hook
|
||||||
callPullRequestWebHookByRequestBranch("synchronize", repository, branch, context.baseUrl, loginAccount)
|
callPullRequestWebHookByRequestBranch("synchronize", repository, branch, context.baseUrl, loginAccount)
|
||||||
val commit = new JGitUtil.CommitInfo(JGitUtil.getRevCommitFromId(git, commitId))
|
val commit = new JGitUtil.CommitInfo(JGitUtil.getRevCommitFromId(git, commitId))
|
||||||
callWebHookOf(repository.owner, repository.name, "push") {
|
callWebHookOf(repository.owner, repository.name, WebHook.Push) {
|
||||||
getAccountByUserName(repository.owner).map{ ownerAccount =>
|
getAccountByUserName(repository.owner).map{ ownerAccount =>
|
||||||
WebHookPushPayload(git, loginAccount, headName, repository, List(commit), ownerAccount,
|
WebHookPushPayload(git, loginAccount, headName, repository, List(commit), ownerAccount,
|
||||||
oldId = headTip, newId = commitId)
|
oldId = headTip, newId = commitId)
|
||||||
@@ -694,11 +718,6 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
private def archiveRepository(name: String, suffix: String, repository: RepositoryService.RepositoryInfo): Unit = {
|
private def archiveRepository(name: String, suffix: String, repository: RepositoryService.RepositoryInfo): Unit = {
|
||||||
val revision = name.stripSuffix(suffix)
|
val revision = name.stripSuffix(suffix)
|
||||||
val workDir = getDownloadWorkDir(repository.owner, repository.name, session.getId)
|
|
||||||
if(workDir.exists) {
|
|
||||||
FileUtils.deleteDirectory(workDir)
|
|
||||||
}
|
|
||||||
workDir.mkdirs
|
|
||||||
|
|
||||||
val filename = repository.name + "-" +
|
val filename = repository.name + "-" +
|
||||||
(if(revision.length == 40) revision.substring(0, 10) else revision).replace('/', '_') + suffix
|
(if(revision.length == 40) revision.substring(0, 10) else revision).replace('/', '_') + suffix
|
||||||
@@ -712,14 +731,17 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
git.archive
|
git.archive
|
||||||
.setFormat(suffix.tail)
|
.setFormat(suffix.tail)
|
||||||
.setTree(revCommit.getTree)
|
.setTree(revCommit)
|
||||||
.setOutputStream(response.getOutputStream)
|
.setOutputStream(response.getOutputStream)
|
||||||
.call()
|
.call()
|
||||||
|
|
||||||
Unit
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 =
|
||||||
hasWritePermission(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
||||||
|
|
||||||
|
override protected def renderUncaughtException(e: Throwable)(implicit request: HttpServletRequest, response: HttpServletResponse): Unit = {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
package gitbucket.core.controller
|
|
||||||
|
|
||||||
import gitbucket.core.search.html
|
|
||||||
import gitbucket.core.service._
|
|
||||||
import gitbucket.core.util.{StringUtil, ControlUtil, ReferrerAuthenticator, Implicits}
|
|
||||||
import ControlUtil._
|
|
||||||
import Implicits._
|
|
||||||
import jp.sf.amateras.scalatra.forms._
|
|
||||||
|
|
||||||
class SearchController extends SearchControllerBase
|
|
||||||
with RepositoryService with AccountService with ActivityService with RepositorySearchService with IssuesService with ReferrerAuthenticator
|
|
||||||
|
|
||||||
trait SearchControllerBase extends ControllerBase { self: RepositoryService
|
|
||||||
with ActivityService with RepositorySearchService with ReferrerAuthenticator =>
|
|
||||||
|
|
||||||
val searchForm = mapping(
|
|
||||||
"query" -> trim(text(required)),
|
|
||||||
"owner" -> trim(text(required)),
|
|
||||||
"repository" -> trim(text(required))
|
|
||||||
)(SearchForm.apply)
|
|
||||||
|
|
||||||
case class SearchForm(query: String, owner: String, repository: String)
|
|
||||||
|
|
||||||
post("/search", searchForm){ form =>
|
|
||||||
redirect(s"/${form.owner}/${form.repository}/search?q=${StringUtil.urlEncode(form.query)}")
|
|
||||||
}
|
|
||||||
|
|
||||||
get("/:owner/:repository/search")(referrersOnly { repository =>
|
|
||||||
defining(params("q").trim, params.getOrElse("type", "code")){ case (query, target) =>
|
|
||||||
val page = try {
|
|
||||||
val i = params.getOrElse("page", "1").toInt
|
|
||||||
if(i <= 0) 1 else i
|
|
||||||
} catch {
|
|
||||||
case e: NumberFormatException => 1
|
|
||||||
}
|
|
||||||
|
|
||||||
target.toLowerCase match {
|
|
||||||
case "issue" => html.issues(
|
|
||||||
searchIssues(repository.owner, repository.name, query),
|
|
||||||
countFiles(repository.owner, repository.name, query),
|
|
||||||
query, page, repository)
|
|
||||||
|
|
||||||
case _ => html.code(
|
|
||||||
searchFiles(repository.owner, repository.name, query),
|
|
||||||
countIssues(repository.owner, repository.name, query),
|
|
||||||
query, page, repository)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user