mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-01 11:06:06 +01:00
Compare commits
506 Commits
optimize-c
...
4.41.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
598f289311 | ||
|
|
447288db9d | ||
|
|
2b8c2a5c06 | ||
|
|
6fd3a73268 | ||
|
|
4536e42949 | ||
|
|
fc575388f1 | ||
|
|
1044d1cc32 | ||
|
|
253eabf2f2 | ||
|
|
8219d57b92 | ||
|
|
89381d3314 | ||
|
|
2e1037e107 | ||
|
|
0a77c71278 | ||
|
|
275101d11b | ||
|
|
bfd7f3b2bc | ||
|
|
21fcedf000 | ||
|
|
d963070f73 | ||
|
|
8174c89f9e | ||
|
|
5bdc74f0a6 | ||
|
|
b259386b67 | ||
|
|
984b52e7ec | ||
|
|
d36ef805f6 | ||
|
|
02bdbd281b | ||
|
|
b3cca9ea91 | ||
|
|
7409c08122 | ||
|
|
339b54cd4b | ||
|
|
1bbdf4917b | ||
|
|
465ed988a9 | ||
|
|
d5d7fe47d5 | ||
|
|
81d14dfaf2 | ||
|
|
302da30746 | ||
|
|
e9110aac80 | ||
|
|
6d104bd585 | ||
|
|
7c47462de8 | ||
|
|
cc8b83cbc5 | ||
|
|
07decd00a0 | ||
|
|
7c3e82f4dd | ||
|
|
95c31dd7b7 | ||
|
|
5ea905e3a2 | ||
|
|
e40d1f42c7 | ||
|
|
aa00351606 | ||
|
|
6311a1f146 | ||
|
|
1517e1f580 | ||
|
|
833f3584c2 | ||
|
|
cdc67bffcb | ||
|
|
52794aa9ea | ||
|
|
9ea3670a56 | ||
|
|
652ec3e029 | ||
|
|
b543bae958 | ||
|
|
4f574cdbcd | ||
|
|
29fc2a666b | ||
|
|
4498c016a4 | ||
|
|
31a1d46175 | ||
|
|
e3904ebdfe | ||
|
|
6e5ffdf658 | ||
|
|
5d0531f00d | ||
|
|
01ea533b97 | ||
|
|
86fc492668 | ||
|
|
3a78356019 | ||
|
|
44f7931ae6 | ||
|
|
7094f99a85 | ||
|
|
550c4a6e60 | ||
|
|
64aeb422c8 | ||
|
|
c2265dc44c | ||
|
|
507085cd56 | ||
|
|
36ef7ddf94 | ||
|
|
be1fbc8594 | ||
|
|
d73eacfa5d | ||
|
|
5d495cfa12 | ||
|
|
acaadff6cb | ||
|
|
e22371e4a5 | ||
|
|
81c426b112 | ||
|
|
1481872ddb | ||
|
|
523da8afb9 | ||
|
|
828dcb7173 | ||
|
|
eaf7bfb78d | ||
|
|
cbcf5ce4b6 | ||
|
|
36dce286b5 | ||
|
|
8ffe75786e | ||
|
|
5d63bc71aa | ||
|
|
37f8f7edda | ||
|
|
fd1c85afb2 | ||
|
|
c08bb6e89f | ||
|
|
d25889f6d2 | ||
|
|
dabddf60b1 | ||
|
|
c7ade7ec4d | ||
|
|
9caa73a585 | ||
|
|
0ee849c73d | ||
|
|
7883d8fd1e | ||
|
|
783ddfffa3 | ||
|
|
24b7cade49 | ||
|
|
51554d4325 | ||
|
|
90bcbd212b | ||
|
|
4ca3816522 | ||
|
|
fc4819cb29 | ||
|
|
5291df8e03 | ||
|
|
5afb0094f6 | ||
|
|
e76813cbee | ||
|
|
bc6398ca3b | ||
|
|
3d5ca44d66 | ||
|
|
8cd7068131 | ||
|
|
0db23b7f4a | ||
|
|
66d9ce328d | ||
|
|
36de0b3097 | ||
|
|
4f3cd26cf4 | ||
|
|
561e1bfec7 | ||
|
|
de64206a82 | ||
|
|
65ddffde89 | ||
|
|
1bc6ddc1a3 | ||
|
|
a404bd0776 | ||
|
|
ccbdd383ae | ||
|
|
acb846e885 | ||
|
|
fa23b4c89e | ||
|
|
a70e1f53b5 | ||
|
|
176deb4930 | ||
|
|
6e26d090ed | ||
|
|
070f74e7dc | ||
|
|
bcd78b3e5b | ||
|
|
be8f45ce49 | ||
|
|
baa96408a8 | ||
|
|
d2a7548f73 | ||
|
|
31e3fc64fc | ||
|
|
01a9883847 | ||
|
|
3cf2bea01e | ||
|
|
7caf11ae83 | ||
|
|
b22bc6fef0 | ||
|
|
88533c5807 | ||
|
|
53d955f198 | ||
|
|
724550ec5f | ||
|
|
1a63eff8f9 | ||
|
|
cf1b245229 | ||
|
|
c54a76c9b4 | ||
|
|
1a7213e2f0 | ||
|
|
a386cda024 | ||
|
|
f414bb4c79 | ||
|
|
6a51c7414a | ||
|
|
9718a67a74 | ||
|
|
179f86c904 | ||
|
|
e6ae6fc17d | ||
|
|
1f42b52cfd | ||
|
|
cdff342e3d | ||
|
|
daa8b6acf2 | ||
|
|
2ae72c6db4 | ||
|
|
9e3204d546 | ||
|
|
59e560b8e1 | ||
|
|
186269f8ff | ||
|
|
e441c40429 | ||
|
|
e1fa85848c | ||
|
|
8d66348634 | ||
|
|
f16b7d2c9b | ||
|
|
0ae8cc2820 | ||
|
|
ca25e7fe90 | ||
|
|
2692e29716 | ||
|
|
b71ccfbcc5 | ||
|
|
659a157cb7 | ||
|
|
f22fab32cc | ||
|
|
631e418733 | ||
|
|
0f57da14e4 | ||
|
|
424790e686 | ||
|
|
5dc43a7f75 | ||
|
|
debb131623 | ||
|
|
e3e21e9590 | ||
|
|
42fa7ea74d | ||
|
|
8ada3dde04 | ||
|
|
d43a666dfc | ||
|
|
5b266229c3 | ||
|
|
d8b0062f2b | ||
|
|
7f0859c0a3 | ||
|
|
38c7fbf589 | ||
|
|
41335964b7 | ||
|
|
c5464b2099 | ||
|
|
dc49b0dace | ||
|
|
365f30b76b | ||
|
|
ff1bc0fbca | ||
|
|
41d55372b5 | ||
|
|
ba8e5fe3cb | ||
|
|
6e692f70b7 | ||
|
|
aab979b78b | ||
|
|
9b7856464a | ||
|
|
903008b417 | ||
|
|
515cf86e4f | ||
|
|
c0b9eb8789 | ||
|
|
fefbf92f83 | ||
|
|
006fae36c9 | ||
|
|
281f7f37d8 | ||
|
|
36c6dd979f | ||
|
|
9f44015003 | ||
|
|
e719533ed9 | ||
|
|
773221d65b | ||
|
|
6beacb6af3 | ||
|
|
f11b92d391 | ||
|
|
def222d035 | ||
|
|
5dee7a9057 | ||
|
|
c20cc1271c | ||
|
|
843d429cb2 | ||
|
|
372e17ea2b | ||
|
|
5490e82411 | ||
|
|
d30a5d2f92 | ||
|
|
ef69763749 | ||
|
|
59d1250e36 | ||
|
|
33bf0b7b31 | ||
|
|
884cd498ce | ||
|
|
e0b021cb3e | ||
|
|
57edf101fa | ||
|
|
a2bf0d86d8 | ||
|
|
32e2ea5061 | ||
|
|
e28c0592f6 | ||
|
|
60627060d5 | ||
|
|
cea4d7e15f | ||
|
|
ca1670b21a | ||
|
|
c9c72faaf1 | ||
|
|
ba42538775 | ||
|
|
39141d8996 | ||
|
|
e3dd099bbb | ||
|
|
6b37d1027f | ||
|
|
b521f43c84 | ||
|
|
7c5a9df759 | ||
|
|
04762a3e53 | ||
|
|
d2ba2df2ba | ||
|
|
0e7f34f1d7 | ||
|
|
d576bbfaed | ||
|
|
2bfdca6992 | ||
|
|
d18fdb6399 | ||
|
|
fe02605544 | ||
|
|
f86ae20791 | ||
|
|
df69f88186 | ||
|
|
8d1323f354 | ||
|
|
2f598b618b | ||
|
|
baf0b0b92c | ||
|
|
27a75250a6 | ||
|
|
15f60402a5 | ||
|
|
41c6fc90b3 | ||
|
|
34356b04a8 | ||
|
|
2ca02b6539 | ||
|
|
cd0c71dffb | ||
|
|
a59120fe19 | ||
|
|
fdc35f48ed | ||
|
|
bae9b7ddc3 | ||
|
|
3dd9b7e587 | ||
|
|
44c905bdab | ||
|
|
5214040257 | ||
|
|
7ad9f901dd | ||
|
|
f472d52954 | ||
|
|
1e752af41b | ||
|
|
3ba46c3fc6 | ||
|
|
bf83da476f | ||
|
|
6b8c4cf8d0 | ||
|
|
445329c07a | ||
|
|
8f370e19c6 | ||
|
|
736dbcfb58 | ||
|
|
c1cb7f87e0 | ||
|
|
3c14fcefc9 | ||
|
|
831badf8db | ||
|
|
5f8a6e8d24 | ||
|
|
a3981493f7 | ||
|
|
6919cf5d4d | ||
|
|
f6d1e6bdd6 | ||
|
|
a13ff89acd | ||
|
|
cd5c76279a | ||
|
|
debff5e4b8 | ||
|
|
433e207ec5 | ||
|
|
3775f6a907 | ||
|
|
10d611c0eb | ||
|
|
963bc4d672 | ||
|
|
e68a21ee30 | ||
|
|
d5c083b70f | ||
|
|
2deb9cf417 | ||
|
|
fca0cfcdc7 | ||
|
|
1466e1bdb3 | ||
|
|
dd48bc443a | ||
|
|
f455738e5f | ||
|
|
85193803cd | ||
|
|
4e90a6074a | ||
|
|
ca94fa5184 | ||
|
|
f14a7c996f | ||
|
|
989d22f4d8 | ||
|
|
400a812343 | ||
|
|
97284f1ced | ||
|
|
5e6a0d7e16 | ||
|
|
599e11245f | ||
|
|
538d714c96 | ||
|
|
953915ba2a | ||
|
|
1a2f5da055 | ||
|
|
749a469d37 | ||
|
|
c7d084321a | ||
|
|
00a61cd6cf | ||
|
|
d9c6c13c62 | ||
|
|
5260c5e889 | ||
|
|
1700f96c62 | ||
|
|
5a0f9f8bbb | ||
|
|
8fa22b4de2 | ||
|
|
d17cae16fd | ||
|
|
c4c48962cf | ||
|
|
4140e92f0b | ||
|
|
887e560a1b | ||
|
|
e2d70181e8 | ||
|
|
148c453dbc | ||
|
|
f6ee9d311d | ||
|
|
35209e43bb | ||
|
|
4a3ecf063d | ||
|
|
4c79101624 | ||
|
|
921b01661b | ||
|
|
c63301d8e6 | ||
|
|
c9ed9d2237 | ||
|
|
ca55cbe456 | ||
|
|
d4828613ee | ||
|
|
a0be02ce2f | ||
|
|
9b8016a4d5 | ||
|
|
8fdd3bfd21 | ||
|
|
695a061e3c | ||
|
|
bd50d9218e | ||
|
|
d8f13bc1ce | ||
|
|
ed84d1a3c9 | ||
|
|
3c765d879c | ||
|
|
4c76b6dd96 | ||
|
|
7e66917993 | ||
|
|
eb0f985399 | ||
|
|
3a2908c3a3 | ||
|
|
f13c10859f | ||
|
|
8e8a314c91 | ||
|
|
dad0478b87 | ||
|
|
240b34016d | ||
|
|
2c164d630c | ||
|
|
3d12a9038f | ||
|
|
71fc02b5cd | ||
|
|
74caaa3d94 | ||
|
|
e024c12521 | ||
|
|
1d0c364947 | ||
|
|
88e59405c5 | ||
|
|
8160c93c15 | ||
|
|
3c8113d607 | ||
|
|
8e2f421e76 | ||
|
|
56df833b4a | ||
|
|
119d7d0be0 | ||
|
|
d4d2ca19a1 | ||
|
|
4ce5597d67 | ||
|
|
17888327b3 | ||
|
|
997def54ab | ||
|
|
a407e75459 | ||
|
|
cece53aad9 | ||
|
|
a2d63bc5f8 | ||
|
|
0c81c63ab7 | ||
|
|
3e8f1eee22 | ||
|
|
a91d1def45 | ||
|
|
032e6d1c57 | ||
|
|
93eb133cba | ||
|
|
b7b78842da | ||
|
|
8100ccaf5f | ||
|
|
936e1c0e96 | ||
|
|
1a7274e475 | ||
|
|
ac7b83b6ed | ||
|
|
e298279032 | ||
|
|
f7e58c28c6 | ||
|
|
18f3bc4056 | ||
|
|
4638f82889 | ||
|
|
4396b6eab5 | ||
|
|
594ae2bb7e | ||
|
|
429cf54bd4 | ||
|
|
274357abc4 | ||
|
|
0e21247755 | ||
|
|
37f2868ff3 | ||
|
|
6a85e25a62 | ||
|
|
a91b1c7e79 | ||
|
|
bfd9ecd130 | ||
|
|
ec888e94fd | ||
|
|
a19c80bef2 | ||
|
|
7b9ade2698 | ||
|
|
d03f28eeb9 | ||
|
|
288dd788bc | ||
|
|
2069a5a931 | ||
|
|
8a434cbd15 | ||
|
|
faafe49848 | ||
|
|
17a72292ce | ||
|
|
9ae09f1801 | ||
|
|
abbba17e4b | ||
|
|
479d5da17e | ||
|
|
dec7890d04 | ||
|
|
61910a6667 | ||
|
|
ac2119ac3b | ||
|
|
8c71cd7369 | ||
|
|
ec8b6ff18f | ||
|
|
e214804d57 | ||
|
|
39448f2e3c | ||
|
|
79dc6fc247 | ||
|
|
a800f305f2 | ||
|
|
67e0fb6b3f | ||
|
|
e401d30159 | ||
|
|
504e651828 | ||
|
|
7a8da2f074 | ||
|
|
1e47e96634 | ||
|
|
69502480b4 | ||
|
|
5833e3fcca | ||
|
|
4e47ffb1d2 | ||
|
|
3056333a7c | ||
|
|
ad0cd7f625 | ||
|
|
dedaa263ce | ||
|
|
bccf729102 | ||
|
|
a244c61e56 | ||
|
|
37594935f0 | ||
|
|
e521c2158b | ||
|
|
b1c8a8c76e | ||
|
|
8d92f210f0 | ||
|
|
287281923c | ||
|
|
6f18135574 | ||
|
|
58cf9bec3b | ||
|
|
b7a45e9901 | ||
|
|
f5585b39c6 | ||
|
|
9c3ef37274 | ||
|
|
e904c0b689 | ||
|
|
237f97f069 | ||
|
|
1eb2a04090 | ||
|
|
cda6106858 | ||
|
|
8c4ce5e5f4 | ||
|
|
b5ee6431c4 | ||
|
|
bd06e6d4dc | ||
|
|
3b607e74ed | ||
|
|
dc16474ed3 | ||
|
|
dc0f088be0 | ||
|
|
2718e10044 | ||
|
|
4213dcb8a2 | ||
|
|
39afb31200 | ||
|
|
8e1ce1c96a | ||
|
|
fdfd8293d6 | ||
|
|
b7d3be6a14 | ||
|
|
bb5c809749 | ||
|
|
a2cbe7cbf5 | ||
|
|
b1fb09ac99 | ||
|
|
201ae7e7db | ||
|
|
2978decb84 | ||
|
|
5fbbd4d5f3 | ||
|
|
4abd363f62 | ||
|
|
8288db60a9 | ||
|
|
6cdf679571 | ||
|
|
51179acc12 | ||
|
|
1ff27d3e17 | ||
|
|
1e9bce3d5a | ||
|
|
8811ea2b58 | ||
|
|
be7cdd0a28 | ||
|
|
611a05aa48 | ||
|
|
9f95a757a2 | ||
|
|
58b577453c | ||
|
|
78acfd87e8 | ||
|
|
bf9cb26164 | ||
|
|
68a99ada0b | ||
|
|
1d841ce171 | ||
|
|
ccfdbfd276 | ||
|
|
70d584d56d | ||
|
|
a49ffb07be | ||
|
|
baa9caf010 | ||
|
|
22025c875f | ||
|
|
3806995a50 | ||
|
|
94d2650491 | ||
|
|
844f24afa4 | ||
|
|
083396a8e4 | ||
|
|
e02769056b | ||
|
|
024f8e8d80 | ||
|
|
3b4a7c3c47 | ||
|
|
d9838d9cba | ||
|
|
b3ca4468cd | ||
|
|
452e41603a | ||
|
|
b41de4a770 | ||
|
|
3423d2f2f3 | ||
|
|
9269acc64d | ||
|
|
18b5f20f1c | ||
|
|
68d592a8ff | ||
|
|
ee18d96f98 | ||
|
|
6d3687cbdf | ||
|
|
1ef1a2983b | ||
|
|
47850fe0fa | ||
|
|
055a37cac0 | ||
|
|
333deb4756 | ||
|
|
34cde4b09a | ||
|
|
5091b4838c | ||
|
|
2e83289061 | ||
|
|
e11f651002 | ||
|
|
be684a567d | ||
|
|
97e552b10f | ||
|
|
5bb8046c32 | ||
|
|
e7192655f7 | ||
|
|
19ba09740c | ||
|
|
d169777722 | ||
|
|
ff8a5f6b77 | ||
|
|
ec953df156 | ||
|
|
d6a191d95b | ||
|
|
aba428bba1 | ||
|
|
6ab37fd596 | ||
|
|
73fc70f55b | ||
|
|
aad18b7a50 | ||
|
|
cc278be5cd | ||
|
|
d0f4f82a0f | ||
|
|
1dcbf386b1 | ||
|
|
414afd285c | ||
|
|
35b645d8b5 | ||
|
|
b3cba53866 | ||
|
|
a4773bb3ca | ||
|
|
863d8a4af5 | ||
|
|
3fccd7b53c | ||
|
|
dd2760eaf7 | ||
|
|
824bafa739 | ||
|
|
60cdaec05f | ||
|
|
c204a435b3 | ||
|
|
37accd92d6 | ||
|
|
01fd0ee1f0 | ||
|
|
fab1c74473 | ||
|
|
0d8fcfd28d | ||
|
|
b91a7c32a6 | ||
|
|
e7a6f0930b |
2
.git-blame-ignore-revs
Normal file
2
.git-blame-ignore-revs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# update scalafmt
|
||||||
|
3d5ca44d66c77a46770a65a895c9737c542690f6
|
||||||
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -2,3 +2,4 @@
|
|||||||
|
|
||||||
build.sbt @xuwei-k
|
build.sbt @xuwei-k
|
||||||
project/* @xuwei-k
|
project/* @xuwei-k
|
||||||
|
.github/workflows/* @xuwei-k
|
||||||
|
|||||||
4
.github/ISSUE_TEMPLATE.md
vendored
4
.github/ISSUE_TEMPLATE.md
vendored
@@ -4,8 +4,12 @@
|
|||||||
- [ ] searched for similar already existing issue
|
- [ ] searched for similar already existing issue
|
||||||
- [ ] read the documentation and [wiki](https://github.com/gitbucket/gitbucket/wiki)
|
- [ ] read the documentation and [wiki](https://github.com/gitbucket/gitbucket/wiki)
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
*(if you have performed all the above, remove the paragraph and continue describing the issue with template below)*
|
*(if you have performed all the above, remove the paragraph and continue describing the issue with template below)*
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
## Issue
|
## Issue
|
||||||
**Impacted version**: xxxx
|
**Impacted version**: xxxx
|
||||||
|
|
||||||
|
|||||||
14
.github/workflows/build.yml
vendored
14
.github/workflows/build.yml
vendored
@@ -8,11 +8,11 @@ jobs:
|
|||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java: [8, 11, 17]
|
java: [11, 21]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Cache
|
- name: Cache
|
||||||
uses: actions/cache@v2.1.6
|
uses: actions/cache@v4
|
||||||
env:
|
env:
|
||||||
cache-name: cache-sbt-libs
|
cache-name: cache-sbt-libs
|
||||||
with:
|
with:
|
||||||
@@ -22,18 +22,18 @@ jobs:
|
|||||||
~/.cache/coursier/v1
|
~/.cache/coursier/v1
|
||||||
key: build-${{ env.cache-name }}-${{ hashFiles('build.sbt') }}
|
key: build-${{ env.cache-name }}-${{ hashFiles('build.sbt') }}
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
distribution: adopt
|
distribution: adopt
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: sbt scalafmtSbtCheck scalafmtCheck test:scalafmtCheck test
|
run: sbt scalafmtSbtCheck scalafmtCheckAll test
|
||||||
- name: Scala 3
|
- name: Scala 3
|
||||||
run: sbt '++ 3.0.1!' update # TODO
|
run: sbt '++ 3.x' update # TODO
|
||||||
- name: Build executable
|
- name: Build executable
|
||||||
run: sbt executable
|
run: sbt executable
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: gitbucket-java${{ matrix.java }}-${{ github.sha }}
|
name: gitbucket-java${{ matrix.java }}-${{ github.sha }}
|
||||||
path: ./target/executable/gitbucket.*
|
path: ./target/executable/gitbucket.*
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,6 +2,9 @@
|
|||||||
*.log
|
*.log
|
||||||
.ensime
|
.ensime
|
||||||
.ensime_cache
|
.ensime_cache
|
||||||
|
.DS_Store
|
||||||
|
.java-version
|
||||||
|
.tmp
|
||||||
|
|
||||||
# sbt specific
|
# sbt specific
|
||||||
dist/*
|
dist/*
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ updates.limit = 3
|
|||||||
updates.includeScala = true
|
updates.includeScala = true
|
||||||
|
|
||||||
updates.pin = [
|
updates.pin = [
|
||||||
{ groupId = "org.eclipse.jetty", version = "9." }
|
{ groupId = "org.eclipse.jetty", version = "10." }
|
||||||
|
{ groupId = "org.mariadb.jdbc", version = "2." }
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
version = "1.5.1"
|
version = "3.8.1"
|
||||||
project.git = true
|
project.git = true
|
||||||
|
|
||||||
maxColumn = 120
|
maxColumn = 120
|
||||||
docstrings = JavaDoc
|
docstrings.style = keep
|
||||||
|
|
||||||
align.tokens = ["%", "%%", {code = "=>", owner = "Case"}]
|
align.tokens = ["%", "%%", {code = "=>", owner = "Case"}]
|
||||||
align.openParenCallSite = false
|
align.openParenCallSite = false
|
||||||
align.openParenDefnSite = false
|
align.openParenDefnSite = false
|
||||||
continuationIndent.callSite = 2
|
continuationIndent.callSite = 2
|
||||||
continuationIndent.defnSite = 2
|
continuationIndent.defnSite = 2
|
||||||
danglingParentheses = true
|
danglingParentheses.preset = true
|
||||||
|
runner.dialect = scala213source3
|
||||||
|
rewrite.trailingCommas.style = keep
|
||||||
|
fileOverride {
|
||||||
|
"glob:**/*.sbt" {
|
||||||
|
runner.dialect = scala212
|
||||||
|
rewrite.scala3.convertToNewSyntax = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rewrite.scala3.convertToNewSyntax = true
|
||||||
|
runner.dialectOverride.allowSignificantIndentation = false
|
||||||
|
runner.dialectOverride.allowAsForImportRename = false
|
||||||
|
runner.dialectOverride.allowStarWildcardImport = false
|
||||||
|
|||||||
79
CHANGELOG.md
79
CHANGELOG.md
@@ -1,32 +1,97 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to the project will be documented in this file.
|
All changes to the project will be documented in this file.
|
||||||
|
|
||||||
### 4.36.2 - 16 Aug 2021
|
## 4.41.0 - 18 May 2024
|
||||||
|
- Simplify pull request UI
|
||||||
|
- Fix layout of branch selector
|
||||||
|
- Integrate keyword search with filtering in the search box
|
||||||
|
- Make max files and lines limit in showing diff configurable
|
||||||
|
- Adjust the default branch automatically when cloning external repo
|
||||||
|
- Performance improvement for listing branches
|
||||||
|
- Upgrade internal libraries
|
||||||
|
|
||||||
|
## 4.40.0 - 22 Oct 2023
|
||||||
|
- Configurable default branch name
|
||||||
|
- Support custom fields of issues and pull requests in search condition
|
||||||
|
- Create pull request from default branch of forked repositories
|
||||||
|
- News feed shows activities of all visible repositories
|
||||||
|
- Drop Java 8 support
|
||||||
|
- Improve git push performance
|
||||||
|
|
||||||
|
## 4.39.0 - 29 Apr 2023
|
||||||
|
- Support enum type in custom fields of Issues and Pull requests
|
||||||
|
- Hide large diffs by default
|
||||||
|
- Add new options to make it possible to run GitBucket using multiple machines
|
||||||
|
- Fix many API issues
|
||||||
|
|
||||||
|
## 4.38.4 - 2 Nov 2022
|
||||||
|
- Downgrade MariaDB JDBC drive to avoid unknown error
|
||||||
|
|
||||||
|
## 4.38.3 - 30 Oct 2022
|
||||||
|
- Fix several issues around multiple assignees in issues and pull requests
|
||||||
|
- Fix IllegalStateException when returning unknown avatar image
|
||||||
|
|
||||||
|
## 4.38.2 - 20 Sep 2022
|
||||||
|
- Resurrect assignee icons on the issue list
|
||||||
|
|
||||||
|
## 4.38.1 - 10 Sep 2022
|
||||||
|
- Fix comment diff in Chrome 105
|
||||||
|
- Fix Markdown table CSS
|
||||||
|
- Fix HTML rendering of multiple asignees
|
||||||
|
|
||||||
|
## 4.38.0 - 3 Sep 2022
|
||||||
|
- Support multiple assignees for Issues and Pull requests
|
||||||
|
- Custom fields for issues and pull requests
|
||||||
|
- Reset password by users
|
||||||
|
- Allow to configure Jetty idle timeout in standalone mode
|
||||||
|
- Horizontal scroll for too wide tables in Markdown
|
||||||
|
- Hide header content on signin and register page
|
||||||
|
- Fix the default charset of the online editor in the repository viewer
|
||||||
|
- Fix the milestone count
|
||||||
|
- Some improvements and bugfixes for WebAPI and WebHook
|
||||||
|
|
||||||
|
## 4.37.2 - 16 Jan 2022
|
||||||
|
- Fixed a security issue reported by [Positive Technologies](https://www.ptsecurity.com/ww-en/). Great thanks for their detailed report and close support!
|
||||||
|
|
||||||
|
## 4.37.1 - 14 Dec 2021
|
||||||
|
- Update gist-plugin and notification-plugin
|
||||||
|
- Fix SSHCommand extension point for apache-sshd 2.x
|
||||||
|
|
||||||
|
## 4.37.0 - 11 Dec 2021
|
||||||
|
- Enhance Git Reference APIs
|
||||||
|
- Add milestone data to issue list API
|
||||||
|
- Support "all" in issue list API
|
||||||
|
- Support EDDSA in signed commit verification
|
||||||
|
- Support custom SSH url
|
||||||
|
- Relax max passward length limitation
|
||||||
|
- Relax max webhook url length limitation
|
||||||
|
|
||||||
|
## 4.36.2 - 16 Aug 2021
|
||||||
- Escape user name in avatar image tag
|
- Escape user name in avatar image tag
|
||||||
|
|
||||||
### 4.36.1 - 22 Jul 2021
|
## 4.36.1 - 22 Jul 2021
|
||||||
- Bump gitbucket-gist-plugin to 4.21.0
|
- Bump gitbucket-gist-plugin to 4.21.0
|
||||||
|
|
||||||
### 4.36.0 - 17 Jul 2021
|
## 4.36.0 - 17 Jul 2021
|
||||||
- Tag selector in the repository viewer
|
- Tag selector in the repository viewer
|
||||||
- Link issues/pull requests of other repositories
|
- Link issues/pull requests of other repositories
|
||||||
- Files and lines can be linked in the diff view
|
- Files and lines can be linked in the diff view
|
||||||
- Option to disable XSS protection
|
- Option to disable XSS protection
|
||||||
|
|
||||||
### 4.35.3 - 14 Jan 2021
|
## 4.35.3 - 14 Jan 2021
|
||||||
- Fix a bug that Wiki page cannot be deleted
|
- Fix a bug that Wiki page cannot be deleted
|
||||||
- Fix a deployment issue on Tomcat
|
- Fix a deployment issue on Tomcat
|
||||||
|
|
||||||
### 4.35.2 - 30 Dec 2020
|
## 4.35.2 - 30 Dec 2020
|
||||||
- Upgrade gitbucket-notifications-plugin to 1.10.0
|
- Upgrade gitbucket-notifications-plugin to 1.10.0
|
||||||
- Upgrade oauth2-oidc-sdk to 8.29.1 to solve dependency issue
|
- Upgrade oauth2-oidc-sdk to 8.29.1 to solve dependency issue
|
||||||
|
|
||||||
### 4.35.1 - 29 Dec 2020
|
## 4.35.1 - 29 Dec 2020
|
||||||
- Fix database migration issue which happens if webhook is configured
|
- Fix database migration issue which happens if webhook is configured
|
||||||
- Call push webhook when pull request is merged
|
- Call push webhook when pull request is merged
|
||||||
- Show commit status at commits tab of pull request
|
- Show commit status at commits tab of pull request
|
||||||
|
|
||||||
### 4.35.0 - 25 Dec 2020
|
## 4.35.0 - 25 Dec 2020
|
||||||
- Editor and source viewer color theme
|
- Editor and source viewer color theme
|
||||||
- Auto completion for issues and pull requests
|
- Auto completion for issues and pull requests
|
||||||
- Upload image from clipboard
|
- Upload image from clipboard
|
||||||
|
|||||||
29
README.md
29
README.md
@@ -1,4 +1,4 @@
|
|||||||
GitBucket [](https://gitter.im/gitbucket/gitbucket) [](https://github.com/gitbucket/gitbucket/actions?query=workflow%3Abuild+branch%3Amaster) [](https://maven-badges.herokuapp.com/maven-central/io.github.gitbucket/gitbucket_2.13) [](https://github.com/gitbucket/gitbucket/blob/master/LICENSE)
|
GitBucket [](https://gitter.im/gitbucket/gitbucket) [](https://github.com/gitbucket/gitbucket/actions?query=workflow%3Abuild+branch%3Amaster) [](https://index.scala-lang.org/gitbucket/gitbucket/gitbucket) [](https://github.com/gitbucket/gitbucket/blob/master/LICENSE)
|
||||||
=========
|
=========
|
||||||
|
|
||||||
GitBucket is a Git web platform powered by Scala offering:
|
GitBucket is a Git web platform powered by Scala offering:
|
||||||
@@ -10,8 +10,6 @@ GitBucket is a Git web platform powered by Scala offering:
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
You can try an [online demo](https://gitbucket.herokuapp.com/) *(ID: root / Pass: root)* of GitBucket, and also get the latest information at [GitBucket News](https://gitbucket.github.io/gitbucket-news/).
|
|
||||||
|
|
||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
The current version of GitBucket provides many features such as:
|
The current version of GitBucket provides many features such as:
|
||||||
@@ -26,12 +24,12 @@ The current version of GitBucket provides many features such as:
|
|||||||
|
|
||||||
Installation
|
Installation
|
||||||
--------
|
--------
|
||||||
GitBucket requires **Java8**. You have to install it, if it is not already installed.
|
GitBucket requires **Java 11**. You have to install it, if it is not already installed.
|
||||||
|
|
||||||
1. Download the latest **gitbucket.war** from [the releases page](https://github.com/gitbucket/gitbucket/releases) and run it by `java -jar gitbucket.war`.
|
1. Download the latest **gitbucket.war** from [the releases page](https://github.com/gitbucket/gitbucket/releases) and run it by `java -jar gitbucket.war`.
|
||||||
2. Go to `http://[hostname]:8080/` and log in with ID: **root** / Pass: **root**.
|
2. Go to `http://[hostname]:8080/` and log in with ID: **root** / Pass: **root**.
|
||||||
|
|
||||||
You can also deploy `gitbucket.war` to a servlet container which supports Servlet 3.0 (like Jetty, Tomcat, JBoss, etc)
|
You can also deploy `gitbucket.war` to a servlet container which supports Servlet 3.0 (like Jetty, Tomcat, JBoss, etc). Note that GitBucket doesn't support Jakarta EE yet.
|
||||||
|
|
||||||
For more information about installation on Mac or Windows Server (with IIS), or configuration of Apache or Nginx and also integration with other tools or services such as Jenkins or Slack, see [Wiki](https://github.com/gitbucket/gitbucket/wiki).
|
For more information about installation on Mac or Windows Server (with IIS), or configuration of Apache or Nginx and also integration with other tools or services such as Jenkins or Slack, see [Wiki](https://github.com/gitbucket/gitbucket/wiki).
|
||||||
|
|
||||||
@@ -61,18 +59,15 @@ Support
|
|||||||
- If you can't find same question and report, send it to our [Gitter room](https://gitter.im/gitbucket/gitbucket) before raising an issue.
|
- If you can't find same question and report, send it to our [Gitter room](https://gitter.im/gitbucket/gitbucket) before raising an issue.
|
||||||
- The highest priority of GitBucket is the ease of installation and API compatibility with GitHub, so your feature request might be rejected if they go against those principles.
|
- The highest priority of GitBucket is the ease of installation and API compatibility with GitHub, so your feature request might be rejected if they go against those principles.
|
||||||
|
|
||||||
What's New in 4.36.x
|
What's New in 4.41.x
|
||||||
-------------
|
-------------
|
||||||
### 4.36.2 - 16 Aug 2021
|
## 4.41.0 - 18 May 2024
|
||||||
- Escape user name in avatar image tag
|
- Simplify pull request UI
|
||||||
|
- Fix layout of branch selector
|
||||||
### 4.36.1 - 22 Jul 2021
|
- Integrate keyword search with filtering in the search box
|
||||||
- Bump gitbucket-gist-plugin to 4.21.0
|
- Make max files and lines limit in showing diff configurable
|
||||||
|
- Adjust the default branch automatically when cloning external repo
|
||||||
### 4.36.0 - 17 Jul 2021
|
- Performance improvement for listing branches
|
||||||
- Tag selector in the repository viewer
|
- Upgrade internal libraries
|
||||||
- Link issues/pull requests of other repositories
|
|
||||||
- Files and lines can be linked in the diff view
|
|
||||||
- Option to disable XSS protection
|
|
||||||
|
|
||||||
See the [change log](CHANGELOG.md) for all of the updates.
|
See the [change log](CHANGELOG.md) for all of the updates.
|
||||||
|
|||||||
118
build.sbt
118
build.sbt
@@ -1,12 +1,12 @@
|
|||||||
import com.typesafe.sbt.license.{DepModuleInfo, LicenseInfo}
|
import sbtlicensereport.license.{DepModuleInfo, LicenseInfo}
|
||||||
import com.jsuereth.sbtpgp.PgpKeys._
|
import com.jsuereth.sbtpgp.PgpKeys._
|
||||||
|
|
||||||
val Organization = "io.github.gitbucket"
|
val Organization = "io.github.gitbucket"
|
||||||
val Name = "gitbucket"
|
val Name = "gitbucket"
|
||||||
val GitBucketVersion = "4.36.2"
|
val GitBucketVersion = "4.41.0"
|
||||||
val ScalatraVersion = "2.8.2"
|
val ScalatraVersion = "3.0.0"
|
||||||
val JettyVersion = "9.4.44.v20210927"
|
val JettyVersion = "10.0.21"
|
||||||
val JgitVersion = "5.13.0.202109080827-r"
|
val JgitVersion = "6.9.0.202403050737-r"
|
||||||
|
|
||||||
lazy val root = (project in file("."))
|
lazy val root = (project in file("."))
|
||||||
.enablePlugins(SbtTwirl, ScalatraPlugin)
|
.enablePlugins(SbtTwirl, ScalatraPlugin)
|
||||||
@@ -15,72 +15,58 @@ sourcesInBase := false
|
|||||||
organization := Organization
|
organization := Organization
|
||||||
name := Name
|
name := Name
|
||||||
version := GitBucketVersion
|
version := GitBucketVersion
|
||||||
scalaVersion := "2.13.7"
|
scalaVersion := "2.13.14"
|
||||||
|
|
||||||
scalafmtOnCompile := true
|
crossScalaVersions += "3.4.2"
|
||||||
|
|
||||||
|
// scalafmtOnCompile := true
|
||||||
|
|
||||||
coverageExcludedPackages := ".*\\.html\\..*"
|
coverageExcludedPackages := ".*\\.html\\..*"
|
||||||
|
|
||||||
// dependency settings
|
|
||||||
resolvers ++= Seq(
|
|
||||||
Classpaths.typesafeReleases,
|
|
||||||
Resolver.jcenterRepo,
|
|
||||||
"sonatype-snapshot" at "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
||||||
)
|
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % JgitVersion,
|
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % JgitVersion,
|
||||||
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % JgitVersion,
|
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % JgitVersion,
|
||||||
"org.scalatra" %% "scalatra" % ScalatraVersion cross CrossVersion.for3Use2_13,
|
"org.scalatra" %% "scalatra-javax" % ScalatraVersion,
|
||||||
"org.scalatra" %% "scalatra-json" % ScalatraVersion cross CrossVersion.for3Use2_13,
|
"org.scalatra" %% "scalatra-json-javax" % ScalatraVersion,
|
||||||
"org.scalatra" %% "scalatra-forms" % ScalatraVersion cross CrossVersion.for3Use2_13,
|
"org.scalatra" %% "scalatra-forms-javax" % ScalatraVersion,
|
||||||
"org.json4s" %% "json4s-jackson" % "4.0.3" cross CrossVersion.for3Use2_13,
|
"org.json4s" %% "json4s-jackson" % "4.1.0-M5",
|
||||||
"commons-io" % "commons-io" % "2.11.0",
|
"commons-io" % "commons-io" % "2.16.1",
|
||||||
"io.github.gitbucket" % "solidbase" % "1.0.3",
|
"io.github.gitbucket" % "solidbase" % "1.1.0",
|
||||||
"io.github.gitbucket" % "markedj" % "1.0.16",
|
"io.github.gitbucket" % "markedj" % "1.0.20",
|
||||||
"org.apache.commons" % "commons-compress" % "1.21",
|
"org.apache.commons" % "commons-compress" % "1.26.1",
|
||||||
"org.apache.commons" % "commons-email" % "1.5",
|
"org.apache.commons" % "commons-email" % "1.6.0",
|
||||||
"commons-net" % "commons-net" % "3.8.0",
|
"commons-net" % "commons-net" % "3.10.0",
|
||||||
"org.apache.httpcomponents" % "httpclient" % "4.5.13",
|
"org.apache.httpcomponents" % "httpclient" % "4.5.14",
|
||||||
"org.apache.sshd" % "apache-sshd" % "2.1.0" exclude ("org.slf4j", "slf4j-jdk14") exclude ("org.apache.sshd", "sshd-mina") exclude ("org.apache.sshd", "sshd-netty"),
|
"org.apache.sshd" % "apache-sshd" % "2.12.1" exclude ("org.slf4j", "slf4j-jdk14") exclude ("org.apache.sshd", "sshd-mina") exclude ("org.apache.sshd", "sshd-netty"),
|
||||||
"org.apache.tika" % "tika-core" % "2.1.0",
|
"org.apache.tika" % "tika-core" % "2.9.2",
|
||||||
"com.github.takezoe" %% "blocking-slick-32" % "0.0.12" cross CrossVersion.for3Use2_13,
|
"com.github.takezoe" %% "blocking-slick" % "0.0.14",
|
||||||
"com.novell.ldap" % "jldap" % "2009-10-07",
|
"com.novell.ldap" % "jldap" % "2009-10-07",
|
||||||
"com.h2database" % "h2" % "1.4.199",
|
"com.h2database" % "h2" % "1.4.199",
|
||||||
"org.mariadb.jdbc" % "mariadb-java-client" % "2.7.4",
|
"org.mariadb.jdbc" % "mariadb-java-client" % "2.7.12",
|
||||||
"org.postgresql" % "postgresql" % "42.3.1",
|
"org.postgresql" % "postgresql" % "42.7.3",
|
||||||
"ch.qos.logback" % "logback-classic" % "1.2.6",
|
"ch.qos.logback" % "logback-classic" % "1.5.6",
|
||||||
"com.zaxxer" % "HikariCP" % "4.0.3" exclude ("org.slf4j", "slf4j-api"),
|
"com.zaxxer" % "HikariCP" % "5.1.0" exclude ("org.slf4j", "slf4j-api"),
|
||||||
"com.typesafe" % "config" % "1.4.1",
|
"com.typesafe" % "config" % "1.4.3",
|
||||||
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.1.0",
|
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.1.0",
|
||||||
"io.github.java-diff-utils" % "java-diff-utils" % "4.11",
|
"io.github.java-diff-utils" % "java-diff-utils" % "4.12",
|
||||||
"org.cache2k" % "cache2k-all" % "1.6.0.Final",
|
"org.cache2k" % "cache2k-all" % "1.6.0.Final",
|
||||||
"net.coobird" % "thumbnailator" % "0.4.14",
|
"net.coobird" % "thumbnailator" % "0.4.20",
|
||||||
"com.github.zafarkhaja" % "java-semver" % "0.9.0",
|
"com.github.zafarkhaja" % "java-semver" % "0.10.2",
|
||||||
"com.nimbusds" % "oauth2-oidc-sdk" % "9.19",
|
"com.nimbusds" % "oauth2-oidc-sdk" % "11.12",
|
||||||
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
|
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
|
||||||
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
|
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
|
||||||
"junit" % "junit" % "4.13.2" % "test",
|
"junit" % "junit" % "4.13.2" % "test",
|
||||||
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test" cross CrossVersion.for3Use2_13,
|
"org.scalatra" %% "scalatra-scalatest-javax" % ScalatraVersion % "test",
|
||||||
"org.mockito" % "mockito-core" % "4.0.0" % "test",
|
"org.mockito" % "mockito-core" % "5.12.0" % "test",
|
||||||
"com.dimafeng" %% "testcontainers-scala" % "0.39.11" % "test",
|
"com.dimafeng" %% "testcontainers-scala" % "0.41.3" % "test",
|
||||||
"org.testcontainers" % "mysql" % "1.16.2" % "test",
|
"org.testcontainers" % "mysql" % "1.19.8" % "test",
|
||||||
"org.testcontainers" % "postgresql" % "1.16.2" % "test",
|
"org.testcontainers" % "postgresql" % "1.19.8" % "test",
|
||||||
"net.i2p.crypto" % "eddsa" % "0.3.0",
|
"net.i2p.crypto" % "eddsa" % "0.3.0",
|
||||||
"is.tagomor.woothee" % "woothee-java" % "1.11.0",
|
"is.tagomor.woothee" % "woothee-java" % "1.11.0",
|
||||||
"org.ec4j.core" % "ec4j-core" % "0.3.0",
|
"org.ec4j.core" % "ec4j-core" % "0.3.0",
|
||||||
"org.kohsuke" % "github-api" % "1.135" % "test"
|
"org.kohsuke" % "github-api" % "1.321" % "test"
|
||||||
)
|
)
|
||||||
|
|
||||||
libraryDependencies ~= {
|
|
||||||
_.map {
|
|
||||||
case x if x.name == "twirl-api" =>
|
|
||||||
x cross CrossVersion.for3Use2_13
|
|
||||||
case x =>
|
|
||||||
x
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compiler settings
|
// Compiler settings
|
||||||
scalacOptions := Seq(
|
scalacOptions := Seq(
|
||||||
"-deprecation",
|
"-deprecation",
|
||||||
@@ -90,7 +76,15 @@ scalacOptions := Seq(
|
|||||||
"-Wunused:imports",
|
"-Wunused:imports",
|
||||||
"-Wconf:cat=unused&src=twirl/.*:s,cat=unused&src=scala/gitbucket/core/model/[^/]+\\.scala:s"
|
"-Wconf:cat=unused&src=twirl/.*:s,cat=unused&src=scala/gitbucket/core/model/[^/]+\\.scala:s"
|
||||||
)
|
)
|
||||||
compile / javacOptions ++= Seq("-target", "8", "-source", "8")
|
scalacOptions ++= {
|
||||||
|
scalaBinaryVersion.value match {
|
||||||
|
case "2.13" =>
|
||||||
|
Seq("-Xsource:3")
|
||||||
|
case _ =>
|
||||||
|
Nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compile / javacOptions ++= Seq("-target", "11", "-source", "11")
|
||||||
Jetty / javaOptions += "-Dlogback.configurationFile=/logback-dev.xml"
|
Jetty / javaOptions += "-Dlogback.configurationFile=/logback-dev.xml"
|
||||||
|
|
||||||
// Test settings
|
// Test settings
|
||||||
@@ -115,8 +109,8 @@ assembly / assemblyMergeStrategy := {
|
|||||||
|
|
||||||
// Exclude a war file from published artifacts
|
// Exclude a war file from published artifacts
|
||||||
signedArtifacts := {
|
signedArtifacts := {
|
||||||
signedArtifacts.value.filterNot {
|
signedArtifacts.value.filterNot { case (_, file) =>
|
||||||
case (_, file) => file.getName.endsWith(".war") || file.getName.endsWith(".war.asc")
|
file.getName.endsWith(".war") || file.getName.endsWith(".war.asc")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +120,6 @@ Keys.ivyConfigurations += ExecutableConfig
|
|||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
|
"org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
|
||||||
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
|
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
|
||||||
"org.eclipse.jetty" % "jetty-continuation" % JettyVersion % "executable",
|
|
||||||
"org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
|
"org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
|
||||||
"org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
|
"org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
|
||||||
"org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
|
"org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
|
||||||
@@ -160,8 +153,7 @@ executableKey := {
|
|||||||
val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
|
val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
|
||||||
jettyJars foreach { jar =>
|
jettyJars foreach { jar =>
|
||||||
IO unzip (jar, temp, (name: String) =>
|
IO unzip (jar, temp, (name: String) =>
|
||||||
(name startsWith "javax/") ||
|
(name startsWith "javax/") || (name startsWith "org/") || (name startsWith "META-INF/services/"))
|
||||||
(name startsWith "org/"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// include original war file
|
// include original war file
|
||||||
@@ -186,7 +178,7 @@ executableKey := {
|
|||||||
val url = "https://github.com/" +
|
val url = "https://github.com/" +
|
||||||
s"gitbucket/gitbucket-${pluginId}-plugin/releases/download/${pluginVersion}/gitbucket-${pluginId}-plugin-${pluginVersion}.jar"
|
s"gitbucket/gitbucket-${pluginId}-plugin/releases/download/${pluginVersion}/gitbucket-${pluginId}-plugin-${pluginVersion}.jar"
|
||||||
log info s"Download: ${url}"
|
log info s"Download: ${url}"
|
||||||
IO transfer (new java.net.URL(url).openStream, pluginsDir / url.substring(url.lastIndexOf("/") + 1))
|
IO transfer (new java.net.URI(url).toURL.openStream, pluginsDir / url.substring(url.lastIndexOf("/") + 1))
|
||||||
case _ => ()
|
case _ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,8 +199,7 @@ executableKey := {
|
|||||||
"md5" -> "MD5",
|
"md5" -> "MD5",
|
||||||
"sha1" -> "SHA-1",
|
"sha1" -> "SHA-1",
|
||||||
"sha256" -> "SHA-256"
|
"sha256" -> "SHA-256"
|
||||||
).foreach {
|
).foreach { case (extension, algorithm) =>
|
||||||
case (extension, algorithm) =>
|
|
||||||
val checksumFile = workDir / (warName + "." + extension)
|
val checksumFile = workDir / (warName + "." + extension)
|
||||||
Checksums generate (outputFile, checksumFile, algorithm)
|
Checksums generate (outputFile, checksumFile, algorithm)
|
||||||
}
|
}
|
||||||
@@ -287,6 +278,9 @@ Test / testOptions ++= {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Jetty / javaOptions ++= Seq(
|
Jetty / javaOptions ++= Seq(
|
||||||
|
"-Dlogback.configurationFile=/logback-dev.xml",
|
||||||
"-Xdebug",
|
"-Xdebug",
|
||||||
"-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"
|
"-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000",
|
||||||
|
"-Dorg.eclipse.jetty.annotations.AnnotationParser.LEVEL=OFF",
|
||||||
|
// "-Ddev-features=keep-session"
|
||||||
)
|
)
|
||||||
|
|||||||
21
doc/build.md
21
doc/build.md
@@ -1,7 +1,7 @@
|
|||||||
How to build and run from the source tree
|
How to build and run from the source tree
|
||||||
========
|
========
|
||||||
|
|
||||||
First of all, Install [sbt](http://www.scala-sbt.org/index.html).
|
First of all, Install [sbt](https://www.scala-sbt.org/index.html).
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ brew install sbt
|
$ brew install sbt
|
||||||
@@ -18,7 +18,21 @@ $ sbt ~jetty:start
|
|||||||
|
|
||||||
Then access `http://localhost:8080/` in your browser. The default administrator account is `root` and password is `root`.
|
Then access `http://localhost:8080/` in your browser. The default administrator account is `root` and password is `root`.
|
||||||
|
|
||||||
Source code modifications are detected and a reloading happens automatically. You can modify the logging configuration by editing `src/main/resources/logback-dev.xml`.
|
Source code modifications are detected and a reloading happens automatically.
|
||||||
|
You can modify the logging configuration by editing `src/main/resources/logback-dev.xml`.
|
||||||
|
|
||||||
|
Note that HttpSession is cleared when auto-reloading happened.
|
||||||
|
This is a bit annoying when developing features that requires sign-in.
|
||||||
|
You can keep HttpSession even if GitBucket is restarted by enabling this configuration in `build.sbt`:
|
||||||
|
https://github.com/gitbucket/gitbucket/blob/d5c083b70f7f3748d080166252e9a3dcaf579648/build.sbt#L292
|
||||||
|
|
||||||
|
Or by launching GitBucket with the following command:
|
||||||
|
```shell
|
||||||
|
sbt '; set Jetty/javaOptions += "-Ddev-features=keep-session" ; ~jetty:start'
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that this feature serializes HttpSession on the local disk and assigns all requests to the same session
|
||||||
|
which means you cannot test multi users behavior in this mode.
|
||||||
|
|
||||||
Build war file
|
Build war file
|
||||||
--------
|
--------
|
||||||
@@ -37,7 +51,8 @@ To build an executable war file, run
|
|||||||
$ sbt executable
|
$ sbt executable
|
||||||
```
|
```
|
||||||
|
|
||||||
at the top of the source tree. It generates executable `gitbucket.war` into `target/executable`. We release this war file as release artifact.
|
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
|
Run tests spec
|
||||||
---------
|
---------
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Debug GitBucket on IntelliJ
|
Debug GitBucket on IntelliJ
|
||||||
========
|
========
|
||||||
Add following configuration for allowing remote debugging to `buils.sbt`:
|
Add following configuration for allowing remote debugging to `build.sbt`:
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
javaOptions in Jetty ++= Seq(
|
javaOptions in Jetty ++= Seq(
|
||||||
|
|||||||
@@ -5,13 +5,17 @@ GitBucket persists all data into __HOME/.gitbucket__ in default (In 1.9 or befor
|
|||||||
This directory has following structure:
|
This directory has following structure:
|
||||||
|
|
||||||
```
|
```
|
||||||
* /HOME/gitbucket
|
* /HOME/.gitbucket
|
||||||
|
* gitbucket.conf
|
||||||
|
* database.conf
|
||||||
|
* activity.log
|
||||||
|
* data.mv.db, data.trace.db (H2 data files if the default embed H2 is used)
|
||||||
* /repositories
|
* /repositories
|
||||||
* /USER_NAME
|
* /USER_NAME
|
||||||
* /REPO_NAME.git (substance of repository. GitServlet sees this directory)
|
* /REPO_NAME.git (substance of repository. GitServlet sees this directory)
|
||||||
* /REPO_NAME.wiki.git (wiki repository)
|
* /REPO_NAME.wiki.git (wiki repository)
|
||||||
* /REPO_NAME
|
* /REPO_NAME
|
||||||
* /issues (files which are attached to issue)
|
* /issues (files attached to issue)
|
||||||
* /lfs (LFS managed files)
|
* /lfs (LFS managed files)
|
||||||
* /data
|
* /data
|
||||||
* /USER_NAME
|
* /USER_NAME
|
||||||
@@ -20,6 +24,8 @@ This directory has following structure:
|
|||||||
* /plugins
|
* /plugins
|
||||||
* plugin.jar
|
* plugin.jar
|
||||||
* /.installed (copied available plugins from the parent directory automatically)
|
* /.installed (copied available plugins from the parent directory automatically)
|
||||||
|
* /sessions
|
||||||
|
* HTTP session data created (if '--save_sessions' option is used in the standalone mode)
|
||||||
* /tmp
|
* /tmp
|
||||||
* /_upload
|
* /_upload
|
||||||
* /SESSION_ID (removed at session timeout)
|
* /SESSION_ID (removed at session timeout)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 203 KiB After Width: | Height: | Size: 112 KiB |
@@ -1,6 +1,6 @@
|
|||||||
Mapping and Validation
|
Mapping and Validation
|
||||||
========
|
========
|
||||||
GitBucket uses [scalatra-forms](http://scalatra.org/guides/2.6/formats/forms.html) to validate request parameters and map them to the scala object. This is inspired by Play2 form mapping / validation.
|
GitBucket uses [scalatra-forms](https://scalatra.org/guides/2.8/formats/forms.html) to validate request parameters and map them to the scala object. This is inspired by Play2 form mapping / validation.
|
||||||
|
|
||||||
At first, define the mapping as following:
|
At first, define the mapping as following:
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
sbt.version=1.5.5
|
sbt.version=1.10.0
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
|
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
|
||||||
|
|
||||||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3")
|
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
|
||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.5.1")
|
addSbtPlugin("org.playframework.twirl" % "sbt-twirl" % "2.0.5")
|
||||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0")
|
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0")
|
||||||
addSbtPlugin("org.scalatra.sbt" % "sbt-scalatra" % "1.0.4")
|
addSbtPlugin("org.scalatra.sbt" % "sbt-scalatra" % "1.0.4")
|
||||||
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
|
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
|
||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-license-report" % "1.2.0")
|
addSbtPlugin("com.github.sbt" % "sbt-license-report" % "1.6.1")
|
||||||
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.2")
|
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.12")
|
||||||
|
|
||||||
addDependencyTreePlugin
|
addDependencyTreePlugin
|
||||||
|
|||||||
@@ -61,12 +61,19 @@ public class JettyLauncher {
|
|||||||
String redirectHttps = getEnvironmentVariable("gitbucket.redirectHttps");
|
String redirectHttps = getEnvironmentVariable("gitbucket.redirectHttps");
|
||||||
String contextPath = getEnvironmentVariable("gitbucket.prefix");
|
String contextPath = getEnvironmentVariable("gitbucket.prefix");
|
||||||
String tmpDirPath = getEnvironmentVariable("gitbucket.tempDir");
|
String tmpDirPath = getEnvironmentVariable("gitbucket.tempDir");
|
||||||
|
String jettyIdleTimeout = getEnvironmentVariable("gitbucket.jettyIdleTimeout");
|
||||||
boolean saveSessions = false;
|
boolean saveSessions = false;
|
||||||
|
|
||||||
for(String arg: args) {
|
for(String arg: args) {
|
||||||
if (arg.equals("--save_sessions")) {
|
if (arg.equals("--save_sessions")) {
|
||||||
saveSessions = true;
|
saveSessions = true;
|
||||||
}
|
}
|
||||||
|
if (arg.equals("--disable_news_feed")) {
|
||||||
|
System.setProperty("gitbucket.disableNewsFeed", "true");
|
||||||
|
}
|
||||||
|
if (arg.equals("--disable_cache")) {
|
||||||
|
System.setProperty("gitbucket.disableCache", "true");
|
||||||
|
}
|
||||||
if(arg.startsWith("--") && arg.contains("=")) {
|
if(arg.startsWith("--") && arg.contains("=")) {
|
||||||
String[] dim = arg.split("=", 2);
|
String[] dim = arg.split("=", 2);
|
||||||
if(dim.length == 2) {
|
if(dim.length == 2) {
|
||||||
@@ -107,6 +114,9 @@ public class JettyLauncher {
|
|||||||
case "--plugin_dir":
|
case "--plugin_dir":
|
||||||
System.setProperty("gitbucket.pluginDir", dim[1]);
|
System.setProperty("gitbucket.pluginDir", dim[1]);
|
||||||
break;
|
break;
|
||||||
|
case "--jetty_idle_timeout":
|
||||||
|
jettyIdleTimeout = dim[1];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,6 +140,11 @@ public class JettyLauncher {
|
|||||||
if (connectorsSet.contains(Connectors.HTTPS)) {
|
if (connectorsSet.contains(Connectors.HTTPS)) {
|
||||||
httpConfig.setSecurePort(fallback(securePort, Defaults.HTTPS_PORT, Integer::parseInt));
|
httpConfig.setSecurePort(fallback(securePort, Defaults.HTTPS_PORT, Integer::parseInt));
|
||||||
}
|
}
|
||||||
|
if (jettyIdleTimeout != null && jettyIdleTimeout.trim().length() != 0) {
|
||||||
|
httpConfig.setIdleTimeout(Long.parseLong(jettyIdleTimeout.trim()));
|
||||||
|
} else {
|
||||||
|
httpConfig.setIdleTimeout(300000L); // default is 5min
|
||||||
|
}
|
||||||
|
|
||||||
if (connectorsSet.contains(Connectors.HTTP)) {
|
if (connectorsSet.contains(Connectors.HTTP)) {
|
||||||
final ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
|
final ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
|
||||||
@@ -140,7 +155,7 @@ public class JettyLauncher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (connectorsSet.contains(Connectors.HTTPS)) {
|
if (connectorsSet.contains(Connectors.HTTPS)) {
|
||||||
final SslContextFactory sslContextFactory = new SslContextFactory.Server();
|
final SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
||||||
|
|
||||||
sslContextFactory.setKeyStorePath(requireNonNull(keyStorePath,
|
sslContextFactory.setKeyStorePath(requireNonNull(keyStorePath,
|
||||||
"You must specify a path to an SSL keystore via the --key_store_path command line argument" +
|
"You must specify a path to an SSL keystore via the --key_store_path command line argument" +
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
notifications:1.10.0
|
notifications:1.11.0
|
||||||
gist:4.21.0
|
gist:4.23.0
|
||||||
emoji:4.6.0
|
emoji:4.6.0
|
||||||
pages:1.10.0
|
pages:1.10.0
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
<file>gitbucket.log</file>
|
<file>.tmp/gitbucket.log</file>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -1,18 +0,0 @@
|
|||||||
CREATE OR REPLACE VIEW ISSUE_OUTLINE_VIEW AS
|
|
||||||
SELECT
|
|
||||||
A.USER_NAME,
|
|
||||||
A.REPOSITORY_NAME,
|
|
||||||
A.ISSUE_ID,
|
|
||||||
COALESCE(B.COMMENT_COUNT, 0) + COALESCE(C.COMMENT_COUNT, 0) AS COMMENT_COUNT
|
|
||||||
FROM ISSUE A
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM ISSUE_COMMENT
|
|
||||||
WHERE ACTION IN ('comment', 'close_comment', 'reopen_comment')
|
|
||||||
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
|
||||||
) B
|
|
||||||
ON (A.USER_NAME = B.USER_NAME AND A.REPOSITORY_NAME = B.REPOSITORY_NAME AND A.ISSUE_ID = B.ISSUE_ID)
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM COMMIT_COMMENT
|
|
||||||
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
|
||||||
) C
|
|
||||||
ON (A.USER_NAME = C.USER_NAME AND A.REPOSITORY_NAME = C.REPOSITORY_NAME AND A.ISSUE_ID = C.ISSUE_ID);
|
|
||||||
@@ -343,4 +343,28 @@
|
|||||||
<addPrimaryKey constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_PK" tableName="PROTECTED_BRANCH_REQUIRE_CONTEXT" columnNames="USER_NAME, REPOSITORY_NAME, BRANCH, CONTEXT"/>
|
<addPrimaryKey constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_PK" tableName="PROTECTED_BRANCH_REQUIRE_CONTEXT" columnNames="USER_NAME, REPOSITORY_NAME, BRANCH, CONTEXT"/>
|
||||||
<addForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_FK0" baseTableName="PROTECTED_BRANCH_REQUIRE_CONTEXT" baseColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" referencedTableName="PROTECTED_BRANCH" referencedColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" onDelete="CASCADE" onUpdate="CASCADE"/>
|
<addForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_FK0" baseTableName="PROTECTED_BRANCH_REQUIRE_CONTEXT" baseColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" referencedTableName="PROTECTED_BRANCH" referencedColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ISSUE_OUTLINE_VIEW -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<sql>
|
||||||
|
CREATE OR REPLACE VIEW ISSUE_OUTLINE_VIEW AS
|
||||||
|
SELECT
|
||||||
|
A.USER_NAME,
|
||||||
|
A.REPOSITORY_NAME,
|
||||||
|
A.ISSUE_ID,
|
||||||
|
COALESCE(B.COMMENT_COUNT, 0) + COALESCE(C.COMMENT_COUNT, 0) AS COMMENT_COUNT
|
||||||
|
FROM ISSUE A
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM ISSUE_COMMENT
|
||||||
|
WHERE ACTION IN ('comment', 'close_comment', 'reopen_comment')
|
||||||
|
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
||||||
|
) B
|
||||||
|
ON (A.USER_NAME = B.USER_NAME AND A.REPOSITORY_NAME = B.REPOSITORY_NAME AND A.ISSUE_ID = B.ISSUE_ID)
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM COMMIT_COMMENT
|
||||||
|
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
||||||
|
) C
|
||||||
|
ON (A.USER_NAME = C.USER_NAME AND A.REPOSITORY_NAME = C.REPOSITORY_NAME AND A.ISSUE_ID = C.ISSUE_ID)
|
||||||
|
</sql>
|
||||||
|
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
CREATE OR REPLACE VIEW ISSUE_OUTLINE_VIEW AS
|
|
||||||
|
|
||||||
SELECT
|
|
||||||
A.USER_NAME,
|
|
||||||
A.REPOSITORY_NAME,
|
|
||||||
A.ISSUE_ID,
|
|
||||||
COALESCE(B.COMMENT_COUNT, 0) + COALESCE(C.COMMENT_COUNT, 0) AS COMMENT_COUNT,
|
|
||||||
COALESCE(D.ORDERING, 9999) AS PRIORITY
|
|
||||||
|
|
||||||
FROM ISSUE A
|
|
||||||
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM ISSUE_COMMENT
|
|
||||||
WHERE ACTION IN ('comment', 'close_comment', 'reopen_comment')
|
|
||||||
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
|
||||||
) B
|
|
||||||
ON (A.USER_NAME = B.USER_NAME AND A.REPOSITORY_NAME = B.REPOSITORY_NAME AND A.ISSUE_ID = B.ISSUE_ID)
|
|
||||||
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM COMMIT_COMMENT
|
|
||||||
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
|
||||||
) C
|
|
||||||
ON (A.USER_NAME = C.USER_NAME AND A.REPOSITORY_NAME = C.REPOSITORY_NAME AND A.ISSUE_ID = C.ISSUE_ID)
|
|
||||||
|
|
||||||
LEFT OUTER JOIN PRIORITY D
|
|
||||||
ON (A.PRIORITY_ID = D.PRIORITY_ID);
|
|
||||||
@@ -35,4 +35,28 @@
|
|||||||
<column name="URL" type="varchar(200)" nullable="false"/>
|
<column name="URL" type="varchar(200)" nullable="false"/>
|
||||||
<column name="EVENT" type="varchar(30)" nullable="false"/>
|
<column name="EVENT" type="varchar(30)" nullable="false"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
|
<sql>
|
||||||
|
CREATE OR REPLACE VIEW ISSUE_OUTLINE_VIEW AS
|
||||||
|
SELECT
|
||||||
|
A.USER_NAME,
|
||||||
|
A.REPOSITORY_NAME,
|
||||||
|
A.ISSUE_ID,
|
||||||
|
COALESCE(B.COMMENT_COUNT, 0) + COALESCE(C.COMMENT_COUNT, 0) AS COMMENT_COUNT,
|
||||||
|
COALESCE(D.ORDERING, 9999) AS PRIORITY
|
||||||
|
FROM ISSUE A
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM ISSUE_COMMENT
|
||||||
|
WHERE ACTION IN ('comment', 'close_comment', 'reopen_comment')
|
||||||
|
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
||||||
|
) B
|
||||||
|
ON (A.USER_NAME = B.USER_NAME AND A.REPOSITORY_NAME = B.REPOSITORY_NAME AND A.ISSUE_ID = B.ISSUE_ID)
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, COUNT(COMMENT_ID) AS COMMENT_COUNT FROM COMMIT_COMMENT
|
||||||
|
GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID
|
||||||
|
) C
|
||||||
|
ON (A.USER_NAME = C.USER_NAME AND A.REPOSITORY_NAME = C.REPOSITORY_NAME AND A.ISSUE_ID = C.ISSUE_ID)
|
||||||
|
LEFT OUTER JOIN PRIORITY D
|
||||||
|
ON (A.PRIORITY_ID = D.PRIORITY_ID);
|
||||||
|
</sql>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|||||||
7
src/main/resources/update/gitbucket-core_4.37.xml
Normal file
7
src/main/resources/update/gitbucket-core_4.37.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<dropForeignKeyConstraint constraintName="IDX_WEB_HOOK_EVENT_FK0" baseTableName="WEB_HOOK_EVENT"/>
|
||||||
|
<modifyDataType columnName="URL" newDataType="varchar(400)" tableName="WEB_HOOK_EVENT"/>
|
||||||
|
<modifyDataType columnName="URL" newDataType="varchar(400)" tableName="WEB_HOOK"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_WEB_HOOK_EVENT_FK0" baseTableName="WEB_HOOK_EVENT" baseColumnNames="USER_NAME, REPOSITORY_NAME, URL" referencedTableName="WEB_HOOK" referencedColumnNames="USER_NAME, REPOSITORY_NAME, URL" onDelete="CASCADE" onUpdate="CASCADE"/>
|
||||||
|
</changeSet>
|
||||||
53
src/main/resources/update/gitbucket-core_4.38.xml
Normal file
53
src/main/resources/update/gitbucket-core_4.38.xml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- CUSTOM_FIELD -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="CUSTOM_FIELD">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="FIELD_ID" type="int" nullable="false" autoIncrement="true" unique="true"/>
|
||||||
|
<column name="FIELD_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="FIELD_TYPE" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="ENABLE_FOR_ISSUES" type="boolean" nullable="false"/>
|
||||||
|
<column name="ENABLE_FOR_PULL_REQUESTS" type="boolean" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey constraintName="IDX_CUSTOM_FIELD_PK" tableName="CUSTOM_FIELD" columnNames="USER_NAME, REPOSITORY_NAME, FIELD_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_CUSTOM_FIELD_FK0" baseTableName="CUSTOM_FIELD" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ISSUE_CUSTOM_FIELD -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ISSUE_CUSTOM_FIELD">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="ISSUE_ID" type="int" nullable="false"/>
|
||||||
|
<column name="FIELD_ID" type="int" nullable="false"/>
|
||||||
|
<column name="VALUE" type="varchar(200)" nullable="true"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey constraintName="IDX_ISSUE_CUSTOM_FIELD_PK" tableName="ISSUE_CUSTOM_FIELD" columnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID, FIELD_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_CUSTOM_FIELD_FK0" baseTableName="ISSUE_CUSTOM_FIELD" baseColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID" referencedTableName="ISSUE" referencedColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_CUSTOM_FIELD_FK1" baseTableName="ISSUE_CUSTOM_FIELD" baseColumnNames="USER_NAME, REPOSITORY_NAME, FIELD_ID" referencedTableName="CUSTOM_FIELD" referencedColumnNames="USER_NAME, REPOSITORY_NAME, FIELD_ID"/>
|
||||||
|
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<!-- ISSUE_ASSIGNEE -->
|
||||||
|
<!--================================================================================================-->
|
||||||
|
<createTable tableName="ISSUE_ASSIGNEE">
|
||||||
|
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
<column name="ISSUE_ID" type="int" nullable="false"/>
|
||||||
|
<column name="ASSIGNEE_USER_NAME" type="varchar(100)" nullable="false"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey constraintName="IDX_ISSUE_ASSIGNEE_PK" tableName="ISSUE_ASSIGNEE" columnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID, ASSIGNEE_USER_NAME"/>
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_ASSIGNEE_FK0" baseTableName="ISSUE_ASSIGNEE" baseColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID" referencedTableName="ISSUE" referencedColumnNames="USER_NAME, REPOSITORY_NAME, ISSUE_ID"/>
|
||||||
|
<!--
|
||||||
|
<addForeignKeyConstraint constraintName="IDX_ISSUE_ASSIGNEE_FK1" baseTableName="ISSUE_ASSIGNEE" baseColumnNames="ASSIGNEE_USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<sql>
|
||||||
|
INSERT INTO ISSUE_ASSIGNEE (USER_NAME, REPOSITORY_NAME, ISSUE_ID, ASSIGNEE_USER_NAME)
|
||||||
|
SELECT USER_NAME, REPOSITORY_NAME, ISSUE_ID, ASSIGNED_USER_NAME FROM ISSUE WHERE ASSIGNED_USER_NAME IS NOT NULL
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<dropColumn tableName="ISSUE" columnName="ASSIGNED_USER_NAME"/>
|
||||||
|
</changeSet>
|
||||||
6
src/main/resources/update/gitbucket-core_4.39.xml
Normal file
6
src/main/resources/update/gitbucket-core_4.39.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="CUSTOM_FIELD">
|
||||||
|
<column name="CONSTRAINTS" type="varchar(200)" nullable="true"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
-- DELETE COLLABORATORS IN GROUP REPOSITORIES
|
|
||||||
DELETE FROM COLLABORATOR WHERE USER_NAME IN (SELECT USER_NAME FROM ACCOUNT WHERE GROUP_ACCOUNT = TRUE)
|
|
||||||
@@ -30,4 +30,9 @@
|
|||||||
<dropColumn tableName="REPOSITORY" columnName="ENABLE_WIKI"/>
|
<dropColumn tableName="REPOSITORY" columnName="ENABLE_WIKI"/>
|
||||||
<dropColumn tableName="REPOSITORY" columnName="ALLOW_WIKI_EDITING"/>
|
<dropColumn tableName="REPOSITORY" columnName="ALLOW_WIKI_EDITING"/>
|
||||||
<dropColumn tableName="REPOSITORY" columnName="ENABLE_ISSUES"/>
|
<dropColumn tableName="REPOSITORY" columnName="ENABLE_ISSUES"/>
|
||||||
|
|
||||||
|
<!-- DELETE COLLABORATORS IN GROUP REPOSITORIES -->
|
||||||
|
<sql>
|
||||||
|
DELETE FROM COLLABORATOR WHERE USER_NAME IN (SELECT USER_NAME FROM ACCOUNT WHERE GROUP_ACCOUNT = TRUE)
|
||||||
|
</sql>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import gitbucket.core.model.Activity
|
|||||||
import gitbucket.core.util.Directory.ActivityLog
|
import gitbucket.core.util.Directory.ActivityLog
|
||||||
import gitbucket.core.util.JDBCUtil
|
import gitbucket.core.util.JDBCUtil
|
||||||
import io.github.gitbucket.solidbase.Solidbase
|
import io.github.gitbucket.solidbase.Solidbase
|
||||||
import io.github.gitbucket.solidbase.migration.{LiquibaseMigration, Migration, SqlMigration}
|
import io.github.gitbucket.solidbase.migration.{LiquibaseMigration, Migration}
|
||||||
import io.github.gitbucket.solidbase.model.{Module, Version}
|
import io.github.gitbucket.solidbase.model.{Module, Version}
|
||||||
import org.json4s.{Formats, NoTypeHints}
|
import org.json4s.{Formats, NoTypeHints}
|
||||||
import org.json4s.jackson.Serialization
|
import org.json4s.jackson.Serialization
|
||||||
@@ -20,11 +20,7 @@ import scala.util.Using
|
|||||||
object GitBucketCoreModule
|
object GitBucketCoreModule
|
||||||
extends Module(
|
extends Module(
|
||||||
"gitbucket-core",
|
"gitbucket-core",
|
||||||
new Version(
|
new Version("4.0.0", new LiquibaseMigration("update/gitbucket-core_4.0.xml")),
|
||||||
"4.0.0",
|
|
||||||
new LiquibaseMigration("update/gitbucket-core_4.0.xml"),
|
|
||||||
new SqlMigration("update/gitbucket-core_4.0.sql")
|
|
||||||
),
|
|
||||||
new Version("4.1.0"),
|
new Version("4.1.0"),
|
||||||
new Version("4.2.0", new LiquibaseMigration("update/gitbucket-core_4.2.xml")),
|
new Version("4.2.0", new LiquibaseMigration("update/gitbucket-core_4.2.xml")),
|
||||||
new Version("4.2.1"),
|
new Version("4.2.1"),
|
||||||
@@ -32,11 +28,7 @@ object GitBucketCoreModule
|
|||||||
new Version("4.4.0"),
|
new Version("4.4.0"),
|
||||||
new Version("4.5.0"),
|
new Version("4.5.0"),
|
||||||
new Version("4.6.0", new LiquibaseMigration("update/gitbucket-core_4.6.xml")),
|
new Version("4.6.0", new LiquibaseMigration("update/gitbucket-core_4.6.xml")),
|
||||||
new Version(
|
new Version("4.7.0", new LiquibaseMigration("update/gitbucket-core_4.7.xml")),
|
||||||
"4.7.0",
|
|
||||||
new LiquibaseMigration("update/gitbucket-core_4.7.xml"),
|
|
||||||
new SqlMigration("update/gitbucket-core_4.7.sql")
|
|
||||||
),
|
|
||||||
new Version("4.7.1"),
|
new Version("4.7.1"),
|
||||||
new Version("4.8"),
|
new Version("4.8"),
|
||||||
new Version("4.9.0", new LiquibaseMigration("update/gitbucket-core_4.9.xml")),
|
new Version("4.9.0", new LiquibaseMigration("update/gitbucket-core_4.9.xml")),
|
||||||
@@ -45,11 +37,7 @@ object GitBucketCoreModule
|
|||||||
new Version("4.12.0"),
|
new Version("4.12.0"),
|
||||||
new Version("4.12.1"),
|
new Version("4.12.1"),
|
||||||
new Version("4.13.0"),
|
new Version("4.13.0"),
|
||||||
new Version(
|
new Version("4.14.0", new LiquibaseMigration("update/gitbucket-core_4.14.xml")),
|
||||||
"4.14.0",
|
|
||||||
new LiquibaseMigration("update/gitbucket-core_4.14.xml"),
|
|
||||||
new SqlMigration("update/gitbucket-core_4.14.sql")
|
|
||||||
),
|
|
||||||
new Version("4.14.1"),
|
new Version("4.14.1"),
|
||||||
new Version("4.15.0"),
|
new Version("4.15.0"),
|
||||||
new Version("4.16.0"),
|
new Version("4.16.0"),
|
||||||
@@ -88,8 +76,7 @@ object GitBucketCoreModule
|
|||||||
import JDBCUtil._
|
import JDBCUtil._
|
||||||
|
|
||||||
val conn = context.get(Solidbase.CONNECTION).asInstanceOf[Connection]
|
val conn = context.get(Solidbase.CONNECTION).asInstanceOf[Connection]
|
||||||
val list = conn.select("SELECT * FROM ACTIVITY ORDER BY ACTIVITY_ID") {
|
val list = conn.select("SELECT * FROM ACTIVITY ORDER BY ACTIVITY_ID") { rs =>
|
||||||
rs =>
|
|
||||||
Activity(
|
Activity(
|
||||||
activityId = UUID.randomUUID().toString,
|
activityId = UUID.randomUUID().toString,
|
||||||
userName = rs.getString("USER_NAME"),
|
userName = rs.getString("USER_NAME"),
|
||||||
@@ -119,5 +106,16 @@ object GitBucketCoreModule
|
|||||||
new Version("4.35.3"),
|
new Version("4.35.3"),
|
||||||
new Version("4.36.0", new LiquibaseMigration("update/gitbucket-core_4.36.xml")),
|
new Version("4.36.0", new LiquibaseMigration("update/gitbucket-core_4.36.xml")),
|
||||||
new Version("4.36.1"),
|
new Version("4.36.1"),
|
||||||
new Version("4.36.2")
|
new Version("4.36.2"),
|
||||||
|
new Version("4.37.0", new LiquibaseMigration("update/gitbucket-core_4.37.xml")),
|
||||||
|
new Version("4.37.1"),
|
||||||
|
new Version("4.37.2"),
|
||||||
|
new Version("4.38.0", new LiquibaseMigration("update/gitbucket-core_4.38.xml")),
|
||||||
|
new Version("4.38.1"),
|
||||||
|
new Version("4.38.2"),
|
||||||
|
new Version("4.38.3"),
|
||||||
|
new Version("4.38.4"),
|
||||||
|
new Version("4.39.0", new LiquibaseMigration("update/gitbucket-core_4.39.xml")),
|
||||||
|
new Version("4.40.0"),
|
||||||
|
new Version("4.41.0")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue
|
||||||
|
*/
|
||||||
|
case class AddLabelsToAnIssue(labels: Seq[String])
|
||||||
@@ -66,15 +66,16 @@ object ApiBranchProtection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
implicit val enforcementLevelSerializer: CustomSerializer[EnforcementLevel] = new CustomSerializer[EnforcementLevel](
|
implicit val enforcementLevelSerializer: CustomSerializer[EnforcementLevel] =
|
||||||
format =>
|
new CustomSerializer[EnforcementLevel](format =>
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
case JString("off") => Off
|
case JString("off") => Off
|
||||||
case JString("non_admins") => NonAdmins
|
case JString("non_admins") => NonAdmins
|
||||||
case JString("everyone") => Everyone
|
case JString("everyone") => Everyone
|
||||||
}, {
|
},
|
||||||
case x: EnforcementLevel => JString(x.name)
|
{ case x: EnforcementLevel =>
|
||||||
|
JString(x.name)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ case class ApiComment(id: Int, user: ApiUser, body: String, created_at: Date, up
|
|||||||
isPullRequest: Boolean
|
isPullRequest: Boolean
|
||||||
) {
|
) {
|
||||||
val html_url = ApiPath(
|
val html_url = ApiPath(
|
||||||
s"/${repositoryName.fullName}/${if (isPullRequest) { "pull" } else { "issues" }}/${issueId}#comment-${id}"
|
s"/${repositoryName.fullName}/${if (isPullRequest) { "pull" }
|
||||||
|
else { "issues" }}/${issueId}#comment-${id}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ case class ApiCommit(
|
|||||||
|
|
||||||
object ApiCommit {
|
object ApiCommit {
|
||||||
def apply(git: Git, repositoryName: RepositoryName, commit: CommitInfo): ApiCommit = {
|
def apply(git: Git, repositoryName: RepositoryName, commit: CommitInfo): ApiCommit = {
|
||||||
val diffs = JGitUtil.getDiffs(git, None, commit.id, false, false)
|
val diffs = JGitUtil.getDiffs(git = git, from = None, to = commit.id, fetchContent = false, makePatch = false)
|
||||||
ApiCommit(
|
ApiCommit(
|
||||||
id = commit.id,
|
id = commit.id,
|
||||||
message = commit.fullMessage,
|
message = commit.fullMessage,
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ object ApiCommits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
File(
|
File(
|
||||||
filename = if (diff.changeType == ChangeType.DELETE) { diff.oldPath } else { diff.newPath },
|
filename = if (diff.changeType == ChangeType.DELETE) { diff.oldPath }
|
||||||
|
else { diff.newPath },
|
||||||
additions = additions,
|
additions = additions,
|
||||||
deletions = deletions,
|
deletions = deletions,
|
||||||
changes = additions + deletions,
|
changes = additions + deletions,
|
||||||
@@ -97,7 +98,7 @@ object ApiCommits {
|
|||||||
ApiCommits(
|
ApiCommits(
|
||||||
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${commitInfo.id}"),
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${commitInfo.id}"),
|
||||||
sha = commitInfo.id,
|
sha = commitInfo.id,
|
||||||
html_url = ApiPath(s"${repositoryName.fullName}/commit/${commitInfo.id}"),
|
html_url = ApiPath(s"/${repositoryName.fullName}/commit/${commitInfo.id}"),
|
||||||
comment_url = ApiPath(""), // TODO no API for commit comment
|
comment_url = ApiPath(""), // TODO no API for commit comment
|
||||||
commit = Commit(
|
commit = Commit(
|
||||||
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${commitInfo.id}"),
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${commitInfo.id}"),
|
||||||
@@ -106,7 +107,9 @@ object ApiCommits {
|
|||||||
message = commitInfo.shortMessage,
|
message = commitInfo.shortMessage,
|
||||||
comment_count = commentCount,
|
comment_count = commentCount,
|
||||||
tree = Tree(
|
tree = Tree(
|
||||||
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/tree/${commitInfo.id}"), // TODO This endpoint has not been implemented yet.
|
url = ApiPath(
|
||||||
|
s"/api/v3/repos/${repositoryName.fullName}/tree/${commitInfo.id}"
|
||||||
|
), // TODO This endpoint has not been implemented yet.
|
||||||
sha = commitInfo.id
|
sha = commitInfo.id
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@@ -114,7 +117,9 @@ object ApiCommits {
|
|||||||
committer = ApiUser(committer),
|
committer = ApiUser(committer),
|
||||||
parents = commitInfo.parents.map { parent =>
|
parents = commitInfo.parents.map { parent =>
|
||||||
Tree(
|
Tree(
|
||||||
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/tree/${parent}"), // TODO This endpoint has not been implemented yet.
|
url = ApiPath(
|
||||||
|
s"/api/v3/repos/${repositoryName.fullName}/tree/${parent}"
|
||||||
|
), // TODO This endpoint has not been implemented yet.
|
||||||
sha = parent
|
sha = parent
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ object ApiContents {
|
|||||||
ApiContents("dir", fileInfo.name, fileInfo.path, fileInfo.commitId, None, None)(repositoryName)
|
ApiContents("dir", fileInfo.name, fileInfo.path, fileInfo.commitId, None, None)(repositoryName)
|
||||||
} else {
|
} else {
|
||||||
content
|
content
|
||||||
.map(
|
.map(arr =>
|
||||||
arr =>
|
|
||||||
ApiContents(
|
ApiContents(
|
||||||
"file",
|
"file",
|
||||||
fileInfo.name,
|
fileInfo.name,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ case class ApiIssue(
|
|||||||
number: Int,
|
number: Int,
|
||||||
title: String,
|
title: String,
|
||||||
user: ApiUser,
|
user: ApiUser,
|
||||||
assignee: Option[ApiUser],
|
assignees: List[ApiUser],
|
||||||
labels: List[ApiLabel],
|
labels: List[ApiLabel],
|
||||||
state: String,
|
state: String,
|
||||||
created_at: Date,
|
created_at: Date,
|
||||||
@@ -21,9 +21,10 @@ case class ApiIssue(
|
|||||||
milestone: Option[ApiMilestone]
|
milestone: Option[ApiMilestone]
|
||||||
)(repositoryName: RepositoryName, isPullRequest: Boolean) {
|
)(repositoryName: RepositoryName, isPullRequest: Boolean) {
|
||||||
val id = 0 // dummy id
|
val id = 0 // dummy id
|
||||||
val assignees = List(assignee).flatten
|
val assignee = assignees.headOption
|
||||||
val comments_url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/issues/${number}/comments")
|
val comments_url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/issues/${number}/comments")
|
||||||
val html_url = ApiPath(s"/${repositoryName.fullName}/${if (isPullRequest) { "pull" } else { "issues" }}/${number}")
|
val html_url = ApiPath(s"/${repositoryName.fullName}/${if (isPullRequest) { "pull" }
|
||||||
|
else { "issues" }}/${number}")
|
||||||
val pull_request = if (isPullRequest) {
|
val pull_request = if (isPullRequest) {
|
||||||
Some(
|
Some(
|
||||||
Map(
|
Map(
|
||||||
@@ -43,7 +44,7 @@ object ApiIssue {
|
|||||||
issue: Issue,
|
issue: Issue,
|
||||||
repositoryName: RepositoryName,
|
repositoryName: RepositoryName,
|
||||||
user: ApiUser,
|
user: ApiUser,
|
||||||
assignee: Option[ApiUser],
|
assignees: List[ApiUser],
|
||||||
labels: List[ApiLabel],
|
labels: List[ApiLabel],
|
||||||
milestone: Option[ApiMilestone]
|
milestone: Option[ApiMilestone]
|
||||||
): ApiIssue =
|
): ApiIssue =
|
||||||
@@ -51,10 +52,11 @@ object ApiIssue {
|
|||||||
number = issue.issueId,
|
number = issue.issueId,
|
||||||
title = issue.title,
|
title = issue.title,
|
||||||
user = user,
|
user = user,
|
||||||
assignee = assignee,
|
assignees = assignees,
|
||||||
labels = labels,
|
labels = labels,
|
||||||
milestone = milestone,
|
milestone = milestone,
|
||||||
state = if (issue.closed) { "closed" } else { "open" },
|
state = if (issue.closed) { "closed" }
|
||||||
|
else { "open" },
|
||||||
body = issue.content.getOrElse(""),
|
body = issue.content.getOrElse(""),
|
||||||
created_at = issue.registeredDate,
|
created_at = issue.registeredDate,
|
||||||
updated_at = issue.updatedDate
|
updated_at = issue.updatedDate
|
||||||
|
|||||||
@@ -21,10 +21,11 @@ case class ApiPullRequest(
|
|||||||
body: String,
|
body: String,
|
||||||
user: ApiUser,
|
user: ApiUser,
|
||||||
labels: List[ApiLabel],
|
labels: List[ApiLabel],
|
||||||
assignee: Option[ApiUser],
|
assignees: List[ApiUser],
|
||||||
draft: Option[Boolean]
|
draft: Option[Boolean]
|
||||||
) {
|
) {
|
||||||
val id = 0 // dummy id
|
val id = 0 // dummy id
|
||||||
|
val assignee = assignees.headOption
|
||||||
val html_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}")
|
val html_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}")
|
||||||
// val diff_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.diff")
|
// val diff_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.diff")
|
||||||
// val patch_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.patch")
|
// val patch_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.patch")
|
||||||
@@ -45,7 +46,7 @@ object ApiPullRequest {
|
|||||||
baseRepo: ApiRepository,
|
baseRepo: ApiRepository,
|
||||||
user: ApiUser,
|
user: ApiUser,
|
||||||
labels: List[ApiLabel],
|
labels: List[ApiLabel],
|
||||||
assignee: Option[ApiUser],
|
assignees: List[ApiUser],
|
||||||
mergedComment: Option[(IssueComment, Account)]
|
mergedComment: Option[(IssueComment, Account)]
|
||||||
): ApiPullRequest =
|
): ApiPullRequest =
|
||||||
ApiPullRequest(
|
ApiPullRequest(
|
||||||
@@ -63,12 +64,13 @@ object ApiPullRequest {
|
|||||||
body = issue.content.getOrElse(""),
|
body = issue.content.getOrElse(""),
|
||||||
user = user,
|
user = user,
|
||||||
labels = labels,
|
labels = labels,
|
||||||
assignee = assignee,
|
assignees = assignees,
|
||||||
draft = Some(pullRequest.isDraft)
|
draft = Some(pullRequest.isDraft)
|
||||||
)
|
)
|
||||||
|
|
||||||
case class Commit(sha: String, ref: String, repo: ApiRepository)(baseOwner: String) {
|
case class Commit(sha: String, ref: String, repo: ApiRepository)(baseOwner: String) {
|
||||||
val label = if (baseOwner == repo.owner.login) { ref } else { s"${repo.owner.login}:${ref}" }
|
val label = if (baseOwner == repo.owner.login) { ref }
|
||||||
|
else { s"${repo.owner.login}:${ref}" }
|
||||||
val user = repo.owner
|
val user = repo.owner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,55 @@
|
|||||||
package gitbucket.core.api
|
package gitbucket.core.api
|
||||||
|
|
||||||
case class ApiObject(sha: String)
|
import gitbucket.core.util.JGitUtil.TagInfo
|
||||||
|
import gitbucket.core.util.RepositoryName
|
||||||
|
import org.eclipse.jgit.lib.Ref
|
||||||
|
|
||||||
case class ApiRef(ref: String, `object`: ApiObject)
|
case class ApiRefCommit(
|
||||||
|
sha: String,
|
||||||
|
`type`: String,
|
||||||
|
url: ApiPath
|
||||||
|
)
|
||||||
|
|
||||||
|
case class ApiRef(
|
||||||
|
ref: String,
|
||||||
|
node_id: String = "",
|
||||||
|
url: ApiPath,
|
||||||
|
`object`: ApiRefCommit,
|
||||||
|
)
|
||||||
|
|
||||||
|
object ApiRef {
|
||||||
|
|
||||||
|
def fromRef(
|
||||||
|
repositoryName: RepositoryName,
|
||||||
|
ref: Ref
|
||||||
|
): ApiRef =
|
||||||
|
ApiRef(
|
||||||
|
ref = ref.getName,
|
||||||
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/git/${ref.getName}"),
|
||||||
|
`object` = ApiRefCommit(
|
||||||
|
sha = ref.getObjectId.getName,
|
||||||
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${ref.getObjectId.getName}"),
|
||||||
|
`type` = "commit"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def fromTag(
|
||||||
|
repositoryName: RepositoryName,
|
||||||
|
tagInfo: TagInfo
|
||||||
|
): ApiRef =
|
||||||
|
ApiRef(
|
||||||
|
ref = s"refs/tags/${tagInfo.name}",
|
||||||
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/git/refs/tags/${tagInfo.name}"),
|
||||||
|
// the GH api distinguishes between "releases" and plain git tags
|
||||||
|
// for "releases", the api returns a reference to the release object (with type `tag`)
|
||||||
|
// this would be something like s"/api/v3/repos/${repositoryName.fullName}/git/tags/<hash-of-tag>"
|
||||||
|
// with a hash for the tag, which I do not fully understand
|
||||||
|
// since this is not yet implemented in GB, we always return a link to the plain `commit` object,
|
||||||
|
// which GH does for tags that are not annotated
|
||||||
|
`object` = ApiRefCommit(
|
||||||
|
sha = tagInfo.objectId,
|
||||||
|
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${tagInfo.objectId}"),
|
||||||
|
`type` = "commit"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ case class ApiRepository(
|
|||||||
val url = ApiPath(s"/api/v3/repos/${full_name}")
|
val url = ApiPath(s"/api/v3/repos/${full_name}")
|
||||||
val clone_url = ApiPath(s"/git/${full_name}.git")
|
val clone_url = ApiPath(s"/git/${full_name}.git")
|
||||||
val html_url = ApiPath(s"/${full_name}")
|
val html_url = ApiPath(s"/${full_name}")
|
||||||
val ssh_url = Some(SshPath(s":${full_name}.git"))
|
val ssh_url = Some(SshPath(""))
|
||||||
}
|
}
|
||||||
|
|
||||||
object ApiRepository {
|
object ApiRepository {
|
||||||
@@ -61,7 +61,7 @@ object ApiRepository {
|
|||||||
watchers = 0,
|
watchers = 0,
|
||||||
forks = 0,
|
forks = 0,
|
||||||
`private` = false,
|
`private` = false,
|
||||||
default_branch = "master",
|
default_branch = "main",
|
||||||
owner = owner,
|
owner = owner,
|
||||||
has_issues = true
|
has_issues = true
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
package gitbucket.core.api
|
|
||||||
|
|
||||||
import gitbucket.core.util.RepositoryName
|
|
||||||
|
|
||||||
case class ApiTagCommit(
|
|
||||||
sha: String,
|
|
||||||
url: ApiPath
|
|
||||||
)
|
|
||||||
|
|
||||||
case class ApiTag(
|
|
||||||
name: String,
|
|
||||||
commit: ApiTagCommit,
|
|
||||||
zipball_url: ApiPath,
|
|
||||||
tarball_url: ApiPath
|
|
||||||
)
|
|
||||||
|
|
||||||
object ApiTag {
|
|
||||||
def apply(
|
|
||||||
tagName: String,
|
|
||||||
repositoryName: RepositoryName,
|
|
||||||
commitId: String
|
|
||||||
): ApiTag =
|
|
||||||
ApiTag(
|
|
||||||
name = tagName,
|
|
||||||
commit = ApiTagCommit(sha = commitId, url = ApiPath(s"/${repositoryName.fullName}/commits/${commitId}")),
|
|
||||||
zipball_url = ApiPath(s"/${repositoryName.fullName}/archive/${tagName}.zip"),
|
|
||||||
tarball_url = ApiPath(s"/${repositoryName.fullName}/archive/${tagName}.tar.gz")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,8 @@ object ApiUser {
|
|||||||
def apply(user: Account): ApiUser = ApiUser(
|
def apply(user: Account): ApiUser = ApiUser(
|
||||||
login = user.userName,
|
login = user.userName,
|
||||||
email = user.mailAddress,
|
email = user.mailAddress,
|
||||||
`type` = if (user.isGroupAccount) { "Organization" } else { "User" },
|
`type` = if (user.isGroupAccount) { "Organization" }
|
||||||
|
else { "User" },
|
||||||
site_admin = user.isAdmin,
|
site_admin = user.isAdmin,
|
||||||
created_at = user.registeredDate
|
created_at = user.registeredDate
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,13 +15,12 @@ object JsonFormat {
|
|||||||
|
|
||||||
val parserISO = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
val parserISO = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||||
|
|
||||||
val jsonFormats = Serialization.formats(NoTypeHints) + new CustomSerializer[Date](
|
val jsonFormats = Serialization.formats(NoTypeHints) + new CustomSerializer[Date](format =>
|
||||||
format =>
|
|
||||||
(
|
(
|
||||||
{
|
{ case JString(s) =>
|
||||||
case JString(s) =>
|
|
||||||
Try(Date.from(Instant.parse(s))).getOrElse(throw new MappingException("Can't convert " + s + " to Date"))
|
Try(Date.from(Instant.parse(s))).getOrElse(throw new MappingException("Can't convert " + s + " to Date"))
|
||||||
}, { case x: Date => JString(OffsetDateTime.ofInstant(x.toInstant, ZoneId.of("UTC")).format(parserISO)) }
|
},
|
||||||
|
{ case x: Date => JString(OffsetDateTime.ofInstant(x.toInstant, ZoneId.of("UTC")).format(parserISO)) }
|
||||||
)
|
)
|
||||||
) + FieldSerializer[ApiUser]() +
|
) + FieldSerializer[ApiUser]() +
|
||||||
FieldSerializer[ApiGroup]() +
|
FieldSerializer[ApiGroup]() +
|
||||||
@@ -48,29 +47,32 @@ object JsonFormat {
|
|||||||
ApiBranchProtection.enforcementLevelSerializer
|
ApiBranchProtection.enforcementLevelSerializer
|
||||||
|
|
||||||
def apiPathSerializer(c: Context) =
|
def apiPathSerializer(c: Context) =
|
||||||
new CustomSerializer[ApiPath](
|
new CustomSerializer[ApiPath](_ =>
|
||||||
_ =>
|
(
|
||||||
({
|
{
|
||||||
case JString(s) if s.startsWith(c.baseUrl) => ApiPath(s.substring(c.baseUrl.length))
|
case JString(s) if s.startsWith(c.baseUrl) => ApiPath(s.substring(c.baseUrl.length))
|
||||||
case JString(s) => throw new MappingException("Can't convert " + s + " to ApiPath")
|
case JString(s) => throw new MappingException("Can't convert " + s + " to ApiPath")
|
||||||
}, {
|
},
|
||||||
case ApiPath(path) => JString(c.baseUrl + path)
|
{ case ApiPath(path) =>
|
||||||
})
|
JString(c.baseUrl + path)
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def sshPathSerializer(c: Context) =
|
def sshPathSerializer(c: Context) =
|
||||||
new CustomSerializer[SshPath](
|
new CustomSerializer[SshPath](_ =>
|
||||||
_ =>
|
(
|
||||||
({
|
{
|
||||||
case JString(s) if c.sshUrl.exists(sshUrl => s.startsWith(sshUrl)) =>
|
case JString(s) if c.sshUrl.exists(sshUrl => s.startsWith(sshUrl)) =>
|
||||||
SshPath(s.substring(c.sshUrl.get.length))
|
SshPath(s.substring(c.sshUrl.get.length))
|
||||||
case JString(s) => throw new MappingException("Can't convert " + s + " to ApiPath")
|
case JString(s) => throw new MappingException("Can't convert " + s + " to ApiPath")
|
||||||
}, {
|
},
|
||||||
case SshPath(path) =>
|
{ case SshPath(path) =>
|
||||||
c.sshUrl.map { sshUrl =>
|
c.sshUrl.map { sshUrl =>
|
||||||
JString(sshUrl + path)
|
JString(sshUrl + path)
|
||||||
} getOrElse JNothing
|
} getOrElse JNothing
|
||||||
})
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -128,6 +128,15 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"highlighterTheme" -> trim(label("Theme", text(required)))
|
"highlighterTheme" -> trim(label("Theme", text(required)))
|
||||||
)(SyntaxHighlighterThemeForm.apply)
|
)(SyntaxHighlighterThemeForm.apply)
|
||||||
|
|
||||||
|
val resetPasswordEmailForm = mapping(
|
||||||
|
"mailAddress" -> trim(label("Email", text(required)))
|
||||||
|
)(ResetPasswordEmailForm.apply)
|
||||||
|
|
||||||
|
val resetPasswordForm = mapping(
|
||||||
|
"token" -> trim(label("Token", text(required))),
|
||||||
|
"password" -> trim(label("Password", text(required, maxlength(40))))
|
||||||
|
)(ResetPasswordForm.apply)
|
||||||
|
|
||||||
case class NewGroupForm(
|
case class NewGroupForm(
|
||||||
groupName: String,
|
groupName: String,
|
||||||
description: Option[String],
|
description: Option[String],
|
||||||
@@ -143,6 +152,13 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
members: String,
|
members: String,
|
||||||
clearImage: Boolean
|
clearImage: Boolean
|
||||||
)
|
)
|
||||||
|
case class ResetPasswordEmailForm(
|
||||||
|
mailAddress: String
|
||||||
|
)
|
||||||
|
case class ResetPasswordForm(
|
||||||
|
token: String,
|
||||||
|
password: String
|
||||||
|
)
|
||||||
|
|
||||||
val newGroupForm = mapping(
|
val newGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
"groupName" -> trim(label("Group name", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
@@ -169,7 +185,6 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
initOption: String,
|
initOption: String,
|
||||||
sourceUrl: Option[String]
|
sourceUrl: Option[String]
|
||||||
)
|
)
|
||||||
case class ForkRepositoryForm(owner: String, name: String)
|
|
||||||
|
|
||||||
val newRepositoryForm = mapping(
|
val newRepositoryForm = mapping(
|
||||||
"owner" -> trim(label("Owner", text(required, maxlength(100), identifier, existsAccount))),
|
"owner" -> trim(label("Owner", text(required, maxlength(100), identifier, existsAccount))),
|
||||||
@@ -180,11 +195,6 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"sourceUrl" -> trim(label("Source URL", optionalRequired(_.value("initOption") == "COPY", text())))
|
"sourceUrl" -> trim(label("Source URL", optionalRequired(_.value("initOption") == "COPY", text())))
|
||||||
)(RepositoryCreationForm.apply)
|
)(RepositoryCreationForm.apply)
|
||||||
|
|
||||||
val forkRepositoryForm = mapping(
|
|
||||||
"owner" -> trim(label("Repository owner", text(required))),
|
|
||||||
"name" -> trim(label("Repository name", text(required)))
|
|
||||||
)(ForkRepositoryForm.apply)
|
|
||||||
|
|
||||||
case class AccountForm(accountName: String)
|
case class AccountForm(accountName: String)
|
||||||
|
|
||||||
val accountForm = mapping(
|
val accountForm = mapping(
|
||||||
@@ -205,9 +215,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"events" -> accountWebhookEvents,
|
"events" -> accountWebhookEvents,
|
||||||
"ctype" -> label("ctype", text()),
|
"ctype" -> label("ctype", text()),
|
||||||
"token" -> optional(trim(label("token", text(maxlength(100)))))
|
"token" -> optional(trim(label("token", text(maxlength(100)))))
|
||||||
)(
|
)((url, events, ctype, token) => AccountWebHookForm(url, events, WebHookContentType.valueOf(ctype), token))
|
||||||
(url, events, ctype, token) => AccountWebHookForm(url, events, WebHookContentType.valueOf(ctype), token)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides duplication check for web hook url. duplicated from RepositorySettingsController.scala
|
* Provides duplication check for web hook url. duplicated from RepositorySettingsController.scala
|
||||||
@@ -252,7 +260,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
gitbucket.core.account.html.activity(
|
gitbucket.core.account.html.activity(
|
||||||
account,
|
account,
|
||||||
if (account.isGroupAccount) Nil else getGroupsByUserName(userName),
|
if (account.isGroupAccount) Nil else getGroupsByUserName(userName),
|
||||||
getActivitiesByUser(userName, true),
|
getActivitiesByUser(userName, publicOnly = true),
|
||||||
extraMailAddresses
|
extraMailAddresses
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -330,8 +338,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
post("/:userName/_edit", editForm)(oneselfOnly { form =>
|
post("/:userName/_edit", editForm)(oneselfOnly { form =>
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map {
|
getAccountByUserName(userName).map { account =>
|
||||||
account =>
|
|
||||||
updateAccount(
|
updateAccount(
|
||||||
account.copy(
|
account.copy(
|
||||||
password = form.password.map(pbkdf2_sha256).getOrElse(account.password),
|
password = form.password.map(pbkdf2_sha256).getOrElse(account.password),
|
||||||
@@ -353,8 +360,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
get("/:userName/_delete")(oneselfOnly {
|
get("/:userName/_delete")(oneselfOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
|
|
||||||
getAccountByUserName(userName, true).map {
|
getAccountByUserName(userName, true).map { account =>
|
||||||
account =>
|
|
||||||
if (isLastAdministrator(account)) {
|
if (isLastAdministrator(account)) {
|
||||||
flash.update("error", "Account can't be removed because this is last one administrator.")
|
flash.update("error", "Account can't be removed because this is last one administrator.")
|
||||||
redirect(s"/${userName}/_edit")
|
redirect(s"/${userName}/_edit")
|
||||||
@@ -515,8 +521,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
get("/:userName/_hooks/edit")(managersOnly {
|
get("/:userName/_hooks/edit")(managersOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).flatMap { account =>
|
getAccountByUserName(userName).flatMap { account =>
|
||||||
getAccountWebHook(userName, params("url")).map {
|
getAccountWebHook(userName, params("url")).map { case (webhook, events) =>
|
||||||
case (webhook, events) =>
|
|
||||||
html.edithook(webhook, events, account, false)
|
html.edithook(webhook, events, account, false)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
@@ -574,8 +579,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"url" -> url,
|
"url" -> url,
|
||||||
"request" -> Await.result(
|
"request" -> Await.result(
|
||||||
reqFuture
|
reqFuture
|
||||||
.map(
|
.map(req =>
|
||||||
req =>
|
|
||||||
Map(
|
Map(
|
||||||
"headers" -> _headers(req.getAllHeaders),
|
"headers" -> _headers(req.getAllHeaders),
|
||||||
"payload" -> json
|
"payload" -> json
|
||||||
@@ -586,8 +590,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
),
|
),
|
||||||
"response" -> Await.result(
|
"response" -> Await.result(
|
||||||
resFuture
|
resFuture
|
||||||
.map(
|
.map(res =>
|
||||||
res =>
|
|
||||||
Map(
|
Map(
|
||||||
"status" -> res.getStatusLine(),
|
"status" -> res.getStatusLine(),
|
||||||
"body" -> EntityUtils.toString(res.getEntity()),
|
"body" -> EntityUtils.toString(res.getEntity()),
|
||||||
@@ -602,7 +605,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/register") {
|
get("/register") {
|
||||||
if (context.settings.allowAccountRegistration) {
|
if (context.settings.basicBehavior.allowAccountRegistration) {
|
||||||
if (context.loginAccount.isDefined) {
|
if (context.loginAccount.isDefined) {
|
||||||
redirect("/")
|
redirect("/")
|
||||||
} else {
|
} else {
|
||||||
@@ -612,7 +615,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
post("/register", newForm) { form =>
|
post("/register", newForm) { form =>
|
||||||
if (context.settings.allowAccountRegistration) {
|
if (context.settings.basicBehavior.allowAccountRegistration) {
|
||||||
createAccount(
|
createAccount(
|
||||||
form.userName,
|
form.userName,
|
||||||
pbkdf2_sha256(form.password),
|
pbkdf2_sha256(form.password),
|
||||||
@@ -628,6 +631,63 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
} else NotFound()
|
} else NotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get("/reset") {
|
||||||
|
if (context.settings.basicBehavior.allowResetPassword) {
|
||||||
|
html.reset()
|
||||||
|
} else NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
post("/reset", resetPasswordEmailForm) { form =>
|
||||||
|
if (context.settings.basicBehavior.allowResetPassword) {
|
||||||
|
getAccountByMailAddress(form.mailAddress).foreach { account =>
|
||||||
|
val token = generateResetPasswordToken(form.mailAddress)
|
||||||
|
val mailer = new Mailer(context.settings)
|
||||||
|
mailer.send(
|
||||||
|
form.mailAddress,
|
||||||
|
"Reset password",
|
||||||
|
s"""Hello, ${account.fullName}!
|
||||||
|
|
|
||||||
|
|You requested to reset the password for your GitBucket account.
|
||||||
|
|If you are not sure about the request, you can ignore this email.
|
||||||
|
|Otherwise, click the following link to set the new password:
|
||||||
|
|${context.baseUrl}/reset/form/${token}
|
||||||
|
|""".stripMargin
|
||||||
|
)
|
||||||
|
}
|
||||||
|
redirect("/reset/sent")
|
||||||
|
} else NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
get("/reset/sent") {
|
||||||
|
if (context.settings.basicBehavior.allowResetPassword) {
|
||||||
|
html.resetsent()
|
||||||
|
} else NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
get("/reset/form/:token") {
|
||||||
|
if (context.settings.basicBehavior.allowResetPassword) {
|
||||||
|
val token = params("token")
|
||||||
|
decodeResetPasswordToken(token)
|
||||||
|
.map { _ =>
|
||||||
|
html.resetform(token)
|
||||||
|
}
|
||||||
|
.getOrElse(NotFound())
|
||||||
|
} else NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
post("/reset/form", resetPasswordForm) { form =>
|
||||||
|
if (context.settings.basicBehavior.allowResetPassword) {
|
||||||
|
decodeResetPasswordToken(form.token)
|
||||||
|
.flatMap { mailAddress =>
|
||||||
|
getAccountByMailAddress(mailAddress).map { account =>
|
||||||
|
updateAccount(account.copy(password = pbkdf2_sha256(form.password)))
|
||||||
|
html.resetcomplete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.getOrElse(NotFound())
|
||||||
|
} else NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
get("/groups/new")(usersOnly {
|
get("/groups/new")(usersOnly {
|
||||||
context.withLoginAccount { loginAccount =>
|
context.withLoginAccount { loginAccount =>
|
||||||
html.creategroup(List(GroupMember("", loginAccount.userName, true)))
|
html.creategroup(List(GroupMember("", loginAccount.userName, true)))
|
||||||
@@ -713,7 +773,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
*/
|
*/
|
||||||
get("/new")(usersOnly {
|
get("/new")(usersOnly {
|
||||||
context.withLoginAccount { loginAccount =>
|
context.withLoginAccount { loginAccount =>
|
||||||
html.newrepo(getGroupsByUserName(loginAccount.userName), context.settings.isCreateRepoOptionPublic)
|
html.newrepo(getGroupsByUserName(loginAccount.userName), context.settings.basicBehavior.isCreateRepoOptionPublic)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -721,9 +781,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
* Create new repository.
|
* Create new repository.
|
||||||
*/
|
*/
|
||||||
post("/new", newRepositoryForm)(usersOnly { form =>
|
post("/new", newRepositoryForm)(usersOnly { form =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
if (context.settings.basicBehavior.repositoryOperation.create || loginAccount.isAdmin) {
|
||||||
if (context.settings.repositoryOperation.create || loginAccount.isAdmin) {
|
|
||||||
LockUtil.lock(s"${form.owner}/${form.name}") {
|
LockUtil.lock(s"${form.owner}/${form.name}") {
|
||||||
if (getRepository(form.owner, form.name).isDefined) {
|
if (getRepository(form.owner, form.name).isDefined) {
|
||||||
// redirect to the repository if repository already exists
|
// redirect to the repository if repository already exists
|
||||||
@@ -740,7 +799,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
form.description,
|
form.description,
|
||||||
form.isPrivate,
|
form.isPrivate,
|
||||||
form.initOption,
|
form.initOption,
|
||||||
form.sourceUrl
|
form.sourceUrl,
|
||||||
|
context.settings.defaultBranch
|
||||||
)
|
)
|
||||||
// redirect to the repository
|
// redirect to the repository
|
||||||
redirect(s"/${form.owner}/${form.name}")
|
redirect(s"/${form.owner}/${form.name}")
|
||||||
@@ -751,17 +811,17 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/fork")(readableUsersOnly { repository =>
|
get("/:owner/:repository/fork")(readableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
if (
|
||||||
if (repository.repository.options.allowFork && (context.settings.repositoryOperation.fork || loginAccount.isAdmin)) {
|
repository.repository.options.allowFork && (context.settings.basicBehavior.repositoryOperation.fork || loginAccount.isAdmin)
|
||||||
|
) {
|
||||||
val loginUserName = loginAccount.userName
|
val loginUserName = loginAccount.userName
|
||||||
val groups = getGroupsByUserName(loginUserName)
|
val groups = getGroupsByUserName(loginUserName)
|
||||||
groups match {
|
groups match {
|
||||||
case _: List[String] =>
|
case _: List[String] =>
|
||||||
val managerPermissions = groups.map { group =>
|
val managerPermissions = groups.map { group =>
|
||||||
val members = getGroupMembers(group)
|
val members = getGroupMembers(group)
|
||||||
context.loginAccount.exists(
|
context.loginAccount.exists(x =>
|
||||||
x =>
|
|
||||||
members.exists { member =>
|
members.exists { member =>
|
||||||
member.userName == x.userName && member.isManager
|
member.userName == x.userName && member.isManager
|
||||||
}
|
}
|
||||||
@@ -778,9 +838,10 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/fork", accountForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/fork", accountForm)(readableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
if (
|
||||||
if (repository.repository.options.allowFork && (context.settings.repositoryOperation.fork || loginAccount.isAdmin)) {
|
repository.repository.options.allowFork && (context.settings.basicBehavior.repositoryOperation.fork || loginAccount.isAdmin)
|
||||||
|
) {
|
||||||
val loginUserName = loginAccount.userName
|
val loginUserName = loginAccount.userName
|
||||||
val accountName = form.accountName
|
val accountName = form.accountName
|
||||||
|
|
||||||
@@ -823,9 +884,11 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
private def members: Constraint = new Constraint() {
|
private def members: Constraint = new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
||||||
if (value.split(",").exists {
|
if (
|
||||||
|
value.split(",").exists {
|
||||||
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
|
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
|
||||||
}) None
|
}
|
||||||
|
) None
|
||||||
else Some("Must select one manager at least.")
|
else Some("Must select one manager at least.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import java.io.{File, FileInputStream}
|
import java.io.{File, FileInputStream, FileOutputStream}
|
||||||
|
|
||||||
import gitbucket.core.api.{ApiError, JsonFormat}
|
import gitbucket.core.api.{ApiError, JsonFormat}
|
||||||
import gitbucket.core.model.Account
|
import gitbucket.core.model.Account
|
||||||
import gitbucket.core.service.{AccountService, RepositoryService, SystemSettingsService}
|
import gitbucket.core.service.{AccountService, RepositoryService, SystemSettingsService}
|
||||||
@@ -14,9 +13,9 @@ import org.scalatra._
|
|||||||
import org.scalatra.i18n._
|
import org.scalatra.i18n._
|
||||||
import org.scalatra.json._
|
import org.scalatra.json._
|
||||||
import org.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
|
|
||||||
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
||||||
import javax.servlet.{FilterChain, ServletRequest, ServletResponse}
|
import javax.servlet.{FilterChain, ServletRequest, ServletResponse}
|
||||||
|
|
||||||
import is.tagomor.woothee.Classifier
|
import is.tagomor.woothee.Classifier
|
||||||
|
|
||||||
import scala.util.Try
|
import scala.util.Try
|
||||||
@@ -29,6 +28,9 @@ import org.eclipse.jgit.treewalk._
|
|||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.json4s.Formats
|
import org.json4s.Formats
|
||||||
|
import org.json4s.jackson.Serialization
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides generic features for controller implementations.
|
* Provides generic features for controller implementations.
|
||||||
@@ -93,8 +95,16 @@ abstract class ControllerBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def LoginAccount: Option[Account] =
|
private def LoginAccount: Option[Account] = {
|
||||||
request.getAs[Account](Keys.Session.LoginAccount).orElse(session.getAs[Account](Keys.Session.LoginAccount))
|
request
|
||||||
|
.getAs[Account](Keys.Session.LoginAccount)
|
||||||
|
.orElse(session.getAs[Account](Keys.Session.LoginAccount))
|
||||||
|
.orElse {
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
getLoginAccountFromLocalFile()
|
||||||
|
} else None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def ajaxGet(path: String)(action: => Any): Route =
|
def ajaxGet(path: String)(action: => Any): Route =
|
||||||
super.get(path) {
|
super.get(path) {
|
||||||
@@ -277,6 +287,47 @@ abstract class ControllerBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected object DevFeatures {
|
||||||
|
val KeepSession = "keep-session"
|
||||||
|
}
|
||||||
|
|
||||||
|
private val loginAccountFile = new File(".tmp/login_account.json")
|
||||||
|
|
||||||
|
protected def isDevFeatureEnabled(feature: String): Boolean = {
|
||||||
|
Option(System.getProperty("dev-features")).getOrElse("").split(",").map(_.trim).contains(feature)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected def getLoginAccountFromLocalFile(): Option[Account] = {
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
if (loginAccountFile.exists()) {
|
||||||
|
Using.resource(new FileInputStream(loginAccountFile)) { in =>
|
||||||
|
val json = IOUtils.toString(in, StandardCharsets.UTF_8)
|
||||||
|
val account = parse(json).extract[Account]
|
||||||
|
session.setAttribute(Keys.Session.LoginAccount, account)
|
||||||
|
Some(parse(json).extract[Account])
|
||||||
|
}
|
||||||
|
} else None
|
||||||
|
|
||||||
|
} else None
|
||||||
|
}
|
||||||
|
|
||||||
|
protected def saveLoginAccountToLocalFile(account: Account): Unit = {
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
if (!loginAccountFile.getParentFile.exists()) {
|
||||||
|
loginAccountFile.getParentFile.mkdirs()
|
||||||
|
}
|
||||||
|
Using.resource(new FileOutputStream(loginAccountFile)) { in =>
|
||||||
|
in.write(Serialization.write(account).getBytes(StandardCharsets.UTF_8))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected def deleteLoginAccountFromLocalFile(): Unit = {
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
loginAccountFile.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -372,10 +423,11 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
messages: Messages
|
messages: Messages
|
||||||
): Option[String] = {
|
): Option[String] = {
|
||||||
val extraMailAddresses = params.view.filterKeys(k => k.startsWith("extraMailAddresses"))
|
val extraMailAddresses = params.view.filterKeys(k => k.startsWith("extraMailAddresses"))
|
||||||
if (extraMailAddresses.exists {
|
if (
|
||||||
case (k, v) =>
|
extraMailAddresses.exists { case (k, v) =>
|
||||||
v.contains(value)
|
v.contains(value)
|
||||||
}) {
|
}
|
||||||
|
) {
|
||||||
Some("These mail addresses are duplicated.")
|
Some("These mail addresses are duplicated.")
|
||||||
} else {
|
} else {
|
||||||
getAccountByMailAddress(value, true)
|
getAccountByMailAddress(value, true)
|
||||||
@@ -395,10 +447,11 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
messages: Messages
|
messages: Messages
|
||||||
): Option[String] = {
|
): Option[String] = {
|
||||||
val extraMailAddresses = params.view.filterKeys(k => k.startsWith("extraMailAddresses"))
|
val extraMailAddresses = params.view.filterKeys(k => k.startsWith("extraMailAddresses"))
|
||||||
if (Some(value) == params.optionValue("mailAddress") || extraMailAddresses.count {
|
if (
|
||||||
case (k, v) =>
|
Some(value) == params.optionValue("mailAddress") || extraMailAddresses.count { case (k, v) =>
|
||||||
v.contains(value)
|
v.contains(value)
|
||||||
} > 1) {
|
} > 1
|
||||||
|
) {
|
||||||
Some("These mail addresses are duplicated.")
|
Some("These mail addresses are duplicated.")
|
||||||
} else {
|
} else {
|
||||||
getAccountByMailAddress(value, true)
|
getAccountByMailAddress(value, true)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import gitbucket.core.service._
|
|||||||
import gitbucket.core.util.{Keys, UsersAuthenticator}
|
import gitbucket.core.util.{Keys, UsersAuthenticator}
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.service.IssuesService._
|
import gitbucket.core.service.IssuesService._
|
||||||
|
import gitbucket.core.service.ActivityService._
|
||||||
|
|
||||||
class DashboardController
|
class DashboardController
|
||||||
extends DashboardControllerBase
|
extends DashboardControllerBase
|
||||||
@@ -40,9 +41,9 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
context.loginAccount,
|
context.loginAccount,
|
||||||
None,
|
None,
|
||||||
withoutPhysicalInfo = true,
|
withoutPhysicalInfo = true,
|
||||||
limit = context.settings.limitVisibleRepositories
|
limit = context.settings.basicBehavior.limitVisibleRepositories
|
||||||
)
|
)
|
||||||
html.repos(getGroupNames(loginAccount.userName), repos, repos)
|
html.repos(getGroupNames(loginAccount.userName), repos, repos, isNewsFeedEnabled)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -111,13 +112,13 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
val condition = getOrCreateCondition(Keys.Session.DashboardIssues, filter, userName)
|
val condition = getOrCreateCondition(Keys.Session.DashboardIssues, filter, userName)
|
||||||
val userRepos = getUserRepositories(userName, true).map(repo => repo.owner -> repo.name)
|
val userRepos = getUserRepositories(userName, true).map(repo => repo.owner -> repo.name)
|
||||||
val page = IssueSearchCondition.page(request)
|
val page = IssueSearchCondition.page(request)
|
||||||
val issues = searchIssue(condition, IssueSearchOption.Issues, (page - 1) * IssueLimit, IssueLimit, userRepos: _*)
|
val issues = searchIssue(condition, IssueSearchOption.Issues, (page - 1) * IssueLimit, IssueLimit, userRepos*)
|
||||||
|
|
||||||
html.issues(
|
html.issues(
|
||||||
issues.map(issue => (issue, None)),
|
issues.map(issue => (issue, None)),
|
||||||
page,
|
page,
|
||||||
countIssue(condition.copy(state = "open"), IssueSearchOption.Issues, userRepos: _*),
|
countIssue(condition.copy(state = "open"), IssueSearchOption.Issues, userRepos*),
|
||||||
countIssue(condition.copy(state = "closed"), IssueSearchOption.Issues, userRepos: _*),
|
countIssue(condition.copy(state = "closed"), IssueSearchOption.Issues, userRepos*),
|
||||||
filter match {
|
filter match {
|
||||||
case "assigned" => condition.copy(assigned = Some(Some(userName)))
|
case "assigned" => condition.copy(assigned = Some(Some(userName)))
|
||||||
case "mentioned" => condition.copy(mentioned = Some(userName))
|
case "mentioned" => condition.copy(mentioned = Some(userName))
|
||||||
@@ -129,8 +130,9 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
context.loginAccount,
|
context.loginAccount,
|
||||||
None,
|
None,
|
||||||
withoutPhysicalInfo = true,
|
withoutPhysicalInfo = true,
|
||||||
limit = context.settings.limitVisibleRepositories
|
limit = context.settings.basicBehavior.limitVisibleRepositories
|
||||||
)
|
),
|
||||||
|
isNewsFeedEnabled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +149,7 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
IssueSearchOption.PullRequests,
|
IssueSearchOption.PullRequests,
|
||||||
(page - 1) * PullRequestLimit,
|
(page - 1) * PullRequestLimit,
|
||||||
PullRequestLimit,
|
PullRequestLimit,
|
||||||
allRepos: _*
|
allRepos*
|
||||||
)
|
)
|
||||||
val status = issues.map { issue =>
|
val status = issues.map { issue =>
|
||||||
issue.commitId.flatMap { commitId =>
|
issue.commitId.flatMap { commitId =>
|
||||||
@@ -158,8 +160,8 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
html.pulls(
|
html.pulls(
|
||||||
issues.zip(status),
|
issues.zip(status),
|
||||||
page,
|
page,
|
||||||
countIssue(condition.copy(state = "open"), IssueSearchOption.PullRequests, allRepos: _*),
|
countIssue(condition.copy(state = "open"), IssueSearchOption.PullRequests, allRepos*),
|
||||||
countIssue(condition.copy(state = "closed"), IssueSearchOption.PullRequests, allRepos: _*),
|
countIssue(condition.copy(state = "closed"), IssueSearchOption.PullRequests, allRepos*),
|
||||||
filter match {
|
filter match {
|
||||||
case "assigned" => condition.copy(assigned = Some(Some(userName)))
|
case "assigned" => condition.copy(assigned = Some(Some(userName)))
|
||||||
case "mentioned" => condition.copy(mentioned = Some(userName))
|
case "mentioned" => condition.copy(mentioned = Some(userName))
|
||||||
@@ -171,8 +173,9 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
context.loginAccount,
|
context.loginAccount,
|
||||||
None,
|
None,
|
||||||
withoutPhysicalInfo = true,
|
withoutPhysicalInfo = true,
|
||||||
limit = context.settings.limitVisibleRepositories
|
limit = context.settings.basicBehavior.limitVisibleRepositories
|
||||||
)
|
),
|
||||||
|
isNewsFeedEnabled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,8 +75,7 @@ class FileUploadController
|
|||||||
post("/wiki/:owner/:repository") {
|
post("/wiki/:owner/:repository") {
|
||||||
setMultipartConfig()
|
setMultipartConfig()
|
||||||
// Don't accept not logged-in users
|
// Don't accept not logged-in users
|
||||||
session.get(Keys.Session.LoginAccount).collect {
|
session.get(Keys.Session.LoginAccount).collect { case loginAccount: Account =>
|
||||||
case loginAccount: Account =>
|
|
||||||
val owner = params("owner")
|
val owner = params("owner")
|
||||||
val repository = params("repository")
|
val repository = params("repository")
|
||||||
|
|
||||||
@@ -86,8 +85,7 @@ class FileUploadController
|
|||||||
{ (file, fileId) =>
|
{ (file, fileId) =>
|
||||||
val fileName = file.getName
|
val fileName = file.getName
|
||||||
LockUtil.lock(s"${owner}/${repository}/wiki") {
|
LockUtil.lock(s"${owner}/${repository}/wiki") {
|
||||||
Using.resource(Git.open(Directory.getWikiRepositoryDir(owner, repository))) {
|
Using.resource(Git.open(Directory.getWikiRepositoryDir(owner, repository))) { git =>
|
||||||
git =>
|
|
||||||
val builder = DirCache.newInCore.builder()
|
val builder = DirCache.newInCore.builder()
|
||||||
val inserter = git.getRepository.newObjectInserter()
|
val inserter = git.getRepository.newObjectInserter()
|
||||||
val headId = git.getRepository.resolve(Constants.HEAD + "^{commit}")
|
val headId = git.getRepository.resolve(Constants.HEAD + "^{commit}")
|
||||||
@@ -135,8 +133,7 @@ class FileUploadController
|
|||||||
setMultipartConfigForLargeFile()
|
setMultipartConfigForLargeFile()
|
||||||
session
|
session
|
||||||
.get(Keys.Session.LoginAccount)
|
.get(Keys.Session.LoginAccount)
|
||||||
.collect {
|
.collect { case _: Account =>
|
||||||
case _: Account =>
|
|
||||||
val owner = params("owner")
|
val owner = params("owner")
|
||||||
val repository = params("repository")
|
val repository = params("repository")
|
||||||
val tag = multiParams("splat").head
|
val tag = multiParams("splat").head
|
||||||
@@ -158,9 +155,12 @@ class FileUploadController
|
|||||||
setMultipartConfig()
|
setMultipartConfig()
|
||||||
session.get(Keys.Session.LoginAccount).collect {
|
session.get(Keys.Session.LoginAccount).collect {
|
||||||
case loginAccount: Account if loginAccount.isAdmin =>
|
case loginAccount: Account if loginAccount.isAdmin =>
|
||||||
execute({ (file, fileId) =>
|
execute(
|
||||||
|
{ (file, fileId) =>
|
||||||
request2Session(request).conn.importAsSQL(file.getInputStream)
|
request2Session(request).conn.importAsSQL(file.getInputStream)
|
||||||
}, _ => true)
|
},
|
||||||
|
_ => true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
redirect("/admin/data")
|
redirect("/admin/data")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import java.net.URI
|
import com.nimbusds.jwt.JWT
|
||||||
|
|
||||||
|
import java.net.URI
|
||||||
import com.nimbusds.oauth2.sdk.id.State
|
import com.nimbusds.oauth2.sdk.id.State
|
||||||
import com.nimbusds.openid.connect.sdk.Nonce
|
import com.nimbusds.openid.connect.sdk.Nonce
|
||||||
import gitbucket.core.helper.xml
|
import gitbucket.core.helper.xml
|
||||||
@@ -13,6 +14,8 @@ import gitbucket.core.view.helpers._
|
|||||||
import org.scalatra.Ok
|
import org.scalatra.Ok
|
||||||
import org.scalatra.forms._
|
import org.scalatra.forms._
|
||||||
|
|
||||||
|
import gitbucket.core.service.ActivityService._
|
||||||
|
|
||||||
class IndexController
|
class IndexController
|
||||||
extends IndexControllerBase
|
extends IndexControllerBase
|
||||||
with RepositoryService
|
with RepositoryService
|
||||||
@@ -57,30 +60,41 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
//
|
//
|
||||||
// case class SearchForm(query: String, owner: String, repository: String)
|
// case class SearchForm(query: String, owner: String, repository: String)
|
||||||
|
|
||||||
case class OidcContext(state: State, nonce: Nonce, redirectBackURI: String)
|
case class OidcAuthContext(state: State, nonce: Nonce, redirectBackURI: String)
|
||||||
|
case class OidcSessionContext(token: JWT)
|
||||||
|
|
||||||
get("/") {
|
get("/") {
|
||||||
context.loginAccount
|
context.loginAccount
|
||||||
.map { account =>
|
.map { account =>
|
||||||
val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName)
|
val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName)
|
||||||
gitbucket.core.html.index(
|
if (!isNewsFeedEnabled) {
|
||||||
getRecentActivitiesByOwners(visibleOwnerSet),
|
redirect("/dashboard/repos")
|
||||||
getVisibleRepositories(
|
} else {
|
||||||
|
val repos = getVisibleRepositories(
|
||||||
Some(account),
|
Some(account),
|
||||||
None,
|
None,
|
||||||
withoutPhysicalInfo = true,
|
withoutPhysicalInfo = true,
|
||||||
limit = context.settings.limitVisibleRepositories
|
limit = false
|
||||||
),
|
)
|
||||||
|
|
||||||
|
gitbucket.core.html.index(
|
||||||
|
activities = getRecentActivitiesByRepos(repos.map(x => (x.owner, x.name)).toSet),
|
||||||
|
recentRepositories = if (context.settings.basicBehavior.limitVisibleRepositories) {
|
||||||
|
repos.filter(x => x.owner == account.userName)
|
||||||
|
} else repos,
|
||||||
showBannerToCreatePersonalAccessToken = hasAccountFederation(account.userName) && !hasAccessToken(
|
showBannerToCreatePersonalAccessToken = hasAccountFederation(account.userName) && !hasAccessToken(
|
||||||
account.userName
|
account.userName
|
||||||
|
),
|
||||||
|
enableNewsFeed = isNewsFeedEnabled
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
.getOrElse {
|
.getOrElse {
|
||||||
gitbucket.core.html.index(
|
gitbucket.core.html.index(
|
||||||
getRecentPublicActivities(),
|
activities = getRecentPublicActivities(),
|
||||||
getVisibleRepositories(None, withoutPhysicalInfo = true),
|
recentRepositories = getVisibleRepositories(None, withoutPhysicalInfo = true),
|
||||||
showBannerToCreatePersonalAccessToken = false
|
showBannerToCreatePersonalAccessToken = false,
|
||||||
|
enableNewsFeed = isNewsFeedEnabled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,8 +134,8 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
case _ => "/"
|
case _ => "/"
|
||||||
}
|
}
|
||||||
session.setAttribute(
|
session.setAttribute(
|
||||||
Keys.Session.OidcContext,
|
Keys.Session.OidcAuthContext,
|
||||||
OidcContext(authenticationRequest.getState, authenticationRequest.getNonce, redirectBackURI)
|
OidcAuthContext(authenticationRequest.getState, authenticationRequest.getNonce, redirectBackURI)
|
||||||
)
|
)
|
||||||
redirect(authenticationRequest.toURI.toString)
|
redirect(authenticationRequest.toURI.toString)
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
@@ -135,9 +149,10 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
get("/signin/oidc") {
|
get("/signin/oidc") {
|
||||||
context.settings.oidc.map { oidc =>
|
context.settings.oidc.map { oidc =>
|
||||||
val redirectURI = new URI(s"$baseUrl/signin/oidc")
|
val redirectURI = new URI(s"$baseUrl/signin/oidc")
|
||||||
session.get(Keys.Session.OidcContext) match {
|
session.get(Keys.Session.OidcAuthContext) match {
|
||||||
case Some(context: OidcContext) =>
|
case Some(context: OidcAuthContext) =>
|
||||||
authenticate(params.toMap, redirectURI, context.state, context.nonce, oidc).map { account =>
|
authenticate(params.toMap, redirectURI, context.state, context.nonce, oidc).map { case (jwt, account) =>
|
||||||
|
session.setAttribute(Keys.Session.OidcSessionContext, OidcSessionContext(jwt))
|
||||||
signin(account, context.redirectBackURI)
|
signin(account, context.redirectBackURI)
|
||||||
} orElse {
|
} orElse {
|
||||||
flash.update("error", "Sorry, authentication failed. Please try again.")
|
flash.update("error", "Sorry, authentication failed. Please try again.")
|
||||||
@@ -155,7 +170,18 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get("/signout") {
|
get("/signout") {
|
||||||
session.invalidate
|
context.settings.oidc.foreach { oidc =>
|
||||||
|
session.get(Keys.Session.OidcSessionContext).foreach { case context: OidcSessionContext =>
|
||||||
|
val redirectURI = new URI(baseUrl)
|
||||||
|
val authenticationRequest = createOIDLogoutRequest(oidc.issuer, oidc.clientID, redirectURI, context.token)
|
||||||
|
session.invalidate()
|
||||||
|
redirect(authenticationRequest.toURI.toString)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.invalidate()
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
deleteLoginAccountFromLocalFile()
|
||||||
|
}
|
||||||
redirect("/")
|
redirect("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +204,9 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
private def signin(account: Account, redirectUrl: String = "/") = {
|
private def signin(account: Account, redirectUrl: String = "/") = {
|
||||||
session.setAttribute(Keys.Session.LoginAccount, account)
|
session.setAttribute(Keys.Session.LoginAccount, account)
|
||||||
|
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
|
||||||
|
saveLoginAccountToLocalFile(account)
|
||||||
|
}
|
||||||
updateLastLoginDate(account.userName)
|
updateLastLoginDate(account.userName)
|
||||||
|
|
||||||
if (LDAPUtil.isDummyMailAddress(account)) {
|
if (LDAPUtil.isDummyMailAddress(account)) {
|
||||||
@@ -201,7 +230,7 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
Map(
|
Map(
|
||||||
"options" -> (
|
"options" -> (
|
||||||
getAllUsers(false)
|
getAllUsers(includeRemoved = false)
|
||||||
.withFilter { t =>
|
.withFilter { t =>
|
||||||
(user, group) match {
|
(user, group) match {
|
||||||
case (true, true) => true
|
case (true, true) => true
|
||||||
@@ -234,11 +263,12 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
} getOrElse ""
|
} getOrElse ""
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO Move to RepositoryViewrController?
|
// TODO Move to RepositoryViewerController?
|
||||||
get("/:owner/:repository/search")(referrersOnly { repository =>
|
get("/:owner/:repository/search")(referrersOnly { repository =>
|
||||||
val query = params.getOrElse("q", "").trim
|
val query = params.getOrElse("q", "").trim
|
||||||
val target = params.getOrElse("type", "code")
|
val target = params.getOrElse("type", "code")
|
||||||
val page = try {
|
val page =
|
||||||
|
try {
|
||||||
val i = params.getOrElse("page", "1").toInt
|
val i = params.getOrElse("page", "1").toInt
|
||||||
if (i <= 0) 1 else i
|
if (i <= 0) 1 else i
|
||||||
} catch {
|
} catch {
|
||||||
@@ -248,8 +278,8 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
target.toLowerCase match {
|
target.toLowerCase match {
|
||||||
case "issues" =>
|
case "issues" =>
|
||||||
gitbucket.core.search.html.issues(
|
gitbucket.core.search.html.issues(
|
||||||
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, false) else Nil,
|
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, pullRequest = false) else Nil,
|
||||||
false,
|
pullRequest = false,
|
||||||
query,
|
query,
|
||||||
page,
|
page,
|
||||||
repository
|
repository
|
||||||
@@ -257,8 +287,8 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
case "pulls" =>
|
case "pulls" =>
|
||||||
gitbucket.core.search.html.issues(
|
gitbucket.core.search.html.issues(
|
||||||
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, true) else Nil,
|
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, pullRequest = true) else Nil,
|
||||||
true,
|
pullRequest = true,
|
||||||
query,
|
query,
|
||||||
page,
|
page,
|
||||||
repository
|
repository
|
||||||
@@ -289,19 +319,19 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
context.loginAccount,
|
context.loginAccount,
|
||||||
None,
|
None,
|
||||||
withoutPhysicalInfo = true,
|
withoutPhysicalInfo = true,
|
||||||
limit = context.settings.limitVisibleRepositories
|
limit = context.settings.basicBehavior.limitVisibleRepositories
|
||||||
)
|
)
|
||||||
|
|
||||||
val repositories = {
|
val repositories = {
|
||||||
context.settings.limitVisibleRepositories match {
|
if (context.settings.basicBehavior.limitVisibleRepositories) {
|
||||||
case true =>
|
|
||||||
getVisibleRepositories(
|
getVisibleRepositories(
|
||||||
context.loginAccount,
|
context.loginAccount,
|
||||||
None,
|
None,
|
||||||
withoutPhysicalInfo = true,
|
withoutPhysicalInfo = true,
|
||||||
limit = false
|
limit = false
|
||||||
)
|
)
|
||||||
case false => visibleRepositories
|
} else {
|
||||||
|
visibleRepositories
|
||||||
}
|
}
|
||||||
}.filter { repository =>
|
}.filter { repository =>
|
||||||
repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0
|
repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.issues.html
|
import gitbucket.core.issues.html
|
||||||
import gitbucket.core.model.Account
|
import gitbucket.core.model.{Account, CustomFieldBehavior}
|
||||||
import gitbucket.core.service.IssuesService._
|
import gitbucket.core.service.IssuesService._
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
@@ -21,6 +21,7 @@ class IssuesController
|
|||||||
with ActivityService
|
with ActivityService
|
||||||
with HandleCommentService
|
with HandleCommentService
|
||||||
with IssueCreationService
|
with IssueCreationService
|
||||||
|
with CustomFieldsService
|
||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with ReferrerAuthenticator
|
with ReferrerAuthenticator
|
||||||
with WritableUsersAuthenticator
|
with WritableUsersAuthenticator
|
||||||
@@ -41,6 +42,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
with ActivityService
|
with ActivityService
|
||||||
with HandleCommentService
|
with HandleCommentService
|
||||||
with IssueCreationService
|
with IssueCreationService
|
||||||
|
with CustomFieldsService
|
||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with ReferrerAuthenticator
|
with ReferrerAuthenticator
|
||||||
with WritableUsersAuthenticator
|
with WritableUsersAuthenticator
|
||||||
@@ -51,7 +53,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
case class IssueCreateForm(
|
case class IssueCreateForm(
|
||||||
title: String,
|
title: String,
|
||||||
content: Option[String],
|
content: Option[String],
|
||||||
assignedUserName: Option[String],
|
assigneeUserNames: Option[String],
|
||||||
milestoneId: Option[Int],
|
milestoneId: Option[Int],
|
||||||
priorityId: Option[Int],
|
priorityId: Option[Int],
|
||||||
labelNames: Option[String]
|
labelNames: Option[String]
|
||||||
@@ -62,7 +64,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
val issueCreateForm = mapping(
|
val issueCreateForm = mapping(
|
||||||
"title" -> trim(label("Title", text(required))),
|
"title" -> trim(label("Title", text(required))),
|
||||||
"content" -> trim(optional(text())),
|
"content" -> trim(optional(text())),
|
||||||
"assignedUserName" -> trim(optional(text())),
|
"assigneeUserNames" -> trim(optional(text())),
|
||||||
"milestoneId" -> trim(optional(number())),
|
"milestoneId" -> trim(optional(number())),
|
||||||
"priorityId" -> trim(optional(number())),
|
"priorityId" -> trim(optional(number())),
|
||||||
"labelNames" -> trim(optional(text()))
|
"labelNames" -> trim(optional(text()))
|
||||||
@@ -87,17 +89,25 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
get("/:owner/:repository/issues")(referrersOnly { repository =>
|
get("/:owner/:repository/issues")(referrersOnly { repository =>
|
||||||
val q = request.getParameter("q")
|
val q = request.getParameter("q")
|
||||||
if (Option(q).exists(_.contains("is:pr"))) {
|
Option(q) match {
|
||||||
|
case Some(filter) if filter.contains("is:pr") =>
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pulls?q=${StringUtil.urlEncode(q)}")
|
redirect(s"/${repository.owner}/${repository.name}/pulls?q=${StringUtil.urlEncode(q)}")
|
||||||
|
case Some(filter) =>
|
||||||
|
val condition = IssueSearchCondition(filter)
|
||||||
|
if (condition.isEmpty) {
|
||||||
|
// Redirect to keyword search
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/search?q=${StringUtil.urlEncode(q)}&type=issues")
|
||||||
} else {
|
} else {
|
||||||
searchIssues(repository)
|
searchIssues(repository, condition, IssueSearchCondition.page(request))
|
||||||
|
}
|
||||||
|
case None =>
|
||||||
|
searchIssues(repository, IssueSearchCondition(request), IssueSearchCondition.page(request))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/:id")(referrersOnly { repository =>
|
get("/:owner/:repository/issues/:id")(referrersOnly { repository =>
|
||||||
val issueId = params("id")
|
val issueId = params("id")
|
||||||
getIssue(repository.owner, repository.name, issueId) map {
|
getIssue(repository.owner, repository.name, issueId) map { issue =>
|
||||||
issue =>
|
|
||||||
if (issue.isPullRequest) {
|
if (issue.isPullRequest) {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
} else {
|
} else {
|
||||||
@@ -105,10 +115,12 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
issue,
|
issue,
|
||||||
getComments(repository.owner, repository.name, issueId.toInt),
|
getComments(repository.owner, repository.name, issueId.toInt),
|
||||||
getIssueLabels(repository.owner, repository.name, issueId.toInt),
|
getIssueLabels(repository.owner, repository.name, issueId.toInt),
|
||||||
|
getIssueAssignees(repository.owner, repository.name, issueId.toInt),
|
||||||
getAssignableUserNames(repository.owner, repository.name),
|
getAssignableUserNames(repository.owner, repository.name),
|
||||||
getMilestonesWithIssueCount(repository.owner, repository.name),
|
getMilestonesWithIssueCount(repository.owner, repository.name),
|
||||||
getPriorities(repository.owner, repository.name),
|
getPriorities(repository.owner, repository.name),
|
||||||
getLabels(repository.owner, repository.name),
|
getLabels(repository.owner, repository.name),
|
||||||
|
getCustomFieldsWithValue(repository.owner, repository.name, issueId.toInt).filter(_._1.enableForIssues),
|
||||||
isIssueEditable(repository),
|
isIssueEditable(repository),
|
||||||
isIssueManageable(repository),
|
isIssueManageable(repository),
|
||||||
isIssueCommentManageable(repository),
|
isIssueCommentManageable(repository),
|
||||||
@@ -126,6 +138,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
getPriorities(repository.owner, repository.name),
|
getPriorities(repository.owner, repository.name),
|
||||||
getDefaultPriority(repository.owner, repository.name),
|
getDefaultPriority(repository.owner, repository.name),
|
||||||
getLabels(repository.owner, repository.name),
|
getLabels(repository.owner, repository.name),
|
||||||
|
getCustomFields(repository.owner, repository.name).filter(_.enableForIssues),
|
||||||
isIssueManageable(repository),
|
isIssueManageable(repository),
|
||||||
getContentTemplate(repository, "ISSUE_TEMPLATE"),
|
getContentTemplate(repository, "ISSUE_TEMPLATE"),
|
||||||
repository
|
repository
|
||||||
@@ -134,29 +147,44 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
if (isIssueEditable(repository)) { // TODO Should this check is provided by authenticator?
|
if (isIssueEditable(repository)) { // TODO Should this check is provided by authenticator?
|
||||||
val issue = createIssue(
|
val issue = createIssue(
|
||||||
repository,
|
repository,
|
||||||
form.title,
|
form.title,
|
||||||
form.content,
|
form.content,
|
||||||
form.assignedUserName,
|
form.assigneeUserNames.toSeq.flatMap(_.split(",")),
|
||||||
form.milestoneId,
|
form.milestoneId,
|
||||||
form.priorityId,
|
form.priorityId,
|
||||||
form.labelNames.toSeq.flatMap(_.split(",")),
|
form.labelNames.toSeq.flatMap(_.split(",")),
|
||||||
loginAccount
|
loginAccount
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Insert custom field values
|
||||||
|
params.toMap.foreach { case (key, value) =>
|
||||||
|
if (key.startsWith("custom-field-")) {
|
||||||
|
getCustomField(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
key.replaceFirst("^custom-field-", "").toInt
|
||||||
|
).foreach { field =>
|
||||||
|
CustomFieldBehavior.validate(field, value, messages) match {
|
||||||
|
case None =>
|
||||||
|
insertOrUpdateCustomFieldValue(field, repository.owner, repository.name, issue.issueId, value)
|
||||||
|
case Some(_) => halt(400)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
redirect(s"/${issue.userName}/${issue.repositoryName}/issues/${issue.issueId}")
|
redirect(s"/${issue.userName}/${issue.repositoryName}/issues/${issue.issueId}")
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/edit_title/:id", issueTitleEditForm)(readableUsersOnly { (title, repository) =>
|
ajaxPost("/:owner/:repository/issues/edit_title/:id", issueTitleEditForm)(readableUsersOnly { (title, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
getIssue(repository.owner, repository.name, params("id")).map { issue =>
|
||||||
getIssue(repository.owner, repository.name, params("id")).map {
|
|
||||||
issue =>
|
|
||||||
if (isEditableContent(repository.owner, repository.name, issue.openedUserName, loginAccount)) {
|
if (isEditableContent(repository.owner, repository.name, issue.openedUserName, loginAccount)) {
|
||||||
if (issue.title != title) {
|
if (issue.title != title) {
|
||||||
// update issue
|
// update issue
|
||||||
@@ -179,8 +207,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/edit/:id", issueEditForm)(readableUsersOnly { (content, repository) =>
|
ajaxPost("/:owner/:repository/issues/edit/:id", issueEditForm)(readableUsersOnly { (content, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
getIssue(repository.owner, repository.name, params("id")).map { issue =>
|
getIssue(repository.owner, repository.name, params("id")).map { issue =>
|
||||||
if (isEditableContent(repository.owner, repository.name, issue.openedUserName, loginAccount)) {
|
if (isEditableContent(repository.owner, repository.name, issue.openedUserName, loginAccount)) {
|
||||||
// update issue
|
// update issue
|
||||||
@@ -195,15 +222,13 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
||||||
val actionOpt =
|
val actionOpt =
|
||||||
params
|
params
|
||||||
.get("action")
|
.get("action")
|
||||||
.filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName, loginAccount))
|
.filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName, loginAccount))
|
||||||
handleComment(issue, Some(form.content), repository, actionOpt) map {
|
handleComment(issue, Some(form.content), repository, actionOpt) map { case (issue, id) =>
|
||||||
case (issue, id) =>
|
|
||||||
redirect(
|
redirect(
|
||||||
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}"
|
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}"
|
||||||
)
|
)
|
||||||
@@ -213,15 +238,13 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issue_comments/state", issueStateForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issue_comments/state", issueStateForm)(readableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
||||||
val actionOpt =
|
val actionOpt =
|
||||||
params
|
params
|
||||||
.get("action")
|
.get("action")
|
||||||
.filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName, loginAccount))
|
.filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName, loginAccount))
|
||||||
handleComment(issue, form.content, repository, actionOpt) map {
|
handleComment(issue, form.content, repository, actionOpt) map { case (issue, id) =>
|
||||||
case (issue, id) =>
|
|
||||||
redirect(
|
redirect(
|
||||||
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}"
|
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}"
|
||||||
)
|
)
|
||||||
@@ -231,11 +254,10 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issue_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/issue_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
getComment(repository.owner, repository.name, params("id")).map { comment =>
|
getComment(repository.owner, repository.name, params("id")).map { comment =>
|
||||||
if (isEditableContent(repository.owner, repository.name, comment.commentedUserName, loginAccount)) {
|
if (isEditableContent(repository.owner, repository.name, comment.commentedUserName, loginAccount)) {
|
||||||
updateComment(comment.issueId, comment.commentId, form.content)
|
updateComment(repository.owner, repository.name, comment.issueId, comment.commentId, form.content)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issue_comments/_data/${comment.commentId}")
|
redirect(s"/${repository.owner}/${repository.name}/issue_comments/_data/${comment.commentId}")
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
@@ -253,10 +275,8 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issues/_data/:id")(readableUsersOnly { repository =>
|
ajaxGet("/:owner/:repository/issues/_data/:id")(readableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
getIssue(repository.owner, repository.name, params("id")) map { x =>
|
||||||
getIssue(repository.owner, repository.name, params("id")) map {
|
|
||||||
x =>
|
|
||||||
if (isEditableContent(x.userName, x.repositoryName, x.openedUserName, loginAccount)) {
|
if (isEditableContent(x.userName, x.repositoryName, x.openedUserName, loginAccount)) {
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editissue(x.content, x.issueId, repository)
|
case t if t == "html" => html.editissue(x.content, x.issueId, repository)
|
||||||
@@ -285,10 +305,8 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issue_comments/_data/:id")(readableUsersOnly { repository =>
|
ajaxGet("/:owner/:repository/issue_comments/_data/:id")(readableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
getComment(repository.owner, repository.name, params("id")) map { x =>
|
||||||
getComment(repository.owner, repository.name, params("id")) map {
|
|
||||||
x =>
|
|
||||||
if (isEditableContent(x.userName, x.repositoryName, x.commentedUserName, loginAccount)) {
|
if (isEditableContent(x.userName, x.repositoryName, x.commentedUserName, loginAccount)) {
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
|
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
|
||||||
@@ -333,15 +351,16 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/assign")(writableUsersOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/assignee/new")(writableUsersOnly { repository =>
|
||||||
updateAssignedUserName(
|
val issueId = params("id").toInt
|
||||||
repository.owner,
|
registerIssueAssignee(repository.owner, repository.name, issueId, params("assigneeUserName"), true)
|
||||||
repository.name,
|
Ok()
|
||||||
params("id").toInt,
|
})
|
||||||
assignedUserName("assignedUserName"),
|
|
||||||
true
|
ajaxPost("/:owner/:repository/issues/:id/assignee/delete")(writableUsersOnly { repository =>
|
||||||
)
|
val issueId = params("id").toInt
|
||||||
Ok("updated")
|
deleteIssueAssignee(repository.owner, repository.name, issueId, params("assigneeUserName"), true)
|
||||||
|
Ok()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/milestone")(writableUsersOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/milestone")(writableUsersOnly { repository =>
|
||||||
@@ -349,8 +368,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
milestoneId("milestoneId").map { milestoneId =>
|
milestoneId("milestoneId").map { milestoneId =>
|
||||||
getMilestonesWithIssueCount(repository.owner, repository.name)
|
getMilestonesWithIssueCount(repository.owner, repository.name)
|
||||||
.find(_._1.milestoneId == milestoneId)
|
.find(_._1.milestoneId == milestoneId)
|
||||||
.map {
|
.map { case (_, openCount, closeCount) =>
|
||||||
case (_, openCount, closeCount) =>
|
|
||||||
gitbucket.core.issues.milestones.html.progress(openCount + closeCount, closeCount)
|
gitbucket.core.issues.milestones.html.progress(openCount + closeCount, closeCount)
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
} getOrElse Ok()
|
} getOrElse Ok()
|
||||||
@@ -362,6 +380,35 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
Ok("updated")
|
Ok("updated")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ajaxPost("/:owner/:repository/issues/customfield_validation/:fieldId")(writableUsersOnly { repository =>
|
||||||
|
val fieldId = params("fieldId").toInt
|
||||||
|
val value = params("value")
|
||||||
|
getCustomField(repository.owner, repository.name, fieldId)
|
||||||
|
.flatMap { field =>
|
||||||
|
CustomFieldBehavior.validate(field, value, messages).map { error =>
|
||||||
|
Ok(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.getOrElse(Ok())
|
||||||
|
})
|
||||||
|
|
||||||
|
ajaxPost("/:owner/:repository/issues/:id/customfield/:fieldId")(writableUsersOnly { repository =>
|
||||||
|
val issueId = params("id").toInt
|
||||||
|
val fieldId = params("fieldId").toInt
|
||||||
|
val value = params("value")
|
||||||
|
|
||||||
|
for {
|
||||||
|
_ <- getIssue(repository.owner, repository.name, issueId.toString)
|
||||||
|
field <- getCustomField(repository.owner, repository.name, fieldId)
|
||||||
|
} {
|
||||||
|
CustomFieldBehavior.validate(field, value, messages) match {
|
||||||
|
case None => insertOrUpdateCustomFieldValue(field, repository.owner, repository.name, issueId, value)
|
||||||
|
case Some(_) => halt(400)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(value)
|
||||||
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/state")(writableUsersOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/state")(writableUsersOnly { repository =>
|
||||||
val action = params.get("value")
|
val action = params.get("value")
|
||||||
action match {
|
action match {
|
||||||
@@ -403,7 +450,13 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
post("/:owner/:repository/issues/batchedit/assign")(writableUsersOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/assign")(writableUsersOnly { repository =>
|
||||||
val value = assignedUserName("value")
|
val value = assignedUserName("value")
|
||||||
executeBatch(repository) {
|
executeBatch(repository) {
|
||||||
updateAssignedUserName(repository.owner, repository.name, _, value, true)
|
// updateAssignedUserName(repository.owner, repository.name, _, value, true)
|
||||||
|
value match {
|
||||||
|
case Some(assignedUserName) =>
|
||||||
|
registerIssueAssignee(repository.owner, repository.name, _, assignedUserName, true)
|
||||||
|
case None =>
|
||||||
|
deleteAllIssueAssignees(repository.owner, repository.name, _, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (params("uri").nonEmpty) {
|
if (params("uri").nonEmpty) {
|
||||||
redirect(params("uri"))
|
redirect(params("uri"))
|
||||||
@@ -471,10 +524,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def searchIssues(repository: RepositoryService.RepositoryInfo) = {
|
private def searchIssues(repository: RepositoryService.RepositoryInfo, condition: IssueSearchCondition, page: Int) = {
|
||||||
val page = IssueSearchCondition.page(request)
|
|
||||||
// retrieve search condition
|
|
||||||
val condition = IssueSearchCondition(request)
|
|
||||||
// search issues
|
// search issues
|
||||||
val issues =
|
val issues =
|
||||||
searchIssue(
|
searchIssue(
|
||||||
@@ -505,8 +555,8 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
/**
|
/**
|
||||||
* Tests whether an issue or a comment is editable by a logged-in user.
|
* Tests whether an issue or a comment is editable by a logged-in user.
|
||||||
*/
|
*/
|
||||||
private def isEditableContent(owner: String, repository: String, author: String, loginAccount: Account)(
|
private def isEditableContent(owner: String, repository: String, author: String, loginAccount: Account)(implicit
|
||||||
implicit context: Context
|
context: Context
|
||||||
): Boolean = {
|
): Boolean = {
|
||||||
hasDeveloperRole(owner, repository, context.loginAccount) || author == loginAccount.userName
|
hasDeveloperRole(owner, repository, context.loginAccount) || author == loginAccount.userName
|
||||||
}
|
}
|
||||||
@@ -514,8 +564,8 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
/**
|
/**
|
||||||
* Tests whether an issue comment is deletable by a logged-in user.
|
* Tests whether an issue comment is deletable by a logged-in user.
|
||||||
*/
|
*/
|
||||||
private def isDeletableComment(owner: String, repository: String, author: String, loginAccount: Account)(
|
private def isDeletableComment(owner: String, repository: String, author: String, loginAccount: Account)(implicit
|
||||||
implicit context: Context
|
context: Context
|
||||||
): Boolean = {
|
): Boolean = {
|
||||||
hasOwnerRole(owner, repository, context.loginAccount) || author == loginAccount.userName
|
hasOwnerRole(owner, repository, context.loginAccount) || author == loginAccount.userName
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
get("/:owner/:repository/issues/labels")(referrersOnly { repository =>
|
get("/:owner/:repository/issues/labels")(referrersOnly { repository =>
|
||||||
html.list(
|
html.list(
|
||||||
getLabels(repository.owner, repository.name),
|
getLabels(repository.owner, repository.name),
|
||||||
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
@@ -59,7 +59,7 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
html.label(
|
html.label(
|
||||||
getLabel(repository.owner, repository.name, labelId).get,
|
getLabel(repository.owner, repository.name, labelId).get,
|
||||||
// TODO futility
|
// TODO futility
|
||||||
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
@@ -76,7 +76,7 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
html.label(
|
html.label(
|
||||||
getLabel(repository.owner, repository.name, params("labelId").toInt).get,
|
getLabel(repository.owner, repository.name, params("labelId").toInt).get,
|
||||||
// TODO futility
|
// TODO futility
|
||||||
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -29,13 +29,15 @@ trait PreProcessControllerBase extends ControllerBase {
|
|||||||
* If anonymous access is allowed, pass all requests.
|
* If anonymous access is allowed, pass all requests.
|
||||||
* But if it's not allowed, demands authentication except some paths.
|
* But if it's not allowed, demands authentication except some paths.
|
||||||
*/
|
*/
|
||||||
get(!context.settings.allowAnonymousAccess, context.loginAccount.isEmpty) {
|
get(!context.settings.basicBehavior.allowAnonymousAccess, context.loginAccount.isEmpty) {
|
||||||
if (!context.currentPath.startsWith("/assets") && !context.currentPath.startsWith("/signin") &&
|
if (
|
||||||
|
!context.currentPath.startsWith("/assets") && !context.currentPath.startsWith("/signin") &&
|
||||||
!context.currentPath.startsWith("/register") && !context.currentPath.endsWith("/info/refs") &&
|
!context.currentPath.startsWith("/register") && !context.currentPath.endsWith("/info/refs") &&
|
||||||
!context.currentPath.startsWith("/plugin-assets") &&
|
!context.currentPath.startsWith("/plugin-assets") &&
|
||||||
!PluginRegistry().getAnonymousAccessiblePaths().exists { path =>
|
!PluginRegistry().getAnonymousAccessiblePaths().exists { path =>
|
||||||
context.currentPath.startsWith(path)
|
context.currentPath.startsWith(path)
|
||||||
}) {
|
}
|
||||||
|
) {
|
||||||
Unauthorized()
|
Unauthorized()
|
||||||
} else {
|
} else {
|
||||||
pass()
|
pass()
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ trait PrioritiesControllerBase extends ControllerBase {
|
|||||||
get("/:owner/:repository/issues/priorities")(referrersOnly { repository =>
|
get("/:owner/:repository/issues/priorities")(referrersOnly { repository =>
|
||||||
html.list(
|
html.list(
|
||||||
getPriorities(repository.owner, repository.name),
|
getPriorities(repository.owner, repository.name),
|
||||||
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
@@ -60,7 +60,7 @@ trait PrioritiesControllerBase extends ControllerBase {
|
|||||||
createPriority(repository.owner, repository.name, form.priorityName, form.description, form.color.substring(1))
|
createPriority(repository.owner, repository.name, form.priorityName, form.description, form.color.substring(1))
|
||||||
html.priority(
|
html.priority(
|
||||||
getPriority(repository.owner, repository.name, priorityId).get,
|
getPriority(repository.owner, repository.name, priorityId).get,
|
||||||
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
@@ -84,7 +84,7 @@ trait PrioritiesControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
html.priority(
|
html.priority(
|
||||||
getPriority(repository.owner, repository.name, params("priorityId").toInt).get,
|
getPriority(repository.owner, repository.name, params("priorityId").toInt).get,
|
||||||
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
|
||||||
repository,
|
repository,
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class PullRequestsController
|
|||||||
with PullRequestService
|
with PullRequestService
|
||||||
with MilestonesService
|
with MilestonesService
|
||||||
with LabelsService
|
with LabelsService
|
||||||
|
with CustomFieldsService
|
||||||
with CommitsService
|
with CommitsService
|
||||||
with ActivityService
|
with ActivityService
|
||||||
with WebHookPullRequestService
|
with WebHookPullRequestService
|
||||||
@@ -44,6 +45,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
with IssuesService
|
with IssuesService
|
||||||
with MilestonesService
|
with MilestonesService
|
||||||
with LabelsService
|
with LabelsService
|
||||||
|
with CustomFieldsService
|
||||||
with CommitsService
|
with CommitsService
|
||||||
with ActivityService
|
with ActivityService
|
||||||
with PullRequestService
|
with PullRequestService
|
||||||
@@ -67,7 +69,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
"commitIdFrom" -> trim(text(required, maxlength(40))),
|
"commitIdFrom" -> trim(text(required, maxlength(40))),
|
||||||
"commitIdTo" -> trim(text(required, maxlength(40))),
|
"commitIdTo" -> trim(text(required, maxlength(40))),
|
||||||
"isDraft" -> trim(boolean(required)),
|
"isDraft" -> trim(boolean(required)),
|
||||||
"assignedUserName" -> trim(optional(text())),
|
"assigneeUserNames" -> trim(optional(text())),
|
||||||
"milestoneId" -> trim(optional(number())),
|
"milestoneId" -> trim(optional(number())),
|
||||||
"priorityId" -> trim(optional(number())),
|
"priorityId" -> trim(optional(number())),
|
||||||
"labelNames" -> trim(optional(text()))
|
"labelNames" -> trim(optional(text()))
|
||||||
@@ -90,7 +92,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
commitIdFrom: String,
|
commitIdFrom: String,
|
||||||
commitIdTo: String,
|
commitIdTo: String,
|
||||||
isDraft: Boolean,
|
isDraft: Boolean,
|
||||||
assignedUserName: Option[String],
|
assigneeUserNames: Option[String],
|
||||||
milestoneId: Option[Int],
|
milestoneId: Option[Int],
|
||||||
priorityId: Option[Int],
|
priorityId: Option[Int],
|
||||||
labelNames: Option[String]
|
labelNames: Option[String]
|
||||||
@@ -100,18 +102,25 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
get("/:owner/:repository/pulls")(referrersOnly { repository =>
|
get("/:owner/:repository/pulls")(referrersOnly { repository =>
|
||||||
val q = request.getParameter("q")
|
val q = request.getParameter("q")
|
||||||
if (Option(q).exists(_.contains("is:issue"))) {
|
Option(q) match {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues?q=" + StringUtil.urlEncode(q))
|
case Some(filter) if filter.contains("is:issue") =>
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/issues?q=${StringUtil.urlEncode(q)}")
|
||||||
|
case Some(filter) =>
|
||||||
|
val condition = IssueSearchCondition(filter)
|
||||||
|
if (condition.isEmpty) {
|
||||||
|
// Redirect to keyword search
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/search?q=${StringUtil.urlEncode(q)}&type=pulls")
|
||||||
} else {
|
} else {
|
||||||
searchPullRequests(None, repository)
|
searchPullRequests(repository, IssueSearchCondition(filter), IssueSearchCondition.page(request))
|
||||||
|
}
|
||||||
|
case None =>
|
||||||
|
searchPullRequests(repository, IssueSearchCondition(request), IssueSearchCondition.page(request))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/pull/:id")(referrersOnly { repository =>
|
get("/:owner/:repository/pull/:id")(referrersOnly { repository =>
|
||||||
params("id").toIntOpt.flatMap {
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
issueId =>
|
getPullRequest(repository.owner, repository.name, issueId) map { case (issue, pullreq) =>
|
||||||
getPullRequest(repository.owner, repository.name, issueId) map {
|
|
||||||
case (issue, pullreq) =>
|
|
||||||
val (commits, diffs) =
|
val (commits, diffs) =
|
||||||
getRequestCompareInfo(
|
getRequestCompareInfo(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
@@ -119,7 +128,8 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
pullreq.commitIdFrom,
|
pullreq.commitIdFrom,
|
||||||
repository.owner,
|
repository.owner,
|
||||||
repository.name,
|
repository.name,
|
||||||
pullreq.commitIdTo
|
pullreq.commitIdTo,
|
||||||
|
context.settings
|
||||||
)
|
)
|
||||||
|
|
||||||
html.conversation(
|
html.conversation(
|
||||||
@@ -129,10 +139,12 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
getPullRequestComments(repository.owner, repository.name, issue.issueId, commits.flatten),
|
getPullRequestComments(repository.owner, repository.name, issue.issueId, commits.flatten),
|
||||||
diffs.size,
|
diffs.size,
|
||||||
getIssueLabels(repository.owner, repository.name, issueId),
|
getIssueLabels(repository.owner, repository.name, issueId),
|
||||||
|
getIssueAssignees(repository.owner, repository.name, issueId),
|
||||||
getAssignableUserNames(repository.owner, repository.name),
|
getAssignableUserNames(repository.owner, repository.name),
|
||||||
getMilestonesWithIssueCount(repository.owner, repository.name),
|
getMilestonesWithIssueCount(repository.owner, repository.name),
|
||||||
getPriorities(repository.owner, repository.name),
|
getPriorities(repository.owner, repository.name),
|
||||||
getLabels(repository.owner, repository.name),
|
getLabels(repository.owner, repository.name),
|
||||||
|
getCustomFieldsWithValue(repository.owner, repository.name, issueId).filter(_._1.enableForPullRequests),
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
isManageable(repository),
|
isManageable(repository),
|
||||||
hasDeveloperRole(pullreq.requestUserName, pullreq.requestRepositoryName, context.loginAccount),
|
hasDeveloperRole(pullreq.requestUserName, pullreq.requestRepositoryName, context.loginAccount),
|
||||||
@@ -140,34 +152,13 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
getRepository(pullreq.requestUserName, pullreq.requestRepositoryName),
|
getRepository(pullreq.requestUserName, pullreq.requestRepositoryName),
|
||||||
flash.iterator.map(f => f._1 -> f._2.toString).toMap
|
flash.iterator.map(f => f._1 -> f._2.toString).toMap
|
||||||
)
|
)
|
||||||
|
|
||||||
// html.pullreq(
|
|
||||||
// issue,
|
|
||||||
// pullreq,
|
|
||||||
// comments,
|
|
||||||
// getIssueLabels(owner, name, issueId),
|
|
||||||
// getAssignableUserNames(owner, name),
|
|
||||||
// getMilestonesWithIssueCount(owner, name),
|
|
||||||
// getPriorities(owner, name),
|
|
||||||
// getLabels(owner, name),
|
|
||||||
// commits,
|
|
||||||
// diffs,
|
|
||||||
// isEditable(repository),
|
|
||||||
// isManageable(repository),
|
|
||||||
// hasDeveloperRole(pullreq.requestUserName, pullreq.requestRepositoryName, context.loginAccount),
|
|
||||||
// repository,
|
|
||||||
// getRepository(pullreq.requestUserName, pullreq.requestRepositoryName),
|
|
||||||
// flash.toMap.map(f => f._1 -> f._2.toString)
|
|
||||||
// )
|
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/pull/:id/commits")(referrersOnly { repository =>
|
get("/:owner/:repository/pull/:id/commits")(referrersOnly { repository =>
|
||||||
params("id").toIntOpt.flatMap {
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
issueId =>
|
getPullRequest(repository.owner, repository.name, issueId) map { case (issue, pullreq) =>
|
||||||
getPullRequest(repository.owner, repository.name, issueId) map {
|
|
||||||
case (issue, pullreq) =>
|
|
||||||
val (commits, diffs) =
|
val (commits, diffs) =
|
||||||
getRequestCompareInfo(
|
getRequestCompareInfo(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
@@ -175,7 +166,8 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
pullreq.commitIdFrom,
|
pullreq.commitIdFrom,
|
||||||
repository.owner,
|
repository.owner,
|
||||||
repository.name,
|
repository.name,
|
||||||
pullreq.commitIdTo
|
pullreq.commitIdTo,
|
||||||
|
context.settings
|
||||||
)
|
)
|
||||||
|
|
||||||
val commitsWithStatus = commits.map { day =>
|
val commitsWithStatus = commits.map { day =>
|
||||||
@@ -198,10 +190,8 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/pull/:id/files")(referrersOnly { repository =>
|
get("/:owner/:repository/pull/:id/files")(referrersOnly { repository =>
|
||||||
params("id").toIntOpt.flatMap {
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
issueId =>
|
getPullRequest(repository.owner, repository.name, issueId) map { case (issue, pullreq) =>
|
||||||
getPullRequest(repository.owner, repository.name, issueId) map {
|
|
||||||
case (issue, pullreq) =>
|
|
||||||
val (commits, diffs) =
|
val (commits, diffs) =
|
||||||
getRequestCompareInfo(
|
getRequestCompareInfo(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
@@ -209,7 +199,8 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
pullreq.commitIdFrom,
|
pullreq.commitIdFrom,
|
||||||
repository.owner,
|
repository.owner,
|
||||||
repository.name,
|
repository.name,
|
||||||
pullreq.commitIdTo
|
pullreq.commitIdTo,
|
||||||
|
context.settings
|
||||||
)
|
)
|
||||||
|
|
||||||
html.files(
|
html.files(
|
||||||
@@ -226,10 +217,8 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/pull/:id/mergeguide")(referrersOnly { repository =>
|
ajaxGet("/:owner/:repository/pull/:id/mergeguide")(referrersOnly { repository =>
|
||||||
params("id").toIntOpt.flatMap {
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
issueId =>
|
getPullRequest(repository.owner, repository.name, issueId) map { case (issue, pullreq) =>
|
||||||
getPullRequest(repository.owner, repository.name, issueId) map {
|
|
||||||
case (issue, pullreq) =>
|
|
||||||
val conflictMessage = LockUtil.lock(s"${repository.owner}/${repository.name}") {
|
val conflictMessage = LockUtil.lock(s"${repository.owner}/${repository.name}") {
|
||||||
checkConflict(repository.owner, repository.name, pullreq.branch, issueId)
|
checkConflict(repository.owner, repository.name, pullreq.branch, issueId)
|
||||||
}
|
}
|
||||||
@@ -239,9 +228,8 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
conflictMessage = conflictMessage,
|
conflictMessage = conflictMessage,
|
||||||
commitStatuses = getCommitStatuses(repository.owner, repository.name, pullreq.commitIdTo),
|
commitStatuses = getCommitStatuses(repository.owner, repository.name, pullreq.commitIdTo),
|
||||||
branchProtection = branchProtection,
|
branchProtection = branchProtection,
|
||||||
branchIsOutOfDate = JGitUtil.getShaByRef(repository.owner, repository.name, pullreq.branch) != Some(
|
branchIsOutOfDate =
|
||||||
pullreq.commitIdFrom
|
!JGitUtil.getShaByRef(repository.owner, repository.name, pullreq.branch).contains(pullreq.commitIdFrom),
|
||||||
),
|
|
||||||
needStatusCheck = context.loginAccount.forall { u =>
|
needStatusCheck = context.loginAccount.forall { u =>
|
||||||
branchProtection.needStatusCheck(u.userName)
|
branchProtection.needStatusCheck(u.userName)
|
||||||
},
|
},
|
||||||
@@ -326,7 +314,9 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
} else {
|
} else {
|
||||||
LockUtil.lock(s"${owner}/${name}") {
|
LockUtil.lock(s"${owner}/${name}") {
|
||||||
val alias =
|
val alias =
|
||||||
if (pullreq.repositoryName == pullreq.requestRepositoryName && pullreq.userName == pullreq.requestUserName) {
|
if (
|
||||||
|
pullreq.repositoryName == pullreq.requestRepositoryName && pullreq.userName == pullreq.requestUserName
|
||||||
|
) {
|
||||||
pullreq.branch
|
pullreq.branch
|
||||||
} else {
|
} else {
|
||||||
s"${pullreq.userName}:${pullreq.branch}"
|
s"${pullreq.userName}:${pullreq.branch}"
|
||||||
@@ -392,11 +382,10 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/compare")(referrersOnly { forkedRepository =>
|
get("/:owner/:repository/compare")(referrersOnly { forkedRepository =>
|
||||||
val headBranch: Option[String] = params.get("head")
|
val headBranch = params.get("head")
|
||||||
(forkedRepository.repository.originUserName, forkedRepository.repository.originRepositoryName) match {
|
(forkedRepository.repository.originUserName, forkedRepository.repository.originRepositoryName) match {
|
||||||
case (Some(originUserName), Some(originRepositoryName)) => {
|
case (Some(originUserName), Some(originRepositoryName)) =>
|
||||||
getRepository(originUserName, originRepositoryName).map {
|
getRepository(originUserName, originRepositoryName).map { originRepository =>
|
||||||
originRepository =>
|
|
||||||
Using.resources(
|
Using.resources(
|
||||||
Git.open(getRepositoryDir(originUserName, originRepositoryName)),
|
Git.open(getRepositoryDir(originUserName, originRepositoryName)),
|
||||||
Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))
|
Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))
|
||||||
@@ -411,11 +400,9 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
case _ =>
|
||||||
case _ => {
|
|
||||||
Using.resource(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))) { git =>
|
Using.resource(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))) { git =>
|
||||||
JGitUtil.getDefaultBranch(git, forkedRepository).map {
|
JGitUtil.getDefaultBranch(git, forkedRepository).map { case (_, defaultBranch) =>
|
||||||
case (_, defaultBranch) =>
|
|
||||||
redirect(
|
redirect(
|
||||||
s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${defaultBranch}...${headBranch.getOrElse(defaultBranch)}"
|
s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${defaultBranch}...${headBranch.getOrElse(defaultBranch)}"
|
||||||
)
|
)
|
||||||
@@ -424,15 +411,14 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/compare/*...*")(referrersOnly { forkedRepository =>
|
private def getOriginRepositoryName(
|
||||||
val Seq(origin, forked) = multiParams("splat")
|
originOwner: String,
|
||||||
val (originOwner, originId) = parseCompareIdentifier(origin, forkedRepository.owner)
|
forkedOwner: String,
|
||||||
val (forkedOwner, forkedId) = parseCompareIdentifier(forked, forkedRepository.owner)
|
forkedRepository: RepositoryInfo
|
||||||
|
): Option[String] = {
|
||||||
(for (originRepositoryName <- if (originOwner == forkedOwner) {
|
if (originOwner == forkedOwner) {
|
||||||
// Self repository
|
// Self repository
|
||||||
Some(forkedRepository.name)
|
Some(forkedRepository.name)
|
||||||
} else if (forkedRepository.repository.originUserName.isEmpty) {
|
} else if (forkedRepository.repository.originUserName.isEmpty) {
|
||||||
@@ -451,20 +437,31 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
x.repository.originRepositoryName == forkedRepository.repository.originRepositoryName
|
x.repository.originRepositoryName == forkedRepository.repository.originRepositoryName
|
||||||
}
|
}
|
||||||
.map(_.repository.repositoryName)
|
.map(_.repository.repositoryName)
|
||||||
};
|
}
|
||||||
originRepository <- getRepository(originOwner, originRepositoryName)) yield {
|
}
|
||||||
|
|
||||||
|
get("/:owner/:repository/compare/*...*")(referrersOnly { forkedRepository =>
|
||||||
|
val Seq(origin, forked) = multiParams("splat")
|
||||||
|
val (originOwner, originId) = parseCompareIdentifier(origin, forkedRepository.owner)
|
||||||
|
val (forkedOwner, forkedId) = parseCompareIdentifier(forked, forkedRepository.owner)
|
||||||
|
|
||||||
|
(for (
|
||||||
|
originRepositoryName <- getOriginRepositoryName(originOwner, forkedOwner, forkedRepository);
|
||||||
|
originRepository <- getRepository(originOwner, originRepositoryName)
|
||||||
|
) yield {
|
||||||
val (oldId, newId) =
|
val (oldId, newId) =
|
||||||
getPullRequestCommitFromTo(originRepository, forkedRepository, originId, forkedId)
|
getPullRequestCommitFromTo(originRepository, forkedRepository, originId, forkedId)
|
||||||
|
|
||||||
(oldId, newId) match {
|
(oldId, newId) match {
|
||||||
case (Some(oldId), Some(newId)) => {
|
case (Some(oldId), Some(newId)) =>
|
||||||
val (commits, diffs) = getRequestCompareInfo(
|
val (commits, diffs) = getRequestCompareInfo(
|
||||||
originRepository.owner,
|
originRepository.owner,
|
||||||
originRepository.name,
|
originRepository.name,
|
||||||
oldId.getName,
|
oldId.getName,
|
||||||
forkedRepository.owner,
|
forkedRepository.owner,
|
||||||
forkedRepository.name,
|
forkedRepository.name,
|
||||||
newId.getName
|
newId.getName,
|
||||||
|
context.settings
|
||||||
)
|
)
|
||||||
|
|
||||||
val title = if (commits.flatten.length == 1) {
|
val title = if (commits.flatten.length == 1) {
|
||||||
@@ -505,9 +502,9 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
getMilestones(originRepository.owner, originRepository.name),
|
getMilestones(originRepository.owner, originRepository.name),
|
||||||
getPriorities(originRepository.owner, originRepository.name),
|
getPriorities(originRepository.owner, originRepository.name),
|
||||||
getDefaultPriority(originRepository.owner, originRepository.name),
|
getDefaultPriority(originRepository.owner, originRepository.name),
|
||||||
getLabels(originRepository.owner, originRepository.name)
|
getLabels(originRepository.owner, originRepository.name),
|
||||||
|
getCustomFields(originRepository.owner, originRepository.name).filter(_.enableForPullRequests)
|
||||||
)
|
)
|
||||||
}
|
|
||||||
case (oldId, newId) =>
|
case (oldId, newId) =>
|
||||||
redirect(
|
redirect(
|
||||||
s"/${forkedRepository.owner}/${forkedRepository.name}/compare/" +
|
s"/${forkedRepository.owner}/${forkedRepository.name}/compare/" +
|
||||||
@@ -519,12 +516,62 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ajaxGet("/:owner/:repository/diff/:id")(referrersOnly { repository =>
|
||||||
|
(for {
|
||||||
|
commitId <- params.get("id")
|
||||||
|
path <- params.get("path")
|
||||||
|
diff <- getSingleDiff(repository.owner, repository.name, commitId, path)
|
||||||
|
} yield {
|
||||||
|
contentType = formats("json")
|
||||||
|
org.json4s.jackson.Serialization.write(
|
||||||
|
Map(
|
||||||
|
"oldContent" -> diff.oldContent,
|
||||||
|
"newContent" -> diff.newContent
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
ajaxGet("/:owner/:repository/diff/*...*")(referrersOnly { forkedRepository =>
|
||||||
|
val Seq(origin, forked) = multiParams("splat")
|
||||||
|
val (originOwner, originId) = parseCompareIdentifier(origin, forkedRepository.owner)
|
||||||
|
val (forkedOwner, forkedId) = parseCompareIdentifier(forked, forkedRepository.owner)
|
||||||
|
|
||||||
|
(for {
|
||||||
|
path <- params.get("path")
|
||||||
|
originRepositoryName <- getOriginRepositoryName(originOwner, forkedOwner, forkedRepository)
|
||||||
|
originRepository <- getRepository(originOwner, originRepositoryName)
|
||||||
|
(oldId, newId) = getPullRequestCommitFromTo(originRepository, forkedRepository, originId, forkedId)
|
||||||
|
oldId <- oldId
|
||||||
|
newId <- newId
|
||||||
|
diff <- getSingleDiff(
|
||||||
|
originRepository.owner,
|
||||||
|
originRepository.name,
|
||||||
|
oldId.getName,
|
||||||
|
forkedRepository.owner,
|
||||||
|
forkedRepository.name,
|
||||||
|
newId.getName,
|
||||||
|
path
|
||||||
|
)
|
||||||
|
} yield {
|
||||||
|
contentType = formats("json")
|
||||||
|
org.json4s.jackson.Serialization.write(
|
||||||
|
Map(
|
||||||
|
"oldContent" -> diff.oldContent,
|
||||||
|
"newContent" -> diff.newContent
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/compare/*...*/mergecheck")(readableUsersOnly { forkedRepository =>
|
ajaxGet("/:owner/:repository/compare/*...*/mergecheck")(readableUsersOnly { forkedRepository =>
|
||||||
val Seq(origin, forked) = multiParams("splat")
|
val Seq(origin, forked) = multiParams("splat")
|
||||||
val (originOwner, tmpOriginBranch) = parseCompareIdentifier(origin, forkedRepository.owner)
|
val (originOwner, tmpOriginBranch) = parseCompareIdentifier(origin, forkedRepository.owner)
|
||||||
val (forkedOwner, tmpForkedBranch) = parseCompareIdentifier(forked, forkedRepository.owner)
|
val (forkedOwner, tmpForkedBranch) = parseCompareIdentifier(forked, forkedRepository.owner)
|
||||||
|
|
||||||
(for (originRepositoryName <- if (originOwner == forkedOwner) {
|
(for (
|
||||||
|
originRepositoryName <-
|
||||||
|
if (originOwner == forkedOwner) {
|
||||||
Some(forkedRepository.name)
|
Some(forkedRepository.name)
|
||||||
} else {
|
} else {
|
||||||
forkedRepository.repository.originRepositoryName.orElse {
|
forkedRepository.repository.originRepositoryName.orElse {
|
||||||
@@ -533,12 +580,12 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
.map(_.repositoryName)
|
.map(_.repositoryName)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
originRepository <- getRepository(originOwner, originRepositoryName)) yield {
|
originRepository <- getRepository(originOwner, originRepositoryName)
|
||||||
|
) yield {
|
||||||
Using.resources(
|
Using.resources(
|
||||||
Git.open(getRepositoryDir(originRepository.owner, originRepository.name)),
|
Git.open(getRepositoryDir(originRepository.owner, originRepository.name)),
|
||||||
Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))
|
Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))
|
||||||
) {
|
) { case (oldGit, newGit) =>
|
||||||
case (oldGit, newGit) =>
|
|
||||||
val originBranch = JGitUtil.getDefaultBranch(oldGit, originRepository, tmpOriginBranch).get._2
|
val originBranch = JGitUtil.getDefaultBranch(oldGit, originRepository, tmpOriginBranch).get._2
|
||||||
val forkedBranch = JGitUtil.getDefaultBranch(newGit, forkedRepository, tmpForkedBranch).get._2
|
val forkedBranch = JGitUtil.getDefaultBranch(newGit, forkedRepository, tmpForkedBranch).get._2
|
||||||
val conflict = LockUtil.lock(s"${originRepository.owner}/${originRepository.name}") {
|
val conflict = LockUtil.lock(s"${originRepository.owner}/${originRepository.name}") {
|
||||||
@@ -557,8 +604,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/pulls/new", pullRequestForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/pulls/new", pullRequestForm)(readableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
val manageable = isManageable(repository)
|
val manageable = isManageable(repository)
|
||||||
|
|
||||||
val issueId = insertIssue(
|
val issueId = insertIssue(
|
||||||
@@ -567,7 +613,6 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
loginUser = loginAccount.userName,
|
loginUser = loginAccount.userName,
|
||||||
title = form.title,
|
title = form.title,
|
||||||
content = form.content,
|
content = form.content,
|
||||||
assignedUserName = if (manageable) form.assignedUserName else None,
|
|
||||||
milestoneId = if (manageable) form.milestoneId else None,
|
milestoneId = if (manageable) form.milestoneId else None,
|
||||||
priorityId = if (manageable) form.priorityId else None,
|
priorityId = if (manageable) form.priorityId else None,
|
||||||
isPullRequest = true
|
isPullRequest = true
|
||||||
@@ -587,8 +632,14 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
settings = context.settings
|
settings = context.settings
|
||||||
)
|
)
|
||||||
|
|
||||||
// insert labels
|
|
||||||
if (manageable) {
|
if (manageable) {
|
||||||
|
// insert assignees
|
||||||
|
form.assigneeUserNames.foreach { value =>
|
||||||
|
value.split(",").foreach { userName =>
|
||||||
|
registerIssueAssignee(repository.owner, repository.name, issueId, userName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// insert labels
|
||||||
form.labelNames.foreach { value =>
|
form.labelNames.foreach { value =>
|
||||||
val labels = getLabels(repository.owner, repository.name)
|
val labels = getLabels(repository.owner, repository.name)
|
||||||
value.split(",").foreach { labelName =>
|
value.split(",").foreach { labelName =>
|
||||||
@@ -609,8 +660,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
context.loginAccount.map(x => Seq(x.mailAddress) ++ getAccountExtraMailAddresses(x.userName)).getOrElse(Nil)
|
context.loginAccount.map(x => Seq(x.mailAddress) ++ getAccountExtraMailAddresses(x.userName)).getOrElse(Nil)
|
||||||
|
|
||||||
val branches =
|
val branches =
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
JGitUtil
|
JGitUtil
|
||||||
.getBranches(
|
.getBranches(
|
||||||
git = git,
|
git = git,
|
||||||
@@ -646,10 +696,11 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
html.proposals(proposedBranches, targetRepository, repository)
|
html.proposals(proposedBranches, targetRepository, repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
private def searchPullRequests(userName: Option[String], repository: RepositoryService.RepositoryInfo) = {
|
private def searchPullRequests(
|
||||||
val page = IssueSearchCondition.page(request)
|
repository: RepositoryService.RepositoryInfo,
|
||||||
// retrieve search condition
|
condition: IssueSearchCondition,
|
||||||
val condition = IssueSearchCondition(request)
|
page: Int
|
||||||
|
) = {
|
||||||
// search issues
|
// search issues
|
||||||
val issues = searchIssue(
|
val issues = searchIssue(
|
||||||
condition,
|
condition,
|
||||||
|
|||||||
@@ -106,8 +106,7 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/releases/*/create", releaseForm)(writableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/releases/*/create", releaseForm)(writableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
val tagName = multiParams("splat").head
|
val tagName = multiParams("splat").head
|
||||||
|
|
||||||
// Insert into RELEASE
|
// Insert into RELEASE
|
||||||
@@ -119,8 +118,7 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
val Array(_, fileId) = name.split(":")
|
val Array(_, fileId) = name.split(":")
|
||||||
(fileId, value)
|
(fileId, value)
|
||||||
}
|
}
|
||||||
files.foreach {
|
files.foreach { case (fileId, fileName) =>
|
||||||
case (fileId, fileName) =>
|
|
||||||
val size =
|
val size =
|
||||||
new File(
|
new File(
|
||||||
getReleaseFilesDir(repository.owner, repository.name),
|
getReleaseFilesDir(repository.owner, repository.name),
|
||||||
@@ -138,7 +136,7 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
get("/:owner/:repository/changelog/*...*")(writableUsersOnly { repository =>
|
get("/:owner/:repository/changelog/*...*")(writableUsersOnly { repository =>
|
||||||
val Seq(previousTag, currentTag) = multiParams("splat")
|
val Seq(previousTag, currentTag) = multiParams("splat")
|
||||||
val previousTagId = repository.tags.collectFirst { case x if x.name == previousTag => x.id }.getOrElse("")
|
val previousTagId = repository.tags.collectFirst { case x if x.name == previousTag => x.commitId }.getOrElse("")
|
||||||
|
|
||||||
val commitLog = Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
val commitLog = Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
val commits = JGitUtil.getCommitLog(git, previousTagId, currentTag).reverse
|
val commits = JGitUtil.getCommitLog(git, previousTagId, currentTag).reverse
|
||||||
@@ -171,13 +169,11 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/releases/*/edit", releaseForm)(writableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/releases/*/edit", releaseForm)(writableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
val tagName = multiParams("splat").head
|
val tagName = multiParams("splat").head
|
||||||
|
|
||||||
getRelease(repository.owner, repository.name, tagName)
|
getRelease(repository.owner, repository.name, tagName)
|
||||||
.map {
|
.map { release =>
|
||||||
release =>
|
|
||||||
// Update RELEASE
|
// Update RELEASE
|
||||||
updateRelease(repository.owner, repository.name, tagName, form.name, form.content)
|
updateRelease(repository.owner, repository.name, tagName, form.name, form.content)
|
||||||
|
|
||||||
@@ -190,8 +186,7 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
val Array(_, fileId) = name.split(":")
|
val Array(_, fileId) = name.split(":")
|
||||||
(fileId, value)
|
(fileId, value)
|
||||||
}
|
}
|
||||||
files.foreach {
|
files.foreach { case (fileId, fileName) =>
|
||||||
case (fileId, fileName) =>
|
|
||||||
val size =
|
val size =
|
||||||
new File(
|
new File(
|
||||||
getReleaseFilesDir(repository.owner, repository.name),
|
getReleaseFilesDir(repository.owner, repository.name),
|
||||||
@@ -237,9 +232,12 @@ trait ReleaseControllerBase extends ControllerBase {
|
|||||||
val assets = getReleaseAssetsMap(repository.owner, repository.name, releases)
|
val assets = getReleaseAssetsMap(repository.owner, repository.name, releases)
|
||||||
|
|
||||||
val tagsWithReleases = tagsToDisplay.map { tag =>
|
val tagsWithReleases = tagsToDisplay.map { tag =>
|
||||||
(tag, releases.find(_.tag == tag.name).map { release =>
|
(
|
||||||
|
tag,
|
||||||
|
releases.find(_.tag == tag.name).map { release =>
|
||||||
(release, assets(release))
|
(release, assets(release))
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
tagsWithReleases
|
tagsWithReleases
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package gitbucket.core.controller
|
|||||||
|
|
||||||
import java.time.{LocalDateTime, ZoneOffset}
|
import java.time.{LocalDateTime, ZoneOffset}
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
import gitbucket.core.settings.html
|
import gitbucket.core.settings.html
|
||||||
import gitbucket.core.model.{RepositoryWebHook, WebHook}
|
import gitbucket.core.model.{RepositoryWebHook, WebHook}
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
@@ -21,7 +20,7 @@ import org.eclipse.jgit.lib.Constants
|
|||||||
import org.eclipse.jgit.lib.ObjectId
|
import org.eclipse.jgit.lib.ObjectId
|
||||||
|
|
||||||
import scala.util.Using
|
import scala.util.Using
|
||||||
import org.scalatra.Forbidden
|
import org.scalatra.{Forbidden, Ok}
|
||||||
|
|
||||||
class RepositorySettingsController
|
class RepositorySettingsController
|
||||||
extends RepositorySettingsControllerBase
|
extends RepositorySettingsControllerBase
|
||||||
@@ -31,6 +30,7 @@ class RepositorySettingsController
|
|||||||
with ProtectedBranchService
|
with ProtectedBranchService
|
||||||
with CommitStatusService
|
with CommitStatusService
|
||||||
with DeployKeyService
|
with DeployKeyService
|
||||||
|
with CustomFieldsService
|
||||||
with ActivityService
|
with ActivityService
|
||||||
with OwnerAuthenticator
|
with OwnerAuthenticator
|
||||||
with UsersAuthenticator
|
with UsersAuthenticator
|
||||||
@@ -43,6 +43,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
with ProtectedBranchService
|
with ProtectedBranchService
|
||||||
with CommitStatusService
|
with CommitStatusService
|
||||||
with DeployKeyService
|
with DeployKeyService
|
||||||
|
with CustomFieldsService
|
||||||
with ActivityService
|
with ActivityService
|
||||||
with OwnerAuthenticator
|
with OwnerAuthenticator
|
||||||
with UsersAuthenticator =>
|
with UsersAuthenticator =>
|
||||||
@@ -121,6 +122,23 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
"newOwner" -> trim(label("New owner", text(required, transferUser)))
|
"newOwner" -> trim(label("New owner", text(required, transferUser)))
|
||||||
)(TransferOwnerShipForm.apply)
|
)(TransferOwnerShipForm.apply)
|
||||||
|
|
||||||
|
// for custom field
|
||||||
|
case class CustomFieldForm(
|
||||||
|
fieldName: String,
|
||||||
|
fieldType: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
enableForIssues: Boolean,
|
||||||
|
enableForPullRequests: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
|
val customFieldForm = mapping(
|
||||||
|
"fieldName" -> trim(label("Field name", text(required, maxlength(100)))),
|
||||||
|
"fieldType" -> trim(label("Field type", text(required))),
|
||||||
|
"constraints" -> trim(label("Constraints", optional(text()))),
|
||||||
|
"enableForIssues" -> trim(label("Enable for issues", boolean(required))),
|
||||||
|
"enableForPullRequests" -> trim(label("Enable for pull requests", boolean(required))),
|
||||||
|
)(CustomFieldForm.apply)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirect to the Options page.
|
* Redirect to the Options page.
|
||||||
*/
|
*/
|
||||||
@@ -268,8 +286,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
Array(h.getName, h.getValue)
|
Array(h.getName, h.getValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import scala.concurrent._
|
import scala.concurrent._
|
||||||
import scala.jdk.CollectionConverters._
|
import scala.jdk.CollectionConverters._
|
||||||
@@ -330,8 +347,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
"url" -> url,
|
"url" -> url,
|
||||||
"request" -> Await.result(
|
"request" -> Await.result(
|
||||||
reqFuture
|
reqFuture
|
||||||
.map(
|
.map(req =>
|
||||||
req =>
|
|
||||||
Map(
|
Map(
|
||||||
"headers" -> _headers(req.getAllHeaders),
|
"headers" -> _headers(req.getAllHeaders),
|
||||||
"payload" -> json
|
"payload" -> json
|
||||||
@@ -342,8 +358,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
),
|
),
|
||||||
"response" -> Await.result(
|
"response" -> Await.result(
|
||||||
resFuture
|
resFuture
|
||||||
.map(
|
.map(res =>
|
||||||
res =>
|
|
||||||
Map(
|
Map(
|
||||||
"status" -> res.getStatusLine.getStatusCode,
|
"status" -> res.getStatusLine.getStatusCode,
|
||||||
"body" -> EntityUtils.toString(res.getEntity()),
|
"body" -> EntityUtils.toString(res.getEntity()),
|
||||||
@@ -362,8 +377,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
* Display the web hook edit page.
|
* Display the web hook edit page.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/settings/hooks/edit")(ownerOnly { repository =>
|
get("/:owner/:repository/settings/hooks/edit")(ownerOnly { repository =>
|
||||||
getWebHook(repository.owner, repository.name, params("url")).map {
|
getWebHook(repository.owner, repository.name, params("url")).map { case (webhook, events) =>
|
||||||
case (webhook, events) =>
|
|
||||||
html.edithook(webhook, events, repository, false)
|
html.edithook(webhook, events, repository, false)
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
@@ -388,9 +402,8 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
* Rename repository.
|
* Rename repository.
|
||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/rename", renameForm)(ownerOnly { (form, repository) =>
|
post("/:owner/:repository/settings/rename", renameForm)(ownerOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
if (context.settings.basicBehavior.repositoryOperation.rename || loginAccount.isAdmin) {
|
||||||
if (context.settings.repositoryOperation.rename || loginAccount.isAdmin) {
|
|
||||||
if (repository.name != form.repositoryName) {
|
if (repository.name != form.repositoryName) {
|
||||||
// Update database and move git repository
|
// Update database and move git repository
|
||||||
renameRepository(repository.owner, repository.name, repository.owner, form.repositoryName)
|
renameRepository(repository.owner, repository.name, repository.owner, form.repositoryName)
|
||||||
@@ -412,9 +425,8 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
* Transfer repository ownership.
|
* Transfer repository ownership.
|
||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/transfer", transferForm)(ownerOnly { (form, repository) =>
|
post("/:owner/:repository/settings/transfer", transferForm)(ownerOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
if (context.settings.basicBehavior.repositoryOperation.transfer || loginAccount.isAdmin) {
|
||||||
if (context.settings.repositoryOperation.transfer || loginAccount.isAdmin) {
|
|
||||||
// Change repository owner
|
// Change repository owner
|
||||||
if (repository.owner != form.newOwner) {
|
if (repository.owner != form.newOwner) {
|
||||||
// Update database and move git repository
|
// Update database and move git repository
|
||||||
@@ -438,7 +450,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
post("/:owner/:repository/settings/delete")(ownerOnly { repository =>
|
post("/:owner/:repository/settings/delete")(ownerOnly { repository =>
|
||||||
context.withLoginAccount { loginAccount =>
|
context.withLoginAccount { loginAccount =>
|
||||||
if (context.settings.repositoryOperation.delete || loginAccount.isAdmin) {
|
if (context.settings.basicBehavior.repositoryOperation.delete || loginAccount.isAdmin) {
|
||||||
// Delete the repository and related files
|
// Delete the repository and related files
|
||||||
deleteRepository(repository.repository)
|
deleteRepository(repository.repository)
|
||||||
redirect(s"/${repository.owner}")
|
redirect(s"/${repository.owner}")
|
||||||
@@ -477,6 +489,60 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
redirect(s"/${repository.owner}/${repository.name}/settings/deploykey")
|
redirect(s"/${repository.owner}/${repository.name}/settings/deploykey")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** Custom fields for issues and pull requests */
|
||||||
|
get("/:owner/:repository/settings/issues")(ownerOnly { repository =>
|
||||||
|
val customFields = getCustomFields(repository.owner, repository.name)
|
||||||
|
html.issues(customFields, repository)
|
||||||
|
})
|
||||||
|
|
||||||
|
/** New custom field form */
|
||||||
|
get("/:owner/:repository/settings/issues/fields/new")(ownerOnly { repository =>
|
||||||
|
html.issuesfieldform(None, repository)
|
||||||
|
})
|
||||||
|
|
||||||
|
/** Add custom field */
|
||||||
|
ajaxPost("/:owner/:repository/settings/issues/fields/new", customFieldForm)(ownerOnly { (form, repository) =>
|
||||||
|
val fieldId = createCustomField(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
form.fieldName,
|
||||||
|
form.fieldType,
|
||||||
|
if (form.fieldType == "enum") form.constraints else None,
|
||||||
|
form.enableForIssues,
|
||||||
|
form.enableForPullRequests
|
||||||
|
)
|
||||||
|
html.issuesfield(getCustomField(repository.owner, repository.name, fieldId).get)
|
||||||
|
})
|
||||||
|
|
||||||
|
/** Edit custom field form */
|
||||||
|
ajaxGet("/:owner/:repository/settings/issues/fields/:fieldId/edit")(ownerOnly { repository =>
|
||||||
|
getCustomField(repository.owner, repository.name, params("fieldId").toInt).map { customField =>
|
||||||
|
html.issuesfieldform(Some(customField), repository)
|
||||||
|
} getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/** Update custom field */
|
||||||
|
ajaxPost("/:owner/:repository/settings/issues/fields/:fieldId/edit", customFieldForm)(ownerOnly {
|
||||||
|
(form, repository) =>
|
||||||
|
updateCustomField(
|
||||||
|
repository.owner,
|
||||||
|
repository.name,
|
||||||
|
params("fieldId").toInt,
|
||||||
|
form.fieldName,
|
||||||
|
form.fieldType,
|
||||||
|
if (form.fieldType == "enum") form.constraints else None,
|
||||||
|
form.enableForIssues,
|
||||||
|
form.enableForPullRequests
|
||||||
|
)
|
||||||
|
html.issuesfield(getCustomField(repository.owner, repository.name, params("fieldId").toInt).get)
|
||||||
|
})
|
||||||
|
|
||||||
|
/** Delete custom field */
|
||||||
|
ajaxPost("/:owner/:repository/settings/issues/fields/:fieldId/delete")(ownerOnly { repository =>
|
||||||
|
deleteCustomField(repository.owner, repository.name, params("fieldId").toInt)
|
||||||
|
Ok()
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides duplication check for web hook url.
|
* Provides duplication check for web hook url.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -257,8 +257,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val (branchName, path) = repository.splitPath(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.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
JGitUtil.getCommitLog(git, branchName, page, 30, path) match {
|
JGitUtil.getCommitLog(git, branchName, page, 30, path) match {
|
||||||
case Right((logs, hasNext)) =>
|
case Right((logs, hasNext)) =>
|
||||||
html.commits(
|
html.commits(
|
||||||
@@ -273,8 +272,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
getCommitStatusWithSummary(repository.owner, repository.name, commit.id)
|
getCommitStatusWithSummary(repository.owner, repository.name, commit.id)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.splitWith {
|
.splitWith { case ((commit1, _, _), (commit2, _, _)) =>
|
||||||
case ((commit1, _, _), (commit2, _, _)) =>
|
|
||||||
view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
||||||
},
|
},
|
||||||
page,
|
page,
|
||||||
@@ -287,8 +285,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/new/*")(writableUsersOnly { repository =>
|
get("/:owner/:repository/new/*")(writableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
||||||
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
||||||
.needStatusCheck(loginAccount.userName)
|
.needStatusCheck(loginAccount.userName)
|
||||||
@@ -310,8 +307,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/upload/*")(writableUsersOnly { repository =>
|
get("/:owner/:repository/upload/*")(writableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
||||||
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
||||||
.needStatusCheck(loginAccount.userName)
|
.needStatusCheck(loginAccount.userName)
|
||||||
@@ -329,60 +325,18 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/upload", uploadForm)(writableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/upload", uploadForm)(writableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
|
||||||
loginAccount =>
|
|
||||||
val files = form.uploadFiles
|
|
||||||
.split("\n")
|
|
||||||
.map { line =>
|
|
||||||
val i = line.indexOf(':')
|
|
||||||
CommitFile(line.substring(0, i).trim, line.substring(i + 1).trim)
|
|
||||||
}
|
|
||||||
.toSeq
|
|
||||||
|
|
||||||
val newFiles = files.map { file =>
|
|
||||||
file.copy(name = if (form.path.length == 0) file.name else s"${form.path}/${file.name}")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (form.newBranch) {
|
|
||||||
val newBranchName = createNewBranchForPullRequest(repository, form.branch, loginAccount)
|
|
||||||
val objectId = _commit(newBranchName, newFiles, loginAccount)
|
|
||||||
val issueId =
|
|
||||||
createIssueAndPullRequest(
|
|
||||||
repository,
|
|
||||||
form.branch,
|
|
||||||
newBranchName,
|
|
||||||
form.commit,
|
|
||||||
objectId.name,
|
|
||||||
form.message,
|
|
||||||
loginAccount
|
|
||||||
)
|
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
|
||||||
} else {
|
|
||||||
_commit(form.branch, newFiles, loginAccount)
|
|
||||||
if (form.path.length == 0) {
|
|
||||||
redirect(s"/${repository.owner}/${repository.name}/tree/${form.branch}")
|
|
||||||
} else {
|
|
||||||
redirect(s"/${repository.owner}/${repository.name}/tree/${form.branch}/${form.path}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def _commit(
|
def _commit(
|
||||||
branchName: String,
|
branchName: String,
|
||||||
//files: Seq[CommitFile],
|
|
||||||
newFiles: Seq[CommitFile],
|
newFiles: Seq[CommitFile],
|
||||||
loginAccount: Account
|
loginAccount: Account
|
||||||
): ObjectId = {
|
): Either[String, ObjectId] = {
|
||||||
commitFiles(
|
commitFiles(
|
||||||
repository = repository,
|
repository = repository,
|
||||||
branch = branchName,
|
branch = branchName,
|
||||||
//path = form.path,
|
|
||||||
//files = files.toIndexedSeq,
|
|
||||||
message = form.message.getOrElse("Add files via upload"),
|
message = form.message.getOrElse("Add files via upload"),
|
||||||
loginAccount = loginAccount,
|
loginAccount = loginAccount,
|
||||||
settings = context.settings
|
settings = context.settings
|
||||||
) {
|
) { case (git, headTip, builder, inserter) =>
|
||||||
case (git, headTip, builder, inserter) =>
|
|
||||||
JGitUtil.processTree(git, headTip) { (path, tree) =>
|
JGitUtil.processTree(git, headTip) { (path, tree) =>
|
||||||
if (!newFiles.exists(_.name.contains(path))) {
|
if (!newFiles.exists(_.name.contains(path))) {
|
||||||
builder.add(JGitUtil.createDirCacheEntry(path, tree.getEntryFileMode, tree.getEntryObjectId))
|
builder.add(JGitUtil.createDirCacheEntry(path, tree.getEntryFileMode, tree.getEntryObjectId))
|
||||||
@@ -399,22 +353,64 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
|
val files = form.uploadFiles
|
||||||
|
.split("\n")
|
||||||
|
.map { line =>
|
||||||
|
val i = line.indexOf(':')
|
||||||
|
CommitFile(line.substring(0, i).trim, line.substring(i + 1).trim)
|
||||||
|
}
|
||||||
|
.toSeq
|
||||||
|
|
||||||
|
val newFiles = files.map { file =>
|
||||||
|
file.copy(name = if (form.path.length == 0) file.name else s"${form.path}/${file.name}")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (form.newBranch) {
|
||||||
|
val newBranchName = createNewBranchForPullRequest(repository, form.branch, loginAccount)
|
||||||
|
_commit(newBranchName, newFiles, loginAccount) match {
|
||||||
|
case Right(objectId) =>
|
||||||
|
val issueId =
|
||||||
|
createIssueAndPullRequest(
|
||||||
|
repository,
|
||||||
|
form.branch,
|
||||||
|
newBranchName,
|
||||||
|
form.commit,
|
||||||
|
objectId.name,
|
||||||
|
form.message,
|
||||||
|
loginAccount
|
||||||
|
)
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
|
case Left(error) => Forbidden(gitbucket.core.html.error(error))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_commit(form.branch, newFiles, loginAccount) match {
|
||||||
|
case Right(_) =>
|
||||||
|
if (form.path.length == 0) {
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/tree/${encodeRefName(form.branch)}")
|
||||||
|
} else {
|
||||||
|
redirect(
|
||||||
|
s"/${repository.owner}/${repository.name}/tree/${encodeRefName(form.branch)}/${encodeRefName(form.path)}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case Left(error) => Forbidden(gitbucket.core.html.error(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/edit/*")(writableUsersOnly { repository =>
|
get("/:owner/:repository/edit/*")(writableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
||||||
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
||||||
.needStatusCheck(loginAccount.userName)
|
.needStatusCheck(loginAccount.userName)
|
||||||
|
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(branch))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(branch))
|
||||||
|
|
||||||
getPathObjectId(git, path, revCommit)
|
getPathObjectId(git, path, revCommit)
|
||||||
.map {
|
.map { objectId =>
|
||||||
objectId =>
|
|
||||||
val paths = path.split("/")
|
val paths = path.split("/")
|
||||||
val info = EditorConfigUtil.getEditorConfigInfo(git, branch, path)
|
val info = EditorConfigUtil.getEditorConfigInfo(git, branch, path)
|
||||||
|
|
||||||
@@ -437,8 +433,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
get("/:owner/:repository/remove/*")(writableUsersOnly { repository =>
|
get("/:owner/:repository/remove/*")(writableUsersOnly { repository =>
|
||||||
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(branch))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(branch))
|
||||||
|
|
||||||
getPathObjectId(git, path, revCommit).map { objectId =>
|
getPathObjectId(git, path, revCommit).map { objectId =>
|
||||||
@@ -456,32 +451,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/create", editorForm)(writableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/create", editorForm)(writableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
def _commit(branchName: String, loginAccount: Account): Either[String, ObjectId] = {
|
||||||
loginAccount =>
|
|
||||||
if (form.newBranch) {
|
|
||||||
val newBranchName = createNewBranchForPullRequest(repository, form.branch, loginAccount)
|
|
||||||
val objectId = _commit(newBranchName, loginAccount)
|
|
||||||
val issueId =
|
|
||||||
createIssueAndPullRequest(
|
|
||||||
repository,
|
|
||||||
form.branch,
|
|
||||||
newBranchName,
|
|
||||||
form.commit,
|
|
||||||
objectId.name,
|
|
||||||
form.message,
|
|
||||||
loginAccount
|
|
||||||
)
|
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
|
||||||
} else {
|
|
||||||
_commit(form.branch, loginAccount)
|
|
||||||
redirect(
|
|
||||||
s"/${repository.owner}/${repository.name}/blob/${form.branch}/${if (form.path.length == 0) urlEncode(form.newFileName)
|
|
||||||
else s"${form.path}/${urlEncode(form.newFileName)}"}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def _commit(branchName: String, loginAccount: Account): ObjectId = {
|
|
||||||
commitFile(
|
commitFile(
|
||||||
repository = repository,
|
repository = repository,
|
||||||
branch = branchName,
|
branch = branchName,
|
||||||
@@ -494,16 +464,14 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
commit = form.commit,
|
commit = form.commit,
|
||||||
loginAccount = loginAccount,
|
loginAccount = loginAccount,
|
||||||
settings = context.settings
|
settings = context.settings
|
||||||
)._1
|
).map(_._1)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
post("/:owner/:repository/update", editorForm)(writableUsersOnly { (form, repository) =>
|
context.withLoginAccount { loginAccount =>
|
||||||
context.withLoginAccount {
|
|
||||||
loginAccount =>
|
|
||||||
if (form.newBranch) {
|
if (form.newBranch) {
|
||||||
val newBranchName = createNewBranchForPullRequest(repository, form.branch, loginAccount)
|
val newBranchName = createNewBranchForPullRequest(repository, form.branch, loginAccount)
|
||||||
val objectId = _commit(newBranchName, loginAccount)
|
_commit(newBranchName, loginAccount) match {
|
||||||
|
case Right(objectId) =>
|
||||||
val issueId =
|
val issueId =
|
||||||
createIssueAndPullRequest(
|
createIssueAndPullRequest(
|
||||||
repository,
|
repository,
|
||||||
@@ -515,16 +483,28 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
loginAccount
|
loginAccount
|
||||||
)
|
)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
|
case Left(error) => Forbidden(gitbucket.core.html.error(error))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_commit(form.branch, loginAccount)
|
_commit(form.branch, loginAccount) match {
|
||||||
|
case Right(_) =>
|
||||||
|
if (form.path.length == 0) {
|
||||||
redirect(
|
redirect(
|
||||||
s"/${repository.owner}/${repository.name}/blob/${urlEncode(form.branch)}/${if (form.path.length == 0) urlEncode(form.newFileName)
|
s"/${repository.owner}/${repository.name}/blob/${encodeRefName(form.branch)}/${urlEncode(form.newFileName)}"
|
||||||
else s"${form.path}/${urlEncode(form.newFileName)}"}"
|
)
|
||||||
|
} else {
|
||||||
|
redirect(
|
||||||
|
s"/${repository.owner}/${repository.name}/blob/${encodeRefName(form.branch)}/${encodeRefName(form.path)}/${urlEncode(form.newFileName)}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
case Left(error) => Forbidden(gitbucket.core.html.error(error))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
def _commit(branchName: String, loginAccount: Account): ObjectId = {
|
post("/:owner/:repository/update", editorForm)(writableUsersOnly { (form, repository) =>
|
||||||
|
def _commit(branchName: String, loginAccount: Account): Either[String, ObjectId] = {
|
||||||
commitFile(
|
commitFile(
|
||||||
repository = repository,
|
repository = repository,
|
||||||
branch = branchName,
|
branch = branchName,
|
||||||
@@ -541,16 +521,14 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
commit = form.commit,
|
commit = form.commit,
|
||||||
loginAccount = loginAccount,
|
loginAccount = loginAccount,
|
||||||
settings = context.settings
|
settings = context.settings
|
||||||
)._1
|
).map(_._1)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
post("/:owner/:repository/remove", deleteForm)(writableUsersOnly { (form, repository) =>
|
context.withLoginAccount { loginAccount =>
|
||||||
context.withLoginAccount {
|
|
||||||
loginAccount =>
|
|
||||||
if (form.newBranch) {
|
if (form.newBranch) {
|
||||||
val newBranchName = createNewBranchForPullRequest(repository, form.branch, loginAccount)
|
val newBranchName = createNewBranchForPullRequest(repository, form.branch, loginAccount)
|
||||||
val objectId = _commit(newBranchName, loginAccount)
|
_commit(newBranchName, loginAccount) match {
|
||||||
|
case Right(objectId) =>
|
||||||
val issueId =
|
val issueId =
|
||||||
createIssueAndPullRequest(
|
createIssueAndPullRequest(
|
||||||
repository,
|
repository,
|
||||||
@@ -562,16 +540,28 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
loginAccount
|
loginAccount
|
||||||
)
|
)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
|
case Left(error) => Forbidden(gitbucket.core.html.error(error))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_commit(form.branch, loginAccount)
|
_commit(form.branch, loginAccount) match {
|
||||||
|
case Right(_) =>
|
||||||
|
if (form.path.length == 0) {
|
||||||
redirect(
|
redirect(
|
||||||
s"/${repository.owner}/${repository.name}/tree/${form.branch}${if (form.path.length == 0) ""
|
s"/${repository.owner}/${repository.name}/blob/${encodeRefName(form.branch)}/${urlEncode(form.newFileName)}"
|
||||||
else "/" + form.path}"
|
)
|
||||||
|
} else {
|
||||||
|
redirect(
|
||||||
|
s"/${repository.owner}/${repository.name}/blob/${encodeRefName(form.branch)}/${encodeRefName(form.path)}/${urlEncode(form.newFileName)}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
case Left(error) => Forbidden(gitbucket.core.html.error(error))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
def _commit(branchName: String, loginAccount: Account): ObjectId = {
|
post("/:owner/:repository/remove", deleteForm)(writableUsersOnly { (form, repository) =>
|
||||||
|
def _commit(branchName: String, loginAccount: Account): Either[String, ObjectId] = {
|
||||||
commitFile(
|
commitFile(
|
||||||
repository = repository,
|
repository = repository,
|
||||||
branch = branchName,
|
branch = branchName,
|
||||||
@@ -584,7 +574,40 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
commit = form.commit,
|
commit = form.commit,
|
||||||
loginAccount = loginAccount,
|
loginAccount = loginAccount,
|
||||||
settings = context.settings
|
settings = context.settings
|
||||||
)._1
|
).map(_._1)
|
||||||
|
}
|
||||||
|
|
||||||
|
context.withLoginAccount { loginAccount =>
|
||||||
|
if (form.newBranch) {
|
||||||
|
val newBranchName = createNewBranchForPullRequest(repository, form.branch, loginAccount)
|
||||||
|
_commit(newBranchName, loginAccount) match {
|
||||||
|
case Right(objectId) =>
|
||||||
|
val issueId =
|
||||||
|
createIssueAndPullRequest(
|
||||||
|
repository,
|
||||||
|
form.branch,
|
||||||
|
newBranchName,
|
||||||
|
form.commit,
|
||||||
|
objectId.name,
|
||||||
|
form.message,
|
||||||
|
loginAccount
|
||||||
|
)
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
|
case Left(error) => Forbidden(gitbucket.core.html.error(error))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_commit(form.branch, loginAccount) match {
|
||||||
|
case Right(_) =>
|
||||||
|
if (form.path.isEmpty) {
|
||||||
|
redirect(s"/${repository.owner}/${repository.name}/tree/${encodeRefName(form.branch)}")
|
||||||
|
} else {
|
||||||
|
redirect(
|
||||||
|
s"/${repository.owner}/${repository.name}/tree/${encodeRefName(form.branch)}/${encodeRefName(form.path)}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case Left(error) => Forbidden(gitbucket.core.html.error(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -640,7 +663,6 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
loginUser = loginAccount.userName,
|
loginUser = loginAccount.userName,
|
||||||
title = requestBranch,
|
title = requestBranch,
|
||||||
content = commitMessage,
|
content = commitMessage,
|
||||||
assignedUserName = None,
|
|
||||||
milestoneId = None,
|
milestoneId = None,
|
||||||
priorityId = None,
|
priorityId = None,
|
||||||
isPullRequest = true
|
isPullRequest = true
|
||||||
@@ -679,11 +701,9 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val (id, path) = repository.splitPath(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
|
||||||
val highlighterTheme = getSyntaxHighlighterTheme()
|
val highlighterTheme = getSyntaxHighlighterTheme()
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||||
getPathObjectId(git, path, revCommit).map {
|
getPathObjectId(git, path, revCommit).map { objectId =>
|
||||||
objectId =>
|
|
||||||
if (raw) {
|
if (raw) {
|
||||||
// Download (This route is left for backward compatibility)
|
// Download (This route is left for backward compatibility)
|
||||||
responseRawFile(git, objectId, path, repository)
|
responseRawFile(git, objectId, path, repository)
|
||||||
@@ -731,8 +751,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
ajaxGet("/:owner/:repository/get-blame/*")(referrersOnly { repository =>
|
ajaxGet("/:owner/:repository/get-blame/*")(referrersOnly { repository =>
|
||||||
val (id, path) = repository.splitPath(multiParams("splat").head)
|
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
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
|
||||||
Serialization.write(
|
Serialization.write(
|
||||||
Map(
|
Map(
|
||||||
@@ -740,8 +759,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
"id" -> id,
|
"id" -> id,
|
||||||
"path" -> path,
|
"path" -> path,
|
||||||
"last" -> last,
|
"last" -> last,
|
||||||
"blame" -> JGitUtil.getBlame(git, id, path).map {
|
"blame" -> JGitUtil.getBlame(git, id, path).map { blame =>
|
||||||
blame =>
|
|
||||||
Map(
|
Map(
|
||||||
"id" -> blame.id,
|
"id" -> blame.id,
|
||||||
"author" -> view.helpers.user(blame.authorName, blame.authorEmailAddress).toString,
|
"author" -> view.helpers.user(blame.authorName, blame.authorEmailAddress).toString,
|
||||||
@@ -766,10 +784,17 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val id = params("id")
|
val id = params("id")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||||
val diffs = JGitUtil.getDiffs(git, None, id, true, false)
|
val diffs = JGitUtil.getDiffs(
|
||||||
|
git = git,
|
||||||
|
from = None,
|
||||||
|
to = id,
|
||||||
|
fetchContent = true,
|
||||||
|
makePatch = false,
|
||||||
|
maxFiles = context.settings.repositoryViewer.maxDiffFiles,
|
||||||
|
maxLines = context.settings.repositoryViewer.maxDiffLines
|
||||||
|
)
|
||||||
val oldCommitId = JGitUtil.getParentCommitId(git, id)
|
val oldCommitId = JGitUtil.getParentCommitId(git, id)
|
||||||
|
|
||||||
html.commit(
|
html.commit(
|
||||||
@@ -855,8 +880,7 @@ 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) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
val id = params("id")
|
val id = params("id")
|
||||||
val commentId = createCommitComment(
|
val commentId = createCommitComment(
|
||||||
repository,
|
repository,
|
||||||
@@ -877,10 +901,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/commit_comments/_data/:id")(readableUsersOnly { repository =>
|
ajaxGet("/:owner/:repository/commit_comments/_data/:id")(readableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
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, loginAccount)) {
|
if (isEditable(x.userName, x.repositoryName, x.commentedUserName, loginAccount)) {
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
|
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
|
||||||
@@ -908,8 +930,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/commit_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/commit_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
getCommitComment(repository.owner, repository.name, params("id")).map { comment =>
|
getCommitComment(repository.owner, repository.name, params("id")).map { comment =>
|
||||||
if (isEditable(repository.owner, repository.name, comment.commentedUserName, loginAccount)) {
|
if (isEditable(repository.owner, repository.name, comment.commentedUserName, loginAccount)) {
|
||||||
updateCommitComment(comment.commentId, form.content)
|
updateCommitComment(comment.commentId, form.content)
|
||||||
@@ -934,8 +955,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
get("/:owner/:repository/branches")(referrersOnly { repository =>
|
get("/:owner/:repository/branches")(referrersOnly { repository =>
|
||||||
val protectedBranches = getProtectedBranchList(repository.owner, repository.name).toSet
|
val protectedBranches = getProtectedBranchList(repository.owner, repository.name).toSet
|
||||||
val branches = Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
val branches = Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
JGitUtil
|
JGitUtil
|
||||||
.getBranches(
|
.getBranches(
|
||||||
git = git,
|
git = git,
|
||||||
@@ -943,8 +963,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
origin = repository.repository.originUserName.isEmpty
|
origin = repository.repository.originUserName.isEmpty
|
||||||
)
|
)
|
||||||
.sortBy(branch => (branch.mergeInfo.isEmpty, branch.commitTime))
|
.sortBy(branch => (branch.mergeInfo.isEmpty, branch.commitTime))
|
||||||
.map(
|
.map(branch =>
|
||||||
branch =>
|
|
||||||
(
|
(
|
||||||
branch,
|
branch,
|
||||||
getPullRequestByRequestCommit(
|
getPullRequestByRequestCommit(
|
||||||
@@ -993,8 +1012,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
post("/:owner/:repository/branches")(writableUsersOnly { 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.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
JGitUtil.createBranch(git, fromBranchName, newBranchName) match {
|
JGitUtil.createBranch(git, fromBranchName, newBranchName) match {
|
||||||
case Right(message) =>
|
case Right(message) =>
|
||||||
flash.update("info", message)
|
flash.update("info", message)
|
||||||
@@ -1048,8 +1066,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
* Deletes branch.
|
* Deletes branch.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/delete/*")(writableUsersOnly { repository =>
|
get("/:owner/:repository/delete/*")(writableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
val branchName = multiParams("splat").head
|
val branchName = multiParams("splat").head
|
||||||
if (repository.repository.defaultBranch != branchName) {
|
if (repository.repository.defaultBranch != branchName) {
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
@@ -1144,8 +1161,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
html.guide(repository, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
html.guide(repository, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
} else {
|
} else {
|
||||||
// get specified commit
|
// get specified commit
|
||||||
JGitUtil.getDefaultBranch(git, repository, revstr).map {
|
JGitUtil.getDefaultBranch(git, repository, revstr).map { case (objectId, revision) =>
|
||||||
case (objectId, revision) =>
|
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, objectId)
|
val revCommit = JGitUtil.getRevCommitFromId(git, objectId)
|
||||||
val lastModifiedCommit =
|
val lastModifiedCommit =
|
||||||
if (path == ".") revCommit else JGitUtil.getLastModifiedCommit(git, revCommit, path)
|
if (path == ".") revCommit else JGitUtil.getLastModifiedCommit(git, revCommit, path)
|
||||||
@@ -1203,8 +1219,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
repository: RepositoryService.RepositoryInfo,
|
repository: RepositoryService.RepositoryInfo,
|
||||||
path: String
|
path: String
|
||||||
) = {
|
) = {
|
||||||
def archive(revision: String, archiveFormat: String, archive: ArchiveOutputStream)(
|
def archive[A <: ArchiveEntry](revision: String, archiveFormat: String, archive: ArchiveOutputStream[A])(
|
||||||
entryCreator: (String, Long, java.util.Date, Int) => ArchiveEntry
|
entryCreator: (String, Long, java.util.Date, Int) => A
|
||||||
): Unit = {
|
): Unit = {
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
val oid = git.getRepository.resolve(revision)
|
val oid = git.getRepository.resolve(revision)
|
||||||
@@ -1246,7 +1262,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val entry: ArchiveEntry = entryCreator(entryPath, size, date, mode)
|
val entry: A = entryCreator(entryPath, size, date, mode)
|
||||||
archive.putArchiveEntry(entry)
|
archive.putArchiveEntry(entry)
|
||||||
Using.resource(new FileInputStream(tempFile)) { in =>
|
Using.resource(new FileInputStream(tempFile)) { in =>
|
||||||
IOUtils.copy(in, archive)
|
IOUtils.copy(in, archive)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
|
|
||||||
import gitbucket.core.admin.html
|
import gitbucket.core.admin.html
|
||||||
import gitbucket.core.plugin.PluginRegistry
|
import gitbucket.core.plugin.PluginRegistry
|
||||||
import gitbucket.core.service.SystemSettingsService._
|
import gitbucket.core.service.SystemSettingsService._
|
||||||
@@ -35,7 +34,9 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
private val form = mapping(
|
private val form = mapping(
|
||||||
"baseUrl" -> trim(label("Base URL", optional(text()))),
|
"baseUrl" -> trim(label("Base URL", optional(text()))),
|
||||||
"information" -> trim(label("Information", optional(text()))),
|
"information" -> trim(label("Information", optional(text()))),
|
||||||
|
"basicBehavior" -> mapping(
|
||||||
"allowAccountRegistration" -> trim(label("Account registration", boolean())),
|
"allowAccountRegistration" -> trim(label("Account registration", boolean())),
|
||||||
|
"allowResetPassword" -> trim(label("Reset password", boolean())),
|
||||||
"allowAnonymousAccess" -> trim(label("Anonymous access", boolean())),
|
"allowAnonymousAccess" -> trim(label("Anonymous access", boolean())),
|
||||||
"isCreateRepoOptionPublic" -> trim(label("Default visibility of new repository", boolean())),
|
"isCreateRepoOptionPublic" -> trim(label("Default visibility of new repository", boolean())),
|
||||||
"repositoryOperation" -> mapping(
|
"repositoryOperation" -> mapping(
|
||||||
@@ -48,10 +49,21 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
"gravatar" -> trim(label("Gravatar", boolean())),
|
"gravatar" -> trim(label("Gravatar", boolean())),
|
||||||
"notification" -> trim(label("Notification", boolean())),
|
"notification" -> trim(label("Notification", boolean())),
|
||||||
"limitVisibleRepositories" -> trim(label("limitVisibleRepositories", boolean())),
|
"limitVisibleRepositories" -> trim(label("limitVisibleRepositories", boolean())),
|
||||||
|
)(BasicBehavior.apply),
|
||||||
"ssh" -> mapping(
|
"ssh" -> mapping(
|
||||||
"enabled" -> trim(label("SSH access", boolean())),
|
"enabled" -> trim(label("SSH access", boolean())),
|
||||||
"host" -> trim(label("SSH host", optional(text()))),
|
"bindAddress" -> mapping(
|
||||||
"port" -> trim(label("SSH port", optional(number())))
|
"host" -> trim(label("Bind SSH host", optional(text()))),
|
||||||
|
"port" -> trim(label("Bind SSH port", optional(number()))),
|
||||||
|
)((hostOption, portOption) =>
|
||||||
|
hostOption.map(h => SshAddress(h, portOption.getOrElse(DefaultSshPort), GenericSshUser))
|
||||||
|
),
|
||||||
|
"publicAddress" -> mapping(
|
||||||
|
"host" -> trim(label("Public SSH host", optional(text()))),
|
||||||
|
"port" -> trim(label("Public SSH port", optional(number()))),
|
||||||
|
)((hostOption, portOption) =>
|
||||||
|
hostOption.map(h => SshAddress(h, portOption.getOrElse(PublicSshPort), GenericSshUser))
|
||||||
|
),
|
||||||
)(Ssh.apply),
|
)(Ssh.apply),
|
||||||
"useSMTP" -> trim(label("SMTP", boolean())),
|
"useSMTP" -> trim(label("SMTP", boolean())),
|
||||||
"smtp" -> optionalIfNotChecked(
|
"smtp" -> optionalIfNotChecked(
|
||||||
@@ -109,15 +121,18 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
"largeTimeout" -> trim(label("Timeout for large file", long(required)))
|
"largeTimeout" -> trim(label("Timeout for large file", long(required)))
|
||||||
)(Upload.apply),
|
)(Upload.apply),
|
||||||
"repositoryViewer" -> mapping(
|
"repositoryViewer" -> mapping(
|
||||||
"maxFiles" -> trim(label("Max files", number(required)))
|
"maxFiles" -> trim(label("Max files", number(required))),
|
||||||
)(RepositoryViewerSettings.apply)
|
"maxDiffFiles" -> trim(label("Max diff files", number(required))),
|
||||||
|
"maxDiffLines" -> trim(label("Max diff lines", number(required)))
|
||||||
|
)(RepositoryViewerSettings.apply),
|
||||||
|
"defaultBranch" -> trim(label("Default branch", text(required)))
|
||||||
)(SystemSettings.apply).verifying { settings =>
|
)(SystemSettings.apply).verifying { settings =>
|
||||||
Vector(
|
Vector(
|
||||||
if (settings.ssh.enabled && settings.baseUrl.isEmpty) {
|
if (settings.ssh.enabled && settings.baseUrl.isEmpty) {
|
||||||
Some("baseUrl" -> "Base URL is required if SSH access is enabled.")
|
Some("baseUrl" -> "Base URL is required if SSH access is enabled.")
|
||||||
} else None,
|
} else None,
|
||||||
if (settings.ssh.enabled && settings.ssh.sshHost.isEmpty) {
|
if (settings.ssh.enabled && settings.ssh.bindAddress.isEmpty) {
|
||||||
Some("sshHost" -> "SSH host is required if SSH access is enabled.")
|
Some("ssh.bindAddress.host" -> "SSH bind host is required if SSH access is enabled.")
|
||||||
} else None
|
} else None
|
||||||
).flatten
|
).flatten
|
||||||
}
|
}
|
||||||
@@ -236,8 +251,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
val conn = request2Session(request).conn
|
val conn = request2Session(request).conn
|
||||||
val meta = conn.getMetaData
|
val meta = conn.getMetaData
|
||||||
val tables = ListBuffer[Table]()
|
val tables = ListBuffer[Table]()
|
||||||
Using.resource(meta.getTables(null, "%", "%", Array("TABLE", "VIEW"))) {
|
Using.resource(meta.getTables(null, "%", "%", Array("TABLE", "VIEW"))) { rs =>
|
||||||
rs =>
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
val tableName = rs.getString("TABLE_NAME")
|
val tableName = rs.getString("TABLE_NAME")
|
||||||
|
|
||||||
@@ -270,11 +284,9 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
if (trimmedQuery.nonEmpty) {
|
if (trimmedQuery.nonEmpty) {
|
||||||
try {
|
try {
|
||||||
val conn = request2Session(request).conn
|
val conn = request2Session(request).conn
|
||||||
Using.resource(conn.prepareStatement(query)) {
|
Using.resource(conn.prepareStatement(query)) { stmt =>
|
||||||
stmt =>
|
|
||||||
if (trimmedQuery.toUpperCase.startsWith("SELECT")) {
|
if (trimmedQuery.toUpperCase.startsWith("SELECT")) {
|
||||||
Using.resource(stmt.executeQuery()) {
|
Using.resource(stmt.executeQuery()) { rs =>
|
||||||
rs =>
|
|
||||||
val meta = rs.getMetaData
|
val meta = rs.getMetaData
|
||||||
val columns = for (i <- 1 to meta.getColumnCount) yield {
|
val columns = for (i <- 1 to meta.getColumnCount) yield {
|
||||||
meta.getColumnName(i)
|
meta.getColumnName(i)
|
||||||
@@ -308,12 +320,15 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
post("/admin/system", form)(adminOnly { form =>
|
post("/admin/system", form)(adminOnly { form =>
|
||||||
saveSystemSettings(form)
|
saveSystemSettings(form)
|
||||||
|
|
||||||
if (form.sshAddress != context.settings.sshAddress) {
|
if (
|
||||||
|
form.ssh.bindAddress != context.settings.sshBindAddress || form.ssh.publicAddress != context.settings.sshPublicAddress
|
||||||
|
) {
|
||||||
SshServer.stop()
|
SshServer.stop()
|
||||||
for {
|
for {
|
||||||
sshAddress <- form.sshAddress
|
bindAddress <- form.ssh.bindAddress
|
||||||
|
publicAddress <- form.ssh.publicAddress.orElse(form.ssh.bindAddress)
|
||||||
baseUrl <- form.baseUrl
|
baseUrl <- form.baseUrl
|
||||||
} SshServer.start(sshAddress, baseUrl)
|
} SshServer.start(bindAddress, publicAddress, baseUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
flash.update("info", "System settings has been updated.")
|
flash.update("info", "System settings has been updated.")
|
||||||
@@ -322,7 +337,12 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
post("/admin/system/sendmail", sendMailForm)(adminOnly { form =>
|
post("/admin/system/sendmail", sendMailForm)(adminOnly { form =>
|
||||||
try {
|
try {
|
||||||
new Mailer(context.settings.copy(smtp = Some(form.smtp), notification = true)).send(
|
new Mailer(
|
||||||
|
context.settings.copy(
|
||||||
|
smtp = Some(form.smtp),
|
||||||
|
basicBehavior = context.settings.basicBehavior.copy(notification = true)
|
||||||
|
)
|
||||||
|
).send(
|
||||||
to = form.testAddress,
|
to = form.testAddress,
|
||||||
subject = "Test message from GitBucket",
|
subject = "Test message from GitBucket",
|
||||||
textMsg = "This is a test message from GitBucket.",
|
textMsg = "This is a test message from GitBucket.",
|
||||||
@@ -399,8 +419,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
post("/admin/users/:name/_edituser", editUserForm)(adminOnly { form =>
|
post("/admin/users/:name/_edituser", editUserForm)(adminOnly { form =>
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName, true).map {
|
getAccountByUserName(userName, true).map { account =>
|
||||||
account =>
|
|
||||||
if (account.isAdmin && (form.isRemoved || !form.isAdmin) && isLastAdministrator(account)) {
|
if (account.isAdmin && (form.isRemoved || !form.isAdmin) && isLastAdministrator(account)) {
|
||||||
flash.update("error", "Account can't be turned off because this is last one administrator.")
|
flash.update("error", "Account can't be turned off because this is last one administrator.")
|
||||||
redirect(s"/admin/users/${userName}/_edituser")
|
redirect(s"/admin/users/${userName}/_edituser")
|
||||||
@@ -477,8 +496,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
.toList
|
.toList
|
||||||
|
|
||||||
getAccountByUserName(groupName, true).map {
|
getAccountByUserName(groupName, true).map { account =>
|
||||||
account =>
|
|
||||||
updateGroup(groupName, form.description, form.url, form.isRemoved)
|
updateGroup(groupName, form.description, form.url, form.isRemoved)
|
||||||
|
|
||||||
if (form.isRemoved) {
|
if (form.isRemoved) {
|
||||||
@@ -531,7 +549,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
private def multiLineText(constraints: Constraint*): SingleValueType[Seq[String]] =
|
private def multiLineText(constraints: Constraint*): SingleValueType[Seq[String]] =
|
||||||
new SingleValueType[Seq[String]](constraints: _*) {
|
new SingleValueType[Seq[String]](constraints*) {
|
||||||
def convert(value: String, messages: Messages): Seq[String] = {
|
def convert(value: String, messages: Messages): Seq[String] = {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
Nil
|
Nil
|
||||||
@@ -544,9 +562,11 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
private def members: Constraint =
|
private def members: Constraint =
|
||||||
new Constraint() {
|
new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
||||||
if (value.split(",").exists {
|
if (
|
||||||
|
value.split(",").exists {
|
||||||
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
|
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
|
||||||
}) None
|
}
|
||||||
|
) None
|
||||||
else Some("Must select one manager at least.")
|
else Some("Must select one manager at least.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ trait ValidationSupport extends FormSupport { self: ServletBase with JacksonJson
|
|||||||
* Converts errors to JSON.
|
* Converts errors to JSON.
|
||||||
*/
|
*/
|
||||||
private def toJson(errors: Seq[(String, String)]): JObject =
|
private def toJson(errors: Seq[(String, String)]): JObject =
|
||||||
JObject(errors.map {
|
JObject(errors.map { case (key, value) =>
|
||||||
case (key, value) =>
|
|
||||||
JField(key, JString(value))
|
JField(key, JString(value))
|
||||||
}.toList)
|
}.toList)
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val newForm = mapping(
|
val newForm = mapping(
|
||||||
"pageName" -> trim(label("Page name", text(required, maxlength(40), pagename, unique))),
|
"pageName" -> trim(label("Page name", text(required, maxlength(40), pageName, unique))),
|
||||||
"content" -> trim(label("Content", text(required, conflictForNew))),
|
"content" -> trim(label("Content", text(required, conflictForNew))),
|
||||||
"message" -> trim(label("Message", optional(text()))),
|
"message" -> trim(label("Message", optional(text()))),
|
||||||
"currentPageName" -> trim(label("Current page name", text())),
|
"currentPageName" -> trim(label("Current page name", text())),
|
||||||
@@ -54,7 +54,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
)(WikiPageEditForm.apply)
|
)(WikiPageEditForm.apply)
|
||||||
|
|
||||||
val editForm = mapping(
|
val editForm = mapping(
|
||||||
"pageName" -> trim(label("Page name", text(required, maxlength(40), pagename))),
|
"pageName" -> trim(label("Page name", text(required, maxlength(40), pageName))),
|
||||||
"content" -> trim(label("Content", text(required, conflictForEdit))),
|
"content" -> trim(label("Content", text(required, conflictForEdit))),
|
||||||
"message" -> trim(label("Message", optional(text()))),
|
"message" -> trim(label("Message", optional(text()))),
|
||||||
"currentPageName" -> trim(label("Current page name", text(required))),
|
"currentPageName" -> trim(label("Current page name", text(required))),
|
||||||
@@ -62,46 +62,56 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
)(WikiPageEditForm.apply)
|
)(WikiPageEditForm.apply)
|
||||||
|
|
||||||
get("/:owner/:repository/wiki")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki")(referrersOnly { repository =>
|
||||||
getWikiPage(repository.owner, repository.name, "Home").map { page =>
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
|
getWikiPage(repository.owner, repository.name, "Home", branch).map { page =>
|
||||||
html.page(
|
html.page(
|
||||||
"Home",
|
"Home",
|
||||||
page,
|
page,
|
||||||
getWikiPageList(repository.owner, repository.name),
|
getWikiPageList(repository.owner, repository.name, branch),
|
||||||
repository,
|
repository,
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
getWikiPage(repository.owner, repository.name, "_Sidebar"),
|
getWikiPage(repository.owner, repository.name, "_Sidebar", branch),
|
||||||
getWikiPage(repository.owner, repository.name, "_Footer")
|
getWikiPage(repository.owner, repository.name, "_Footer", branch)
|
||||||
)
|
)
|
||||||
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/Home/_edit")
|
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/Home/_edit")
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/:page")(referrersOnly { repository =>
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
getWikiPage(repository.owner, repository.name, pageName).map { page =>
|
getWikiPage(repository.owner, repository.name, pageName, branch).map { page =>
|
||||||
html.page(
|
html.page(
|
||||||
pageName,
|
pageName,
|
||||||
page,
|
page,
|
||||||
getWikiPageList(repository.owner, repository.name),
|
getWikiPageList(repository.owner, repository.name, branch),
|
||||||
repository,
|
repository,
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
getWikiPage(repository.owner, repository.name, "_Sidebar"),
|
getWikiPage(repository.owner, repository.name, "_Sidebar", branch),
|
||||||
getWikiPage(repository.owner, repository.name, "_Footer")
|
getWikiPage(repository.owner, repository.name, "_Footer", branch)
|
||||||
)
|
)
|
||||||
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}/_edit")
|
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}/_edit")
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_history")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_history")(referrersOnly { repository =>
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
Using.resource(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getWikiRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
JGitUtil.getCommitLog(git, "master", path = pageName + ".md") match {
|
JGitUtil.getCommitLog(git, branch, path = pageName + ".md") match {
|
||||||
case Right((logs, hasNext)) => html.history(Some(pageName), logs, repository, isEditable(repository))
|
case Right((logs, hasNext)) => html.history(Some(pageName), logs, repository, isEditable(repository))
|
||||||
case Left(_) => NotFound()
|
case Left(_) => NotFound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
private def getWikiBranch(owner: String, repository: String): String = {
|
||||||
|
Using.resource(Git.open(Directory.getWikiRepositoryDir(owner, repository))) { git =>
|
||||||
|
git.getRepository.getBranch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_compare/:commitId")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_compare/:commitId")(referrersOnly { repository =>
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||||
@@ -111,7 +121,17 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
Some(pageName),
|
Some(pageName),
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
JGitUtil.getDiffs(git, Some(from), to, true, false).filter(_.newPath == pageName + ".md"),
|
JGitUtil
|
||||||
|
.getDiffs(
|
||||||
|
git = git,
|
||||||
|
from = Some(from),
|
||||||
|
to = to,
|
||||||
|
fetchContent = true,
|
||||||
|
makePatch = false,
|
||||||
|
maxFiles = context.settings.repositoryViewer.maxDiffFiles,
|
||||||
|
maxLines = context.settings.repositoryViewer.maxDiffLines
|
||||||
|
)
|
||||||
|
.filter(_.newPath == pageName + ".md"),
|
||||||
repository,
|
repository,
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
flash.get("info")
|
flash.get("info")
|
||||||
@@ -127,7 +147,15 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
None,
|
None,
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
JGitUtil.getDiffs(git, Some(from), to, true, false),
|
JGitUtil.getDiffs(
|
||||||
|
git = git,
|
||||||
|
from = Some(from),
|
||||||
|
to = to,
|
||||||
|
fetchContent = true,
|
||||||
|
makePatch = false,
|
||||||
|
maxFiles = context.settings.repositoryViewer.maxDiffFiles,
|
||||||
|
maxLines = context.settings.repositoryViewer.maxDiffLines
|
||||||
|
),
|
||||||
repository,
|
repository,
|
||||||
isEditable(repository),
|
isEditable(repository),
|
||||||
flash.get("info")
|
flash.get("info")
|
||||||
@@ -136,13 +164,13 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_revert/:commitId")(readableUsersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_revert/:commitId")(readableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||||
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
if (revertWikiPage(repository.owner, repository.name, from, to, loginAccount, Some(pageName))) {
|
if (revertWikiPage(repository.owner, repository.name, from, to, loginAccount, Some(pageName), branch)) {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}")
|
redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}")
|
||||||
} else {
|
} else {
|
||||||
flash.update("info", "This patch was not able to be reversed.")
|
flash.update("info", "This patch was not able to be reversed.")
|
||||||
@@ -155,12 +183,12 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/_revert/:commitId")(readableUsersOnly { repository =>
|
get("/:owner/:repository/wiki/_revert/:commitId")(readableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||||
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
if (revertWikiPage(repository.owner, repository.name, from, to, loginAccount, None)) {
|
if (revertWikiPage(repository.owner, repository.name, from, to, loginAccount, None, branch)) {
|
||||||
redirect(s"/${repository.owner}/${repository.name}/wiki")
|
redirect(s"/${repository.owner}/${repository.name}/wiki")
|
||||||
} else {
|
} else {
|
||||||
flash.update("info", "This patch was not able to be reversed.")
|
flash.update("info", "This patch was not able to be reversed.")
|
||||||
@@ -173,13 +201,14 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
get("/:owner/:repository/wiki/:page/_edit")(readableUsersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_edit")(readableUsersOnly { repository =>
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
html.edit(pageName, getWikiPage(repository.owner, repository.name, pageName), repository)
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
|
||||||
|
html.edit(pageName, getWikiPage(repository.owner, repository.name, pageName, branch), repository)
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/wiki/_edit", editForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/wiki/_edit", editForm)(readableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
saveWikiPage(
|
saveWikiPage(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
@@ -190,8 +219,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
loginAccount,
|
loginAccount,
|
||||||
form.message.getOrElse(""),
|
form.message.getOrElse(""),
|
||||||
Some(form.id)
|
Some(form.id)
|
||||||
).foreach {
|
).foreach { commitId =>
|
||||||
commitId =>
|
|
||||||
updateLastActivityDate(repository.owner, repository.name)
|
updateLastActivityDate(repository.owner, repository.name)
|
||||||
val wikiEditInfo =
|
val wikiEditInfo =
|
||||||
EditWikiPageInfo(repository.owner, repository.name, loginAccount.userName, form.pageName, commitId)
|
EditWikiPageInfo(repository.owner, repository.name, loginAccount.userName, form.pageName, commitId)
|
||||||
@@ -218,8 +246,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/wiki/_new", newForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/wiki/_new", newForm)(readableUsersOnly { (form, repository) =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
saveWikiPage(
|
saveWikiPage(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
@@ -230,8 +257,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
loginAccount,
|
loginAccount,
|
||||||
form.message.getOrElse(""),
|
form.message.getOrElse(""),
|
||||||
None
|
None
|
||||||
).foreach {
|
).foreach { commitId =>
|
||||||
commitId =>
|
|
||||||
updateLastActivityDate(repository.owner, repository.name)
|
updateLastActivityDate(repository.owner, repository.name)
|
||||||
val createWikiPageInfo =
|
val createWikiPageInfo =
|
||||||
CreateWikiPageInfo(repository.owner, repository.name, loginAccount.userName, form.pageName)
|
CreateWikiPageInfo(repository.owner, repository.name, loginAccount.userName, form.pageName)
|
||||||
@@ -253,8 +279,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_delete")(readableUsersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_delete")(readableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
if (isEditable(repository)) {
|
if (isEditable(repository)) {
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
deleteWikiPage(
|
deleteWikiPage(
|
||||||
@@ -280,7 +305,8 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/_pages")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/_pages")(referrersOnly { repository =>
|
||||||
html.pages(getWikiPageList(repository.owner, repository.name), repository, isEditable(repository))
|
val branch = getWikiBranch(repository.owner, repository.name)
|
||||||
|
html.pages(getWikiPageList(repository.owner, repository.name, branch), repository, isEditable(repository))
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/_history")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/_history")(referrersOnly { repository =>
|
||||||
@@ -309,13 +335,18 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
value: String,
|
value: String,
|
||||||
params: Map[String, Seq[String]],
|
params: Map[String, Seq[String]],
|
||||||
messages: Messages
|
messages: Messages
|
||||||
): Option[String] =
|
): Option[String] = {
|
||||||
getWikiPageList(params.value("owner"), params.value("repository"))
|
val owner = params.value("owner")
|
||||||
|
val repository = params.value("repository")
|
||||||
|
val branch = getWikiBranch(owner, repository)
|
||||||
|
|
||||||
|
getWikiPageList(owner, repository, branch)
|
||||||
.find(_ == value)
|
.find(_ == value)
|
||||||
.map(_ => "Page already exists.")
|
.map(_ => "Page already exists.")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private def pagename: Constraint = new Constraint() {
|
private def pageName: Constraint = new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
||||||
if (value.exists("\\/:*?\"<>|".contains(_))) {
|
if (value.exists("\\/:*?\"<>|".contains(_))) {
|
||||||
Some(s"${name} contains invalid character.")
|
Some(s"${name} contains invalid character.")
|
||||||
@@ -326,7 +357,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def notReservedPageName(value: String) = !(Array[String]("_Sidebar", "_Footer") contains value)
|
private def notReservedPageName(value: String): Boolean = !(Array[String]("_Sidebar", "_Footer") contains value)
|
||||||
|
|
||||||
private def conflictForNew: Constraint = new Constraint() {
|
private def conflictForNew: Constraint = new Constraint() {
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
override def validate(name: String, value: String, messages: Messages): Option[String] = {
|
||||||
@@ -344,7 +375,13 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def targetWikiPage = getWikiPage(params("owner"), params("repository"), params("pageName"))
|
private def targetWikiPage: Option[WikiService.WikiPageInfo] = {
|
||||||
|
val owner = params("owner")
|
||||||
|
val repository = params("repository")
|
||||||
|
val pageName = params("pageName")
|
||||||
|
val branch = getWikiBranch(owner, repository)
|
||||||
|
getWikiPage(owner, repository, pageName, branch)
|
||||||
|
}
|
||||||
|
|
||||||
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||||
repository.repository.options.wikiOption match {
|
repository.repository.options.wikiOption match {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package gitbucket.core.controller.api
|
package gitbucket.core.controller.api
|
||||||
import gitbucket.core.api.{ApiObject, ApiRef, CreateARef, JsonFormat, UpdateARef}
|
import gitbucket.core.api.{ApiError, ApiRef, CreateARef, JsonFormat, UpdateARef}
|
||||||
import gitbucket.core.controller.ControllerBase
|
import gitbucket.core.controller.ControllerBase
|
||||||
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
import gitbucket.core.util.Directory.getRepositoryDir
|
import gitbucket.core.util.Directory.getRepositoryDir
|
||||||
import gitbucket.core.util.ReferrerAuthenticator
|
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
|
import gitbucket.core.util.{ReferrerAuthenticator, RepositoryName, WritableUsersAuthenticator}
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.lib.ObjectId
|
import org.eclipse.jgit.lib.ObjectId
|
||||||
import org.eclipse.jgit.lib.RefUpdate.Result
|
import org.eclipse.jgit.lib.RefUpdate.Result
|
||||||
@@ -14,47 +15,38 @@ import scala.jdk.CollectionConverters._
|
|||||||
import scala.util.Using
|
import scala.util.Using
|
||||||
|
|
||||||
trait ApiGitReferenceControllerBase extends ControllerBase {
|
trait ApiGitReferenceControllerBase extends ControllerBase {
|
||||||
self: ReferrerAuthenticator =>
|
self: ReferrerAuthenticator with WritableUsersAuthenticator =>
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(classOf[ApiGitReferenceControllerBase])
|
private val logger = LoggerFactory.getLogger(classOf[ApiGitReferenceControllerBase])
|
||||||
|
|
||||||
|
get("/api/v3/repos/:owner/:repository/git/refs")(referrersOnly { repository =>
|
||||||
|
val result = Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
|
val refs = git
|
||||||
|
.getRepository()
|
||||||
|
.getRefDatabase()
|
||||||
|
.getRefsByPrefix("refs")
|
||||||
|
.asScala
|
||||||
|
|
||||||
|
refs.map(ApiRef.fromRef(RepositoryName(s"${repository.owner}/${repository.name}"), _))
|
||||||
|
}
|
||||||
|
JsonFormat(result)
|
||||||
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* i. Get a reference
|
* i. Get a reference
|
||||||
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#get-a-reference
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#get-a-reference
|
||||||
*/
|
*/
|
||||||
get("/api/v3/repos/:owner/:repository/git/ref/*")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/git/ref/*")(referrersOnly { repository =>
|
||||||
getRef()
|
val revstr = multiParams("splat").head
|
||||||
|
getRef(revstr, repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Some versions of GHE support this path
|
// Some versions of GHE support this path
|
||||||
get("/api/v3/repos/:owner/:repository/git/refs/*")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/git/refs/*")(referrersOnly { repository =>
|
||||||
logger.warn("git/refs/ endpoint may not be compatible with GitHub API v3. Consider using git/ref/ endpoint instead")
|
logger.warn("git/refs/ endpoint may not be compatible with GitHub API v3. Consider using git/ref/ endpoint instead")
|
||||||
getRef()
|
|
||||||
})
|
|
||||||
|
|
||||||
private def getRef() = {
|
|
||||||
val revstr = multiParams("splat").head
|
val revstr = multiParams("splat").head
|
||||||
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
|
getRef(revstr, repository)
|
||||||
val ref = git.getRepository().findRef(revstr)
|
|
||||||
|
|
||||||
if (ref != null) {
|
|
||||||
val sha = ref.getObjectId().name()
|
|
||||||
JsonFormat(ApiRef(revstr, ApiObject(sha)))
|
|
||||||
|
|
||||||
} else {
|
|
||||||
val refs = git
|
|
||||||
.getRepository()
|
|
||||||
.getRefDatabase()
|
|
||||||
.getRefsByPrefix("refs/")
|
|
||||||
.asScala
|
|
||||||
|
|
||||||
JsonFormat(refs.map { ref =>
|
|
||||||
val sha = ref.getObjectId().name()
|
|
||||||
ApiRef(revstr, ApiObject(sha))
|
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ii. Get all references
|
* ii. Get all references
|
||||||
@@ -65,17 +57,20 @@ trait ApiGitReferenceControllerBase extends ControllerBase {
|
|||||||
* iii. Create a reference
|
* iii. Create a reference
|
||||||
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#create-a-reference
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#create-a-reference
|
||||||
*/
|
*/
|
||||||
post("/api/v3/repos/:owner/:repository/git/refs")(referrersOnly { _ =>
|
post("/api/v3/repos/:owner/:repository/git/refs")(writableUsersOnly { repository =>
|
||||||
extractFromJsonBody[CreateARef].map {
|
extractFromJsonBody[CreateARef].map { data =>
|
||||||
data =>
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
|
|
||||||
val ref = git.getRepository.findRef(data.ref)
|
val ref = git.getRepository.findRef(data.ref)
|
||||||
if (ref == null) {
|
if (ref == null) {
|
||||||
val update = git.getRepository.updateRef(data.ref)
|
val update = git.getRepository.updateRef(data.ref)
|
||||||
update.setNewObjectId(ObjectId.fromString(data.sha))
|
update.setNewObjectId(ObjectId.fromString(data.sha))
|
||||||
val result = update.update()
|
val result = update.update()
|
||||||
result match {
|
result match {
|
||||||
case Result.NEW => JsonFormat(ApiRef(update.getName, ApiObject(update.getNewObjectId.getName)))
|
case Result.NEW =>
|
||||||
|
JsonFormat(
|
||||||
|
ApiRef
|
||||||
|
.fromRef(RepositoryName(repository.owner, repository.name), git.getRepository.findRef(data.ref))
|
||||||
|
)
|
||||||
case _ => UnprocessableEntity(result.name())
|
case _ => UnprocessableEntity(result.name())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -89,11 +84,10 @@ trait ApiGitReferenceControllerBase extends ControllerBase {
|
|||||||
* iv. Update a reference
|
* iv. Update a reference
|
||||||
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#update-a-reference
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#update-a-reference
|
||||||
*/
|
*/
|
||||||
patch("/api/v3/repos/:owner/:repository/git/refs/*")(referrersOnly { _ =>
|
patch("/api/v3/repos/:owner/:repository/git/refs/*")(writableUsersOnly { repository =>
|
||||||
val refName = multiParams("splat").mkString("/")
|
val refName = multiParams("splat").mkString("/")
|
||||||
extractFromJsonBody[UpdateARef].map {
|
extractFromJsonBody[UpdateARef].map { data =>
|
||||||
data =>
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
|
|
||||||
val ref = git.getRepository.findRef(refName)
|
val ref = git.getRepository.findRef(refName)
|
||||||
if (ref == null) {
|
if (ref == null) {
|
||||||
UnprocessableEntity("Ref does not exist.")
|
UnprocessableEntity("Ref does not exist.")
|
||||||
@@ -104,7 +98,7 @@ trait ApiGitReferenceControllerBase extends ControllerBase {
|
|||||||
val result = update.update()
|
val result = update.update()
|
||||||
result match {
|
result match {
|
||||||
case Result.FORCED | Result.FAST_FORWARD | Result.NO_CHANGE =>
|
case Result.FORCED | Result.FAST_FORWARD | Result.NO_CHANGE =>
|
||||||
JsonFormat(ApiRef(update.getName, ApiObject(update.getNewObjectId.getName)))
|
JsonFormat(ApiRef.fromRef(RepositoryName(repository), git.getRepository.findRef(refName)))
|
||||||
case _ => UnprocessableEntity(result.name())
|
case _ => UnprocessableEntity(result.name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +110,7 @@ trait ApiGitReferenceControllerBase extends ControllerBase {
|
|||||||
* v. Delete a reference
|
* v. Delete a reference
|
||||||
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#delete-a-reference
|
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#delete-a-reference
|
||||||
*/
|
*/
|
||||||
delete("/api/v3/repos/:owner/:repository/git/refs/*")(referrersOnly { _ =>
|
delete("/api/v3/repos/:owner/:repository/git/refs/*")(writableUsersOnly { _ =>
|
||||||
val refName = multiParams("splat").mkString("/")
|
val refName = multiParams("splat").mkString("/")
|
||||||
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
|
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
|
||||||
val ref = git.getRepository.findRef(refName)
|
val ref = git.getRepository.findRef(refName)
|
||||||
@@ -133,4 +127,34 @@ trait ApiGitReferenceControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
private def notFound(): ApiError = {
|
||||||
|
response.setStatus(404)
|
||||||
|
ApiError("Not Found")
|
||||||
|
}
|
||||||
|
|
||||||
|
protected def getRef(revstr: String, repository: RepositoryInfo): AnyRef = {
|
||||||
|
logger.debug(s"getRef: path '${revstr}'")
|
||||||
|
|
||||||
|
val name = RepositoryName(repository)
|
||||||
|
val result = JsonFormat(revstr match {
|
||||||
|
case "tags" => repository.tags.map(ApiRef.fromTag(name, _))
|
||||||
|
case x if x.startsWith("tags/") =>
|
||||||
|
val tagName = x.substring("tags/".length)
|
||||||
|
repository.tags.find(_.name == tagName) match {
|
||||||
|
case Some(tagInfo) => ApiRef.fromTag(name, tagInfo)
|
||||||
|
case None => notFound()
|
||||||
|
}
|
||||||
|
case other =>
|
||||||
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
|
git.getRepository().findRef(other) match {
|
||||||
|
case null => notFound()
|
||||||
|
case ref => ApiRef.fromRef(name, ref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
logger.debug(s"json result: $result")
|
||||||
|
result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ trait ApiIssueCommentControllerBase extends ControllerBase {
|
|||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
comments = getCommentsForApi(repository.owner, repository.name, issueId)
|
comments = getCommentsForApi(repository.owner, repository.name, issueId)
|
||||||
} yield {
|
} yield {
|
||||||
JsonFormat(comments.map {
|
JsonFormat(comments.map { case (issueComment, user, issue) =>
|
||||||
case (issueComment, user, issue) =>
|
|
||||||
ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(user), issue.isPullRequest)
|
ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(user), issue.isPullRequest)
|
||||||
})
|
})
|
||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
@@ -85,7 +84,7 @@ trait ApiIssueCommentControllerBase extends ControllerBase {
|
|||||||
* iv. Delete a comment
|
* iv. Delete a comment
|
||||||
* https://docs.github.com/en/rest/reference/issues#delete-an-issue-comment
|
* https://docs.github.com/en/rest/reference/issues#delete-an-issue-comment
|
||||||
*/
|
*/
|
||||||
delete("/api/v3/repos/:owner/:repo/issues/comments/:id")(readableUsersOnly { repository =>
|
delete("/api/v3/repos/:owner/:repository/issues/comments/:id")(readableUsersOnly { repository =>
|
||||||
val maybeDeleteResponse: Option[Either[ActionResult, Option[Int]]] =
|
val maybeDeleteResponse: Option[Either[ActionResult, Option[Int]]] =
|
||||||
for {
|
for {
|
||||||
commentId <- params("id").toIntOpt
|
commentId <- params("id").toIntOpt
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
val page = IssueSearchCondition.page(request)
|
val page = IssueSearchCondition.page(request)
|
||||||
// TODO: more api spec condition
|
// TODO: more api spec condition
|
||||||
val condition = IssueSearchCondition(request)
|
val condition = IssueSearchCondition(request)
|
||||||
val baseOwner = getAccountByUserName(repository.owner).get
|
// val baseOwner = getAccountByUserName(repository.owner).get
|
||||||
|
|
||||||
val issues: List[(Issue, Account, Option[Account])] =
|
val issues: List[(Issue, Account, List[Account])] =
|
||||||
searchIssueByApi(
|
searchIssueByApi(
|
||||||
condition = condition,
|
condition = condition,
|
||||||
offset = (page - 1) * PullRequestLimit,
|
offset = (page - 1) * PullRequestLimit,
|
||||||
@@ -39,13 +39,12 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
repos = repository.owner -> repository.name
|
repos = repository.owner -> repository.name
|
||||||
)
|
)
|
||||||
|
|
||||||
JsonFormat(issues.map {
|
JsonFormat(issues.map { case (issue, issueUser, assigneeUsers) =>
|
||||||
case (issue, issueUser, assignedUser) =>
|
|
||||||
ApiIssue(
|
ApiIssue(
|
||||||
issue = issue,
|
issue = issue,
|
||||||
repositoryName = RepositoryName(repository),
|
repositoryName = RepositoryName(repository),
|
||||||
user = ApiUser(issueUser),
|
user = ApiUser(issueUser),
|
||||||
assignee = assignedUser.map(ApiUser(_)),
|
assignees = assigneeUsers.map(ApiUser(_)),
|
||||||
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
||||||
.map(ApiLabel(_, RepositoryName(repository))),
|
.map(ApiLabel(_, RepositoryName(repository))),
|
||||||
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
|
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
|
||||||
@@ -61,7 +60,8 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
(for {
|
(for {
|
||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
issue <- getIssue(repository.owner, repository.name, issueId.toString)
|
issue <- getIssue(repository.owner, repository.name, issueId.toString)
|
||||||
users = getAccountsByUserNames(Set(issue.openedUserName) ++ issue.assignedUserName, Set())
|
assigneeUsers = getIssueAssignees(repository.owner, repository.name, issueId)
|
||||||
|
users = getAccountsByUserNames(Set(issue.openedUserName) ++ assigneeUsers.map(_.assigneeUserName), Set())
|
||||||
openedUser <- users.get(issue.openedUserName)
|
openedUser <- users.get(issue.openedUserName)
|
||||||
} yield {
|
} yield {
|
||||||
JsonFormat(
|
JsonFormat(
|
||||||
@@ -69,7 +69,7 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
issue,
|
issue,
|
||||||
RepositoryName(repository),
|
RepositoryName(repository),
|
||||||
ApiUser(openedUser),
|
ApiUser(openedUser),
|
||||||
issue.assignedUserName.flatMap(users.get(_)).map(ApiUser(_)),
|
assigneeUsers.flatMap(x => users.get(x.assigneeUserName)).map(ApiUser(_)),
|
||||||
getIssueLabels(repository.owner, repository.name, issue.issueId).map(ApiLabel(_, RepositoryName(repository))),
|
getIssueLabels(repository.owner, repository.name, issue.issueId).map(ApiLabel(_, RepositoryName(repository))),
|
||||||
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
|
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
|
||||||
)
|
)
|
||||||
@@ -92,7 +92,7 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
repository,
|
repository,
|
||||||
data.title,
|
data.title,
|
||||||
data.body,
|
data.body,
|
||||||
data.assignees.headOption,
|
data.assignees,
|
||||||
milestone.map(_.milestoneId),
|
milestone.map(_.milestoneId),
|
||||||
None,
|
None,
|
||||||
data.labels,
|
data.labels,
|
||||||
@@ -103,7 +103,9 @@ trait ApiIssueControllerBase extends ControllerBase {
|
|||||||
issue,
|
issue,
|
||||||
RepositoryName(repository),
|
RepositoryName(repository),
|
||||||
ApiUser(loginAccount),
|
ApiUser(loginAccount),
|
||||||
issue.assignedUserName.flatMap(getAccountByUserName(_)).map(ApiUser(_)),
|
getIssueAssignees(repository.owner, repository.name, issue.issueId)
|
||||||
|
.flatMap(x => getAccountByUserName(x.assigneeUserName, false))
|
||||||
|
.map(ApiUser.apply),
|
||||||
getIssueLabels(repository.owner, repository.name, issue.issueId)
|
getIssueLabels(repository.owner, repository.name, issue.issueId)
|
||||||
.map(ApiLabel(_, RepositoryName(repository))),
|
.map(ApiLabel(_, RepositoryName(repository))),
|
||||||
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
|
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package gitbucket.core.controller.api
|
package gitbucket.core.controller.api
|
||||||
import gitbucket.core.api.{ApiError, ApiLabel, CreateALabel, JsonFormat}
|
import gitbucket.core.api.{AddLabelsToAnIssue, ApiError, ApiLabel, CreateALabel, JsonFormat}
|
||||||
import gitbucket.core.controller.ControllerBase
|
import gitbucket.core.controller.ControllerBase
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
@@ -69,8 +69,7 @@ trait ApiIssueLabelControllerBase extends ControllerBase {
|
|||||||
data <- extractFromJsonBody[CreateALabel] if data.isValid
|
data <- extractFromJsonBody[CreateALabel] if data.isValid
|
||||||
} yield {
|
} yield {
|
||||||
LockUtil.lock(RepositoryName(repository).fullName) {
|
LockUtil.lock(RepositoryName(repository).fullName) {
|
||||||
getLabel(repository.owner, repository.name, params("labelName")).map {
|
getLabel(repository.owner, repository.name, params("labelName")).map { label =>
|
||||||
label =>
|
|
||||||
if (getLabel(repository.owner, repository.name, data.name).isEmpty) {
|
if (getLabel(repository.owner, repository.name, data.name).isEmpty) {
|
||||||
updateLabel(repository.owner, repository.name, label.labelId, data.name, data.color)
|
updateLabel(repository.owner, repository.name, label.labelId, data.name, data.color)
|
||||||
JsonFormat(
|
JsonFormat(
|
||||||
@@ -121,10 +120,10 @@ trait ApiIssueLabelControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
post("/api/v3/repos/:owner/:repository/issues/:id/labels")(writableUsersOnly { repository =>
|
post("/api/v3/repos/:owner/:repository/issues/:id/labels")(writableUsersOnly { repository =>
|
||||||
JsonFormat(for {
|
JsonFormat(for {
|
||||||
data <- extractFromJsonBody[Seq[String]]
|
data <- extractFromJsonBody[AddLabelsToAnIssue]
|
||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
} yield {
|
} yield {
|
||||||
data.map { labelName =>
|
data.labels.map { labelName =>
|
||||||
val label = getLabel(repository.owner, repository.name, labelName).getOrElse(
|
val label = getLabel(repository.owner, repository.name, labelName).getOrElse(
|
||||||
getLabel(
|
getLabel(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
@@ -160,11 +159,11 @@ trait ApiIssueLabelControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
put("/api/v3/repos/:owner/:repository/issues/:id/labels")(writableUsersOnly { repository =>
|
put("/api/v3/repos/:owner/:repository/issues/:id/labels")(writableUsersOnly { repository =>
|
||||||
JsonFormat(for {
|
JsonFormat(for {
|
||||||
data <- extractFromJsonBody[Seq[String]]
|
data <- extractFromJsonBody[AddLabelsToAnIssue]
|
||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
} yield {
|
} yield {
|
||||||
deleteAllIssueLabels(repository.owner, repository.name, issueId, true)
|
deleteAllIssueLabels(repository.owner, repository.name, issueId, true)
|
||||||
data.map { labelName =>
|
data.labels.map { labelName =>
|
||||||
val label = getLabel(repository.owner, repository.name, labelName).getOrElse(
|
val label = getLabel(repository.owner, repository.name, labelName).getOrElse(
|
||||||
getLabel(
|
getLabel(
|
||||||
repository.owner,
|
repository.owner,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package gitbucket.core.controller.api
|
|||||||
import gitbucket.core.api._
|
import gitbucket.core.api._
|
||||||
import gitbucket.core.controller.ControllerBase
|
import gitbucket.core.controller.ControllerBase
|
||||||
import gitbucket.core.service.MilestonesService
|
import gitbucket.core.service.MilestonesService
|
||||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
|
||||||
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import org.scalatra.NoContent
|
import org.scalatra.NoContent
|
||||||
@@ -17,8 +16,10 @@ trait ApiIssueMilestoneControllerBase extends ControllerBase {
|
|||||||
get("/api/v3/repos/:owner/:repository/milestones")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/milestones")(referrersOnly { repository =>
|
||||||
val state = params.getOrElse("state", "all")
|
val state = params.getOrElse("state", "all")
|
||||||
// TODO "sort", "direction" params should be implemented.
|
// TODO "sort", "direction" params should be implemented.
|
||||||
val apiMilestones = (for (milestoneWithIssue <- getMilestonesWithIssueCount(repository.owner, repository.name)
|
val apiMilestones = (for (
|
||||||
.sortBy(p => p._1.milestoneId))
|
milestoneWithIssue <- getMilestonesWithIssueCount(repository.owner, repository.name)
|
||||||
|
.sortBy(p => p._1.milestoneId)
|
||||||
|
)
|
||||||
yield {
|
yield {
|
||||||
ApiMilestone(
|
ApiMilestone(
|
||||||
repository.repository,
|
repository.repository,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
val condition = IssueSearchCondition(request)
|
val condition = IssueSearchCondition(request)
|
||||||
val baseOwner = getAccountByUserName(repository.owner).get
|
val baseOwner = getAccountByUserName(repository.owner).get
|
||||||
|
|
||||||
val issues: List[(Issue, Account, Int, PullRequest, Repository, Account, Option[Account])] =
|
val issues: List[(Issue, Account, Int, PullRequest, Repository, Account, List[Account])] =
|
||||||
searchPullRequestByApi(
|
searchPullRequestByApi(
|
||||||
condition = condition,
|
condition = condition,
|
||||||
offset = (page - 1) * PullRequestLimit,
|
offset = (page - 1) * PullRequestLimit,
|
||||||
@@ -48,8 +48,7 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
repos = repository.owner -> repository.name
|
repos = repository.owner -> repository.name
|
||||||
)
|
)
|
||||||
|
|
||||||
JsonFormat(issues.map {
|
JsonFormat(issues.map { case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner, assignees) =>
|
||||||
case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner, assignee) =>
|
|
||||||
ApiPullRequest(
|
ApiPullRequest(
|
||||||
issue = issue,
|
issue = issue,
|
||||||
pullRequest = pullRequest,
|
pullRequest = pullRequest,
|
||||||
@@ -58,7 +57,7 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
user = ApiUser(issueUser),
|
user = ApiUser(issueUser),
|
||||||
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
||||||
.map(ApiLabel(_, RepositoryName(repository))),
|
.map(ApiLabel(_, RepositoryName(repository))),
|
||||||
assignee = assignee.map(ApiUser.apply),
|
assignees = assignees.map(ApiUser.apply),
|
||||||
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -89,8 +88,7 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
case Left(createPullReq) =>
|
case Left(createPullReq) =>
|
||||||
val (reqOwner, reqBranch) = parseCompareIdentifier(createPullReq.head, repository.owner)
|
val (reqOwner, reqBranch) = parseCompareIdentifier(createPullReq.head, repository.owner)
|
||||||
getRepository(reqOwner, repository.name)
|
getRepository(reqOwner, repository.name)
|
||||||
.flatMap {
|
.flatMap { forkedRepository =>
|
||||||
forkedRepository =>
|
|
||||||
getPullRequestCommitFromTo(repository, forkedRepository, createPullReq.base, reqBranch) match {
|
getPullRequestCommitFromTo(repository, forkedRepository, createPullReq.base, reqBranch) match {
|
||||||
case (Some(commitIdFrom), Some(commitIdTo)) =>
|
case (Some(commitIdFrom), Some(commitIdTo)) =>
|
||||||
val issueId = insertIssue(
|
val issueId = insertIssue(
|
||||||
@@ -99,7 +97,6 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
loginUser = context.loginAccount.get.userName,
|
loginUser = context.loginAccount.get.userName,
|
||||||
title = createPullReq.title,
|
title = createPullReq.title,
|
||||||
content = createPullReq.body,
|
content = createPullReq.body,
|
||||||
assignedUserName = None,
|
|
||||||
milestoneId = None,
|
milestoneId = None,
|
||||||
priorityId = None,
|
priorityId = None,
|
||||||
isPullRequest = true
|
isPullRequest = true
|
||||||
@@ -129,8 +126,7 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
case Right(createPullReqAlt) =>
|
case Right(createPullReqAlt) =>
|
||||||
val (reqOwner, reqBranch) = parseCompareIdentifier(createPullReqAlt.head, repository.owner)
|
val (reqOwner, reqBranch) = parseCompareIdentifier(createPullReqAlt.head, repository.owner)
|
||||||
getRepository(reqOwner, repository.name)
|
getRepository(reqOwner, repository.name)
|
||||||
.flatMap {
|
.flatMap { forkedRepository =>
|
||||||
forkedRepository =>
|
|
||||||
getPullRequestCommitFromTo(repository, forkedRepository, createPullReqAlt.base, reqBranch) match {
|
getPullRequestCommitFromTo(repository, forkedRepository, createPullReqAlt.base, reqBranch) match {
|
||||||
case (Some(commitIdFrom), Some(commitIdTo)) =>
|
case (Some(commitIdFrom), Some(commitIdTo)) =>
|
||||||
changeIssueToPullRequest(repository.owner, repository.name, createPullReqAlt.issue)
|
changeIssueToPullRequest(repository.owner, repository.name, createPullReqAlt.issue)
|
||||||
@@ -191,10 +187,8 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
get("/api/v3/repos/:owner/:repository/pulls/:id/commits")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/pulls/:id/commits")(referrersOnly { repository =>
|
||||||
val owner = repository.owner
|
val owner = repository.owner
|
||||||
val name = repository.name
|
val name = repository.name
|
||||||
params("id").toIntOpt.flatMap {
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
issueId =>
|
getPullRequest(owner, name, issueId) map { case (issue, pullreq) =>
|
||||||
getPullRequest(owner, name, issueId) map {
|
|
||||||
case (issue, pullreq) =>
|
|
||||||
Using.resource(Git.open(getRepositoryDir(owner, name))) { git =>
|
Using.resource(Git.open(getRepositoryDir(owner, name))) { git =>
|
||||||
val oldId = git.getRepository.resolve(pullreq.commitIdFrom)
|
val oldId = git.getRepository.resolve(pullreq.commitIdFrom)
|
||||||
val newId = git.getRepository.resolve(pullreq.commitIdTo)
|
val newId = git.getRepository.resolve(pullreq.commitIdTo)
|
||||||
@@ -319,8 +313,8 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
baseOwner <- users.get(repository.owner)
|
baseOwner <- users.get(repository.owner)
|
||||||
headOwner <- users.get(pullRequest.requestUserName)
|
headOwner <- users.get(pullRequest.requestUserName)
|
||||||
issueUser <- users.get(issue.openedUserName)
|
issueUser <- users.get(issue.openedUserName)
|
||||||
assignee = issue.assignedUserName.flatMap { userName =>
|
assignees = getIssueAssignees(repository.owner, repository.name, issueId).flatMap { assignedUser =>
|
||||||
getAccountByUserName(userName, false)
|
getAccountByUserName(assignedUser.assigneeUserName, false)
|
||||||
}
|
}
|
||||||
headRepo <- getRepository(pullRequest.requestUserName, pullRequest.requestRepositoryName)
|
headRepo <- getRepository(pullRequest.requestUserName, pullRequest.requestRepositoryName)
|
||||||
} yield {
|
} yield {
|
||||||
@@ -332,7 +326,7 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
user = ApiUser(issueUser),
|
user = ApiUser(issueUser),
|
||||||
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
||||||
.map(ApiLabel(_, RepositoryName(repository))),
|
.map(ApiLabel(_, RepositoryName(repository))),
|
||||||
assignee = assignee.map(ApiUser.apply),
|
assignees = assignees.map(ApiUser.apply),
|
||||||
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,8 +119,7 @@ trait ApiReleaseControllerBase extends ControllerBase {
|
|||||||
* ix. Upload a release asset
|
* ix. Upload a release asset
|
||||||
* https://developer.github.com/v3/repos/releases/#upload-a-release-asset
|
* https://developer.github.com/v3/repos/releases/#upload-a-release-asset
|
||||||
*/
|
*/
|
||||||
post("/api/v3/repos/:owner/:repository/releases/:tag/assets")(writableUsersOnly {
|
post("/api/v3/repos/:owner/:repository/releases/:tag/assets")(writableUsersOnly { repository =>
|
||||||
repository =>
|
|
||||||
val name = params("name")
|
val name = params("name")
|
||||||
val tag = params("tag")
|
val tag = params("tag")
|
||||||
getRelease(repository.owner, repository.name, tag)
|
getRelease(repository.owner, repository.name, tag)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package gitbucket.core.controller.api
|
package gitbucket.core.controller.api
|
||||||
import gitbucket.core.api._
|
import gitbucket.core.api.*
|
||||||
import gitbucket.core.controller.ControllerBase
|
import gitbucket.core.controller.ControllerBase
|
||||||
import gitbucket.core.service.{AccountService, ProtectedBranchService, RepositoryService}
|
import gitbucket.core.service.{AccountService, ProtectedBranchService, RepositoryService}
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util.*
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory.*
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits.*
|
||||||
import gitbucket.core.util.JGitUtil.getBranches
|
import gitbucket.core.util.JGitUtil.getBranchesNoMergeInfo
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.scalatra.NoContent
|
import org.scalatra.NoContent
|
||||||
|
|
||||||
@@ -30,10 +30,9 @@ trait ApiRepositoryBranchControllerBase extends ControllerBase {
|
|||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
JsonFormat(
|
JsonFormat(
|
||||||
JGitUtil
|
JGitUtil
|
||||||
.getBranches(
|
.getBranchesNoMergeInfo(
|
||||||
git = git,
|
git = git,
|
||||||
defaultBranch = repository.repository.defaultBranch,
|
defaultBranch = repository.repository.defaultBranch
|
||||||
origin = repository.repository.originUserName.isEmpty
|
|
||||||
)
|
)
|
||||||
.map { br =>
|
.map { br =>
|
||||||
ApiBranchForList(br.name, ApiBranchCommit(br.commitId))
|
ApiBranchForList(br.name, ApiBranchCommit(br.commitId))
|
||||||
@@ -47,14 +46,12 @@ trait ApiRepositoryBranchControllerBase extends ControllerBase {
|
|||||||
* https://docs.github.com/en/rest/reference/repos#get-a-branch
|
* https://docs.github.com/en/rest/reference/repos#get-a-branch
|
||||||
*/
|
*/
|
||||||
get("/api/v3/repos/:owner/:repository/branches/*")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/branches/*")(referrersOnly { repository =>
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
(for {
|
(for {
|
||||||
branch <- params.get("splat") if repository.branchList.contains(branch)
|
branch <- params.get("splat") if repository.branchList.contains(branch)
|
||||||
br <- getBranches(
|
br <- getBranchesNoMergeInfo(
|
||||||
git,
|
git,
|
||||||
repository.repository.defaultBranch,
|
repository.repository.defaultBranch
|
||||||
repository.repository.originUserName.isEmpty
|
|
||||||
).find(_.name == branch)
|
).find(_.name == branch)
|
||||||
} yield {
|
} yield {
|
||||||
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
||||||
@@ -274,16 +271,14 @@ trait ApiRepositoryBranchControllerBase extends ControllerBase {
|
|||||||
* https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
|
* https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
|
||||||
*/
|
*/
|
||||||
patch("/api/v3/repos/:owner/:repository/branches/*")(ownerOnly { repository =>
|
patch("/api/v3/repos/:owner/:repository/branches/*")(ownerOnly { repository =>
|
||||||
import gitbucket.core.api._
|
import gitbucket.core.api.*
|
||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
git =>
|
|
||||||
(for {
|
(for {
|
||||||
branch <- params.get("splat") if repository.branchList.contains(branch)
|
branch <- params.get("splat") if repository.branchList.contains(branch)
|
||||||
protection <- extractFromJsonBody[ApiBranchProtection.EnablingAndDisabling].map(_.protection)
|
protection <- extractFromJsonBody[ApiBranchProtection.EnablingAndDisabling].map(_.protection)
|
||||||
br <- getBranches(
|
br <- getBranchesNoMergeInfo(
|
||||||
git,
|
git,
|
||||||
repository.repository.defaultBranch,
|
repository.repository.defaultBranch
|
||||||
repository.repository.originUserName.isEmpty
|
|
||||||
).find(_.name == branch)
|
).find(_.name == branch)
|
||||||
} yield {
|
} yield {
|
||||||
if (protection.enabled) {
|
if (protection.enabled) {
|
||||||
|
|||||||
@@ -4,13 +4,20 @@ import gitbucket.core.controller.ControllerBase
|
|||||||
import gitbucket.core.model.Account
|
import gitbucket.core.model.Account
|
||||||
import gitbucket.core.service.{AccountService, CommitsService, ProtectedBranchService}
|
import gitbucket.core.service.{AccountService, CommitsService, ProtectedBranchService}
|
||||||
import gitbucket.core.util.Directory.getRepositoryDir
|
import gitbucket.core.util.Directory.getRepositoryDir
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits.*
|
||||||
import gitbucket.core.util.JGitUtil.{CommitInfo, getBranches, getBranchesOfCommit}
|
import gitbucket.core.util.JGitUtil.{CommitInfo, getBranchesNoMergeInfo, getBranchesOfCommit}
|
||||||
import gitbucket.core.util.{JGitUtil, ReferrerAuthenticator, RepositoryName}
|
import gitbucket.core.util.{JGitUtil, ReferrerAuthenticator, RepositoryName}
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.revwalk.RevWalk
|
import org.eclipse.jgit.revwalk.RevWalk
|
||||||
|
import org.eclipse.jgit.revwalk.filter.*
|
||||||
|
import org.eclipse.jgit.treewalk.filter.{AndTreeFilter, PathFilterGroup, TreeFilter}
|
||||||
|
|
||||||
import scala.jdk.CollectionConverters._
|
import java.time.format.DateTimeFormatter.*
|
||||||
|
import java.time.{LocalDateTime, ZoneOffset}
|
||||||
|
import java.util.Date
|
||||||
|
import scala.collection.mutable.ListBuffer
|
||||||
|
import scala.jdk.CollectionConverters.*
|
||||||
|
import scala.math.min
|
||||||
import scala.util.Using
|
import scala.util.Using
|
||||||
|
|
||||||
trait ApiRepositoryCommitControllerBase extends ControllerBase {
|
trait ApiRepositoryCommitControllerBase extends ControllerBase {
|
||||||
@@ -22,17 +29,49 @@ trait ApiRepositoryCommitControllerBase extends ControllerBase {
|
|||||||
get("/api/v3/repos/:owner/:repository/commits")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/commits")(referrersOnly { repository =>
|
||||||
val owner = repository.owner
|
val owner = repository.owner
|
||||||
val name = repository.name
|
val name = repository.name
|
||||||
// TODO: The following parameters need to be implemented. [:path, :author, :since, :until]
|
val sha = params.get("sha").filter(_.nonEmpty).getOrElse("HEAD")
|
||||||
val sha = params.getOrElse("sha", "refs/heads/master")
|
val page = params.get("page").filter(_.nonEmpty).getOrElse("1").toInt
|
||||||
Using.resource(Git.open(getRepositoryDir(owner, name))) {
|
val per_page = min(params.get("per_page").filter(_.nonEmpty).getOrElse("30").toInt, 100)
|
||||||
git =>
|
val author = params.get("author").filter(_.nonEmpty)
|
||||||
|
val path = params.get("path").filter(_.nonEmpty)
|
||||||
|
val since = params.get("since").filter(_.nonEmpty)
|
||||||
|
val until = params.get("until").filter(_.nonEmpty)
|
||||||
|
Using.resource(Git.open(getRepositoryDir(owner, name))) { git =>
|
||||||
val repo = git.getRepository
|
val repo = git.getRepository
|
||||||
Using.resource(new RevWalk(repo)) {
|
Using.resource(new RevWalk(repo)) { revWalk =>
|
||||||
revWalk =>
|
|
||||||
val objectId = repo.resolve(sha)
|
val objectId = repo.resolve(sha)
|
||||||
revWalk.markStart(revWalk.parseCommit(objectId))
|
revWalk.markStart(revWalk.parseCommit(objectId))
|
||||||
JsonFormat(revWalk.asScala.take(30).map {
|
if (path.nonEmpty) {
|
||||||
commit =>
|
revWalk.setTreeFilter(
|
||||||
|
AndTreeFilter.create(PathFilterGroup.createFromStrings(path.get), TreeFilter.ANY_DIFF)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val revfilters = new ListBuffer[(RevFilter)]()
|
||||||
|
if (author.nonEmpty) {
|
||||||
|
revfilters += AuthorRevFilter.create(author.get)
|
||||||
|
}
|
||||||
|
if (since.nonEmpty) {
|
||||||
|
revfilters += CommitTimeRevFilter.after(
|
||||||
|
Date.from(LocalDateTime.parse(since.get, ISO_DATE_TIME).toInstant(ZoneOffset.UTC))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (until.nonEmpty) {
|
||||||
|
revfilters += CommitTimeRevFilter.before(
|
||||||
|
Date.from(LocalDateTime.parse(until.get, ISO_DATE_TIME).toInstant(ZoneOffset.UTC))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (page > 1) {
|
||||||
|
revfilters += SkipRevFilter.create(page * per_page - 2)
|
||||||
|
}
|
||||||
|
revfilters += MaxCountRevFilter.create(per_page);
|
||||||
|
revWalk.setRevFilter(
|
||||||
|
if (revfilters.size > 1) {
|
||||||
|
AndRevFilter.create(revfilters.toArray)
|
||||||
|
} else {
|
||||||
|
revfilters(0)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
JsonFormat(revWalk.asScala.map { commit =>
|
||||||
val commitInfo = new CommitInfo(commit)
|
val commitInfo = new CommitInfo(commit)
|
||||||
ApiCommits(
|
ApiCommits(
|
||||||
repositoryName = RepositoryName(repository),
|
repositoryName = RepositoryName(repository),
|
||||||
@@ -56,8 +95,7 @@ trait ApiRepositoryCommitControllerBase extends ControllerBase {
|
|||||||
val name = repository.name
|
val name = repository.name
|
||||||
val sha = params("sha")
|
val sha = params("sha")
|
||||||
|
|
||||||
Using.resource(Git.open(getRepositoryDir(owner, name))) {
|
Using.resource(Git.open(getRepositoryDir(owner, name))) { git =>
|
||||||
git =>
|
|
||||||
val repo = git.getRepository
|
val repo = git.getRepository
|
||||||
val objectId = repo.resolve(sha)
|
val objectId = repo.resolve(sha)
|
||||||
val commitInfo = Using.resource(new RevWalk(repo)) { revWalk =>
|
val commitInfo = Using.resource(new RevWalk(repo)) { revWalk =>
|
||||||
@@ -121,7 +159,7 @@ trait ApiRepositoryCommitControllerBase extends ControllerBase {
|
|||||||
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
val apiBranchForCommits = for {
|
val apiBranchForCommits = for {
|
||||||
branch <- getBranchesOfCommit(git, sha)
|
branch <- getBranchesOfCommit(git, sha)
|
||||||
br <- getBranches(git, branch, repository.repository.originUserName.isEmpty).find(_.name == branch)
|
br <- getBranchesNoMergeInfo(git, branch).find(_.name == branch)
|
||||||
} yield {
|
} yield {
|
||||||
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
||||||
ApiBranchForHeadCommit(branch, ApiBranchCommit(br.commitId), protection.enabled)
|
ApiBranchForHeadCommit(branch, ApiBranchCommit(br.commitId), protection.enabled)
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ trait ApiRepositoryContentsControllerBase extends ControllerBase {
|
|||||||
* https://docs.github.com/en/rest/reference/repos#get-a-repository-readme
|
* https://docs.github.com/en/rest/reference/repos#get-a-repository-readme
|
||||||
*/
|
*/
|
||||||
get("/api/v3/repos/:owner/:repository/readme")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/readme")(referrersOnly { repository =>
|
||||||
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) {
|
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
|
||||||
git =>
|
|
||||||
val refStr = params.getOrElse("ref", repository.repository.defaultBranch)
|
val refStr = params.getOrElse("ref", repository.repository.defaultBranch)
|
||||||
val files = getFileList(git, refStr, ".", maxFiles = context.settings.repositoryViewer.maxFiles)
|
val files = getFileList(git, refStr, ".", maxFiles = context.settings.repositoryViewer.maxFiles)
|
||||||
files // files should be sorted alphabetically.
|
files // files should be sorted alphabetically.
|
||||||
@@ -134,8 +133,7 @@ trait ApiRepositoryContentsControllerBase extends ControllerBase {
|
|||||||
* requested #2112
|
* requested #2112
|
||||||
*/
|
*/
|
||||||
put("/api/v3/repos/:owner/:repository/contents/*")(writableUsersOnly { repository =>
|
put("/api/v3/repos/:owner/:repository/contents/*")(writableUsersOnly { repository =>
|
||||||
context.withLoginAccount {
|
context.withLoginAccount { loginAccount =>
|
||||||
loginAccount =>
|
|
||||||
JsonFormat(for {
|
JsonFormat(for {
|
||||||
data <- extractFromJsonBody[CreateAFile]
|
data <- extractFromJsonBody[CreateAFile]
|
||||||
} yield {
|
} yield {
|
||||||
@@ -146,8 +144,7 @@ trait ApiRepositoryContentsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
val paths = multiParams("splat").head.split("/")
|
val paths = multiParams("splat").head.split("/")
|
||||||
val path = paths.take(paths.size - 1).toList.mkString("/")
|
val path = paths.take(paths.size - 1).toList.mkString("/")
|
||||||
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) {
|
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
|
||||||
git =>
|
|
||||||
val fileInfo = getFileInfo(git, commit, path, false)
|
val fileInfo = getFileInfo(git, commit, path, false)
|
||||||
|
|
||||||
fileInfo match {
|
fileInfo match {
|
||||||
@@ -157,7 +154,7 @@ trait ApiRepositoryContentsControllerBase extends ControllerBase {
|
|||||||
Some("https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents")
|
Some("https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents")
|
||||||
)
|
)
|
||||||
case _ =>
|
case _ =>
|
||||||
val (commitId, blobId) = commitFile(
|
commitFile(
|
||||||
repository,
|
repository,
|
||||||
branch,
|
branch,
|
||||||
path,
|
path,
|
||||||
@@ -170,12 +167,12 @@ trait ApiRepositoryContentsControllerBase extends ControllerBase {
|
|||||||
data.committer.map(_.name).getOrElse(loginAccount.fullName),
|
data.committer.map(_.name).getOrElse(loginAccount.fullName),
|
||||||
data.committer.map(_.email).getOrElse(loginAccount.mailAddress),
|
data.committer.map(_.email).getOrElse(loginAccount.mailAddress),
|
||||||
context.settings
|
context.settings
|
||||||
)
|
) match {
|
||||||
|
case Left(error) =>
|
||||||
blobId match {
|
ApiError(s"Failed to commit a file: ${error}", None)
|
||||||
case None =>
|
case Right((_, None)) =>
|
||||||
ApiError("Failed to commit a file.", None)
|
ApiError("Failed to commit a file.", None)
|
||||||
case Some(blobId) =>
|
case Right((commitId, Some(blobId))) =>
|
||||||
Map(
|
Map(
|
||||||
"content" -> ApiContents(
|
"content" -> ApiContents(
|
||||||
"file",
|
"file",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import scala.util.Using
|
|||||||
|
|
||||||
trait ApiRepositoryControllerBase extends ControllerBase {
|
trait ApiRepositoryControllerBase extends ControllerBase {
|
||||||
self: RepositoryService
|
self: RepositoryService
|
||||||
|
with ApiGitReferenceControllerBase
|
||||||
with RepositoryCreationService
|
with RepositoryCreationService
|
||||||
with AccountService
|
with AccountService
|
||||||
with OwnerAuthenticator
|
with OwnerAuthenticator
|
||||||
@@ -92,7 +93,8 @@ trait ApiRepositoryControllerBase extends ControllerBase {
|
|||||||
data.name,
|
data.name,
|
||||||
data.description,
|
data.description,
|
||||||
data.`private`,
|
data.`private`,
|
||||||
data.auto_init
|
data.auto_init,
|
||||||
|
context.settings.defaultBranch
|
||||||
)
|
)
|
||||||
Await.result(f, Duration.Inf)
|
Await.result(f, Duration.Inf)
|
||||||
|
|
||||||
@@ -129,7 +131,8 @@ trait ApiRepositoryControllerBase extends ControllerBase {
|
|||||||
data.name,
|
data.name,
|
||||||
data.description,
|
data.description,
|
||||||
data.`private`,
|
data.`private`,
|
||||||
data.auto_init
|
data.auto_init,
|
||||||
|
context.settings.defaultBranch
|
||||||
)
|
)
|
||||||
Await.result(f, Duration.Inf)
|
Await.result(f, Duration.Inf)
|
||||||
val repository = Database() withTransaction { session =>
|
val repository = Database() withTransaction { session =>
|
||||||
@@ -184,9 +187,11 @@ trait ApiRepositoryControllerBase extends ControllerBase {
|
|||||||
* https://docs.github.com/en/rest/reference/repos#list-repository-tags
|
* https://docs.github.com/en/rest/reference/repos#list-repository-tags
|
||||||
*/
|
*/
|
||||||
get("/api/v3/repos/:owner/:repository/tags")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/tags")(referrersOnly { repository =>
|
||||||
|
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
JsonFormat(
|
JsonFormat(
|
||||||
repository.tags.map(tagInfo => ApiTag(tagInfo.name, RepositoryName(repository), tagInfo.id))
|
self.getRef("tags", repository)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ trait ApiRepositoryStatusControllerBase extends ControllerBase {
|
|||||||
ref <- params.get("ref")
|
ref <- params.get("ref")
|
||||||
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
||||||
} yield {
|
} yield {
|
||||||
JsonFormat(getCommitStatusesWithCreator(repository.owner, repository.name, sha).map {
|
JsonFormat(getCommitStatusesWithCreator(repository.owner, repository.name, sha).map { case (status, creator) =>
|
||||||
case (status, creator) =>
|
|
||||||
ApiCommitStatus(status, ApiUser(creator))
|
ApiCommitStatus(status, ApiUser(creator))
|
||||||
})
|
})
|
||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ trait AccessTokenComponent { self: Profile =>
|
|||||||
val userName = column[String]("USER_NAME")
|
val userName = column[String]("USER_NAME")
|
||||||
val tokenHash = column[String]("TOKEN_HASH")
|
val tokenHash = column[String]("TOKEN_HASH")
|
||||||
val note = column[String]("NOTE")
|
val note = column[String]("NOTE")
|
||||||
def * = (accessTokenId, userName, tokenHash, note).<>(AccessToken.tupled, AccessToken.unapply)
|
def * = (accessTokenId, userName, tokenHash, note).mapTo[AccessToken]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case class AccessToken(
|
case class AccessToken(
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ trait AccountComponent { self: Profile =>
|
|||||||
groupAccount,
|
groupAccount,
|
||||||
removed,
|
removed,
|
||||||
description.?
|
description.?
|
||||||
).<>(Account.tupled, Account.unapply)
|
).mapTo[Account]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ trait AccountExtraMailAddressComponent { self: Profile =>
|
|||||||
val userName = column[String]("USER_NAME", O PrimaryKey)
|
val userName = column[String]("USER_NAME", O PrimaryKey)
|
||||||
val extraMailAddress = column[String]("EXTRA_MAIL_ADDRESS", O PrimaryKey)
|
val extraMailAddress = column[String]("EXTRA_MAIL_ADDRESS", O PrimaryKey)
|
||||||
def * =
|
def * =
|
||||||
(userName, extraMailAddress).<>(AccountExtraMailAddress.tupled, AccountExtraMailAddress.unapply)
|
(userName, extraMailAddress).mapTo[AccountExtraMailAddress]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ trait AccountFederationComponent { self: Profile =>
|
|||||||
val issuer = column[String]("ISSUER")
|
val issuer = column[String]("ISSUER")
|
||||||
val subject = column[String]("SUBJECT")
|
val subject = column[String]("SUBJECT")
|
||||||
val userName = column[String]("USER_NAME")
|
val userName = column[String]("USER_NAME")
|
||||||
def * = (issuer, subject, userName).<>(AccountFederation.tupled, AccountFederation.unapply)
|
def * = (issuer, subject, userName).mapTo[AccountFederation]
|
||||||
|
|
||||||
def byPrimaryKey(issuer: String, subject: String): Rep[Boolean] =
|
def byPrimaryKey(issuer: String, subject: String): Rep[Boolean] =
|
||||||
(this.issuer === issuer.bind) && (this.subject === subject.bind)
|
(this.issuer === issuer.bind) && (this.subject === subject.bind)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ trait AccountPreferenceComponent { self: Profile =>
|
|||||||
val userName = column[String]("USER_NAME", O PrimaryKey)
|
val userName = column[String]("USER_NAME", O PrimaryKey)
|
||||||
val highlighterTheme = column[String]("HIGHLIGHTER_THEME")
|
val highlighterTheme = column[String]("HIGHLIGHTER_THEME")
|
||||||
def * =
|
def * =
|
||||||
(userName, highlighterTheme).<>(AccountPreference.tupled, AccountPreference.unapply)
|
(userName, highlighterTheme).mapTo[AccountPreference]
|
||||||
|
|
||||||
def byPrimaryKey(userName: String): Rep[Boolean] = this.userName === userName.bind
|
def byPrimaryKey(userName: String): Rep[Boolean] = this.userName === userName.bind
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ trait AccountWebHookComponent extends TemplateComponent { self: Profile =>
|
|||||||
val url = column[String]("URL")
|
val url = column[String]("URL")
|
||||||
val token = column[Option[String]]("TOKEN")
|
val token = column[Option[String]]("TOKEN")
|
||||||
val ctype = column[WebHookContentType]("CTYPE")
|
val ctype = column[WebHookContentType]("CTYPE")
|
||||||
def * = (userName, url, ctype, token).<>((AccountWebHook.apply _).tupled, AccountWebHook.unapply)
|
def * = (userName, url, ctype, token).mapTo[AccountWebHook]
|
||||||
|
|
||||||
def byPrimaryKey(userName: String, url: String) = (this.userName === userName.bind) && (this.url === url.bind)
|
def byPrimaryKey(userName: String, url: String) = (this.userName === userName.bind) && (this.url === url.bind)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ trait AccountWebHookEventComponent extends TemplateComponent { self: Profile =>
|
|||||||
val url = column[String]("URL")
|
val url = column[String]("URL")
|
||||||
val event = column[WebHook.Event]("EVENT")
|
val event = column[WebHook.Event]("EVENT")
|
||||||
|
|
||||||
def * = (userName, url, event).<>((AccountWebHookEvent.apply _).tupled, AccountWebHookEvent.unapply)
|
def * = (userName, url, event).mapTo[AccountWebHookEvent]
|
||||||
|
|
||||||
def byAccountWebHook(userName: String, url: String) = (this.userName === userName.bind) && (this.url === url.bind)
|
def byAccountWebHook(userName: String, url: String) = (this.userName === userName.bind) && (this.url === url.bind)
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ trait ActivityComponent extends TemplateComponent { self: Profile =>
|
|||||||
lazy val Activities = TableQuery[Activities]
|
lazy val Activities = TableQuery[Activities]
|
||||||
|
|
||||||
class Activities(tag: Tag) extends Table[Activity](tag, "ACTIVITY") with BasicTemplate {
|
class Activities(tag: Tag) extends Table[Activity](tag, "ACTIVITY") with BasicTemplate {
|
||||||
def * = ???
|
def * : slick.lifted.ProvenShape[Activity] = ???
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package gitbucket.core.model
|
|||||||
protected[model] trait TemplateComponent { self: Profile =>
|
protected[model] trait TemplateComponent { self: Profile =>
|
||||||
import profile.api._
|
import profile.api._
|
||||||
|
|
||||||
trait BasicTemplate { self: Table[_] =>
|
trait BasicTemplate { self: Table[?] =>
|
||||||
val userName = column[String]("USER_NAME")
|
val userName = column[String]("USER_NAME")
|
||||||
val repositoryName = column[String]("REPOSITORY_NAME")
|
val repositoryName = column[String]("REPOSITORY_NAME")
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
(this.userName === userName) && (this.repositoryName === repositoryName)
|
(this.userName === userName) && (this.repositoryName === repositoryName)
|
||||||
}
|
}
|
||||||
|
|
||||||
trait IssueTemplate extends BasicTemplate { self: Table[_] =>
|
trait IssueTemplate extends BasicTemplate { self: Table[?] =>
|
||||||
val issueId = column[Int]("ISSUE_ID")
|
val issueId = column[Int]("ISSUE_ID")
|
||||||
|
|
||||||
def byIssue(owner: String, repository: String, issueId: Int) =
|
def byIssue(owner: String, repository: String, issueId: Int) =
|
||||||
@@ -28,7 +28,7 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
byRepository(userName, repositoryName) && (this.issueId === issueId)
|
byRepository(userName, repositoryName) && (this.issueId === issueId)
|
||||||
}
|
}
|
||||||
|
|
||||||
trait LabelTemplate extends BasicTemplate { self: Table[_] =>
|
trait LabelTemplate extends BasicTemplate { self: Table[?] =>
|
||||||
val labelId = column[Int]("LABEL_ID")
|
val labelId = column[Int]("LABEL_ID")
|
||||||
val labelName = column[String]("LABEL_NAME")
|
val labelName = column[String]("LABEL_NAME")
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
byRepository(owner, repository) && (this.labelName === labelName.bind)
|
byRepository(owner, repository) && (this.labelName === labelName.bind)
|
||||||
}
|
}
|
||||||
|
|
||||||
trait PriorityTemplate extends BasicTemplate { self: Table[_] =>
|
trait PriorityTemplate extends BasicTemplate { self: Table[?] =>
|
||||||
val priorityId = column[Int]("PRIORITY_ID")
|
val priorityId = column[Int]("PRIORITY_ID")
|
||||||
val priorityName = column[String]("PRIORITY_NAME")
|
val priorityName = column[String]("PRIORITY_NAME")
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
byRepository(owner, repository) && (this.priorityName === priorityName.bind)
|
byRepository(owner, repository) && (this.priorityName === priorityName.bind)
|
||||||
}
|
}
|
||||||
|
|
||||||
trait MilestoneTemplate extends BasicTemplate { self: Table[_] =>
|
trait MilestoneTemplate extends BasicTemplate { self: Table[?] =>
|
||||||
val milestoneId = column[Int]("MILESTONE_ID")
|
val milestoneId = column[Int]("MILESTONE_ID")
|
||||||
|
|
||||||
def byMilestone(owner: String, repository: String, milestoneId: Int) =
|
def byMilestone(owner: String, repository: String, milestoneId: Int) =
|
||||||
@@ -66,7 +66,7 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
byRepository(userName, repositoryName) && (this.milestoneId === milestoneId)
|
byRepository(userName, repositoryName) && (this.milestoneId === milestoneId)
|
||||||
}
|
}
|
||||||
|
|
||||||
trait CommitTemplate extends BasicTemplate { self: Table[_] =>
|
trait CommitTemplate extends BasicTemplate { self: Table[?] =>
|
||||||
val commitId = column[String]("COMMIT_ID")
|
val commitId = column[String]("COMMIT_ID")
|
||||||
|
|
||||||
def byCommit(owner: String, repository: String, commitId: String) =
|
def byCommit(owner: String, repository: String, commitId: String) =
|
||||||
@@ -76,7 +76,7 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
byRepository(userName, repositoryName) && (this.commitId === commitId)
|
byRepository(userName, repositoryName) && (this.commitId === commitId)
|
||||||
}
|
}
|
||||||
|
|
||||||
trait BranchTemplate extends BasicTemplate { self: Table[_] =>
|
trait BranchTemplate extends BasicTemplate { self: Table[?] =>
|
||||||
val branch = column[String]("BRANCH")
|
val branch = column[String]("BRANCH")
|
||||||
def byBranch(owner: String, repository: String, branchName: String) =
|
def byBranch(owner: String, repository: String, branchName: String) =
|
||||||
byRepository(owner, repository) && (branch === branchName.bind)
|
byRepository(owner, repository) && (branch === branchName.bind)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ trait CollaboratorComponent extends TemplateComponent { self: Profile =>
|
|||||||
class Collaborators(tag: Tag) extends Table[Collaborator](tag, "COLLABORATOR") with BasicTemplate {
|
class Collaborators(tag: Tag) extends Table[Collaborator](tag, "COLLABORATOR") with BasicTemplate {
|
||||||
val collaboratorName = column[String]("COLLABORATOR_NAME")
|
val collaboratorName = column[String]("COLLABORATOR_NAME")
|
||||||
val role = column[String]("ROLE")
|
val role = column[String]("ROLE")
|
||||||
def * = (userName, repositoryName, collaboratorName, role).<>(Collaborator.tupled, Collaborator.unapply)
|
def * = (userName, repositoryName, collaboratorName, role).mapTo[Collaborator]
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
||||||
byRepository(owner, repository) && (collaboratorName === collaborator.bind)
|
byRepository(owner, repository) && (collaboratorName === collaborator.bind)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ trait IssueCommentComponent extends TemplateComponent { self: Profile =>
|
|||||||
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
def * =
|
def * =
|
||||||
(userName, repositoryName, issueId, commentId, action, commentedUserName, content, registeredDate, updatedDate)
|
(userName, repositoryName, issueId, commentId, action, commentedUserName, content, registeredDate, updatedDate)
|
||||||
.<>(IssueComment.tupled, IssueComment.unapply)
|
.mapTo[IssueComment]
|
||||||
|
|
||||||
def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind
|
def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ trait CommitCommentComponent extends TemplateComponent { self: Profile =>
|
|||||||
originalCommitId,
|
originalCommitId,
|
||||||
originalOldLine,
|
originalOldLine,
|
||||||
originalNewLine
|
originalNewLine
|
||||||
).<>(CommitComment.tupled, CommitComment.unapply)
|
).mapTo[CommitComment]
|
||||||
|
|
||||||
def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind
|
def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ trait CommitStatusComponent extends TemplateComponent { self: Profile =>
|
|||||||
creator,
|
creator,
|
||||||
registeredDate,
|
registeredDate,
|
||||||
updatedDate
|
updatedDate
|
||||||
).<>((CommitStatus.apply _).tupled, CommitStatus.unapply)
|
).mapTo[CommitStatus]
|
||||||
def byPrimaryKey(id: Int) = commitStatusId === id.bind
|
def byPrimaryKey(id: Int) = commitStatusId === id.bind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
377
src/main/scala/gitbucket/core/model/CustomField.scala
Normal file
377
src/main/scala/gitbucket/core/model/CustomField.scala
Normal file
@@ -0,0 +1,377 @@
|
|||||||
|
package gitbucket.core.model
|
||||||
|
|
||||||
|
import gitbucket.core.controller.Context
|
||||||
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
|
import gitbucket.core.util.StringUtil
|
||||||
|
import gitbucket.core.view.helpers
|
||||||
|
import org.scalatra.i18n.Messages
|
||||||
|
import play.twirl.api.Html
|
||||||
|
|
||||||
|
trait CustomFieldComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.api._
|
||||||
|
|
||||||
|
lazy val CustomFields = TableQuery[CustomFields]
|
||||||
|
|
||||||
|
class CustomFields(tag: Tag) extends Table[CustomField](tag, "CUSTOM_FIELD") with BasicTemplate {
|
||||||
|
val fieldId = column[Int]("FIELD_ID", O AutoInc)
|
||||||
|
val fieldName = column[String]("FIELD_NAME")
|
||||||
|
val fieldType = column[String]("FIELD_TYPE")
|
||||||
|
val constraints = column[Option[String]]("CONSTRAINTS")
|
||||||
|
val enableForIssues = column[Boolean]("ENABLE_FOR_ISSUES")
|
||||||
|
val enableForPullRequests = column[Boolean]("ENABLE_FOR_PULL_REQUESTS")
|
||||||
|
def * =
|
||||||
|
(userName, repositoryName, fieldId, fieldName, fieldType, constraints, enableForIssues, enableForPullRequests)
|
||||||
|
.mapTo[CustomField]
|
||||||
|
|
||||||
|
def byPrimaryKey(userName: String, repositoryName: String, fieldId: Int) =
|
||||||
|
(this.userName === userName.bind) && (this.repositoryName === repositoryName.bind) && (this.fieldId === fieldId.bind)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case class CustomField(
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
fieldId: Int = 0,
|
||||||
|
fieldName: String,
|
||||||
|
fieldType: String, // long, double, string, date, or enum
|
||||||
|
constraints: Option[String],
|
||||||
|
enableForIssues: Boolean,
|
||||||
|
enableForPullRequests: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
|
trait CustomFieldBehavior {
|
||||||
|
def createHtml(repository: RepositoryInfo, fieldId: Int, fieldName: String, constraints: Option[String])(implicit
|
||||||
|
context: Context
|
||||||
|
): String
|
||||||
|
def fieldHtml(
|
||||||
|
repository: RepositoryInfo,
|
||||||
|
issueId: Int,
|
||||||
|
fieldId: Int,
|
||||||
|
fieldName: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
value: String,
|
||||||
|
editable: Boolean
|
||||||
|
)(implicit
|
||||||
|
context: Context
|
||||||
|
): String
|
||||||
|
def validate(name: String, constraints: Option[String], value: String, messages: Messages): Option[String]
|
||||||
|
}
|
||||||
|
|
||||||
|
object CustomFieldBehavior {
|
||||||
|
def validate(field: CustomField, value: String, messages: Messages): Option[String] = {
|
||||||
|
if (value.isEmpty) None
|
||||||
|
else {
|
||||||
|
CustomFieldBehavior(field.fieldType).flatMap { behavior =>
|
||||||
|
behavior.validate(field.fieldName, field.constraints, value, messages)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def apply(fieldType: String): Option[CustomFieldBehavior] = {
|
||||||
|
fieldType match {
|
||||||
|
case "long" => Some(LongFieldBehavior)
|
||||||
|
case "double" => Some(DoubleFieldBehavior)
|
||||||
|
case "string" => Some(StringFieldBehavior)
|
||||||
|
case "date" => Some(DateFieldBehavior)
|
||||||
|
case "enum" => Some(EnumFieldBehavior)
|
||||||
|
case _ => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case object LongFieldBehavior extends TextFieldBehavior {
|
||||||
|
override def validate(
|
||||||
|
name: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
value: String,
|
||||||
|
messages: Messages
|
||||||
|
): Option[String] = {
|
||||||
|
try {
|
||||||
|
value.toLong
|
||||||
|
None
|
||||||
|
} catch {
|
||||||
|
case _: NumberFormatException => Some(messages("error.number").format(name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case object DoubleFieldBehavior extends TextFieldBehavior {
|
||||||
|
override def validate(
|
||||||
|
name: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
value: String,
|
||||||
|
messages: Messages
|
||||||
|
): Option[String] = {
|
||||||
|
try {
|
||||||
|
value.toDouble
|
||||||
|
None
|
||||||
|
} catch {
|
||||||
|
case _: NumberFormatException => Some(messages("error.number").format(name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case object StringFieldBehavior extends TextFieldBehavior
|
||||||
|
case object DateFieldBehavior extends TextFieldBehavior {
|
||||||
|
private val pattern = "yyyy-MM-dd"
|
||||||
|
override protected val fieldType: String = "date"
|
||||||
|
|
||||||
|
override def validate(
|
||||||
|
name: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
value: String,
|
||||||
|
messages: Messages
|
||||||
|
): Option[String] = {
|
||||||
|
try {
|
||||||
|
new java.text.SimpleDateFormat(pattern).parse(value)
|
||||||
|
None
|
||||||
|
} catch {
|
||||||
|
case _: java.text.ParseException =>
|
||||||
|
Some(messages("error.datePattern").format(name, pattern))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case object EnumFieldBehavior extends CustomFieldBehavior {
|
||||||
|
override def createHtml(repository: RepositoryInfo, fieldId: Int, fieldName: String, constraints: Option[String])(
|
||||||
|
implicit context: Context
|
||||||
|
): String = {
|
||||||
|
createPulldownHtml(repository, fieldId, fieldName, constraints, None, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def fieldHtml(
|
||||||
|
repository: RepositoryInfo,
|
||||||
|
issueId: Int,
|
||||||
|
fieldId: Int,
|
||||||
|
fieldName: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
value: String,
|
||||||
|
editable: Boolean
|
||||||
|
)(implicit context: Context): String = {
|
||||||
|
if (!editable) {
|
||||||
|
val sb = new StringBuilder
|
||||||
|
sb.append("""</div>""")
|
||||||
|
sb.append("""<div>""")
|
||||||
|
if (value == "") {
|
||||||
|
sb.append(s"""<span id="label-custom-field-$fieldId"><span class="muted small">No ${StringUtil.escapeHtml(
|
||||||
|
fieldName
|
||||||
|
)}</span></span>""")
|
||||||
|
} else {
|
||||||
|
sb.append(s"""<span id="label-custom-field-$fieldId"><span class="muted small">${StringUtil
|
||||||
|
.escapeHtml(value)}</span></span>""")
|
||||||
|
}
|
||||||
|
sb.toString()
|
||||||
|
} else {
|
||||||
|
createPulldownHtml(repository, fieldId, fieldName, constraints, Some(issueId), Some(value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private def createPulldownHtml(
|
||||||
|
repository: RepositoryInfo,
|
||||||
|
fieldId: Int,
|
||||||
|
fieldName: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
issueId: Option[Int],
|
||||||
|
value: Option[String]
|
||||||
|
)(implicit context: Context): String = {
|
||||||
|
val sb = new StringBuilder
|
||||||
|
sb.append("""<div class="pull-right">""")
|
||||||
|
sb.append(
|
||||||
|
gitbucket.core.helper.html
|
||||||
|
.dropdown("Edit", right = true, filter = (fieldName, s"Filter $fieldName")) {
|
||||||
|
val options = new StringBuilder()
|
||||||
|
options.append(
|
||||||
|
s"""<li><a href="javascript:void(0);" class="custom-field-option-$fieldId" data-value=""><i class="octicon octicon-x"></i> Clear ${StringUtil
|
||||||
|
.escapeHtml(fieldName)}</a></li>"""
|
||||||
|
)
|
||||||
|
constraints.foreach { x =>
|
||||||
|
x.split(",").map(_.trim).foreach { item =>
|
||||||
|
options.append(s"""<li>
|
||||||
|
| <a href="javascript:void(0);" class="custom-field-option-$fieldId" data-value="${StringUtil
|
||||||
|
.escapeHtml(item)}">
|
||||||
|
| ${gitbucket.core.helper.html.checkicon(value.contains(item))}
|
||||||
|
| ${StringUtil.escapeHtml(item)}
|
||||||
|
| </a>
|
||||||
|
|</li>
|
||||||
|
|""".stripMargin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Html(options.toString())
|
||||||
|
}
|
||||||
|
.toString()
|
||||||
|
)
|
||||||
|
sb.append("""</div>""")
|
||||||
|
sb.append("""</div>""")
|
||||||
|
sb.append("""<div>""")
|
||||||
|
value match {
|
||||||
|
case None =>
|
||||||
|
sb.append(s"""<span id="label-custom-field-$fieldId"><span class="muted small">No ${StringUtil.escapeHtml(
|
||||||
|
fieldName
|
||||||
|
)}</span></span>""")
|
||||||
|
case Some(value) =>
|
||||||
|
sb.append(s"""<span id="label-custom-field-$fieldId"><span class="muted small">${StringUtil
|
||||||
|
.escapeHtml(value)}</span></span>""")
|
||||||
|
}
|
||||||
|
if (value.isEmpty || issueId.isEmpty) {
|
||||||
|
sb.append(s"""<input type="hidden" id="custom-field-$fieldId" name="custom-field-$fieldId" value=""/>""")
|
||||||
|
sb.append(s"""<script>
|
||||||
|
|$$('a.custom-field-option-$fieldId').click(function(){
|
||||||
|
| const value = $$(this).data('value');
|
||||||
|
| $$('a.custom-field-option-$fieldId i.octicon-check').removeClass('octicon-check');
|
||||||
|
| $$('#custom-field-$fieldId').val(value);
|
||||||
|
| if (value == '') {
|
||||||
|
| $$('#label-custom-field-$fieldId').html($$('<span class="muted small">').text('No ${StringUtil
|
||||||
|
.escapeHtml(fieldName)}'));
|
||||||
|
| } else {
|
||||||
|
| $$('#label-custom-field-$fieldId').html($$('<span class="muted small">').text(value));
|
||||||
|
| $$('a.custom-field-option-$fieldId[data-value=' + value + '] i').addClass('octicon-check');
|
||||||
|
| }
|
||||||
|
|});
|
||||||
|
|</script>""".stripMargin)
|
||||||
|
} else {
|
||||||
|
sb.append(s"""<script>
|
||||||
|
|$$('a.custom-field-option-$fieldId').click(function(){
|
||||||
|
| const value = $$(this).data('value');
|
||||||
|
| $$.post('${helpers.url(repository)}/issues/${issueId.get}/customfield/$fieldId',
|
||||||
|
| { value: value },
|
||||||
|
| function(data){
|
||||||
|
| $$('a.custom-field-option-$fieldId i.octicon-check').removeClass('octicon-check');
|
||||||
|
| if (value == '') {
|
||||||
|
| $$('#label-custom-field-$fieldId').html($$('<span class="muted small">').text('No ${StringUtil
|
||||||
|
.escapeHtml(fieldName)}'));
|
||||||
|
| } else {
|
||||||
|
| $$('#label-custom-field-$fieldId').html($$('<span class="muted small">').text(value));
|
||||||
|
| $$('a.custom-field-option-$fieldId[data-value=' + value + '] i').addClass('octicon-check');
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| );
|
||||||
|
|});
|
||||||
|
|</script>
|
||||||
|
|""".stripMargin)
|
||||||
|
}
|
||||||
|
sb.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
override def validate(
|
||||||
|
name: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
value: String,
|
||||||
|
messages: Messages
|
||||||
|
): Option[String] = None
|
||||||
|
}
|
||||||
|
|
||||||
|
trait TextFieldBehavior extends CustomFieldBehavior {
|
||||||
|
protected val fieldType = "text"
|
||||||
|
|
||||||
|
override def createHtml(repository: RepositoryInfo, fieldId: Int, fieldName: String, constraints: Option[String])(
|
||||||
|
implicit context: Context
|
||||||
|
): String = {
|
||||||
|
val sb = new StringBuilder
|
||||||
|
sb.append(
|
||||||
|
s"""<input type="$fieldType" class="form-control input-sm" id="custom-field-$fieldId" name="custom-field-$fieldId" data-field-id="$fieldId" style="width: 120px;"/>"""
|
||||||
|
)
|
||||||
|
sb.append(s"""<script>
|
||||||
|
|$$('#custom-field-$fieldId').focusout(function(){
|
||||||
|
| const $$this = $$(this);
|
||||||
|
| $$.post('${helpers.url(repository)}/issues/customfield_validation/$fieldId',
|
||||||
|
| { value: $$this.val() },
|
||||||
|
| function(data){
|
||||||
|
| if (data != '') {
|
||||||
|
| $$('#custom-field-$fieldId-error').text(data);
|
||||||
|
| } else {
|
||||||
|
| $$('#custom-field-$fieldId-error').text('');
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| );
|
||||||
|
|});
|
||||||
|
|</script>
|
||||||
|
|""".stripMargin)
|
||||||
|
sb.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
override def fieldHtml(
|
||||||
|
repository: RepositoryInfo,
|
||||||
|
issueId: Int,
|
||||||
|
fieldId: Int,
|
||||||
|
fieldName: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
value: String,
|
||||||
|
editable: Boolean
|
||||||
|
)(implicit
|
||||||
|
context: Context
|
||||||
|
): String = {
|
||||||
|
val sb = new StringBuilder
|
||||||
|
if (value.nonEmpty) {
|
||||||
|
sb.append(
|
||||||
|
s"""<span id="custom-field-$fieldId-label" class="custom-field-label">${StringUtil
|
||||||
|
.escapeHtml(value)}</span>"""
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
if (editable) {
|
||||||
|
sb.append(
|
||||||
|
s"""<span id="custom-field-$fieldId-label" class="custom-field-label"><i class="octicon octicon-pencil" style="cursor: pointer;"></i></span>"""
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
sb.append(
|
||||||
|
s"""<span id="custom-field-$fieldId-label" class="custom-field-label">N/A</span>"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (editable) {
|
||||||
|
sb.append(
|
||||||
|
s"""<input type="$fieldType" id="custom-field-$fieldId-editor" class="form-control input-sm custom-field-editor" data-field-id="$fieldId" style="width: 120px; display: none;"/>"""
|
||||||
|
)
|
||||||
|
sb.append(s"""<script>
|
||||||
|
|$$('#custom-field-$fieldId-label').click(function(){
|
||||||
|
| const $$this = $$(this);
|
||||||
|
| $$this.hide();
|
||||||
|
| $$this.next().val($$this.text()).show().focus();
|
||||||
|
|});
|
||||||
|
|
|
||||||
|
|$$('#custom-field-$fieldId-editor').focusout(function(){
|
||||||
|
| const $$this = $$(this);
|
||||||
|
| $$.post('${helpers.url(repository)}/issues/customfield_validation/$fieldId',
|
||||||
|
| { value: $$this.val() },
|
||||||
|
| function(data){
|
||||||
|
| if (data != '') {
|
||||||
|
| $$('#custom-field-$fieldId-error').text(data);
|
||||||
|
| } else {
|
||||||
|
| $$('#custom-field-$fieldId-error').text('');
|
||||||
|
| $$.post('${helpers.url(repository)}/issues/$issueId/customfield/$fieldId',
|
||||||
|
| { value: $$this.val() },
|
||||||
|
| function(data){
|
||||||
|
| $$this.hide();
|
||||||
|
| if (data == '') {
|
||||||
|
| $$this.prev().html('<i class="octicon octicon-pencil" style="cursor: pointer;">').show();
|
||||||
|
| } else {
|
||||||
|
| $$this.prev().text(data).show();
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| );
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| );
|
||||||
|
|});
|
||||||
|
|
|
||||||
|
|// ESC key handling in text field
|
||||||
|
|$$('#custom-field-$fieldId-editor').keyup(function(e){
|
||||||
|
| if (e.keyCode == 27) {
|
||||||
|
| const $$this = $$(this);
|
||||||
|
| $$this.hide();
|
||||||
|
| $$this.prev().show();
|
||||||
|
| }
|
||||||
|
| if (e.keyCode == 13) {
|
||||||
|
| $$('#custom-field-$fieldId-editor').blur();
|
||||||
|
| }
|
||||||
|
|});
|
||||||
|
|</script>
|
||||||
|
|""".stripMargin)
|
||||||
|
}
|
||||||
|
sb.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
override def validate(
|
||||||
|
name: String,
|
||||||
|
constraints: Option[String],
|
||||||
|
value: String,
|
||||||
|
messages: Messages
|
||||||
|
): Option[String] = None
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ trait DeployKeyComponent extends TemplateComponent { self: Profile =>
|
|||||||
val publicKey = column[String]("PUBLIC_KEY")
|
val publicKey = column[String]("PUBLIC_KEY")
|
||||||
val allowWrite = column[Boolean]("ALLOW_WRITE")
|
val allowWrite = column[Boolean]("ALLOW_WRITE")
|
||||||
def * =
|
def * =
|
||||||
(userName, repositoryName, deployKeyId, title, publicKey, allowWrite).<>(DeployKey.tupled, DeployKey.unapply)
|
(userName, repositoryName, deployKeyId, title, publicKey, allowWrite).mapTo[DeployKey]
|
||||||
|
|
||||||
def byPrimaryKey(userName: String, repositoryName: String, deployKeyId: Int) =
|
def byPrimaryKey(userName: String, repositoryName: String, deployKeyId: Int) =
|
||||||
(this.userName === userName.bind) && (this.repositoryName === repositoryName.bind) && (this.deployKeyId === deployKeyId.bind)
|
(this.userName === userName.bind) && (this.repositoryName === repositoryName.bind) && (this.deployKeyId === deployKeyId.bind)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ trait GpgKeyComponent { self: Profile =>
|
|||||||
val gpgKeyId = column[Long]("GPG_KEY_ID")
|
val gpgKeyId = column[Long]("GPG_KEY_ID")
|
||||||
val title = column[String]("TITLE")
|
val title = column[String]("TITLE")
|
||||||
val publicKey = column[String]("PUBLIC_KEY")
|
val publicKey = column[String]("PUBLIC_KEY")
|
||||||
def * = (userName, keyId, gpgKeyId, title, publicKey).<>(GpgKey.tupled, GpgKey.unapply)
|
def * = (userName, keyId, gpgKeyId, title, publicKey).mapTo[GpgKey]
|
||||||
|
|
||||||
def byPrimaryKey(userName: String, keyId: Int) =
|
def byPrimaryKey(userName: String, keyId: Int) =
|
||||||
(this.userName === userName.bind) && (this.keyId === keyId.bind)
|
(this.userName === userName.bind) && (this.keyId === keyId.bind)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ trait GroupMemberComponent { self: Profile =>
|
|||||||
val groupName = column[String]("GROUP_NAME", O PrimaryKey)
|
val groupName = column[String]("GROUP_NAME", O PrimaryKey)
|
||||||
val userName = column[String]("USER_NAME", O PrimaryKey)
|
val userName = column[String]("USER_NAME", O PrimaryKey)
|
||||||
val isManager = column[Boolean]("MANAGER")
|
val isManager = column[Boolean]("MANAGER")
|
||||||
def * = (groupName, userName, isManager).<>(GroupMember.tupled, GroupMember.unapply)
|
def * = (groupName, userName, isManager).mapTo[GroupMember]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ trait IssueComponent extends TemplateComponent { self: Profile =>
|
|||||||
with MilestoneTemplate
|
with MilestoneTemplate
|
||||||
with PriorityTemplate {
|
with PriorityTemplate {
|
||||||
val openedUserName = column[String]("OPENED_USER_NAME")
|
val openedUserName = column[String]("OPENED_USER_NAME")
|
||||||
val assignedUserName = column[String]("ASSIGNED_USER_NAME")
|
|
||||||
val title = column[String]("TITLE")
|
val title = column[String]("TITLE")
|
||||||
val content = column[String]("CONTENT")
|
val content = column[String]("CONTENT")
|
||||||
val closed = column[Boolean]("CLOSED")
|
val closed = column[Boolean]("CLOSED")
|
||||||
@@ -42,14 +41,13 @@ trait IssueComponent extends TemplateComponent { self: Profile =>
|
|||||||
openedUserName,
|
openedUserName,
|
||||||
milestoneId.?,
|
milestoneId.?,
|
||||||
priorityId.?,
|
priorityId.?,
|
||||||
assignedUserName.?,
|
|
||||||
title,
|
title,
|
||||||
content.?,
|
content.?,
|
||||||
closed,
|
closed,
|
||||||
registeredDate,
|
registeredDate,
|
||||||
updatedDate,
|
updatedDate,
|
||||||
pullRequest
|
pullRequest
|
||||||
).<>(Issue.tupled, Issue.unapply)
|
).mapTo[Issue]
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId)
|
def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId)
|
||||||
}
|
}
|
||||||
@@ -62,7 +60,6 @@ case class Issue(
|
|||||||
openedUserName: String,
|
openedUserName: String,
|
||||||
milestoneId: Option[Int],
|
milestoneId: Option[Int],
|
||||||
priorityId: Option[Int],
|
priorityId: Option[Int],
|
||||||
assignedUserName: Option[String],
|
|
||||||
title: String,
|
title: String,
|
||||||
content: Option[String],
|
content: Option[String],
|
||||||
closed: Boolean,
|
closed: Boolean,
|
||||||
|
|||||||
25
src/main/scala/gitbucket/core/model/IssueAssignee.scala
Normal file
25
src/main/scala/gitbucket/core/model/IssueAssignee.scala
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package gitbucket.core.model
|
||||||
|
|
||||||
|
trait IssueAssigneeComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.api._
|
||||||
|
import self._
|
||||||
|
|
||||||
|
lazy val IssueAssignees = TableQuery[IssueAssignees]
|
||||||
|
|
||||||
|
class IssueAssignees(tag: Tag) extends Table[IssueAssignee](tag, "ISSUE_ASSIGNEE") with IssueTemplate {
|
||||||
|
val assigneeUserName = column[String]("ASSIGNEE_USER_NAME")
|
||||||
|
def * =
|
||||||
|
(userName, repositoryName, issueId, assigneeUserName).mapTo[IssueAssignee]
|
||||||
|
|
||||||
|
def byPrimaryKey(owner: String, repository: String, issueId: Int, assigneeUserName: String) = {
|
||||||
|
byIssue(owner, repository, issueId) && this.assigneeUserName === assigneeUserName.bind
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case class IssueAssignee(
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
issueId: Int,
|
||||||
|
assigneeUserName: String
|
||||||
|
)
|
||||||
30
src/main/scala/gitbucket/core/model/IssueCustomFields.scala
Normal file
30
src/main/scala/gitbucket/core/model/IssueCustomFields.scala
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package gitbucket.core.model
|
||||||
|
|
||||||
|
trait IssueCustomFieldComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.api._
|
||||||
|
import self._
|
||||||
|
|
||||||
|
lazy val IssueCustomFields = TableQuery[IssueCustomFields]
|
||||||
|
|
||||||
|
class IssueCustomFields(tag: Tag) extends Table[IssueCustomField](tag, "ISSUE_CUSTOM_FIELD") {
|
||||||
|
val userName = column[String]("USER_NAME", O.PrimaryKey)
|
||||||
|
val repositoryName = column[String]("REPOSITORY_NAME", O.PrimaryKey)
|
||||||
|
val issueId = column[Int]("ISSUE_ID", O.PrimaryKey)
|
||||||
|
val fieldId = column[Int]("FIELD_ID", O.PrimaryKey)
|
||||||
|
val value = column[String]("VALUE")
|
||||||
|
def * =
|
||||||
|
(userName, repositoryName, issueId, fieldId, value).mapTo[IssueCustomField]
|
||||||
|
|
||||||
|
def byPrimaryKey(owner: String, repository: String, issueId: Int, fieldId: Int) = {
|
||||||
|
this.userName === owner.bind && this.repositoryName === repository.bind && this.issueId === issueId.bind && this.fieldId === fieldId.bind
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case class IssueCustomField(
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
issueId: Int,
|
||||||
|
fieldId: Int,
|
||||||
|
value: String
|
||||||
|
)
|
||||||
@@ -6,7 +6,7 @@ trait IssueLabelComponent extends TemplateComponent { self: Profile =>
|
|||||||
lazy val IssueLabels = TableQuery[IssueLabels]
|
lazy val IssueLabels = TableQuery[IssueLabels]
|
||||||
|
|
||||||
class IssueLabels(tag: Tag) extends Table[IssueLabel](tag, "ISSUE_LABEL") with IssueTemplate with LabelTemplate {
|
class IssueLabels(tag: Tag) extends Table[IssueLabel](tag, "ISSUE_LABEL") with IssueTemplate with LabelTemplate {
|
||||||
def * = (userName, repositoryName, issueId, labelId).<>(IssueLabel.tupled, IssueLabel.unapply)
|
def * = (userName, repositoryName, issueId, labelId).mapTo[IssueLabel]
|
||||||
def byPrimaryKey(owner: String, repository: String, issueId: Int, labelId: Int) =
|
def byPrimaryKey(owner: String, repository: String, issueId: Int, labelId: Int) =
|
||||||
byIssue(owner, repository, issueId) && (this.labelId === labelId.bind)
|
byIssue(owner, repository, issueId) && (this.labelId === labelId.bind)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ trait LabelComponent extends TemplateComponent { self: Profile =>
|
|||||||
override val labelId = column[Int]("LABEL_ID", O AutoInc)
|
override val labelId = column[Int]("LABEL_ID", O AutoInc)
|
||||||
override val labelName = column[String]("LABEL_NAME")
|
override val labelName = column[String]("LABEL_NAME")
|
||||||
val color = column[String]("COLOR")
|
val color = column[String]("COLOR")
|
||||||
def * = (userName, repositoryName, labelId, labelName, color).<>(Label.tupled, Label.unapply)
|
def * = (userName, repositoryName, labelId, labelName, color).mapTo[Label]
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, labelId: Int) = byLabel(owner, repository, labelId)
|
def byPrimaryKey(owner: String, repository: String, labelId: Int) = byLabel(owner, repository, labelId)
|
||||||
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], labelId: Rep[Int]) =
|
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], labelId: Rep[Int]) =
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ trait MilestoneComponent extends TemplateComponent { self: Profile =>
|
|||||||
val dueDate = column[Option[java.util.Date]]("DUE_DATE")
|
val dueDate = column[Option[java.util.Date]]("DUE_DATE")
|
||||||
val closedDate = column[Option[java.util.Date]]("CLOSED_DATE")
|
val closedDate = column[Option[java.util.Date]]("CLOSED_DATE")
|
||||||
def * =
|
def * =
|
||||||
(userName, repositoryName, milestoneId, title, description, dueDate, closedDate)
|
(userName, repositoryName, milestoneId, title, description, dueDate, closedDate).mapTo[Milestone]
|
||||||
.<>(Milestone.tupled, Milestone.unapply)
|
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) = byMilestone(owner, repository, milestoneId)
|
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) = byMilestone(owner, repository, milestoneId)
|
||||||
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], milestoneId: Rep[Int]) =
|
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], milestoneId: Rep[Int]) =
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ trait PriorityComponent extends TemplateComponent { self: Profile =>
|
|||||||
val isDefault = column[Boolean]("IS_DEFAULT")
|
val isDefault = column[Boolean]("IS_DEFAULT")
|
||||||
val color = column[String]("COLOR")
|
val color = column[String]("COLOR")
|
||||||
def * =
|
def * =
|
||||||
(userName, repositoryName, priorityId, priorityName, description.?, isDefault, ordering, color)
|
(userName, repositoryName, priorityId, priorityName, description.?, isDefault, ordering, color).mapTo[Priority]
|
||||||
.<>(Priority.tupled, Priority.unapply)
|
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, priorityId: Int) = byPriority(owner, repository, priorityId)
|
def byPrimaryKey(owner: String, repository: String, priorityId: Int) = byPriority(owner, repository, priorityId)
|
||||||
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], priorityId: Rep[Int]) =
|
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], priorityId: Rep[Int]) =
|
||||||
|
|||||||
@@ -73,5 +73,8 @@ trait CoreProfile
|
|||||||
with ReleaseAssetComponent
|
with ReleaseAssetComponent
|
||||||
with AccountExtraMailAddressComponent
|
with AccountExtraMailAddressComponent
|
||||||
with AccountPreferenceComponent
|
with AccountPreferenceComponent
|
||||||
|
with CustomFieldComponent
|
||||||
|
with IssueCustomFieldComponent
|
||||||
|
with IssueAssigneeComponent
|
||||||
|
|
||||||
object Profile extends CoreProfile
|
object Profile extends CoreProfile
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ trait ProtectedBranchComponent extends TemplateComponent { self: Profile =>
|
|||||||
lazy val ProtectedBranches = TableQuery[ProtectedBranches]
|
lazy val ProtectedBranches = TableQuery[ProtectedBranches]
|
||||||
class ProtectedBranches(tag: Tag) extends Table[ProtectedBranch](tag, "PROTECTED_BRANCH") with BranchTemplate {
|
class ProtectedBranches(tag: Tag) extends Table[ProtectedBranch](tag, "PROTECTED_BRANCH") with BranchTemplate {
|
||||||
val statusCheckAdmin = column[Boolean]("STATUS_CHECK_ADMIN")
|
val statusCheckAdmin = column[Boolean]("STATUS_CHECK_ADMIN")
|
||||||
def * = (userName, repositoryName, branch, statusCheckAdmin).<>(ProtectedBranch.tupled, ProtectedBranch.unapply)
|
def * = (userName, repositoryName, branch, statusCheckAdmin).mapTo[ProtectedBranch]
|
||||||
def byPrimaryKey(userName: String, repositoryName: String, branch: String) =
|
def byPrimaryKey(userName: String, repositoryName: String, branch: String) =
|
||||||
byBranch(userName, repositoryName, branch)
|
byBranch(userName, repositoryName, branch)
|
||||||
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], branch: Rep[String]) =
|
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], branch: Rep[String]) =
|
||||||
@@ -20,7 +20,7 @@ trait ProtectedBranchComponent extends TemplateComponent { self: Profile =>
|
|||||||
with BranchTemplate {
|
with BranchTemplate {
|
||||||
val context = column[String]("CONTEXT")
|
val context = column[String]("CONTEXT")
|
||||||
def * =
|
def * =
|
||||||
(userName, repositoryName, branch, context).<>(ProtectedBranchContext.tupled, ProtectedBranchContext.unapply)
|
(userName, repositoryName, branch, context).mapTo[ProtectedBranchContext]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ trait PullRequestComponent extends TemplateComponent { self: Profile =>
|
|||||||
commitIdFrom,
|
commitIdFrom,
|
||||||
commitIdTo,
|
commitIdTo,
|
||||||
isDraft
|
isDraft
|
||||||
).<>(PullRequest.tupled, PullRequest.unapply)
|
).mapTo[PullRequest]
|
||||||
|
|
||||||
def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) =
|
def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) =
|
||||||
byIssue(userName, repositoryName, issueId)
|
byIssue(userName, repositoryName, issueId)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ trait ReleaseAssetComponent extends TemplateComponent { self: Profile =>
|
|||||||
|
|
||||||
def * =
|
def * =
|
||||||
(userName, repositoryName, tag, releaseAssetId, fileName, label, size, uploader, registeredDate, updatedDate)
|
(userName, repositoryName, tag, releaseAssetId, fileName, label, size, uploader, registeredDate, updatedDate)
|
||||||
.<>(ReleaseAsset.tupled, ReleaseAsset.unapply)
|
.mapTo[ReleaseAsset]
|
||||||
def byPrimaryKey(owner: String, repository: String, tag: String, fileName: String) =
|
def byPrimaryKey(owner: String, repository: String, tag: String, fileName: String) =
|
||||||
byTag(owner, repository, tag) && (this.fileName === fileName.bind)
|
byTag(owner, repository, tag) && (this.fileName === fileName.bind)
|
||||||
def byTag(owner: String, repository: String, tag: String) =
|
def byTag(owner: String, repository: String, tag: String) =
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ trait ReleaseTagComponent extends TemplateComponent { self: Profile =>
|
|||||||
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
|
|
||||||
def * =
|
def * =
|
||||||
(userName, repositoryName, name, tag, author, content, registeredDate, updatedDate)
|
(userName, repositoryName, name, tag, author, content, registeredDate, updatedDate).mapTo[ReleaseTag]
|
||||||
.<>(ReleaseTag.tupled, ReleaseTag.unapply)
|
|
||||||
def byPrimaryKey(owner: String, repository: String, tag: String) = byTag(owner, repository, tag)
|
def byPrimaryKey(owner: String, repository: String, tag: String) = byTag(owner, repository, tag)
|
||||||
def byTag(owner: String, repository: String, tag: String) =
|
def byTag(owner: String, repository: String, tag: String) =
|
||||||
byRepository(owner, repository) && (this.tag === tag.bind)
|
byRepository(owner, repository) && (this.tag === tag.bind)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user