Compare commits

...

1107 Commits

Author SHA1 Message Date
takezoe
a791e937b6 Support for revert pull request 2025-08-13 08:06:05 +09:00
Scala Steward
f7027e57df Update HikariCP to 7.0.1 2025-08-09 12:01:30 +09:00
Scala Steward
6a4719469d Update tika-core to 3.2.2 2025-08-08 19:03:31 +09:00
Scala Steward
6ebc865ba5 Update sbt, sbt-dependency-tree, ... to 1.11.4 2025-08-05 07:04:59 +09:00
Naoki Takezoe
0c1e8b932b Reject direct push to branch if branch protection is enabled (#3791) 2025-08-03 11:58:28 +09:00
scala-steward-bot
fda67a32e2 Update scalafmt-core to 3.9.9 (#3815) 2025-08-03 01:31:06 +09:00
Scala Steward
14d7e9ee90 Update commons-net to 3.12.0 2025-08-02 06:56:11 +09:00
Naoki Takezoe
b7b7322cce Fix branch selector in repository viewer (#3813) 2025-08-01 02:33:05 +09:00
Scala Steward
5eb44398d0 Update oauth2-oidc-sdk to 11.27 2025-07-30 10:09:17 +09:00
Scala Steward
be7bb255c3 Update commons-compress to 1.28.0 2025-07-30 09:54:03 +09:00
Scala Steward
cb9522d416 Update github-api to 1.329 2025-07-30 06:56:36 +09:00
Scala Steward
d80afb473b Update scala3-library to 3.7.2 2025-07-30 06:49:49 +09:00
Scala Steward
607d85c661 Update HikariCP to 7.0.0 2025-07-29 05:59:20 +09:00
Scala Steward
a5fab3bc96 Update oauth2-oidc-sdk to 11.26.1 2025-07-25 18:55:51 +09:00
Scala Steward
eb403ada58 Update HikariCP to 6.3.2 2025-07-24 17:34:00 +09:00
Naoki Takezoe
911c102f39 Improve logging in initialization process (#3804) 2025-07-21 12:10:56 +09:00
Naoki Takezoe
bf23e854f8 Exclude sshd-spring-sftp (#3803) 2025-07-21 11:58:22 +09:00
Scala Steward
52427c0a1e Update HikariCP to 6.3.1 2025-07-21 06:15:54 +09:00
Naoki Takezoe
d8e5ac585c Disable blank issue (#3801) 2025-07-20 10:52:14 +09:00
Naoki Takezoe
2fbeef73b0 Move issue_template.yml to .github directory (#3800) 2025-07-20 10:42:25 +09:00
Naoki Takezoe
15e39572dd Update issue template (#3799) 2025-07-20 10:33:40 +09:00
Scala Steward
9eac4f42c5 Update commons-io to 2.20.0 2025-07-20 06:04:11 +09:00
scala-steward-bot
01d18bb5c3 Update typesafe:config to 1.4.4 (#3796) 2025-07-13 08:52:18 +09:00
scala-steward-bot
00258e9125 Update tika-core to 3.2.1 (#3795) 2025-07-13 08:52:02 +09:00
Scala Steward
046b337337 Update java-diff-utils to 4.16 2025-07-08 17:02:18 +09:00
Naoki Takezoe
46cc7b6fd3 Update H2 database migration guide (#3793) 2025-07-06 21:24:28 +09:00
Scala Steward
59344b4f05 Update sbt, sbt-dependency-tree, ... to 1.11.3 2025-07-06 07:11:59 +09:00
Naoki Takezoe
c4d8af02b2 Fix wrong redirect after sign-in when user-defined CSS is used (#3789) 2025-07-05 12:08:20 +09:00
Scala Steward
a10bc3687a Update sbt-twirl, twirl-api to 2.0.9 2025-07-01 06:36:38 +09:00
Scala Steward
b0d21dee42 Update sbt-scalafmt to 2.5.5 2025-06-30 17:35:49 +09:00
Naoki Takezoe
13ea0e7507 Update release procedure doc (#3785) 2025-06-29 13:57:16 +09:00
takezoe
d66fdaede5 Update README and CHANGELOG 2025-06-29 13:33:29 +09:00
takezoe
d6217d89eb Update README and CHANGELOG 2025-06-29 13:01:17 +09:00
Naoki Takezoe
c99ff1cf0f Release 4.43.0 (#3784) 2025-06-29 13:00:21 +09:00
Scala Steward
001b9ae2ae Update mysql, postgresql to 1.21.3 2025-06-29 07:49:01 +09:00
Scala Steward
f63493f1c0 Update scalafmt-core to 3.9.8 2025-06-29 07:48:45 +09:00
Naoki Takezoe
c9095722f8 Redirect from sign-in page to top page if already authenticated (#3781) 2025-06-22 21:23:15 +09:00
Naoki Takezoe
b9d2efa582 UI: Fix bottom margin of branch deletion box in pull request (#3780) 2025-06-21 17:23:23 +09:00
Naoki Takezoe
9c2e09020a Fix warnings in service test cases (#3779) 2025-06-21 17:01:54 +09:00
Naoki Takezoe
1ffcf8c1e9 Bump h2 to 2.3.232 (#3746) 2025-06-21 13:03:48 +09:00
Naoki Takezoe
0124091840 Fix the issue template (#3778) 2025-06-21 12:59:50 +09:00
Naoki Takezoe
2a28a7b35b Migrate templates for issue request (#3777) 2025-06-21 12:48:06 +09:00
Scala Steward
2a68ffc8dc Update mysql, postgresql to 1.21.2 2025-06-19 20:42:59 +09:00
Scala Steward
6b47c49cdd Update oauth2-oidc-sdk to 11.26 2025-06-18 05:15:40 +09:00
Scala Steward
b634967776 Update postgresql to 42.7.7 2025-06-11 19:52:43 +09:00
Scala Steward
172bed760d Update sbt, sbt-dependency-tree, ... to 1.11.2 2025-06-08 07:42:23 +09:00
Naoki Takezoe
1b7eb69083 Migrate from OSSRH to Central Portal (#3770) 2025-06-08 00:17:29 +09:00
scala-steward-bot
185c01db99 Update sbt, sbt-dependency-tree, ... to 1.11.1 (#3767) 2025-06-07 23:56:26 +09:00
Scala Steward
ab548d8c25 Update scala3-library to 3.7.1 2025-06-03 05:24:59 +09:00
kenji yoshida
983975620b Merge pull request #3766 from scala-steward-bot/update/scalafmt-core-3.9.7
Update scalafmt-core to 3.9.7
2025-06-01 08:27:00 +09:00
Scala Steward
b512b08256 Add 'Reformat with scalafmt 3.9.7' to .git-blame-ignore-revs 2025-05-30 14:45:26 +00:00
Scala Steward
a54fb4960f Reformat with scalafmt 3.9.7
Executed command: scalafmt --non-interactive
2025-05-30 14:45:26 +00:00
Scala Steward
93de53d717 Update scalafmt-core to 3.9.7 2025-05-30 14:45:19 +00:00
Scala Steward
f262c0a9eb Update mysql, postgresql to 1.21.1 2025-05-30 17:44:07 +09:00
Scala Steward
e5d15569df Update postgresql to 42.7.6 2025-05-28 20:41:26 +09:00
Scala Steward
369b08eae3 Update tika-core to 3.2.0 2025-05-27 06:49:24 +09:00
Scala Steward
8e6fcb022b Update sbt, sbt-dependency-tree, ... to 1.11.0 2025-05-24 15:52:45 +09:00
Scala Steward
456b1f6571 Update org.eclipse.jgit.archive, ... to 6.10.1.202505221210-r 2025-05-23 11:28:36 +09:00
Scala Steward
6e459ad225 Update oauth2-oidc-sdk to 11.25 2025-05-23 05:51:55 +09:00
Scala Steward
cece4c1c7d Update mockito-core to 5.18.0 2025-05-21 06:47:39 +09:00
Scala Steward
42e7a9fa9f Update ec4j-core to 1.1.1 2025-05-18 06:45:58 +09:00
Scala Steward
f9510aba8e Update scalafmt-core to 3.9.6 2025-05-15 11:47:04 +09:00
Scala Steward
8a7d719025 Update oauth2-oidc-sdk to 11.24 2025-05-07 06:53:07 +09:00
Scala Steward
1293a21450 Update scala3-library to 3.7.0 2025-05-06 06:34:29 +09:00
scala-steward-bot
65dd597ab7 Update scalatra-forms-javax, ... to 3.1.2 (#3752) 2025-05-03 18:42:17 +09:00
Scala Steward
e145b5151e Update scalafmt-core to 3.9.5 2025-04-30 06:38:32 +09:00
Scala Steward
b9684c277b Update mysql, postgresql to 1.21.0 2025-04-24 11:47:26 +09:00
Scala Steward
4accb77533 Update commons-io to 2.19.0 2025-04-12 14:10:18 +09:00
Scala Steward
9eef961025 Update mockito-core to 5.17.0 2025-04-05 07:10:28 +09:00
Scala Steward
546b40cdd1 Update HikariCP to 6.3.0 2025-03-25 06:24:54 +09:00
Scala Steward
274a08c14c Update logback-classic to 1.5.18 2025-03-20 06:35:18 +09:00
Scala Steward
eed4b51189 Update jetty-http, jetty-io, jetty-runner, ... to 10.0.25 2025-03-18 08:00:26 +09:00
Scala Steward
5c2f84367b Update sbt, sbt-dependency-tree, ... to 1.10.11 2025-03-17 19:21:55 +09:00
Scala Steward
d5b625e43f Update mockito-core to 5.16.1 2025-03-16 07:10:45 +09:00
scala-steward-bot
27f9e3dec9 Update scalafmt-core to 3.9.4 (#3737) 2025-03-15 12:53:33 +09:00
Scala Steward
00ef4db9a7 Update testcontainers-scala to 0.43.0 2025-03-12 19:32:26 +09:00
Scala Steward
bf4f814389 Update scalafmt-core to 3.9.3 2025-03-07 19:13:22 +09:00
Scala Steward
23e45afd7f Update scala3-library to 3.6.4 2025-03-07 19:12:26 +09:00
Scala Steward
bfb02eef62 Update mysql, postgresql to 1.20.6 2025-03-05 06:57:03 +09:00
Scala Steward
c129aae73a Update sbt, sbt-dependency-tree, ... to 1.10.10 2025-03-04 16:01:56 +09:00
Scala Steward
a955856cef Update sbt, sbt-dependency-tree, ... to 1.10.9 2025-03-04 07:19:27 +09:00
Scala Steward
a43a3fa55c Update sbt, sbt-dependency-tree, ... to 1.10.8 2025-03-03 20:03:42 +09:00
Scala Steward
a6254ab955 Update mockito-core to 5.16.0 2025-03-03 20:03:13 +09:00
scala-steward-bot
b505c3dc12 Update scalafmt-core to 3.9.2 (#3726) 2025-03-01 15:35:33 +09:00
mnival
9d69b9e980 Add bearer authentification (#3725)
Co-authored-by: mnival <extern.nival_michael@allianz.com>
2025-02-28 09:30:45 +09:00
Scala Steward
44b2320644 Update scalafmt-core to 3.9.1 2025-02-26 19:12:54 +09:00
Scala Steward
8fb9643ea5 Update oauth2-oidc-sdk to 11.23.1 2025-02-26 19:12:31 +09:00
Scala Steward
10ea988298 Update logback-classic to 1.5.17 2025-02-26 04:00:17 +09:00
Scala Steward
7896945519 Update apache-sshd to 2.15.0 2025-02-25 03:36:14 +09:00
Scala Steward
210342d2bc Update sbt-twirl, twirl-api to 2.0.8 2025-02-24 06:45:06 +09:00
Scala Steward
fdacea858b Update sbt-scoverage to 2.3.1 2025-02-21 06:19:43 +09:00
Scala Steward
6825028d37 Update mysql, postgresql to 1.20.5 2025-02-20 07:54:32 +09:00
Scala Steward
2089882d41 Update oauth2-oidc-sdk to 11.23 2025-02-18 06:52:15 +09:00
Scala Steward
8e1d938155 Update github-api to 1.327 2025-02-13 23:30:25 +09:00
Scala Steward
39eb4cef04 Update oauth2-oidc-sdk to 11.22.2 2025-02-13 13:33:44 +09:00
Scala Steward
d4e3adafa6 Update oauth2-oidc-sdk to 11.22.1 2025-02-09 17:45:03 +09:00
Scala Steward
a7b8326499 Update oauth2-oidc-sdk to 11.22 2025-02-07 04:19:11 +09:00
Naoki Takezoe
249f8738d3 Update command to run GitBucket in debug.md (#3708) 2025-02-05 22:52:49 +09:00
Scala Steward
fefe6ef74f Update scalafmt-core to 3.8.6 2025-02-01 17:22:55 +09:00
Scala Steward
9ca6cd1d90 Update tika-core to 3.1.0 2025-02-01 07:18:24 +09:00
Scala Steward
bff7b7c460 Update oauth2-oidc-sdk to 11.21.3 2025-02-01 07:18:01 +09:00
Scala Steward
cfff79758b Update oauth2-oidc-sdk to 11.21.2 2025-01-22 03:38:05 +09:00
Scala Steward
ded8ceb2c6 Update sbt-assembly to 2.3.1 2025-01-21 08:50:51 +09:00
Scala Steward
c502ebfc16 Update testcontainers-scala to 0.41.8 2025-01-21 08:13:08 +09:00
Naoki Takezoe
d3268265cf Release GitBucket 4.42.1 (#3699) 2025-01-20 10:16:31 +09:00
Naoki Takezoe
5eaf59eebb Remove unnecessary setup code for SSL in LDAPUtil (#3697) 2025-01-20 09:41:33 +09:00
Scala Steward
d6d47aa977 Update scalafmt-core to 3.8.5 2025-01-20 07:19:49 +09:00
Naoki Takezoe
dc052e05ce Setup sbt explicitly in GitHub Actions (#3698) 2025-01-20 02:29:51 +09:00
Scala Steward
afb145ca7c Update sbt-scalafmt to 2.5.4 2025-01-17 07:26:49 +09:00
Scala Steward
a8beed33e0 Update scala3-library to 3.6.3 2025-01-16 20:00:10 +09:00
Scala Steward
488599dba5 Update postgresql to 42.7.5 2025-01-15 05:45:47 +09:00
Scala Steward
ef0d08a917 Update sbt-scoverage to 2.3.0 2025-01-14 07:42:48 +09:00
Scala Steward
9fa0d03c99 Update sbt-scalafmt to 2.5.3 2025-01-14 07:36:37 +09:00
kenji yoshida
15b6c5952b update build status badge in README 2025-01-11 16:06:43 +09:00
Scala Steward
cb75e9d312 Update oauth2-oidc-sdk to 11.21 2025-01-11 07:04:42 +09:00
Scala Steward
d542ee3528 Update scala-library to 2.13.16 2025-01-11 06:55:05 +09:00
Scala Steward
608a59cbfd Update oauth2-oidc-sdk to 11.20.2 2025-01-10 07:15:27 +09:00
Scala Steward
768e3a5c91 Update logback-classic to 1.5.16 2025-01-06 10:02:28 +09:00
Naoki Takezoe
f1fc794c0c Fix warnings in JGitUtil (#3683) 2025-01-05 14:35:50 +09:00
kenji yoshida
4cf924bee0 remove unused imports 2025-01-03 12:05:40 +09:00
kenji yoshida
8164efc720 remove unused import 2025-01-03 10:25:25 +09:00
Scala Steward
580a627d9d Update mockito-core to 5.15.2 2025-01-03 07:59:55 +09:00
Naoki Takezoe
1701916209 Update README and CHANGELOG for Java 17 requirement (#3679) 2025-01-02 02:17:06 +09:00
takezoe
811b2bff70 Update README.md and CHANGELOG.md 2024-12-30 05:52:06 +09:00
takezoe
9de9dd8940 Update README.md 2024-12-30 04:59:26 +09:00
Naoki Takezoe
572f83327f Release GitBucket 4.42.0 (#3678) 2024-12-30 04:56:10 +09:00
Naoki Takezoe
2afb37823b Increase max branch name length 100 -> 255 (#3676) 2024-12-30 04:36:24 +09:00
Naoki Takezoe
edc9720a88 Fix warnings in controllers (#3674) 2024-12-25 03:02:45 +09:00
Scala Steward
defc0fa041 Update sbt, sbt-dependency-tree, ... to 1.10.7 2024-12-23 12:51:33 +09:00
Naoki Takezoe
c14b3c5576 Fix warnings in ControllerBase (#3673) 2024-12-22 13:23:31 +09:00
Naoki Takezoe
10fc04cbc9 Return 400 error for invalid query string (#3672) 2024-12-22 12:48:39 +09:00
Scala Steward
67563a8805 Update logback-classic to 1.5.15 2024-12-22 07:13:09 +09:00
Naoki Takezoe
743bdab79b Fix wrong redirection when non-existent branch name is given as default branch (#3669) 2024-12-21 22:13:27 +09:00
Naoki Takezoe
a5a2e4732d Stabilize AccountServiceSpec (#3670) 2024-12-21 18:50:34 +09:00
Scala Steward
3a0cd5df62 Update scalatra-forms-javax, ... to 3.1.1 2024-12-21 14:43:49 +09:00
Naoki Takezoe
ad9a0afc9b Show branch errors when creating pull request (#3667) 2024-12-21 11:54:47 +09:00
Scala Steward
d2fc7a0642 Update logback-classic to 1.5.14 2024-12-20 13:44:08 +09:00
Naoki Takezoe
b1d4a18c9b Fix ref and ssh_url in WebHook payloads (#3656) 2024-12-19 15:19:42 +09:00
Scala Steward
fdfd8ec9b2 Update testcontainers-scala to 0.41.5 2024-12-19 13:31:22 +09:00
Scala Steward
396156c4e3 Update logback-classic to 1.5.13 2024-12-19 06:09:02 +09:00
Naoki Takezoe
8168580d60 Restore the original response of list-repository-tags API (#3662) 2024-12-16 00:27:56 +09:00
Naoki Takezoe
2abdd233e7 Apply user-defined CSS after plugins' JavaScript runs (#3661) 2024-12-15 12:30:07 +09:00
Naoki Takezoe
ef95ce99d2 Suppress Liquibase logs (#3660) 2024-12-14 14:49:38 +09:00
Scala Steward
3a6b2f6f4e Update sbt-pgp to 2.3.1 2024-12-11 07:09:14 +09:00
ziggystar
92304ac8c6 fix: make some methods call JGitUtil.getCommitLog with ObjectId instead of strings (#3653)
Co-authored-by: Thomas Geier <thomas.geier@solidat.de>
2024-12-10 08:25:38 +09:00
Scala Steward
a2242a3cb7 Update scala3-library to 3.6.2 2024-12-10 06:10:34 +09:00
ziggystar
64e8167fcb fix: calculate diffs between commits based on common ancestor; works for force push (#3647)
fixes #3476

Co-authored-by: Thomas Geier <thomas.geier@solidat.de>
2024-12-05 08:51:03 +09:00
Naoki Takezoe
06b93293a6 Update build.md about testing on Jetty from sbt (#3650) 2024-12-01 13:10:20 +09:00
Naoki Takezoe
3dcc0aee3c Use ContainerPlugin instead of JettyPlugin to run newer version of Jetty (#3649) 2024-12-01 12:49:14 +09:00
Scala Steward
c009a39dd7 Update sbt, sbt-dependency-tree, ... to 1.10.6 2024-12-01 07:45:38 +09:00
Scala Steward
b27e8ebb7e Update java-diff-utils to 4.15 2024-11-25 13:39:54 +09:00
Scala Steward
a690d43491 Update mysql, postgresql to 1.20.4 2024-11-21 06:36:53 +09:00
Scala Steward
86bfb68a0c Update commons-io to 2.18.0 2024-11-20 08:13:46 +09:00
Scala Steward
9469801d3d Update HikariCP to 6.2.1 2024-11-19 06:59:42 +09:00
Scala Steward
757a8399c1 Update HikariCP to 6.2.0 2024-11-17 15:49:50 +09:00
Scala Steward
ed00e613c3 Update json4s-jackson to 4.1.0-M8 2024-11-07 16:30:48 +09:00
Scala Steward
6e341116c1 Update HikariCP to 6.1.0 2024-11-06 13:54:48 +09:00
Scala Steward
9ccc2d0f97 Update sbt, sbt-dependency-tree, ... to 1.10.5 2024-11-04 09:16:17 +09:00
Scala Steward
72742306a0 Update sbt, sbt-dependency-tree, ... to 1.10.4 2024-10-30 09:50:35 +09:00
Scala Steward
47c6d61661 Update logback-classic to 1.5.12 2024-10-27 07:13:39 +09:00
Scala Steward
cfc444bcd2 Update sbt-license-report to 1.7.0 2024-10-24 05:24:38 +09:00
Scala Steward
a1f65258ea Update mysql, postgresql to 1.20.3 2024-10-23 10:22:47 +09:00
Scala Steward
5e3b97cf85 Update sbt, sbt-dependency-tree, ... to 1.10.3 2024-10-20 13:31:53 +09:00
kenji yoshida
209e1967d6 fail-fast: false 2024-10-20 13:23:32 +09:00
Scala Steward
4437a4e7a6 Update tika-core to 3.0.0 2024-10-20 09:31:44 +09:00
Scala Steward
e4d92bb494 Update scala3-library to 3.6.1 2024-10-19 19:27:45 +09:00
Scala Steward
d942c8f48a Update scala3-library to 3.6.0 2024-10-19 04:02:52 +09:00
Scala Steward
3a798e152f Update sbt-scoverage to 2.2.2 2024-10-19 04:02:29 +09:00
Scala Steward
91b862970f Update scala3-library to 3.5.2 2024-10-17 04:15:47 +09:00
Scala Steward
2d199e22e7 Update logback-classic to 1.5.11 2024-10-16 08:39:26 +09:00
Scala Steward
757da408d1 Update mockito-core to 5.14.2 2024-10-16 08:01:30 +09:00
Scala Steward
309d6e8b57 Update ec4j-core to 1.1.0 2024-10-13 07:55:33 +09:00
Scala Steward
ec0395a7f3 Update logback-classic to 1.5.10 2024-10-13 06:59:03 +09:00
Scala Steward
7cb4958ca0 Update oauth2-oidc-sdk to 11.20.1 2024-10-11 08:23:57 +09:00
Scala Steward
2d1c917a2c Update logback-classic to 1.5.9 2024-10-09 06:29:26 +09:00
Scala Steward
27dd5120dd Update sbt-assembly to 2.3.0 2024-10-07 12:21:35 +09:00
Scala Steward
9e0f8992c5 Update sbt-pgp to 2.3.0 2024-10-05 21:41:34 +09:00
Scala Steward
5f87a28da6 Update apache-sshd to 2.14.0 2024-10-03 08:07:53 +09:00
Scala Steward
25d5d5eee5 Update mysql, postgresql to 1.20.2 2024-10-01 12:31:19 +09:00
Scala Steward
ec9472b7cc Update mockito-core to 5.14.1 2024-10-01 06:58:02 +09:00
Scala Steward
b967fb93a7 Update oauth2-oidc-sdk to 11.20 2024-09-30 06:14:20 +09:00
Scala Steward
9d1bf3035b Update mockito-core to 5.14.0 2024-09-28 06:34:32 +09:00
Scala Steward
d6cedc2171 Update sbt-scoverage to 2.2.1 2024-09-26 06:39:12 +09:00
Scala Steward
8d8c78966a Update HikariCP to 6.0.0 2024-09-24 06:05:20 +09:00
Scala Steward
cbe1c1c9f6 Update ec4j-core to 1.0.0 2024-09-21 07:48:45 +09:00
Scala Steward
bf946960a7 Update scala-library to 2.13.15 2024-09-21 06:53:23 +09:00
Scala Steward
9677735542 Update github-api to 1.326 2024-09-19 09:30:09 +09:00
Scala Steward
e06c8fe5da Update scala3-library to 3.5.1 2024-09-19 09:27:27 +09:00
Scala Steward
d4ee6c9063 Update commons-io to 2.17.0 2024-09-19 09:26:32 +09:00
Scala Steward
1d0f079bd2 Update sbt, sbt-dependency-tree to 1.10.2 2024-09-16 20:05:08 +09:00
Scala Steward
7cc6972d83 Update github-api to 1.325 2024-09-14 06:52:27 +09:00
kenji yoshida
177da92b39 fix warning 2024-09-11 11:47:54 +09:00
Scala Steward
e1f433573b Update json4s-jackson to 4.1.0-M7 2024-09-10 08:08:14 +09:00
Scala Steward
cd958d7681 Update logback-classic to 1.5.8 2024-09-07 07:12:32 +09:00
Scala Steward
9c8e77f472 Update oauth2-oidc-sdk to 11.19.1 2024-09-06 10:46:21 +09:00
Scala Steward
bf7d3a8f0b Update sbt-scoverage to 2.2.0 2024-09-06 10:46:09 +09:00
Scala Steward
934e17666d Update jetty-http, jetty-io, jetty-security, ... to 10.0.24 2024-09-04 08:20:28 +09:00
Scala Steward
b20c4b3d7d Update oauth2-oidc-sdk to 11.19 2024-08-29 17:39:44 +09:00
Scala Steward
7c4e8b54d0 Update mockito-core to 5.13.0 2024-08-28 08:15:20 +09:00
Scala Steward
1e3794674b Update postgresql to 42.7.4 2024-08-23 10:01:12 +09:00
Scala Steward
5d5706451d Update sbt-scoverage to 2.1.1 2024-08-22 06:28:14 +09:00
Scala Steward
76e8d01846 Update oauth2-oidc-sdk to 11.18 2024-08-21 09:14:20 +09:00
Scala Steward
75e2883f61 Update jetty-http, jetty-io, jetty-security, ... to 10.0.23 2024-08-21 09:14:01 +09:00
Scala Steward
7e7cc1d4c7 Update commons-compress to 1.27.1 2024-08-21 06:25:57 +09:00
Scala Steward
d7623e8b7a Update github-api to 1.324 2024-08-19 19:45:55 +09:00
Scala Steward
7dd1470cd4 Update oauth2-oidc-sdk to 11.17 2024-08-19 06:15:01 +09:00
Scala Steward
9fb8d6fc66 Update oauth2-oidc-sdk to 11.16.1 2024-08-17 06:15:36 +09:00
Scala Steward
4f1869817c Update oauth2-oidc-sdk to 11.16 2024-08-16 07:07:35 +09:00
Scala Steward
6be269c388 Update logback-classic to 1.5.7 2024-08-16 06:32:52 +09:00
Scala Steward
af857853cb Update oauth2-oidc-sdk to 11.15 2024-08-14 07:45:41 +09:00
Scala Steward
1a664c2b6a Update scala3-library to 3.5.0 2024-08-13 06:17:59 +09:00
scala-steward-bot
1feb33fc19 Update commons-compress to 1.27.0 (#3574)
* Update commons-compress to 1.27.0

* Update build.sbt

---------

Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2024-08-11 11:32:52 +09:00
Scala Steward
4fc1d9c3b6 Update oauth2-oidc-sdk to 11.14 2024-08-02 05:26:05 +09:00
Scala Steward
7eb77908d4 Update apache-sshd to 2.13.2 2024-08-01 05:58:36 +09:00
Scala Steward
54f9d01c42 Update mysql, postgresql to 1.20.1 2024-08-01 05:57:46 +09:00
Scala Steward
08154af7b1 Update scalafmt-core to 3.8.3 2024-07-27 07:57:11 +09:00
Scala Steward
e7ab376a34 Update mysql, postgresql to 1.20.0 2024-07-18 05:58:08 +09:00
Scala Steward
a680398c54 Update sbt, sbt-dependency-tree to 1.10.1 2024-07-08 08:49:28 +09:00
Scala Steward
6acf1e68ca Update jetty-http, jetty-io, jetty-security, ... to 10.0.22 2024-07-05 16:12:38 +09:00
Scala Steward
fc35e7b83d Update sbt-scoverage to 2.1.0 2024-07-04 02:31:10 +09:00
Scala Steward
1ae6fc7e9e Update github-api to 1.323 2024-07-02 06:12:05 +09:00
scala-steward-bot
884f63e6f4 Update scalatra-forms-javax, ... to 3.1.0 (#3545)
Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2024-06-28 09:19:57 +09:00
Scala Steward
4d3e34af8b Update sbt-twirl, twirl-api to 2.0.7 2024-06-28 09:01:31 +09:00
Scala Steward
54426bb456 Update oauth2-oidc-sdk to 11.13 2024-06-26 13:23:20 +09:00
Scala Steward
c86b72bf6b Update oauth2-oidc-sdk to 11.12.1 2024-06-25 19:18:52 +09:00
Scala Steward
e6a5911a39 Update apache-sshd to 2.13.1 2024-06-25 07:08:53 +09:00
Scala Steward
6ea77fa73e Update github-api to 1.322 2024-06-21 19:09:21 +09:00
Scala Steward
32d0b94a7a Update apache-sshd to 2.13.0 2024-06-20 03:37:43 +09:00
scala-steward-bot
4f770adb35 Update sbt-twirl, twirl-api to 2.0.6 (#3553) 2024-06-17 21:32:10 +09:00
kenji yoshida
361f92a08d -Xsource:3-cross 2024-06-17 15:16:42 +09:00
xuwei-k
c2068f58e7 prepare Scala 3 2024-06-17 15:07:53 +09:00
kenji yoshida
67dd604469 Merge pull request #3549 from scala-steward-bot/update/scalafmt-core-3.8.2
Update scalafmt-core to 3.8.2
2024-06-17 11:23:22 +09:00
Scala Steward
d1a2c23cf3 Update json4s-jackson to 4.1.0-M6 2024-06-17 01:26:00 +09:00
Scala Steward
262500508c Add 'Reformat with scalafmt 3.8.2' to .git-blame-ignore-revs 2024-06-14 16:40:55 +00:00
Scala Steward
f1360f44c6 Reformat with scalafmt 3.8.2
Executed command: scalafmt --non-interactive
2024-06-14 16:40:55 +00:00
Scala Steward
1c818f890a Update scalafmt-core to 3.8.2 2024-06-14 16:40:45 +00:00
Scala Steward
16f146b660 Update testcontainers-scala to 0.41.4 2024-06-14 06:12:35 +09:00
Scala Steward
6166eaf0c7 Update org.eclipse.jgit.archive, ... to 6.10.0.202406032230-r 2024-06-13 09:43:42 +09:00
Scala Steward
ad4312cedb Update commons-net to 3.11.1 2024-06-11 05:46:46 +09:00
Scala Steward
15083a5aac Update commons-net to 3.11.0 2024-06-01 07:26:44 +09:00
Scala Steward
9ae420c553 Update commons-compress to 1.26.2 2024-05-25 05:08:23 +09:00
takezoe
4115ea4ab6 Update ChangeLog of 4.41.0 2024-05-18 17:26:23 +09:00
takezoe
024ac313ae Update ChangeLog of 4.41.0 2024-05-18 17:12:06 +09:00
takezoe
598f289311 Update README 2024-05-18 16:16:02 +09:00
Naoki Takezoe
447288db9d Release GitBucket 4.41.0 (#3540) 2024-05-18 16:14:52 +09:00
Naoki Takezoe
2b8c2a5c06 Upgrade json4s to 4.1.0-M5 (#3537) 2024-05-18 11:54:13 +09:00
scala-steward-bot
6fd3a73268 Update mariadb-java-client to 2.7.12 (#3491) 2024-05-18 11:53:10 +09:00
scala-steward-bot
4536e42949 Update sbt-twirl, twirl-api to 2.0.5 (#3525) 2024-05-18 11:52:46 +09:00
scala-steward-bot
fc575388f1 Update solidbase to 1.1.0 (#3538) 2024-05-18 11:48:23 +09:00
Scala Steward
1044d1cc32 Update oauth2-oidc-sdk to 11.12 2024-05-17 21:02:48 +09:00
Scala Steward
253eabf2f2 Update oauth2-oidc-sdk to 11.11 2024-05-17 03:57:20 +09:00
Scala Steward
8219d57b92 Update jetty-http, jetty-io, jetty-security, ... to 10.0.21 2024-05-17 03:53:28 +09:00
Brian Wignall
89381d3314 Fix typo (#3533) 2024-05-15 23:42:48 +09:00
Scala Steward
2e1037e107 Update scala3-library to 3.4.2 2024-05-14 07:00:27 +09:00
Scala Steward
0a77c71278 Update mockito-core to 5.12.0 2024-05-12 07:32:14 +09:00
Scala Steward
275101d11b Update mysql, postgresql to 1.19.8 2024-05-09 11:05:59 +09:00
Scala Steward
bfd7f3b2bc Update sbt, sbt-dependency-tree to 1.10.0 2024-05-06 13:36:40 +09:00
Scala Steward
21fcedf000 Update sbt-scoverage to 2.0.12 2024-05-03 05:13:46 +09:00
Scala Steward
d963070f73 Update scala-library to 2.13.14 2024-04-30 08:05:56 +09:00
Scala Steward
8174c89f9e Update sbt-twirl, twirl-api to 1.6.6 2024-04-26 09:03:01 +09:00
Scala Steward
5bdc74f0a6 Update logback-classic to 1.5.6 2024-04-18 06:50:24 +09:00
Scala Steward
b259386b67 Update logback-classic to 1.5.4 2024-04-10 06:28:37 +09:00
Scala Steward
984b52e7ec Update commons-io to 2.16.1 2024-04-09 08:25:08 +09:00
Scala Steward
d36ef805f6 Update tika-core to 2.9.2 2024-04-03 03:54:23 +09:00
Scala Steward
02bdbd281b Update scalafmt-core to 3.8.1 2024-03-30 07:45:17 +09:00
Scala Steward
b3cca9ea91 Update commons-io to 2.16.0 2024-03-29 09:12:29 +09:00
Scala Steward
7409c08122 Update scala3-library to 3.4.1 2024-03-28 03:43:57 +09:00
Scala Steward
339b54cd4b Update github-api to 1.321 2024-03-21 12:37:31 +09:00
Scala Steward
1bbdf4917b Update github-api to 1.320 2024-03-19 07:43:04 +09:00
Scala Steward
465ed988a9 Update postgresql to 42.7.3 2024-03-15 06:35:07 +09:00
Scala Steward
d5d7fe47d5 Update sbt-assembly to 2.2.0 2024-03-14 15:51:43 +09:00
Scala Steward
81d14dfaf2 Update commons-compress to 1.26.1 2024-03-09 12:29:36 +09:00
Scala Steward
302da30746 Update org.eclipse.jgit.archive, ... to 6.9.0.202403050737-r 2024-03-09 02:29:35 +09:00
Scala Steward
e9110aac80 Update logback-classic to 1.5.3 2024-03-06 06:10:57 +09:00
Scala Steward
6d104bd585 Update mysql, postgresql to 1.19.7 2024-03-06 06:06:10 +09:00
Scala Steward
7c47462de8 Update logback-classic to 1.5.2 2024-03-03 08:22:05 +09:00
Scala Steward
cc8b83cbc5 Update mockito-core to 5.11.0 2024-03-01 20:12:40 +09:00
Scala Steward
07decd00a0 Update logback-classic to 1.5.1 2024-02-29 09:53:45 +09:00
Scala Steward
7c3e82f4dd Update sbt-twirl, twirl-api to 1.6.5 2024-02-28 00:39:35 +09:00
Scala Steward
95c31dd7b7 Update oauth2-oidc-sdk to 11.10.1 2024-02-27 03:36:40 +09:00
Scala Steward
5ea905e3a2 Update sbt-scoverage to 2.0.11 2024-02-24 19:42:15 +09:00
Scala Steward
e40d1f42c7 Update sbt, sbt-dependency-tree to 1.9.9 2024-02-23 15:42:31 +09:00
Scala Steward
aa00351606 Update scala-library to 2.13.13 2024-02-23 08:09:31 +09:00
Scala Steward
6311a1f146 Update mysql, postgresql to 1.19.6 2024-02-22 18:59:34 +09:00
Scala Steward
1517e1f580 Update github-api to 1.319 2024-02-21 22:16:54 +09:00
Scala Steward
833f3584c2 Update postgresql to 42.7.2 2024-02-21 07:05:16 +09:00
Scala Steward
cdc67bffcb Update commons-compress to 1.26.0 2024-02-19 12:01:40 +09:00
Scala Steward
52794aa9ea Update testcontainers-scala to 0.41.3 2024-02-19 01:59:15 +09:00
Scala Steward
9ea3670a56 Update oauth2-oidc-sdk to 11.10 2024-02-18 20:51:42 +09:00
Scala Steward
652ec3e029 Update logback-classic to 1.5.0 2024-02-17 12:19:47 +09:00
Scala Steward
b543bae958 Update apache-sshd to 2.12.1 2024-02-17 07:34:44 +09:00
Scala Steward
4f574cdbcd Update scala3-library to 3.4.0 2024-02-15 06:54:28 +09:00
Scala Steward
29fc2a666b Update sbt-scoverage to 2.0.10 2024-02-15 02:03:44 +09:00
Scala Steward
4498c016a4 Update scala3-library to 3.3.2 2024-02-15 01:51:14 +09:00
Scala Steward
31a1d46175 Update mysql, postgresql to 1.19.5 2024-02-09 04:43:08 +09:00
Scala Steward
e3904ebdfe Update jetty-http, jetty-io, jetty-security, ... to 10.0.20 2024-02-01 03:11:08 +09:00
Scala Steward
6e5ffdf658 Update testcontainers-scala to 0.41.2 2024-01-29 13:46:01 +09:00
Scala Steward
5d0531f00d Update markedj to 1.0.20 2024-01-27 14:06:49 +09:00
Scala Steward
01ea533b97 Update mysql, postgresql to 1.19.4 2024-01-26 04:19:39 +09:00
Scala Steward
86fc492668 Update mockito-core to 5.10.0 2024-01-25 06:51:12 +09:00
dependabot[bot]
3a78356019 Bump actions/cache from 3 to 4
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-22 12:34:32 +09:00
Scala Steward
44f7931ae6 Update apache-sshd to 2.12.0 2024-01-19 13:05:46 +09:00
Scala Steward
7094f99a85 Update mockito-core to 5.9.0 2024-01-15 08:08:49 +09:00
Scala Steward
550c4a6e60 Update java-semver to 0.10.2 2024-01-15 08:08:03 +09:00
Naoki Takezoe
64aeb422c8 Adjust the default branch automatically when cloning external repo (#3466) 2024-01-14 16:17:29 +09:00
Scala Steward
c2265dc44c Update java-semver to 0.10.1 2024-01-13 07:43:41 +09:00
Scala Steward
507085cd56 Update java-semver to 0.10.0 2024-01-11 02:38:03 +09:00
Scala Steward
36ef7ddf94 Update oauth2-oidc-sdk to 11.9.1 2024-01-07 08:10:55 +09:00
Scala Steward
be1fbc8594 Update markedj to 1.0.19 2024-01-07 02:14:14 +09:00
xuwei-k
d73eacfa5d Update scalafmt setting
use new syntax. prepare Scala 3.4
2023-12-30 08:10:39 +09:00
Scala Steward
5d495cfa12 Update oauth2-oidc-sdk to 11.9 2023-12-28 07:32:54 +09:00
dependabot[bot]
acaadff6cb Bump actions/upload-artifact from 3 to 4
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-24 15:54:17 +09:00
kenji yoshida
e22371e4a5 Update CODEOWNERS 2023-12-24 15:48:07 +09:00
Scala Steward
81c426b112 Update commons-email to 1.6.0 2023-12-23 08:45:55 +09:00
Scala Steward
1481872ddb Update jetty-http, jetty-io, jetty-security, ... to 10.0.19 2023-12-20 07:44:56 +09:00
Scala Steward
523da8afb9 Update sbt, sbt-dependency-tree to 1.9.8 2023-12-17 11:10:19 +09:00
Scala Steward
828dcb7173 Update oauth2-oidc-sdk to 11.8 2023-12-17 08:14:44 +09:00
Scala Steward
eaf7bfb78d Update oauth2-oidc-sdk to 11.7.1 2023-12-08 19:49:02 +09:00
scala-steward-bot
cbcf5ce4b6 Update HikariCP to 5.1.0 (#3413) 2023-12-08 08:01:24 +09:00
Scala Steward
36dce286b5 Update sbt-twirl, twirl-api to 1.6.4 2023-12-08 08:00:56 +09:00
Scala Steward
8ffe75786e Update postgresql to 42.7.1 2023-12-07 08:16:30 +09:00
Scala Steward
5d63bc71aa Update org.eclipse.jgit.archive, ... to 6.8.0.202311291450-r 2023-12-06 10:45:17 +09:00
dependabot[bot]
37f8f7edda Bump actions/setup-java from 3 to 4
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3 to 4.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-06 10:43:18 +09:00
scala-steward-bot
fd1c85afb2 Update logback-classic to 1.4.14 (#3440) 2023-12-03 21:40:52 +09:00
scala-steward-bot
c08bb6e89f Update mockito-core to 5.8.0 (#3441) 2023-12-03 21:40:35 +09:00
Scala Steward
d25889f6d2 Update json4s-jackson to 4.0.7 2023-12-03 20:03:35 +09:00
ziggystar
dabddf60b1 fix: add GitUtils.findBranchesNoMergeInfo and use it when merge info … (#3436)
* fix: add GitUtils.findBranchesNoMergeInfo and use it when merge info not necessary

* rfr: add some missing override annotations and a return type

---------

Co-authored-by: Thomas Geier <thomas.geier@solidat.de>
2023-11-30 21:01:57 +09:00
Scala Steward
c7ade7ec4d Update commons-io to 2.15.1 2023-11-30 07:43:52 +09:00
scala-steward-bot
9caa73a585 Update logback-classic to 1.4.13 (#3438) 2023-11-29 05:30:27 +09:00
Scala Steward
0ee849c73d Update logback-classic to 1.4.12 2023-11-28 15:51:46 +09:00
Scala Steward
7883d8fd1e Update oauth2-oidc-sdk to 11.7 2023-11-28 15:50:51 +09:00
Naoki Takezoe
783ddfffa3 Make max files and lines limit in showing diff configurable (#3433) 2023-11-26 21:02:40 +09:00
Naoki Takezoe
24b7cade49 Simplify pull request UI (#3417) 2023-11-25 23:48:48 +09:00
Scala Steward
51554d4325 Update github-api to 1.318 2023-11-24 01:53:46 +09:00
Scala Steward
90bcbd212b Update mysql, postgresql to 1.19.3 2023-11-22 03:06:56 +09:00
Naoki Takezoe
4ca3816522 Keyword search for issues and pull requests using search box (#3429) 2023-11-22 01:55:01 +09:00
Scala Steward
fc4819cb29 Update postgresql to 42.7.0 2023-11-21 08:02:24 +09:00
Scala Steward
5291df8e03 Update sbt-assembly to 2.1.5 2023-11-20 17:47:53 +09:00
Scala Steward
5afb0094f6 Update scalafmt-core to 3.7.17 2023-11-17 19:45:20 +09:00
kenji yoshida
e76813cbee remove unnecessary resolvers 2023-11-17 19:39:12 +09:00
kenji yoshida
bc6398ca3b add .git-blame-ignore-revs 2023-11-17 19:29:14 +09:00
xuwei-k
3d5ca44d66 update scalafmt 2023-11-17 19:26:04 +09:00
Scala Steward
8cd7068131 Update sbt-twirl, twirl-api to 1.6.3 2023-11-17 08:13:43 +09:00
xuwei-k
0db23b7f4a commons-compress 1.25.0 2023-11-16 12:07:37 +09:00
Scala Steward
66d9ce328d Update mysql, postgresql to 1.19.2 2023-11-16 04:36:20 +09:00
Naoki Takezoe
36de0b3097 Fix layout of branch selector (#3416) 2023-11-12 22:58:18 +09:00
Scala Steward
4f3cd26cf4 Update oauth2-oidc-sdk to 11.6 2023-11-06 07:35:18 +09:00
Scala Steward
561e1bfec7 Update mockito-core to 5.7.0 2023-11-03 07:25:05 +09:00
Scala Steward
de64206a82 Update jetty-http, jetty-io, jetty-security, ... to 10.0.18 2023-10-31 07:39:16 +09:00
Scala Steward
65ddffde89 Update sbt-assembly to 2.1.4 2023-10-27 17:44:42 +09:00
Scala Steward
1bc6ddc1a3 Update commons-io to 2.15.0 2023-10-26 07:04:36 +09:00
Scala Steward
a404bd0776 Update oauth2-oidc-sdk to 11.5 2023-10-24 07:42:57 +09:00
Scala Steward
ccbdd383ae Update sbt, sbt-dependency-tree to 1.9.7 2023-10-23 07:47:30 +09:00
Naoki Takezoe
acb846e885 Update README.md (#3401) 2023-10-23 02:57:41 +09:00
takezoe
fa23b4c89e Update ChangeLog of GitBucket 4.40.0 2023-10-23 00:09:29 +09:00
Scala Steward
a70e1f53b5 Update sbt-twirl, twirl-api to 1.6.2 2023-10-22 21:04:28 +09:00
Naoki Takezoe
176deb4930 Bump gist plugin to 4.23.0 to support GitBucket 4.40.0 (#3399) 2023-10-22 18:09:00 +09:00
Naoki Takezoe
6e26d090ed Fix executable war for Jetty 10 (#3397) 2023-10-22 17:20:04 +09:00
Naoki Takezoe
070f74e7dc Release GitBucket 4.40.0 (#3396) 2023-10-22 02:26:54 +09:00
Naoki Takezoe
bcd78b3e5b Support custom fields in search condition (#3286) 2023-10-22 02:00:24 +09:00
Scala Steward
be8f45ce49 Update tika-core to 2.9.1 2023-10-21 10:45:17 +09:00
Scala Steward
baa96408a8 Update apache-sshd to 2.11.0 2023-10-20 18:58:23 +09:00
Scala Steward
d2a7548f73 Update github-api to 1.317 2023-10-20 10:53:01 +09:00
Scala Steward
31e3fc64fc Update oauth2-oidc-sdk to 11.4 2023-10-19 07:42:27 +09:00
Scala Steward
01a9883847 Update typesafe:config to 1.4.3 2023-10-17 19:46:41 +09:00
kenji yoshida
3cf2bea01e add JDK 21 test 2023-10-13 08:03:01 +09:00
Scala Steward
7caf11ae83 Update jetty-http, jetty-io, jetty-security, ... to 10.0.17 2023-10-10 14:04:45 +09:00
Scala Steward
b22bc6fef0 Update oauth2-oidc-sdk to 11.2 2023-10-09 18:35:04 +09:00
kenji yoshida
88533c5807 update scala 3 build setting 2023-10-09 10:34:11 +09:00
Scala Steward
53d955f198 Update mockito-core to 5.6.0 2023-10-07 07:52:10 +09:00
Scala Steward
724550ec5f Update commons-net to 3.10.0 2023-10-06 15:26:10 +09:00
Scala Steward
1a63eff8f9 Update oauth2-oidc-sdk to 11.1 2023-10-06 15:25:42 +09:00
Scala Steward
cf1b245229 Update mysql, postgresql to 1.19.1 2023-10-03 08:09:12 +09:00
Scala Steward
c54a76c9b4 Update commons-io to 2.14.0 2023-09-30 08:56:10 +09:00
Scala Steward
1a7213e2f0 Update scalatra-forms-javax, ... to 3.0.0 2023-09-25 08:38:14 +09:00
Naoki Takezoe
a386cda024 Bump to Scalatra 3.0.0-RC1 (#3376) 2023-09-24 10:22:42 +09:00
Scala Steward
f414bb4c79 Update oauth2-oidc-sdk to 11.0 2023-09-21 08:29:55 +09:00
kenji yoshida
6a51c7414a fix warning. avoid deprecated URL constructor 2023-09-20 15:47:09 +09:00
Scala Steward
9718a67a74 Update sbt-assembly to 2.1.3 2023-09-18 20:56:27 +09:00
scala-steward-bot
179f86c904 Update sbt-twirl, twirl-api to 1.6.1 (#3372)
* Update sbt-twirl, twirl-api to 1.6.1

* Revert commit(s) 9cd04872

* Update sbt-twirl, twirl-api to 1.6.1
2023-09-17 23:46:50 +00:00
Scala Steward
e6ae6fc17d Update sbt-assembly to 2.1.2 2023-09-18 07:47:50 +09:00
dependabot[bot]
1f42b52cfd Bump actions/checkout from 3 to 4 (#3366)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-17 00:00:35 +09:00
scala-steward-bot
cdff342e3d Update sbt-twirl, twirl-api to 1.6.0 (#3369) 2023-09-16 23:59:19 +09:00
Scala Steward
daa8b6acf2 Update sbt, sbt-dependency-tree to 1.9.6 2023-09-16 07:31:13 +09:00
Scala Steward
2ae72c6db4 Update oauth2-oidc-sdk to 10.15 2023-09-15 10:03:01 +09:00
Scala Steward
9e3204d546 Update sbt, sbt-dependency-tree to 1.9.5 2023-09-14 17:45:42 +09:00
kenji yoshida
59e560b8e1 add -Xsource:3 2023-09-11 07:54:58 +09:00
xuwei-k
186269f8ff add explicit type 2023-09-10 20:04:23 +09:00
Scala Steward
e441c40429 Update commons-compress to 1.24.0 2023-09-09 09:05:43 +09:00
Scala Steward
e1fa85848c Update sbt-scoverage to 2.0.9 2023-09-09 08:00:39 +09:00
Scala Steward
8d66348634 Update scala-library to 2.13.12 2023-09-07 07:45:23 +09:00
Scala Steward
f16b7d2c9b Update org.eclipse.jgit.archive, ... to 6.7.0.202309050840-r 2023-09-06 22:25:07 +09:00
Scala Steward
0ae8cc2820 Update scala3-library to 3.3.1 2023-09-06 08:26:29 +09:00
Scala Steward
ca25e7fe90 Update sbt-scalafmt to 2.5.2 2023-09-03 13:33:56 +09:00
Scala Steward
2692e29716 Update org.eclipse.jgit.archive, ... to 6.6.1.202309021850-r 2023-09-03 10:45:43 +09:00
Scala Steward
b71ccfbcc5 Update oauth2-oidc-sdk to 10.14.2 2023-09-02 10:33:01 +09:00
Scala Steward
659a157cb7 Update jetty-http, jetty-io, jetty-security, ... to 10.0.16 2023-08-31 07:47:22 +09:00
Scala Steward
f22fab32cc Update testcontainers-scala to 0.41.0 2023-08-30 07:21:12 +09:00
Scala Steward
631e418733 Update sbt-scalafmt to 2.5.1 2023-08-30 07:20:56 +09:00
Scala Steward
0f57da14e4 Update oauth2-oidc-sdk to 10.14.1 2023-08-30 07:20:40 +09:00
Scala Steward
424790e686 Update tika-core to 2.9.0 2023-08-29 07:37:26 +09:00
Scala Steward
5dc43a7f75 Update sbt, sbt-dependency-tree to 1.9.4 2023-08-25 07:51:17 +09:00
Scala Steward
debb131623 Update mockito-core to 5.5.0 2023-08-22 18:16:15 +09:00
Scala Steward
e3e21e9590 Update github-api to 1.316 2023-08-22 06:57:37 +09:00
Scala Steward
42fa7ea74d Update mysql, postgresql to 1.19.0 2023-08-22 04:59:17 +09:00
Naoki Takezoe
8ada3dde04 Allow to create pull request from default branch of forked repositories (#3339) 2023-08-13 01:48:23 +09:00
xuwei-k
d43a666dfc use mapTo. prepare Scala 3 2023-08-11 10:22:16 +09:00
Naoki Takezoe
5b266229c3 Fix AccountController (#3337) 2023-08-11 03:27:44 +09:00
Naoki Takezoe
d8b0062f2b Show activities of all visible repositories (#3336) 2023-08-11 03:11:51 +09:00
kenji yoshida
7f0859c0a3 update blocking-slick 2023-08-10 07:59:43 +09:00
Scala Steward
38c7fbf589 Update logback-classic to 1.4.11 2023-08-10 07:39:26 +09:00
Scala Steward
41335964b7 Update logback-classic to 1.4.10 2023-08-10 03:13:16 +09:00
Scala Steward
c5464b2099 Update logback-classic to 1.4.9 2023-08-08 06:31:55 +09:00
Scala Steward
dc49b0dace Update oauth2-oidc-sdk to 10.13.2 2023-08-05 10:28:40 +09:00
Scala Steward
365f30b76b Update oauth2-oidc-sdk to 10.13 2023-08-03 06:43:45 +09:00
Scala Steward
ff1bc0fbca Update oauth2-oidc-sdk to 10.12 2023-07-31 20:20:18 +09:00
Scala Steward
41d55372b5 Update sbt-license-report to 1.6.1 2023-07-31 09:52:52 +09:00
Scala Steward
ba8e5fe3cb Update sbt-license-report to 1.6.0 2023-07-30 15:15:42 +09:00
Scala Steward
6e692f70b7 Update sbt, sbt-dependency-tree to 1.9.3 2023-07-25 09:36:29 +09:00
Scala Steward
aab979b78b Update scalatra, scalatra-forms, ... to 3.0.0-M5-javax 2023-07-23 13:26:14 +09:00
scala-steward-bot
9b7856464a Update markedj to 1.0.18 (#3323) 2023-07-22 21:40:27 +09:00
kenji yoshida
903008b417 update blocking-slick 2023-07-11 09:12:15 +09:00
Scala Steward
515cf86e4f Update sbt, sbt-dependency-tree to 1.9.2 2023-07-10 12:21:48 +09:00
Scala Steward
c0b9eb8789 Update oauth2-oidc-sdk to 10.11 2023-07-09 02:31:16 +09:00
Scala Steward
fefbf92f83 Update oauth2-oidc-sdk to 10.10.1 2023-06-30 07:45:44 +09:00
Scala Steward
006fae36c9 Update thumbnailator to 0.4.20 2023-06-29 07:09:36 +09:00
Scala Steward
281f7f37d8 Update sbt, sbt-dependency-tree to 1.9.1 2023-06-26 13:51:18 +09:00
Scala Steward
36c6dd979f Update oauth2-oidc-sdk to 10.9.2 2023-06-23 06:06:28 +09:00
Scala Steward
9f44015003 Update mockito-core to 5.4.0 2023-06-18 19:47:18 +09:00
kenji yoshida
e719533ed9 Update ISSUE_TEMPLATE.md 2023-06-18 12:55:08 +09:00
Scala Steward
773221d65b Update testcontainers-scala to 0.40.17 2023-06-18 07:46:09 +09:00
Scala Steward
6beacb6af3 Update logback-classic to 1.4.8 2023-06-14 07:10:28 +09:00
Scala Steward
f11b92d391 Update org.eclipse.jgit.archive, ... to 6.6.0.202305301015-r 2023-06-13 03:58:06 +09:00
Scala Steward
def222d035 Update commons-io to 2.13.0 2023-06-08 05:36:02 +09:00
Scala Steward
5dee7a9057 Update scalatra, scalatra-forms, ... to 3.0.0-M4 2023-06-08 05:35:20 +09:00
Scala Steward
c20cc1271c Update sbt-scoverage to 2.0.8 2023-06-03 19:48:05 +09:00
Scala Steward
843d429cb2 Update scala-library to 2.13.11 2023-06-03 03:34:17 +09:00
Scala Steward
372e17ea2b Update sbt to 1.9.0 2023-06-02 20:02:47 +09:00
Scala Steward
5490e82411 Update github-api to 1.315 2023-06-01 17:02:45 +09:00
Scala Steward
d30a5d2f92 Update mysql, postgresql to 1.18.3 2023-06-01 07:52:54 +09:00
Scala Steward
ef69763749 Update mysql, postgresql to 1.18.2 2023-05-31 01:06:52 +09:00
Scala Steward
59d1250e36 Update testcontainers-scala to 0.40.16 2023-05-27 07:19:22 +09:00
Scala Steward
33bf0b7b31 Update scala3-library to 3.3.0 2023-05-24 04:35:31 +09:00
Scala Steward
884cd498ce Update commons-io to 2.12.0 2023-05-17 07:02:27 +09:00
Scala Steward
e0b021cb3e Update tika-core to 2.8.0 2023-05-16 05:42:27 +09:00
Scala Steward
57edf101fa Update sbt-license-report to 1.5.0 2023-05-15 14:49:08 +09:00
Scala Steward
a2bf0d86d8 Update apache-sshd to 2.10.0 2023-05-15 06:49:29 +09:00
Scala Steward
32e2ea5061 Update sbt, sbt-dependency-tree to 1.8.3 2023-05-13 06:57:17 +09:00
Scala Steward
e28c0592f6 Update oauth2-oidc-sdk to 10.9.1 2023-05-12 07:07:12 +09:00
Scala Steward
60627060d5 Update mysql, postgresql to 1.18.1 2023-05-11 20:08:12 +09:00
Scala Steward
cea4d7e15f Update oauth2-oidc-sdk to 10.9 2023-05-06 19:47:44 +09:00
Naoki Takezoe
ca1670b21a Make it possible to edit empty custom field value (#3288) 2023-05-06 18:34:54 +09:00
Naoki Takezoe
c9c72faaf1 Improve git push performance (#3284) 2023-05-02 12:36:53 +09:00
kenji yoshida
ba42538775 Update validation.md 2023-05-02 07:29:42 +09:00
kenji yoshida
39141d8996 http => https 2023-05-01 19:27:33 +09:00
takezoe
e3dd099bbb Update version to 4.40.0-SNAPSHOT 2023-05-01 01:20:59 +09:00
Naoki Takezoe
6b37d1027f Make the default branch configurable (#3283) 2023-04-30 22:09:19 +09:00
scala-steward-bot
b521f43c84 Update org.eclipse.jgit.archive, ... to 6.5.0.202303070854-r (#3281)
* Update org.eclipse.jgit.archive, ... to 6.5.0.202303070854-r

* Revert commit(s) 61079bb8

* Update org.eclipse.jgit.archive, ... to 6.5.0.202303070854-r
2023-04-30 14:48:48 +09:00
Scala Steward
7c5a9df759 Update jetty-http, jetty-io, jetty-security, ... to 10.0.15 2023-04-30 13:49:29 +09:00
Scala Steward
04762a3e53 Update mockito-core to 5.3.1 2023-04-30 13:49:06 +09:00
kenji yoshida
d2ba2df2ba Update .scala-steward.conf 2023-04-30 13:15:24 +09:00
kenji yoshida
0e7f34f1d7 fix scala 3 build 2023-04-30 13:13:30 +09:00
xuwei-k
d576bbfaed update scala 3 build settings 2023-04-30 13:10:32 +09:00
kenji yoshida
2bfdca6992 Update build.yml 2023-04-29 16:10:55 +09:00
scala-steward-bot
d18fdb6399 Update logback-classic to 1.4.7 (#3273)
Co-authored-by: Naoki Takezoe <takezoe@gmail.com>
2023-04-29 12:04:02 +09:00
Naoki Takezoe
fe02605544 Upgrade to Scalatra 3.0.0-M3 and drop Java 8 support (#3279)
* Bump to Scalatra 3.0.0-M1
* Bump to Scalatra 3.0.0-M3
* Format build.sbt
* Drop Java 8 support
* Fix scala-xml related warnings
* Bump sbt-scoverage to 2.0.7

---------

Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2023-04-29 11:53:30 +09:00
scala-steward-bot
f86ae20791 Update sbt-license-report to 1.4.0 (#3278)
Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2023-04-28 22:45:53 +00:00
Naoki Takezoe
df69f88186 Release 4.39.0 (#3277) 2023-04-29 01:46:13 +09:00
Naoki Takezoe
8d1323f354 Delete records in ISSUE_ASSIGNEE when repository is deleted (#3276) 2023-04-24 02:26:21 +09:00
Naoki Takezoe
2f598b618b Fix issues in git refs APIs (#3275) 2023-04-23 22:52:31 +09:00
Scala Steward
baf0b0b92c Update oauth2-oidc-sdk to 10.8 2023-04-23 03:07:02 +09:00
Scala Steward
27a75250a6 Update logback-classic to 1.3.7 2023-04-20 06:32:21 +09:00
Scala Steward
15f60402a5 Update oauth2-oidc-sdk to 10.7.2 2023-04-17 17:49:56 +09:00
Scala Steward
41c6fc90b3 Update testcontainers-scala to 0.40.15 2023-04-17 00:50:22 +09:00
Scala Steward
34356b04a8 Update mysql, postgresql to 1.18.0 2023-04-05 02:14:51 +09:00
Scala Steward
2ca02b6539 Update oauth2-oidc-sdk to 10.7.1 2023-03-31 03:06:07 +09:00
Scala Steward
cd0c71dffb Update commons-compress to 1.23.0 2023-03-23 07:28:32 +09:00
Scala Steward
a59120fe19 Update testcontainers-scala to 0.40.14 2023-03-22 06:59:19 +09:00
Naoki Takezoe
fdc35f48ed Update the developer doc (#3257) 2023-03-19 11:48:07 +09:00
Naoki Takezoe
bae9b7ddc3 Ignore signed-commit verification error (#3256) 2023-03-18 21:58:15 +09:00
Scala Steward
3dd9b7e587 Update postgresql to 42.6.0 2023-03-18 07:48:38 +09:00
Scala Steward
44c905bdab Update logback-classic to 1.3.6 2023-03-17 13:08:58 +09:00
Scala Steward
5214040257 Update jetty-continuation, jetty-http, ... to 9.4.51.v20230217 2023-02-28 07:00:10 +09:00
Scala Steward
7ad9f901dd Update github-api to 1.314 2023-02-27 07:09:28 +09:00
Naoki Takezoe
f472d52954 Add --disable_news_feed option to disable News Feed (#3246) 2023-02-27 02:17:52 +09:00
Naoki Takezoe
1e752af41b Update directory.md 2023-02-26 11:25:50 +09:00
Naoki Takezoe
3ba46c3fc6 Update directory.md 2023-02-26 11:25:30 +09:00
Naoki Takezoe
bf83da476f Update directory.md 2023-02-26 11:21:26 +09:00
Naoki Takezoe
6b8c4cf8d0 Add --disable_cache option to disable cache (#3245) 2023-02-24 09:42:17 +09:00
Scala Steward
445329c07a Update postgresql to 42.5.4 2023-02-17 04:14:01 +09:00
Scala Steward
8f370e19c6 Update oauth2-oidc-sdk to 10.7 2023-02-16 21:44:11 +09:00
Scala Steward
736dbcfb58 Update oauth2-oidc-sdk to 10.6 2023-02-16 03:53:15 +09:00
Scala Steward
c1cb7f87e0 Update oauth2-oidc-sdk to 10.5.2 2023-02-14 07:22:34 +09:00
Scala Steward
3c14fcefc9 Update sbt-assembly to 2.1.1 2023-02-12 15:54:07 +09:00
Scala Steward
831badf8db Update tika-core to 2.7.0 2023-02-04 09:06:43 +09:00
Scala Steward
5f8a6e8d24 Update postgresql to 42.5.3 2023-02-04 07:54:40 +09:00
Scala Steward
a3981493f7 Update postgresql to 42.5.2 2023-02-01 07:33:53 +09:00
Scala Steward
6919cf5d4d Update oauth2-oidc-sdk to 10.5.1 2023-01-27 09:50:55 +09:00
kenji yoshida
f6d1e6bdd6 pin mockito 4.x
https://github.com/mockito/mockito/pull/2804
2023-01-14 18:11:18 +09:00
Scala Steward
a13ff89acd Update oauth2-oidc-sdk to 10.5 2023-01-13 07:20:28 +09:00
Naoki Takezoe
cd5c76279a Fix input JSON schema of add/replace labels to an issue API (#3226) 2023-01-13 02:41:48 +09:00
Scala Steward
debff5e4b8 Update thumbnailator to 0.4.19 2023-01-01 06:56:02 +09:00
Scala Steward
433e207ec5 Update mockito-core to 4.11.0 2022-12-29 01:38:44 +09:00
Naoki Takezoe
3775f6a907 Fix NoSuchElementException in delete issue comment API (#3220) 2022-12-26 09:48:05 +09:00
Naoki Takezoe
10d611c0eb Call OpenID connect logout endpoint when signed-out on GitBucket (#3219) 2022-12-26 09:41:29 +09:00
takezoe
963bc4d672 Change the log file path in local dev mode 2022-12-18 22:53:20 +09:00
Naoki Takezoe
e68a21ee30 Enum support in custom fields (#3195) 2022-12-18 22:46:11 +09:00
Naoki Takezoe
d5c083b70f Upgrade logback-classic to 1.3.5 (#3218) 2022-12-18 19:39:06 +09:00
Scala Steward
2deb9cf417 Update mockito-core to 4.10.0 2022-12-15 07:49:15 +09:00
Scala Steward
fca0cfcdc7 Update oauth2-oidc-sdk to 10.4 2022-12-13 22:09:35 +09:00
Scala Steward
1466e1bdb3 Update oauth2-oidc-sdk to 10.3.1 2022-12-13 20:58:47 +09:00
Naoki Takezoe
dd48bc443a Add option to keep session in the local dev mode (#3205) 2022-12-12 08:22:41 +09:00
Scala Steward
f455738e5f Update sbt-assembly to 2.1.0 2022-12-10 07:37:40 +09:00
Scala Steward
85193803cd Update jetty-continuation, jetty-http, ... to 9.4.50.v20221201 2022-12-08 08:58:51 +09:00
Scala Steward
4e90a6074a Update oauth2-oidc-sdk to 10.3 2022-12-07 08:02:34 +09:00
Scala Steward
ca94fa5184 Update sbt-pgp to 2.2.1 2022-12-06 14:45:21 +09:00
Scala Steward
f14a7c996f Update testcontainers-scala to 0.40.12 2022-12-05 04:53:03 +09:00
Scala Steward
989d22f4d8 Update httpclient to 4.5.14 2022-12-04 22:46:38 +09:00
Scala Steward
400a812343 Update commons-net to 3.9.0 2022-12-02 09:11:27 +09:00
Scala Steward
97284f1ced Update postgresql to 42.5.1 2022-11-24 03:45:39 +09:00
Scala Steward
5e6a0d7e16 Update mysql, postgresql to 1.17.6 2022-11-16 23:28:52 +09:00
Scala Steward
599e11245f Update apache-sshd to 2.9.2 2022-11-16 07:35:21 +09:00
Scala Steward
538d714c96 Update sbt-scalafmt to 2.5.0 2022-11-15 08:53:31 +09:00
Scala Steward
953915ba2a Update mockito-core to 4.9.0 2022-11-15 05:12:27 +09:00
Naoki Takezoe
1a2f5da055 Suppress "scanned from multiple locations" warnings in development (#3194) 2022-11-12 20:17:56 +09:00
Scala Steward
749a469d37 Update tika-core to 2.6.0 2022-11-08 03:15:07 +09:00
scala-steward-bot
c7d084321a Update mariadb-java-client to 2.7.6 (#3190) 2022-11-07 13:33:23 +09:00
Naoki Takezoe
00a61cd6cf Downgrade and pin MariaDB JDBC driver version (#3189) 2022-11-05 15:58:18 +09:00
Naoki Takezoe
d9c6c13c62 Merge 4.38.4 release notes into master (#3187) 2022-11-02 13:30:02 +09:00
Scala Steward
5260c5e889 Update commons-compress to 1.22 2022-11-01 06:47:55 +09:00
Scala Steward
1700f96c62 Update sbt-pgp to 2.2.0 2022-10-30 20:47:40 +09:00
Naoki Takezoe
5a0f9f8bbb Merge 4.38.3 release notes into master 2022-10-30 11:02:49 +09:00
takezoe
8fa22b4de2 Enhance .gitignore 2022-10-30 10:58:07 +09:00
Naoki Takezoe
d17cae16fd Revert "Fix IllegalStateException when returning unknown avatar image (#3158)" (#3179)
This reverts commit a0be02ce2f.
2022-10-30 10:18:49 +09:00
Naoki Takezoe
c4c48962cf Fix an issue that assignees are not saved in PR creation (#3178) 2022-10-30 09:54:33 +09:00
Naoki Takezoe
4140e92f0b Fix an issue that assignees are not saved in PR creation (#3178) 2022-10-30 09:54:18 +09:00
Scala Steward
887e560a1b Update oauth2-oidc-sdk to 10.1 2022-10-28 07:22:22 +09:00
pea-sys
e2d70181e8 png optimization (#3176) 2022-10-27 22:32:08 +09:00
Scala Steward
148c453dbc Update oauth2-oidc-sdk to 10.0 2022-10-24 20:52:36 +09:00
Scala Steward
f6ee9d311d Update thumbnailator to 0.4.18 2022-10-24 08:45:56 +09:00
Scala Steward
35209e43bb Update mockito-core to 4.8.1 2022-10-22 06:50:07 +09:00
Scala Steward
4a3ecf063d Update sbt-assembly to 2.0.0 2022-10-18 06:54:35 +09:00
Naoki Takezoe
4c79101624 Fix duplications in issue labels and assignees (#3168) 2022-10-17 01:00:22 +09:00
Naoki Takezoe
921b01661b Upgrade Scalatra to 2.8.4 (#3165) 2022-10-16 16:49:47 +09:00
Scala Steward
c63301d8e6 Update testcontainers-scala to 0.40.11 2022-10-11 12:22:12 +09:00
Naoki Takezoe
c9ed9d2237 Hide large diffs by default and show on demand (#3157) 2022-10-10 15:49:37 +09:00
Naoki Takezoe
ca55cbe456 Disable scalafmt on compile (#3160) 2022-10-10 03:15:59 +09:00
Scala Steward
d4828613ee Update scala-library to 2.13.10 2022-10-09 05:13:06 +09:00
Naoki Takezoe
a0be02ce2f Fix IllegalStateException when returning unknown avatar image (#3158) 2022-10-08 11:24:03 +09:00
Scala Steward
9b8016a4d5 Update mysql, postgresql to 1.17.5 2022-10-05 06:25:59 +09:00
Scala Steward
8fdd3bfd21 Update tika-core to 2.5.0 2022-10-04 06:11:07 +09:00
Scala Steward
695a061e3c Update sbt, sbt-dependency-tree to 1.7.2 2022-10-03 16:05:29 +09:00
Scala Steward
bd50d9218e Update mysql, postgresql to 1.17.4 2022-09-30 06:13:37 +09:00
Scala Steward
d8f13bc1ce Update json4s-jackson to 4.0.6 2022-09-29 17:14:45 +09:00
Scala Steward
ed84d1a3c9 Update github-api to 1.313 2022-09-27 18:50:29 +09:00
Scala Steward
3c765d879c Update mariadb-java-client to 3.0.8 2022-09-21 01:05:42 +09:00
Naoki Takezoe
4c76b6dd96 Release 4.38.2 (#3141) 2022-09-20 17:52:14 +09:00
Scala Steward
7e66917993 Update scala-library to 2.13.9 2022-09-20 07:35:35 +09:00
Scala Steward
eb0f985399 Update jetty-continuation, jetty-http, ... to 9.4.49.v20220914 2022-09-16 07:13:32 +09:00
Naoki Takezoe
3a2908c3a3 Resurrect assignee icons on the issue list (#3136) 2022-09-13 23:19:38 +09:00
Naoki Takezoe
f13c10859f Fix warnings in AccountService (#3135) 2022-09-13 15:42:43 +09:00
Scala Steward
8e8a314c91 Update oauth2-oidc-sdk to 9.43.1 2022-09-10 07:07:24 +09:00
Naoki Takezoe
dad0478b87 Remove unused import statement (#3134) 2022-09-10 03:06:21 +09:00
Naoki Takezoe
240b34016d Release 4.38.1 (#3133) 2022-09-10 02:43:06 +09:00
yurafuca
2c164d630c Fix comment diff in Chrome 105 (#3131) 2022-09-10 02:06:13 +09:00
Scala Steward
3d12a9038f Update mockito-core to 4.8.0 2022-09-08 06:51:44 +09:00
Scala Steward
71fc02b5cd Update apache-sshd to 2.9.1 2022-09-08 00:03:30 +09:00
Naoki Takezoe
74caaa3d94 Fix Markdown table CSS (#3126) 2022-09-06 00:11:53 +09:00
Naoki Takezoe
e024c12521 Fix HTML rendering of multiple asignees (#3125) 2022-09-05 22:39:36 +09:00
Scala Steward
1d0c364947 Update oauth2-oidc-sdk to 9.43 2022-09-05 18:53:55 +09:00
Naoki Takezoe
88e59405c5 Release 4.38.0 (#3123) 2022-09-04 00:36:03 +09:00
Naoki Takezoe
8160c93c15 Fix ref and ssh_url in webhook payload (#3122) 2022-09-03 13:15:37 +09:00
Naoki Takezoe
3c8113d607 Minor code cleanup for GitRepositoryServlet (#3121) 2022-09-03 12:27:06 +09:00
scala-steward-bot
8e2f421e76 Update markedj to 1.0.17 (#3120) 2022-09-03 12:19:37 +09:00
Scala Steward
56df833b4a Update oauth2-oidc-sdk to 9.42 2022-09-02 06:27:00 +09:00
Naoki Takezoe
119d7d0be0 Revert "Drop unused ActivityComponent (#3024)" (#3117)
This reverts commit bd06e6d4dc.
2022-08-28 03:33:19 +09:00
Scala Steward
d4d2ca19a1 Update oauth2-oidc-sdk to 9.41.1 2022-08-27 07:59:51 +09:00
Naoki Takezoe
4ce5597d67 Remove a link to the demo site from README (#3115) 2022-08-26 14:33:12 +09:00
Scala Steward
17888327b3 Update postgresql to 42.5.0 2022-08-25 07:01:14 +09:00
Naoki Takezoe
997def54ab Set UTF-8 as the default commit charset at the online text editor (#3112) 2022-08-21 22:50:12 +09:00
Naoki Takezoe
a407e75459 Remove unused import (#3111) 2022-08-21 21:52:55 +09:00
Scala Steward
cece53aad9 Update github-api to 1.308 2022-08-19 08:40:16 +09:00
Scala Steward
a2d63bc5f8 Update postgresql to 42.4.2 2022-08-18 07:26:45 +09:00
Scala Steward
0c81c63ab7 Update mockito-core to 4.7.0 2022-08-13 22:35:03 +09:00
Scala Steward
3e8f1eee22 Update oauth2-oidc-sdk to 9.41 2022-08-12 07:52:55 +09:00
Scala Steward
a91d1def45 Update oauth2-oidc-sdk to 9.40 2022-08-09 22:49:48 +09:00
Scala Steward
032e6d1c57 Update oauth2-oidc-sdk to 9.39.1 2022-08-09 17:31:16 +09:00
yurafuca
93eb133cba Fix milestone count (#3103) 2022-08-09 12:28:07 +09:00
Scala Steward
b7b78842da Update mariadb-java-client to 3.0.7 2022-08-05 05:48:20 +09:00
Scala Steward
8100ccaf5f Update postgresql to 42.4.1 2022-08-04 07:13:05 +09:00
Scala Steward
936e1c0e96 Update testcontainers-scala to 0.40.10 2022-07-30 12:07:10 +09:00
Scala Steward
1a7274e475 Update solidbase to 1.0.5 2022-07-25 18:59:59 +09:00
Scala Steward
ac7b83b6ed Update java-diff-utils to 4.12 2022-07-23 12:32:01 +09:00
Scala Steward
e298279032 Update apache-sshd to 2.9.0 2022-07-23 07:55:52 +09:00
Scala Steward
f7e58c28c6 Update oauth2-oidc-sdk to 9.39 2022-07-22 16:52:09 +09:00
Scala Steward
18f3bc4056 Update testcontainers-scala to 0.40.9 2022-07-14 22:32:58 +09:00
Scala Steward
4638f82889 Update oauth2-oidc-sdk to 9.38.1 2022-07-14 05:01:11 +09:00
Naoki Takezoe
4396b6eab5 Horizontal scroll for too wide tables in Markdown (#3087) 2022-07-13 21:24:58 +09:00
Zain Aftab
594ae2bb7e #2983 fixed css for table (#3082) 2022-07-13 08:19:21 +09:00
Scala Steward
429cf54bd4 Update sbt, sbt-dependency-tree to 1.7.1 2022-07-12 14:14:05 +09:00
Scala Steward
274357abc4 Update sbt, sbt-dependency-tree to 1.7.0 2022-07-11 07:24:10 +09:00
Scala Steward
0e21247755 Update oauth2-oidc-sdk to 9.38 2022-07-06 18:52:46 +09:00
Scala Steward
37f2868ff3 Update oauth2-oidc-sdk to 9.37.3 2022-07-04 17:00:26 +09:00
Scala Steward
6a85e25a62 Update mariadb-java-client to 3.0.6 2022-06-30 06:33:58 +09:00
Scala Steward
a91b1c7e79 Update mysql, postgresql to 1.17.3 2022-06-29 18:03:50 +09:00
Scala Steward
bfd9ecd130 Update github-api to 1.307 2022-06-27 18:33:09 +09:00
Scala Steward
ec888e94fd Update sbt-scoverage to 2.0.0 2022-06-26 06:30:23 +09:00
Scala Steward
a19c80bef2 Update jetty-continuation, jetty-http, ... to 9.4.48.v20220622 2022-06-23 07:01:52 +09:00
Scala Steward
7b9ade2698 Update jetty-continuation, jetty-http, ... to 9.4.47.v20220610 2022-06-21 06:25:34 +09:00
Scala Steward
d03f28eeb9 Update tika-core to 2.4.1 2022-06-18 07:22:37 +09:00
Scala Steward
288dd788bc Update org.eclipse.jgit.archive, ... to 5.13.1.202206130422-r 2022-06-13 20:47:46 +09:00
Scala Steward
2069a5a931 Update postgresql to 42.4.0 2022-06-10 02:10:28 +09:00
Scala Steward
8a434cbd15 Update mockito-core to 4.6.1 2022-06-03 07:10:47 +09:00
Scala Steward
faafe49848 Update oauth2-oidc-sdk to 9.37.2 2022-06-02 19:33:26 +09:00
Scala Steward
17a72292ce Update oauth2-oidc-sdk to 9.37.1 2022-06-01 19:03:35 +09:00
Scala Steward
9ae09f1801 Update testcontainers-scala to 0.40.8 2022-06-01 06:54:21 +09:00
Scala Steward
abbba17e4b Update oauth2-oidc-sdk to 9.37 2022-05-31 06:29:58 +09:00
Scala Steward
479d5da17e Update mockito-core to 4.6.0 2022-05-28 07:59:15 +09:00
Scala Steward
dec7890d04 Update oauth2-oidc-sdk to 9.36 2022-05-26 19:45:42 +09:00
Scala Steward
61910a6667 Update mariadb-java-client to 3.0.5 2022-05-26 07:06:52 +09:00
Scala Steward
ac2119ac3b Update postgresql to 42.3.6 2022-05-24 23:05:58 +09:00
Scala Steward
8c71cd7369 Update mysql, postgresql to 1.17.2 2022-05-20 08:20:48 +09:00
porkotron
ec8b6ff18f Implement missing parameters on commits api (#3061)
* Add missing leading slash html_url api path
* Use HEAD as default ref
* Implement missing parameters

Co-authored-by: Petri Pyy <petri.pyy@abako.fi>
2022-05-15 01:51:16 +09:00
Naoki Takezoe
e214804d57 Bump mariadb-java-client to 3.0.4 (#3059) 2022-05-08 21:57:25 +09:00
Scala Steward
39448f2e3c Update postgresql to 42.3.5 2022-05-05 07:37:40 +09:00
Naoki Takezoe
79dc6fc247 Support multiple assignees for Issues and Pull requests (#3055) 2022-05-03 22:51:54 +09:00
Naoki Takezoe
a800f305f2 Refactor old migrations (#3056) 2022-05-03 22:24:14 +09:00
Scala Steward
67e0fb6b3f Update tika-core to 2.4.0 2022-05-03 03:41:42 +09:00
Naoki Takezoe
e401d30159 Fix wrong overwriting of updatedDate of Issues and Pull requests (#3053) 2022-05-02 22:11:46 +09:00
Scala Steward
504e651828 Update testcontainers-scala to 0.40.7 2022-04-28 06:40:34 +09:00
Scala Steward
7a8da2f074 Update oauth2-oidc-sdk to 9.35 2022-04-27 01:22:23 +09:00
Scala Steward
1e47e96634 Update testcontainers-scala to 0.40.6 2022-04-25 07:11:30 +09:00
Scala Steward
69502480b4 Update github-api to 1.306 2022-04-22 03:39:39 +09:00
Scala Steward
5833e3fcca Update mockito-core to 4.5.1 2022-04-21 22:31:44 +09:00
Scala Steward
4e47ffb1d2 Update github-api to 1.305 2022-04-20 09:28:21 +09:00
Scala Steward
3056333a7c Update github-api to 1.304 2022-04-20 06:08:23 +09:00
Scala Steward
ad0cd7f625 Update mockito-core to 4.5.0 2022-04-20 06:08:10 +09:00
kenji yoshida
dedaa263ce Scala 3.1.2 2022-04-18 07:02:22 +09:00
Scala Steward
bccf729102 Update oauth2-oidc-sdk to 9.34 2022-04-18 06:46:15 +09:00
onukura
a244c61e56 Hide header content on signin and register page (#2589)
Co-authored-by: Naoki Takezoe <takezoe@gmail.com>
2022-04-18 01:43:03 +09:00
Naoki Takezoe
37594935f0 Custom fields for issues and pull requests (#3034) 2022-04-18 01:01:15 +09:00
Scala Steward
e521c2158b Update postgresql to 42.3.4 2022-04-16 07:06:11 +09:00
Scala Steward
b1c8a8c76e Update mysql, postgresql to 1.17.1 2022-04-14 01:44:20 +09:00
Scala Steward
8d92f210f0 Update oauth2-oidc-sdk to 9.33 2022-04-13 06:02:00 +09:00
Scala Steward
287281923c Update mysql, postgresql to 1.17.0 2022-04-12 22:58:11 +09:00
dependabot[bot]
6f18135574 Bump actions/setup-java from 2 to 3 (#3037)
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2 to 3.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-12 17:22:01 +09:00
dependabot[bot]
58cf9bec3b Bump actions/upload-artifact from 2 to 3 (#3038)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-12 17:21:43 +09:00
Scala Steward
b7a45e9901 Update json4s-jackson to 4.0.5 2022-04-05 18:26:05 +09:00
Scala Steward
f5585b39c6 Update testcontainers-scala to 0.40.5 2022-04-04 05:32:48 +09:00
Scala Steward
9c3ef37274 Update jetty-continuation, jetty-http, ... to 9.4.46.v20220331 2022-04-02 07:27:09 +09:00
Scala Steward
e904c0b689 Update oauth2-oidc-sdk to 9.32 2022-03-30 18:30:21 +09:00
Scala Steward
237f97f069 Update testcontainers-scala to 0.40.4 2022-03-30 00:37:40 +09:00
Scala Steward
1eb2a04090 Update oauth2-oidc-sdk to 9.31.1 2022-03-29 20:18:47 +09:00
Naoki Takezoe
cda6106858 Allow to configure Jetty idle timeout in standalone mode (#3027) 2022-03-29 07:44:14 +09:00
Naoki Takezoe
8c4ce5e5f4 Hash password when reset it (#3026) 2022-03-29 07:16:12 +09:00
Naoki Takezoe
b5ee6431c4 Reset password email by users themselves (#3023) 2022-03-29 01:04:57 +09:00
Naoki Takezoe
bd06e6d4dc Drop unused ActivityComponent (#3024) 2022-03-28 22:24:34 +09:00
dependabot[bot]
3b607e74ed Bump actions/cache from 2.1.7 to 3 (#3025)
Bumps [actions/cache](https://github.com/actions/cache) from 2.1.7 to 3.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.7...v3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-28 21:55:49 +09:00
Scala Steward
dc16474ed3 Update oauth2-oidc-sdk to 9.31 2022-03-19 19:51:24 +09:00
Scala Steward
dc0f088be0 Update oauth2-oidc-sdk to 9.30 2022-03-19 09:21:48 +09:00
Scala Steward
2718e10044 Update oauth2-oidc-sdk to 9.29 2022-03-17 06:15:25 +09:00
Scala Steward
4213dcb8a2 Update testcontainers-scala to 0.40.3 2022-03-16 11:49:15 +09:00
Scala Steward
39afb31200 Update solidbase to 1.0.4 2022-03-14 06:30:05 +09:00
dependabot[bot]
8e1ce1c96a Bump actions/checkout from 2 to 3 (#3011)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-13 17:52:16 +09:00
Scala Steward
fdfd8293d6 Update oauth2-oidc-sdk to 9.28 2022-03-12 08:34:36 +09:00
Scala Steward
b7d3be6a14 Update oauth2-oidc-sdk to 9.27.1 2022-03-09 05:42:19 +09:00
Scala Steward
bb5c809749 Update mockito-core to 4.4.0 2022-03-09 05:41:08 +09:00
Scala Steward
a2cbe7cbf5 Update logback-classic to 1.2.11 2022-03-06 20:37:40 +09:00
Scala Steward
b1fb09ac99 Update github-api to 1.303 2022-03-06 08:05:46 +09:00
Scala Steward
201ae7e7db Update github-api to 1.302 2022-03-02 12:23:53 +09:00
ziggystar
2978decb84 fix: the URLs returned in tag api to point to something that exists (#2998)
Co-authored-by: Thomas Geier <thomas.geier@solidat.de>
2022-02-24 14:19:24 +09:00
Scala Steward
5fbbd4d5f3 Update testcontainers-scala to 0.40.2 2022-02-21 06:39:36 +09:00
Scala Steward
4abd363f62 Update oauth2-oidc-sdk to 9.27 2022-02-18 06:19:36 +09:00
Scala Steward
8288db60a9 Update postgresql to 42.3.3 2022-02-16 05:08:44 +09:00
Scala Steward
6cdf679571 Update sbt-assembly to 1.2.0 2022-02-13 18:11:57 +09:00
Scala Steward
51179acc12 Update sbt-assembly to 1.1.1 2022-02-13 17:35:25 +09:00
Scala Steward
1ff27d3e17 Update thumbnailator to 0.4.17 2022-02-12 06:52:22 +09:00
Scala Steward
1e9bce3d5a Update oauth2-oidc-sdk to 9.25 2022-02-10 18:47:18 +09:00
Scala Steward
8811ea2b58 Update jetty-continuation, jetty-http, ... to 9.4.45.v20220203 2022-02-08 03:05:22 +09:00
Scala Steward
be7cdd0a28 Update tika-core to 2.3.0 2022-02-08 03:03:55 +09:00
Scala Steward
611a05aa48 Update testcontainers-scala to 0.40.1 2022-02-06 07:42:19 +09:00
Naoki Takezoe
9f95a757a2 Update CHANGELOG of 4.37.2 2022-02-05 08:47:17 +09:00
Scala Steward
58b577453c Update oauth2-oidc-sdk to 9.24 2022-02-05 06:57:49 +09:00
Naoki Takezoe
78acfd87e8 Update CHANGELOG.md 2022-02-03 11:41:40 +09:00
Scala Steward
bf9cb26164 Update typesafe:config to 1.4.2 2022-02-03 07:29:36 +09:00
Scala Steward
68a99ada0b Update postgresql to 42.3.2 2022-02-02 01:37:26 +09:00
Scala Steward
1d841ce171 Update sbt, sbt-dependency-tree to 1.6.2 2022-02-01 15:00:58 +09:00
Naoki Takezoe
ccfdbfd276 Mention that GitBucket doesn't support JakartaEE in README (#2986) 2022-01-31 23:51:44 +09:00
Naoki Takezoe
70d584d56d Report commit failure caused by hook (#2984) 2022-01-30 21:38:15 +09:00
kenji yoshida
a49ffb07be update Scala 3 version 2022-01-30 16:14:57 +09:00
Scala Steward
baa9caf010 Update testcontainers-scala to 0.40.0 2022-01-28 14:11:19 +09:00
Scala Steward
22025c875f Update oauth2-oidc-sdk to 9.22.2 2022-01-26 06:46:20 +09:00
Scala Steward
3806995a50 Update mockito-core to 4.3.1 2022-01-26 06:44:32 +09:00
Scala Steward
94d2650491 Update mockito-core to 4.3.0 2022-01-24 22:05:03 +09:00
Scala Steward
844f24afa4 Update json4s-jackson to 4.0.4 2022-01-23 12:27:59 +09:00
kenji yoshida
083396a8e4 update maven badge 2022-01-22 16:25:53 +09:00
kenji yoshida
e02769056b remove Resolver.jcenterRepo
- 00eab5d584
- debbc21bf3
- https://repo1.maven.org/maven2/io/github/java-diff-utils/java-diff-utils/
2022-01-22 15:49:21 +09:00
Scala Steward
024f8e8d80 Update oauth2-oidc-sdk to 9.22.1 2022-01-21 22:51:38 +09:00
Scala Steward
3b4a7c3c47 Update mariadb-java-client to 2.7.5 2022-01-20 08:22:53 +09:00
Scala Steward
d9838d9cba Update mysql, postgresql to 1.16.3 2022-01-19 23:59:28 +09:00
Naoki Takezoe
b3ca4468cd Release 4.37.2 (#2970) 2022-01-16 11:21:58 +09:00
Naoki Takezoe
452e41603a Fix activities template (#2969) 2022-01-16 03:38:16 +09:00
Scala Steward
b41de4a770 Update oauth2-oidc-sdk to 9.22 2022-01-13 07:03:53 +09:00
Scala Steward
3423d2f2f3 Update sbt-scoverage to 1.9.3 2022-01-11 22:58:10 +09:00
Scala Steward
9269acc64d Update scala-library to 2.13.8 2022-01-11 08:57:06 +09:00
Scala Steward
18b5f20f1c Update oauth2-oidc-sdk to 9.21 2022-01-11 07:14:42 +09:00
kenji yoshida
68d592a8ff pin HikariCP 2022-01-10 14:01:22 +09:00
Scala Steward
ee18d96f98 Update oauth2-oidc-sdk to 9.20.1 2022-01-04 17:48:12 +09:00
Scala Steward
6d3687cbdf Update thumbnailator to 0.4.16 2022-01-02 22:38:01 +09:00
Scala Steward
1ef1a2983b Update sbt, sbt-dependency-tree to 1.6.1 2021-12-29 16:30:22 +09:00
Scala Steward
47850fe0fa Update sbt, sbt-dependency-tree to 1.6.0 2021-12-27 07:50:11 +09:00
Scala Steward
055a37cac0 Update sbt-scalafmt to 2.4.6 2021-12-25 13:16:01 +09:00
Scala Steward
333deb4756 Update tika-core to 2.2.1 2021-12-24 07:10:06 +09:00
Scala Steward
34cde4b09a Update logback-classic to 1.2.10 2021-12-23 19:52:39 +09:00
Scala Steward
5091b4838c Update sbt, sbt-dependency-tree to 1.5.8 2021-12-21 08:49:23 +09:00
Scala Steward
2e83289061 Update tika-core to 2.2.0 2021-12-18 07:51:40 +09:00
Scala Steward
e11f651002 Update logback-classic to 1.2.9 2021-12-17 12:02:30 +09:00
Scala Steward
be684a567d Update mockito-core to 4.2.0 2021-12-16 22:51:33 +09:00
Scala Steward
97e552b10f Update sbt, sbt-dependency-tree to 1.5.7 2021-12-15 16:47:00 +09:00
Scala Steward
5bb8046c32 Update logback-classic to 1.2.8 2021-12-15 07:03:01 +09:00
Naoki Takezoe
e7192655f7 Release 4.37.1 (#2949) 2021-12-14 01:05:27 +09:00
Naoki Takezoe
19ba09740c Update gist plugin and notification plugin for GitBucket 4.37.x (#2948) 2021-12-14 00:55:35 +09:00
Naoki Takezoe
d169777722 Fix SSHCommand extension point for apache-sshd 2.x (#2941) 2021-12-11 19:11:23 +09:00
Naoki Takezoe
ff8a5f6b77 Release 4.37.0 (#2940) 2021-12-11 14:28:23 +09:00
Scala Steward
ec953df156 Update sbt, sbt-dependency-tree to 1.5.6 2021-12-10 22:27:40 +09:00
Naoki Takezoe
d6a191d95b Enhance Git Reference APIs (#2937) 2021-12-06 17:16:33 +09:00
Naoki Takezoe
aba428bba1 Fix refs API as far as Jenkins github-branch-source plugin can detect tags (#2936)
Co-authored-by: Thomas Geier <thomas.geier@solidat.de>
2021-12-06 01:06:59 +09:00
Scala Steward
6ab37fd596 Update thumbnailator to 0.4.15 2021-12-05 16:11:17 +09:00
Scala Steward
73fc70f55b Update apache-sshd to 2.8.0 2021-12-04 08:27:01 +09:00
Scala Steward
aad18b7a50 Update sbt-scalafmt to 2.4.5 2021-12-04 08:26:37 +09:00
dependabot[bot]
cc278be5cd Bump actions/cache from 2.1.6 to 2.1.7
Bumps [actions/cache](https://github.com/actions/cache) from 2.1.6 to 2.1.7.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.6...v2.1.7)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-30 09:24:19 +09:00
kenji yoshida
d0f4f82a0f pin jgit 5.x 2021-11-30 09:23:36 +09:00
Naoki Takezoe
1dcbf386b1 Fix SSH server handling (#2930) 2021-11-28 17:39:31 +09:00
Naoki Takezoe
414afd285c Remove unused imports 2021-11-28 15:14:51 +09:00
Naoki Takezoe
35b645d8b5 Merge branch 'keywordsalad-custom-ssh-url' 2021-11-28 15:08:04 +09:00
Naoki Takezoe
b3cba53866 Reformat GitCommandSpec 2021-11-28 15:02:29 +09:00
Naoki Takezoe
a4773bb3ca Merge branch 'master' into custom-ssh-url 2021-11-28 14:56:55 +09:00
Naoki Takezoe
863d8a4af5 Bump apache-sshd to 2.7.0 (#2929) 2021-11-28 14:47:58 +09:00
Scala Steward
3fccd7b53c Update oauth2-oidc-sdk to 9.20 2021-11-25 20:46:24 +09:00
Scala Steward
dd2760eaf7 Update github-api to 1.301 2021-11-24 12:10:25 +09:00
Scala Steward
824bafa739 Update github-api to 1.300 2021-11-22 11:15:11 +09:00
kaz-on
60cdaec05f Fix line highlighting in dark themes (#2921) 2021-11-22 01:31:52 +09:00
kaz-on
c204a435b3 Remove unnecessary loading of google-code-prettify (#2922) 2021-11-22 01:31:16 +09:00
Scala Steward
37accd92d6 Update mockito-core to 4.1.0 2021-11-20 07:35:42 +09:00
Scala Steward
01fd0ee1f0 Update sbt-scalafmt to 2.4.4 2021-11-19 07:19:22 +09:00
Scala Steward
fab1c74473 Update testcontainers-scala to 0.39.12 2021-11-15 06:14:54 +09:00
Scala Steward
0d8fcfd28d Update logback-classic to 1.2.7 2021-11-12 03:45:11 +09:00
Naoki Takezoe
b91a7c32a6 Relax max length limitation for WebHook URLs (#2915) 2021-11-11 01:39:12 +09:00
Naoki Takezoe
7f665c649b Fix duplicated diff issue in exporting patch feature(#2913) 2021-11-05 19:31:52 +09:00
Scala Steward
dcbadb4071 Update sbt-scoverage to 1.9.2 2021-11-03 02:44:03 +09:00
Mira
e3096d15ff resolve #2907 API - not milestone data in issue list (#2908) 2021-11-03 01:23:18 +09:00
Scala Steward
a83c24e7b3 Update scala-library to 2.13.7 2021-11-02 07:15:21 +09:00
Scala Steward
73457c9658 Update testcontainers-scala to 0.39.11 2021-11-02 06:59:06 +09:00
Naoki Takezoe
cfc8d9f3f1 Relax max password length limitation to 40 (#2906) 2021-10-31 11:30:39 +09:00
Scala Steward
8f423b83ea Update postgresql to 42.3.1 2021-10-30 07:15:00 +09:00
Scala Steward
1e7ac532b6 Update testcontainers-scala to 0.39.10 2021-10-28 12:17:14 +09:00
Scala Steward
0fd1db4596 Update mysql, postgresql to 1.16.2 2021-10-23 06:48:28 +09:00
Scala Steward
0755b7ab7f Update testcontainers-scala to 0.39.9 2021-10-22 07:58:09 +09:00
Scala Steward
052382e5c4 Update github-api to 1.135 2021-10-22 07:22:16 +09:00
Scala Steward
f44a63cec1 Update oauth2-oidc-sdk to 9.19 2021-10-20 22:36:12 +09:00
Scala Steward
603d67354a Update mysql, postgresql to 1.16.1 2021-10-19 22:06:56 +09:00
Scala Steward
aafa423b9f Update postgresql to 42.3.0 2021-10-19 06:59:29 +09:00
Mészáros István
2da9d0a801 Add HTTPS support for JettyLauncher (#2896) 2021-10-14 11:27:26 +09:00
Scala Steward
b60c112a74 Update sbt-scoverage to 1.9.1 2021-10-11 19:04:31 +09:00
Scala Steward
843ed6df37 Update mockito-core to 4.0.0 2021-10-07 23:48:03 +09:00
Scala Steward
0f0a849677 Update jetty-continuation, jetty-http, ... to 9.4.44.v20210927 2021-10-01 12:15:06 +09:00
Scala Steward
682901ccbb Update oauth2-oidc-sdk to 9.18 2021-09-30 17:50:08 +09:00
Naoki Takezoe
048fdb8837 Remove unnecessary workaround for scala-xml version conflict (#2888) 2021-09-27 03:00:15 +09:00
scala-steward-bot
3353616789 Update scalatra, scalatra-forms, ... to 2.8.2 (#2886) 2021-09-25 19:07:58 +09:00
scala-steward-bot
b6cb4c865f Update scalatra, scalatra-forms, ... to 2.8.1 (#2885) 2021-09-25 16:00:15 +09:00
kenji yoshida
1fcfd093f7 add jdk 17 test 2021-09-25 10:51:36 +09:00
Scala Steward
3f27c6e733 Update postgresql to 42.2.24 2021-09-23 21:00:09 +09:00
Scala Steward
b6bd9bfc3b Update oauth2-oidc-sdk to 9.17 2021-09-22 07:27:44 +09:00
Scala Steward
6c392f0056 Update oauth2-oidc-sdk to 9.16 2021-09-21 21:18:30 +09:00
Scala Steward
9a38de9a23 Update testcontainers-scala to 0.39.8 2021-09-20 19:57:18 +09:00
Scala Steward
8883600090 Update sbt-scoverage to 1.9.0 2021-09-17 01:27:52 +09:00
Naoki Takezoe
ab822a3c27 Fix Wiki page editing bug when over 100 pages (#2869) 2021-09-13 00:48:38 +09:00
Scala Steward
0e4d64de23 Update org.eclipse.jgit.archive, ... to 5.13.0.202109080827-r 2021-09-12 23:08:48 +09:00
Scala Steward
fbc6bd36bd Update logback-classic to 1.2.6 2021-09-10 13:09:30 +09:00
Naoki Takezoe
ed90ca2dce Bump gitbucket-pages-plugin to 1.10.0 (#2856) 2021-09-10 09:03:51 +09:00
Scala Steward
537ef92149 Update github-api to 1.133 2021-09-09 15:56:16 +09:00
Scala Steward
d51afa7d40 Update java-diff-utils to 4.11 2021-09-08 21:27:57 +09:00
Scala Steward
975cffff48 Update sbt-assembly to 1.1.0 2021-09-01 23:08:42 +09:00
Scala Steward
d92e9c00e8 Update testcontainers-scala to 0.39.7 2021-08-31 14:52:37 +09:00
KN4CK3R
12d72cbb19 Add support for "all" in issue list API (#2859) 2021-08-31 00:38:38 +09:00
Logan McGrath
e7a6f0930b Closes #2818 - Supporting custom SSH URL's when hosting behind a proxy 2021-08-29 16:38:06 -07:00
Scala Steward
d8e03bed1f Update mockito-core to 3.12.4 2021-08-26 08:43:19 +09:00
Scala Steward
f48c087cd8 Update mockito-core to 3.12.3 2021-08-25 08:39:46 +09:00
Scala Steward
917663e0df Update mockito-core to 3.12.2 2021-08-25 06:11:05 +09:00
Scala Steward
556ddbc926 Update tika-core to 2.1.0 2021-08-24 23:07:23 +09:00
Scala Steward
1c6f37b8e8 Update testcontainers-scala to 0.39.6 2021-08-23 15:26:54 +09:00
Scala Steward
720a329a50 Update oauth2-oidc-sdk to 9.15 2021-08-21 07:09:24 +09:00
Scala Steward
220a8f076a Update mockito-core to 3.12.1 2021-08-21 07:09:08 +09:00
Scala Steward
43be8333c7 Update oauth2-oidc-sdk to 9.14 2021-08-20 21:08:36 +09:00
Scala Steward
08706ab4df Update mockito-core to 3.12.0 2021-08-20 08:04:50 +09:00
Naoki Takezoe
b1196657e0 Release GitBucket 4.36.2 2021-08-16 01:11:21 +09:00
Naoki Takezoe
334bd0c919 Escape user name in avatar image tag (#2845) 2021-08-16 01:06:16 +09:00
Scala Steward
cf0f896972 Update mariadb-java-client to 2.7.4 2021-08-12 07:10:24 +09:00
Scala Steward
d21ca3ff8a Update oauth2-oidc-sdk to 9.12 2021-08-11 19:08:07 +09:00
xuwei-k
83f1f16de7 remove == true 2021-08-09 16:56:55 +09:00
xuwei-k
0fa2ccf107 use keys 2021-08-09 16:48:03 +09:00
xuwei-k
18e3dd431b use until instead of to 2021-08-09 16:48:03 +09:00
xuwei-k
f25dee2249 .getOrElse(None) => .flatten 2021-08-09 16:48:03 +09:00
kenji yoshida
575ffa9580 avoid Array.toString 2021-08-09 16:43:09 +09:00
xuwei-k
f17af5aeb0 use forall or exists instead of map(f).getOrElse 2021-08-09 16:40:37 +09:00
xuwei-k
639f153589 use sizeIs 2021-08-09 16:38:16 +09:00
xuwei-k
fb07098c13 map(f).flatten => flatMap 2021-08-09 16:30:40 +09:00
xuwei-k
74fc08b039 use foreach instead of map 2021-08-09 16:28:15 +09:00
xuwei-k
2776e00004 fix typo 2021-08-09 16:25:55 +09:00
xuwei-k
5932fce303 remove semicolons 2021-08-09 16:12:41 +09:00
xuwei-k
39c9fc4261 remove redundant toString 2021-08-09 16:10:23 +09:00
kenji yoshida
89ea4509a3 use SAM conversion 2021-08-09 16:08:07 +09:00
kenji yoshida
d19d838ead getOrElse(null) => orNull 2021-08-09 16:05:22 +09:00
kenji yoshida
633a2699a8 find(f).isDefined => exists(f) 2021-08-09 16:03:22 +09:00
kenji yoshida
e79bca4a3c remove unnecessary local variable initial values 2021-08-09 16:01:02 +09:00
kenji yoshida
f8ab480d20 remove unused import 2021-08-09 15:55:52 +09:00
kenji yoshida
a14129e340 use diamond operator 2021-08-09 15:55:03 +09:00
Scala Steward
5ec39df6e0 Update oauth2-oidc-sdk to 9.11 2021-08-02 07:07:47 +09:00
kenji yoshida
956e0c6321 fix warning in build.sbt
02a0cfa0a6/io/src/main/scala/sbt/io/IO.scala (L611-L630)

```
/home/runner/work/gitbucket/gitbucket/build.sbt:205: warning: method jar in object IO is deprecated (since 1.3.2): Please specify whether to use a static timestamp
  IO jar (contentMappings.map { case (file, path) => (file, path.toString) }, outputFile, manifest)
     ^
```
2021-07-31 16:14:15 +09:00
Scala Steward
0660a9203a Update oauth2-oidc-sdk to 9.10.2 2021-07-27 23:30:19 +09:00
kenji yoshida
1b660272a1 prepare Scala 3 2021-07-27 07:23:01 +09:00
Scala Steward
d9ef9b874d Update logback-classic to 1.2.5 2021-07-27 06:56:21 +09:00
Scala Steward
7824f796ee Update json4s-jackson to 4.0.3 2021-07-27 03:01:31 +09:00
Scala Steward
838a8d4c7b Update scalatra, scalatra-forms, ... to 2.8.0 (#2834)
Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2021-07-25 09:30:05 +09:00
Scala Steward
8db9f77f91 Update github-api to 1.132 2021-07-23 10:22:45 +09:00
Naoki Takezoe
4f82a469d9 Release GitBucket 4.36.1 2021-07-22 14:30:44 +09:00
Naoki Takezoe
0f6ae8559b Bump gist-plugin to 4.21.0 (#2832) 2021-07-22 14:27:34 +09:00
Scala Steward
3f4b2eec35 Update logback-classic to 1.2.4 (#2826) 2021-07-21 13:14:38 +09:00
Lilian BENOIT
a020601d3a exclude dependency org.slf4j from HikariCP (#2830) 2021-07-21 09:17:51 +09:00
Scala Steward
d511205588 Update tika-core to 2.0.0 2021-07-21 07:19:21 +09:00
Scala Steward
fc896b2ea1 Update mysql, postgresql to 1.16.0 2021-07-21 07:09:17 +09:00
Pedro Rijo
3819670535 Update sbt-dependency-graph plugin installation (#2828)
* Update sbt-dependency-graph plugin installation

According with https://github.com/sbt/sbt-dependency-graph#usage-instructions, for sbt >= 1.4.x we should install the plugin with `addDependencyTreePlugin` instead of `addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1")`

* Fix scalafmt
2021-07-20 18:56:07 +09:00
Lilian BENOIT
067669a18c unprotect plugin-assets (#2825) 2021-07-18 18:31:00 +09:00
Naoki Takezoe
bef7cee8db Fix typo 2021-07-17 17:34:51 +09:00
Naoki Takezoe
cb9f56fc22 Release GitBucket 4.36.0 2021-07-17 17:26:18 +09:00
kenji yoshida
719a521f06 Update build.yml 2021-07-17 13:00:44 +09:00
Scala Steward
413754976f Update oauth2-oidc-sdk to 9.10.1 2021-07-15 23:22:47 +09:00
Scala Steward
4530cfc068 Update commons-io to 2.11.0 2021-07-13 23:11:16 +09:00
Scala Steward
fcc7d6da2d Update commons-compress to 1.21 2021-07-13 07:51:46 +09:00
Scala Steward
33e565d029 Update sbt to 1.5.5 2021-07-12 23:08:02 +09:00
Naoki Takezoe
6a1da37e9a Ignore submodules in repository archive downloading (#2817) 2021-07-11 16:55:44 +09:00
Naoki Takezoe
897cc5eea4 Support tags in the branch selector (#2811) 2021-07-11 16:05:41 +09:00
Naoki Takezoe
5cbea281af Add new option to disable XSS protection in image rendering (#2806) 2021-07-10 12:51:25 +09:00
Scala Steward
e74db57b75 Update sbt-scalafmt to 2.4.3 2021-07-09 09:08:26 +09:00
Scala Steward
6b2d124d09 Update jetty-continuation, jetty-http, ... to 9.4.43.v20210629 2021-07-07 11:07:23 +09:00
Scala Steward
7b3c77db8c Update tika-core to 1.27 2021-07-07 07:12:36 +09:00
Scala Steward
1bcab5c2c7 Update postgresql to 42.2.23 2021-07-07 07:11:43 +09:00
Scala Steward
16020e9a7d Update oauth2-oidc-sdk to 9.9.1 2021-07-03 20:05:42 +09:00
Naoki Takezoe
dfd3e22986 Handle slash contained tag name correctly in releases (#2805) 2021-06-27 03:32:18 +09:00
Naoki Takezoe
48d7a20fb7 Keep default merge strategy selection (#2804) 2021-06-27 02:40:17 +09:00
Scala Steward
04108a0a1a Update mockito-core to 3.11.2 2021-06-22 06:16:55 +09:00
Naoki Takezoe
e0bab59846 Fix Repository Contents API issues (#2802) 2021-06-21 00:55:03 +09:00
Naoki Takezoe
1004c83bc4 Drop the use of SyntaxSugars.defining from codebase (#2800) 2021-06-20 09:48:50 +09:00
ShalokShalom
502bb450e3 correct typo (#2801)
Gitter is a name, and since that capitalized
2021-06-20 02:32:21 +09:00
Scala Steward
fb03b0bec7 Update postgresql to 42.2.22 2021-06-17 06:21:51 +09:00
Scala Steward
2c3a1c9c92 Update github-api to 1.131 2021-06-16 08:54:24 +09:00
Scala Steward
73b7ee2d57 Update sbt to 1.5.4 2021-06-14 19:50:44 +09:00
Scala Steward
71df890f39 Update commons-io to 2.10.0 2021-06-14 07:09:47 +09:00
Scala Steward
1fdac404b1 Update mockito-core to 3.11.1 2021-06-12 01:12:18 +09:00
Scala Steward
47be1e60bb Update postgresql to 42.2.21 2021-06-11 07:53:15 +09:00
Scala Steward
1c05f50954 Update jetty-continuation, jetty-http, ... to 9.4.42.v20210604 2021-06-09 09:10:08 +09:00
Scala Steward
ce26a48fd7 Update org.eclipse.jgit.archive, ... to 5.12.0.202106070339-r 2021-06-08 06:53:34 +09:00
Scala Steward
26e0838ae0 Update oauth2-oidc-sdk to 9.9 2021-06-07 21:08:37 +09:00
xuwei-k
6b5b0db20a avoid enum
prepare Scala 3
2021-06-07 20:19:57 +09:00
xuwei-k
5973c8cb85 prepare Scala 3 2021-06-07 20:16:18 +09:00
Scala Steward
f683439c73 Update sbt-assembly to 1.0.0 2021-06-07 19:24:14 +09:00
xuwei-k
625f3655ec prepare Scala 3 2021-06-07 17:35:14 +09:00
Scala Steward
4a5ab1ae71 Update oauth2-oidc-sdk to 9.8.1 2021-06-05 19:25:06 +09:00
kenji yoshida
3bcae2c6d2 Create CODEOWNERS 2021-06-04 11:54:06 +09:00
Scala Steward
4441eff657 Update sbt to 1.5.3 2021-06-04 11:51:42 +09:00
Scala Steward
9fed83e222 Update oauth2-oidc-sdk to 9.8 2021-06-04 11:51:33 +09:00
Scala Steward
42ea9bac65 Update github-api to 1.130 2021-06-04 11:51:27 +09:00
Scala Steward
2aba827772 Update mockito-core to 3.11.0 2021-06-04 11:51:23 +09:00
dependabot[bot]
31e84bd543 Bump actions/cache from 2.1.5 to 2.1.6
Bumps [actions/cache](https://github.com/actions/cache) from 2.1.5 to 2.1.6.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.5...v2.1.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-04 11:51:11 +09:00
Scala Steward
ba471b8bf7 Update sbt-scoverage to 1.8.2 (#2780) 2021-05-30 08:46:40 +09:00
Scala Steward
90ec95494d Update commons-io to 2.9.0 (#2778) 2021-05-26 16:22:49 +09:00
Scala Steward
e72dbad765 Update testcontainers-scala to 0.39.5 (#2777) 2021-05-26 16:22:35 +09:00
Scala Steward
ed63ea4674 Update github-api to 1.129 (#2776) 2021-05-26 16:22:25 +09:00
Scala Steward
559a52404f Update oauth2-oidc-sdk to 9.7 2021-05-23 09:41:40 +09:00
Scala Steward
5e80848524 Update oauth2-oidc-sdk to 9.5.3 2021-05-22 21:24:38 +09:00
Scala Steward
055a4f0798 Update oauth2-oidc-sdk to 9.5.2 (#2771) 2021-05-21 02:32:29 +09:00
Scala Steward
6f432e537c Update sbt-scoverage to 1.8.1 (#2772) 2021-05-21 02:32:11 +09:00
Scala Steward
a2abbbbd63 Update scala-library to 2.13.6 2021-05-18 11:53:45 +09:00
Scala Steward
16707b99e6 Update jetty-continuation, jetty-http, ... to 9.4.41.v20210516 2021-05-18 11:53:36 +09:00
Scala Steward
80a4ed62cc Update org.eclipse.jgit.archive, ... to 5.11.1.202105131744-r 2021-05-17 07:06:13 +09:00
Scala Steward
b713a334f0 Update mariadb-java-client to 2.7.3 2021-05-14 06:45:53 +09:00
Scala Steward
ec6264c04c Update testcontainers-scala to 0.39.4 (#2765)
Co-authored-by: Naoki Takezoe <takezoe@gmail.com>
2021-05-14 06:45:33 +09:00
Scala Steward
44bb1ab565 Update mockito-core to 3.10.0 (#2766) 2021-05-13 02:35:27 +09:00
Scala Steward
523ee025ac Update sbt-scoverage to 1.8.0 (#2764) 2021-05-11 23:13:31 +09:00
Scala Steward
d193c6399c Update sbt-scoverage to 1.7.3 2021-05-11 12:16:17 +09:00
Scala Steward
8c9715f4d9 Update oauth2-oidc-sdk to 9.5.1 2021-05-11 12:16:13 +09:00
Scala Steward
3bbdcd5f14 Update sbt to 1.5.2 2021-05-11 12:16:05 +09:00
Scala Steward
c183d3b0b5 Update sbt-scoverage to 1.7.2 (#2759) 2021-05-03 20:10:28 +09:00
Scala Steward
b6f0c6bf57 Update oauth2-oidc-sdk to 9.5 2021-05-02 15:08:38 +09:00
Scala Steward
8719e834f3 Update java-diff-utils to 4.10 (#2754) 2021-04-29 10:21:10 +09:00
Scala Steward
f23b8c6d61 Update sbt-scoverage to 1.7.0 (#2753) 2021-04-29 10:21:00 +09:00
Scala Steward
d46be31ea8 Update oauth2-oidc-sdk to 9.4.1 2021-04-27 06:53:40 +09:00
Scala Steward
9bb36e4cb2 Update sbt to 1.5.1 2021-04-27 06:53:29 +09:00
Scala Steward
2780fb9605 Update oauth2-oidc-sdk to 9.4 2021-04-23 08:58:10 +09:00
Scala Steward
b69e2d299a Update github-api to 1.128 2021-04-23 08:57:45 +09:00
Scala Steward
a07bd7b1a4 Update postgresql to 42.2.20 2021-04-23 08:57:33 +09:00
dependabot[bot]
d605455678 Bump actions/cache from v2.1.4 to v2.1.5
Bumps [actions/cache](https://github.com/actions/cache) from v2.1.4 to v2.1.5.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.4...1a9e2138d905efd099035b49d8b7a3888c653ca8)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-20 12:31:14 +09:00
Naoki Takezoe
781b1169a2 Use account name as pusher for commits by WebUI (#2745) 2021-04-17 13:08:42 +09:00
Scala Steward
80112d3437 Update mysql, postgresql to 1.15.3 2021-04-17 12:42:41 +09:00
Scala Steward
131af7f4fa Update jetty-continuation, jetty-http, ... to 9.4.40.v20210413 2021-04-17 12:42:15 +09:00
Naoki Takezoe
1ceac4ef9f Minor fix for WebHook testing UI (#2744) 2021-04-17 12:40:14 +09:00
Jesse Gorzinski
b7aa3e69f4 (bugfix) password msg when editing an LDAP profile (#2732) 2021-04-15 16:55:46 +09:00
Scala Steward
62231c41b2 Update oauth2-oidc-sdk to 9.3.3 2021-04-14 19:07:45 +09:00
dependabot[bot]
6c0a33712b Bump actions/setup-java from v1 to v2 (#2736)
Bumps [actions/setup-java](https://github.com/actions/setup-java) from v1 to v2.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v1...8764a52df183aa0ccea74521dfd9d506ffc7a19a)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2021-04-14 09:50:22 +00:00
Scala Steward
e192624489 Update github-api to 1.127 (#2735) 2021-04-10 12:34:09 +09:00
Scala Steward
68609e44de Update mockito-core to 3.9.0 (#2733) 2021-04-08 11:36:47 +09:00
Naoki Takezoe
c8e3af6072 Abolish the pull request title length limitation (#2731) 2021-04-07 12:49:58 +09:00
Naoki Takezoe
9f7048a19c Eliminate context.loginAccount.get() by adding context.withLoginAccount() (#2729) 2021-04-07 12:19:47 +09:00
Scala Steward
cbdc0528ca Update sbt to 1.5.0 2021-04-06 13:22:29 +09:00
Naoki Takezoe
444facc95b Drop unused syntax sugars (#2728) 2021-04-05 09:54:56 +09:00
Naoki Takezoe
ed40ddaa45 Remove unused import statements (#2726) 2021-04-04 23:35:22 +09:00
Naoki Takezoe
43c629b3e5 Fix repository creation permission check (#2725) 2021-04-04 10:22:34 +09:00
onukura
0d2c156579 Add function to refer issue/PR of other repositories within issue/PR conversations (#2608) 2021-04-03 11:14:36 +09:00
Scala Steward
ab218f8540 Update tika-core to 1.26 2021-03-30 14:51:43 +09:00
Scala Steward
4b8a375890 Update oauth2-oidc-sdk to 9.3 2021-03-30 14:51:34 +09:00
Scala Steward
9c3a5f3f0a Update jetty-continuation, jetty-http, ... to 9.4.39.v20210325 2021-03-30 14:51:19 +09:00
Scala Steward
1bcfbec29c Update oauth2-oidc-sdk to 9.2.4 2021-03-26 12:35:23 +09:00
Scala Steward
781940436a Update github-api to 1.125 (#2717) 2021-03-26 12:09:23 +09:00
kaz-on
7f226a6ab1 Fixed file names passed to syntax highlighter in diff view (#2716) 2021-03-25 07:45:35 +09:00
Shreejan Shrestha
f538950d64 Solve repository deletion error on Windows (#2711)
- Added function to delete given folder recursively.
- Used the function for deleting the folder, while deleting repository.

fixes #2628
2021-03-23 09:06:38 +09:00
Naoki Takezoe
142be65893 Revert workaround for timestamp issue in war file creation (#2714) 2021-03-23 08:56:33 +09:00
Scala Steward
8b01e5bc1f Update github-api to 1.124 2021-03-21 11:08:42 +09:00
Scala Steward
bde0aab207 Update oauth2-oidc-sdk to 9.2.3 2021-03-21 11:08:27 +09:00
Scala Steward
31ecfef1c9 Update sbt-twirl to 1.5.1 2021-03-21 11:07:36 +09:00
Scala Steward
0fdae4c334 Update org.eclipse.jgit.archive, ... to 5.11.0.202103091610-r 2021-03-16 20:13:23 +09:00
xuwei-k
3ea7de974b add explicit types for implicit val
prepare Scala 3
2021-03-14 10:53:50 +09:00
kenji yoshida
34a7990d1d use slash syntax 2021-03-14 10:32:58 +09:00
Scala Steward
709d759d09 Update thumbnailator to 0.4.14 2021-03-14 08:10:51 +09:00
Scala Steward
2d47252b27 Update sbt to 1.4.9 2021-03-14 08:08:45 +09:00
xuwei-k
8586e141fc avoid do-while
prepare Scala 3

https://dotty.epfl.ch/docs/reference/dropped-features/do-while.html
2021-03-10 12:10:30 +09:00
Scala Steward
e3887e6872 Update sbt to 1.4.8 2021-03-10 11:54:48 +09:00
Scala Steward
fd658c35ee Update oauth2-oidc-sdk to 9.2.2 2021-03-07 13:19:34 +09:00
Scala Steward
ca4c1b237f Update HikariCP to 4.0.3 2021-03-07 13:19:00 +09:00
Scala Steward
92b17fd719 Update json4s-jackson to 3.6.11 (#2699) 2021-03-03 15:49:19 +09:00
Naoki Takezoe
b4453531a3 Update auto_update.md 2021-03-02 20:58:58 +09:00
Naoki Takezoe
de72a9223f Update build.md 2021-03-02 20:48:58 +09:00
Scala Steward
ae26e3031e Update jetty-continuation, jetty-http, ... to 9.4.38.v20210224 2021-02-27 13:15:35 +09:00
Scala Steward
c26b41cfc2 Update github-api to 1.123 2021-02-27 13:15:15 +09:00
Scala Steward
2c4ee664ab Update oauth2-oidc-sdk to 9.2.1 2021-02-26 19:16:36 +09:00
kenji yoshida
911cd45965 ignore jetty 11.x and 10.x updates 2021-02-26 07:19:51 +09:00
Scala Steward
320cc58c62 Update testcontainers-scala to 0.39.3 (#2695) 2021-02-25 17:58:01 +09:00
ziggystar
cfa1638e3c Update README.md (#2694)
## Developer information is hard to find

I've been looking for instructions on how to build gitbucket a couple of times, and I've never found them until takzoe pointed me towards `doc/build.md`. After knowing about this, I read through the readme once again, looking for such a link, and then I've found it as the last sentence within a section named `Features`.

What I've been looking for:
 - either a file named `INSTALL.md`, `BUILD.md` in `/`
 - or a section (or a link) in the main readme

I've put the link to `doc/readme.md` into a separate section "Building and Development" and added a short summary. I'm not so sure about the order of the new section and "Plugins".
2021-02-25 06:53:09 +09:00
Scala Steward
27264bf59a Update testcontainers-scala to 0.39.2 (#2693) 2021-02-24 23:25:22 +09:00
Scala Steward
935283272e Update scala-library to 2.13.5 2021-02-23 17:00:52 +09:00
Scala Steward
ea440294b1 Update oauth2-oidc-sdk to 9.2 2021-02-23 10:32:29 +09:00
Scala Steward
df8435bf6a Update jetty-continuation, jetty-http, ... to 9.4.37.v20210219 2021-02-23 10:31:29 +09:00
Scala Steward
4fe019b11f Update mockito-core to 3.8.0 2021-02-23 10:31:12 +09:00
kenji yoshida
538c79705a updates.includeScala = true 2021-02-23 10:26:50 +09:00
onukura
e94d972741 Add create and push webhooks call for branch creation via GUI. (#2624) 2021-02-22 03:38:43 +09:00
Naoki Takezoe
c58a9aca6a Links to files and lines in the diff view (#2685) 2021-02-21 23:33:53 +09:00
solsticesurfer
a6612e8522 Prevent execution of empty SQL strings during database import (#2664)
Co-authored-by: Naoki Takezoe <takezoe@gmail.com>
2021-02-21 17:10:06 +09:00
Naoki Takezoe
bd455b9a0a Update authenticator.md 2021-02-21 14:06:04 +09:00
Naoki Takezoe
122853f1f6 Fix issue / pull request view templates (#2684) 2021-02-21 08:06:11 +09:00
Naoki Takezoe
debbc21bf3 Upgrade java-diff-utils (#2678) 2021-02-20 18:27:15 +09:00
Scala Steward
d991fdcbd9 Update postgresql to 42.2.19 (#2682) 2021-02-20 17:44:35 +09:00
Scala Steward
78cc8f14fd Update commons-net to 3.8.0 (#2683) 2021-02-20 17:44:23 +09:00
Naoki Takezoe
09f1a06267 Update authenticator.md 2021-02-20 17:41:50 +09:00
Naoki Takezoe
6fb910a939 Update authenticator.md 2021-02-20 17:41:13 +09:00
Naoki Takezoe
9e891a0168 Fix typo 2021-02-20 17:40:30 +09:00
Naoki Takezoe
0bc77ce453 Fix typo 2021-02-20 17:40:04 +09:00
kenji yoshida
a46c821673 use slash syntax instead of old "in"
https://github.com/sbt/sbt/pull/6309
2021-02-17 15:29:21 +09:00
Scala Steward
cae843d18f Update sbt-pgp to 2.1.2 (#2681)
Co-authored-by: Naoki Takezoe <takezoe@gmail.com>
2021-02-16 18:55:11 +09:00
Scala Steward
40ffc689b0 Update testcontainers-scala to 0.39.1 2021-02-15 11:15:09 +09:00
Scala Steward
65afbd25b8 Update junit to 4.13.2 2021-02-14 09:31:50 +09:00
Scala Steward
458b30610f Update HikariCP to 4.0.2 2021-02-13 18:22:22 +09:00
Scala Steward
a89608a2e2 Update testcontainers to 1.15.2 2021-02-12 11:22:40 +09:00
dependabot[bot]
0f45311d5e Bump actions/cache from v2 to v2.1.4
Bumps [actions/cache](https://github.com/actions/cache) from v2 to v2.1.4.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2...26968a09c0ea4f3e233fdddbafd1166051a095f6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-09 18:19:41 +09:00
Jason Southwell
447ed6ce88 As is, the unsuspend API cannot unsuspend since it's not searching suspended accounts. This should allow the api to function without getting a 404. (#2660)
Co-authored-by: Jason Southwell <jsouthwell@sivv.com>
2021-02-07 22:55:00 +09:00
Scala Steward
ab358a10bc Update oauth2-oidc-sdk to 9.1 2021-02-06 08:00:20 +09:00
Scala Steward
5148851d49 Update testcontainers-scala to 0.39.0 2021-02-06 08:00:05 +09:00
Scala Steward
068ecd30fe Update testcontainers-scala to 0.38.9 2021-02-06 03:19:26 +09:00
Scala Steward
5396c0ee58 Update sbt to 1.4.7 2021-02-06 03:19:10 +09:00
Scala Steward
2328c1878b Update mariadb-java-client to 2.7.2 2021-01-31 15:49:57 +09:00
Scala Steward
bc9a6f464a Update oauth2-oidc-sdk to 8.36 2021-01-31 15:49:47 +09:00
Scala Steward
4613fd4cb4 Update oauth2-oidc-sdk to 8.35 2021-01-28 21:41:02 +09:00
Scala Steward
ff89c8805c Update ec4j-core to 0.3.0 2021-01-27 19:18:05 +09:00
Scala Steward
95d98c525b Update sbt-scalafmt to 2.4.2 2021-01-27 19:17:41 +09:00
Scala Steward
bc78a38570 Update postgresql to 42.2.18
Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2021-01-27 11:28:19 +09:00
Scala Steward
8db2398dd8 Update mariadb-java-client to 2.7.1 2021-01-27 11:03:16 +09:00
Scala Steward
e073ca74da Update oauth2-oidc-sdk to 8.34.2 2021-01-27 11:03:09 +09:00
Scala Steward
50e899bf83 Update ec4j-core to 0.0.4 2021-01-27 11:02:56 +09:00
Scala Steward
5ddd6234e3 Update cache2k-all to 1.6.0.Final 2021-01-27 11:02:36 +09:00
Scala Steward
84fa11b5df Update jetty to 9.4.36.v20210114 2021-01-27 11:01:57 +09:00
Scala Steward
f51db60fc7 Update mockito-core to 3.7.7 2021-01-27 11:01:14 +09:00
Scala Steward
351e72e8c2 Update sbt-scalafmt to 2.0.7 2021-01-27 11:01:00 +09:00
Scala Steward
a0f54b0b8e Update tika-core to 1.25 2021-01-26 20:49:36 +09:00
Scala Steward
4c491e40c7 Update httpclient to 4.5.13 2021-01-26 20:49:19 +09:00
Scala Steward
54440d9cde Update thumbnailator to 0.4.13 2021-01-26 20:48:42 +09:00
Scala Steward
ea8333844c Update org.eclipse.jgit.archive, ... to 5.10.0.202012080955-r 2021-01-26 20:48:24 +09:00
Scala Steward
fc34df7008 Update github-api to 1.122 2021-01-26 20:48:05 +09:00
Scala Steward
d49d62edfc Update junit to 4.13.1 2021-01-26 20:47:47 +09:00
Scala Steward
246e2e2de4 Update sbt-pgp to 2.1.1 2021-01-26 12:28:23 +09:00
Scala Steward
83b48d26ce Update HikariCP to 4.0.1 2021-01-26 12:11:11 +09:00
Scala Steward
3d40094925 Update commons-net to 3.7.2 2021-01-26 12:10:56 +09:00
Scala Steward
2d7e8526ed Update testcontainers-scala to 0.38.8 2021-01-26 11:39:45 +09:00
Scala Steward
7768f4c4dd Update sbt-scalafmt to 2.0.0 (#2631)
Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2021-01-26 10:46:32 +09:00
kenji yoshida
e43fabf895 set timeout-minutes 2021-01-26 10:21:43 +09:00
Scala Steward
7cf83979a6 Update oauth2-oidc-sdk to 8.34.1 2021-01-26 10:19:16 +09:00
Scala Steward
1ecc30c570 Update typesafe:config to 1.4.1 2021-01-26 10:18:56 +09:00
Scala Steward
ee0721f40d Update sbt-pgp to 1.1.2-1 2021-01-26 10:18:31 +09:00
kenji yoshida
07836edf84 Create .scala-steward.conf 2021-01-26 07:36:12 +09:00
Naoki Takezoe
bfbe40e027 Release GitBucket 4.35.3 (#2626)
* Update version to 4.35.3
* Update README and CHANGELOG
2021-01-14 11:22:13 +09:00
Naoki Takezoe
842d3b6185 Fix timestamp which is set to create war file to epoch millis (#2627) 2021-01-13 22:45:03 +09:00
Naoki Takezoe
086437ca4f Set time to create war instead of specifying SOURCE_DATE_EPOCH (#2625) 2021-01-13 11:14:28 +09:00
Naoki Takezoe
6e48435f38 Add screenshot to README 2021-01-10 22:01:47 +09:00
Naoki Takezoe
3b8e903cb5 Set SOURCE_DATE_EPOCH to build war file (#2623) 2021-01-08 16:52:02 +09:00
onukura
55308f2deb fix delete wiki page function (#2622) 2021-01-07 22:42:05 +09:00
Naoki Takezoe
a913a95d5b Release 4.35.2 2020-12-30 00:37:53 +09:00
Naoki Takezoe
870a20721c Bump oauth2-oidc-sdk to 8.29.1 (#2617) 2020-12-30 00:36:04 +09:00
Naoki Takezoe
df81f6e364 Upgrade gitbucket-notifications-plugin to 1.10.0 (#2616) 2020-12-29 22:42:23 +09:00
pbg42
d4a892bf7f Update CONTRIBUTING.md (#2613)
corrected just a typo
2020-12-29 11:11:47 +09:00
Naoki Takezoe
41d13db5d4 Release 4.35.1 2020-12-29 00:31:22 +09:00
Naoki Takezoe
c63e20ce7d Resurrect ActivityComponent for binary compatibility in 4.35.1 (#2612) 2020-12-29 00:26:58 +09:00
Naoki Takezoe
736fdafea4 Call webhook when pull request is merged (#2611) 2020-12-28 10:54:48 +09:00
Naoki Takezoe
1dfe76e21c Fix WEB_HOOK table migration issue in 4.35.0 (#2610) 2020-12-27 19:10:07 +09:00
Naoki Takezoe
e7ddfc7ebb Bump to sbt 1.4.6, Scala 2.13.3, and Scalatra 2.7.1 (#2609)
* Bump to sbt 1.4.6, Scala 2.13.3, and Scalatra 2.7.1
* Fix warnings in Scala 2.13
2020-12-27 13:35:57 +09:00
Naoki Takezoe
66be84289d Show commit status at commits tab of pull request (#2606) 2020-12-25 22:34:47 +09:00
Naoki Takezoe
2a3c8e0712 Update README and CHANGELOG for 4.45.0 2020-12-25 22:00:31 +09:00
onukura
d3a29b3ecb fix issue title on milestone page (#2603) 2020-12-16 14:39:43 +09:00
Naoki Takezoe
7a50a15748 Upgrade plugins to GitBucket 4.35.0 compatibles 2020-12-14 03:00:13 +09:00
Naoki Takezoe
9a1b55b992 Upgrade plugins to GitBucket 4.35.0 compatibles 2020-12-14 02:58:22 +09:00
Naoki Takezoe
828b798c0e Tweak GitHub Actions trigger 2020-12-14 02:36:01 +09:00
Naoki Takezoe
8d8845536d Integration test for Web API (#2578) 2020-12-13 21:04:44 +09:00
Naoki Takezoe
f20497e769 Setting version to 4.35.0 2020-12-13 14:38:51 +09:00
Naoki Takezoe
6053d9826e Call ReceiveHook when pull request is merged (#2520) 2020-12-13 03:29:19 +09:00
Naoki Takezoe
85263474a7 Show the commit status in various places (#2601) 2020-12-13 02:30:48 +09:00
onukura
c02a722799 Bump sbt to 1.4.4 (#2602) 2020-12-13 02:10:57 +09:00
Naoki Takezoe
ce4faceccc Update README.md 2020-12-07 04:22:14 +09:00
onukura
04c8f8b864 Improve issue comment management (#2588) 2020-12-07 04:19:30 +09:00
onukura
1b32e13113 Add milestone page (#2586) 2020-12-07 04:17:30 +09:00
Naoki Takezoe
401728d47f Fix branch protection setting API (#2600) 2020-12-07 02:28:49 +09:00
kenji yoshida
31ace89f43 Create dependabot.yml 2020-11-21 01:51:03 +09:00
onukura
995cb86e90 fix typo on UI of commit with new branch (#2594) 2020-11-09 22:17:27 +09:00
Naoki Takezoe
e27623ca29 Bump sbt to 1.4.2 (#2592) 2020-11-04 01:32:20 +09:00
onukura
ea4da561c5 Add syntax highlighter setting per user (#2555) 2020-11-04 00:51:25 +09:00
Mészáros István
2e8f3efafd Implement API for creating, updating and deleting refs. (#2590) 2020-11-04 00:01:16 +09:00
Marcel Berteler
f25cf5781c Use attr() instead of data() to prevent parsing of json (#2548)
* Use attr() instead of data() to prevent parsing of json

A fix for issue #2503 
Valid JSON text will be converted to a JSON object, not text , when using .data(). using .attr() prevents this behavior.

* Update gitbucket.js

Use different methods to get old and head values depending on the object type
2020-11-03 16:25:47 +09:00
onukura
d97f7c6025 Add function to create new branch with commit on UI and start PR (#2571) 2020-11-03 16:04:08 +09:00
SIkebe
e91d903650 Upload images from clipboard (#2518) 2020-11-03 15:35:03 +09:00
Akifumi Tominaga
4f93f06de5 Fix file name of the commit comment (#2581) 2020-11-03 15:31:53 +09:00
SIkebe
08ed3c4171 Bump sbt from 1.4.0 to 1.4.1 (#2585) 2020-10-22 01:05:21 +09:00
onukura
5193d82980 save editor theme to localStorage (#2583) 2020-10-18 17:12:47 +09:00
uli-heller
eab82bf1be json4s-jackson-3.6.10 (#2567)
Co-authored-by: Naoki Takezoe <takezoe@gmail.com>
2020-10-14 22:45:47 +09:00
uli-heller
311d758910 thumbnailator-0.4.12 (#2570) 2020-10-14 15:16:48 +09:00
uli-heller
097a2d32b8 jetty-9.4.32.v20200930 (#2563) 2020-10-14 15:16:13 +09:00
uli-heller
a34766ccfd commons-io-2.8.0 (#2566) 2020-10-14 15:15:21 +09:00
uli-heller
147eef9ee5 commons-net-3.7 (#2565) 2020-10-14 15:15:09 +09:00
uli-heller
49118662b2 mariadb-java-client-2.7.0 (#2564) 2020-10-14 15:14:49 +09:00
onukura
5989f2e2cb fix milestone api (#2580) 2020-10-14 15:08:51 +09:00
onukura
127f034bba update latest activity date when pr merged (#2560) 2020-10-14 15:07:28 +09:00
onukura
e1e00c4b94 Add Get-branch-protection, Delete-branch-protection, Get-all-status-check-contexts API (#2574) 2020-10-14 15:06:23 +09:00
SIkebe
eb64cdd9cd Bump sbt from 1.3.12 to 1.4.0 (#2573) 2020-10-13 07:36:28 +09:00
onukura
1bfa8dffb8 update api repository branches reference lists (#2575) 2020-10-10 03:01:21 +09:00
uli-heller
33361b8015 Updated jgit to 5.9.0.202009080501-r (#2562) 2020-10-02 07:54:52 +09:00
onukura
b5ee074075 add create a milestone and update a milestone api (#2561) 2020-10-02 07:54:29 +09:00
onukura
cbddc34bfa Add update a pull request API (#2557) 2020-10-02 07:42:30 +09:00
onukura
61504ae9e3 add api endpoints for repository collaborator (#2558) 2020-09-29 06:14:19 +09:00
Naoki Takezoe
3049f6010c Update CHANGELOG.md 2020-09-27 23:37:01 +09:00
Naoki Takezoe
d4e01d631f Small refactoring for README handling (#2556) 2020-09-20 03:43:43 +09:00
onukura
a46aa2c61c Add list-milestones and get-a-milestone API (#2546) 2020-09-20 02:26:31 +09:00
onukura
ad147e8dd5 add webhook APIs (#2551) 2020-09-20 01:42:14 +09:00
Yuusuke KOUNOIKE
3555519392 force eol to lf by editorconfig / allow trailing space to *.md (#1965) 2020-09-20 00:53:57 +09:00
onukura
f6a5def638 Add list repository tags API (#2544) 2020-09-20 00:36:54 +09:00
SIkebe
0590cb7048 Improve accessibility (#2552)
* Document language missing
* Missing form label
* Image elements do not have [alt] attributes
* Fix metals specific configuration
* [user-scalable="no"] is used in the <meta name="viewport"> element or the [maximum-scale] attribute is less than 5
* Fix AvatarImageProviderSpec
* [id] attributes on active, focusable elements are not unique
* Links do not have a discernible name
* Links to cross-origin destinations are unsafe
2020-09-14 10:42:50 +09:00
onukura
b35d0792aa fix list commit api sha param (#2550) 2020-09-12 14:56:41 +09:00
James Yoo
0d20bc0173 adding support for GitHub v3 delete comment (#2540) 2020-09-12 14:52:47 +09:00
onukura
851141c2f4 add list-branches-for-head-commit API (#2547) 2020-09-11 06:06:04 +09:00
onukura
31a104a697 Add update-an-issue-comment API (#2538) 2020-09-11 05:38:34 +09:00
onukura
bfc44cff98 Add get-a-repository-README endpoint (#2535) 2020-09-07 04:05:46 +09:00
onukura
0da781c33d Limit the number of characters for user completion and issue completioin (#2534) 2020-09-07 03:55:11 +09:00
onukura
8dbcbb5485 Add get-an-issue-comment API endpoint (#2536) 2020-09-05 23:23:16 +09:00
onukura
7544f64c65 Add "has_issue" boolean to GET /repos/:owner/:repo API (#2542) 2020-09-05 16:45:16 +09:00
James Yoo
73d05aefad adding support for wiki page deletion recording (#2537) 2020-09-05 16:15:43 +09:00
SIkebe
4d70b056ad Show issue/PR title as a tooltip (#2532)
* Show issue/PR title as a tooltip
* Enable title for issue/PR on activities
2020-09-05 15:59:03 +09:00
onukura
b81ce41d51 Add list-public-repositories API (#2529) 2020-08-29 15:32:00 +09:00
James Yoo
a143683d7f refactored ActivityService logging strategy (#2526) 2020-08-29 15:29:42 +09:00
onukura
5ba38057dc add update activity date for commitsfile (#2525) 2020-08-28 00:11:58 +09:00
onukura
07eb2bc41e record wiki activity via http (#2521) 2020-08-23 18:02:01 +09:00
SIkebe
5e4d041295 Merge pull request #2519 from gitbucket/fix-branch-setting
Handle branch contains / properly in branch settings
2020-08-23 01:57:55 +09:00
Naoki Takezoe
4d7fc061a4 Handle branch contains / properly in branch settings 2020-08-23 01:11:33 +09:00
onukura
8db98d7b16 Add issue completion (#2513) 2020-08-21 05:54:31 +09:00
SIkebe
a6063c8aa9 Show userName as link only when a user is not removed (#2516) 2020-08-20 10:44:10 +09:00
onukura
2cc1336e82 Keep the default branch in the forked repositories (#2514) 2020-08-18 20:56:54 +09:00
onukura
308bda2050 add activity record for issue closing by comment (#2510) 2020-08-18 15:27:55 +09:00
Naoki Takezoe
36989c38d4 Max files for getting commit info becomes configurable (#2511) 2020-08-15 06:05:47 +09:00
onukura
29357ae170 Add theme choices for editor (#2501) 2020-08-03 00:50:01 +09:00
SIkebe
36643bcdd0 Show the number of milestones on the sidebar menu (#2500) 2020-08-03 00:48:47 +09:00
Kasan
72e40a0b12 Move the settings link down (#2497) 2020-08-01 15:35:41 +09:00
YHojo
2194ff7625 Add Merge PullRequest API (#2482) 2020-07-31 04:38:05 +09:00
Brosilio
b247864bfe Fixed some grammar and spelling issues, modified sign in form (#2496)
Co-authored-by: SIkebe <SIkebe@users.noreply.github.com>
2020-07-29 20:43:35 +09:00
Naoki Takezoe
b1c3ae4974 Update message for sidebar repo-list setting (#2493) 2020-07-28 22:38:10 +09:00
onukura
81c0e2037f Add function to close multiple issues with one keyword on commits (#2491) 2020-07-27 07:45:40 +09:00
Naoki Takezoe
6224ec2a7b Bump Scalatra to 2.7.0-GA (#2494) 2020-07-27 07:22:19 +09:00
Naoki Takezoe
9ff4507fe2 Fix system settings tab behavior (#2492) 2020-07-26 13:34:57 +09:00
Naoki Takezoe
67667dbff1 Remove activity log configuration no longer used (#2490) 2020-07-26 11:50:48 +09:00
Naoki Takezoe
1a4961c3e1 Merge pull request #2489 from gitbucket/release-4.34.0
GitBucket 4.34.0 release
2020-07-26 02:38:51 +09:00
Naoki Takezoe
561220237f Update README and CHANGELOG 2020-07-26 02:28:47 +09:00
Naoki Takezoe
f45b85aa71 Bump gist-plugin (refs #2443) and notifications-plugin (refs #2433) 2020-07-25 21:04:45 +09:00
Naoki Takezoe
83b3a7983e Update version to 4.34.0 2020-07-25 17:52:33 +09:00
Naoki Takezoe
63d4c5054e Deny empty password (#2488) 2020-07-25 17:49:58 +09:00
Naoki Takezoe
c8f6017be9 Migrate activity log to JSON-based file from database (#2468)
This also includes:
- Record rename and transfer repository in activity log
- Check existence of repsoitory when rendering activity logs
- Drop Akka dependency
2020-07-18 23:28:40 +09:00
Naoki Takezoe
f9fcb54861 Fix coursier cache path (#2481) 2020-07-18 17:17:41 +09:00
404 changed files with 19928 additions and 8191 deletions

View File

@@ -5,6 +5,10 @@ trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
end_of_line = lf
[*.md]
trim_trailing_whitespace = false
[*.java]
trim_trailing_whitespace = true

8
.git-blame-ignore-revs Normal file
View File

@@ -0,0 +1,8 @@
# update scalafmt
3d5ca44d66c77a46770a65a895c9737c542690f6
# Scala Steward: Reformat with scalafmt 3.8.2
f1360f44c61f8e12666965c10e79f11cd75d6d30
# Scala Steward: Reformat with scalafmt 3.9.7
a54fb4960ff0762738f4895cdc29bf2715a57f87

5
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1,5 @@
* @takezoe
build.sbt @xuwei-k
project/* @xuwei-k
.github/workflows/* @xuwei-k

View File

@@ -1,6 +1,6 @@
# The guidelines for contributing
- At first, see [Wiki](https://github.com/gitbucket/gitbucket/wiki) and check issues and pull requests whether there is a same request in the past.
- The highest priority of GitBucket is the ease of installation and API compatibility with GitHub, so your feature request might be rejected if they go against those principles. If you don't wanna waste your time to make a pull request, ask us about your idea at [gitter room](https://gitter.im/gitbucket/gitbucket) before staring your work.
- The highest priority of GitBucket is the ease of installation and API compatibility with GitHub, so your feature request might be rejected if they go against those principles. If you don't wanna waste your time to make a pull request, ask us about your idea at [gitter room](https://gitter.im/gitbucket/gitbucket) before starting your work.
- You can edit the GitBucket documentation on Wiki if you have a GitHub account. When you find any mistakes or lacks in the documentation, please update it directly.
- All your contributions are handled as [Apache Software License, Version 2.0](https://github.com/gitbucket/gitbucket/blob/master/LICENSE). When you create a pull request or update the documentation, we assume you agreed this clause.

View File

@@ -1,18 +0,0 @@
### Before submitting an issue to GitBucket I have first:
- [ ] read the [contribution guidelines](https://github.com/gitbucket/gitbucket/blob/master/.github/CONTRIBUTING.md)
- [ ] searched for similar already existing issue
- [ ] read the documentation and [wiki](https://github.com/gitbucket/gitbucket/wiki)
*(if you have performed all the above, remove the paragraph and continue describing the issue with template below)*
## Issue
**Impacted version**: xxxx
**Deployment mode**: *explain here how you use GitBucket : standalone app, under webcontainer (which one), with an http frontend (nginx, httpd, ...)*
**Problem description**:
- *be as explicit has you can*
- *describe the problem and its symptoms*
- *explain how to reproduce*
- *attach whatever information that can help understanding the context (screen capture, log files)*

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1 @@
blank_issues_enabled: false

View File

@@ -0,0 +1,41 @@
name: Report issue
description: Report a problem or feature request with GitBucket
body:
- type: markdown
attributes:
value: |
### Before submitting an issue to GitBucket, please ensure you have:
- Read the [contribution guidelines](https://github.com/gitbucket/gitbucket/blob/master/.github/CONTRIBUTING.md)
- Searched for similar existing issues
- Read the documentation and [wiki](https://github.com/gitbucket/gitbucket/wiki)
- You can use [Gitter chat room](https://gitter.im/gitbucket/gitbucket) instead of GitHub Issues for casual discussion or inquiry
- type: checkboxes
id: prerequisites
attributes:
label: Prerequisites
options:
- label: I have read the contribution guidelines
- label: I have searched for similar issues
- label: I have read the documentation and wiki
- type: input
id: impacted_version
attributes:
label: Impacted version
description: Which version of GitBucket is affected?
placeholder: e.g. 4.37.0
- type: input
id: deployment_mode
attributes:
label: Deployment mode
description: How do you use GitBucket? (standalone app, under webcontainer, with an HTTP frontend, etc.)
placeholder: e.g. Standalone app, Tomcat, nginx
- type: textarea
id: problem_description
attributes:
label: Problem description
description: Be as explicit as you can. Describe the problem, its symptoms, how to reproduce, and attach any relevant information (screenshots, logs, etc.)
placeholder: Describe the problem and how to reproduce it

6
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

View File

@@ -1,39 +1,42 @@
name: build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
java: [8, 11]
java: [17, 21]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-sbt-libs
with:
path: |
~/.ivy2/cache
~/.sbt
~/.coursier
~/.cache/coursier/v1
key: build-${{ env.cache-name }}-${{ hashFiles('build.sbt') }}
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: adopt
- name: Setup sbt launcher
uses: sbt/setup-sbt@v1
- name: Run tests
run: sbt scalafmtSbtCheck scalafmtCheck test:scalafmtCheck test
run: sbt scalafmtSbtCheck scalafmtCheckAll test
- name: Scala 3
run: sbt '++ 3.x' update # TODO
- name: Build executable
run: sbt executable
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: gitbucket-java${{ matrix.java }}-${{ github.sha }}
path: ./target/executable/gitbucket.*

10
.gitignore vendored
View File

@@ -2,6 +2,9 @@
*.log
.ensime
.ensime_cache
.DS_Store
.java-version
.tmp
# sbt specific
dist/*
@@ -10,6 +13,7 @@ lib_managed/
src_managed/
project/boot/
project/plugins/project/
.bsp/
# Scala-IDE specific
.scala_dependencies
@@ -28,4 +32,8 @@ project/plugins/project/
# Metals specific
.metals
.bloop
project/metals.sbt
**/metals.sbt
# Visual Studio Code specific
.vscode

8
.scala-steward.conf Normal file
View File

@@ -0,0 +1,8 @@
updates.limit = 3
updates.includeScala = true
updates.pin = [
{ groupId = "org.eclipse.jetty", version = "10." }
{ groupId = "org.mariadb.jdbc", version = "2." }
]

View File

@@ -1,12 +1,24 @@
version = "1.5.1"
version = "3.9.9"
project.git = true
maxColumn = 120
docstrings = JavaDoc
docstrings.style = keep
align.tokens = ["%", "%%", {code = "=>", owner = "Case"}]
align.openParenCallSite = false
align.openParenDefnSite = false
continuationIndent.callSite = 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

View File

@@ -1,15 +1,162 @@
# Changelog
All changes to the project will be documented in this file.
### 4.33.0 - 31 Dec 2019
## 4.43.0 - 29 Jun 2025
- Upgrade H2 database from 1.x to 2.x
Note that upgrading from h2 1.x to 2.x requires data file migration: https://www.h2database.com/html/migration-to-v2.html
It can't be done automatically using GitBucket's auto migration mechanism because it relies on database itself. So, users who use h2 will have to dump and recreate their database manually with the following steps:
```bash
# Export database using the current version of H2
$ curl -O https://repo1.maven.org/maven2/com/h2database/h2/1.4.199/h2-1.4.199.jar
$ java -cp h2-1.4.199.jar org.h2.tools.Script -url "jdbc:h2:~/.gitbucket/data" -user sa -password sa -script dump.sql
# Recreate database using the new version of H2
$ curl -O https://repo1.maven.org/maven2/com/h2database/h2/2.3.232/h2-2.3.232.jar
$ java -cp h2-2.3.232.jar org.h2.tools.RunScript -url "jdbc:h2:~/.gitbucket/data" -user sa -password sa -script dump.sql
```
In addition, if `~/.gitbucket/database.conf` has the following configuration, remove `;MVCC=true` from `url`.
```
db {
url = "jdbc:h2:${DatabaseHome};MVCC=true" // => "jdbc:h2:${DatabaseHome}"
...
}
```
## 4.42.1 - 20 Jan 2025
- Fix LDAP issue with SSL
## 4.42.0 - 30 Dec 2024
- Increase max branch name length 100 -> 255
- Fix some GitHub incompatible Web APIs
- Apply user-defined CSS after all plugins
- Improve performance of listing commit logs
- Drop Java 11 support. Java 17 is now required
## 4.41.0 - 18 May 2024
- Simplify pull request UI
- Keyword search for issues and pull requests
- New settings for max files and lines limit in showing diff
- Adjust the default branch automatically when cloning external repository
- Fix layout of branch selector
- Performance improvement for listing branches
- Upgrade internal libraries
## 4.40.0 - 22 Oct 2023
- Configurable default branch name
- Support custom fields of issues and pull requests in search condition
- Create pull request from default branch of forked repositories
- News feed shows activities of all visible repositories
- Drop Java 8 support
- Improve git push performance
## 4.39.0 - 29 Apr 2023
- Support enum type in custom fields of Issues and Pull requests
- Hide large diffs by default
- Add new options to make it possible to run GitBucket using multiple machines
- Fix many API issues
## 4.38.4 - 2 Nov 2022
- Downgrade MariaDB JDBC drive to avoid unknown error
## 4.38.3 - 30 Oct 2022
- Fix several issues around multiple assignees in issues and pull requests
- Fix IllegalStateException when returning unknown avatar image
## 4.38.2 - 20 Sep 2022
- Resurrect assignee icons on the issue list
## 4.38.1 - 10 Sep 2022
- Fix comment diff in Chrome 105
- Fix Markdown table CSS
- Fix HTML rendering of multiple asignees
## 4.38.0 - 3 Sep 2022
- Support multiple assignees for Issues and Pull requests
- Custom fields for issues and pull requests
- Reset password by users
- Allow to configure Jetty idle timeout in standalone mode
- Horizontal scroll for too wide tables in Markdown
- Hide header content on signin and register page
- Fix the default charset of the online editor in the repository viewer
- Fix the milestone count
- Some improvements and bugfixes for WebAPI and WebHook
## 4.37.2 - 16 Jan 2022
- Fixed a security issue reported by [Positive Technologies](https://www.ptsecurity.com/ww-en/). Great thanks for their detailed report and close support!
## 4.37.1 - 14 Dec 2021
- Update gist-plugin and notification-plugin
- Fix SSHCommand extension point for apache-sshd 2.x
## 4.37.0 - 11 Dec 2021
- Enhance Git Reference APIs
- Add milestone data to issue list API
- Support "all" in issue list API
- Support EDDSA in signed commit verification
- Support custom SSH url
- Relax max passward length limitation
- Relax max webhook url length limitation
## 4.36.2 - 16 Aug 2021
- Escape user name in avatar image tag
## 4.36.1 - 22 Jul 2021
- Bump gitbucket-gist-plugin to 4.21.0
## 4.36.0 - 17 Jul 2021
- Tag selector in the repository viewer
- Link issues/pull requests of other repositories
- Files and lines can be linked in the diff view
- Option to disable XSS protection
## 4.35.3 - 14 Jan 2021
- Fix a bug that Wiki page cannot be deleted
- Fix a deployment issue on Tomcat
## 4.35.2 - 30 Dec 2020
- Upgrade gitbucket-notifications-plugin to 1.10.0
- Upgrade oauth2-oidc-sdk to 8.29.1 to solve dependency issue
## 4.35.1 - 29 Dec 2020
- Fix database migration issue which happens if webhook is configured
- Call push webhook when pull request is merged
- Show commit status at commits tab of pull request
## 4.35.0 - 25 Dec 2020
- Editor and source viewer color theme
- Auto completion for issues and pull requests
- Upload image from clipboard
- Close multiple issues by commit comment
- Create pull request from online editor
- Milestone overview
- Commit status at various places
- WebAPI coverage improvements
## 4.34.0 - 26 Jul 2020
- Enhancement admin settings UI
- File upload settings
- Restrict repository operations
- User-defined CSS
- Limit the repository list in the sidebar
- Improve MariaDB support
- Improve activity logging
- CLI option to persist session on disk in the standalone mode
- Web API updates
- Add [list commits API](https://developer.github.com/v3/repos/commits/#list-commits)
- Bundled plugins updates
- [gitbucket-gist-plugin](https://github.com/gitbucket/gitbucket-gist-plugin) 4.18.0 -> 4.19.0
- [gitbucket-notifications-plugin](https://github.com/gitbucket/gitbucket-notifications-plugin) 1.8.0 -> 1.9.0
## 4.33.0 - 31 Dec 2019
- All CLI options are configurable by environment variables
- Folding pull request files
- WebHook security options
- Add assignee and assignees properties to some Web APIs' response
### 4.32.0 - 7 Aug 2019
## 4.32.0 - 7 Aug 2019
- Bump to Scala 2.13.0 and Scalatra 2.7.0
- Draft pull request
- Drop network installation of plugins
@@ -17,20 +164,20 @@ All changes to the project will be documented in this file.
- Apply default priority to pull requests
- Focus title after clicking issue / pull request edit button
### 4.31.2 - 7 Apr 2019
## 4.31.2 - 7 Apr 2019
- Bug and security fix
### 4.31.1 - 17 Mar 2019
## 4.31.1 - 17 Mar 2019
- Bug fix
### 4.31.0 - 17 Mar 2019
## 4.31.0 - 17 Mar 2019
- Docker support in CI plugin
- Verify GPG key signed commit
- OAuth2 Token (sent as a parameter) authentication support and new APIs in Web API
- OGP (Open Graph protocol) support
- Username completion with avatars
### 4.30.1 - 22 Dec 2018
## 4.30.1 - 22 Dec 2018
- Bug fix for several WebHooks and Web API
## 4.30.0 - 15 Dec 2018
@@ -117,7 +264,7 @@ All changes to the project will be documented in this file.
- Submodule links to web page
- Clarify close/reopen button
# 4.20.0 - 23 Dec 2017
## 4.20.0 - 23 Dec 2017
- Squash and rebase merge strategy for pull requests
- Quick pull request creation
- Download patch from the diff view

View File

@@ -1,4 +1,4 @@
GitBucket [![Gitter chat](https://badges.gitter.im/gitbucket/gitbucket.svg)](https://gitter.im/gitbucket/gitbucket) [![build](https://github.com/gitbucket/gitbucket/workflows/build/badge.svg?branch=master)](https://github.com/gitbucket/gitbucket/actions?query=workflow%3Abuild+branch%3Amaster) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.gitbucket/gitbucket_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.gitbucket/gitbucket_2.13) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/gitbucket/gitbucket/blob/master/LICENSE)
GitBucket [![Gitter chat](https://badges.gitter.im/gitbucket/gitbucket.svg)](https://gitter.im/gitbucket/gitbucket) [![build](https://github.com/gitbucket/gitbucket/actions/workflows/build.yml/badge.svg)](https://github.com/gitbucket/gitbucket/actions/workflows/build.yml) [![gitbucket Scala version support](https://index.scala-lang.org/gitbucket/gitbucket/gitbucket/latest-by-scala-version.svg)](https://index.scala-lang.org/gitbucket/gitbucket/gitbucket) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/gitbucket/gitbucket/blob/master/LICENSE)
=========
GitBucket is a Git web platform powered by Scala offering:
@@ -8,7 +8,7 @@ GitBucket is a Git web platform powered by Scala offering:
- High extensibility by plugins
- API compatibility with GitHub
You can try an [online demo](https://gitbucket.herokuapp.com/) *(ID: root / Pass: root)* of GitBucket, and also get the latest information at [GitBucket News](https://gitbucket.github.io/gitbucket-news/).
![GitBucket](https://gitbucket.github.io/img/screenshots/screenshot-repository_viewer.png)
Features
--------
@@ -22,16 +22,14 @@ The current version of GitBucket provides many features such as:
- Account and group management with LDAP integration
- a Plug-in system
If you want to try the development version of GitBucket, see the [Developer's Guide](https://github.com/gitbucket/gitbucket/blob/master/doc/readme.md).
Installation
--------
GitBucket requires **Java8**. You have to install it, if it is not already installed.
GitBucket requires **Java 17**. 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`.
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).
@@ -48,20 +46,43 @@ GitBucket has a plug-in system that allows extra functionality. Officially the f
You can find more plugins made by the community at [GitBucket community plugins](https://gitbucket-plugins.github.io/).
Building and Development
-----------
If you want to try the development version of GitBucket, or want to contribute to the project, please see the [Developer's Guide](https://github.com/gitbucket/gitbucket/blob/master/doc/readme.md).
It provides instructions on building from source and on setting up an IDE for debugging.
It also contains documentation of the core concepts used within the project.
Support
--------
- If you have any questions about GitBucket, see [Wiki](https://github.com/gitbucket/gitbucket/wiki) and check issues whether there is a same question or request in the past.
- If you can't find same question and report, send it to [gitter room](https://gitter.im/gitbucket/gitbucket) before raising an issue.
- If you can't find same question and report, send it to our [Gitter chat 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.
What's New in 4.33.x
What's New in 4.43.x
-------------
### 4.33.0 - 31 Dec 2019
## 4.43.0 - 29 Jun 2025
- Upgrade H2 database from 1.x to 2.x
- All CLI options are configurable by environment variables
- Folding pull request files
- WebHook security options
- Add assignee and assignees properties to some Web APIs' response
Note that upgrading from h2 1.x to 2.x requires data file migration: https://www.h2database.com/html/migration-to-v2.html
See the [change log](CHANGELOG.md) for all of the updates.
It can't be done automatically using GitBucket's auto migration mechanism because it relies on database itself. So, users who use h2 will have to dump and recreate their database manually with the following steps:
```bash
# Export database using the current version of H2
$ curl -O https://repo1.maven.org/maven2/com/h2database/h2/1.4.199/h2-1.4.199.jar
$ java -cp h2-1.4.199.jar org.h2.tools.Script -url "jdbc:h2:~/.gitbucket/data" -user sa -password sa -script dump.sql
# Recreate database using the new version of H2
$ curl -O https://repo1.maven.org/maven2/com/h2database/h2/2.3.232/h2-2.3.232.jar
$ java -cp h2-2.3.232.jar org.h2.tools.RunScript -url "jdbc:h2:~/.gitbucket/data" -user sa -password sa -script dump.sql
```
In addition, if `~/.gitbucket/database.conf` has the following configuration, remove `;MVCC=true` from `url`.
```
db {
url = "jdbc:h2:${DatabaseHome};MVCC=true" // => "jdbc:h2:${DatabaseHome}"
...
}
```
See the [change log](CHANGELOG.md) for all the past updates.

218
build.sbt
View File

@@ -1,97 +1,108 @@
import com.typesafe.sbt.license.{DepModuleInfo, LicenseInfo}
import com.typesafe.sbt.pgp.PgpKeys._
import com.jsuereth.sbtpgp.PgpKeys._
val Organization = "io.github.gitbucket"
val Name = "gitbucket"
val GitBucketVersion = "4.33.0"
val ScalatraVersion = "2.7.0-RC1"
val JettyVersion = "9.4.30.v20200611"
val JgitVersion = "5.8.0.202006091008-r"
val GitBucketVersion = "4.43.0"
val ScalatraVersion = "3.1.2"
val JettyVersion = "10.0.25"
val JgitVersion = "6.10.1.202505221210-r"
lazy val root = (project in file("."))
.enablePlugins(SbtTwirl, ScalatraPlugin)
.settings(
)
.enablePlugins(SbtTwirl, ContainerPlugin)
sourcesInBase := false
organization := Organization
name := Name
version := GitBucketVersion
scalaVersion := "2.13.1"
scalaVersion := "2.13.16"
scalafmtOnCompile := true
crossScalaVersions += "3.7.2"
// scalafmtOnCompile := true
coverageExcludedPackages := ".*\\.html\\..*"
// dependency settings
resolvers ++= Seq(
Classpaths.typesafeReleases,
Resolver.jcenterRepo,
"sonatype-snapshot" at "https://oss.sonatype.org/content/repositories/snapshots/"
)
libraryDependencies ++= Seq(
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % JgitVersion,
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % JgitVersion,
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
"org.scalatra" %% "scalatra-forms" % ScalatraVersion,
"org.json4s" %% "json4s-jackson" % "3.6.9",
"commons-io" % "commons-io" % "2.7",
"io.github.gitbucket" % "solidbase" % "1.0.3",
"io.github.gitbucket" % "markedj" % "1.0.16",
"org.apache.commons" % "commons-compress" % "1.20",
"org.apache.commons" % "commons-email" % "1.5",
"commons-net" % "commons-net" % "3.6",
"org.apache.httpcomponents" % "httpclient" % "4.5.12",
"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.tika" % "tika-core" % "1.24.1",
"com.github.takezoe" %% "blocking-slick-32" % "0.0.12",
"com.novell.ldap" % "jldap" % "2009-10-07",
"com.h2database" % "h2" % "1.4.199",
"org.mariadb.jdbc" % "mariadb-java-client" % "2.6.0",
"org.postgresql" % "postgresql" % "42.2.6",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"com.zaxxer" % "HikariCP" % "3.4.5",
"com.typesafe" % "config" % "1.4.0",
"com.typesafe.akka" %% "akka-actor" % "2.5.27",
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.1.0",
"com.github.bkromhout" % "java-diff-utils" % "2.1.1",
"org.cache2k" % "cache2k-all" % "1.2.4.Final",
"com.enragedginger" %% "akka-quartz-scheduler" % "1.8.1-akka-2.5.x" exclude ("com.mchange", "c3p0") exclude ("com.zaxxer", "HikariCP-java6"),
"net.coobird" % "thumbnailator" % "0.4.11",
"com.github.zafarkhaja" % "java-semver" % "0.9.0",
"com.nimbusds" % "oauth2-oidc-sdk" % "5.64.4",
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"junit" % "junit" % "4.13" % "test",
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
"org.mockito" % "mockito-core" % "3.3.3" % "test",
"com.dimafeng" %% "testcontainers-scala" % "0.37.0" % "test",
"org.testcontainers" % "mysql" % "1.14.3" % "test",
"org.testcontainers" % "postgresql" % "1.14.3" % "test",
"net.i2p.crypto" % "eddsa" % "0.3.0",
"is.tagomor.woothee" % "woothee-java" % "1.11.0",
"org.ec4j.core" % "ec4j-core" % "0.0.3"
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % JgitVersion,
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % JgitVersion,
"org.scalatra" %% "scalatra-javax" % ScalatraVersion,
"org.scalatra" %% "scalatra-json-javax" % ScalatraVersion,
"org.scalatra" %% "scalatra-forms-javax" % ScalatraVersion,
"org.json4s" %% "json4s-jackson" % "4.1.0-M8",
"commons-io" % "commons-io" % "2.20.0",
"io.github.gitbucket" % "solidbase" % "1.1.0",
"io.github.gitbucket" % "markedj" % "1.0.20",
"org.tukaani" % "xz" % "1.10",
"org.apache.commons" % "commons-compress" % "1.28.0",
"org.apache.commons" % "commons-email" % "1.6.0",
"commons-net" % "commons-net" % "3.12.0",
"org.apache.httpcomponents" % "httpclient" % "4.5.14",
"org.apache.sshd" % "apache-sshd" % "2.15.0" exclude ("org.slf4j", "slf4j-jdk14") exclude (
"org.apache.sshd",
"sshd-mina"
) exclude ("org.apache.sshd", "sshd-netty")
exclude ("org.apache.sshd", "sshd-spring-sftp"),
"org.apache.tika" % "tika-core" % "3.2.2",
"com.github.takezoe" %% "blocking-slick" % "0.0.14",
"com.novell.ldap" % "jldap" % "2009-10-07",
"com.h2database" % "h2" % "2.3.232",
"org.mariadb.jdbc" % "mariadb-java-client" % "2.7.12",
"org.postgresql" % "postgresql" % "42.7.7",
"ch.qos.logback" % "logback-classic" % "1.5.18",
"com.zaxxer" % "HikariCP" % "7.0.1" exclude ("org.slf4j", "slf4j-api"),
"com.typesafe" % "config" % "1.4.4",
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.1.0",
"io.github.java-diff-utils" % "java-diff-utils" % "4.16",
"org.cache2k" % "cache2k-all" % "1.6.0.Final",
"net.coobird" % "thumbnailator" % "0.4.20",
"com.github.zafarkhaja" % "java-semver" % "0.10.2",
"com.nimbusds" % "oauth2-oidc-sdk" % "11.27",
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"junit" % "junit" % "4.13.2" % "test",
"org.scalatra" %% "scalatra-scalatest-javax" % ScalatraVersion % "test",
"org.mockito" % "mockito-core" % "5.18.0" % "test",
"com.dimafeng" %% "testcontainers-scala" % "0.43.0" % "test",
"org.testcontainers" % "mysql" % "1.21.3" % "test",
"org.testcontainers" % "postgresql" % "1.21.3" % "test",
"net.i2p.crypto" % "eddsa" % "0.3.0",
"is.tagomor.woothee" % "woothee-java" % "1.11.0",
"org.ec4j.core" % "ec4j-core" % "1.1.1",
"org.kohsuke" % "github-api" % "1.329" % "test"
)
// Compiler settings
scalacOptions := Seq("-deprecation", "-language:postfixOps", "-opt:l:method")
javacOptions in compile ++= Seq("-target", "8", "-source", "8")
javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml"
scalacOptions := Seq(
"-deprecation",
"-language:postfixOps",
"-opt:l:method",
"-feature",
"-Wunused:imports",
"-Wconf:cat=unused&src=twirl/.*:s,cat=unused&src=scala/gitbucket/core/model/[^/]+\\.scala:s"
)
scalacOptions ++= {
scalaBinaryVersion.value match {
case "2.13" =>
Seq("-Xsource:3-cross")
case _ =>
Nil
}
}
compile / javacOptions ++= Seq("-target", "11", "-source", "11")
Container / javaOptions += "-Dlogback.configurationFile=/logback-dev.xml"
// Test settings
//testOptions in Test += Tests.Argument("-l", "ExternalDBTest")
javaOptions in Test += "-Dgitbucket.home=target/gitbucket_home_for_test"
testOptions in Test += Tests.Setup(() => new java.io.File("target/gitbucket_home_for_test").mkdir())
fork in Test := true
Test / javaOptions += "-Dgitbucket.home=target/gitbucket_home_for_test"
Test / testOptions += Tests.Setup(() => new java.io.File("target/gitbucket_home_for_test").mkdir())
Test / fork := true
// Packaging options
packageOptions += Package.MainClass("JettyLauncher")
// Assembly settings
test in assembly := {}
assemblyMergeStrategy in assembly := {
assembly / test := {}
assembly / assemblyMergeStrategy := {
case PathList("META-INF", xs @ _*) =>
(xs map { _.toLowerCase }) match {
case ("manifest.mf" :: Nil) => MergeStrategy.discard
@@ -102,8 +113,8 @@ assemblyMergeStrategy in assembly := {
// Exclude a war file from published artifacts
signedArtifacts := {
signedArtifacts.value.filterNot {
case (_, file) => file.getName.endsWith(".war") || file.getName.endsWith(".war.asc")
signedArtifacts.value.filterNot { case (_, file) =>
file.getName.endsWith(".war") || file.getName.endsWith(".war.asc")
}
}
@@ -111,17 +122,22 @@ signedArtifacts := {
val ExecutableConfig = config("executable").hide
Keys.ivyConfigurations += ExecutableConfig
libraryDependencies ++= Seq(
"org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-continuation" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-servlet" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-io" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
"org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-servlet" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-io" % JettyVersion % "executable",
"org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
)
// Run package task before test to generate target/webapp for integration test
Test / test := {
_root_.sbt.Keys.`package`.value
(Test / test).value
}
val executableKey = TaskKey[File]("executable")
executableKey := {
import java.util.jar.Attributes.{Name => AttrName}
@@ -140,9 +156,11 @@ executableKey := {
// include jetty classes
val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
jettyJars foreach { jar =>
IO unzip (jar, temp, (name: String) =>
(name startsWith "javax/") ||
(name startsWith "org/"))
IO unzip (
jar,
temp,
(name: String) => (name startsWith "javax/") || (name startsWith "org/") || (name startsWith "META-INF/services/")
)
}
// include original war file
@@ -150,7 +168,7 @@ executableKey := {
IO unzip (warFile, temp)
// include launcher classes
val classDir = (Keys.classDirectory in Compile).value
val classDir = (Compile / Keys.classDirectory).value
val launchClasses = Seq("JettyLauncher.class" /*, "HttpsSupportConnector.class" */ )
launchClasses foreach { name =>
IO copyFile (classDir / name, temp / name)
@@ -167,7 +185,7 @@ executableKey := {
val url = "https://github.com/" +
s"gitbucket/gitbucket-${pluginId}-plugin/releases/download/${pluginVersion}/gitbucket-${pluginId}-plugin-${pluginVersion}.jar"
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 _ => ()
}
}
@@ -181,17 +199,16 @@ executableKey := {
manifest.getMainAttributes put (AttrName.MANIFEST_VERSION, "1.0")
manifest.getMainAttributes put (AttrName.MAIN_CLASS, "JettyLauncher")
val outputFile = workDir / warName
IO jar (contentMappings.map { case (file, path) => (file, path.toString) }, outputFile, manifest)
IO jar (contentMappings.map { case (file, path) => (file, path.toString) }, outputFile, manifest, None)
// generate checksums
Seq(
"md5" -> "MD5",
"sha1" -> "SHA-1",
"sha256" -> "SHA-256"
).foreach {
case (extension, algorithm) =>
val checksumFile = workDir / (warName + "." + extension)
Checksums generate (outputFile, checksumFile, algorithm)
).foreach { case (extension, algorithm) =>
val checksumFile = workDir / (warName + "." + extension)
Checksums generate (outputFile, checksumFile, algorithm)
}
// done
@@ -199,9 +216,9 @@ executableKey := {
outputFile
}
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
val centralSnapshots = "https://central.sonatype.com/repository/maven-snapshots/"
if (isSnapshot.value) Some("central-snapshots" at centralSnapshots)
else localStaging.value
}
publishMavenStyle := true
pomIncludeRepository := { _ =>
@@ -253,12 +270,7 @@ pomExtra := (
</developers>
)
licenseOverrides := {
case DepModuleInfo("com.github.bkromhout", "java-diff-utils", _) =>
LicenseInfo(LicenseCategory.Apache, "Apache-2.0", "http://www.apache.org/licenses/LICENSE-2.0")
}
testOptions in Test ++= {
Test / testOptions ++= {
if (scala.util.Properties.isWin) {
Seq(
Tests.Exclude(
@@ -271,3 +283,13 @@ testOptions in Test ++= {
Nil
}
}
Container / javaOptions ++= Seq(
"-Dlogback.configurationFile=/logback-dev.xml",
"-Xdebug",
"-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000",
"-Dorg.eclipse.jetty.annotations.AnnotationParser.LEVEL=OFF",
// "-Ddev-features=keep-session"
)
Container / containerLibs := Seq(("org.eclipse.jetty" % "jetty-runner" % JettyVersion).intransitive())
Container / containerMain := "org.eclipse.jetty.runner.Runner"

View File

@@ -2,7 +2,7 @@ Authentication in Controller
========
GitBucket provides many [authenticators](https://github.com/gitbucket/gitbucket/blob/master/src/main/scala/gitbucket/core/util/Authenticator.scala) to access controlling in the controller.
For example, in the case of `RepositoryViwerController`,
For example, in the case of `RepositoryViewerController`,
it references three authenticators: `ReadableUsersAuthenticator`, `ReferrerAuthenticator` and `CollaboratorsAuthenticator`.
```scala
@@ -19,13 +19,13 @@ trait RepositoryViewerControllerBase extends ControllerBase {
...
```
Authenticators provides a method to add guard to actions in the controller:
Authenticators provide a method to add guard to actions in the controller:
- `ReadableUsersAuthenticator` provides `readableUsersOnly` method
- `ReferrerAuthenticator` provides `referrersOnly` method
- `CollaboratorsAuthenticator` provides `collaboratorsOnly` method
These methods are available in each actions as below:
These methods are available in each action as below:
```scala
// Allows only the repository owner (or manager for group repository) and administrators.
@@ -38,7 +38,7 @@ get("/:owner/:repository/new/*")(collaboratorsOnly { repository =>
...
})
// Allows only signed in users which can access the repository.
// Allows only signed-in users which can access the repository.
post("/:owner/:repository/commit/:id/comment/new", commentForm)(readableUsersOnly { (form, repository) =>
...
})
@@ -50,11 +50,11 @@ Currently, GitBucket provides below authenticators:
|--------------------------|-----------------|--------------------------------------------------------------------------------------|
|OneselfAuthenticator |oneselfOnly |Allows only oneself and administrators. |
|OwnerAuthenticator |ownerOnly |Allows only the repository owner and administrators. |
|UsersAuthenticator |usersOnly |Allows only signed in users. |
|UsersAuthenticator |usersOnly |Allows only signed-in users. |
|AdminAuthenticator |adminOnly |Allows only administrators. |
|CollaboratorsAuthenticator|collaboratorsOnly|Allows only collaborators and administrators. |
|ReferrerAuthenticator |referrersOnly |Allows only the repository owner (or manager for group repository) and administrators.|
|ReadableUsersAuthenticator|readableUsersOnly|Allows only signed in users which can access the repository. |
|ReadableUsersAuthenticator|readableUsersOnly|Allows only signed-in users which can access the repository. |
|GroupManagerAuthenticator |managersOnly |Allows only the group managers. |
Of course, if you make a new plugin, you can define a your own authenticator according to requirement in your plugin.
Of course, if you make a new plugin, you can implement your own authenticator according to requirement in your plugin.

View File

@@ -2,7 +2,7 @@ Automatic Schema Updating
========
GitBucket updates database schema automatically using [Solidbase](https://github.com/gitbucket/solidbase) in the first run after the upgrading.
To release a new version of GitBucket, add the version definition to the [gitbucket.core.GitBucketCoreModule](https://github.com/gitbucket/gitbucket/blob/master/src/main/scala/gitbucket/core/GitBucketCoreModule.scala) at first.
To release a new version of GitBucket, add the version definition to [gitbucket.core.GitBucketCoreModule](https://github.com/gitbucket/gitbucket/blob/master/src/main/scala/gitbucket/core/GitBucketCoreModule.scala) at first.
```scala
object GitBucketCoreModule extends Module("gitbucket-core",
@@ -17,7 +17,7 @@ object GitBucketCoreModule extends Module("gitbucket-core",
)
```
Next, add a XML file which updates database schema into [/src/main/resources/update/](https://github.com/gitbucket/gitbucket/tree/master/src/main/resources/update) with a filenane defined in `GitBucketCoreModule`.
Next, add a XML file which updates database schema into [/src/main/resources/update/](https://github.com/gitbucket/gitbucket/tree/master/src/main/resources/update) with a filename defined in `GitBucketCoreModule`.
```xml
<?xml version="1.0" encoding="UTF-8"?>
@@ -31,9 +31,9 @@ Next, add a XML file which updates database schema into [/src/main/resources/upd
</changeSet>
```
Solidbase stores the current version to `VERSIONS` table and checks it at start-up. If the stored version differs from the actual version, it executes differences between the stored version and the actual version.
Solidbase stores the current version to `VERSIONS` table and checks it at start-up. If the stored version different from the actual version, it executes differences between the stored version and the actual version.
We can add the SQL file instead of the XML file using `SqlMigration`. It try to load a SQL file from classpath as following order:
We can add the SQL file instead of the XML file using `SqlMigration`. It tries to load a SQL file from classpath in the following order:
1. Specified path (if specified)
2. `${moduleId}_${version}_${database}.sql`
@@ -51,4 +51,4 @@ object GitBucketCoreModule extends Module("gitbucket-core",
)
```
See more details [README of Solidbase](https://github.com/gitbucket/solidbase).
See more details at [README of Solidbase](https://github.com/gitbucket/solidbase).

View File

@@ -1,7 +1,7 @@
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
$ brew install sbt
@@ -13,17 +13,31 @@ Run for Development
If you want to test GitBucket, type the following command in the root directory of the source tree.
```shell
$ sbt ~jetty:start
$ sbt ~container:start
```
Then access `http://localhost:8080/` in your browser. The default administrator account is `root` and password is `root`.
Source code modifications are detected and a reloaded happens automatically. You can modify the logging configuration by editing `src/main/resources/logback-dev.xml`.
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/3dcc0aee3c4413b05be7c03476626cb202674afc/build.sbt#L292
Or by launching GitBucket with the following command:
```shell
sbt '; set Container/javaOptions += "-Ddev-features=keep-session" ; ~container:start'
```
Note that this feature serializes HttpSession on the local disk and assigns all requests to the same session
which means you cannot test multi users behavior in this mode.
Build war file
--------
To build war file, run the following command:
To build a war file, run the following command:
```shell
$ sbt package
@@ -37,7 +51,8 @@ To build an executable war file, run
$ sbt executable
```
at the top of the source tree. It generates executable `gitbucket.war` into `target/executable`. We release this war file as release artifact.
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
---------

View File

@@ -1,6 +1,6 @@
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
javaOptions in Jetty ++= Seq(
@@ -12,7 +12,7 @@ javaOptions in Jetty ++= Seq(
Run GitBucket:
```shell
$ sbt ~jetty:start
$ sbt ~container:start
```
In IntelliJ, create remote debug configuration as follows. Make sure port number is same as above configuration.

View File

@@ -5,13 +5,17 @@ GitBucket persists all data into __HOME/.gitbucket__ in default (In 1.9 or befor
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
* /USER_NAME
* /REPO_NAME.git (substance of repository. GitServlet sees this directory)
* /REPO_NAME.wiki.git (wiki repository)
* /REPO_NAME
* /issues (files which are attached to issue)
* /issues (files attached to issue)
* /lfs (LFS managed files)
* /data
* /USER_NAME
@@ -20,6 +24,8 @@ This directory has following structure:
* /plugins
* plugin.jar
* /.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
* /_upload
* /SESSION_ID (removed at session timeout)

View File

@@ -38,15 +38,26 @@ Generate release files
For plug-in development, we have to publish the GitBucket jar file to the Maven central repository before release GitBucket itself.
First, hit following command to publish artifacts to the sonatype OSS repository:
First, start the sbt shell:
```bash
$ sbt publishSigned
```
Then logged-in to https://oss.sonatype.org/, close and release the repository.
Next, upload artifacts to Sonatype's Central Portal with the following command:
You need to wait up to a day until [gitbucket-notification-plugin](https://plugins.gitbucket-community.org/) which is default bundled plugin is built for new version of GitBucket.
```bash
$ sbt sonaUpload
```
Then logged-in to https://central.sonatype.com/ and publish the deployment.
You need to wait up to a day until default bundled plugins:
- https://github.com/gitbucket/gitbucket-notifications-plugin
- https://github.com/gitbucket/gitbucket-gist-plugin
- https://github.com/gitbucket/gitbucket-pages-plugin
- https://github.com/gitbucket/gitbucket-emoji-plugin
### Make release war file
@@ -55,5 +66,4 @@ Run `sbt executable`. The release war file and fingerprint are generated into `t
```bash
$ sbt executable
```
Create new release from the corresponded tag on GitHub, then upload generated jar file and fingerprints to the release.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 KiB

After

Width:  |  Height:  |  Size: 112 KiB

View File

@@ -1,6 +1,6 @@
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:

View File

@@ -1 +1 @@
sbt.version=1.3.12
sbt.version=1.11.4

View File

@@ -1,10 +1,11 @@
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.5.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0")
addSbtPlugin("org.scalatra.sbt" % "sbt-scalatra" % "1.0.4")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-license-report" % "1.2.0")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5")
addSbtPlugin("org.playframework.twirl" % "sbt-twirl" % "2.0.9")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.1")
addSbtPlugin("org.scalatra.sbt" % "sbt-scalatra" % "1.0.4")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.1")
addSbtPlugin("com.github.sbt" % "sbt-license-report" % "1.7.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.3.1")
addDependencyTreePlugin

View File

@@ -1,51 +1,107 @@
import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.SecuredRedirectHandler;
import org.eclipse.jetty.server.handler.StatisticsHandler;
import org.eclipse.jetty.server.session.DefaultSessionCache;
import org.eclipse.jetty.server.session.FileSessionDataStore;
import org.eclipse.jetty.server.session.SessionCache;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;
import java.io.File;
import java.net.InetAddress;
import java.net.URL;
import java.net.InetSocketAddress;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Stream;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.toSet;
public class JettyLauncher {
private interface Defaults {
String CONNECTORS = "http";
String HOST = "0.0.0.0";
int HTTP_PORT = 8080;
int HTTPS_PORT = 8443;
boolean REDIRECT_HTTPS = false;
}
private interface Connectors {
String HTTP = "http";
String HTTPS = "https";
}
public static void main(String[] args) throws Exception {
System.setProperty("java.awt.headless", "true");
String host = null;
String port = null;
InetSocketAddress address = null;
String contextPath = "/";
String tmpDirPath="";
boolean forceHttps = false;
String connectors = getEnvironmentVariable("gitbucket.connectors");
String host = getEnvironmentVariable("gitbucket.host");
String port = getEnvironmentVariable("gitbucket.port");
String securePort = getEnvironmentVariable("gitbucket.securePort");
String keyStorePath = getEnvironmentVariable("gitbucket.keyStorePath");
String keyStorePassword = getEnvironmentVariable("gitbucket.keyStorePassword");
String keyManagerPassword = getEnvironmentVariable("gitbucket.keyManagerPassword");
String redirectHttps = getEnvironmentVariable("gitbucket.redirectHttps");
String contextPath = getEnvironmentVariable("gitbucket.prefix");
String tmpDirPath = getEnvironmentVariable("gitbucket.tempDir");
String jettyIdleTimeout = getEnvironmentVariable("gitbucket.jettyIdleTimeout");
boolean saveSessions = false;
host = getEnvironmentVariable("gitbucket.host");
port = getEnvironmentVariable("gitbucket.port");
contextPath = getEnvironmentVariable("gitbucket.prefix");
tmpDirPath = getEnvironmentVariable("gitbucket.tempDir");
for(String arg: args) {
if(arg.equals("--save_sessions")) {
if (arg.equals("--save_sessions")) {
saveSessions = true;
}
if (arg.equals("--disable_news_feed")) {
System.setProperty("gitbucket.disableNewsFeed", "true");
}
if (arg.equals("--disable_cache")) {
System.setProperty("gitbucket.disableCache", "true");
}
if(arg.startsWith("--") && arg.contains("=")) {
String[] dim = arg.split("=");
if(dim.length >= 2) {
String[] dim = arg.split("=", 2);
if(dim.length == 2) {
switch (dim[0]) {
case "--connectors":
connectors = dim[1];
break;
case "--host":
host = dim[1];
break;
case "--port":
port = dim[1];
break;
case "--secure_port":
securePort = dim[1];
break;
case "--key_store_path":
keyStorePath = dim[1];
break;
case "--key_store_password":
keyStorePassword = dim[1];
break;
case "--key_manager_password":
keyManagerPassword = dim[1];
break;
case "--redirect_https":
redirectHttps = dim[1];
break;
case "--prefix":
contextPath = dim[1];
break;
@@ -58,6 +114,9 @@ public class JettyLauncher {
case "--plugin_dir":
System.setProperty("gitbucket.pluginDir", dim[1]);
break;
case "--jetty_idle_timeout":
jettyIdleTimeout = dim[1];
break;
}
}
}
@@ -67,38 +126,74 @@ public class JettyLauncher {
contextPath = "/" + contextPath;
}
if(host != null) {
address = new InetSocketAddress(host, getPort(port));
final String hostName = InetAddress.getByName(fallback(host, Defaults.HOST)).getHostName();
final Server server = new Server();
final Set<String> connectorsSet = Stream.of(fallback(connectors, Defaults.CONNECTORS)
.toLowerCase().split(",")).map(String::trim).collect(toSet());
final List<ServerConnector> connectorInstances = new ArrayList<>();
final HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSendServerVersion(false);
if (connectorsSet.contains(Connectors.HTTPS)) {
httpConfig.setSecurePort(fallback(securePort, Defaults.HTTPS_PORT, Integer::parseInt));
}
if (jettyIdleTimeout != null && jettyIdleTimeout.trim().length() != 0) {
httpConfig.setIdleTimeout(Long.parseLong(jettyIdleTimeout.trim()));
} else {
address = new InetSocketAddress(getPort(port));
httpConfig.setIdleTimeout(300000L); // default is 5min
}
Server server = new Server(address);
if (connectorsSet.contains(Connectors.HTTP)) {
final ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
connector.setHost(hostName);
connector.setPort(fallback(port, Defaults.HTTP_PORT, Integer::parseInt));
// SelectChannelConnector connector = new SelectChannelConnector();
// if(host != null) {
// connector.setHost(host);
// }
// connector.setMaxIdleTime(1000 * 60 * 60);
// connector.setSoLingerTime(-1);
// connector.setPort(port);
// server.addConnector(connector);
// Disabling Server header
for (Connector connector : server.getConnectors()) {
for (ConnectionFactory factory : connector.getConnectionFactories()) {
if (factory instanceof HttpConnectionFactory) {
((HttpConnectionFactory) factory).getHttpConfiguration().setSendServerVersion(false);
}
}
connectorInstances.add(connector);
}
if (connectorsSet.contains(Connectors.HTTPS)) {
final SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
sslContextFactory.setKeyStorePath(requireNonNull(keyStorePath,
"You must specify a path to an SSL keystore via the --key_store_path command line argument" +
" or GITBUCKET_KEYSTOREPATH environment variable."));
sslContextFactory.setKeyStorePassword(requireNonNull(keyStorePassword,
"You must specify a an SSL keystore password via the --key_store_password argument" +
" or GITBUCKET_KEYSTOREPASSWORD environment variable."));
sslContextFactory.setKeyManagerPassword(requireNonNull(keyManagerPassword,
"You must specify a key manager password via the --key_manager_password' argument" +
" or GITBUCKET_KEYMANAGERPASSWORD environment variable."));
final HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
final ServerConnector connector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(httpsConfig));
connector.setHost(hostName);
connector.setPort(fallback(securePort, Defaults.HTTPS_PORT, Integer::parseInt));
connectorInstances.add(connector);
}
require(!connectorInstances.isEmpty(),
"No server connectors could be configured, please check your --connectors command line argument" +
" or GITBUCKET_CONNECTORS environment variable.");
server.setConnectors(connectorInstances.toArray(new ServerConnector[0]));
WebAppContext context = new WebAppContext();
if(saveSessions) {
File sessDir = new File(getGitBucketHome(), "sessions");
if(!sessDir.exists()){
sessDir.mkdirs();
mkdir(sessDir);
}
SessionHandler sessions = context.getSessionHandler();
SessionCache cache = new DefaultSessionCache(sessions);
@@ -112,7 +207,7 @@ public class JettyLauncher {
if(tmpDirPath == null || tmpDirPath.equals("")){
tmpDir = new File(getGitBucketHome(), "tmp");
if(!tmpDir.exists()){
tmpDir.mkdirs();
mkdir(tmpDir);
}
} else {
tmpDir = new File(tmpDirPath);
@@ -136,13 +231,16 @@ public class JettyLauncher {
context.setDescriptor(location.toExternalForm() + "/WEB-INF/web.xml");
context.setServer(server);
context.setWar(location.toExternalForm());
if (forceHttps) {
context.setInitParameter("org.scalatra.ForceHttps", "true");
final HandlerList handlers = new HandlerList();
if (fallback(redirectHttps, Defaults.REDIRECT_HTTPS, Boolean::parseBoolean)) {
handlers.addHandler(new SecuredRedirectHandler());
}
Handler handler = addStatisticsHandler(context);
handlers.addHandler(addStatisticsHandler(context));
server.setHandler(handler);
server.setHandler(handlers);
server.setStopAtShutdown(true);
server.setStopTimeout(7_000);
server.start();
@@ -170,11 +268,28 @@ public class JettyLauncher {
}
}
private static int getPort(String port){
if(port == null) {
return 8080;
} else {
return Integer.parseInt(port);
private static <T, R> T fallback(R value, T defaultValue, Function<R, T> converter) {
return value == null ? defaultValue : converter.apply(value);
}
private static <T> T fallback(T value, T defaultValue) {
return fallback(value, defaultValue, identity());
}
private static void require(boolean condition, String message) {
if (!condition) {
throw new IllegalArgumentException(message);
}
}
private static <T> T requireNonNull(T value, String message) {
require(value != null, message);
return value;
}
private static void mkdir(File dir) {
if (!dir.mkdirs()) {
throw new RuntimeException("Unable to create directory: " + dir);
}
}

View File

@@ -20,15 +20,15 @@ public class PatchUtil {
public static String apply(String source, String patch, FileHeader fh)
throws IOException, PatchApplyException {
RawText rt = new RawText(source.getBytes("UTF-8"));
List<String> oldLines = new ArrayList<String>(rt.size());
List<String> oldLines = new ArrayList<>(rt.size());
for (int i = 0; i < rt.size(); i++)
oldLines.add(rt.getString(i));
List<String> newLines = new ArrayList<String>(oldLines);
List<String> newLines = new ArrayList<>(oldLines);
for (HunkHeader hh : fh.getHunks()) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(patch.getBytes("UTF-8"), hh.getStartOffset(), hh.getEndOffset() - hh.getStartOffset());
RawText hrt = new RawText(out.toByteArray());
List<String> hunkLines = new ArrayList<String>(hrt.size());
List<String> hunkLines = new ArrayList<>(hrt.size());
for (int i = 0; i < hrt.size(); i++)
hunkLines.add(hrt.getString(i));
int pos = 0;

View File

@@ -1,4 +1,4 @@
notifications:1.8.0
gist:4.18.0
notifications:1.11.0
gist:4.23.0
emoji:4.6.0
pages:1.8.0
pages:1.10.0

View File

@@ -7,7 +7,7 @@
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>gitbucket.log</file>
<file>.tmp/gitbucket.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
@@ -23,4 +23,4 @@
<logger name="scala.slick.jdbc.JdbcBackend.statement" level="DEBUG" />
-->
</configuration>
</configuration>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -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);

View File

@@ -237,7 +237,7 @@
<addForeignKeyConstraint constraintName="IDX_ISSUE_ID_FK1" baseTableName="ISSUE_ID" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
<!--================================================================================================-->
<!-- ISSUE_ID -->
<!-- ISSUE_LABEL -->
<!--================================================================================================-->
<createTable tableName="ISSUE_LABEL">
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
@@ -343,4 +343,28 @@
<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"/>
<!--================================================================================================-->
<!-- 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>

View File

@@ -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);

View File

@@ -35,4 +35,28 @@
<column name="URL" type="varchar(200)" nullable="false"/>
<column name="EVENT" type="varchar(30)" nullable="false"/>
</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>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<changeSet>
<dropTable tableName="ACTIVITY" />
</changeSet>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<changeSet>
<!--================================================================================================-->
<!-- WEB_HOOK -->
<!--================================================================================================-->
<dropForeignKeyConstraint constraintName="IDX_WEB_HOOK_EVENT_FK0" baseTableName="WEB_HOOK_EVENT"/>
<dropForeignKeyConstraint constraintName="IDX_WEB_HOOK_FK0" baseTableName="WEB_HOOK"/>
<dropPrimaryKey constraintName="IDX_WEB_HOOK_PK" tableName="WEB_HOOK"/>
<createTable tableName="WEB_HOOK_2">
<column name="HOOK_ID" type="int" nullable="true" autoIncrement="true" unique="false" primaryKeyName="IDX_WEB_HOOK_PK" primaryKey="true" />
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
<column name="URL" type="varchar(200)" nullable="false"/>
<column name="TOKEN" type="varchar(100)" nullable="true"/>
<column name="CTYPE" type="varchar(10)" nullable="true"/>
</createTable>
<sql>
INSERT INTO WEB_HOOK_2 (USER_NAME, REPOSITORY_NAME, URL, TOKEN, CTYPE) SELECT USER_NAME, REPOSITORY_NAME, URL, TOKEN, CTYPE FROM WEB_HOOK
</sql>
<renameTable newTableName="WEB_HOOK_BK" oldTableName="WEB_HOOK"/>
<renameTable newTableName="WEB_HOOK" oldTableName="WEB_HOOK_2"/>
<addUniqueConstraint constraintName="IDX_WEB_HOOK_1" tableName="WEB_HOOK" columnNames="USER_NAME, REPOSITORY_NAME, URL"/>
<addForeignKeyConstraint constraintName="IDX_WEB_HOOK_FK0" baseTableName="WEB_HOOK" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
<addForeignKeyConstraint constraintName="IDX_WEB_HOOK_EVENT_FK0" baseTableName="WEB_HOOK_EVENT" baseColumnNames="USER_NAME, REPOSITORY_NAME, URL" referencedTableName="WEB_HOOK" referencedColumnNames="USER_NAME, REPOSITORY_NAME, URL" onDelete="CASCADE" onUpdate="CASCADE"/>
<!--================================================================================================-->
<!-- ACCOUNT_PREFERENCE -->
<!--================================================================================================-->
<createTable tableName="ACCOUNT_PREFERENCE">
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
<column name="HIGHLIGHTER_THEME" type="varchar(100)" nullable="false" defaultValue="prettify"/>
</createTable>
<addPrimaryKey constraintName="IDX_ACCOUNT_PREFERENCE_PK" tableName="ACCOUNT_PREFERENCE" columnNames="USER_NAME"/>
<addForeignKeyConstraint constraintName="IDX_ACCOUNT_PREFERENCE_FK0" baseTableName="ACCOUNT_PREFERENCE" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
</changeSet>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<changeSet>
<addColumn tableName="REPOSITORY">
<column name="SAFE_MODE" type="boolean" nullable="false" defaultValue="true"/>
</addColumn>
</changeSet>

View 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>

View 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>

View 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>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<changeSet>
<dropForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_FK0" baseTableName="PROTECTED_BRANCH_REQUIRE_CONTEXT"/>
<dropPrimaryKey constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_PK" tableName="PROTECTED_BRANCH_REQUIRE_CONTEXT"/>
<dropForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_FK0" baseTableName="PROTECTED_BRANCH"/>
<dropPrimaryKey constraintName="IDX_PROTECTED_BRANCH_PK" tableName="PROTECTED_BRANCH"/>
<modifyDataType columnName="DEFAULT_BRANCH" newDataType="varchar(255)" tableName="REPOSITORY"/>
<modifyDataType columnName="BRANCH" newDataType="varchar(255)" tableName="PULL_REQUEST"/>
<modifyDataType columnName="REQUEST_BRANCH" newDataType="varchar(255)" tableName="PULL_REQUEST"/>
<modifyDataType columnName="BRANCH" newDataType="varchar(255)" tableName="PROTECTED_BRANCH"/>
<modifyDataType columnName="BRANCH" newDataType="varchar(255)" tableName="PROTECTED_BRANCH_REQUIRE_CONTEXT"/>
<addPrimaryKey constraintName="IDX_PROTECTED_BRANCH_PK" tableName="PROTECTED_BRANCH" columnNames="USER_NAME, REPOSITORY_NAME, BRANCH"/>
<addForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_FK0" baseTableName="PROTECTED_BRANCH" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
<addPrimaryKey constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_PK" tableName="PROTECTED_BRANCH_REQUIRE_CONTEXT" columnNames="USER_NAME, REPOSITORY_NAME, BRANCH, CONTEXT"/>
<addForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_REQUIRE_CONTEXT_FK0" baseTableName="PROTECTED_BRANCH_REQUIRE_CONTEXT" baseColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" referencedTableName="PROTECTED_BRANCH" referencedColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" onDelete="CASCADE" onUpdate="CASCADE"/>
</changeSet>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<changeSet>
<!--================================================================================================-->
<!-- PROTECTED_BRANCH -->
<!--================================================================================================-->
<addColumn tableName="PROTECTED_BRANCH">
<column name="REQUIRED_STATUS_CHECK" type="boolean" nullable="false" defaultValue="false"/>
<column name="RESTRICTIONS" type="boolean" nullable="false" defaultValue="false"/>
</addColumn>
<sql>
UPDATE PROTECTED_BRANCH SET REQUIRED_STATUS_CHECK = TRUE
WHERE EXISTS (SELECT * FROM PROTECTED_BRANCH_REQUIRE_CONTEXT
WHERE PROTECTED_BRANCH.USER_NAME = PROTECTED_BRANCH_REQUIRE_CONTEXT.USER_NAME
AND PROTECTED_BRANCH.REPOSITORY_NAME = PROTECTED_BRANCH_REQUIRE_CONTEXT.REPOSITORY_NAME
AND PROTECTED_BRANCH.BRANCH = PROTECTED_BRANCH_REQUIRE_CONTEXT.BRANCH)
</sql>
<!--================================================================================================-->
<!-- PROTECTED_BRANCH_RESTRICTIONS_USER -->
<!--================================================================================================-->
<createTable tableName="PROTECTED_BRANCH_RESTRICTION">
<column name="USER_NAME" type="varchar(100)" nullable="false"/>
<column name="REPOSITORY_NAME" type="varchar(100)" nullable="false"/>
<column name="BRANCH" type="varchar(100)" nullable="false"/>
<column name="ALLOWED_USER" type="varchar(255)" nullable="false"/>
</createTable>
<addPrimaryKey constraintName="IDX_PROTECTED_BRANCH_RESTRICTION_PK" tableName="PROTECTED_BRANCH_RESTRICTION" columnNames="USER_NAME, REPOSITORY_NAME, BRANCH, ALLOWED_USER"/>
<addForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_RESTRICTION_FK0" baseTableName="PROTECTED_BRANCH_RESTRICTION" baseColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" referencedTableName="PROTECTED_BRANCH" referencedColumnNames="USER_NAME, REPOSITORY_NAME, BRANCH" onDelete="CASCADE" onUpdate="CASCADE"/>
<addForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_RESTRICTION_FK1" baseTableName="PROTECTED_BRANCH_RESTRICTION" baseColumnNames="ALLOWED_USER" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
<!--================================================================================================-->
<!-- PULL_REQUEST -->
<!--================================================================================================-->
<addColumn tableName="PULL_REQUEST">
<column name="MERGED_COMMIT_IDS" type="text" nullable="true"/>
</addColumn>
</changeSet>

View File

@@ -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)

View File

@@ -30,4 +30,9 @@
<dropColumn tableName="REPOSITORY" columnName="ENABLE_WIKI"/>
<dropColumn tableName="REPOSITORY" columnName="ALLOW_WIKI_EDITING"/>
<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>

View File

@@ -2,7 +2,6 @@ import java.util.EnumSet
import javax.servlet._
import gitbucket.core.controller.{ReleaseController, _}
import gitbucket.core.plugin.PluginRegistry
import gitbucket.core.service.SystemSettingsService
import gitbucket.core.servlet._
import gitbucket.core.util.Directory

View File

@@ -1,16 +1,26 @@
package gitbucket.core
import io.github.gitbucket.solidbase.migration.{SqlMigration, LiquibaseMigration}
import io.github.gitbucket.solidbase.model.{Version, Module}
import java.io.FileOutputStream
import java.nio.charset.StandardCharsets
import java.sql.Connection
import java.util.UUID
import gitbucket.core.model.Activity
import gitbucket.core.util.Directory.ActivityLog
import gitbucket.core.util.JDBCUtil
import io.github.gitbucket.solidbase.Solidbase
import io.github.gitbucket.solidbase.migration.{LiquibaseMigration, Migration}
import io.github.gitbucket.solidbase.model.{Module, Version}
import org.json4s.{Formats, NoTypeHints}
import org.json4s.jackson.Serialization
import org.json4s.jackson.Serialization.write
import java.util.logging.Level
import scala.util.Using
object GitBucketCoreModule
extends Module(
"gitbucket-core",
new Version(
"4.0.0",
new LiquibaseMigration("update/gitbucket-core_4.0.xml"),
new SqlMigration("update/gitbucket-core_4.0.sql")
),
new Version("4.0.0", new LiquibaseMigration("update/gitbucket-core_4.0.xml")),
new Version("4.1.0"),
new Version("4.2.0", new LiquibaseMigration("update/gitbucket-core_4.2.xml")),
new Version("4.2.1"),
@@ -18,11 +28,7 @@ object GitBucketCoreModule
new Version("4.4.0"),
new Version("4.5.0"),
new Version("4.6.0", new LiquibaseMigration("update/gitbucket-core_4.6.xml")),
new Version(
"4.7.0",
new LiquibaseMigration("update/gitbucket-core_4.7.xml"),
new SqlMigration("update/gitbucket-core_4.7.sql")
),
new Version("4.7.0", new LiquibaseMigration("update/gitbucket-core_4.7.xml")),
new Version("4.7.1"),
new Version("4.8"),
new Version("4.9.0", new LiquibaseMigration("update/gitbucket-core_4.9.xml")),
@@ -31,11 +37,7 @@ object GitBucketCoreModule
new Version("4.12.0"),
new Version("4.12.1"),
new Version("4.13.0"),
new Version(
"4.14.0",
new LiquibaseMigration("update/gitbucket-core_4.14.xml"),
new SqlMigration("update/gitbucket-core_4.14.sql")
),
new Version("4.14.0", new LiquibaseMigration("update/gitbucket-core_4.14.xml")),
new Version("4.14.1"),
new Version("4.15.0"),
new Version("4.16.0"),
@@ -65,5 +67,61 @@ object GitBucketCoreModule
new Version("4.31.1"),
new Version("4.31.2"),
new Version("4.32.0", new LiquibaseMigration("update/gitbucket-core_4.32.xml")),
new Version("4.33.0")
)
new Version("4.33.0"),
new Version(
"4.34.0",
new Migration() {
override def migrate(moduleId: String, version: String, context: java.util.Map[String, AnyRef]): Unit = {
implicit val formats: Formats = Serialization.formats(NoTypeHints)
import JDBCUtil._
val conn = context.get(Solidbase.CONNECTION).asInstanceOf[Connection]
val list = conn.select("SELECT * FROM ACTIVITY ORDER BY ACTIVITY_ID") { rs =>
Activity(
activityId = UUID.randomUUID().toString,
userName = rs.getString("USER_NAME"),
repositoryName = rs.getString("REPOSITORY_NAME"),
activityUserName = rs.getString("ACTIVITY_USER_NAME"),
activityType = rs.getString("ACTIVITY_TYPE"),
message = rs.getString("MESSAGE"),
additionalInfo = {
val additionalInfo = rs.getString("ADDITIONAL_INFO")
if (rs.wasNull()) None else Some(additionalInfo)
},
activityDate = rs.getTimestamp("ACTIVITY_DATE")
)
}
Using.resource(new FileOutputStream(ActivityLog, true)) { out =>
list.foreach { activity =>
out.write((write(activity) + "\n").getBytes(StandardCharsets.UTF_8))
}
}
}
},
new LiquibaseMigration("update/gitbucket-core_4.34.xml")
),
new Version("4.35.0", new LiquibaseMigration("update/gitbucket-core_4.35.xml")),
new Version("4.35.1"),
new Version("4.35.2"),
new Version("4.35.3"),
new Version("4.36.0", new LiquibaseMigration("update/gitbucket-core_4.36.xml")),
new Version("4.36.1"),
new Version("4.36.2"),
new Version("4.37.0", new LiquibaseMigration("update/gitbucket-core_4.37.xml")),
new Version("4.37.1"),
new Version("4.37.2"),
new Version("4.38.0", new LiquibaseMigration("update/gitbucket-core_4.38.xml")),
new Version("4.38.1"),
new Version("4.38.2"),
new Version("4.38.3"),
new Version("4.38.4"),
new Version("4.39.0", new LiquibaseMigration("update/gitbucket-core_4.39.xml")),
new Version("4.40.0"),
new Version("4.41.0"),
new Version("4.42.0", new LiquibaseMigration("update/gitbucket-core_4.42.xml")),
new Version("4.42.1"),
new Version("4.43.0"),
new Version("4.44.0", new LiquibaseMigration("update/gitbucket-core_4.44.xml"))
) {
java.util.logging.Logger.getLogger("liquibase").setLevel(Level.SEVERE)
}

View File

@@ -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])

View File

@@ -6,7 +6,7 @@ import gitbucket.core.util.RepositoryName
* https://developer.github.com/v3/repos/#get-branch
* https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
*/
case class ApiBranch(name: String, commit: ApiBranchCommit, protection: ApiBranchProtection)(
case class ApiBranch(name: String, commit: ApiBranchCommit, protection: ApiBranchProtectionResponse)(
repositoryName: RepositoryName
) extends FieldSerializable {
val _links =
@@ -22,3 +22,12 @@ case class ApiBranchForList(
name: String,
commit: ApiBranchCommit
)
/**
* https://docs.github.com/en/rest/reference/repos#list-branches-for-head-commit
*/
case class ApiBranchForHeadCommit(
name: String,
commit: ApiBranchCommit,
`protected`: Boolean
)

View File

@@ -1,54 +0,0 @@
package gitbucket.core.api
import gitbucket.core.service.ProtectedBranchService
import org.json4s._
/** https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection */
case class ApiBranchProtection(enabled: Boolean, required_status_checks: Option[ApiBranchProtection.Status]) {
def status: ApiBranchProtection.Status = required_status_checks.getOrElse(ApiBranchProtection.statusNone)
}
object ApiBranchProtection {
/** form for enabling-and-disabling-branch-protection */
case class EnablingAndDisabling(protection: ApiBranchProtection)
def apply(info: ProtectedBranchService.ProtectedBranchInfo): ApiBranchProtection =
ApiBranchProtection(
enabled = info.enabled,
required_status_checks = Some(
Status(EnforcementLevel(info.enabled && info.contexts.nonEmpty, info.includeAdministrators), info.contexts)
)
)
val statusNone = Status(Off, Seq.empty)
case class Status(enforcement_level: EnforcementLevel, contexts: Seq[String])
sealed class EnforcementLevel(val name: String)
case object Off extends EnforcementLevel("off")
case object NonAdmins extends EnforcementLevel("non_admins")
case object Everyone extends EnforcementLevel("everyone")
object EnforcementLevel {
def apply(enabled: Boolean, includeAdministrators: Boolean): EnforcementLevel =
if (enabled) {
if (includeAdministrators) {
Everyone
} else {
NonAdmins
}
} else {
Off
}
}
implicit val enforcementLevelSerializer = new CustomSerializer[EnforcementLevel](
format =>
(
{
case JString("off") => Off
case JString("non_admins") => NonAdmins
case JString("everyone") => Everyone
}, {
case x: EnforcementLevel => JString(x.name)
}
)
)
}

View File

@@ -0,0 +1,21 @@
package gitbucket.core.api
/** https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection */
case class ApiBranchProtectionRequest(
enabled: Boolean,
required_status_checks: Option[ApiBranchProtectionRequest.Status],
restrictions: Option[ApiBranchProtectionRequest.Restrictions],
enforce_admins: Option[Boolean]
)
object ApiBranchProtectionRequest {
/** form for enabling-and-disabling-branch-protection */
case class EnablingAndDisabling(protection: ApiBranchProtectionRequest)
case class Status(
contexts: Seq[String]
)
case class Restrictions(users: Seq[String])
}

View File

@@ -0,0 +1,97 @@
package gitbucket.core.api
import gitbucket.core.service.ProtectedBranchService
import org.json4s._
/** https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection */
case class ApiBranchProtectionResponse(
url: Option[ApiPath], // for output
enabled: Boolean,
required_status_checks: Option[ApiBranchProtectionResponse.Status],
restrictions: Option[ApiBranchProtectionResponse.Restrictions],
enforce_admins: Option[ApiBranchProtectionResponse.EnforceAdmins]
) {
def status: ApiBranchProtectionResponse.Status =
required_status_checks.getOrElse(ApiBranchProtectionResponse.statusNone)
}
object ApiBranchProtectionResponse {
case class EnforceAdmins(enabled: Boolean)
// /** form for enabling-and-disabling-branch-protection */
// case class EnablingAndDisabling(protection: ApiBranchProtectionResponse)
def apply(info: ProtectedBranchService.ProtectedBranchInfo): ApiBranchProtectionResponse =
ApiBranchProtectionResponse(
url = Some(
ApiPath(
s"/api/v3/repos/${info.owner}/${info.repository}/branches/${info.branch}/protection"
)
),
enabled = info.enabled,
required_status_checks = info.contexts.map { contexts =>
Status(
Some(
ApiPath(
s"/api/v3/repos/${info.owner}/${info.repository}/branches/${info.branch}/protection/required_status_checks"
)
),
EnforcementLevel(info.enabled && info.contexts.nonEmpty, info.enforceAdmins),
contexts,
Some(
ApiPath(
s"/api/v3/repos/${info.owner}/${info.repository}/branches/${info.branch}/protection/required_status_checks/contexts"
)
)
)
},
restrictions = info.restrictionsUsers.map { restrictionsUsers =>
Restrictions(restrictionsUsers)
},
enforce_admins = if (info.enabled) Some(EnforceAdmins(info.enforceAdmins)) else None
)
val statusNone: Status = Status(None, Off, Seq.empty, None)
case class Status(
url: Option[ApiPath], // for output
enforcement_level: EnforcementLevel,
contexts: Seq[String],
contexts_url: Option[ApiPath] // for output
)
sealed class EnforcementLevel(val name: String)
case object Off extends EnforcementLevel("off")
case object NonAdmins extends EnforcementLevel("non_admins")
case object Everyone extends EnforcementLevel("everyone")
object EnforcementLevel {
def apply(enabled: Boolean, includeAdministrators: Boolean): EnforcementLevel =
if (enabled) {
if (includeAdministrators) {
Everyone
} else {
NonAdmins
}
} else {
Off
}
}
case class Restrictions(users: Seq[String])
implicit val enforcementLevelSerializer: CustomSerializer[EnforcementLevel] =
new CustomSerializer[EnforcementLevel](format =>
(
{
case JString("off") => Off
case JString("non_admins") => NonAdmins
case JString("everyone") => Everyone
},
{ case x: EnforcementLevel =>
JString(x.name)
}
)
)
}

View File

@@ -14,7 +14,8 @@ case class ApiComment(id: Int, user: ApiUser, body: String, created_at: Date, up
isPullRequest: Boolean
) {
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}"
)
}

View File

@@ -29,7 +29,7 @@ case class ApiCommit(
object 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(
id = commit.id,
message = commit.fullMessage,

View File

@@ -69,7 +69,8 @@ object ApiCommits {
}
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,
deletions = deletions,
changes = additions + deletions,
@@ -97,7 +98,7 @@ object ApiCommits {
ApiCommits(
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${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
commit = Commit(
url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/commits/${commitInfo.id}"),
@@ -106,7 +107,9 @@ object ApiCommits {
message = commitInfo.shortMessage,
comment_count = commentCount,
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
)
),
@@ -114,7 +117,9 @@ object ApiCommits {
committer = ApiUser(committer),
parents = commitInfo.parents.map { parent =>
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
)
},

View File

@@ -22,16 +22,15 @@ object ApiContents {
ApiContents("dir", fileInfo.name, fileInfo.path, fileInfo.commitId, None, None)(repositoryName)
} else {
content
.map(
arr =>
ApiContents(
"file",
fileInfo.name,
fileInfo.path,
fileInfo.commitId,
Some(Base64.getEncoder.encodeToString(arr)),
Some("base64")
)(repositoryName)
.map(arr =>
ApiContents(
"file",
fileInfo.name,
fileInfo.path,
fileInfo.id.getName,
Some(Base64.getEncoder.encodeToString(arr)),
Some("base64")
)(repositoryName)
)
.getOrElse(ApiContents("file", fileInfo.name, fileInfo.path, fileInfo.commitId, None, None)(repositoryName))
}

View File

@@ -12,17 +12,19 @@ case class ApiIssue(
number: Int,
title: String,
user: ApiUser,
assignee: Option[ApiUser],
assignees: List[ApiUser],
labels: List[ApiLabel],
state: String,
created_at: Date,
updated_at: Date,
body: String
body: String,
milestone: Option[ApiMilestone]
)(repositoryName: RepositoryName, isPullRequest: Boolean) {
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 html_url = ApiPath(s"/${repositoryName.fullName}/${if (isPullRequest) { "pull" } else { "issues" }}/${number}")
val html_url = ApiPath(s"/${repositoryName.fullName}/${if (isPullRequest) { "pull" }
else { "issues" }}/${number}")
val pull_request = if (isPullRequest) {
Some(
Map(
@@ -42,16 +44,19 @@ object ApiIssue {
issue: Issue,
repositoryName: RepositoryName,
user: ApiUser,
assignee: Option[ApiUser],
labels: List[ApiLabel]
assignees: List[ApiUser],
labels: List[ApiLabel],
milestone: Option[ApiMilestone]
): ApiIssue =
ApiIssue(
number = issue.issueId,
title = issue.title,
user = user,
assignee = assignee,
assignees = assignees,
labels = labels,
state = if (issue.closed) { "closed" } else { "open" },
milestone = milestone,
state = if (issue.closed) { "closed" }
else { "open" },
body = issue.content.getOrElse(""),
created_at = issue.registeredDate,
updated_at = issue.updatedDate

View File

@@ -0,0 +1,49 @@
package gitbucket.core.api
import gitbucket.core.model.{Milestone, Repository}
import gitbucket.core.util.RepositoryName
import java.util.Date
/**
* https://docs.github.com/en/rest/reference/issues#milestones
*/
case class ApiMilestone(
url: ApiPath,
html_url: ApiPath,
// label_url: ApiPath,
id: Int,
number: Int,
state: String,
title: String,
description: String,
// creator: ApiUser, // MILESTONE table does not have created user column
open_issues: Int,
closed_issues: Int,
// created_at: Option[Date],
// updated_at: Option[Date],
closed_at: Option[Date],
due_on: Option[Date]
)
object ApiMilestone {
def apply(
repository: Repository,
milestone: Milestone,
open_issue_count: Int = 0,
closed_issue_count: Int = 0
): ApiMilestone =
ApiMilestone(
url = ApiPath(s"/api/v3/repos/${RepositoryName(repository).fullName}/milestones/${milestone.milestoneId}"),
html_url = ApiPath(s"/${RepositoryName(repository).fullName}/milestone/${milestone.milestoneId}"),
// label_url = ApiPath(s"/api/v3/repos/${RepositoryName(repository).fullName}/milestones/${milestone_number}/labels"),
id = milestone.milestoneId,
number = milestone.milestoneId, // use milestoneId as number
state = if (milestone.closedDate.isDefined) "closed" else "open",
title = milestone.title,
description = milestone.description.getOrElse(""),
open_issues = open_issue_count,
closed_issues = closed_issue_count,
closed_at = milestone.closedDate,
due_on = milestone.dueDate
)
}

View File

@@ -1,6 +1,6 @@
package gitbucket.core.api
import gitbucket.core.plugin.{PluginRegistry, PluginInfo}
import gitbucket.core.plugin.PluginInfo
case class ApiPlugin(
id: String,

View File

@@ -21,15 +21,16 @@ case class ApiPullRequest(
body: String,
user: ApiUser,
labels: List[ApiLabel],
assignee: Option[ApiUser],
assignees: List[ApiUser],
draft: Option[Boolean]
) {
val id = 0 // dummy id
val assignee = assignees.headOption
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 patch_url = ApiPath(s"${base.repo.html_url.path}/pull/${number}.patch")
// 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 url = ApiPath(s"${base.repo.url.path}/pulls/${number}")
//val issue_url = ApiPath(s"${base.repo.url.path}/issues/${number}")
// val issue_url = ApiPath(s"${base.repo.url.path}/issues/${number}")
val commits_url = ApiPath(s"${base.repo.url.path}/pulls/${number}/commits")
val review_comments_url = ApiPath(s"${base.repo.url.path}/pulls/${number}/comments")
val review_comment_url = ApiPath(s"${base.repo.url.path}/pulls/comments/{number}")
@@ -45,7 +46,7 @@ object ApiPullRequest {
baseRepo: ApiRepository,
user: ApiUser,
labels: List[ApiLabel],
assignee: Option[ApiUser],
assignees: List[ApiUser],
mergedComment: Option[(IssueComment, Account)]
): ApiPullRequest =
ApiPullRequest(
@@ -63,12 +64,13 @@ object ApiPullRequest {
body = issue.content.getOrElse(""),
user = user,
labels = labels,
assignee = assignee,
assignees = assignees,
draft = Some(pullRequest.isDraft)
)
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
}

View File

@@ -1,5 +1,55 @@
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"
)
)
}

View File

@@ -12,16 +12,16 @@ case class ApiRepository(
forks: Int,
`private`: Boolean,
default_branch: String,
owner: ApiUser
owner: ApiUser,
has_issues: Boolean
) {
val id = 0 // dummy id
val forks_count = forks
val watchers_count = watchers
val url = ApiPath(s"/api/v3/repos/${full_name}")
val http_url = ApiPath(s"/git/${full_name}.git")
val clone_url = ApiPath(s"/git/${full_name}.git")
val html_url = ApiPath(s"/${full_name}")
val ssh_url = Some(SshPath(s":${full_name}.git"))
val ssh_url = Some(SshPath(s"/${full_name}.git"))
}
object ApiRepository {
@@ -39,11 +39,16 @@ object ApiRepository {
forks = forkedCount,
`private` = repository.isPrivate,
default_branch = repository.defaultBranch,
owner = owner
owner = owner,
has_issues = if (repository.options.issuesOption == "DISABLE") false else true
)
def apply(repositoryInfo: RepositoryInfo, owner: ApiUser): ApiRepository =
ApiRepository(repositoryInfo.repository, owner, forkedCount = repositoryInfo.forkedCount)
ApiRepository(
repositoryInfo.repository,
owner,
forkedCount = repositoryInfo.forkedCount
)
def apply(repositoryInfo: RepositoryInfo, owner: Account): ApiRepository =
this(repositoryInfo, ApiUser(owner))
@@ -56,7 +61,8 @@ object ApiRepository {
watchers = 0,
forks = 0,
`private` = false,
default_branch = "master",
owner = owner
default_branch = "main",
owner = owner,
has_issues = true
)
}

View File

@@ -0,0 +1,6 @@
package gitbucket.core.api
case class ApiRepositoryCollaborator(
permission: String,
user: ApiUser
)

View File

@@ -0,0 +1,29 @@
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")
)
}

View File

@@ -24,7 +24,8 @@ object ApiUser {
def apply(user: Account): ApiUser = ApiUser(
login = user.userName,
email = user.mailAddress,
`type` = if (user.isGroupAccount) { "Organization" } else { "User" },
`type` = if (user.isGroupAccount) { "Organization" }
else { "User" },
site_admin = user.isAdmin,
created_at = user.registeredDate
)

View File

@@ -0,0 +1,44 @@
package gitbucket.core.api
import gitbucket.core.model.{RepositoryWebHook, WebHook}
/**
* https://docs.github.com/en/rest/reference/repos#webhooks
*/
case class ApiWebhookConfig(
content_type: String,
// insecure_ssl: String,
url: String
)
case class ApiWebhook(
`type`: String,
id: Int,
name: String,
active: Boolean,
events: List[String],
config: ApiWebhookConfig,
// updated_at: Option[Date],
// created_at: Option[Date],
url: ApiPath,
// test_url: ApiPath,
// ping_url: ApiPath,
// last_response: ...
)
object ApiWebhook {
def apply(
_type: String,
hook: RepositoryWebHook,
hookEvents: Set[WebHook.Event]
): ApiWebhook =
ApiWebhook(
`type` = _type,
id = hook.hookId,
name = "web", // dummy
active = true, // dummy
events = hookEvents.toList.map(_.name),
config = ApiWebhookConfig(hook.ctype.code, hook.url),
url = ApiPath(s"/api/v3/${hook.userName}/${hook.repositoryName}/hooks/${hook.hookId}")
)
}

View File

@@ -0,0 +1,14 @@
package gitbucket.core.api
import java.util.Date
case class CreateAMilestone(
title: String,
state: String = "open",
description: Option[String],
due_on: Option[Date]
) {
def isValid: Boolean = {
title.length <= 100 && title.matches("[a-zA-Z0-9\\-\\+_.]+")
}
}

View File

@@ -15,3 +15,11 @@ case class CreateAPullRequestAlt(
base: String,
maintainer_can_modify: Option[Boolean]
)
case class UpdateAPullRequest(
title: Option[String],
body: Option[String],
state: Option[String],
base: Option[String],
maintainer_can_modify: Option[Boolean],
)

View File

@@ -0,0 +1,7 @@
package gitbucket.core.api
/**
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#create-a-reference
* api form
*/
case class CreateARef(ref: String, sha: String)

View File

@@ -0,0 +1,35 @@
package gitbucket.core.api
case class CreateARepositoryWebhookConfig(
url: String,
content_type: String = "form",
insecure_ssl: String = "0",
secret: Option[String]
)
/**
* https://docs.github.com/en/rest/reference/repos#create-a-repository-webhook
*/
case class CreateARepositoryWebhook(
name: String = "web",
config: CreateARepositoryWebhookConfig,
events: List[String] = List("push"),
active: Boolean = true
) {
def isValid: Boolean = {
config.content_type == "form" || config.content_type == "json"
}
}
case class UpdateARepositoryWebhook(
name: String = "web",
config: CreateARepositoryWebhookConfig,
events: List[String] = List("push"),
add_events: List[String] = List(),
remove_events: List[String] = List(),
active: Boolean = true
) {
def isValid: Boolean = {
config.content_type == "form" || config.content_type == "json"
}
}

View File

@@ -15,13 +15,12 @@ object JsonFormat {
val parserISO = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
val jsonFormats = Serialization.formats(NoTypeHints) + new CustomSerializer[Date](
format =>
(
{
case JString(s) =>
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)) }
val jsonFormats = Serialization.formats(NoTypeHints) + new CustomSerializer[Date](format =>
(
{ case JString(s) =>
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)) }
)
) + FieldSerializer[ApiUser]() +
FieldSerializer[ApiGroup]() +
@@ -45,32 +44,35 @@ object JsonFormat {
FieldSerializer[ApiCommits.File]() +
FieldSerializer[ApiRelease]() +
FieldSerializer[ApiReleaseAsset]() +
ApiBranchProtection.enforcementLevelSerializer
ApiBranchProtectionResponse.enforcementLevelSerializer
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) => 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) =
new CustomSerializer[SshPath](
_ =>
({
new CustomSerializer[SshPath](_ =>
(
{
case JString(s) if c.sshUrl.exists(sshUrl => s.startsWith(sshUrl)) =>
SshPath(s.substring(c.sshUrl.get.length))
case JString(s) => throw new MappingException("Can't convert " + s + " to ApiPath")
}, {
case SshPath(path) =>
c.sshUrl.map { sshUrl =>
JString(sshUrl + path)
} getOrElse JNothing
})
},
{ case SshPath(path) =>
c.sshUrl.map { sshUrl =>
JString(sshUrl + path)
} getOrElse JNothing
}
)
)
/**

View File

@@ -0,0 +1,23 @@
package gitbucket.core.api
/**
* https://docs.github.com/en/rest/reference/pulls#merge-a-pull-request
*/
case class MergeAPullRequest(
commit_title: Option[String],
commit_message: Option[String],
/* TODO: Not Implemented
sha: Option[String],*/
merge_method: Option[String]
)
case class SuccessToMergePrResponse(
sha: String,
merged: Boolean,
message: String
)
case class FailToMergePrResponse(
documentation_url: String,
message: String
)

View File

@@ -0,0 +1,7 @@
package gitbucket.core.api
/**
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#update-a-reference
* api form
*/
case class UpdateARef(sha: String, force: Boolean)

View File

@@ -35,25 +35,14 @@ class AccountController
with WebHookService
with PrioritiesService
with RepositoryCreationService
with RequestCache
trait AccountControllerBase extends AccountManagementControllerBase {
self: AccountService
with RepositoryService
with ActivityService
with WikiService
with LabelsService
with SshKeyService
with GpgKeyService
with OneselfAuthenticator
with UsersAuthenticator
with GroupManagerAuthenticator
with ReadableUsersAuthenticator
with AccessTokenService
with WebHookService
with PrioritiesService
with RepositoryCreationService =>
self: AccountService & RepositoryService & ActivityService & WikiService & LabelsService & SshKeyService &
GpgKeyService & OneselfAuthenticator & UsersAuthenticator & GroupManagerAuthenticator & ReadableUsersAuthenticator &
AccessTokenService & WebHookService & PrioritiesService & RepositoryCreationService =>
case class AccountNewForm(
private case class AccountNewForm(
userName: String,
password: String,
fullName: String,
@@ -64,7 +53,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
fileId: Option[String]
)
case class AccountEditForm(
private case class AccountEditForm(
password: Option[String],
fullName: String,
mailAddress: String,
@@ -75,15 +64,17 @@ trait AccountControllerBase extends AccountManagementControllerBase {
clearImage: Boolean
)
case class SshKeyForm(title: String, publicKey: String)
private case class SshKeyForm(title: String, publicKey: String)
case class GpgKeyForm(title: String, publicKey: String)
private case class GpgKeyForm(title: String, publicKey: String)
case class PersonalTokenForm(note: String)
private case class PersonalTokenForm(note: String)
val newForm = mapping(
private case class SyntaxHighlighterThemeForm(theme: String)
private val newForm = mapping(
"userName" -> trim(label("User name", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
"password" -> trim(label("Password", text(required, maxlength(20)))),
"password" -> trim(label("Password", text(required, maxlength(40)))),
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress()))),
"extraMailAddresses" -> list(
@@ -94,8 +85,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
"fileId" -> trim(label("File ID", optional(text())))
)(AccountNewForm.apply)
val editForm = mapping(
"password" -> trim(label("Password", optional(text(maxlength(20))))),
private val editForm = mapping(
"password" -> trim(label("Password", optional(text(maxlength(40))))),
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress("userName")))),
"extraMailAddresses" -> list(
@@ -107,28 +98,41 @@ trait AccountControllerBase extends AccountManagementControllerBase {
"clearImage" -> trim(label("Clear image", boolean()))
)(AccountEditForm.apply)
val sshKeyForm = mapping(
private val sshKeyForm = mapping(
"title" -> trim(label("Title", text(required, maxlength(100)))),
"publicKey" -> trim2(label("Key", text(required, validPublicKey)))
)(SshKeyForm.apply)
val gpgKeyForm = mapping(
private val gpgKeyForm = mapping(
"title" -> trim(label("Title", text(required, maxlength(100)))),
"publicKey" -> label("Key", text(required, validGpgPublicKey))
)(GpgKeyForm.apply)
val personalTokenForm = mapping(
private val personalTokenForm = mapping(
"note" -> trim(label("Token", text(required, maxlength(100))))
)(PersonalTokenForm.apply)
case class NewGroupForm(
private val syntaxHighlighterThemeForm = mapping(
"highlighterTheme" -> trim(label("Theme", text(required)))
)(SyntaxHighlighterThemeForm.apply)
private val resetPasswordEmailForm = mapping(
"mailAddress" -> trim(label("Email", text(required)))
)(ResetPasswordEmailForm.apply)
private val resetPasswordForm = mapping(
"token" -> trim(label("Token", text(required))),
"password" -> trim(label("Password", text(required, maxlength(40))))
)(ResetPasswordForm.apply)
private case class NewGroupForm(
groupName: String,
description: Option[String],
url: Option[String],
fileId: Option[String],
members: String
)
case class EditGroupForm(
private case class EditGroupForm(
groupName: String,
description: Option[String],
url: Option[String],
@@ -136,8 +140,15 @@ trait AccountControllerBase extends AccountManagementControllerBase {
members: String,
clearImage: Boolean
)
private case class ResetPasswordEmailForm(
mailAddress: String
)
private case class ResetPasswordForm(
token: String,
password: String
)
val newGroupForm = mapping(
private val newGroupForm = mapping(
"groupName" -> trim(label("Group name", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
"description" -> trim(label("Group description", optional(text()))),
"url" -> trim(label("URL", optional(text(maxlength(200))))),
@@ -145,7 +156,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
"members" -> trim(label("Members", text(required, members)))
)(NewGroupForm.apply)
val editGroupForm = mapping(
private val editGroupForm = mapping(
"groupName" -> trim(label("Group name", text(required, maxlength(100), identifier))),
"description" -> trim(label("Group description", optional(text()))),
"url" -> trim(label("URL", optional(text(maxlength(200))))),
@@ -154,7 +165,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
"clearImage" -> trim(label("Clear image", boolean()))
)(EditGroupForm.apply)
case class RepositoryCreationForm(
private case class RepositoryCreationForm(
owner: String,
name: String,
description: Option[String],
@@ -162,9 +173,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
initOption: String,
sourceUrl: Option[String]
)
case class ForkRepositoryForm(owner: String, name: String)
val newRepositoryForm = mapping(
private val newRepositoryForm = mapping(
"owner" -> trim(label("Owner", text(required, maxlength(100), identifier, existsAccount))),
"name" -> trim(label("Repository name", text(required, maxlength(100), repository, uniqueRepository))),
"description" -> trim(label("Description", optional(text()))),
@@ -173,34 +183,27 @@ trait AccountControllerBase extends AccountManagementControllerBase {
"sourceUrl" -> trim(label("Source URL", optionalRequired(_.value("initOption") == "COPY", text())))
)(RepositoryCreationForm.apply)
val forkRepositoryForm = mapping(
"owner" -> trim(label("Repository owner", text(required))),
"name" -> trim(label("Repository name", text(required)))
)(ForkRepositoryForm.apply)
private case class AccountForm(accountName: String)
case class AccountForm(accountName: String)
val accountForm = mapping(
private val accountForm = mapping(
"account" -> trim(label("Group/User name", text(required, validAccountName)))
)(AccountForm.apply)
// for account web hook url addition.
case class AccountWebHookForm(
private case class AccountWebHookForm(
url: String,
events: Set[WebHook.Event],
ctype: WebHookContentType,
token: Option[String]
)
def accountWebHookForm(update: Boolean) =
private def accountWebHookForm(update: Boolean) =
mapping(
"url" -> trim(label("url", text(required, accountWebHook(update)))),
"events" -> accountWebhookEvents,
"ctype" -> label("ctype", text()),
"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
@@ -245,12 +248,12 @@ trait AccountControllerBase extends AccountManagementControllerBase {
gitbucket.core.account.html.activity(
account,
if (account.isGroupAccount) Nil else getGroupsByUserName(userName),
getActivitiesByUser(userName, true),
getActivitiesByUser(userName, publicOnly = true),
extraMailAddresses
)
// Members
case "members" if (account.isGroupAccount) => {
case "members" if account.isGroupAccount =>
val members = getGroupMembers(account.userName)
gitbucket.core.account.html.members(
account,
@@ -258,10 +261,9 @@ trait AccountControllerBase extends AccountManagementControllerBase {
extraMailAddresses,
isGroupManager(context.loginAccount, members)
)
}
// Repositories
case _ => {
case _ =>
val members = getGroupMembers(account.userName)
gitbucket.core.account.html.repositories(
account,
@@ -270,7 +272,6 @@ trait AccountControllerBase extends AccountManagementControllerBase {
extraMailAddresses,
isGroupManager(context.loginAccount, members)
)
}
}
} getOrElse NotFound()
}
@@ -278,7 +279,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
get("/:userName.atom") {
val userName = params("userName")
contentType = "application/atom+xml; type=feed"
helper.xml.feed(getActivitiesByUser(userName, true))
helper.xml.feed(getActivitiesByUser(userName, publicOnly = true))
}
get("/:userName.keys") {
@@ -323,22 +324,21 @@ trait AccountControllerBase extends AccountManagementControllerBase {
post("/:userName/_edit", editForm)(oneselfOnly { form =>
val userName = params("userName")
getAccountByUserName(userName).map {
account =>
updateAccount(
account.copy(
password = form.password.map(pbkdf2_sha256).getOrElse(account.password),
fullName = form.fullName,
mailAddress = form.mailAddress,
description = form.description,
url = form.url
)
getAccountByUserName(userName).map { account =>
updateAccount(
account.copy(
password = form.password.map(pbkdf2_sha256).getOrElse(account.password),
fullName = form.fullName,
mailAddress = form.mailAddress,
description = form.description,
url = form.url
)
)
updateImage(userName, form.fileId, form.clearImage)
updateAccountExtraMailAddresses(userName, form.extraMailAddresses.filter(_ != ""))
flash.update("info", "Account information has been updated.")
redirect(s"/${userName}/_edit")
updateImage(userName, form.fileId, form.clearImage)
updateAccountExtraMailAddresses(userName, form.extraMailAddresses.filter(_ != ""))
flash.update("info", "Account information has been updated.")
redirect(s"/$userName/_edit")
} getOrElse NotFound()
})
@@ -346,12 +346,11 @@ trait AccountControllerBase extends AccountManagementControllerBase {
get("/:userName/_delete")(oneselfOnly {
val userName = params("userName")
getAccountByUserName(userName, true).map {
account =>
if (isLastAdministrator(account)) {
flash.update("error", "Account can't be removed because this is last one administrator.")
redirect(s"/${userName}/_edit")
} else {
getAccountByUserName(userName, includeRemoved = true).map { account =>
if (isLastAdministrator(account)) {
flash.update("error", "Account can't be removed because this is last one administrator.")
redirect(s"/$userName/_edit")
} else {
// // Remove repositories
// getRepositoryNamesOfUser(userName).foreach { repositoryName =>
// deleteRepository(userName, repositoryName)
@@ -359,10 +358,10 @@ trait AccountControllerBase extends AccountManagementControllerBase {
// FileUtils.deleteDirectory(getWikiRepositoryDir(userName, repositoryName))
// FileUtils.deleteDirectory(getTemporaryDir(userName, repositoryName))
// }
suspendAccount(account)
session.invalidate
redirect("/")
}
suspendAccount(account)
session.invalidate()
redirect("/")
}
} getOrElse NotFound()
})
@@ -376,20 +375,20 @@ trait AccountControllerBase extends AccountManagementControllerBase {
post("/:userName/_ssh", sshKeyForm)(oneselfOnly { form =>
val userName = params("userName")
addPublicKey(userName, form.title, form.publicKey)
redirect(s"/${userName}/_ssh")
redirect(s"/$userName/_ssh")
})
get("/:userName/_ssh/delete/:id")(oneselfOnly {
val userName = params("userName")
val sshKeyId = params("id").toInt
deletePublicKey(userName, sshKeyId)
redirect(s"/${userName}/_ssh")
redirect(s"/$userName/_ssh")
})
get("/:userName/_gpg")(oneselfOnly {
val userName = params("userName")
getAccountByUserName(userName).map { x =>
//html.ssh(x, getPublicKeys(x.userName))
// html.ssh(x, getPublicKeys(x.userName))
html.gpg(x, getGpgPublicKeys(x.userName))
} getOrElse NotFound()
})
@@ -397,14 +396,14 @@ trait AccountControllerBase extends AccountManagementControllerBase {
post("/:userName/_gpg", gpgKeyForm)(oneselfOnly { form =>
val userName = params("userName")
addGpgPublicKey(userName, form.title, form.publicKey)
redirect(s"/${userName}/_gpg")
redirect(s"/$userName/_gpg")
})
get("/:userName/_gpg/delete/:id")(oneselfOnly {
val userName = params("userName")
val keyId = params("id").toInt
deleteGpgPublicKey(userName, keyId)
redirect(s"/${userName}/_gpg")
redirect(s"/$userName/_gpg")
})
get("/:userName/_application")(oneselfOnly {
@@ -412,13 +411,12 @@ trait AccountControllerBase extends AccountManagementControllerBase {
getAccountByUserName(userName).map { x =>
var tokens = getAccessTokens(x.userName)
val generatedToken = flash.get("generatedToken") match {
case Some((tokenId: Int, token: String)) => {
case Some((tokenId: Int, token: String)) =>
val gt = tokens.find(_.accessTokenId == tokenId)
gt.map { t =>
tokens = tokens.filterNot(_ == t)
(t, token)
}
}
case _ => None
}
html.application(x, tokens, generatedToken)
@@ -427,18 +425,41 @@ trait AccountControllerBase extends AccountManagementControllerBase {
post("/:userName/_personalToken", personalTokenForm)(oneselfOnly { form =>
val userName = params("userName")
getAccountByUserName(userName).map { x =>
getAccountByUserName(userName).foreach { _ =>
val (tokenId, token) = generateAccessToken(userName, form.note)
flash.update("generatedToken", (tokenId, token))
}
redirect(s"/${userName}/_application")
redirect(s"/$userName/_application")
})
get("/:userName/_personalToken/delete/:id")(oneselfOnly {
val userName = params("userName")
val tokenId = params("id").toInt
deleteAccessToken(userName, tokenId)
redirect(s"/${userName}/_application")
redirect(s"/$userName/_application")
})
/**
* Display the user preference settings page
*/
get("/:userName/_preferences")(oneselfOnly {
val userName = params("userName")
val currentTheme = getAccountPreference(userName) match {
case Some(accountHighlighter) => accountHighlighter.highlighterTheme
case _ => "github-v2"
}
getAccountByUserName(userName).map { x =>
html.preferences(x, currentTheme)
} getOrElse NotFound()
})
/**
* Update the syntax highlighter setting of user
*/
post("/:userName/_preferences/highlighter", syntaxHighlighterThemeForm)(oneselfOnly { form =>
val userName = params("userName")
addOrUpdateAccountPreference(userName, form.theme)
redirect(s"/$userName/_preferences")
})
get("/:userName/_hooks")(managersOnly {
@@ -455,7 +476,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
val userName = params("userName")
getAccountByUserName(userName).map { account =>
val webhook = AccountWebHook(userName, "", WebHookContentType.FORM, None)
html.edithook(webhook, Set(WebHook.Push), account, true)
html.edithook(webhook, Set(WebHook.Push), account, create = true)
} getOrElse NotFound()
})
@@ -466,7 +487,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
val userName = params("userName")
addAccountWebHook(userName, form.url, form.events, form.ctype, form.token)
flash.update("info", s"Webhook ${form.url} created")
redirect(s"/${userName}/_hooks")
redirect(s"/$userName/_hooks")
})
/**
@@ -476,7 +497,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
val userName = params("userName")
deleteAccountWebHook(userName, params("url"))
flash.update("info", s"Webhook ${params("url")} deleted")
redirect(s"/${userName}/_hooks")
redirect(s"/$userName/_hooks")
})
/**
@@ -485,9 +506,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
get("/:userName/_hooks/edit")(managersOnly {
val userName = params("userName")
getAccountByUserName(userName).flatMap { account =>
getAccountWebHook(userName, params("url")).map {
case (webhook, events) =>
html.edithook(webhook, events, account, false)
getAccountWebHook(userName, params("url")).map { case (webhook, events) =>
html.edithook(webhook, events, account, create = false)
}
} getOrElse NotFound()
})
@@ -499,7 +519,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
val userName = params("userName")
updateAccountWebHook(userName, form.url, form.events, form.ctype, form.token)
flash.update("info", s"webhook ${form.url} updated")
redirect(s"/${userName}/_hooks")
redirect(s"/$userName/_hooks")
})
/**
@@ -507,8 +527,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
*/
ajaxPost("/:userName/_hooks/test")(managersOnly {
// TODO Is it possible to merge with [[RepositorySettingsController.ajaxPost]]?
import scala.concurrent.duration._
import scala.concurrent._
import scala.concurrent.duration.*
import scala.concurrent.*
import scala.util.control.NonFatal
import org.apache.http.util.EntityUtils
import scala.concurrent.ExecutionContext.Implicits.global
@@ -521,7 +541,8 @@ trait AccountControllerBase extends AccountManagementControllerBase {
val url = params("url")
val token = Some(params("token"))
val ctype = WebHookContentType.valueOf(params("ctype"))
val dummyWebHookInfo = RepositoryWebHook(userName, "dummy", url, ctype, token)
val dummyWebHookInfo =
RepositoryWebHook(userName = userName, repositoryName = "dummy", url = url, ctype = ctype, token = token)
val dummyPayload = {
val ownerAccount = getAccountByUserName(userName).get
WebHookPushPayload.createDummyPayload(ownerAccount)
@@ -531,10 +552,10 @@ trait AccountControllerBase extends AccountManagementControllerBase {
callWebHook(WebHook.Push, List(dummyWebHookInfo), dummyPayload, context.settings).head
val toErrorMap: PartialFunction[Throwable, Map[String, String]] = {
case e: java.net.UnknownHostException => Map("error" -> ("Unknown host " + e.getMessage))
case e: java.lang.IllegalArgumentException => Map("error" -> ("invalid url"))
case e: org.apache.http.client.ClientProtocolException => Map("error" -> ("invalid url"))
case NonFatal(e) => Map("error" -> (s"${e.getClass} ${e.getMessage}"))
case e: java.net.UnknownHostException => Map("error" -> s"Unknown host ${e.getMessage}")
case _: java.lang.IllegalArgumentException => Map("error" -> "invalid url")
case _: org.apache.http.client.ClientProtocolException => Map("error" -> "invalid url")
case NonFatal(e) => Map("error" -> s"${e.getClass} ${e.getMessage}")
}
contentType = formats("json")
@@ -543,11 +564,10 @@ trait AccountControllerBase extends AccountManagementControllerBase {
"url" -> url,
"request" -> Await.result(
reqFuture
.map(
req =>
Map(
"headers" -> _headers(req.getAllHeaders),
"payload" -> json
.map(req =>
Map(
"headers" -> _headers(req.getAllHeaders),
"payload" -> json
)
)
.recover(toErrorMap),
@@ -555,12 +575,11 @@ trait AccountControllerBase extends AccountManagementControllerBase {
),
"response" -> Await.result(
resFuture
.map(
res =>
Map(
"status" -> res.getStatusLine(),
"body" -> EntityUtils.toString(res.getEntity()),
"headers" -> _headers(res.getAllHeaders())
.map(res =>
Map(
"status" -> res.getStatusLine,
"body" -> EntityUtils.toString(res.getEntity),
"headers" -> _headers(res.getAllHeaders)
)
)
.recover(toErrorMap),
@@ -571,7 +590,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
})
get("/register") {
if (context.settings.allowAccountRegistration) {
if (context.settings.basicBehavior.allowAccountRegistration) {
if (context.loginAccount.isDefined) {
redirect("/")
} else {
@@ -581,24 +600,83 @@ trait AccountControllerBase extends AccountManagementControllerBase {
}
post("/register", newForm) { form =>
if (context.settings.allowAccountRegistration) {
if (context.settings.basicBehavior.allowAccountRegistration) {
createAccount(
form.userName,
pbkdf2_sha256(form.password),
form.fullName,
form.mailAddress,
false,
isAdmin = false,
form.description,
form.url
)
updateImage(form.userName, form.fileId, false)
updateImage(form.userName, form.fileId, clearImage = false)
updateAccountExtraMailAddresses(form.userName, form.extraMailAddresses.filter(_ != ""))
redirect("/signin")
} 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 {
html.creategroup(List(GroupMember("", context.loginAccount.get.userName, true)))
context.withLoginAccount { loginAccount =>
html.creategroup(List(GroupMember("", loginAccount.userName, isManager = true)))
}
})
post("/groups/new", newGroupForm)(usersOnly { form =>
@@ -614,27 +692,25 @@ trait AccountControllerBase extends AccountManagementControllerBase {
}
.toList
)
updateImage(form.groupName, form.fileId, false)
updateImage(form.groupName, form.fileId, clearImage = false)
redirect(s"/${form.groupName}")
})
get("/:groupName/_editgroup")(managersOnly {
defining(params("groupName")) { groupName =>
getAccountByUserName(groupName, true).map { account =>
html.editgroup(account, getGroupMembers(groupName), flash.get("info"))
} getOrElse NotFound()
}
val groupName = params("groupName")
getAccountByUserName(groupName, includeRemoved = true).map { account =>
html.editgroup(account, getGroupMembers(groupName), flash.get("info"))
} getOrElse NotFound()
})
get("/:groupName/_deletegroup")(managersOnly {
defining(params("groupName")) {
groupName =>
// Remove from GROUP_MEMBER
updateGroupMembers(groupName, Nil)
// Disable group
getAccountByUserName(groupName, false).foreach { account =>
updateGroup(groupName, account.description, account.url, true)
}
val groupName = params("groupName")
// Remove from GROUP_MEMBER
updateGroupMembers(groupName, Nil)
// Disable group
getAccountByUserName(groupName, includeRemoved = false).foreach { account =>
updateGroup(groupName, account.description, account.url, removed = true)
}
// // Remove repositories
// getRepositoryNamesOfUser(groupName).foreach { repositoryName =>
// deleteRepository(groupName, repositoryName)
@@ -642,28 +718,25 @@ trait AccountControllerBase extends AccountManagementControllerBase {
// FileUtils.deleteDirectory(getWikiRepositoryDir(groupName, repositoryName))
// FileUtils.deleteDirectory(getTemporaryDir(groupName, repositoryName))
// }
}
redirect("/")
})
post("/:groupName/_editgroup", editGroupForm)(managersOnly { form =>
defining(
params("groupName"),
form.members
.split(",")
.map {
_.split(":") match {
case Array(userName, isManager) => (userName, isManager.toBoolean)
}
val groupName = params("groupName")
val members = form.members
.split(",")
.map {
_.split(":") match {
case Array(userName, isManager) => (userName, isManager.toBoolean)
}
.toList
) {
case (groupName, members) =>
getAccountByUserName(groupName, true).map { account =>
updateGroup(groupName, form.description, form.url, false)
}
.toList
// Update GROUP_MEMBER
updateGroupMembers(form.groupName, members)
getAccountByUserName(groupName, includeRemoved = true).map { _ =>
updateGroup(groupName, form.description, form.url, removed = false)
// Update GROUP_MEMBER
updateGroupMembers(form.groupName, members)
// // Update COLLABORATOR for group repositories
// getRepositoryNamesOfUser(form.groupName).foreach { repositoryName =>
// removeCollaborators(form.groupName, repositoryName)
@@ -672,87 +745,105 @@ trait AccountControllerBase extends AccountManagementControllerBase {
// }
// }
updateImage(form.groupName, form.fileId, form.clearImage)
updateImage(form.groupName, form.fileId, form.clearImage)
flash.update("info", "Account information has been updated.")
redirect(s"/${groupName}/_editgroup")
flash.update("info", "Account information has been updated.")
redirect(s"/$groupName/_editgroup")
} getOrElse NotFound()
}
} getOrElse NotFound()
})
/**
* Show the new repository form.
*/
get("/new")(usersOnly {
html.newrepo(getGroupsByUserName(context.loginAccount.get.userName), context.settings.isCreateRepoOptionPublic)
context.withLoginAccount { loginAccount =>
html.newrepo(getGroupsByUserName(loginAccount.userName), context.settings.basicBehavior.isCreateRepoOptionPublic)
}
})
/**
* Create new repository.
*/
post("/new", newRepositoryForm)(usersOnly { form =>
if (context.settings.repositoryOperation.create || context.loginAccount.get.isAdmin) {
LockUtil.lock(s"${form.owner}/${form.name}") {
if (getRepository(form.owner, form.name).isEmpty) {
createRepository(
context.loginAccount.get,
form.owner,
form.name,
form.description,
form.isPrivate,
form.initOption,
form.sourceUrl
)
context.withLoginAccount { loginAccount =>
if (context.settings.basicBehavior.repositoryOperation.create || loginAccount.isAdmin) {
LockUtil.lock(s"${form.owner}/${form.name}") {
if (getRepository(form.owner, form.name).isDefined) {
// redirect to the repository if repository already exists
redirect(s"/${form.owner}/${form.name}")
} else if (!canCreateRepository(form.owner, loginAccount)) {
// Permission error
Forbidden()
} else {
// create repository asynchronously
createRepository(
loginAccount,
form.owner,
form.name,
form.description,
form.isPrivate,
form.initOption,
form.sourceUrl,
context.settings.defaultBranch
)
// redirect to the repository
redirect(s"/${form.owner}/${form.name}")
}
}
}
// redirect to the repository
redirect(s"/${form.owner}/${form.name}")
} else Forbidden()
} else Forbidden()
}
})
get("/:owner/:repository/fork")(readableUsersOnly { repository =>
val loginAccount = context.loginAccount.get
if (repository.repository.options.allowFork && (context.settings.repositoryOperation.fork || loginAccount.isAdmin)) {
val loginUserName = loginAccount.userName
val groups = getGroupsByUserName(loginUserName)
groups match {
case _: List[String] =>
val managerPermissions = groups.map { group =>
val members = getGroupMembers(group)
context.loginAccount.exists(
x =>
context.withLoginAccount { loginAccount =>
if (
repository.repository.options.allowFork && (context.settings.basicBehavior.repositoryOperation.fork || loginAccount.isAdmin)
) {
val loginUserName = loginAccount.userName
val groups = getGroupsByUserName(loginUserName)
groups match {
case _: List[String] =>
val managerPermissions = groups.map { group =>
val members = getGroupMembers(group)
context.loginAccount.exists(x =>
members.exists { member =>
member.userName == x.userName && member.isManager
}
}
)
}
helper.html.forkrepository(
repository,
(groups zip managerPermissions).sortBy(_._1)
)
}
helper.html.forkrepository(
repository,
(groups zip managerPermissions).sortBy(_._1)
)
case _ => redirect(s"/${loginUserName}")
}
} else BadRequest()
case _ => redirect(s"/$loginUserName")
}
} else BadRequest()
}
})
post("/:owner/:repository/fork", accountForm)(readableUsersOnly { (form, repository) =>
val loginAccount = context.loginAccount.get
if (repository.repository.options.allowFork && (context.settings.repositoryOperation.fork || loginAccount.isAdmin)) {
val loginUserName = loginAccount.userName
val accountName = form.accountName
context.withLoginAccount { loginAccount =>
if (
repository.repository.options.allowFork && (context.settings.basicBehavior.repositoryOperation.fork || loginAccount.isAdmin)
) {
val loginUserName = loginAccount.userName
val accountName = form.accountName
if (getRepository(accountName, repository.name).isDefined ||
(accountName != loginUserName && !getGroupsByUserName(loginUserName).contains(accountName))) {
// redirect to the repository if repository already exists
redirect(s"/${accountName}/${repository.name}")
} else {
// fork repository asynchronously
forkRepository(accountName, repository, loginUserName)
// redirect to the repository
redirect(s"/${accountName}/${repository.name}")
}
} else Forbidden()
if (getRepository(accountName, repository.name).isDefined) {
// redirect to the repository if repository already exists
redirect(s"/$accountName/${repository.name}")
} else if (!canCreateRepository(accountName, loginAccount)) {
// Permission error
Forbidden()
} else {
// fork repository asynchronously
forkRepository(accountName, repository, loginUserName)
// redirect to the repository
redirect(s"/$accountName/${repository.name}")
}
} else Forbidden()
}
})
private def existsAccount: Constraint = new Constraint() {
@@ -778,9 +869,11 @@ trait AccountControllerBase extends AccountManagementControllerBase {
private def members: Constraint = new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] = {
if (value.split(",").exists {
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
}) None
if (
value.split(",").exists {
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
}
) None
else Some("Must select one manager at least.")
}
}

View File

@@ -1,10 +1,10 @@
package gitbucket.core.controller
import gitbucket.core.api._
import gitbucket.core.controller.api._
import gitbucket.core.service._
import gitbucket.core.util.Implicits._
import gitbucket.core.util._
import gitbucket.core.api.*
import gitbucket.core.controller.api.*
import gitbucket.core.service.*
import gitbucket.core.util.Implicits.*
import gitbucket.core.util.*
import gitbucket.core.plugin.PluginRegistry
class ApiController
@@ -13,6 +13,7 @@ class ApiController
with ApiIssueCommentControllerBase
with ApiIssueControllerBase
with ApiIssueLabelControllerBase
with ApiIssueMilestoneControllerBase
with ApiOrganizationControllerBase
with ApiPullRequestControllerBase
with ApiReleaseControllerBase
@@ -22,6 +23,7 @@ class ApiController
with ApiRepositoryContentsControllerBase
with ApiRepositoryControllerBase
with ApiRepositoryStatusControllerBase
with ApiRepositoryWebhookControllerBase
with ApiUserControllerBase
with RepositoryService
with AccountService
@@ -52,6 +54,7 @@ class ApiController
with ReferrerAuthenticator
with ReadableUsersAuthenticator
with WritableUsersAuthenticator
with RequestCache
trait ApiControllerBase extends ControllerBase {

View File

@@ -1,22 +1,21 @@
package gitbucket.core.controller
import java.io.{File, FileInputStream}
import java.io.{File, FileInputStream, FileOutputStream}
import gitbucket.core.api.{ApiError, JsonFormat}
import gitbucket.core.model.Account
import gitbucket.core.service.{AccountService, RepositoryService, SystemSettingsService}
import gitbucket.core.util.SyntaxSugars._
import gitbucket.core.util.Directory._
import gitbucket.core.util.Implicits._
import gitbucket.core.util._
import org.json4s._
import org.scalatra._
import org.scalatra.i18n._
import org.scalatra.json._
import org.scalatra.forms._
import gitbucket.core.util.SyntaxSugars.*
import gitbucket.core.util.Directory.*
import gitbucket.core.util.Implicits.*
import gitbucket.core.util.*
import org.json4s.*
import org.scalatra.{MultiParams, *}
import org.scalatra.i18n.*
import org.scalatra.json.*
import org.scalatra.forms.*
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
import javax.servlet.{FilterChain, ServletRequest, ServletResponse}
import is.tagomor.woothee.Classifier
import scala.util.Try
@@ -25,9 +24,13 @@ import net.coobird.thumbnailator.Thumbnails
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.ObjectId
import org.eclipse.jgit.revwalk.RevCommit
import org.eclipse.jgit.treewalk._
import org.eclipse.jgit.treewalk.*
import org.apache.commons.io.IOUtils
import org.slf4j.LoggerFactory
import org.json4s.Formats
import org.json4s.jackson.Serialization
import java.nio.charset.StandardCharsets
/**
* Provides generic features for controller implementations.
@@ -43,13 +46,23 @@ abstract class ControllerBase
private val logger = LoggerFactory.getLogger(getClass)
implicit val jsonFormats = gitbucket.core.api.JsonFormat.jsonFormats
implicit val jsonFormats: Formats = gitbucket.core.api.JsonFormat.jsonFormats
private case class HttpException(status: Int) extends RuntimeException
before("/api/v3/*") {
contentType = formats("json")
request.setAttribute(Keys.Request.APIv3, true)
}
override def multiParams(implicit request: HttpServletRequest): MultiParams = {
try {
super.multiParams
} catch {
case _: Exception => throw HttpException(400)
}
}
override def requestPath(uri: String, idx: Int): String = {
val path = super.requestPath(uri, idx)
if (path != "/" && path.endsWith("/")) {
@@ -83,17 +96,24 @@ abstract class ControllerBase
*/
implicit def context: Context = {
contextCache.get match {
case null => {
case null =>
val context = Context(loadSystemSettings(), LoginAccount, request)
contextCache.set(context)
context
}
case context => context
}
}
private def LoginAccount: Option[Account] =
request.getAs[Account](Keys.Session.LoginAccount).orElse(session.getAs[Account](Keys.Session.LoginAccount))
private def LoginAccount: Option[Account] = {
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 =
super.get(path) {
@@ -119,7 +139,7 @@ abstract class ControllerBase
action(form)
}
protected def NotFound() =
protected def NotFound(): ActionResult =
if (request.hasAttribute(Keys.Request.Ajax)) {
org.scalatra.NotFound()
} else if (request.hasAttribute(Keys.Request.APIv3)) {
@@ -139,7 +159,7 @@ abstract class ControllerBase
}
}
protected def Unauthorized()(implicit context: Context) =
protected def Unauthorized()(implicit context: Context): ActionResult =
if (request.hasAttribute(Keys.Request.Ajax)) {
org.scalatra.Unauthorized()
} else if (request.hasAttribute(Keys.Request.APIv3)) {
@@ -157,11 +177,8 @@ abstract class ControllerBase
org.scalatra.Unauthorized(
redirect(
"/signin?redirect=" + StringUtil.urlEncode(
defining(request.getQueryString) { queryString =>
request.getRequestURI.substring(request.getContextPath.length) + (if (queryString != null)
"?" + queryString
else "")
}
request.getRequestURI
.substring(request.getContextPath.length) + Option(request.getQueryString).map("?" + _).getOrElse("")
)
)
)
@@ -170,7 +187,9 @@ abstract class ControllerBase
}
error {
case e => {
case e: HttpException =>
ActionResult(e.status, (), Map.empty)
case e =>
logger.error(s"Catch unhandled error in request: ${request}", e)
if (request.hasAttribute(Keys.Request.Ajax)) {
org.scalatra.InternalServerError()
@@ -180,7 +199,6 @@ abstract class ControllerBase
} else {
org.scalatra.InternalServerError(gitbucket.core.html.error("Internal Server Error", Some(e)))
}
}
}
override def url(
@@ -192,7 +210,7 @@ abstract class ControllerBase
withSessionId: Boolean = true
)(implicit request: HttpServletRequest, response: HttpServletResponse): String =
if (path.startsWith("http")) path
else baseUrl + super.url(path, params, false, false, false)
else baseUrl + super.url(path, params, includeContextPath = false, includeServletPath = false, absolutize = false)
/**
* Extends scalatra-form's trim rule to eliminate CR and LF.
@@ -236,9 +254,9 @@ abstract class ControllerBase
protected def getPathObjectId(git: Git, path: String, revCommit: RevCommit): Option[ObjectId] = {
@scala.annotation.tailrec
def _getPathObjectId(path: String, walk: TreeWalk): Option[ObjectId] = walk.next match {
case true if (walk.getPathString == path) => Some(walk.getObjectId(0))
case true => _getPathObjectId(path, walk)
case false => None
case true if walk.getPathString == path => Some(walk.getObjectId(0))
case true => _getPathObjectId(path, walk)
case false => None
}
Using.resource(new TreeWalk(git.getRepository)) { treeWalk =>
@@ -255,7 +273,7 @@ abstract class ControllerBase
repository: RepositoryService.RepositoryInfo
): Unit = {
JGitUtil.getObjectLoaderFromId(git, objectId) { loader =>
contentType = FileUtil.getSafeMimeType(path)
contentType = FileUtil.getSafeMimeType(path, repository.repository.options.safeMode)
if (loader.isLarge) {
response.setContentLength(loader.getSize.toInt)
@@ -279,6 +297,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()
}
}
}
/**
@@ -289,18 +348,25 @@ case class Context(
loginAccount: Option[Account],
request: HttpServletRequest
) {
val path = settings.baseUrl.getOrElse(request.getContextPath)
val currentPath = request.getRequestURI.substring(request.getContextPath.length)
val baseUrl = settings.baseUrl(request)
val host = new java.net.URL(baseUrl).getHost
val platform = request.getHeader("User-Agent") match {
val path: String = settings.baseUrl.getOrElse(request.getContextPath)
val currentPath: String = request.getRequestURI.substring(request.getContextPath.length)
val baseUrl: String = settings.baseUrl(request)
val host: String = new java.net.URL(baseUrl).getHost
val platform: String = request.getHeader("User-Agent") match {
case null => null
case agent if agent.contains("Mac") => "mac"
case agent if agent.contains("Linux") => "linux"
case agent if agent.contains("Win") => "windows"
case _ => null
}
val sidebarCollapse = request.getSession.getAttribute("sidebar-collapse") != null
val sidebarCollapse: Boolean = request.getSession.getAttribute("sidebar-collapse") != null
def withLoginAccount(f: Account => Any): Any = {
loginAccount match {
case Some(loginAccount) => f(loginAccount)
case None => Unauthorized()
}
}
/**
* Get object from cache.
@@ -308,14 +374,14 @@ case class Context(
* If object has not been cached with the specified key then retrieves by given action.
* Cached object are available during a request.
*/
def cache[A](key: String)(action: => A): A =
defining(Keys.Request.Cache(key)) { cacheKey =>
Option(request.getAttribute(cacheKey).asInstanceOf[A]).getOrElse {
val newObject = action
request.setAttribute(cacheKey, newObject)
newObject
}
def cache[A](key: String)(action: => A): A = {
val cacheKey = Keys.Request.Cache(key)
Option(request.getAttribute(cacheKey).asInstanceOf[A]).getOrElse {
val newObject = action
request.setAttribute(cacheKey, newObject)
newObject
}
}
}
@@ -367,15 +433,16 @@ trait AccountManagementControllerBase extends ControllerBase {
messages: Messages
): Option[String] = {
val extraMailAddresses = params.view.filterKeys(k => k.startsWith("extraMailAddresses"))
if (extraMailAddresses.exists {
case (k, v) =>
v.contains(value)
}) {
if (
extraMailAddresses.exists { case (k, v) =>
v.contains(value)
}
) {
Some("These mail addresses are duplicated.")
} else {
getAccountByMailAddress(value, true)
getAccountByMailAddress(value, includeRemoved = true)
.collect {
case x if paramName.isEmpty || Some(x.userName) != params.optionValue(paramName) =>
case x if paramName.isEmpty || !params.optionValue(paramName).contains(x.userName) =>
"Mail address is already registered."
}
}
@@ -390,22 +457,23 @@ trait AccountManagementControllerBase extends ControllerBase {
messages: Messages
): Option[String] = {
val extraMailAddresses = params.view.filterKeys(k => k.startsWith("extraMailAddresses"))
if (Some(value) == params.optionValue("mailAddress") || extraMailAddresses.count {
case (k, v) =>
v.contains(value)
} > 1) {
if (
params.optionValue("mailAddress").contains(value) || extraMailAddresses.count { case (k, v) =>
v.contains(value)
} > 1
) {
Some("These mail addresses are duplicated.")
} else {
getAccountByMailAddress(value, true)
getAccountByMailAddress(value, includeRemoved = true)
.collect {
case x if paramName.isEmpty || Some(x.userName) != params.optionValue(paramName) =>
case x if paramName.isEmpty || !params.optionValue(paramName).contains(x.userName) =>
"Mail address is already registered."
}
}
}
}
val allReservedNames = Set(
private val allReservedNames = Set(
"git",
"admin",
"upload",
@@ -421,13 +489,12 @@ trait AccountManagementControllerBase extends ControllerBase {
"new"
)
protected def reservedNames(): Constraint = new Constraint() {
protected def reservedNames: Constraint = new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] =
if (allReservedNames.contains(value.toLowerCase)) {
Some(s"${value} is reserved")
Some(s"$value is reserved")
} else {
None
}
}
}

View File

@@ -1,10 +1,12 @@
package gitbucket.core.controller
import gitbucket.core.dashboard.html
import gitbucket.core.service._
import gitbucket.core.util.{Keys, UsersAuthenticator}
import gitbucket.core.util.Implicits._
import gitbucket.core.service.IssuesService._
import gitbucket.core.model.Account
import gitbucket.core.service.*
import gitbucket.core.util.UsersAuthenticator
import gitbucket.core.util.Implicits.*
import gitbucket.core.service.IssuesService.*
import gitbucket.core.service.ActivityService.*
class DashboardController
extends DashboardControllerBase
@@ -21,54 +23,75 @@ class DashboardController
with WebHookPullRequestService
with WebHookPullRequestReviewCommentService
with MilestonesService
with CommitStatusService
with UsersAuthenticator
with RequestCache
trait DashboardControllerBase extends ControllerBase {
self: IssuesService with PullRequestService with RepositoryService with AccountService with UsersAuthenticator =>
self: IssuesService & PullRequestService & RepositoryService & AccountService & CommitStatusService &
UsersAuthenticator =>
get("/dashboard/repos")(usersOnly {
val repos = getVisibleRepositories(
context.loginAccount,
None,
withoutPhysicalInfo = true,
limit = context.settings.limitVisibleRepositories
)
html.repos(getGroupNames(context.loginAccount.get.userName), repos, repos)
context.withLoginAccount { loginAccount =>
val repos = getVisibleRepositories(
context.loginAccount,
None,
withoutPhysicalInfo = true,
limit = context.settings.basicBehavior.limitVisibleRepositories
)
html.repos(getGroupNames(loginAccount.userName), repos, repos, isNewsFeedEnabled)
}
})
get("/dashboard/issues")(usersOnly {
searchIssues("created_by")
context.withLoginAccount { loginAccount =>
searchIssues(loginAccount, "created_by")
}
})
get("/dashboard/issues/assigned")(usersOnly {
searchIssues("assigned")
context.withLoginAccount { loginAccount =>
searchIssues(loginAccount, "assigned")
}
})
get("/dashboard/issues/created_by")(usersOnly {
searchIssues("created_by")
context.withLoginAccount { loginAccount =>
searchIssues(loginAccount, "created_by")
}
})
get("/dashboard/issues/mentioned")(usersOnly {
searchIssues("mentioned")
context.withLoginAccount { loginAccount =>
searchIssues(loginAccount, "mentioned")
}
})
get("/dashboard/pulls")(usersOnly {
searchPullRequests("created_by")
context.withLoginAccount { loginAccount =>
searchPullRequests(loginAccount, "created_by")
}
})
get("/dashboard/pulls/created_by")(usersOnly {
searchPullRequests("created_by")
context.withLoginAccount { loginAccount =>
searchPullRequests(loginAccount, "created_by")
}
})
get("/dashboard/pulls/assigned")(usersOnly {
searchPullRequests("assigned")
context.withLoginAccount { loginAccount =>
searchPullRequests(loginAccount, "assigned")
}
})
get("/dashboard/pulls/mentioned")(usersOnly {
searchPullRequests("mentioned")
context.withLoginAccount { loginAccount =>
searchPullRequests(loginAccount, "mentioned")
}
})
private def getOrCreateCondition(key: String, filter: String, userName: String) = {
private def getOrCreateCondition(filter: String, userName: String) = {
val condition = IssueSearchCondition(request)
filter match {
@@ -78,19 +101,20 @@ trait DashboardControllerBase extends ControllerBase {
}
}
private def searchIssues(filter: String) = {
import IssuesService._
private def searchIssues(loginAccount: Account, filter: String) = {
import IssuesService.*
val userName = context.loginAccount.get.userName
val condition = getOrCreateCondition(Keys.Session.DashboardIssues, filter, userName)
val userRepos = getUserRepositories(userName, true).map(repo => repo.owner -> repo.name)
val userName = loginAccount.userName
val condition = getOrCreateCondition(filter, userName)
val userRepos = getUserRepositories(userName, withoutPhysicalInfo = true).map(repo => repo.owner -> repo.name)
val page = IssueSearchCondition.page(request)
val issues = searchIssue(condition, IssueSearchOption.Issues, (page - 1) * IssueLimit, IssueLimit, userRepos*)
html.issues(
searchIssue(condition, false, (page - 1) * IssueLimit, IssueLimit, userRepos: _*),
issues.map(issue => (issue, None)),
page,
countIssue(condition.copy(state = "open"), false, userRepos: _*),
countIssue(condition.copy(state = "closed"), false, userRepos: _*),
countIssue(condition.copy(state = "open"), IssueSearchOption.Issues, userRepos*),
countIssue(condition.copy(state = "closed"), IssueSearchOption.Issues, userRepos*),
filter match {
case "assigned" => condition.copy(assigned = Some(Some(userName)))
case "mentioned" => condition.copy(mentioned = Some(userName))
@@ -102,25 +126,38 @@ trait DashboardControllerBase extends ControllerBase {
context.loginAccount,
None,
withoutPhysicalInfo = true,
limit = context.settings.limitVisibleRepositories
)
limit = context.settings.basicBehavior.limitVisibleRepositories
),
isNewsFeedEnabled
)
}
private def searchPullRequests(filter: String) = {
import IssuesService._
import PullRequestService._
private def searchPullRequests(loginAccount: Account, filter: String) = {
import IssuesService.*
import PullRequestService.*
val userName = context.loginAccount.get.userName
val condition = getOrCreateCondition(Keys.Session.DashboardPulls, filter, userName)
val userName = loginAccount.userName
val condition = getOrCreateCondition(filter, userName)
val allRepos = getAllRepositories(userName)
val page = IssueSearchCondition.page(request)
val issues = searchIssue(
condition,
IssueSearchOption.PullRequests,
(page - 1) * PullRequestLimit,
PullRequestLimit,
allRepos*
)
val status = issues.map { issue =>
issue.commitId.flatMap { commitId =>
getCommitStatusWithSummary(issue.issue.userName, issue.issue.repositoryName, commitId)
}
}
html.pulls(
searchIssue(condition, true, (page - 1) * PullRequestLimit, PullRequestLimit, allRepos: _*),
issues.zip(status),
page,
countIssue(condition.copy(state = "open"), true, allRepos: _*),
countIssue(condition.copy(state = "closed"), true, allRepos: _*),
countIssue(condition.copy(state = "open"), IssueSearchOption.PullRequests, allRepos*),
countIssue(condition.copy(state = "closed"), IssueSearchOption.PullRequests, allRepos*),
filter match {
case "assigned" => condition.copy(assigned = Some(Some(userName)))
case "mentioned" => condition.copy(mentioned = Some(userName))
@@ -132,8 +169,9 @@ trait DashboardControllerBase extends ControllerBase {
context.loginAccount,
None,
withoutPhysicalInfo = true,
limit = context.settings.limitVisibleRepositories
)
limit = context.settings.basicBehavior.limitVisibleRepositories
),
isNewsFeedEnabled
)
}

View File

@@ -6,7 +6,6 @@ import gitbucket.core.model.Account
import gitbucket.core.service.{AccountService, ReleaseService, RepositoryService}
import gitbucket.core.servlet.Database
import gitbucket.core.util._
import gitbucket.core.util.SyntaxSugars._
import gitbucket.core.util.Directory._
import gitbucket.core.util.Implicits._
import org.eclipse.jgit.api.Git
@@ -18,6 +17,7 @@ import org.apache.commons.io.{FileUtils, IOUtils}
import scala.util.Using
import gitbucket.core.service.SystemSettingsService
import slick.jdbc.JdbcBackend.Session
/**
* Provides Ajax based file upload functionality.
@@ -37,10 +37,10 @@ class FileUploadController
execute(
{ (file, fileId) =>
FileUtils
.writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get)
.writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get())
session += Keys.Session.Upload(fileId) -> file.name
},
FileUtil.isImage
FileUtil.isImage(_)
)
}
@@ -49,7 +49,7 @@ class FileUploadController
execute(
{ (file, fileId) =>
FileUtils
.writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get)
.writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get())
session += Keys.Session.Upload(fileId) -> file.name
},
_ => true
@@ -65,7 +65,7 @@ class FileUploadController
getAttachedDir(params("owner"), params("repository")),
FileUtil.checkFilename(fileId + "." + FileUtil.getExtension(file.getName))
),
file.get
file.get()
)
},
_ => true
@@ -75,92 +75,92 @@ class FileUploadController
post("/wiki/:owner/:repository") {
setMultipartConfig()
// Don't accept not logged-in users
session.get(Keys.Session.LoginAccount).collect {
case loginAccount: Account =>
val owner = params("owner")
val repository = params("repository")
session.get(Keys.Session.LoginAccount).collect { case loginAccount: Account =>
val owner = params("owner")
val repository = params("repository")
// Check whether logged-in user is collaborator
onlyWikiEditable(owner, repository, loginAccount) {
execute(
{ (file, fileId) =>
val fileName = file.getName
LockUtil.lock(s"${owner}/${repository}/wiki") {
Using.resource(Git.open(Directory.getWikiRepositoryDir(owner, repository))) {
git =>
val builder = DirCache.newInCore.builder()
val inserter = git.getRepository.newObjectInserter()
val headId = git.getRepository.resolve(Constants.HEAD + "^{commit}")
// Check whether logged-in user is collaborator
onlyWikiEditable(owner, repository, loginAccount) {
execute(
{ (file, fileId) =>
val fileName = file.getName
LockUtil.lock(s"$owner/$repository/wiki") {
Using.resource(Git.open(Directory.getWikiRepositoryDir(owner, repository))) { git =>
val builder = DirCache.newInCore.builder()
val inserter = git.getRepository.newObjectInserter()
val headId = git.getRepository.resolve(Constants.HEAD + "^{commit}")
if (headId != null) {
JGitUtil.processTree(git, headId) { (path, tree) =>
if (path != fileName) {
builder.add(JGitUtil.createDirCacheEntry(path, tree.getEntryFileMode, tree.getEntryObjectId))
}
}
if (headId != null) {
JGitUtil.processTree(git, headId) { (path, tree) =>
if (path != fileName) {
builder.add(JGitUtil.createDirCacheEntry(path, tree.getEntryFileMode, tree.getEntryObjectId))
}
val bytes = IOUtils.toByteArray(file.getInputStream)
builder.add(
JGitUtil.createDirCacheEntry(
fileName,
FileMode.REGULAR_FILE,
inserter.insert(Constants.OBJ_BLOB, bytes)
)
)
builder.finish()
val newHeadId = JGitUtil.createNewCommit(
git,
inserter,
headId,
builder.getDirCache.writeTree(inserter),
Constants.HEAD,
loginAccount.fullName,
loginAccount.mailAddress,
s"Uploaded ${fileName}"
)
fileName
}
}
val bytes = IOUtils.toByteArray(file.getInputStream)
builder.add(
JGitUtil.createDirCacheEntry(
fileName,
FileMode.REGULAR_FILE,
inserter.insert(Constants.OBJ_BLOB, bytes)
)
)
builder.finish()
JGitUtil.createNewCommit(
git,
inserter,
headId,
builder.getDirCache.writeTree(inserter),
Constants.HEAD,
loginAccount.fullName,
loginAccount.mailAddress,
s"Uploaded $fileName"
)
fileName
}
},
_ => true
)
}
}
},
_ => true
)
}
} getOrElse BadRequest()
}
post("/release/:owner/:repository/:tag") {
post("/release/:owner/:repository/*") {
setMultipartConfigForLargeFile()
session
.get(Keys.Session.LoginAccount)
.collect {
case _: Account =>
val owner = params("owner")
val repository = params("repository")
val tag = params("tag")
execute(
{ (file, fileId) =>
FileUtils.writeByteArrayToFile(
new File(getReleaseFilesDir(owner, repository), FileUtil.checkFilename(tag + "/" + fileId)),
file.get
)
},
_ => true
)
.collect { case _: Account =>
val owner = params("owner")
val repository = params("repository")
val tag = multiParams("splat").head
execute(
{ (file, fileId) =>
FileUtils.writeByteArrayToFile(
new File(getReleaseFilesDir(owner, repository), FileUtil.checkFilename(tag + "/" + fileId)),
file.get()
)
},
_ => true
)
}
.getOrElse(BadRequest())
}
post("/import") {
import JDBCUtil._
import JDBCUtil.*
setMultipartConfig()
session.get(Keys.Session.LoginAccount).collect {
case loginAccount: Account if loginAccount.isAdmin =>
execute({ (file, fileId) =>
request2Session(request).conn.importAsSQL(file.getInputStream)
}, _ => true)
execute(
{ (file, fileId) =>
request2Session(request).conn.importAsSQL(file.getInputStream)
},
_ => true
)
}
redirect("/admin/data")
}
@@ -168,17 +168,17 @@ class FileUploadController
private def setMultipartConfig(): Unit = {
val settings = loadSystemSettings()
val config = MultipartConfig(maxFileSize = Some(settings.upload.maxFileSize))
config.apply(request.getServletContext())
config.apply(request.getServletContext)
}
private def setMultipartConfigForLargeFile(): Unit = {
val settings = loadSystemSettings()
val config = MultipartConfig(maxFileSize = Some(settings.upload.largeMaxFileSize))
config.apply(request.getServletContext())
config.apply(request.getServletContext)
}
private def onlyWikiEditable(owner: String, repository: String, loginAccount: Account)(action: => Any): Any = {
implicit val session = Database.getSession(request)
implicit val session: Session = Database.getSession(request)
getRepository(owner, repository) match {
case Some(x) =>
x.repository.options.wikiOption match {
@@ -191,14 +191,13 @@ class FileUploadController
}
}
private def execute(f: (FileItem, String) => Unit, mimeTypeChcker: (String) => Boolean) =
private def execute(f: (FileItem, String) => Unit, mimeTypeChecker: String => Boolean) =
fileParams.get("file") match {
case Some(file) if (mimeTypeChcker(file.name)) =>
defining(FileUtil.generateFileId) { fileId =>
f(file, fileId)
contentType = "text/plain"
Ok(fileId)
}
case Some(file) if mimeTypeChecker(file.name) =>
val fileId = FileUtil.generateFileId
f(file, fileId)
contentType = "text/plain"
Ok(fileId)
case _ => BadRequest()
}

View File

@@ -1,18 +1,20 @@
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.openid.connect.sdk.Nonce
import gitbucket.core.helper.xml
import gitbucket.core.model.Account
import gitbucket.core.service._
import gitbucket.core.util.Implicits._
import gitbucket.core.util.SyntaxSugars._
import gitbucket.core.util._
import gitbucket.core.view.helpers._
import gitbucket.core.service.*
import gitbucket.core.util.Implicits.*
import gitbucket.core.util.*
import gitbucket.core.view.helpers.*
import org.scalatra.Ok
import org.scalatra.forms._
import org.scalatra.forms.*
import gitbucket.core.service.ActivityService.*
class IndexController
extends IndexControllerBase
@@ -29,21 +31,15 @@ class IndexController
with AccessTokenService
with AccountFederationService
with OpenIDConnectService
with RequestCache
trait IndexControllerBase extends ControllerBase {
self: RepositoryService
with ActivityService
with AccountService
with RepositorySearchService
with UsersAuthenticator
with ReferrerAuthenticator
with AccessTokenService
with AccountFederationService
with OpenIDConnectService =>
self: RepositoryService & ActivityService & AccountService & RepositorySearchService & UsersAuthenticator &
ReferrerAuthenticator & AccessTokenService & AccountFederationService & OpenIDConnectService =>
case class SignInForm(userName: String, password: String, hash: Option[String])
private case class SignInForm(userName: String, password: String, hash: Option[String])
val signinForm = mapping(
private val signinForm = mapping(
"userName" -> trim(label("Username", text(required))),
"password" -> trim(label("Password", text(required))),
"hash" -> trim(optional(text()))
@@ -57,38 +53,53 @@ trait IndexControllerBase extends ControllerBase {
//
// case class SearchForm(query: String, owner: String, repository: String)
case class OidcContext(state: State, nonce: Nonce, redirectBackURI: String)
private case class OidcAuthContext(state: State, nonce: Nonce, redirectBackURI: String)
private case class OidcSessionContext(token: JWT)
get("/") {
context.loginAccount
.map { account =>
val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName)
gitbucket.core.html.index(
getRecentActivitiesByOwners(visibleOwnerSet),
getVisibleRepositories(
// val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName)
if (!isNewsFeedEnabled) {
redirect("/dashboard/repos")
} else {
val repos = getVisibleRepositories(
Some(account),
None,
withoutPhysicalInfo = true,
limit = context.settings.limitVisibleRepositories
),
showBannerToCreatePersonalAccessToken = hasAccountFederation(account.userName) && !hasAccessToken(
account.userName
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(
account.userName
),
enableNewsFeed = isNewsFeedEnabled
)
}
}
.getOrElse {
gitbucket.core.html.index(
getRecentActivities(),
getVisibleRepositories(None, withoutPhysicalInfo = true),
showBannerToCreatePersonalAccessToken = false
activities = getRecentPublicActivities(),
recentRepositories = getVisibleRepositories(None, withoutPhysicalInfo = true),
showBannerToCreatePersonalAccessToken = false,
enableNewsFeed = isNewsFeedEnabled
)
}
}
get("/signin") {
val redirect = params.get("redirect")
if (redirect.isDefined && redirect.get.startsWith("/")) {
flash.update(Keys.Flash.Redirect, redirect.get)
if (context.loginAccount.nonEmpty) {
redirect("/")
}
params.get("redirect").foreach { redirect =>
if (redirect.startsWith("/")) {
flash.update(Keys.Flash.Redirect, redirect)
}
}
gitbucket.core.html.signin(flash.get("userName"), flash.get("password"), flash.get("error"))
}
@@ -120,8 +131,8 @@ trait IndexControllerBase extends ControllerBase {
case _ => "/"
}
session.setAttribute(
Keys.Session.OidcContext,
OidcContext(authenticationRequest.getState, authenticationRequest.getNonce, redirectBackURI)
Keys.Session.OidcAuthContext,
OidcAuthContext(authenticationRequest.getState, authenticationRequest.getNonce, redirectBackURI)
)
redirect(authenticationRequest.toURI.toString)
} getOrElse {
@@ -135,9 +146,10 @@ trait IndexControllerBase extends ControllerBase {
get("/signin/oidc") {
context.settings.oidc.map { oidc =>
val redirectURI = new URI(s"$baseUrl/signin/oidc")
session.get(Keys.Session.OidcContext) match {
case Some(context: OidcContext) =>
authenticate(params.toMap, redirectURI, context.state, context.nonce, oidc).map { account =>
session.get(Keys.Session.OidcAuthContext) match {
case Some(context: OidcAuthContext) =>
authenticate(params.toMap, redirectURI, context.state, context.nonce, oidc).map { case (jwt, account) =>
session.setAttribute(Keys.Session.OidcSessionContext, OidcSessionContext(jwt))
signin(account, context.redirectBackURI)
} orElse {
flash.update("error", "Sorry, authentication failed. Please try again.")
@@ -155,13 +167,24 @@ trait IndexControllerBase extends ControllerBase {
}
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("/")
}
get("/activities.atom") {
contentType = "application/atom+xml; type=feed"
xml.feed(getRecentActivities())
xml.feed(getRecentPublicActivities())
}
post("/sidebar-collapse") {
@@ -173,11 +196,24 @@ trait IndexControllerBase extends ControllerBase {
Ok()
}
get("/user.css") {
context.settings.userDefinedCss match {
case Some(css) =>
contentType = "text/css"
css
case None =>
NotFound()
}
}
/**
* Set account information into HttpSession and redirect.
*/
private def signin(account: Account, redirectUrl: String = "/") = {
session.setAttribute(Keys.Session.LoginAccount, account)
if (isDevFeatureEnabled(DevFeatures.KeepSession)) {
saveLoginAccountToLocalFile(account)
}
updateLastLoginDate(account.userName)
if (LDAPUtil.isDummyMailAddress(account)) {
@@ -200,8 +236,8 @@ trait IndexControllerBase extends ControllerBase {
val group = params("group").toBoolean
org.json4s.jackson.Serialization.write(
Map(
"options" -> (
getAllUsers(false)
"options" ->
getAllUsers(includeRemoved = false)
.withFilter { t =>
(user, group) match {
case (true, true) => true
@@ -212,72 +248,84 @@ trait IndexControllerBase extends ControllerBase {
}
.map { t =>
Map(
"label" -> s"${avatar(t.userName, 16)}<b>@${StringUtil.escapeHtml(t.userName)}</b> ${StringUtil
.escapeHtml(t.fullName)}",
"label" -> s"${avatar(t.userName, 16)}<b>@${StringUtil.escapeHtml(
StringUtil.cutTail(t.userName, 25, "...")
)}</b> ${StringUtil
.escapeHtml(StringUtil.cutTail(t.fullName, 25, "..."))}",
"value" -> t.userName
)
}
)
)
)
})
/**
* JSON API for checking user or group existence.
*
* Returns a single string which is any of "group", "user" or "".
* Additionally, check whether the user is writable to the repository
* if "owner" and "repository" are given,
*/
post("/_user/existence")(usersOnly {
getAccountByUserNameIgnoreCase(params("userName")).map { account =>
if (account.isGroupAccount) "group" else "user"
if (!account.isGroupAccount && params.get("repository").isDefined && params.get("owner").isDefined) {
getRepository(params("owner"), params("repository"))
.collect {
case repository if isWritable(repository.repository, Some(account)) => "user"
}
.getOrElse("")
} else {
if (account.isGroupAccount) "group" else "user"
}
} getOrElse ""
})
// TODO Move to RepositoryViewrController?
// TODO Move to RepositoryViewerController?
get("/:owner/:repository/search")(referrersOnly { repository =>
defining(params.getOrElse("q", "").trim, params.getOrElse("type", "code")) {
case (query, target) =>
val page = try {
val i = params.getOrElse("page", "1").toInt
if (i <= 0) 1 else i
} catch {
case e: NumberFormatException => 1
}
val query = params.getOrElse("q", "").trim
val target = params.getOrElse("type", "code")
val page =
try {
val i = params.getOrElse("page", "1").toInt
if (i <= 0) 1 else i
} catch {
case _: NumberFormatException => 1
}
target.toLowerCase match {
case "issues" =>
gitbucket.core.search.html.issues(
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, false) else Nil,
false,
query,
page,
repository
)
target.toLowerCase match {
case "issues" =>
gitbucket.core.search.html.issues(
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, pullRequest = false) else Nil,
pullRequest = false,
query,
page,
repository
)
case "pulls" =>
gitbucket.core.search.html.issues(
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, true) else Nil,
true,
query,
page,
repository
)
case "pulls" =>
gitbucket.core.search.html.issues(
if (query.nonEmpty) searchIssues(repository.owner, repository.name, query, pullRequest = true) else Nil,
pullRequest = true,
query,
page,
repository
)
case "wiki" =>
gitbucket.core.search.html.wiki(
if (query.nonEmpty) searchWikiPages(repository.owner, repository.name, query) else Nil,
query,
page,
repository
)
case "wiki" =>
gitbucket.core.search.html.wiki(
if (query.nonEmpty) searchWikiPages(repository.owner, repository.name, query) else Nil,
query,
page,
repository
)
case _ =>
gitbucket.core.search.html.code(
if (query.nonEmpty) searchFiles(repository.owner, repository.name, query) else Nil,
query,
page,
repository
)
}
case _ =>
gitbucket.core.search.html.code(
if (query.nonEmpty) searchFiles(repository.owner, repository.name, query) else Nil,
query,
page,
repository
)
}
})
@@ -288,19 +336,19 @@ trait IndexControllerBase extends ControllerBase {
context.loginAccount,
None,
withoutPhysicalInfo = true,
limit = context.settings.limitVisibleRepositories
limit = context.settings.basicBehavior.limitVisibleRepositories
)
val repositories = {
context.settings.limitVisibleRepositories match {
case true =>
getVisibleRepositories(
context.loginAccount,
None,
withoutPhysicalInfo = true,
limit = false
)
case false => visibleRepositories
if (context.settings.basicBehavior.limitVisibleRepositories) {
getVisibleRepositories(
context.loginAccount,
None,
withoutPhysicalInfo = true,
limit = false
)
} else {
visibleRepositories
}
}.filter { repository =>
repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0

View File

@@ -1,14 +1,14 @@
package gitbucket.core.controller
import gitbucket.core.issues.html
import gitbucket.core.service.IssuesService._
import gitbucket.core.service._
import gitbucket.core.util.SyntaxSugars._
import gitbucket.core.util.Implicits._
import gitbucket.core.util._
import gitbucket.core.model.{Account, CustomFieldBehavior}
import gitbucket.core.service.IssuesService.*
import gitbucket.core.service.*
import gitbucket.core.util.Implicits.*
import gitbucket.core.util.*
import gitbucket.core.view
import gitbucket.core.view.Markdown
import org.scalatra.forms._
import org.scalatra.forms.*
import org.scalatra.{BadRequest, Ok}
class IssuesController
@@ -21,6 +21,7 @@ class IssuesController
with ActivityService
with HandleCommentService
with IssueCreationService
with CustomFieldsService
with ReadableUsersAuthenticator
with ReferrerAuthenticator
with WritableUsersAuthenticator
@@ -30,224 +31,242 @@ class IssuesController
with WebHookPullRequestReviewCommentService
with CommitsService
with PrioritiesService
with RequestCache
trait IssuesControllerBase extends ControllerBase {
self: IssuesService
with RepositoryService
with AccountService
with LabelsService
with MilestonesService
with ActivityService
with HandleCommentService
with IssueCreationService
with ReadableUsersAuthenticator
with ReferrerAuthenticator
with WritableUsersAuthenticator
with PullRequestService
with WebHookIssueCommentService
with PrioritiesService =>
self: IssuesService & RepositoryService & AccountService & LabelsService & MilestonesService & ActivityService &
HandleCommentService & IssueCreationService & CustomFieldsService & ReadableUsersAuthenticator &
ReferrerAuthenticator & WritableUsersAuthenticator & PullRequestService & WebHookIssueCommentService &
PrioritiesService =>
case class IssueCreateForm(
private case class IssueCreateForm(
title: String,
content: Option[String],
assignedUserName: Option[String],
assigneeUserNames: Option[String],
milestoneId: Option[Int],
priorityId: Option[Int],
labelNames: Option[String]
)
case class CommentForm(issueId: Int, content: String)
case class IssueStateForm(issueId: Int, content: Option[String])
private case class CommentForm(issueId: Int, content: String)
private case class IssueStateForm(issueId: Int, content: Option[String])
val issueCreateForm = mapping(
private val issueCreateForm = mapping(
"title" -> trim(label("Title", text(required))),
"content" -> trim(optional(text())),
"assignedUserName" -> trim(optional(text())),
"assigneeUserNames" -> trim(optional(text())),
"milestoneId" -> trim(optional(number())),
"priorityId" -> trim(optional(number())),
"labelNames" -> trim(optional(text()))
)(IssueCreateForm.apply)
val issueTitleEditForm = mapping(
private val issueTitleEditForm = mapping(
"title" -> trim(label("Title", text(required)))
)(x => x)
val issueEditForm = mapping(
private val issueEditForm = mapping(
"content" -> trim(optional(text()))
)(x => x)
val commentForm = mapping(
private val commentForm = mapping(
"issueId" -> label("Issue Id", number()),
"content" -> trim(label("Comment", text(required)))
)(CommentForm.apply)
val issueStateForm = mapping(
private val issueStateForm = mapping(
"issueId" -> label("Issue Id", number()),
"content" -> trim(optional(text()))
)(IssueStateForm.apply)
get("/:owner/:repository/issues")(referrersOnly { repository =>
val q = request.getParameter("q")
if (Option(q).exists(_.contains("is:pr"))) {
redirect(s"/${repository.owner}/${repository.name}/pulls?q=${StringUtil.urlEncode(q)}")
} else {
searchIssues(repository)
Option(q) match {
case Some(filter) if filter.contains("is:pr") =>
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 {
searchIssues(repository, condition, IssueSearchCondition.page(request))
}
case None =>
searchIssues(repository, IssueSearchCondition(request), IssueSearchCondition.page(request))
}
})
get("/:owner/:repository/issues/:id")(referrersOnly { repository =>
defining(repository.owner, repository.name, params("id")) {
case (owner, name, issueId) =>
getIssue(owner, name, issueId) map {
issue =>
if (issue.isPullRequest) {
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
} else {
html.issue(
issue,
getComments(owner, name, issueId.toInt),
getIssueLabels(owner, name, issueId.toInt),
getAssignableUserNames(owner, name),
getMilestonesWithIssueCount(owner, name),
getPriorities(owner, name),
getLabels(owner, name),
isIssueEditable(repository),
isIssueManageable(repository),
repository
)
}
} getOrElse NotFound()
}
val issueId = params("id")
getIssue(repository.owner, repository.name, issueId) map { issue =>
if (issue.isPullRequest) {
redirect(s"/${repository.owner}/${repository.name}/pull/$issueId")
} else {
html.issue(
issue,
getComments(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),
getMilestonesWithIssueCount(repository.owner, repository.name),
getPriorities(repository.owner, repository.name),
getLabels(repository.owner, repository.name),
getCustomFieldsWithValue(repository.owner, repository.name, issueId.toInt).filter(_._1.enableForIssues),
isIssueEditable(repository),
isIssueManageable(repository),
isIssueCommentManageable(repository),
repository
)
}
} getOrElse NotFound()
})
get("/:owner/:repository/issues/new")(readableUsersOnly { repository =>
if (isIssueEditable(repository)) { // TODO Should this check is provided by authenticator?
defining(repository.owner, repository.name) {
case (owner, name) =>
html.create(
getAssignableUserNames(owner, name),
getMilestones(owner, name),
getPriorities(owner, name),
getDefaultPriority(owner, name),
getLabels(owner, name),
isIssueManageable(repository),
getContentTemplate(repository, "ISSUE_TEMPLATE"),
repository
)
}
html.create(
getAssignableUserNames(repository.owner, repository.name),
getMilestones(repository.owner, repository.name),
getPriorities(repository.owner, repository.name),
getDefaultPriority(repository.owner, repository.name),
getLabels(repository.owner, repository.name),
getCustomFields(repository.owner, repository.name).filter(_.enableForIssues),
isIssueManageable(repository),
getContentTemplate(repository, "ISSUE_TEMPLATE"),
repository
)
} else Unauthorized()
})
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
if (isIssueEditable(repository)) { // TODO Should this check is provided by authenticator?
val issue = createIssue(
repository,
form.title,
form.content,
form.assignedUserName,
form.milestoneId,
form.priorityId,
form.labelNames.toSeq.flatMap(_.split(",")),
context.loginAccount.get
)
context.withLoginAccount { loginAccount =>
if (isIssueEditable(repository)) { // TODO Should this check is provided by authenticator?
val issue = createIssue(
repository,
form.title,
form.content,
form.assigneeUserNames.toSeq.flatMap(_.split(",")),
form.milestoneId,
form.priorityId,
form.labelNames.toSeq.flatMap(_.split(",")),
loginAccount
)
redirect(s"/${issue.userName}/${issue.repositoryName}/issues/${issue.issueId}")
} else Unauthorized()
// 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}")
} else Unauthorized()
}
})
ajaxPost("/:owner/:repository/issues/edit_title/:id", issueTitleEditForm)(readableUsersOnly { (title, repository) =>
defining(repository.owner, repository.name) {
case (owner, name) =>
getIssue(owner, name, params("id")).map {
issue =>
if (isEditableContent(owner, name, issue.openedUserName)) {
if (issue.title != title) {
// update issue
updateIssue(owner, name, issue.issueId, title, issue.content)
// extract references and create refer comment
createReferComment(owner, name, issue.copy(title = title), title, context.loginAccount.get)
createComment(
owner,
name,
context.loginAccount.get.userName,
issue.issueId,
issue.title + "\r\n" + title,
"change_title"
)
}
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
} else Unauthorized()
} getOrElse NotFound()
context.withLoginAccount { loginAccount =>
getIssue(repository.owner, repository.name, params("id")).map { issue =>
if (isEditableContent(repository.owner, repository.name, issue.openedUserName, loginAccount)) {
if (issue.title != title) {
// update issue
updateIssue(repository.owner, repository.name, issue.issueId, title, issue.content)
// extract references and create refer comment
createReferComment(repository.owner, repository.name, issue.copy(title = title), title, loginAccount)
createComment(
repository.owner,
repository.name,
loginAccount.userName,
issue.issueId,
issue.title + "\r\n" + title,
"change_title"
)
}
redirect(s"/${repository.owner}/${repository.name}/issues/_data/${issue.issueId}")
} else Unauthorized()
} getOrElse NotFound()
}
})
ajaxPost("/:owner/:repository/issues/edit/:id", issueEditForm)(readableUsersOnly { (content, repository) =>
defining(repository.owner, repository.name) {
case (owner, name) =>
getIssue(owner, name, params("id")).map { issue =>
if (isEditableContent(owner, name, issue.openedUserName)) {
// update issue
updateIssue(owner, name, issue.issueId, issue.title, content)
// extract references and create refer comment
createReferComment(owner, name, issue, content.getOrElse(""), context.loginAccount.get)
context.withLoginAccount { loginAccount =>
getIssue(repository.owner, repository.name, params("id")).map { issue =>
if (isEditableContent(repository.owner, repository.name, issue.openedUserName, loginAccount)) {
// update issue
updateIssue(repository.owner, repository.name, issue.issueId, issue.title, content)
// extract references and create refer comment
createReferComment(repository.owner, repository.name, issue, content.getOrElse(""), loginAccount)
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
} else Unauthorized()
} getOrElse NotFound()
redirect(s"/${repository.owner}/${repository.name}/issues/_data/${issue.issueId}")
} else Unauthorized()
} getOrElse NotFound()
}
})
post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) =>
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
val actionOpt =
params.get("action").filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName))
handleComment(issue, Some(form.content), repository, actionOpt) map {
case (issue, id) =>
context.withLoginAccount { loginAccount =>
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
val actionOpt =
params
.get("action")
.filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName, loginAccount))
handleComment(issue, Some(form.content), repository, actionOpt) map { case (issue, id) =>
redirect(
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}"
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-$id"
)
}
} getOrElse NotFound()
}
} getOrElse NotFound()
}
})
post("/:owner/:repository/issue_comments/state", issueStateForm)(readableUsersOnly { (form, repository) =>
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
val actionOpt =
params.get("action").filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName))
handleComment(issue, form.content, repository, actionOpt) map {
case (issue, id) =>
context.withLoginAccount { loginAccount =>
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
val actionOpt =
params
.get("action")
.filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName, loginAccount))
handleComment(issue, form.content, repository, actionOpt) map { case (issue, id) =>
redirect(
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}"
s"/${repository.owner}/${repository.name}/${if (issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-$id"
)
}
} getOrElse NotFound()
}
} getOrElse NotFound()
}
})
ajaxPost("/:owner/:repository/issue_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
defining(repository.owner, repository.name) {
case (owner, name) =>
getComment(owner, name, params("id")).map { comment =>
if (isEditableContent(owner, name, comment.commentedUserName)) {
updateComment(comment.issueId, comment.commentId, form.content)
redirect(s"/${owner}/${name}/issue_comments/_data/${comment.commentId}")
} else Unauthorized()
} getOrElse NotFound()
context.withLoginAccount { loginAccount =>
getComment(repository.owner, repository.name, params("id")).map { comment =>
if (isEditableContent(repository.owner, repository.name, comment.commentedUserName, loginAccount)) {
updateComment(repository.owner, repository.name, comment.issueId, comment.commentId, form.content)
redirect(s"/${repository.owner}/${repository.name}/issue_comments/_data/${comment.commentId}")
} else Unauthorized()
} getOrElse NotFound()
}
})
ajaxPost("/:owner/:repository/issue_comments/delete/:id")(readableUsersOnly { repository =>
defining(repository.owner, repository.name) {
case (owner, name) =>
getComment(owner, name, params("id")).map { comment =>
if (isEditableContent(owner, name, comment.commentedUserName)) {
Ok(deleteComment(comment.issueId, comment.commentId))
} else Unauthorized()
} getOrElse NotFound()
context.withLoginAccount { loginAccount =>
getComment(repository.owner, repository.name, params("id")).map { comment =>
if (isDeletableComment(repository.owner, repository.name, comment.commentedUserName, loginAccount)) {
Ok(deleteComment(repository.owner, repository.name, comment.issueId, comment.commentId))
} else Unauthorized()
} getOrElse NotFound()
}
})
ajaxGet("/:owner/:repository/issues/_data/:id")(readableUsersOnly { repository =>
getIssue(repository.owner, repository.name, params("id")) map {
x =>
if (isEditableContent(x.userName, x.repositoryName, x.openedUserName)) {
context.withLoginAccount { loginAccount =>
getIssue(repository.owner, repository.name, params("id")) map { x =>
if (isEditableContent(x.userName, x.repositoryName, x.openedUserName, loginAccount)) {
params.get("dataType") collect {
case t if t == "html" => html.editissue(x.content, x.issueId, repository)
} getOrElse {
@@ -270,13 +289,14 @@ trait IssuesControllerBase extends ControllerBase {
)
}
} else Unauthorized()
} getOrElse NotFound()
} getOrElse NotFound()
}
})
ajaxGet("/:owner/:repository/issue_comments/_data/:id")(readableUsersOnly { repository =>
getComment(repository.owner, repository.name, params("id")) map {
x =>
if (isEditableContent(x.userName, x.repositoryName, x.commentedUserName)) {
context.withLoginAccount { loginAccount =>
getComment(repository.owner, repository.name, params("id")) map { x =>
if (isEditableContent(x.userName, x.repositoryName, x.commentedUserName, loginAccount)) {
params.get("dataType") collect {
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
} getOrElse {
@@ -298,7 +318,8 @@ trait IssuesControllerBase extends ControllerBase {
)
}
} else Unauthorized()
} getOrElse NotFound()
} getOrElse NotFound()
}
})
ajaxPost("/:owner/:repository/issues/new/label")(writableUsersOnly { repository =>
@@ -308,66 +329,103 @@ trait IssuesControllerBase extends ControllerBase {
})
ajaxPost("/:owner/:repository/issues/:id/label/new")(writableUsersOnly { repository =>
defining(params("id").toInt) { issueId =>
registerIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt, true)
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
}
val issueId = params("id").toInt
registerIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt, insertComment = true)
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
})
ajaxPost("/:owner/:repository/issues/:id/label/delete")(writableUsersOnly { repository =>
defining(params("id").toInt) { issueId =>
deleteIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt, true)
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
}
val issueId = params("id").toInt
deleteIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt, insertComment = true)
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
})
ajaxPost("/:owner/:repository/issues/:id/assign")(writableUsersOnly { repository =>
updateAssignedUserName(
repository.owner,
repository.name,
params("id").toInt,
assignedUserName("assignedUserName"),
true
)
Ok("updated")
ajaxPost("/:owner/:repository/issues/:id/assignee/new")(writableUsersOnly { repository =>
val issueId = params("id").toInt
registerIssueAssignee(repository.owner, repository.name, issueId, params("assigneeUserName"), insertComment = true)
Ok()
})
ajaxPost("/:owner/:repository/issues/:id/assignee/delete")(writableUsersOnly { repository =>
val issueId = params("id").toInt
deleteIssueAssignee(repository.owner, repository.name, issueId, params("assigneeUserName"), insertComment = true)
Ok()
})
ajaxPost("/:owner/:repository/issues/:id/milestone")(writableUsersOnly { repository =>
updateMilestoneId(repository.owner, repository.name, params("id").toInt, milestoneId("milestoneId"), true)
updateMilestoneId(
repository.owner,
repository.name,
params("id").toInt,
milestoneId("milestoneId"),
insertComment = true
)
milestoneId("milestoneId").map { milestoneId =>
getMilestonesWithIssueCount(repository.owner, repository.name)
.find(_._1.milestoneId == milestoneId)
.map {
case (_, openCount, closeCount) =>
gitbucket.core.issues.milestones.html.progress(openCount + closeCount, closeCount)
.map { case (_, openCount, closeCount) =>
gitbucket.core.issues.milestones.html.progress(openCount + closeCount, closeCount)
} getOrElse NotFound()
} getOrElse Ok()
})
ajaxPost("/:owner/:repository/issues/:id/priority")(writableUsersOnly { repository =>
val priority = priorityId("priorityId")
updatePriorityId(repository.owner, repository.name, params("id").toInt, priority, true)
updatePriorityId(repository.owner, repository.name, params("id").toInt, priority, insertComment = true)
Ok("updated")
})
post("/:owner/:repository/issues/batchedit/state")(writableUsersOnly { repository =>
defining(params.get("value")) {
action =>
action match {
case Some("open") =>
executeBatch(repository) { issueId =>
getIssue(repository.owner, repository.name, issueId.toString).foreach { issue =>
handleComment(issue, None, repository, Some("reopen"))
}
}
case Some("close") =>
executeBatch(repository) { issueId =>
getIssue(repository.owner, repository.name, issueId.toString).foreach { issue =>
handleComment(issue, None, repository, Some("close"))
}
}
case _ => BadRequest()
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 =>
val action = params.get("value")
action match {
case Some("open") =>
executeBatch(repository) { issueId =>
getIssue(repository.owner, repository.name, issueId.toString).foreach { issue =>
handleComment(issue, None, repository, Some("reopen"))
}
}
if (params("uri").nonEmpty) {
redirect(params("uri"))
}
case Some("close") =>
executeBatch(repository) { issueId =>
getIssue(repository.owner, repository.name, issueId.toString).foreach { issue =>
handleComment(issue, None, repository, Some("close"))
}
}
if (params("uri").nonEmpty) {
redirect(params("uri"))
}
case _ => BadRequest()
}
})
@@ -375,39 +433,48 @@ trait IssuesControllerBase extends ControllerBase {
params("value").toIntOpt.map { labelId =>
executeBatch(repository) { issueId =>
getIssueLabel(repository.owner, repository.name, issueId, labelId) getOrElse {
registerIssueLabel(repository.owner, repository.name, issueId, labelId, true)
registerIssueLabel(repository.owner, repository.name, issueId, labelId, insertComment = true)
if (params("uri").nonEmpty) {
redirect(params("uri"))
}
}
}
} getOrElse NotFound()
})
post("/:owner/:repository/issues/batchedit/assign")(writableUsersOnly { repository =>
defining(assignedUserName("value")) { value =>
executeBatch(repository) {
updateAssignedUserName(repository.owner, repository.name, _, value, true)
val value = assignedUserName("value")
executeBatch(repository) {
// updateAssignedUserName(repository.owner, repository.name, _, value, true)
value match {
case Some(assignedUserName) =>
registerIssueAssignee(repository.owner, repository.name, _, assignedUserName, insertComment = true)
case None =>
deleteAllIssueAssignees(repository.owner, repository.name, _, insertComment = true)
}
}
if (params("uri").nonEmpty) {
redirect(params("uri"))
}
})
post("/:owner/:repository/issues/batchedit/milestone")(writableUsersOnly { repository =>
defining(milestoneId("value")) { value =>
executeBatch(repository) {
updateMilestoneId(repository.owner, repository.name, _, value, true)
}
val value = milestoneId("value")
executeBatch(repository) {
updateMilestoneId(repository.owner, repository.name, _, value, insertComment = true)
}
})
post("/:owner/:repository/issues/batchedit/priority")(writableUsersOnly { repository =>
defining(priorityId("value")) { value =>
executeBatch(repository) {
updatePriorityId(repository.owner, repository.name, _, value, true)
}
val value = priorityId("value")
executeBatch(repository) {
updatePriorityId(repository.owner, repository.name, _, value, insertComment = true)
}
})
get("/:owner/:repository/_attached/:file")(referrersOnly { repository =>
(Directory.getAttachedDir(repository.owner, repository.name) match {
case dir if (dir.exists && dir.isDirectory) =>
case dir if dir.exists && dir.isDirectory =>
dir.listFiles.find(_.getName.startsWith(params("file") + ".")).map { file =>
response.setHeader("Content-Disposition", f"""inline; filename=${file.getName}""")
RawData(FileUtil.getSafeMimeType(file.getName), file)
@@ -416,50 +483,84 @@ trait IssuesControllerBase extends ControllerBase {
}) getOrElse NotFound()
})
val assignedUserName = (key: String) => params.get(key) filter (_.trim != "")
val milestoneId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
val priorityId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
/**
* JSON API for issue and PR completion.
*/
ajaxGet("/:owner/:repository/_issue/proposals")(writableUsersOnly { repository =>
contentType = formats("json")
org.json4s.jackson.Serialization.write(
Map(
"options" ->
getOpenIssues(repository.owner, repository.name)
.map { t =>
Map(
"label" -> s"""${if (t.isPullRequest) "<i class='octicon octicon-git-pull-request'></i>"
else "<i class='octicon octicon-issue-opened'></i>"}<b> #${StringUtil
.escapeHtml(t.issueId.toString)} ${StringUtil
.escapeHtml(StringUtil.cutTail(t.title, 50, "..."))}</b>""",
"value" -> t.issueId.toString
)
}
)
)
})
private def executeBatch(repository: RepositoryService.RepositoryInfo)(execute: Int => Unit) = {
private val assignedUserName = (key: String) => params.get(key) filter (_.trim != "")
private val milestoneId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
private val priorityId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
private def executeBatch(repository: RepositoryService.RepositoryInfo)(execute: Int => Unit): Unit = {
params("checked").split(',') map (_.toInt) foreach execute
params("from") match {
case "issues" => redirect(s"/${repository.owner}/${repository.name}/issues")
case "pulls" => redirect(s"/${repository.owner}/${repository.name}/pulls")
case _ =>
}
}
private def searchIssues(repository: RepositoryService.RepositoryInfo) = {
defining(repository.owner, repository.name) {
case (owner, repoName) =>
val page = IssueSearchCondition.page(request)
private def searchIssues(repository: RepositoryService.RepositoryInfo, condition: IssueSearchCondition, page: Int) = {
// search issues
val issues =
searchIssue(
condition,
IssueSearchOption.Issues,
(page - 1) * IssueLimit,
IssueLimit,
repository.owner -> repository.name
)
// retrieve search condition
val condition = IssueSearchCondition(request)
html.list(
"issues",
searchIssue(condition, false, (page - 1) * IssueLimit, IssueLimit, owner -> repoName),
page,
getAssignableUserNames(owner, repoName),
getMilestones(owner, repoName),
getPriorities(owner, repoName),
getLabels(owner, repoName),
countIssue(condition.copy(state = "open"), false, owner -> repoName),
countIssue(condition.copy(state = "closed"), false, owner -> repoName),
condition,
repository,
isIssueEditable(repository),
isIssueManageable(repository)
)
}
html.list(
"issues",
issues.map(issue => (issue, None)),
page,
getAssignableUserNames(repository.owner, repository.name),
getMilestones(repository.owner, repository.name),
getPriorities(repository.owner, repository.name),
getLabels(repository.owner, repository.name),
countIssue(condition.copy(state = "open"), IssueSearchOption.Issues, repository.owner -> repository.name),
countIssue(condition.copy(state = "closed"), IssueSearchOption.Issues, repository.owner -> repository.name),
condition,
repository,
isIssueEditable(repository),
isIssueManageable(repository)
)
}
/**
* Tests whether an issue or a comment is editable by a logged-in user.
*/
private def isEditableContent(owner: String, repository: String, author: String)(
implicit context: Context
private def isEditableContent(owner: String, repository: String, author: String, loginAccount: Account)(implicit
context: Context
): Boolean = {
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
hasDeveloperRole(owner, repository, context.loginAccount) || author == loginAccount.userName
}
/**
* Tests whether an issue comment is deletable by a logged-in user.
*/
private def isDeletableComment(owner: String, repository: String, author: String, loginAccount: Account)(implicit
context: Context
): Boolean = {
hasOwnerRole(owner, repository, context.loginAccount) || author == loginAccount.userName
}
}

View File

@@ -10,9 +10,9 @@ import gitbucket.core.service.{
PrioritiesService
}
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
import gitbucket.core.util.Implicits._
import gitbucket.core.util.SyntaxSugars._
import org.scalatra.forms._
import gitbucket.core.util.Implicits.*
import gitbucket.core.util.SyntaxSugars.*
import org.scalatra.forms.*
import org.scalatra.i18n.Messages
import org.scalatra.Ok
@@ -28,15 +28,11 @@ class LabelsController
with WritableUsersAuthenticator
trait LabelsControllerBase extends ControllerBase {
self: LabelsService
with IssuesService
with RepositoryService
with ReferrerAuthenticator
with WritableUsersAuthenticator =>
self: LabelsService & IssuesService & RepositoryService & ReferrerAuthenticator & WritableUsersAuthenticator =>
case class LabelForm(labelName: String, color: String)
private case class LabelForm(labelName: String, color: String)
val labelForm = mapping(
private val labelForm = mapping(
"labelName" -> trim(label("Label name", text(required, labelName, uniqueLabelName, maxlength(100)))),
"labelColor" -> trim(label("Color", text(required, color)))
)(LabelForm.apply)
@@ -44,7 +40,7 @@ trait LabelsControllerBase extends ControllerBase {
get("/:owner/:repository/issues/labels")(referrersOnly { repository =>
html.list(
getLabels(repository.owner, repository.name),
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
repository,
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
)
@@ -59,7 +55,7 @@ trait LabelsControllerBase extends ControllerBase {
html.label(
getLabel(repository.owner, repository.name, labelId).get,
// TODO futility
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
repository,
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
)
@@ -76,7 +72,7 @@ trait LabelsControllerBase extends ControllerBase {
html.label(
getLabel(repository.owner, repository.name, params("labelId").toInt).get,
// TODO futility
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
repository,
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
)
@@ -93,9 +89,9 @@ trait LabelsControllerBase extends ControllerBase {
private def labelName: Constraint = new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] =
if (value.contains(',')) {
Some(s"${name} contains invalid character.")
Some(s"$name contains invalid character.")
} else if (value.startsWith("_") || value.startsWith("-")) {
Some(s"${name} starts with invalid character.")
Some(s"$name starts with invalid character.")
} else {
None
}

View File

@@ -1,11 +1,19 @@
package gitbucket.core.controller
import gitbucket.core.issues.milestones.html
import gitbucket.core.service.{AccountService, MilestonesService, RepositoryService}
import gitbucket.core.util.Implicits._
import gitbucket.core.service.IssuesService.{IssueLimit, IssueSearchCondition}
import gitbucket.core.service.{
AccountService,
CommitStatusService,
IssueSearchOption,
MilestonesService,
RepositoryService
}
import gitbucket.core.util.Implicits.*
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
import gitbucket.core.util.SyntaxSugars._
import org.scalatra.forms._
import gitbucket.core.util.SyntaxSugars.*
import gitbucket.core.view.helpers.{getAssignableUserNames, getLabels, getPriorities, searchIssue}
import org.scalatra.forms.*
import org.scalatra.i18n.Messages
class MilestonesController
@@ -13,15 +21,17 @@ class MilestonesController
with MilestonesService
with RepositoryService
with AccountService
with CommitStatusService
with ReferrerAuthenticator
with WritableUsersAuthenticator
trait MilestonesControllerBase extends ControllerBase {
self: MilestonesService with RepositoryService with ReferrerAuthenticator with WritableUsersAuthenticator =>
self: MilestonesService & RepositoryService & CommitStatusService & ReferrerAuthenticator &
WritableUsersAuthenticator =>
case class MilestoneForm(title: String, description: Option[String], dueDate: Option[java.util.Date])
private case class MilestoneForm(title: String, description: Option[String], dueDate: Option[java.util.Date])
val milestoneForm = mapping(
private val milestoneForm = mapping(
"title" -> trim(label("Title", text(required, maxlength(100), uniqueMilestone))),
"description" -> trim(label("Description", optional(text()))),
"dueDate" -> trim(label("Due Date", optional(date())))
@@ -36,6 +46,41 @@ trait MilestonesControllerBase extends ControllerBase {
)
})
get("/:owner/:repository/milestone/:id")(referrersOnly { repository =>
val milestone = getMilestone(repository.owner, repository.name, params("id").toInt)
val page = IssueSearchCondition.page(request)
val condition = IssueSearchCondition(
request,
milestone.get.title
)
val issues = searchIssue(
condition,
IssueSearchOption.Both,
(page - 1) * IssueLimit,
IssueLimit,
repository.owner -> repository.name
)
val status = issues.map { issue =>
issue.commitId.flatMap { commitId =>
getCommitStatusWithSummary(issue.issue.userName, issue.issue.repositoryName, commitId)
}
}
html.milestone(
condition.state,
issues.zip(status),
page,
getAssignableUserNames(repository.owner, repository.name),
getPriorities(repository.owner, repository.name),
getLabels(repository.owner, repository.name),
condition,
getMilestonesWithIssueCount(repository.owner, repository.name)
.filter(p => p._1.milestoneId == milestone.get.milestoneId),
repository,
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
)
})
get("/:owner/:repository/issues/milestones/new")(writableUsersOnly {
html.edit(None, _)
})

View File

@@ -29,12 +29,15 @@ trait PreProcessControllerBase extends ControllerBase {
* If anonymous access is allowed, pass all requests.
* But if it's not allowed, demands authentication except some paths.
*/
get(!context.settings.allowAnonymousAccess, context.loginAccount.isEmpty) {
if (!context.currentPath.startsWith("/assets") && !context.currentPath.startsWith("/signin") &&
!context.currentPath.startsWith("/register") && !context.currentPath.endsWith("/info/refs") &&
!PluginRegistry().getAnonymousAccessiblePaths().exists { path =>
context.currentPath.startsWith(path)
}) {
get(!context.settings.basicBehavior.allowAnonymousAccess, context.loginAccount.isEmpty) {
if (
!context.currentPath.startsWith("/assets") && !context.currentPath.startsWith("/signin") &&
!context.currentPath.startsWith("/register") && !context.currentPath.endsWith("/info/refs") &&
!context.currentPath.startsWith("/plugin-assets") && !context.currentPath.equals("/user.css") &&
!PluginRegistry().getAnonymousAccessiblePaths().exists { path =>
context.currentPath.startsWith(path)
}
) {
Unauthorized()
} else {
pass()

View File

@@ -28,15 +28,11 @@ class PrioritiesController
with WritableUsersAuthenticator
trait PrioritiesControllerBase extends ControllerBase {
self: PrioritiesService
with IssuesService
with RepositoryService
with ReferrerAuthenticator
with WritableUsersAuthenticator =>
self: PrioritiesService & IssuesService & RepositoryService & ReferrerAuthenticator & WritableUsersAuthenticator =>
case class PriorityForm(priorityName: String, description: Option[String], color: String)
private case class PriorityForm(priorityName: String, description: Option[String], color: String)
val priorityForm = mapping(
private val priorityForm = mapping(
"priorityName" -> trim(label("Priority name", text(required, priorityName, uniquePriorityName, maxlength(100)))),
"description" -> trim(label("Description", optional(text(maxlength(255))))),
"priorityColor" -> trim(label("Color", text(required, color)))
@@ -45,7 +41,7 @@ trait PrioritiesControllerBase extends ControllerBase {
get("/:owner/:repository/issues/priorities")(referrersOnly { repository =>
html.list(
getPriorities(repository.owner, repository.name),
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
repository,
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
)
@@ -60,7 +56,7 @@ trait PrioritiesControllerBase extends ControllerBase {
createPriority(repository.owner, repository.name, form.priorityName, form.description, form.color.substring(1))
html.priority(
getPriority(repository.owner, repository.name, priorityId).get,
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
countIssueGroupByPriorities(repository.owner, repository.name, IssuesService.IssueSearchCondition()),
repository,
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
)
@@ -84,13 +80,13 @@ trait PrioritiesControllerBase extends ControllerBase {
)
html.priority(
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,
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
)
})
ajaxPost("/:owner/:repository/issues/priorities/reorder")(writableUsersOnly { (repository) =>
ajaxPost("/:owner/:repository/issues/priorities/reorder")(writableUsersOnly { repository =>
reorderPriorities(
repository.owner,
repository.name,
@@ -104,7 +100,7 @@ trait PrioritiesControllerBase extends ControllerBase {
Ok()
})
ajaxPost("/:owner/:repository/issues/priorities/default")(writableUsersOnly { (repository) =>
ajaxPost("/:owner/:repository/issues/priorities/default")(writableUsersOnly { repository =>
setDefaultPriority(repository.owner, repository.name, priorityId("priorityId"))
Ok()
})
@@ -122,9 +118,9 @@ trait PrioritiesControllerBase extends ControllerBase {
private def priorityName: Constraint = new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] =
if (value.contains(',')) {
Some(s"${name} contains invalid character.")
Some(s"$name contains invalid character.")
} else if (value.startsWith("_") || value.startsWith("-")) {
Some(s"${name} starts with invalid character.")
Some(s"$name starts with invalid character.")
} else {
None
}

View File

@@ -2,11 +2,19 @@ package gitbucket.core.controller
import java.io.File
import gitbucket.core.service.{AccountService, ActivityService, PaginationHelper, ReleaseService, RepositoryService}
import gitbucket.core.util._
import gitbucket.core.util.Directory._
import gitbucket.core.util.Implicits._
import org.scalatra.forms._
import gitbucket.core.model.activity.ReleaseInfo
import gitbucket.core.service.{
AccountService,
ActivityService,
PaginationHelper,
ReleaseService,
RepositoryService,
RequestCache
}
import gitbucket.core.util.*
import gitbucket.core.util.Directory.*
import gitbucket.core.util.Implicits.*
import org.scalatra.forms.*
import gitbucket.core.releases.html
import org.apache.commons.io.FileUtils
import org.eclipse.jgit.api.Git
@@ -22,22 +30,18 @@ class ReleaseController
with ReadableUsersAuthenticator
with ReferrerAuthenticator
with WritableUsersAuthenticator
with RequestCache
trait ReleaseControllerBase extends ControllerBase {
self: RepositoryService
with AccountService
with ReleaseService
with ReadableUsersAuthenticator
with ReferrerAuthenticator
with WritableUsersAuthenticator
with ActivityService =>
self: RepositoryService & AccountService & ReleaseService & ReadableUsersAuthenticator & ReferrerAuthenticator &
WritableUsersAuthenticator & ActivityService =>
case class ReleaseForm(
private case class ReleaseForm(
name: String,
content: Option[String]
)
val releaseForm = mapping(
private val releaseForm = mapping(
"name" -> trim(text(required)),
"content" -> trim(optional(text()))
)(ReleaseForm.apply)
@@ -54,8 +58,8 @@ trait ReleaseControllerBase extends ControllerBase {
)
})
get("/:owner/:repository/releases/:tag")(referrersOnly { repository =>
val tagName = params("tag")
get("/:owner/:repository/releases/*")(referrersOnly { repository =>
val tagName = multiParams("splat").head
getRelease(repository.owner, repository.name, tagName)
.map { release =>
html.release(
@@ -68,8 +72,8 @@ trait ReleaseControllerBase extends ControllerBase {
.getOrElse(NotFound())
})
get("/:owner/:repository/releases/:tag/assets/:fileId")(referrersOnly { repository =>
val tagName = params("tag")
get("/:owner/:repository/releases/*/assets/:fileId")(referrersOnly { repository =>
val tagName = multiParams("splat").head
val fileId = params("fileId")
(for {
_ <- repository.tags.find(_.name == tagName)
@@ -84,8 +88,8 @@ trait ReleaseControllerBase extends ControllerBase {
}).getOrElse(NotFound())
})
get("/:owner/:repository/releases/:tag/create")(writableUsersOnly { repository =>
val tagName = params("tag")
get("/:owner/:repository/releases/*/create")(writableUsersOnly { repository =>
val tagName = multiParams("splat").head
val previousTags = repository.tags.takeWhile(_.name != tagName).reverse
repository.tags
@@ -96,40 +100,40 @@ trait ReleaseControllerBase extends ControllerBase {
.getOrElse(NotFound())
})
post("/:owner/:repository/releases/:tag/create", releaseForm)(writableUsersOnly { (form, repository) =>
val tagName = params("tag")
val loginAccount = context.loginAccount.get
post("/:owner/:repository/releases/*/create", releaseForm)(writableUsersOnly { (form, repository) =>
context.withLoginAccount { loginAccount =>
val tagName = multiParams("splat").head
// Insert into RELEASE
createRelease(repository.owner, repository.name, form.name, form.content, tagName, loginAccount)
// Insert into RELEASE
createRelease(repository.owner, repository.name, form.name, form.content, tagName, loginAccount)
// Insert into RELEASE_ASSET
val files = params.toMap.collect {
case (name, value) if name.startsWith("file:") =>
val Array(_, fileId) = name.split(":")
(fileId, value)
}
files.foreach {
case (fileId, fileName) =>
// Insert into RELEASE_ASSET
val files = params.toMap.collect {
case (name, value) if name.startsWith("file:") =>
val Array(_, fileId) = name.split(":")
(fileId, value)
}
files.foreach { case (fileId, fileName) =>
val size =
new File(
getReleaseFilesDir(repository.owner, repository.name),
FileUtil.checkFilename(tagName + "/" + fileId)
).length
createReleaseAsset(repository.owner, repository.name, tagName, fileId, fileName, size, loginAccount)
}
val releaseInfo = ReleaseInfo(repository.owner, repository.name, loginAccount.userName, form.name, tagName)
recordActivity(releaseInfo)
redirect(s"/${repository.owner}/${repository.name}/releases/$tagName")
}
recordReleaseActivity(repository.owner, repository.name, loginAccount.userName, form.name, tagName)
redirect(s"/${repository.owner}/${repository.name}/releases/${tagName}")
})
get("/:owner/:repository/changelog/*...*")(writableUsersOnly { repository =>
val Seq(previousTag, currentTag) = multiParams("splat")
val previousTagId = repository.tags.collectFirst { case x if x.name == previousTag => x.id }.getOrElse("")
val commitLog = Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
val commits = JGitUtil.getCommitLog(git, previousTagId, currentTag).reverse
val Seq(previousTag, currentTag) = multiParams("splat")
val commits = JGitUtil.getCommitLog(git, previousTag, currentTag).reverse
commits
.map { commit =>
s"- ${commit.shortMessage} ${commit.id}"
@@ -140,8 +144,8 @@ trait ReleaseControllerBase extends ControllerBase {
commitLog
})
get("/:owner/:repository/releases/:tag/edit")(writableUsersOnly { repository =>
val tagName = params("tag")
get("/:owner/:repository/releases/*/edit")(writableUsersOnly { repository =>
val tagName = multiParams("splat").head
val previousTags = repository.tags.takeWhile(_.name != tagName).reverse
(for {
@@ -158,10 +162,9 @@ trait ReleaseControllerBase extends ControllerBase {
}).getOrElse(NotFound())
})
post("/:owner/:repository/releases/:tag/edit", releaseForm)(writableUsersOnly {
(form, repository) =>
val tagName = params("tag")
val loginAccount = context.loginAccount.get
post("/:owner/:repository/releases/*/edit", releaseForm)(writableUsersOnly { (form, repository) =>
context.withLoginAccount { loginAccount =>
val tagName = multiParams("splat").head
getRelease(repository.owner, repository.name, tagName)
.map { release =>
@@ -177,14 +180,13 @@ trait ReleaseControllerBase extends ControllerBase {
val Array(_, fileId) = name.split(":")
(fileId, value)
}
files.foreach {
case (fileId, fileName) =>
val size =
new File(
getReleaseFilesDir(repository.owner, repository.name),
FileUtil.checkFilename(tagName + "/" + fileId)
).length
createReleaseAsset(repository.owner, repository.name, tagName, fileId, fileName, size, loginAccount)
files.foreach { case (fileId, fileName) =>
val size =
new File(
getReleaseFilesDir(repository.owner, repository.name),
FileUtil.checkFilename(tagName + "/" + fileId)
).length
createReleaseAsset(repository.owner, repository.name, tagName, fileId, fileName, size, loginAccount)
}
assets.foreach { asset =>
@@ -197,13 +199,14 @@ trait ReleaseControllerBase extends ControllerBase {
}
}
redirect(s"/${release.userName}/${release.repositoryName}/releases/${tagName}")
redirect(s"/${release.userName}/${release.repositoryName}/releases/$tagName")
}
.getOrElse(NotFound())
}
})
post("/:owner/:repository/releases/:tag/delete")(writableUsersOnly { repository =>
val tagName = params("tag")
post("/:owner/:repository/releases/*/delete")(writableUsersOnly { repository =>
val tagName = multiParams("splat").head
getRelease(repository.owner, repository.name, tagName).foreach { release =>
FileUtils.deleteDirectory(
new File(getReleaseFilesDir(repository.owner, repository.name), FileUtil.checkFilename(release.tag))
@@ -214,8 +217,7 @@ trait ReleaseControllerBase extends ControllerBase {
})
private def fetchReleases(repository: RepositoryService.RepositoryInfo, page: Int) = {
import gitbucket.core.service.ReleaseService._
import gitbucket.core.service.ReleaseService.*
val (offset, limit) = ((page - 1) * ReleaseLimit, ReleaseLimit)
val tagsToDisplay = repository.tags.reverse.slice(offset, offset + limit)
@@ -224,9 +226,12 @@ trait ReleaseControllerBase extends ControllerBase {
val assets = getReleaseAssetsMap(repository.owner, repository.name, releases)
val tagsWithReleases = tagsToDisplay.map { tag =>
(tag, releases.find(_.tag == tag.name).map { release =>
(release, assets(release))
})
(
tag,
releases.find(_.tag == tag.name).map { release =>
(release, assets(release))
}
)
}
tagsWithReleases
}

View File

@@ -1,26 +1,26 @@
package gitbucket.core.controller
import java.time.{LocalDateTime, ZoneId, ZoneOffset}
import java.time.{LocalDateTime, ZoneOffset}
import java.util.Date
import gitbucket.core.settings.html
import gitbucket.core.model.{RepositoryWebHook, WebHook}
import gitbucket.core.service._
import gitbucket.core.service.WebHookService._
import gitbucket.core.util._
import gitbucket.core.util.JGitUtil._
import gitbucket.core.util.SyntaxSugars._
import gitbucket.core.util.Implicits._
import gitbucket.core.util.Directory._
import gitbucket.core.service.*
import gitbucket.core.service.WebHookService.*
import gitbucket.core.util.*
import gitbucket.core.util.JGitUtil.*
import gitbucket.core.util.SyntaxSugars.*
import gitbucket.core.util.Implicits.*
import gitbucket.core.util.Directory.*
import gitbucket.core.model.WebHookContentType
import org.scalatra.forms._
import gitbucket.core.model.activity.RenameRepositoryInfo
import org.scalatra.forms.*
import org.scalatra.i18n.Messages
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.Constants
import org.eclipse.jgit.lib.ObjectId
import scala.util.Using
import org.scalatra.Forbidden
import org.scalatra.{Forbidden, Ok}
class RepositorySettingsController
extends RepositorySettingsControllerBase
@@ -30,21 +30,18 @@ class RepositorySettingsController
with ProtectedBranchService
with CommitStatusService
with DeployKeyService
with CustomFieldsService
with ActivityService
with OwnerAuthenticator
with UsersAuthenticator
with RequestCache
trait RepositorySettingsControllerBase extends ControllerBase {
self: RepositoryService
with AccountService
with WebHookService
with ProtectedBranchService
with CommitStatusService
with DeployKeyService
with OwnerAuthenticator
with UsersAuthenticator =>
self: RepositoryService & AccountService & WebHookService & ProtectedBranchService & CommitStatusService &
DeployKeyService & CustomFieldsService & ActivityService & OwnerAuthenticator & UsersAuthenticator =>
// for repository options
case class OptionsForm(
private case class OptionsForm(
description: Option[String],
isPrivate: Boolean,
issuesOption: String,
@@ -53,10 +50,11 @@ trait RepositorySettingsControllerBase extends ControllerBase {
externalWikiUrl: Option[String],
allowFork: Boolean,
mergeOptions: Seq[String],
defaultMergeOption: String
defaultMergeOption: String,
safeMode: Boolean
)
val optionsForm = mapping(
private val optionsForm = mapping(
"description" -> trim(label("Description", optional(text()))),
"isPrivate" -> trim(label("Repository Type", boolean())),
"issuesOption" -> trim(label("Issues Option", text(required, featureOption))),
@@ -65,7 +63,8 @@ trait RepositorySettingsControllerBase extends ControllerBase {
"externalWikiUrl" -> trim(label("External Wiki URL", optional(text(maxlength(200))))),
"allowFork" -> trim(label("Allow Forking", boolean())),
"mergeOptions" -> mergeOptions,
"defaultMergeOption" -> trim(label("Default merge strategy", text(required)))
"defaultMergeOption" -> trim(label("Default merge strategy", text(required))),
"safeMode" -> trim(label("XSS protection", boolean()))
)(OptionsForm.apply).verifying { form =>
if (!form.mergeOptions.contains(form.defaultMergeOption)) {
Seq("defaultMergeOption" -> s"This merge strategy isn't enabled.")
@@ -73,50 +72,70 @@ trait RepositorySettingsControllerBase extends ControllerBase {
}
// for default branch
case class DefaultBranchForm(defaultBranch: String)
private case class DefaultBranchForm(defaultBranch: String)
val defaultBranchForm = mapping(
private val defaultBranchForm = mapping(
"defaultBranch" -> trim(label("Default Branch", text(required, maxlength(100))))
)(DefaultBranchForm.apply)
// for deploy key
case class DeployKeyForm(title: String, publicKey: String, allowWrite: Boolean)
private case class DeployKeyForm(title: String, publicKey: String, allowWrite: Boolean)
val deployKeyForm = mapping(
private val deployKeyForm = mapping(
"title" -> trim(label("Title", text(required, maxlength(100)))),
"publicKey" -> trim2(label("Key", text(required))), // TODO duplication check in the repository?
"allowWrite" -> trim(label("Key", boolean()))
)(DeployKeyForm.apply)
// for web hook url addition
case class WebHookForm(url: String, events: Set[WebHook.Event], ctype: WebHookContentType, token: Option[String])
private case class WebHookForm(
url: String,
events: Set[WebHook.Event],
ctype: WebHookContentType,
token: Option[String]
)
def webHookForm(update: Boolean) =
private def webHookForm(update: Boolean) =
mapping(
"url" -> trim(label("url", text(required, webHook(update)))),
"events" -> webhookEvents,
"ctype" -> label("ctype", text()),
"token" -> optional(trim(label("token", text(maxlength(100)))))
)(
(url, events, ctype, token) => WebHookForm(url, events, WebHookContentType.valueOf(ctype), token)
)
)((url, events, ctype, token) => WebHookForm(url, events, WebHookContentType.valueOf(ctype), token))
// for rename repository
case class RenameRepositoryForm(repositoryName: String)
private case class RenameRepositoryForm(repositoryName: String)
val renameForm = mapping(
private val renameForm = mapping(
"repositoryName" -> trim(
label("New repository name", text(required, maxlength(100), repository, renameRepositoryName))
)
)(RenameRepositoryForm.apply)
// for transfer ownership
case class TransferOwnerShipForm(newOwner: String)
private case class TransferOwnerShipForm(newOwner: String)
val transferForm = mapping(
private val transferForm = mapping(
"newOwner" -> trim(label("New owner", text(required, transferUser)))
)(TransferOwnerShipForm.apply)
// for custom field
private case class CustomFieldForm(
fieldName: String,
fieldType: String,
constraints: Option[String],
enableForIssues: Boolean,
enableForPullRequests: Boolean
)
private 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.
*/
@@ -148,7 +167,8 @@ trait RepositorySettingsControllerBase extends ControllerBase {
form.externalWikiUrl,
form.allowFork,
form.mergeOptions,
form.defaultMergeOption
form.defaultMergeOption,
form.safeMode
)
flash.update("info", "Repository settings has been updated.")
redirect(s"/${repository.owner}/${repository.name}/settings/options")
@@ -163,7 +183,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
/** Update default branch */
post("/:owner/:repository/settings/update_default_branch", defaultBranchForm)(ownerOnly { (form, repository) =>
if (!repository.branchList.contains(form.defaultBranch)) {
redirect(s"/${repository.owner}/${repository.name}/settings/options")
redirect(s"/${repository.owner}/${repository.name}/settings/branches")
} else {
saveRepositoryDefaultBranch(repository.owner, repository.name, form.defaultBranch)
// Change repository HEAD
@@ -176,14 +196,15 @@ trait RepositorySettingsControllerBase extends ControllerBase {
})
/** Branch protection for branch */
get("/:owner/:repository/settings/branches/:branch")(ownerOnly { repository =>
import gitbucket.core.api._
val branch = params("branch")
get("/:owner/:repository/settings/branches/*")(ownerOnly { repository =>
import gitbucket.core.api.*
val branch = params("splat")
if (!repository.branchList.contains(branch)) {
redirect(s"/${repository.owner}/${repository.name}/settings/branches")
} else {
val protection = ApiBranchProtection(getProtectedBranchInfo(repository.owner, repository.name, branch))
val lastWeeks = getRecentStatuesContexts(
val protection = ApiBranchProtectionResponse(getProtectedBranchInfo(repository.owner, repository.name, branch))
val lastWeeks = getRecentStatusContexts(
repository.owner,
repository.name,
Date.from(LocalDateTime.now.minusWeeks(1).toInstant(ZoneOffset.UTC))
@@ -225,8 +246,14 @@ trait RepositorySettingsControllerBase extends ControllerBase {
* Display the web hook edit page.
*/
get("/:owner/:repository/settings/hooks/new")(ownerOnly { repository =>
val webhook = RepositoryWebHook(repository.owner, repository.name, "", WebHookContentType.FORM, None)
html.edithook(webhook, Set(WebHook.Push), repository, true)
val webhook = RepositoryWebHook(
userName = repository.owner,
repositoryName = repository.name,
url = "",
ctype = WebHookContentType.FORM,
token = None
)
html.edithook(webhook, Set(WebHook.Push), repository, create = true)
})
/**
@@ -251,91 +278,95 @@ trait RepositorySettingsControllerBase extends ControllerBase {
* Send the test request to registered web hook URLs.
*/
ajaxPost("/:owner/:repository/settings/hooks/test")(ownerOnly { repository =>
def _headers(h: Array[org.apache.http.Header]): Array[Array[String]] = h.map { h =>
Array(h.getName, h.getValue)
}
def _headers(h: Array[org.apache.http.Header]): Array[Array[String]] =
h.map { h =>
Array(h.getName, h.getValue)
}
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
git =>
import scala.concurrent.duration._
import scala.concurrent._
import scala.jdk.CollectionConverters._
import scala.util.control.NonFatal
import org.apache.http.util.EntityUtils
import scala.concurrent.ExecutionContext.Implicits.global
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
import scala.concurrent.duration.*
import scala.concurrent.*
import scala.jdk.CollectionConverters.*
import scala.util.control.NonFatal
import org.apache.http.util.EntityUtils
import scala.concurrent.ExecutionContext.Implicits.global
val url = params("url")
val token = Some(params("token"))
val ctype = WebHookContentType.valueOf(params("ctype"))
val dummyWebHookInfo = RepositoryWebHook(repository.owner, repository.name, url, ctype, token)
val dummyPayload = {
val ownerAccount = getAccountByUserName(repository.owner).get
val commits =
if (JGitUtil.isEmpty(git)) List.empty
else
git.log
.add(git.getRepository.resolve(repository.repository.defaultBranch))
.setMaxCount(4)
.call
.iterator
.asScala
.map(new CommitInfo(_))
.toList
val pushedCommit = commits.drop(1)
val url = params("url")
val token = Some(params("token"))
val ctype = WebHookContentType.valueOf(params("ctype"))
val dummyWebHookInfo = RepositoryWebHook(
userName = repository.owner,
repositoryName = repository.name,
url = url,
ctype = ctype,
token = token
)
val dummyPayload = {
val ownerAccount = getAccountByUserName(repository.owner).get
val commits =
if (JGitUtil.isEmpty(git)) List.empty
else
git.log
.add(git.getRepository.resolve(repository.repository.defaultBranch))
.setMaxCount(4)
.call
.iterator
.asScala
.map(new CommitInfo(_))
.toList
val pushedCommit = commits.drop(1)
WebHookPushPayload(
git = git,
sender = ownerAccount,
refName = "refs/heads/" + repository.repository.defaultBranch,
repositoryInfo = repository,
commits = pushedCommit,
repositoryOwner = ownerAccount,
oldId = commits.lastOption.map(_.id).map(ObjectId.fromString).getOrElse(ObjectId.zeroId()),
newId = commits.headOption.map(_.id).map(ObjectId.fromString).getOrElse(ObjectId.zeroId())
)
}
WebHookPushPayload(
git = git,
sender = ownerAccount,
refName = "refs/heads/" + repository.repository.defaultBranch,
repositoryInfo = repository,
commits = pushedCommit,
repositoryOwner = ownerAccount,
oldId = commits.lastOption.map(_.id).map(ObjectId.fromString).getOrElse(ObjectId.zeroId()),
newId = commits.headOption.map(_.id).map(ObjectId.fromString).getOrElse(ObjectId.zeroId())
)
}
val (webHook, json, reqFuture, resFuture) =
callWebHook(WebHook.Push, List(dummyWebHookInfo), dummyPayload, context.settings).head
val (webHook, json, reqFuture, resFuture) =
callWebHook(WebHook.Push, List(dummyWebHookInfo), dummyPayload, context.settings).head
val toErrorMap: PartialFunction[Throwable, Map[String, String]] = {
case e: java.net.UnknownHostException => Map("error" -> ("Unknown host " + e.getMessage))
case e: java.lang.IllegalArgumentException => Map("error" -> ("invalid url"))
case e: org.apache.http.client.ClientProtocolException => Map("error" -> ("invalid url"))
case NonFatal(e) => Map("error" -> (s"${e.getClass} ${e.getMessage}"))
}
val toErrorMap: PartialFunction[Throwable, Map[String, String]] = {
case e: java.net.UnknownHostException => Map("error" -> s"Unknown host ${e.getMessage}")
case _: java.lang.IllegalArgumentException => Map("error" -> "invalid url")
case _: org.apache.http.client.ClientProtocolException => Map("error" -> "invalid url")
case NonFatal(e) => Map("error" -> s"${e.getClass} ${e.getMessage}")
}
contentType = formats("json")
org.json4s.jackson.Serialization.write(
Map(
"url" -> url,
"request" -> Await.result(
reqFuture
.map(
req =>
Map(
"headers" -> _headers(req.getAllHeaders),
"payload" -> json
)
contentType = formats("json")
org.json4s.jackson.Serialization.write(
Map(
"url" -> url,
"request" -> Await.result(
reqFuture
.map(req =>
Map(
"headers" -> _headers(req.getAllHeaders),
"payload" -> json
)
.recover(toErrorMap),
20 seconds
),
"response" -> Await.result(
resFuture
.map(
res =>
Map(
"status" -> res.getStatusLine(),
"body" -> EntityUtils.toString(res.getEntity()),
"headers" -> _headers(res.getAllHeaders())
)
)
.recover(toErrorMap),
20 seconds
),
"response" -> Await.result(
resFuture
.map(res =>
Map(
"status" -> res.getStatusLine.getStatusCode,
"body" -> EntityUtils.toString(res.getEntity),
"headers" -> _headers(res.getAllHeaders)
)
.recover(toErrorMap),
20 seconds
)
)
.recover(toErrorMap),
20 seconds
)
)
)
}
})
@@ -343,9 +374,8 @@ trait RepositorySettingsControllerBase extends ControllerBase {
* Display the web hook edit page.
*/
get("/:owner/:repository/settings/hooks/edit")(ownerOnly { repository =>
getWebHook(repository.owner, repository.name, params("url")).map {
case (webhook, events) =>
html.edithook(webhook, events, repository, false)
getWebHook(repository.owner, repository.name, params("url")).map { case (webhook, events) =>
html.edithook(webhook, events, repository, create = false)
} getOrElse NotFound()
})
@@ -369,36 +399,60 @@ trait RepositorySettingsControllerBase extends ControllerBase {
* Rename repository.
*/
post("/:owner/:repository/settings/rename", renameForm)(ownerOnly { (form, repository) =>
if (context.settings.repositoryOperation.rename || context.loginAccount.get.isAdmin) {
if (repository.name != form.repositoryName) {
renameRepository(repository.owner, repository.name, repository.owner, form.repositoryName)
}
redirect(s"/${repository.owner}/${form.repositoryName}")
} else Forbidden()
context.withLoginAccount { loginAccount =>
if (context.settings.basicBehavior.repositoryOperation.rename || loginAccount.isAdmin) {
if (repository.name != form.repositoryName) {
// Update database and move git repository
renameRepository(repository.owner, repository.name, repository.owner, form.repositoryName)
// Record activity log
val renameInfo = RenameRepositoryInfo(
repository.owner,
form.repositoryName,
loginAccount.userName,
repository.name
)
recordActivity(renameInfo)
}
redirect(s"/${repository.owner}/${form.repositoryName}")
} else Forbidden()
}
})
/**
* Transfer repository ownership.
*/
post("/:owner/:repository/settings/transfer", transferForm)(ownerOnly { (form, repository) =>
if (context.settings.repositoryOperation.transfer || context.loginAccount.get.isAdmin) {
// Change repository owner
if (repository.owner != form.newOwner) {
renameRepository(repository.owner, repository.name, form.newOwner, repository.name)
}
redirect(s"/${form.newOwner}/${repository.name}")
} else Forbidden()
context.withLoginAccount { loginAccount =>
if (context.settings.basicBehavior.repositoryOperation.transfer || loginAccount.isAdmin) {
// Change repository owner
if (repository.owner != form.newOwner) {
// Update database and move git repository
renameRepository(repository.owner, repository.name, form.newOwner, repository.name)
// Record activity log
val renameInfo = RenameRepositoryInfo(
form.newOwner,
repository.name,
loginAccount.userName,
repository.owner
)
recordActivity(renameInfo)
}
redirect(s"/${form.newOwner}/${repository.name}")
} else Forbidden()
}
})
/**
* Delete the repository.
*/
post("/:owner/:repository/settings/delete")(ownerOnly { repository =>
if (context.settings.repositoryOperation.delete || context.loginAccount.get.isAdmin) {
// Delete the repository and related files
deleteRepository(repository.repository)
redirect(s"/${repository.owner}")
} else Forbidden()
context.withLoginAccount { loginAccount =>
if (context.settings.basicBehavior.repositoryOperation.delete || loginAccount.isAdmin) {
// Delete the repository and related files
deleteRepository(repository.repository)
redirect(s"/${repository.owner}")
} else Forbidden()
}
})
/**
@@ -432,35 +486,91 @@ trait RepositorySettingsControllerBase extends ControllerBase {
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.
*/
private def webHook(needExists: Boolean): Constraint = new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] =
if (getWebHook(params("owner"), params("repository"), value).isDefined != needExists) {
Some(if (needExists) {
"URL had not been registered yet."
private def webHook(needExists: Boolean): Constraint =
new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] =
if (getWebHook(params("owner"), params("repository"), value).isDefined != needExists) {
Some(if (needExists) {
"URL had not been registered yet."
} else {
"URL had been registered already."
})
} else {
"URL had been registered already."
})
} else {
None
}
}
private def webhookEvents = new ValueType[Set[WebHook.Event]] {
def convert(name: String, params: Map[String, Seq[String]], messages: Messages): Set[WebHook.Event] = {
WebHook.Event.values.flatMap { t =>
params.get(name + "." + t.name).map(_ => t)
}.toSet
None
}
}
def validate(name: String, params: Map[String, Seq[String]], messages: Messages): Seq[(String, String)] =
if (convert(name, params, messages).isEmpty) {
Seq(name -> messages("error.required").format(name))
} else {
Nil
private def webhookEvents =
new ValueType[Set[WebHook.Event]] {
def convert(name: String, params: Map[String, Seq[String]], messages: Messages): Set[WebHook.Event] = {
WebHook.Event.values.flatMap { t =>
params.get(name + "." + t.name).map(_ => t)
}.toSet
}
}
def validate(name: String, params: Map[String, Seq[String]], messages: Messages): Seq[(String, String)] =
if (convert(name, params, messages).isEmpty) {
Seq(name -> messages("error.required").format(name))
} else {
Nil
}
}
// /**
// * Provides Constraint to validate the collaborator name.
@@ -480,70 +590,77 @@ trait RepositorySettingsControllerBase extends ControllerBase {
/**
* Duplicate check for the rename repository name.
*/
private def renameRepositoryName: Constraint = new Constraint() {
override def validate(
name: String,
value: String,
params: Map[String, Seq[String]],
messages: Messages
): Option[String] = {
for {
repoName <- params.optionValue("repository") if repoName != value
userName <- params.optionValue("owner")
_ <- getRepositoryNamesOfUser(userName).find(_ == value)
} yield {
"Repository already exists."
private def renameRepositoryName: Constraint =
new Constraint() {
override def validate(
name: String,
value: String,
params: Map[String, Seq[String]],
messages: Messages
): Option[String] = {
for {
repoName <- params.optionValue("repository") if repoName != value
userName <- params.optionValue("owner")
_ <- getRepositoryNamesOfUser(userName).find(_ == value)
} yield {
"Repository already exists."
}
}
}
}
/**
*
*/
private def featureOption: Constraint = new Constraint() {
override def validate(
name: String,
value: String,
params: Map[String, Seq[String]],
messages: Messages
): Option[String] =
if (Seq("DISABLE", "PRIVATE", "PUBLIC", "ALL").contains(value)) None else Some("Option is invalid.")
}
private def featureOption: Constraint =
new Constraint() {
override def validate(
name: String,
value: String,
params: Map[String, Seq[String]],
messages: Messages
): Option[String] =
if (Seq("DISABLE", "PRIVATE", "PUBLIC", "ALL").contains(value)) None else Some("Option is invalid.")
}
/**
* Provides Constraint to validate the repository transfer user.
*/
private def transferUser: Constraint = new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] =
getAccountByUserName(value) match {
case None => Some("User does not exist.")
case Some(x) =>
if (x.userName == params("owner")) {
Some("This is current repository owner.")
} else {
params.get("repository").flatMap { repositoryName =>
getRepositoryNamesOfUser(x.userName).find(_ == repositoryName).map { _ =>
"User already has same repository."
private def transferUser: Constraint =
new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] =
getAccountByUserName(value) match {
case None => Some("User does not exist.")
case Some(x) =>
if (x.userName == params("owner")) {
Some("This is current repository owner.")
} else {
params.get("repository").flatMap { repositoryName =>
getRepositoryNamesOfUser(x.userName).find(_ == repositoryName).map { _ =>
"User already has same repository."
}
}
}
}
}
}
}
}
private def mergeOptions = new ValueType[Seq[String]] {
override def convert(name: String, params: Map[String, Seq[String]], messages: Messages): Seq[String] = {
params.getOrElse("mergeOptions", Nil)
}
override def validate(name: String, params: Map[String, Seq[String]], messages: Messages): Seq[(String, String)] = {
val mergeOptions = params.getOrElse("mergeOptions", Nil)
if (mergeOptions.isEmpty) {
Seq("mergeOptions" -> "At least one option must be enabled.")
} else if (!mergeOptions.forall(x => Seq("merge-commit", "squash", "rebase").contains(x))) {
Seq("mergeOptions" -> "mergeOptions are invalid.")
} else {
Nil
private def mergeOptions =
new ValueType[Seq[String]] {
override def convert(name: String, params: Map[String, Seq[String]], messages: Messages): Seq[String] = {
params.getOrElse("mergeOptions", Nil)
}
override def validate(
name: String,
params: Map[String, Seq[String]],
messages: Messages
): Seq[(String, String)] = {
val mergeOptions = params.getOrElse("mergeOptions", Nil)
if (mergeOptions.isEmpty) {
Seq("mergeOptions" -> "At least one option must be enabled.")
} else if (!mergeOptions.forall(x => Seq("merge-commit", "squash", "rebase").contains(x))) {
Seq("mergeOptions" -> "mergeOptions are invalid.")
} else {
Nil
}
}
}
}
}

View File

@@ -1,21 +1,19 @@
package gitbucket.core.controller
import java.io.FileInputStream
import gitbucket.core.admin.html
import gitbucket.core.plugin.PluginRegistry
import gitbucket.core.service.SystemSettingsService._
import gitbucket.core.service.SystemSettingsService.*
import gitbucket.core.service.{AccountService, RepositoryService}
import gitbucket.core.ssh.SshServer
import gitbucket.core.util.Implicits._
import gitbucket.core.util.StringUtil._
import gitbucket.core.util.SyntaxSugars._
import gitbucket.core.util.Implicits.*
import gitbucket.core.util.StringUtil.*
import gitbucket.core.util.{AdminAuthenticator, Mailer}
import org.apache.commons.io.IOUtils
import org.apache.commons.mail.EmailException
import org.json4s.jackson.Serialization
import org.scalatra._
import org.scalatra.forms._
import org.scalatra.*
import org.scalatra.forms.*
import org.scalatra.i18n.Messages
import scala.collection.mutable.ListBuffer
@@ -31,29 +29,41 @@ case class Table(name: String, columns: Seq[Column])
case class Column(name: String, primaryKey: Boolean)
trait SystemSettingsControllerBase extends AccountManagementControllerBase {
self: AccountService with RepositoryService with AdminAuthenticator =>
self: AccountService & RepositoryService & AdminAuthenticator =>
private val form = mapping(
"baseUrl" -> trim(label("Base URL", optional(text()))),
"information" -> trim(label("Information", optional(text()))),
"allowAccountRegistration" -> trim(label("Account registration", boolean())),
"allowAnonymousAccess" -> trim(label("Anonymous access", boolean())),
"isCreateRepoOptionPublic" -> trim(label("Default visibility of new repository", boolean())),
"repositoryOperation" -> mapping(
"create" -> trim(label("Allow all users to create repository", boolean())),
"delete" -> trim(label("Allow all users to delete repository", boolean())),
"rename" -> trim(label("Allow all users to rename repository", boolean())),
"transfer" -> trim(label("Allow all users to transfer repository", boolean())),
"fork" -> trim(label("Allow all users to fork repository", boolean()))
)(RepositoryOperation.apply),
"gravatar" -> trim(label("Gravatar", boolean())),
"notification" -> trim(label("Notification", boolean())),
"activityLogLimit" -> trim(label("Limit of activity logs", optional(number()))),
"limitVisibleRepositories" -> trim(label("limitVisibleRepositories", boolean())),
"basicBehavior" -> mapping(
"allowAccountRegistration" -> trim(label("Account registration", boolean())),
"allowResetPassword" -> trim(label("Reset password", boolean())),
"allowAnonymousAccess" -> trim(label("Anonymous access", boolean())),
"isCreateRepoOptionPublic" -> trim(label("Default visibility of new repository", boolean())),
"repositoryOperation" -> mapping(
"create" -> trim(label("Allow all users to create repository", boolean())),
"delete" -> trim(label("Allow all users to delete repository", boolean())),
"rename" -> trim(label("Allow all users to rename repository", boolean())),
"transfer" -> trim(label("Allow all users to transfer repository", boolean())),
"fork" -> trim(label("Allow all users to fork repository", boolean()))
)(RepositoryOperation.apply),
"gravatar" -> trim(label("Gravatar", boolean())),
"notification" -> trim(label("Notification", boolean())),
"limitVisibleRepositories" -> trim(label("limitVisibleRepositories", boolean())),
)(BasicBehavior.apply),
"ssh" -> mapping(
"enabled" -> trim(label("SSH access", boolean())),
"host" -> trim(label("SSH host", optional(text()))),
"port" -> trim(label("SSH port", optional(number())))
"bindAddress" -> mapping(
"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),
"useSMTP" -> trim(label("SMTP", boolean())),
"smtp" -> optionalIfNotChecked(
@@ -109,14 +119,20 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
"timeout" -> trim(label("Timeout", long(required))),
"largeMaxFileSize" -> trim(label("Max file size for large file", long(required))),
"largeTimeout" -> trim(label("Timeout for large file", long(required)))
)(Upload.apply)
)(Upload.apply),
"repositoryViewer" -> mapping(
"maxFiles" -> trim(label("Max files", number(required))),
"maxDiffFiles" -> trim(label("Max diff files", number(required))),
"maxDiffLines" -> trim(label("Max diff lines", number(required)))
)(RepositoryViewerSettings.apply),
"defaultBranch" -> trim(label("Default branch", text(required)))
)(SystemSettings.apply).verifying { settings =>
Vector(
if (settings.ssh.enabled && settings.baseUrl.isEmpty) {
Some("baseUrl" -> "Base URL is required if SSH access is enabled.")
} else None,
if (settings.ssh.enabled && settings.ssh.sshHost.isEmpty) {
Some("sshHost" -> "SSH host is required if SSH access is enabled.")
if (settings.ssh.enabled && settings.ssh.bindAddress.isEmpty) {
Some("ssh.bindAddress.host" -> "SSH bind host is required if SSH access is enabled.")
} else None
).flatten
}
@@ -135,11 +151,11 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
"testAddress" -> trim(label("", text(required)))
)(SendMailForm.apply)
case class SendMailForm(smtp: Smtp, testAddress: String)
private case class SendMailForm(smtp: Smtp, testAddress: String)
case class DataExportForm(tableNames: List[String])
// case class DataExportForm(tableNames: List[String])
case class NewUserForm(
private case class NewUserForm(
userName: String,
password: String,
fullName: String,
@@ -151,7 +167,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
fileId: Option[String]
)
case class EditUserForm(
private case class EditUserForm(
userName: String,
password: Option[String],
fullName: String,
@@ -165,7 +181,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
isRemoved: Boolean
)
case class NewGroupForm(
private case class NewGroupForm(
groupName: String,
description: Option[String],
url: Option[String],
@@ -173,7 +189,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
members: String
)
case class EditGroupForm(
private case class EditGroupForm(
groupName: String,
description: Option[String],
url: Option[String],
@@ -183,9 +199,9 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
isRemoved: Boolean
)
val newUserForm = mapping(
private val newUserForm = mapping(
"userName" -> trim(label("Username", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
"password" -> trim(label("Password", text(required, maxlength(20)))),
"password" -> trim(label("Password", text(required, maxlength(40)))),
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress()))),
"extraMailAddresses" -> list(
@@ -197,9 +213,9 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
"fileId" -> trim(label("File ID", optional(text())))
)(NewUserForm.apply)
val editUserForm = mapping(
private val editUserForm = mapping(
"userName" -> trim(label("Username", text(required, maxlength(100), identifier))),
"password" -> trim(label("Password", optional(text(maxlength(20))))),
"password" -> trim(label("Password", optional(text(maxlength(40))))),
"fullName" -> trim(label("Full Name", text(required, maxlength(100)))),
"mailAddress" -> trim(label("Mail Address", text(required, maxlength(100), uniqueMailAddress("userName")))),
"extraMailAddresses" -> list(
@@ -213,7 +229,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
"removed" -> trim(label("Disable", boolean(disableByNotYourself("userName"))))
)(EditUserForm.apply)
val newGroupForm = mapping(
private val newGroupForm = mapping(
"groupName" -> trim(label("Group name", text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
"description" -> trim(label("Group description", optional(text()))),
"url" -> trim(label("URL", optional(text(maxlength(200))))),
@@ -221,7 +237,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
"members" -> trim(label("Members", text(required, members)))
)(NewGroupForm.apply)
val editGroupForm = mapping(
private val editGroupForm = mapping(
"groupName" -> trim(label("Group name", text(required, maxlength(100), identifier))),
"description" -> trim(label("Group description", optional(text()))),
"url" -> trim(label("URL", optional(text(maxlength(200))))),
@@ -235,28 +251,27 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
val conn = request2Session(request).conn
val meta = conn.getMetaData
val tables = ListBuffer[Table]()
Using.resource(meta.getTables(null, "%", "%", Array("TABLE", "VIEW"))) {
rs =>
while (rs.next()) {
val tableName = rs.getString("TABLE_NAME")
Using.resource(meta.getTables(null, "%", "%", Array("TABLE", "VIEW"))) { rs =>
while (rs.next()) {
val tableName = rs.getString("TABLE_NAME")
val pkColumns = ListBuffer[String]()
Using.resource(meta.getPrimaryKeys(null, null, tableName)) { rs =>
while (rs.next()) {
pkColumns += rs.getString("COLUMN_NAME").toUpperCase
}
val pkColumns = ListBuffer[String]()
Using.resource(meta.getPrimaryKeys(null, null, tableName)) { rs =>
while (rs.next()) {
pkColumns += rs.getString("COLUMN_NAME").toUpperCase
}
val columns = ListBuffer[Column]()
Using.resource(meta.getColumns(null, "%", tableName, "%")) { rs =>
while (rs.next()) {
val columnName = rs.getString("COLUMN_NAME").toUpperCase
columns += Column(columnName, pkColumns.contains(columnName))
}
}
tables += Table(tableName.toUpperCase, columns.toSeq)
}
val columns = ListBuffer[Column]()
Using.resource(meta.getColumns(null, "%", tableName, "%")) { rs =>
while (rs.next()) {
val columnName = rs.getString("COLUMN_NAME").toUpperCase
columns += Column(columnName, pkColumns.contains(columnName))
}
}
tables += Table(tableName.toUpperCase, columns.toSeq)
}
}
html.dbviewer(tables.toSeq)
})
@@ -269,28 +284,26 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
if (trimmedQuery.nonEmpty) {
try {
val conn = request2Session(request).conn
Using.resource(conn.prepareStatement(query)) {
stmt =>
if (trimmedQuery.toUpperCase.startsWith("SELECT")) {
Using.resource(stmt.executeQuery()) {
rs =>
val meta = rs.getMetaData
val columns = for (i <- 1 to meta.getColumnCount) yield {
meta.getColumnName(i)
}
val result = ListBuffer[Map[String, String]]()
while (rs.next()) {
val row = columns.map { columnName =>
columnName -> Option(rs.getObject(columnName)).map(_.toString).getOrElse("<NULL>")
}.toMap
result += row
}
Ok(Serialization.write(Map("type" -> "query", "columns" -> columns, "rows" -> result)))
Using.resource(conn.prepareStatement(query)) { stmt =>
if (trimmedQuery.toUpperCase.startsWith("SELECT")) {
Using.resource(stmt.executeQuery()) { rs =>
val meta = rs.getMetaData
val columns = for (i <- 1 to meta.getColumnCount) yield {
meta.getColumnName(i)
}
} else {
val rows = stmt.executeUpdate()
Ok(Serialization.write(Map("type" -> "update", "rows" -> rows)))
val result = ListBuffer[Map[String, String]]()
while (rs.next()) {
val row = columns.map { columnName =>
columnName -> Option(rs.getObject(columnName)).map(_.toString).getOrElse("<NULL>")
}.toMap
result += row
}
Ok(Serialization.write(Map("type" -> "query", "columns" -> columns, "rows" -> result)))
}
} else {
val rows = stmt.executeUpdate()
Ok(Serialization.write(Map("type" -> "update", "rows" -> rows)))
}
}
} catch {
case e: Exception =>
@@ -307,12 +320,15 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
post("/admin/system", form)(adminOnly { form =>
saveSystemSettings(form)
if (form.sshAddress != context.settings.sshAddress) {
if (
form.ssh.bindAddress != context.settings.sshBindAddress || form.ssh.publicAddress != context.settings.sshPublicAddress
) {
SshServer.stop()
for {
sshAddress <- form.sshAddress
bindAddress <- form.ssh.bindAddress
publicAddress <- form.ssh.publicAddress.orElse(form.ssh.bindAddress)
baseUrl <- form.baseUrl
} SshServer.start(sshAddress, baseUrl)
} SshServer.start(bindAddress, publicAddress, baseUrl)
}
flash.update("info", "System settings has been updated.")
@@ -321,7 +337,12 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
post("/admin/system/sendmail", sendMailForm)(adminOnly { form =>
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,
subject = "Test message from GitBucket",
textMsg = "This is a test message from GitBucket.",
@@ -342,7 +363,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
})
post("/admin/plugins/_reload")(adminOnly {
PluginRegistry.reload(request.getServletContext(), loadSystemSettings(), request2Session(request).conn)
PluginRegistry.reload(request.getServletContext, loadSystemSettings(), request2Session(request).conn)
flash.update("info", "All plugins were reloaded.")
redirect("/admin/plugins")
})
@@ -360,11 +381,11 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
})
get("/admin/users")(adminOnly {
val includeRemoved = params.get("includeRemoved").map(_.toBoolean).getOrElse(false)
val includeGroups = params.get("includeGroups").map(_.toBoolean).getOrElse(false)
val includeRemoved = params.get("includeRemoved").exists(_.toBoolean)
val includeGroups = params.get("includeGroups").exists(_.toBoolean)
val users = getAllUsers(includeRemoved, includeGroups)
val members = users.collect {
case account if (account.isGroupAccount) =>
case account if account.isGroupAccount =>
account.userName -> getGroupMembers(account.userName).map(_.userName)
}.toMap
@@ -385,7 +406,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
form.description,
form.url
)
updateImage(form.userName, form.fileId, false)
updateImage(form.userName, form.fileId, clearImage = false)
updateAccountExtraMailAddresses(form.userName, form.extraMailAddresses.filter(_ != ""))
redirect("/admin/users")
})
@@ -393,49 +414,48 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
get("/admin/users/:userName/_edituser")(adminOnly {
val userName = params("userName")
val extraMails = getAccountExtraMailAddresses(userName)
html.user(getAccountByUserName(userName, true), extraMails, flash.get("error"))
html.user(getAccountByUserName(userName, includeRemoved = true), extraMails, flash.get("error"))
})
post("/admin/users/:name/_edituser", editUserForm)(adminOnly { form =>
val userName = params("userName")
getAccountByUserName(userName, true).map {
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.")
redirect(s"/admin/users/${userName}/_edituser")
} else {
if (form.isRemoved) {
// Remove repositories
// getRepositoryNamesOfUser(userName).foreach { repositoryName =>
// deleteRepository(userName, repositoryName)
// FileUtils.deleteDirectory(getRepositoryDir(userName, repositoryName))
// FileUtils.deleteDirectory(getWikiRepositoryDir(userName, repositoryName))
// FileUtils.deleteDirectory(getTemporaryDir(userName, repositoryName))
// }
// Remove from GROUP_MEMBER and COLLABORATOR
removeUserRelatedData(userName)
}
updateAccount(
account.copy(
password = form.password.map(pbkdf2_sha256).getOrElse(account.password),
fullName = form.fullName,
mailAddress = form.mailAddress,
isAdmin = form.isAdmin,
description = form.description,
url = form.url,
isRemoved = form.isRemoved
)
)
updateImage(userName, form.fileId, form.clearImage)
updateAccountExtraMailAddresses(userName, form.extraMailAddresses.filter(_ != ""))
// call hooks
if (form.isRemoved) PluginRegistry().getAccountHooks.foreach(_.deleted(userName))
redirect("/admin/users")
getAccountByUserName(userName, includeRemoved = true).map { 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.")
redirect(s"/admin/users/${userName}/_edituser")
} else {
if (form.isRemoved) {
// Remove repositories
// getRepositoryNamesOfUser(userName).foreach { repositoryName =>
// deleteRepository(userName, repositoryName)
// FileUtils.deleteDirectory(getRepositoryDir(userName, repositoryName))
// FileUtils.deleteDirectory(getWikiRepositoryDir(userName, repositoryName))
// FileUtils.deleteDirectory(getTemporaryDir(userName, repositoryName))
// }
// Remove from GROUP_MEMBER and COLLABORATOR
removeUserRelatedData(userName)
}
updateAccount(
account.copy(
password = form.password.map(pbkdf2_sha256).getOrElse(account.password),
fullName = form.fullName,
mailAddress = form.mailAddress,
isAdmin = form.isAdmin,
description = form.description,
url = form.url,
isRemoved = form.isRemoved
)
)
updateImage(userName, form.fileId, form.clearImage)
updateAccountExtraMailAddresses(userName, form.extraMailAddresses.filter(_ != ""))
// call hooks
if (form.isRemoved) PluginRegistry().getAccountHooks.foreach(_.deleted(userName))
redirect("/admin/users")
}
} getOrElse NotFound()
})
@@ -456,36 +476,32 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
}
.toList
)
updateImage(form.groupName, form.fileId, false)
updateImage(form.groupName, form.fileId, clearImage = false)
redirect("/admin/users")
})
get("/admin/users/:groupName/_editgroup")(adminOnly {
defining(params("groupName")) { groupName =>
html.usergroup(getAccountByUserName(groupName, true), getGroupMembers(groupName))
}
val groupName = params("groupName")
html.usergroup(getAccountByUserName(groupName, includeRemoved = true), getGroupMembers(groupName))
})
post("/admin/users/:groupName/_editgroup", editGroupForm)(adminOnly { form =>
defining(
params("groupName"),
form.members
.split(",")
.map {
_.split(":") match {
case Array(userName, isManager) => (userName, isManager.toBoolean)
}
val groupName = params("groupName")
val members = form.members
.split(",")
.map {
_.split(":") match {
case Array(userName, isManager) => (userName, isManager.toBoolean)
}
.toList
) {
case (groupName, members) =>
getAccountByUserName(groupName, true).map {
account =>
updateGroup(groupName, form.description, form.url, form.isRemoved)
}
.toList
if (form.isRemoved) {
// Remove from GROUP_MEMBER
updateGroupMembers(form.groupName, Nil)
getAccountByUserName(groupName, includeRemoved = true).map { account =>
updateGroup(groupName, form.description, form.url, form.isRemoved)
if (form.isRemoved) {
// Remove from GROUP_MEMBER
updateGroupMembers(form.groupName, Nil)
// // Remove repositories
// getRepositoryNamesOfUser(form.groupName).foreach { repositoryName =>
// deleteRepository(groupName, repositoryName)
@@ -493,9 +509,9 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
// FileUtils.deleteDirectory(getWikiRepositoryDir(groupName, repositoryName))
// FileUtils.deleteDirectory(getTemporaryDir(groupName, repositoryName))
// }
} else {
// Update GROUP_MEMBER
updateGroupMembers(form.groupName, members)
} else {
// Update GROUP_MEMBER
updateGroupMembers(form.groupName, members)
// // Update COLLABORATOR for group repositories
// getRepositoryNamesOfUser(form.groupName).foreach { repositoryName =>
// removeCollaborators(form.groupName, repositoryName)
@@ -503,23 +519,22 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
// addCollaborator(form.groupName, repositoryName, userName)
// }
// }
}
}
updateImage(form.groupName, form.fileId, form.clearImage)
redirect("/admin/users")
updateImage(form.groupName, form.fileId, form.clearImage)
redirect("/admin/users")
} getOrElse NotFound()
}
} getOrElse NotFound()
})
get("/admin/data")(adminOnly {
import gitbucket.core.util.JDBCUtil._
import gitbucket.core.util.JDBCUtil.*
val session = request2Session(request)
html.data(session.conn.allTableNames())
})
post("/admin/export")(adminOnly {
import gitbucket.core.util.JDBCUtil._
import gitbucket.core.util.JDBCUtil.*
val file = request2Session(request).conn.exportAsSQL(request.getParameterValues("tableNames").toSeq)
contentType = "application/octet-stream"
@@ -534,7 +549,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
})
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] = {
if (value == null) {
Nil
@@ -547,9 +562,11 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
private def members: Constraint =
new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] = {
if (value.split(",").exists {
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
}) None
if (
value.split(",").exists {
_.split(":") match { case Array(userName, isManager) => isManager.toBoolean }
}
) None
else Some("Must select one manager at least.")
}
}
@@ -557,12 +574,11 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
protected def disableByNotYourself(paramName: String): Constraint =
new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] = {
params.get(paramName).flatMap { userName =>
if (userName == context.loginAccount.get.userName && params.get("removed") == Some("true"))
Some("You can't disable your account yourself")
else
None
}
for {
userName <- params.get(paramName)
loginAccount <- context.loginAccount
if userName == loginAccount.userName && params.get("removed").contains("true")
} yield "You can't disable your account yourself"
}
}

View File

@@ -1,16 +1,16 @@
package gitbucket.core.controller
import org.json4s.{JField, JObject, JString}
import org.scalatra._
import org.scalatra.json._
import org.scalatra.forms._
import org.scalatra.*
import org.scalatra.json.*
import org.scalatra.forms.*
import org.scalatra.i18n.I18nSupport
import org.scalatra.servlet.ServletBase
/**
* Extends scalatra-forms to support the client-side validation and Ajax requests as well.
*/
trait ValidationSupport extends FormSupport { self: ServletBase with JacksonJsonSupport with I18nSupport =>
trait ValidationSupport extends FormSupport { self: ServletBase & JacksonJsonSupport & I18nSupport =>
def get[T](path: String, form: ValueType[T])(action: T => Any): Route = {
registerValidate(path, form)
@@ -84,9 +84,8 @@ trait ValidationSupport extends FormSupport { self: ServletBase with JacksonJson
* Converts errors to JSON.
*/
private def toJson(errors: Seq[(String, String)]): JObject =
JObject(errors.map {
case (key, value) =>
JField(key, JString(value))
JObject(errors.map { case (key, value) =>
JField(key, JString(value))
}.toList)
}

View File

@@ -1,18 +1,20 @@
package gitbucket.core.controller
import gitbucket.core.model.WebHook
import gitbucket.core.model.activity.{CreateWikiPageInfo, DeleteWikiInfo, EditWikiPageInfo}
import gitbucket.core.service.RepositoryService.RepositoryInfo
import gitbucket.core.service.WebHookService.WebHookGollumPayload
import gitbucket.core.wiki.html
import gitbucket.core.service._
import gitbucket.core.util._
import gitbucket.core.util.StringUtil._
import gitbucket.core.util.SyntaxSugars._
import gitbucket.core.util.Implicits._
import gitbucket.core.util.Directory._
import org.scalatra.forms._
import gitbucket.core.service.*
import gitbucket.core.util.*
import gitbucket.core.util.StringUtil.*
import gitbucket.core.util.SyntaxSugars.*
import gitbucket.core.util.Implicits.*
import gitbucket.core.util.Directory.*
import org.scalatra.forms.*
import org.eclipse.jgit.api.Git
import org.scalatra.i18n.Messages
import scala.util.Using
class WikiController
@@ -24,17 +26,13 @@ class WikiController
with WebHookService
with ReadableUsersAuthenticator
with ReferrerAuthenticator
with RequestCache
trait WikiControllerBase extends ControllerBase {
self: WikiService
with RepositoryService
with AccountService
with ActivityService
with WebHookService
with ReadableUsersAuthenticator
with ReferrerAuthenticator =>
self: WikiService & RepositoryService & AccountService & ActivityService & WebHookService &
ReadableUsersAuthenticator & ReferrerAuthenticator =>
case class WikiPageEditForm(
private case class WikiPageEditForm(
pageName: String,
content: String,
message: Option[String],
@@ -42,16 +40,16 @@ trait WikiControllerBase extends ControllerBase {
id: String
)
val newForm = mapping(
"pageName" -> trim(label("Page name", text(required, maxlength(40), pagename, unique))),
private val newForm = mapping(
"pageName" -> trim(label("Page name", text(required, maxlength(40), pageName, unique))),
"content" -> trim(label("Content", text(required, conflictForNew))),
"message" -> trim(label("Message", optional(text()))),
"currentPageName" -> trim(label("Current page name", text())),
"id" -> trim(label("Latest commit id", text()))
)(WikiPageEditForm.apply)
val editForm = mapping(
"pageName" -> trim(label("Page name", text(required, maxlength(40), pagename))),
private val editForm = mapping(
"pageName" -> trim(label("Page name", text(required, maxlength(40), pageName))),
"content" -> trim(label("Content", text(required, conflictForEdit))),
"message" -> trim(label("Message", optional(text()))),
"currentPageName" -> trim(label("Current page name", text(required))),
@@ -59,46 +57,56 @@ trait WikiControllerBase extends ControllerBase {
)(WikiPageEditForm.apply)
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(
"Home",
page,
getWikiPageList(repository.owner, repository.name),
getWikiPageList(repository.owner, repository.name, branch),
repository,
isEditable(repository),
getWikiPage(repository.owner, repository.name, "_Sidebar"),
getWikiPage(repository.owner, repository.name, "_Footer")
getWikiPage(repository.owner, repository.name, "_Sidebar", branch),
getWikiPage(repository.owner, repository.name, "_Footer", branch)
)
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/Home/_edit")
})
get("/:owner/:repository/wiki/:page")(referrersOnly { repository =>
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(
pageName,
page,
getWikiPageList(repository.owner, repository.name),
getWikiPageList(repository.owner, repository.name, branch),
repository,
isEditable(repository),
getWikiPage(repository.owner, repository.name, "_Sidebar"),
getWikiPage(repository.owner, repository.name, "_Footer")
getWikiPage(repository.owner, repository.name, "_Sidebar", branch),
getWikiPage(repository.owner, repository.name, "_Footer", branch)
)
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}/_edit")
})
get("/:owner/:repository/wiki/:page/_history")(referrersOnly { repository =>
val pageName = StringUtil.urlDecode(params("page"))
val branch = getWikiBranch(repository.owner, repository.name)
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 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 =>
val pageName = StringUtil.urlDecode(params("page"))
val Array(from, to) = params("commitId").split("\\.\\.\\.")
@@ -108,7 +116,17 @@ trait WikiControllerBase extends ControllerBase {
Some(pageName),
from,
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,
isEditable(repository),
flash.get("info")
@@ -124,7 +142,15 @@ trait WikiControllerBase extends ControllerBase {
None,
from,
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,
isEditable(repository),
flash.get("info")
@@ -133,77 +159,79 @@ trait WikiControllerBase extends ControllerBase {
})
get("/:owner/:repository/wiki/:page/_revert/:commitId")(readableUsersOnly { repository =>
if (isEditable(repository)) {
val pageName = StringUtil.urlDecode(params("page"))
val Array(from, to) = params("commitId").split("\\.\\.\\.")
context.withLoginAccount { loginAccount =>
if (isEditable(repository)) {
val pageName = StringUtil.urlDecode(params("page"))
val Array(from, to) = params("commitId").split("\\.\\.\\.")
val branch = getWikiBranch(repository.owner, repository.name)
if (revertWikiPage(repository.owner, repository.name, from, to, context.loginAccount.get, Some(pageName))) {
redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}")
} else {
flash.update("info", "This patch was not able to be reversed.")
redirect(
s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}/_compare/${from}...${to}"
)
}
} else Unauthorized()
if (revertWikiPage(repository.owner, repository.name, from, to, loginAccount, Some(pageName), branch)) {
redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}")
} else {
flash.update("info", "This patch was not able to be reversed.")
redirect(
s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}/_compare/$from...$to"
)
}
} else Unauthorized()
}
})
get("/:owner/:repository/wiki/_revert/:commitId")(readableUsersOnly { repository =>
if (isEditable(repository)) {
val Array(from, to) = params("commitId").split("\\.\\.\\.")
context.withLoginAccount { loginAccount =>
if (isEditable(repository)) {
val Array(from, to) = params("commitId").split("\\.\\.\\.")
val branch = getWikiBranch(repository.owner, repository.name)
if (revertWikiPage(repository.owner, repository.name, from, to, context.loginAccount.get, None)) {
redirect(s"/${repository.owner}/${repository.name}/wiki")
} else {
flash.update("info", "This patch was not able to be reversed.")
redirect(s"/${repository.owner}/${repository.name}/wiki/_compare/${from}...${to}")
}
} else Unauthorized()
if (revertWikiPage(repository.owner, repository.name, from, to, loginAccount, None, branch)) {
redirect(s"/${repository.owner}/${repository.name}/wiki")
} else {
flash.update("info", "This patch was not able to be reversed.")
redirect(s"/${repository.owner}/${repository.name}/wiki/_compare/$from...$to")
}
} else Unauthorized()
}
})
get("/:owner/:repository/wiki/:page/_edit")(readableUsersOnly { repository =>
if (isEditable(repository)) {
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()
})
post("/:owner/:repository/wiki/_edit", editForm)(readableUsersOnly { (form, repository) =>
if (isEditable(repository)) {
defining(context.loginAccount.get) {
loginAccount =>
saveWikiPage(
repository.owner,
repository.name,
form.currentPageName,
form.pageName,
appendNewLine(convertLineSeparator(form.content, "LF"), "LF"),
loginAccount,
form.message.getOrElse(""),
Some(form.id)
).foreach {
commitId =>
updateLastActivityDate(repository.owner, repository.name)
recordEditWikiPageActivity(
repository.owner,
repository.name,
loginAccount.userName,
form.pageName,
commitId
)
callWebHookOf(repository.owner, repository.name, WebHook.Gollum, context.settings) {
getAccountByUserName(repository.owner).map { repositoryUser =>
WebHookGollumPayload("edited", form.pageName, commitId, repository, repositoryUser, loginAccount)
}
}
context.withLoginAccount { loginAccount =>
if (isEditable(repository)) {
saveWikiPage(
repository.owner,
repository.name,
form.currentPageName,
form.pageName,
appendNewLine(convertLineSeparator(form.content, "LF"), "LF"),
loginAccount,
form.message.getOrElse(""),
Some(form.id)
).foreach { commitId =>
updateLastActivityDate(repository.owner, repository.name)
val wikiEditInfo =
EditWikiPageInfo(repository.owner, repository.name, loginAccount.userName, form.pageName, commitId)
recordActivity(wikiEditInfo)
callWebHookOf(repository.owner, repository.name, WebHook.Gollum, context.settings) {
getAccountByUserName(repository.owner).map { repositoryUser =>
WebHookGollumPayload("edited", form.pageName, commitId, repository, repositoryUser, loginAccount)
}
}
if (notReservedPageName(form.pageName)) {
redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(form.pageName)}")
} else {
redirect(s"/${repository.owner}/${repository.name}/wiki")
}
}
} else Unauthorized()
}
if (notReservedPageName(form.pageName)) {
redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(form.pageName)}")
} else {
redirect(s"/${repository.owner}/${repository.name}/wiki")
}
} else Unauthorized()
}
})
get("/:owner/:repository/wiki/_new")(readableUsersOnly { repository =>
@@ -213,60 +241,67 @@ trait WikiControllerBase extends ControllerBase {
})
post("/:owner/:repository/wiki/_new", newForm)(readableUsersOnly { (form, repository) =>
if (isEditable(repository)) {
defining(context.loginAccount.get) {
loginAccount =>
saveWikiPage(
repository.owner,
repository.name,
form.currentPageName,
form.pageName,
form.content,
loginAccount,
form.message.getOrElse(""),
None
).foreach {
commitId =>
updateLastActivityDate(repository.owner, repository.name)
recordCreateWikiPageActivity(repository.owner, repository.name, loginAccount.userName, form.pageName)
callWebHookOf(repository.owner, repository.name, WebHook.Gollum, context.settings) {
getAccountByUserName(repository.owner).map { repositoryUser =>
WebHookGollumPayload("created", form.pageName, commitId, repository, repositoryUser, loginAccount)
}
}
context.withLoginAccount { loginAccount =>
if (isEditable(repository)) {
saveWikiPage(
repository.owner,
repository.name,
form.currentPageName,
form.pageName,
form.content,
loginAccount,
form.message.getOrElse(""),
None
).foreach { commitId =>
updateLastActivityDate(repository.owner, repository.name)
val createWikiPageInfo =
CreateWikiPageInfo(repository.owner, repository.name, loginAccount.userName, form.pageName)
recordActivity(createWikiPageInfo)
callWebHookOf(repository.owner, repository.name, WebHook.Gollum, context.settings) {
getAccountByUserName(repository.owner).map { repositoryUser =>
WebHookGollumPayload("created", form.pageName, commitId, repository, repositoryUser, loginAccount)
}
}
}
if (notReservedPageName(form.pageName)) {
redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(form.pageName)}")
} else {
redirect(s"/${repository.owner}/${repository.name}/wiki")
}
}
} else Unauthorized()
if (notReservedPageName(form.pageName)) {
redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(form.pageName)}")
} else {
redirect(s"/${repository.owner}/${repository.name}/wiki")
}
} else Unauthorized()
}
})
get("/:owner/:repository/wiki/:page/_delete")(readableUsersOnly { repository =>
if (isEditable(repository)) {
val pageName = StringUtil.urlDecode(params("page"))
defining(context.loginAccount.get) { loginAccount =>
context.withLoginAccount { loginAccount =>
if (isEditable(repository)) {
val pageName = StringUtil.urlDecode(params("page"))
deleteWikiPage(
repository.owner,
repository.name,
pageName,
loginAccount.fullName,
loginAccount.mailAddress,
s"Destroyed ${pageName}"
s"Destroyed $pageName"
)
val deleteWikiInfo = DeleteWikiInfo(
repository.owner,
repository.name,
loginAccount.userName,
pageName
)
recordActivity(deleteWikiInfo)
updateLastActivityDate(repository.owner, repository.name)
redirect(s"/${repository.owner}/${repository.name}/wiki")
}
} else Unauthorized()
} else Unauthorized()
}
})
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 =>
@@ -295,24 +330,29 @@ trait WikiControllerBase extends ControllerBase {
value: String,
params: Map[String, Seq[String]],
messages: Messages
): Option[String] =
getWikiPageList(params.value("owner"), params.value("repository"))
): Option[String] = {
val owner = params.value("owner")
val repository = params.value("repository")
val branch = getWikiBranch(owner, repository)
getWikiPageList(owner, repository, branch)
.find(_ == value)
.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] =
if (value.exists("\\/:*?\"<>|".contains(_))) {
Some(s"${name} contains invalid character.")
Some(s"$name contains invalid character.")
} else if (notReservedPageName(value) && (value.startsWith("_") || value.startsWith("-"))) {
Some(s"${name} starts with invalid character.")
Some(s"$name starts with invalid character.")
} else {
None
}
}
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() {
override def validate(name: String, value: String, messages: Messages): Option[String] = {
@@ -330,7 +370,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 = {
repository.repository.options.wikiOption match {

View File

@@ -1,75 +1,160 @@
package gitbucket.core.controller.api
import gitbucket.core.api.{ApiObject, ApiRef, JsonFormat}
import gitbucket.core.api.{ApiError, ApiRef, CreateARef, JsonFormat, UpdateARef}
import gitbucket.core.controller.ControllerBase
import gitbucket.core.service.RepositoryService.RepositoryInfo
import gitbucket.core.util.Directory.getRepositoryDir
import gitbucket.core.util.ReferrerAuthenticator
import gitbucket.core.util.Implicits._
import gitbucket.core.util.{ReferrerAuthenticator, RepositoryName, WritableUsersAuthenticator}
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.ObjectId
import org.eclipse.jgit.lib.RefUpdate.Result
import org.scalatra.{BadRequest, NoContent, UnprocessableEntity}
import org.slf4j.LoggerFactory
import scala.jdk.CollectionConverters._
import scala.util.Using
trait ApiGitReferenceControllerBase extends ControllerBase {
self: ReferrerAuthenticator =>
self: ReferrerAuthenticator & WritableUsersAuthenticator =>
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
* https://developer.github.com/v3/git/refs/#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 =>
getRef()
val revstr = multiParams("splat").head
getRef(revstr, repository)
})
// Some versions of GHE support this path
get("/api/v3/repos/:owner/:repository/git/refs/*")(referrersOnly { repository =>
logger.warn("git/refs/ endpoint may not be compatible with GitHub API v3. Consider using git/ref/ endpoint instead")
getRef()
})
private def getRef() = {
val revstr = multiParams("splat").head
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
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))
})
}
}
}
getRef(revstr, repository)
})
/*
* ii. Get all references
* https://developer.github.com/v3/git/refs/#get-all-references
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#list-matching-references
*/
/*
* iii. Create a reference
* https://developer.github.com/v3/git/refs/#create-a-reference
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#create-a-reference
*/
post("/api/v3/repos/:owner/:repository/git/refs")(writableUsersOnly { repository =>
extractFromJsonBody[CreateARef].map { data =>
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
val ref = git.getRepository.findRef(data.ref)
if (ref == null) {
val update = git.getRepository.updateRef(data.ref)
update.setNewObjectId(ObjectId.fromString(data.sha))
val result = update.update()
result match {
case Result.NEW =>
JsonFormat(
ApiRef
.fromRef(RepositoryName(repository.owner, repository.name), git.getRepository.findRef(data.ref))
)
case _ => UnprocessableEntity(result.name())
}
} else {
UnprocessableEntity("Ref already exists.")
}
}
} getOrElse BadRequest()
})
/*
* iv. Update a reference
* https://developer.github.com/v3/git/refs/#update-a-reference
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#update-a-reference
*/
patch("/api/v3/repos/:owner/:repository/git/refs/*")(writableUsersOnly { repository =>
val refName = multiParams("splat").mkString("/")
extractFromJsonBody[UpdateARef].map { data =>
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
val ref = git.getRepository.findRef(refName)
if (ref == null) {
UnprocessableEntity("Ref does not exist.")
} else {
val update = git.getRepository.updateRef(ref.getName)
update.setNewObjectId(ObjectId.fromString(data.sha))
update.setForceUpdate(data.force)
val result = update.update()
result match {
case Result.FORCED | Result.FAST_FORWARD | Result.NO_CHANGE =>
JsonFormat(ApiRef.fromRef(RepositoryName(repository), git.getRepository.findRef(refName)))
case _ => UnprocessableEntity(result.name())
}
}
}
} getOrElse BadRequest()
})
/*
* v. Delete a reference
* https://developer.github.com/v3/git/refs/#delete-a-reference
*/
* v. Delete a reference
* https://docs.github.com/en/free-pro-team@latest/rest/reference/git#delete-a-reference
*/
delete("/api/v3/repos/:owner/:repository/git/refs/*")(writableUsersOnly { _ =>
val refName = multiParams("splat").mkString("/")
Using.resource(Git.open(getRepositoryDir(params("owner"), params("repository")))) { git =>
val ref = git.getRepository.findRef(refName)
if (ref == null) {
UnprocessableEntity("Ref does not exist.")
} else {
val update = git.getRepository.updateRef(ref.getName)
update.setForceUpdate(true)
val result = update.delete()
result match {
case Result.FORCED => NoContent()
case _ => UnprocessableEntity(result.name())
}
}
}
})
private def notFound(): ApiError = {
response.setStatus(404)
ApiError("Not Found")
}
protected def getRef(revstr: String, repository: RepositoryInfo): AnyRef = {
logger.debug(s"getRef: path '${revstr}'")
val name = RepositoryName(repository)
val result = JsonFormat(revstr match {
case "tags" => repository.tags.map(ApiRef.fromTag(name, _))
case x if x.startsWith("tags/") =>
val tagName = x.substring("tags/".length)
repository.tags.find(_.name == tagName) match {
case Some(tagInfo) => ApiRef.fromTag(name, tagInfo)
case None => notFound()
}
case other =>
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
git.getRepository().findRef(other) match {
case null => notFound()
case ref => ApiRef.fromRef(name, ref)
}
}
})
logger.debug(s"json result: $result")
result
}
}

View File

@@ -4,44 +4,111 @@ import gitbucket.core.controller.{Context, ControllerBase}
import gitbucket.core.service._
import gitbucket.core.util.Implicits._
import gitbucket.core.util.{ReadableUsersAuthenticator, ReferrerAuthenticator, RepositoryName}
import org.scalatra.ActionResult
trait ApiIssueCommentControllerBase extends ControllerBase {
self: AccountService
with IssuesService
with RepositoryService
with HandleCommentService
with MilestonesService
with ReadableUsersAuthenticator
with ReferrerAuthenticator =>
self: AccountService & IssuesService & RepositoryService & HandleCommentService & MilestonesService &
ReadableUsersAuthenticator & ReferrerAuthenticator =>
/*
* i. List comments on an issue
* https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
* i. List issue comments for a repository
* https://docs.github.com/en/rest/reference/issues#list-issue-comments-for-a-repository
*/
get("/api/v3/repos/:owner/:repository/issues/:id/comments")(referrersOnly { repository =>
(for {
issueId <- params("id").toIntOpt
comments = getCommentsForApi(repository.owner, repository.name, issueId)
} yield {
JsonFormat(comments.map {
case (issueComment, user, issue) =>
ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(user), issue.isPullRequest)
JsonFormat(comments.map { case (issueComment, user, issue) =>
ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(user), issue.isPullRequest)
})
}) getOrElse NotFound()
})
/*
* ii. List comments in a repository
* https://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
* ii. Get an issue comment
* https://docs.github.com/en/rest/reference/issues#get-an-issue-comment
*/
get("/api/v3/repos/:owner/:repository/issues/comments/:id")(referrersOnly { repository =>
val commentId = params("id").toInt
getCommentForApi(repository.owner, repository.name, commentId) match {
case Some((issueComment, user, issue)) =>
JsonFormat(
ApiComment(issueComment, RepositoryName(repository), issue.issueId, ApiUser(user), issue.isPullRequest)
)
case _ => NotFound()
}
})
/*
* iii. Update an issue comment
* https://docs.github.com/en/rest/reference/issues#update-an-issue-comment
*/
patch("/api/v3/repos/:owner/:repository/issues/comments/:id")(readableUsersOnly { repository =>
val commentId = params("id")
val result = for {
issueComment <- getComment(repository.owner, repository.name, commentId)
issue <- getIssue(repository.owner, repository.name, issueComment.issueId.toString)
} yield {
if (isEditable(repository.owner, repository.name, issueComment.commentedUserName)) {
val body = extractFromJsonBody[CreateAComment].map(_.body)
updateCommentByApi(repository, issue, issueComment.commentId.toString, body)
getComment(repository.owner, repository.name, commentId) match {
case Some(issueComment) =>
JsonFormat(
ApiComment(
issueComment,
RepositoryName(repository),
issue.issueId,
ApiUser(context.loginAccount.get),
issue.isPullRequest
)
)
case _ =>
}
} else {
Unauthorized()
}
}
result match {
case Some(response) => response
case None => NotFound()
}
})
/*
* iv. Delete a comment
* https://docs.github.com/en/rest/reference/issues#delete-an-issue-comment
*/
delete("/api/v3/repos/:owner/:repository/issues/comments/:id")(readableUsersOnly { repository =>
val maybeDeleteResponse: Option[Either[ActionResult, Option[Int]]] =
for {
commentId <- params("id").toIntOpt
comment <- getComment(repository.owner, repository.name, commentId.toString)
issue <- getIssue(repository.owner, repository.name, comment.issueId.toString)
} yield {
if (isEditable(repository.owner, repository.name, comment.commentedUserName)) {
val maybeDeletedComment = deleteCommentByApi(repository, comment, issue)
Right(maybeDeletedComment.map(_.commentId))
} else {
Left(Unauthorized())
}
}
maybeDeleteResponse
.map {
case Right(maybeDeletedCommentId) => maybeDeletedCommentId.getOrElse(NotFound())
case Left(err) => err
}
.getOrElse(NotFound())
})
/*
* v. List issue comments
* https://docs.github.com/en/rest/reference/issues#list-issue-comments
*/
/*
* iii. Get a single comment
* https://developer.github.com/v3/issues/comments/#get-a-single-comment
*/
/*
* iv. Create a comment
* https://developer.github.com/v3/issues/comments/#create-a-comment
* vi. Create an issue comment
* https://docs.github.com/en/rest/reference/issues#create-an-issue-comment
*/
post("/api/v3/repos/:owner/:repository/issues/:id/comments")(readableUsersOnly { repository =>
(for {
@@ -64,16 +131,6 @@ trait ApiIssueCommentControllerBase extends ControllerBase {
}) getOrElse NotFound()
})
/*
* v. Edit a comment
* https://developer.github.com/v3/issues/comments/#edit-a-comment
*/
/*
* vi. Delete a comment
* https://developer.github.com/v3/issues/comments/#delete-a-comment
*/
private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean =
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
}

View File

@@ -5,16 +5,12 @@ import gitbucket.core.model.{Account, Issue}
import gitbucket.core.service.{AccountService, IssueCreationService, IssuesService, MilestonesService}
import gitbucket.core.service.IssuesService.IssueSearchCondition
import gitbucket.core.service.PullRequestService.PullRequestLimit
import gitbucket.core.util.{ReadableUsersAuthenticator, ReferrerAuthenticator, RepositoryName, UsersAuthenticator}
import gitbucket.core.util.{ReadableUsersAuthenticator, ReferrerAuthenticator, RepositoryName}
import gitbucket.core.util.Implicits._
trait ApiIssueControllerBase extends ControllerBase {
self: AccountService
with IssuesService
with IssueCreationService
with MilestonesService
with ReadableUsersAuthenticator
with ReferrerAuthenticator =>
self: AccountService & IssuesService & IssueCreationService & MilestonesService & ReadableUsersAuthenticator &
ReferrerAuthenticator =>
/*
* i. List issues
* https://developer.github.com/v3/issues/#list-issues
@@ -29,9 +25,9 @@ trait ApiIssueControllerBase extends ControllerBase {
val page = IssueSearchCondition.page(request)
// TODO: more api spec condition
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(
condition = condition,
offset = (page - 1) * PullRequestLimit,
@@ -39,16 +35,16 @@ trait ApiIssueControllerBase extends ControllerBase {
repos = repository.owner -> repository.name
)
JsonFormat(issues.map {
case (issue, issueUser, assignedUser) =>
ApiIssue(
issue = issue,
repositoryName = RepositoryName(repository),
user = ApiUser(issueUser),
assignee = assignedUser.map(ApiUser(_)),
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
.map(ApiLabel(_, RepositoryName(repository)))
)
JsonFormat(issues.map { case (issue, issueUser, assigneeUsers) =>
ApiIssue(
issue = issue,
repositoryName = RepositoryName(repository),
user = ApiUser(issueUser),
assignees = assigneeUsers.map(ApiUser(_)),
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
.map(ApiLabel(_, RepositoryName(repository))),
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
)
})
})
@@ -60,7 +56,8 @@ trait ApiIssueControllerBase extends ControllerBase {
(for {
issueId <- params("id").toIntOpt
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)
} yield {
JsonFormat(
@@ -68,8 +65,9 @@ trait ApiIssueControllerBase extends ControllerBase {
issue,
RepositoryName(repository),
ApiUser(openedUser),
issue.assignedUserName.flatMap(users.get(_)).map(ApiUser(_)),
getIssueLabels(repository.owner, repository.name, issue.issueId).map(ApiLabel(_, RepositoryName(repository)))
assigneeUsers.flatMap(x => users.get(x.assigneeUserName)).map(ApiUser(_)),
getIssueLabels(repository.owner, repository.name, issue.issueId).map(ApiLabel(_, RepositoryName(repository))),
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
)
)
}) getOrElse NotFound()
@@ -90,7 +88,7 @@ trait ApiIssueControllerBase extends ControllerBase {
repository,
data.title,
data.body,
data.assignees.headOption,
data.assignees,
milestone.map(_.milestoneId),
None,
data.labels,
@@ -101,9 +99,12 @@ trait ApiIssueControllerBase extends ControllerBase {
issue,
RepositoryName(repository),
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)
.map(ApiLabel(_, RepositoryName(repository)))
.map(ApiLabel(_, RepositoryName(repository))),
issue.milestoneId.flatMap { getApiMilestone(repository, _) }
)
)
}) getOrElse NotFound()
@@ -120,7 +121,7 @@ trait ApiIssueControllerBase extends ControllerBase {
*/
/*
* vii. Unlock an issue
* https://developer.github.com/v3/issues/#unlock-an-issue
*/
* vii. Unlock an issue
* https://developer.github.com/v3/issues/#unlock-an-issue
*/
}

View File

@@ -1,5 +1,5 @@
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.service._
import gitbucket.core.util.Implicits._
@@ -7,11 +7,7 @@ import gitbucket.core.util._
import org.scalatra.{Created, NoContent, UnprocessableEntity}
trait ApiIssueLabelControllerBase extends ControllerBase {
self: AccountService
with IssuesService
with LabelsService
with ReferrerAuthenticator
with WritableUsersAuthenticator =>
self: AccountService & IssuesService & LabelsService & ReferrerAuthenticator & WritableUsersAuthenticator =>
/*
* i. List all labels for this repository
@@ -69,25 +65,24 @@ trait ApiIssueLabelControllerBase extends ControllerBase {
data <- extractFromJsonBody[CreateALabel] if data.isValid
} yield {
LockUtil.lock(RepositoryName(repository).fullName) {
getLabel(repository.owner, repository.name, params("labelName")).map {
label =>
if (getLabel(repository.owner, repository.name, data.name).isEmpty) {
updateLabel(repository.owner, repository.name, label.labelId, data.name, data.color)
JsonFormat(
ApiLabel(
getLabel(repository.owner, repository.name, label.labelId).get,
RepositoryName(repository)
)
getLabel(repository.owner, repository.name, params("labelName")).map { label =>
if (getLabel(repository.owner, repository.name, data.name).isEmpty) {
updateLabel(repository.owner, repository.name, label.labelId, data.name, data.color)
JsonFormat(
ApiLabel(
getLabel(repository.owner, repository.name, label.labelId).get,
RepositoryName(repository)
)
} else {
// TODO ApiError should support errors field to enhance compatibility of GitHub API
UnprocessableEntity(
ApiError(
"Validation Failed",
Some("https://developer.github.com/v3/issues/labels/#create-a-label")
)
)
} else {
// TODO ApiError should support errors field to enhance compatibility of GitHub API
UnprocessableEntity(
ApiError(
"Validation Failed",
Some("https://developer.github.com/v3/issues/labels/#create-a-label")
)
}
)
}
} getOrElse NotFound()
}
}) getOrElse NotFound()
@@ -121,10 +116,10 @@ trait ApiIssueLabelControllerBase extends ControllerBase {
*/
post("/api/v3/repos/:owner/:repository/issues/:id/labels")(writableUsersOnly { repository =>
JsonFormat(for {
data <- extractFromJsonBody[Seq[String]];
data <- extractFromJsonBody[AddLabelsToAnIssue]
issueId <- params("id").toIntOpt
} yield {
data.map { labelName =>
data.labels.map { labelName =>
val label = getLabel(repository.owner, repository.name, labelName).getOrElse(
getLabel(
repository.owner,
@@ -160,11 +155,11 @@ trait ApiIssueLabelControllerBase extends ControllerBase {
*/
put("/api/v3/repos/:owner/:repository/issues/:id/labels")(writableUsersOnly { repository =>
JsonFormat(for {
data <- extractFromJsonBody[Seq[String]];
data <- extractFromJsonBody[AddLabelsToAnIssue]
issueId <- params("id").toIntOpt
} yield {
deleteAllIssueLabels(repository.owner, repository.name, issueId, true)
data.map { labelName =>
data.labels.map { labelName =>
val label = getLabel(repository.owner, repository.name, labelName).getOrElse(
getLabel(
repository.owner,
@@ -189,7 +184,7 @@ trait ApiIssueLabelControllerBase extends ControllerBase {
})
/*
* xi Get labels for every issue in a milestone
* https://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone
*/
* xi Get labels for every issue in a milestone
* https://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone
*/
}

View File

@@ -0,0 +1,106 @@
package gitbucket.core.controller.api
import gitbucket.core.api._
import gitbucket.core.controller.ControllerBase
import gitbucket.core.service.MilestonesService
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
import gitbucket.core.util.Implicits._
import org.scalatra.NoContent
trait ApiIssueMilestoneControllerBase extends ControllerBase {
self: MilestonesService & WritableUsersAuthenticator & ReferrerAuthenticator =>
/*
* i. List milestones
* https://docs.github.com/en/rest/reference/issues#list-milestones
*/
get("/api/v3/repos/:owner/:repository/milestones")(referrersOnly { repository =>
val state = params.getOrElse("state", "all")
// TODO "sort", "direction" params should be implemented.
val apiMilestones = (for (
milestoneWithIssue <- getMilestonesWithIssueCount(repository.owner, repository.name)
.sortBy(p => p._1.milestoneId)
)
yield {
ApiMilestone(
repository.repository,
milestoneWithIssue._1,
milestoneWithIssue._2,
milestoneWithIssue._3
)
}).reverse
state match {
case "all" => JsonFormat(apiMilestones)
case "open" | "closed" =>
JsonFormat(
apiMilestones.filter(p => p.state == state)
)
case _ => NotFound()
}
})
/*
* ii. Create a milestone
* https://docs.github.com/en/rest/reference/issues#create-a-milestone
*/
post("/api/v3/repos/:owner/:repository/milestones")(writableUsersOnly { repository =>
(for {
data <- extractFromJsonBody[CreateAMilestone] if data.isValid
milestoneId = createMilestone(
repository.owner,
repository.name,
data.title,
data.description,
data.due_on
)
apiMilestone <- getApiMilestone(repository, milestoneId)
} yield {
JsonFormat(apiMilestone)
}) getOrElse NotFound()
})
/*
* iii. Get a milestone
* https://docs.github.com/en/rest/reference/issues#get-a-milestone
*/
get("/api/v3/repos/:owner/:repository/milestones/:number")(referrersOnly { repository =>
val milestoneId = params("number").toInt // use milestoneId as number
(for (apiMilestone <- getApiMilestone(repository, milestoneId)) yield {
JsonFormat(apiMilestone)
}) getOrElse NotFound()
})
/*
* iv.Update a milestone
* https://docs.github.com/en/rest/reference/issues#update-a-milestone
*/
patch("/api/v3/repos/:owner/:repository/milestones/:number")(writableUsersOnly { repository =>
val milestoneId = params("number").toInt
(for {
data <- extractFromJsonBody[CreateAMilestone] if data.isValid
milestone <- getMilestone(repository.owner, repository.name, milestoneId)
_ = (data.state, milestone.closedDate) match {
case ("open", Some(_)) =>
openMilestone(milestone)
case ("closed", None) =>
closeMilestone(milestone)
case _ =>
}
milestone <- getMilestone(repository.owner, repository.name, milestoneId)
_ = updateMilestone(milestone.copy(title = data.title, description = data.description, dueDate = data.due_on))
apiMilestone <- getApiMilestone(repository, milestoneId)
} yield {
JsonFormat(apiMilestone)
}) getOrElse NotFound()
})
/*
* v. Delete a milestone
* https://docs.github.com/en/rest/reference/issues#delete-a-milestone
*/
delete("/api/v3/repos/:owner/:repository/milestones/:number")(writableUsersOnly { repository =>
val milestoneId = params("number").toInt // use milestoneId as number
deleteMilestone(repository.owner, repository.name, milestoneId)
NoContent()
})
}

View File

@@ -1,12 +1,12 @@
package gitbucket.core.controller.api
import gitbucket.core.api.{ApiGroup, CreateAGroup, ApiRepository, ApiUser, JsonFormat}
import gitbucket.core.api.{ApiGroup, CreateAGroup, JsonFormat}
import gitbucket.core.controller.ControllerBase
import gitbucket.core.service.{AccountService, RepositoryService}
import gitbucket.core.util.Implicits._
import gitbucket.core.util.{AdminAuthenticator, UsersAuthenticator}
trait ApiOrganizationControllerBase extends ControllerBase {
self: RepositoryService with AccountService with AdminAuthenticator with UsersAuthenticator =>
self: RepositoryService & AccountService & AdminAuthenticator & UsersAuthenticator =>
/*
* i. List your organizations
@@ -71,6 +71,6 @@ trait ApiOrganizationControllerBase extends ControllerBase {
*/
/*
* should implement delete an organization API?
*/
* should implement delete an organization API?
*/
}

View File

@@ -10,20 +10,14 @@ import gitbucket.core.util.Implicits._
import gitbucket.core.util.JGitUtil.CommitInfo
import gitbucket.core.util._
import org.eclipse.jgit.api.Git
import org.scalatra.NoContent
import org.scalatra.{Conflict, MethodNotAllowed, NoContent, Ok}
import scala.util.Using
import scala.jdk.CollectionConverters._
trait ApiPullRequestControllerBase extends ControllerBase {
self: AccountService
with IssuesService
with PullRequestService
with RepositoryService
with MergeService
with ReferrerAuthenticator
with ReadableUsersAuthenticator
with WritableUsersAuthenticator =>
self: AccountService & IssuesService & PullRequestService & RepositoryService & MergeService & ReferrerAuthenticator &
ReadableUsersAuthenticator & WritableUsersAuthenticator =>
/*
* i. Link Relations
@@ -40,7 +34,7 @@ trait ApiPullRequestControllerBase extends ControllerBase {
val condition = IssueSearchCondition(request)
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(
condition = condition,
offset = (page - 1) * PullRequestLimit,
@@ -48,19 +42,18 @@ trait ApiPullRequestControllerBase extends ControllerBase {
repos = repository.owner -> repository.name
)
JsonFormat(issues.map {
case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner, assignee) =>
ApiPullRequest(
issue = issue,
pullRequest = pullRequest,
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
baseRepo = ApiRepository(repository, ApiUser(baseOwner)),
user = ApiUser(issueUser),
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
.map(ApiLabel(_, RepositoryName(repository))),
assignee = assignee.map(ApiUser.apply),
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
)
JsonFormat(issues.map { case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner, assignees) =>
ApiPullRequest(
issue = issue,
pullRequest = pullRequest,
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
baseRepo = ApiRepository(repository, ApiUser(baseOwner)),
user = ApiUser(issueUser),
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
.map(ApiLabel(_, RepositoryName(repository))),
assignees = assignees.map(ApiUser.apply),
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
)
})
})
@@ -89,39 +82,37 @@ trait ApiPullRequestControllerBase extends ControllerBase {
case Left(createPullReq) =>
val (reqOwner, reqBranch) = parseCompareIdentifier(createPullReq.head, repository.owner)
getRepository(reqOwner, repository.name)
.flatMap {
forkedRepository =>
getPullRequestCommitFromTo(repository, forkedRepository, createPullReq.base, reqBranch) match {
case (Some(commitIdFrom), Some(commitIdTo)) =>
val issueId = insertIssue(
owner = repository.owner,
repository = repository.name,
loginUser = context.loginAccount.get.userName,
title = createPullReq.title,
content = createPullReq.body,
assignedUserName = None,
milestoneId = None,
priorityId = None,
isPullRequest = true
)
.flatMap { forkedRepository =>
getPullRequestCommitFromTo(repository, forkedRepository, createPullReq.base, reqBranch) match {
case (Some(commitIdFrom), Some(commitIdTo)) =>
val issueId = insertIssue(
owner = repository.owner,
repository = repository.name,
loginUser = context.loginAccount.get.userName,
title = createPullReq.title,
content = createPullReq.body,
milestoneId = None,
priorityId = None,
isPullRequest = true
)
createPullRequest(
originRepository = repository,
issueId = issueId,
originBranch = createPullReq.base,
requestUserName = reqOwner,
requestRepositoryName = repository.name,
requestBranch = reqBranch,
commitIdFrom = commitIdFrom.getName,
commitIdTo = commitIdTo.getName,
isDraft = createPullReq.draft.getOrElse(false),
loginAccount = context.loginAccount.get,
settings = context.settings
)
getApiPullRequest(repository, issueId).map(JsonFormat(_))
case _ =>
None
}
createPullRequest(
originRepository = repository,
issueId = issueId,
originBranch = createPullReq.base,
requestUserName = reqOwner,
requestRepositoryName = repository.name,
requestBranch = reqBranch,
commitIdFrom = commitIdFrom.getName,
commitIdTo = commitIdTo.getName,
isDraft = createPullReq.draft.getOrElse(false),
loginAccount = context.loginAccount.get,
settings = context.settings
)
getApiPullRequest(repository, issueId).map(JsonFormat(_))
case _ =>
None
}
}
.getOrElse {
NotFound()
@@ -129,28 +120,27 @@ trait ApiPullRequestControllerBase extends ControllerBase {
case Right(createPullReqAlt) =>
val (reqOwner, reqBranch) = parseCompareIdentifier(createPullReqAlt.head, repository.owner)
getRepository(reqOwner, repository.name)
.flatMap {
forkedRepository =>
getPullRequestCommitFromTo(repository, forkedRepository, createPullReqAlt.base, reqBranch) match {
case (Some(commitIdFrom), Some(commitIdTo)) =>
changeIssueToPullRequest(repository.owner, repository.name, createPullReqAlt.issue)
createPullRequest(
originRepository = repository,
issueId = createPullReqAlt.issue,
originBranch = createPullReqAlt.base,
requestUserName = reqOwner,
requestRepositoryName = repository.name,
requestBranch = reqBranch,
commitIdFrom = commitIdFrom.getName,
commitIdTo = commitIdTo.getName,
isDraft = false,
loginAccount = context.loginAccount.get,
settings = context.settings
)
getApiPullRequest(repository, createPullReqAlt.issue).map(JsonFormat(_))
case _ =>
None
}
.flatMap { forkedRepository =>
getPullRequestCommitFromTo(repository, forkedRepository, createPullReqAlt.base, reqBranch) match {
case (Some(commitIdFrom), Some(commitIdTo)) =>
changeIssueToPullRequest(repository.owner, repository.name, createPullReqAlt.issue)
createPullRequest(
originRepository = repository,
issueId = createPullReqAlt.issue,
originBranch = createPullReqAlt.base,
requestUserName = reqOwner,
requestRepositoryName = repository.name,
requestBranch = reqBranch,
commitIdFrom = commitIdFrom.getName,
commitIdTo = commitIdTo.getName,
isDraft = false,
loginAccount = context.loginAccount.get,
settings = context.settings
)
getApiPullRequest(repository, createPullReqAlt.issue).map(JsonFormat(_))
case _ =>
None
}
}
.getOrElse {
NotFound()
@@ -161,8 +151,28 @@ trait ApiPullRequestControllerBase extends ControllerBase {
/*
* v. Update a pull request
* https://developer.github.com/v3/pulls/#update-a-pull-request
* https://docs.github.com/en/rest/reference/pulls#update-a-pull-request
*/
patch("/api/v3/repos/:owner/:repository/pulls/:id")(referrersOnly { repository =>
(for {
issueId <- params("id").toIntOpt
account <- context.loginAccount
settings = context.settings
data <- extractFromJsonBody[UpdateAPullRequest]
} yield {
updatePullRequestsByApi(
repository,
issueId,
account,
settings,
data.title,
data.body,
data.state,
data.base
)
JsonFormat(getApiPullRequest(repository, issueId))
}) getOrElse NotFound()
})
/*
* vi. List commits on a pull request
@@ -171,26 +181,24 @@ trait ApiPullRequestControllerBase extends ControllerBase {
get("/api/v3/repos/:owner/:repository/pulls/:id/commits")(referrersOnly { repository =>
val owner = repository.owner
val name = repository.name
params("id").toIntOpt.flatMap {
issueId =>
getPullRequest(owner, name, issueId) map {
case (issue, pullreq) =>
Using.resource(Git.open(getRepositoryDir(owner, name))) { git =>
val oldId = git.getRepository.resolve(pullreq.commitIdFrom)
val newId = git.getRepository.resolve(pullreq.commitIdTo)
val repoFullName = RepositoryName(repository)
val commits = git.log
.addRange(oldId, newId)
.call
.iterator
.asScala
.map { c =>
ApiCommitListItem(new CommitInfo(c), repoFullName)
}
.toList
JsonFormat(commits)
params("id").toIntOpt.flatMap { issueId =>
getPullRequest(owner, name, issueId) map { case (issue, pullreq) =>
Using.resource(Git.open(getRepositoryDir(owner, name))) { git =>
val oldId = git.getRepository.resolve(pullreq.commitIdFrom)
val newId = git.getRepository.resolve(pullreq.commitIdTo)
val repoFullName = RepositoryName(repository)
val commits = git.log
.addRange(oldId, newId)
.call
.iterator
.asScala
.map { c =>
ApiCommitListItem(new CommitInfo(c), repoFullName)
}
.toList
JsonFormat(commits)
}
}
} getOrElse NotFound()
})
/*
@@ -210,15 +218,79 @@ trait ApiPullRequestControllerBase extends ControllerBase {
if (checkConflict(repository.owner, repository.name, pullReq.branch, issueId).isDefined) {
NoContent
} else {
NotFound
NotFound()
}
}).getOrElse(NotFound)
}).getOrElse(NotFound())
})
/*
* ix. Merge a pull request (Merge Button)
* https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
* https://docs.github.com/en/rest/reference/pulls#merge-a-pull-request
*/
put("/api/v3/repos/:owner/:repository/pulls/:id/merge")(referrersOnly { repository =>
(for {
// TODO: crash when body is empty
// TODO: Implement sha parameter
data <- extractFromJsonBody[MergeAPullRequest]
issueId <- params("id").toIntOpt
(issue, pullReq) <- getPullRequest(repository.owner, repository.name, issueId)
} yield {
if (checkConflict(repository.owner, repository.name, pullReq.branch, issueId).isDefined) {
Conflict(
JsonFormat(
FailToMergePrResponse(
message = "Head branch was modified. Review and try the merge again.",
documentation_url = "https://docs.github.com/en/rest/reference/pulls#merge-a-pull-request",
)
)
)
} else {
if (issue.closed) {
MethodNotAllowed(
JsonFormat(
FailToMergePrResponse(
message = "Pull Request is not mergeable, Closed",
documentation_url = "https://docs.github.com/en/rest/reference/pulls#merge-a-pull-request",
)
)
)
} else {
val strategy =
if (data.merge_method.getOrElse("merge-commit") == "merge") "merge-commit"
else data.merge_method.getOrElse("merge-commit")
mergePullRequest(
repository,
issueId,
context.loginAccount.get,
data.commit_message.getOrElse(""), // TODO: Implement commit_title
strategy,
pullReq.isDraft,
context.settings
) match {
case Right(objectId) =>
Ok(
JsonFormat(
SuccessToMergePrResponse(
sha = objectId.toString,
merged = true,
message = "Pull Request successfully merged"
)
)
)
case Left(message) =>
MethodNotAllowed(
JsonFormat(
FailToMergePrResponse(
message = "Pull Request is not mergeable",
documentation_url = "https://docs.github.com/en/rest/reference/pulls#merge-a-pull-request",
)
)
)
}
}
}
})
})
/*
* x. Labels, assignees, and milestones
@@ -235,8 +307,8 @@ trait ApiPullRequestControllerBase extends ControllerBase {
baseOwner <- users.get(repository.owner)
headOwner <- users.get(pullRequest.requestUserName)
issueUser <- users.get(issue.openedUserName)
assignee = issue.assignedUserName.flatMap { userName =>
getAccountByUserName(userName, false)
assignees = getIssueAssignees(repository.owner, repository.name, issueId).flatMap { assignedUser =>
getAccountByUserName(assignedUser.assigneeUserName, false)
}
headRepo <- getRepository(pullRequest.requestUserName, pullRequest.requestRepositoryName)
} yield {
@@ -248,7 +320,7 @@ trait ApiPullRequestControllerBase extends ControllerBase {
user = ApiUser(issueUser),
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
.map(ApiLabel(_, RepositoryName(repository))),
assignee = assignee.map(ApiUser.apply),
assignees = assignees.map(ApiUser.apply),
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
)
}

View File

@@ -1,5 +1,5 @@
package gitbucket.core.controller.api
import java.io.{ByteArrayInputStream, File}
import java.io.File
import gitbucket.core.api._
import gitbucket.core.controller.ControllerBase
@@ -7,12 +7,11 @@ import gitbucket.core.service.{AccountService, ReleaseService}
import gitbucket.core.util.Directory.getReleaseFilesDir
import gitbucket.core.util.{FileUtil, ReferrerAuthenticator, RepositoryName, WritableUsersAuthenticator}
import gitbucket.core.util.Implicits._
import gitbucket.core.util.SyntaxSugars.defining
import org.apache.commons.io.FileUtils
import org.scalatra.{Created, NoContent}
import org.scalatra.NoContent
trait ApiReleaseControllerBase extends ControllerBase {
self: AccountService with ReleaseService with ReferrerAuthenticator with WritableUsersAuthenticator =>
self: AccountService & ReleaseService & ReferrerAuthenticator & WritableUsersAuthenticator =>
/**
* i. List releases for a repository
@@ -87,7 +86,7 @@ trait ApiReleaseControllerBase extends ControllerBase {
/**
* vi. Edit a release
* https://developer.github.com/v3/repos/releases/#edit-a-release
* Incompatiblity info: GitHub API requires :release_id, but GitBucket API requires :tag_name
* Incompatibility info: GitHub API requires :release_id, but GitBucket API requires :tag_name
*/
patch("/api/v3/repos/:owner/:repository/releases/:tag")(writableUsersOnly { repository =>
(for {
@@ -104,7 +103,7 @@ trait ApiReleaseControllerBase extends ControllerBase {
/**
* vii. Delete a release
* https://developer.github.com/v3/repos/releases/#delete-a-release
* Incompatiblity info: GitHub API requires :release_id, but GitBucket API requires :tag_name
* Incompatibility info: GitHub API requires :release_id, but GitBucket API requires :tag_name
*/
delete("/api/v3/repos/:owner/:repository/releases/:tag")(writableUsersOnly { repository =>
val tag = params("tag")
@@ -124,34 +123,32 @@ trait ApiReleaseControllerBase extends ControllerBase {
val name = params("name")
val tag = params("tag")
getRelease(repository.owner, repository.name, tag)
.map {
release =>
defining(FileUtil.generateFileId) { fileId =>
val buf = new Array[Byte](request.inputStream.available())
request.inputStream.read(buf)
FileUtils.writeByteArrayToFile(
new File(
getReleaseFilesDir(repository.owner, repository.name),
FileUtil.checkFilename(tag + "/" + fileId)
),
buf
)
createReleaseAsset(
repository.owner,
repository.name,
tag,
fileId,
name,
request.contentLength.getOrElse(0),
context.loginAccount.get
)
getReleaseAsset(repository.owner, repository.name, tag, fileId)
.map { asset =>
JsonFormat(ApiReleaseAsset(asset, RepositoryName(repository)))
}
.getOrElse {
ApiError("Unknown error")
}
.map { release =>
val fileId = FileUtil.generateFileId
val buf = new Array[Byte](request.inputStream.available())
request.inputStream.read(buf)
FileUtils.writeByteArrayToFile(
new File(
getReleaseFilesDir(repository.owner, repository.name),
FileUtil.checkFilename(tag + "/" + fileId)
),
buf
)
createReleaseAsset(
repository.owner,
repository.name,
tag,
fileId,
name,
request.contentLength.getOrElse(0),
context.loginAccount.get
)
getReleaseAsset(repository.owner, repository.name, tag, fileId)
.map { asset =>
JsonFormat(ApiReleaseAsset(asset, RepositoryName(repository)))
}
.getOrElse {
ApiError("Unknown error")
}
}
.getOrElse(NotFound())
@@ -178,7 +175,7 @@ trait ApiReleaseControllerBase extends ControllerBase {
*/
/*
* xii. Delete a release asset
* https://developer.github.com/v3/repos/releases/#edit-a-release-asset
*/
* xii. Delete a release asset
* https://developer.github.com/v3/repos/releases/#edit-a-release-asset
*/
}

View File

@@ -1,38 +1,29 @@
package gitbucket.core.controller.api
import gitbucket.core.api._
import gitbucket.core.api.*
import gitbucket.core.controller.ControllerBase
import gitbucket.core.service.{AccountService, ProtectedBranchService, RepositoryService}
import gitbucket.core.util._
import gitbucket.core.util.Directory._
import gitbucket.core.util.Implicits._
import gitbucket.core.util.JGitUtil.getBranches
import gitbucket.core.util.*
import gitbucket.core.util.Directory.*
import gitbucket.core.util.Implicits.*
import gitbucket.core.util.JGitUtil.{getBranchesNoMergeInfo, processTree}
import org.eclipse.jgit.api.Git
import org.scalatra.NoContent
import scala.util.Using
trait ApiRepositoryBranchControllerBase extends ControllerBase {
self: RepositoryService
with AccountService
with OwnerAuthenticator
with UsersAuthenticator
with GroupManagerAuthenticator
with ProtectedBranchService
with ReferrerAuthenticator
with ReadableUsersAuthenticator
with WritableUsersAuthenticator =>
self: RepositoryService & AccountService & OwnerAuthenticator & UsersAuthenticator & GroupManagerAuthenticator &
ProtectedBranchService & ReferrerAuthenticator & ReadableUsersAuthenticator & WritableUsersAuthenticator =>
/**
* i. List branches
* https://developer.github.com/v3/repos/branches/#list-branches
* https://docs.github.com/en/rest/reference/repos#list-branches
*/
get("/api/v3/repos/:owner/:repository/branches")(referrersOnly { repository =>
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
JsonFormat(
JGitUtil
.getBranches(
git = git,
defaultBranch = repository.repository.defaultBranch,
origin = repository.repository.originUserName.isEmpty
)
.getBranchesNoMergeInfo(git)
.map { br =>
ApiBranchForList(br.name, ApiBranchCommit(br.commitId))
}
@@ -41,171 +32,227 @@ trait ApiRepositoryBranchControllerBase extends ControllerBase {
})
/**
* ii. Get branch
* https://developer.github.com/v3/repos/branches/#get-branch
* ii. Get a branch
* https://docs.github.com/en/rest/reference/repos#get-a-branch
*/
get("/api/v3/repos/:owner/:repository/branches/*")(referrersOnly { repository =>
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
git =>
(for {
branch <- params.get("splat") if repository.branchList.contains(branch)
br <- getBranches(
git,
repository.repository.defaultBranch,
repository.repository.originUserName.isEmpty
).find(_.name == branch)
} yield {
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
JsonFormat(
ApiBranch(branch, ApiBranchCommit(br.commitId), ApiBranchProtection(protection))(RepositoryName(repository))
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
(for {
branch <- params.get("splat") if repository.branchList.contains(branch)
br <- getBranchesNoMergeInfo(git).find(_.name == branch)
} yield {
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
JsonFormat(
ApiBranch(branch, ApiBranchCommit(br.commitId), ApiBranchProtectionResponse(protection))(
RepositoryName(repository)
)
}) getOrElse NotFound()
)
}) getOrElse NotFound()
}
})
/*
* iii. Get branch protection
* https://developer.github.com/v3/repos/branches/#get-branch-protection
* https://docs.github.com/en/rest/reference/repos#get-branch-protection
*/
get("/api/v3/repos/:owner/:repository/branches/:branch/protection")(referrersOnly { repository =>
val branch = params("branch")
if (repository.branchList.contains(branch)) {
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
JsonFormat(
ApiBranchProtectionResponse(protection)
)
} else { NotFound() }
})
/*
* iv. Update branch protection
* https://developer.github.com/v3/repos/branches/#update-branch-protection
* https://docs.github.com/en/rest/reference/repos#update-branch-protection
*/
/*
* v. Remove branch protection
* https://developer.github.com/v3/repos/branches/#remove-branch-protection
* v. Delete branch protection
* https://docs.github.com/en/rest/reference/repos#delete-branch-protection
*/
delete("/api/v3/repos/:owner/:repository/branches/:branch/protection")(writableUsersOnly { repository =>
val branch = params("branch")
if (repository.branchList.contains(branch)) {
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
if (protection.enabled) {
disableBranchProtection(repository.owner, repository.name, branch)
NoContent()
} else NotFound()
} else NotFound()
})
/*
* vi. Get admin branch protection
* https://docs.github.com/en/rest/reference/repos#get-admin-branch-protection
*/
/*
* vi. Get required status checks of protected branch
* https://developer.github.com/v3/repos/branches/#get-required-status-checks-of-protected-branch
* vii. Set admin branch protection
* https://docs.github.com/en/rest/reference/repos#set-admin-branch-protection
*/
/*
* vii. Update required status checks of protected branch
* https://developer.github.com/v3/repos/branches/#update-required-status-checks-of-protected-branch
* viii. Delete admin branch protection
* https://docs.github.com/en/rest/reference/repos#delete-admin-branch-protection
*/
/*
* viii. Remove required status checks of protected branch
* https://developer.github.com/v3/repos/branches/#remove-required-status-checks-of-protected-branch
* ix. Get pull request review protection
* https://docs.github.com/en/rest/reference/repos#get-pull-request-review-protection
*/
/*
* ix. List required status checks contexts of protected branch
* https://developer.github.com/v3/repos/branches/#list-required-status-checks-contexts-of-protected-branch
* x. Update pull request review protection
* https://docs.github.com/en/rest/reference/repos#update-pull-request-review-protection
*/
/*
* x. Replace required status checks contexts of protected branch
* https://developer.github.com/v3/repos/branches/#replace-required-status-checks-contexts-of-protected-branch
* xi. Delete pull request review protection
* https://docs.github.com/en/rest/reference/repos#delete-pull-request-review-protection
*/
/*
* xi. Add required status checks contexts of protected branch
* https://developer.github.com/v3/repos/branches/#remove-required-status-checks-contexts-of-protected-branch
* xii. Get commit signature protection
* https://docs.github.com/en/rest/reference/repos#get-commit-signature-protection
*/
/*
* xii. Remove required status checks contexts of protected branch
* https://developer.github.com/v3/repos/branches/#remove-required-status-checks-contexts-of-protected-branch
* xiii. Create commit signature protection
* https://docs.github.com/en/rest/reference/repos#create-commit-signature-protection
*/
/*
* xiii. Get pull request review enforcement of protected branch
* https://developer.github.com/v3/repos/branches/#get-pull-request-review-enforcement-of-protected-branch
* xiv. Delete commit signature protection
* https://docs.github.com/en/rest/reference/repos#delete-commit-signature-protection
*/
/*
* xiv. Update pull request review enforcement of protected branch
* https://developer.github.com/v3/repos/branches/#update-pull-request-review-enforcement-of-protected-branch
* xv. Get status checks protection
* https://docs.github.com/en/rest/reference/repos#get-status-checks-protection
*/
get("/api/v3/repos/:owner/:repository/branches/:branch/protection/required_status_checks")(referrersOnly {
repository =>
val branch = params("branch")
if (repository.branchList.contains(branch)) {
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
JsonFormat(
ApiBranchProtectionResponse(protection).required_status_checks
)
} else { NotFound() }
})
/*
* xvi. Update status check protection
* https://docs.github.com/en/rest/reference/repos#update-status-check-protection
*/
/*
* xv. Remove pull request review enforcement of protected branch
* https://developer.github.com/v3/repos/branches/#remove-pull-request-review-enforcement-of-protected-branch
* xvii. Remove status check protection
* https://docs.github.com/en/rest/reference/repos#remove-status-check-protection
*/
/*
* xvi. Get required signatures of protected branch
* https://developer.github.com/v3/repos/branches/#get-required-signatures-of-protected-branch
* xviii. Get all status check contexts
* https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-all-status-check-contexts
*/
get("/api/v3/repos/:owner/:repository/branches/:branch/protection/required_status_checks/contexts")(referrersOnly {
repository =>
val branch = params("branch")
if (repository.branchList.contains(branch)) {
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
if (protection.enabled) {
protection.contexts.toList
} else NotFound()
} else NotFound()
})
/*
* xix. Add status check contexts
* https://docs.github.com/en/rest/reference/repos#add-status-check-contexts
*/
/*
* xvii. Add required signatures of protected branch
* https://developer.github.com/v3/repos/branches/#add-required-signatures-of-protected-branch
* xx. Set status check contexts
* https://docs.github.com/en/rest/reference/repos#set-status-check-contexts
*/
/*
* xviii. Remove required signatures of protected branch
* https://developer.github.com/v3/repos/branches/#remove-required-signatures-of-protected-branch
* xxi. Remove status check contexts
* https://docs.github.com/en/rest/reference/repos#remove-status-check-contexts
*/
/*
* xix. Get admin enforcement of protected branch
* https://developer.github.com/v3/repos/branches/#get-admin-enforcement-of-protected-branch
* xxii. Get access restrictions
* https://docs.github.com/en/rest/reference/repos#get-access-restrictions
*/
/*
* xx. Add admin enforcement of protected branch
* https://developer.github.com/v3/repos/branches/#add-admin-enforcement-of-protected-branch
* xxiii. Delete access restrictions
* https://docs.github.com/en/rest/reference/repos#delete-access-restrictions
*/
/*
* xxi. Remove admin enforcement of protected branch
* https://developer.github.com/v3/repos/branches/#remove-admin-enforcement-of-protected-branch
* xxiv. Get apps with access to the protected branch
* https://docs.github.com/en/rest/reference/repos#get-apps-with-access-to-the-protected-branch
*/
/*
* xxii. Get restrictions of protected branch
* https://developer.github.com/v3/repos/branches/#get-restrictions-of-protected-branch
* xxv. Add app access restrictions
* https://docs.github.com/en/rest/reference/repos#add-app-access-restrictions
*/
/*
* xxiii. Remove restrictions of protected branch
* https://developer.github.com/v3/repos/branches/#remove-restrictions-of-protected-branch
* xxvi. Set app access restrictions
* https://docs.github.com/en/rest/reference/repos#set-app-access-restrictions
*/
/*
* xxiv. List team restrictions of protected branch
* https://developer.github.com/v3/repos/branches/#list-team-restrictions-of-protected-branch
* xxvii. Remove app access restrictions
* https://docs.github.com/en/rest/reference/repos#remove-app-access-restrictions
*/
/*
* xxv. Replace team restrictions of protected branch
* https://developer.github.com/v3/repos/branches/#replace-team-restrictions-of-protected-branch
* xxviii. Get teams with access to the protected branch
* https://docs.github.com/en/rest/reference/repos#get-teams-with-access-to-the-protected-branch
*/
/*
* xxvi. Add team restrictions of protected branch
* https://developer.github.com/v3/repos/branches/#add-team-restrictions-of-protected-branch
* xxix. Add team access restrictions
* https://docs.github.com/en/rest/reference/repos#add-team-access-restrictions
*/
/*
* xxvii. Remove team restrictions of protected branch
* https://developer.github.com/v3/repos/branches/#remove-team-restrictions-of-protected-branch
* xxx. Set team access restrictions
* https://docs.github.com/en/rest/reference/repos#set-team-access-restrictions
*/
/*
* xxviii. List user restrictions of protected branch
* https://developer.github.com/v3/repos/branches/#list-user-restrictions-of-protected-branch
* xxxi. Remove team access restrictions
* https://docs.github.com/en/rest/reference/repos#remove-team-access-restrictions
*/
/*
* xxix. Replace user restrictions of protected branch
* https://developer.github.com/v3/repos/branches/#replace-user-restrictions-of-protected-branch
* xxxii. Get users with access to the protected branch
* https://docs.github.com/en/rest/reference/repos#get-users-with-access-to-the-protected-branch
*/
/*
* xxx. Add user restrictions of protected branch
* https://developer.github.com/v3/repos/branches/#add-user-restrictions-of-protected-branch
* xxxiii. Add user access restrictions
* https://docs.github.com/en/rest/reference/repos#add-user-access-restrictions
*/
/*
* xxxi. Remove user restrictions of protected branch
* https://developer.github.com/v3/repos/branches/#remove-user-restrictions-of-protected-branch
* xxxiv. Set user access restrictions
* https://docs.github.com/en/rest/reference/repos#set-user-access-restrictions
*/
/*
* xxxv. Remove user access restrictions
* https://docs.github.com/en/rest/reference/repos#remove-user-access-restrictions
*/
/**
@@ -213,31 +260,30 @@ trait ApiRepositoryBranchControllerBase extends ControllerBase {
* https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
*/
patch("/api/v3/repos/:owner/:repository/branches/*")(ownerOnly { repository =>
import gitbucket.core.api._
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) {
git =>
(for {
branch <- params.get("splat") if repository.branchList.contains(branch)
protection <- extractFromJsonBody[ApiBranchProtection.EnablingAndDisabling].map(_.protection)
br <- getBranches(
git,
repository.repository.defaultBranch,
repository.repository.originUserName.isEmpty
).find(_.name == branch)
} yield {
if (protection.enabled) {
enableBranchProtection(
repository.owner,
repository.name,
branch,
protection.status.enforcement_level == ApiBranchProtection.Everyone,
protection.status.contexts
)
} else {
disableBranchProtection(repository.owner, repository.name, branch)
}
JsonFormat(ApiBranch(branch, ApiBranchCommit(br.commitId), protection)(RepositoryName(repository)))
}) getOrElse NotFound()
import gitbucket.core.api.*
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
(for {
branch <- params.get("splat") if repository.branchList.contains(branch)
protection <- extractFromJsonBody[ApiBranchProtectionRequest.EnablingAndDisabling].map(_.protection)
br <- getBranchesNoMergeInfo(git).find(_.name == branch)
} yield {
if (protection.enabled) {
enableBranchProtection(
repository.owner,
repository.name,
branch,
protection.enforce_admins.getOrElse(false),
protection.required_status_checks.isDefined,
protection.required_status_checks.map(_.contexts).getOrElse(Nil),
protection.restrictions.isDefined,
protection.restrictions.map(_.users).getOrElse(Nil)
)
} else {
disableBranchProtection(repository.owner, repository.name, branch)
}
val response = ApiBranchProtectionResponse(getProtectedBranchInfo(repository.owner, repository.name, branch))
JsonFormat(ApiBranch(branch, ApiBranchCommit(br.commitId), response)(RepositoryName(repository)))
}) getOrElse NotFound()
}
})
}

View File

@@ -1,5 +1,5 @@
package gitbucket.core.controller.api
import gitbucket.core.api.{AddACollaborator, ApiUser, JsonFormat}
import gitbucket.core.api.{AddACollaborator, ApiRepositoryCollaborator, ApiUser, JsonFormat}
import gitbucket.core.controller.ControllerBase
import gitbucket.core.service.{AccountService, RepositoryService}
import gitbucket.core.util.Implicits._
@@ -7,11 +7,11 @@ import gitbucket.core.util.{OwnerAuthenticator, ReferrerAuthenticator}
import org.scalatra.NoContent
trait ApiRepositoryCollaboratorControllerBase extends ControllerBase {
self: RepositoryService with AccountService with ReferrerAuthenticator with OwnerAuthenticator =>
self: RepositoryService & AccountService & ReferrerAuthenticator & OwnerAuthenticator =>
/*
* i. List collaborators
* https://developer.github.com/v3/repos/collaborators/#list-collaborators
* i. List repository collaborators
* https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#list-repository-collaborators
*/
get("/api/v3/repos/:owner/:repository/collaborators")(referrersOnly { repository =>
// TODO Should ApiUser take permission? getCollaboratorUserNames does not return owner group members.
@@ -19,19 +19,40 @@ trait ApiRepositoryCollaboratorControllerBase extends ControllerBase {
getCollaboratorUserNames(params("owner"), params("repository")).map(u => ApiUser(getAccountByUserName(u).get))
)
})
/*
* ii. Check if a user is a collaborator
* https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
* https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#check-if-a-user-is-a-repository-collaborator
*/
get("/api/v3/repos/:owner/:repository/collaborators/:userName")(referrersOnly { repository =>
(for (account <- getAccountByUserName(params("userName"))) yield {
if (getCollaboratorUserNames(repository.owner, repository.name).contains(account.userName)) {
NoContent()
} else {
NotFound()
}
}) getOrElse NotFound()
})
/*
* iii. Review a user's permission level
* https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level
* iii. Get repository permissions for a user
* https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-permissions-for-a-user
*/
get("/api/v3/repos/:owner/:repository/collaborators/:userName/permission")(referrersOnly { repository =>
(for {
account <- getAccountByUserName(params("userName"))
collaborator <- getCollaborators(repository.owner, repository.name)
.find(p => p._1.collaboratorName == account.userName)
} yield {
JsonFormat(
ApiRepositoryCollaborator(collaborator._1.role, ApiUser(account))
)
}) getOrElse NotFound()
})
/*
* iv. Add user as a collaborator
* https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator
* iv. Add a repository collaborator
* https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#add-a-repository-collaborator
* requested #1586
*/
put("/api/v3/repos/:owner/:repository/collaborators/:userName")(ownerOnly { repository =>
@@ -44,8 +65,8 @@ trait ApiRepositoryCollaboratorControllerBase extends ControllerBase {
})
/*
* v. Remove user as a collaborator
* https://developer.github.com/v3/repos/collaborators/#remove-user-as-a-collaborator
* v. Remove a repository collaborator
* https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#remove-a-repository-collaborator
* requested #1586
*/
delete("/api/v3/repos/:owner/:repository/collaborators/:userName")(ownerOnly { repository =>

Some files were not shown because too many files have changed in this diff Show More