mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-08 23:16:48 +02:00
Compare commits
250 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2904bcf4a7 | ||
|
|
6630fa2f37 | ||
|
|
351e63e7b6 | ||
|
|
ea0f35a0a1 | ||
|
|
623c53e169 | ||
|
|
3e6fd2caf8 | ||
|
|
39f1aa4487 | ||
|
|
8ffd905a9f | ||
|
|
668f9ef919 | ||
|
|
ffb9bb10f5 | ||
|
|
2618f54442 | ||
|
|
6b3218dd43 | ||
|
|
56a9b7b0f1 | ||
|
|
4f4afc5686 | ||
|
|
87fb136b85 | ||
|
|
7af271e14a | ||
|
|
f44d44cb4a | ||
|
|
e7fc5f1753 | ||
|
|
f0e2775861 | ||
|
|
2488ab9bd4 | ||
|
|
f0872d410c | ||
|
|
9d69cc9d45 | ||
|
|
1c66052372 | ||
|
|
158f799ca1 | ||
|
|
907532fd13 | ||
|
|
0f6a433623 | ||
|
|
00eab5d584 | ||
|
|
5d928b1a62 | ||
|
|
50d6f0c96f | ||
|
|
a60b43b862 | ||
|
|
4b1235b484 | ||
|
|
f354b9cfd7 | ||
|
|
0c2283ce28 | ||
|
|
840479a022 | ||
|
|
1bceaaab1d | ||
|
|
65ece3292a | ||
|
|
e410623cac | ||
|
|
09f7f036aa | ||
|
|
5249224dec | ||
|
|
00def3a46d | ||
|
|
134c0010b5 | ||
|
|
fe3b40557a | ||
|
|
d3cdc5d5fc | ||
|
|
7ebb28be74 | ||
|
|
707cd3c5c3 | ||
|
|
4c5017d108 | ||
|
|
fdd91b1e0e | ||
|
|
9124777ce7 | ||
|
|
7c575fdc52 | ||
|
|
f9d6f1334f | ||
|
|
65d4900325 | ||
|
|
64248d1fce | ||
|
|
bec75120bc | ||
|
|
3b0eed48d9 | ||
|
|
25c4b1e6a7 | ||
|
|
cccff46715 | ||
|
|
fc0ffd1b4f | ||
|
|
b70a2a2327 | ||
|
|
b5ca7ca0e1 | ||
|
|
7bb5379b45 | ||
|
|
5692a8c83e | ||
|
|
6c6126148e | ||
|
|
5b2e24daef | ||
|
|
29f390e48c | ||
|
|
c49eff6e54 | ||
|
|
27930a5849 | ||
|
|
6ffc139d2f | ||
|
|
59ed027b60 | ||
|
|
5dc55822d7 | ||
|
|
9bfe5115cc | ||
|
|
aaf9c65f30 | ||
|
|
d6197261fb | ||
|
|
8fd7df2a9d | ||
|
|
4eb148f4a6 | ||
|
|
8f1e460893 | ||
|
|
8c80f8a506 | ||
|
|
9eb9fc666c | ||
|
|
d70c6cece7 | ||
|
|
dbdee135a3 | ||
|
|
132bb6bee4 | ||
|
|
2dfa7a1190 | ||
|
|
06d559b47e | ||
|
|
83baaa6ed9 | ||
|
|
85d38a47f1 | ||
|
|
0c3c6ea15a | ||
|
|
2ce436bddc | ||
|
|
a60c607fcb | ||
|
|
0456739118 | ||
|
|
368052bd8f | ||
|
|
ce916a7d4b | ||
|
|
60ff046823 | ||
|
|
7d3bda42e2 | ||
|
|
83a39f1e39 | ||
|
|
de726d8d96 | ||
|
|
91bb241e8c | ||
|
|
8da55d8aa8 | ||
|
|
3355c46503 | ||
|
|
0a3d457218 | ||
|
|
7fa5fdfbd0 | ||
|
|
95f88891d0 | ||
|
|
550f8f415c | ||
|
|
5ab947d8ec | ||
|
|
ec793535e7 | ||
|
|
2f1d81cc4c | ||
|
|
0f189ca710 | ||
|
|
6afd51bb8d | ||
|
|
e415f9d24e | ||
|
|
ba5d587a1e | ||
|
|
92f778b6e9 | ||
|
|
b52981a845 | ||
|
|
9c5d3edc72 | ||
|
|
56d68c6145 | ||
|
|
4d13282915 | ||
|
|
872320ccab | ||
|
|
28ee80b727 | ||
|
|
2621de2cde | ||
|
|
82b102845f | ||
|
|
28c9f8b89a | ||
|
|
23fa937fd1 | ||
|
|
02330a2050 | ||
|
|
c65599d995 | ||
|
|
22ae1df4b1 | ||
|
|
6b22342166 | ||
|
|
53f6190267 | ||
|
|
f73daaef44 | ||
|
|
d99e382dfe | ||
|
|
aefbee2093 | ||
|
|
11fb0a7edf | ||
|
|
fe959aecff | ||
|
|
9b33655bd4 | ||
|
|
33acad85db | ||
|
|
6bfe3ea760 | ||
|
|
1532fd71d0 | ||
|
|
c14a732e2a | ||
|
|
a1372034ed | ||
|
|
98914269b7 | ||
|
|
d5e455336b | ||
|
|
7b84f25c56 | ||
|
|
2ca20af502 | ||
|
|
78df2accfc | ||
|
|
7a282fb67e | ||
|
|
db679967af | ||
|
|
9e98d30612 | ||
|
|
a47065e4a9 | ||
|
|
94d18c471c | ||
|
|
f8f3019228 | ||
|
|
c3d90b8593 | ||
|
|
62c1299f29 | ||
|
|
b75db98cad | ||
|
|
3592b3d13c | ||
|
|
ca814e2c08 | ||
|
|
48b6a590bf | ||
|
|
285ef02a17 | ||
|
|
18375c741e | ||
|
|
21030344cc | ||
|
|
a494027217 | ||
|
|
7bca01af59 | ||
|
|
acf3fa9980 | ||
|
|
c0ce0f8d19 | ||
|
|
56e7168461 | ||
|
|
c2d0d94f05 | ||
|
|
fc22cfbbdd | ||
|
|
d62adbf649 | ||
|
|
dba5539e3e | ||
|
|
f0a8b3bb17 | ||
|
|
f52e7e1bdd | ||
|
|
58ba26f21e | ||
|
|
bf7b30630c | ||
|
|
b5cac0308e | ||
|
|
373ea39048 | ||
|
|
427f5eec5f | ||
|
|
a4e9903e00 | ||
|
|
0d900a892c | ||
|
|
dc6fdaf482 | ||
|
|
b79498ed9f | ||
|
|
69e8f628df | ||
|
|
d3d8e3ce5f | ||
|
|
0499c47f4b | ||
|
|
7fd0cdd7d8 | ||
|
|
49eaf79e01 | ||
|
|
3a96c30aa8 | ||
|
|
6d550fa485 | ||
|
|
7f9d69bb51 | ||
|
|
709fab9ccc | ||
|
|
fd13a2db79 | ||
|
|
840d81f7bd | ||
|
|
5d08f4d339 | ||
|
|
ef48b2d5ef | ||
|
|
f54e4f337f | ||
|
|
743965d3b8 | ||
|
|
0e787eddfd | ||
|
|
442c0d575e | ||
|
|
485516be2e | ||
|
|
6b2fbb3bf0 | ||
|
|
e510b1c26b | ||
|
|
8d35494169 | ||
|
|
cf1504bae7 | ||
|
|
9bb4e473b9 | ||
|
|
d67afebadc | ||
|
|
417886161c | ||
|
|
1b85d511e9 | ||
|
|
45d84f63c1 | ||
|
|
fff60b2704 | ||
|
|
c9339aec9e | ||
|
|
7c98ae1341 | ||
|
|
01c2291715 | ||
|
|
2e03f081d9 | ||
|
|
0cbafdd884 | ||
|
|
d5a9c2c15d | ||
|
|
1496591244 | ||
|
|
f5acce3901 | ||
|
|
5568a0ad8e | ||
|
|
26a18287c7 | ||
|
|
b0f819b9bd | ||
|
|
ebff7baf07 | ||
|
|
cf9a55d896 | ||
|
|
72f7b659f4 | ||
|
|
87192d025b | ||
|
|
fd181b9a0c | ||
|
|
9c4cc12a02 | ||
|
|
44497b559e | ||
|
|
09c50a149b | ||
|
|
88beb68e01 | ||
|
|
0da358311b | ||
|
|
cf97b63dab | ||
|
|
4b5f22144e | ||
|
|
0d342a6863 | ||
|
|
458820a09d | ||
|
|
135c34ef0f | ||
|
|
8187c5a013 | ||
|
|
6ff48c8130 | ||
|
|
d37c70cd8d | ||
|
|
8abf357405 | ||
|
|
c93ac71634 | ||
|
|
408180f071 | ||
|
|
4e98abfe5c | ||
|
|
efbb404bd4 | ||
|
|
66f409bfad | ||
|
|
44ec64fb4b | ||
|
|
fb27bd29e8 | ||
|
|
c26ca9d463 | ||
|
|
8c36ba33f4 | ||
|
|
fe1e18b495 | ||
|
|
29e632af04 | ||
|
|
2b9daae62b | ||
|
|
8a11f85dd1 | ||
|
|
b09c72b106 | ||
|
|
43456e817a | ||
|
|
41e49423b2 | ||
|
|
3cc7bd3cdb |
2
LICENSE
2
LICENSE
@@ -187,7 +187,7 @@
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
Copyright 2013-2016 GitBucket Team
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
67
README.md
67
README.md
@@ -50,6 +50,7 @@ GitBucket has the plug-in system to extend GitBucket from outside of GitBucket.
|
|||||||
- [gitbucket-commitgraphs-plugin](https://github.com/yoshiyoshifujii/gitbucket-commitgraphs-plugin)
|
- [gitbucket-commitgraphs-plugin](https://github.com/yoshiyoshifujii/gitbucket-commitgraphs-plugin)
|
||||||
- [gitbucket-asciidoctor-plugin](https://github.com/lefou/gitbucket-asciidoctor-plugin)
|
- [gitbucket-asciidoctor-plugin](https://github.com/lefou/gitbucket-asciidoctor-plugin)
|
||||||
- [gitbucket-network-plugin](https://github.com/mrkm4ntr/gitbucket-network-plugin)
|
- [gitbucket-network-plugin](https://github.com/mrkm4ntr/gitbucket-network-plugin)
|
||||||
|
- [gitbucket-emoji-plugin](https://github.com/gitbucket/gitbucket-emoji-plugin)
|
||||||
|
|
||||||
You can find community plugins other than them at [gitbucket community plugins](http://gitbucket-plugins.github.io/).
|
You can find community plugins other than them at [gitbucket community plugins](http://gitbucket-plugins.github.io/).
|
||||||
|
|
||||||
@@ -64,21 +65,80 @@ Support
|
|||||||
|
|
||||||
Release Notes
|
Release Notes
|
||||||
-------------
|
-------------
|
||||||
### 4.2 - 2 Jul 2016
|
## 4.8 - 23 Dec 2016
|
||||||
|
- Search for repository names from the global header
|
||||||
|
- Filter repositories on the sidebar of the dashboard
|
||||||
|
- Search issues and wiki
|
||||||
|
- Keep pull request comments after new commits are pushed
|
||||||
|
- New web API to get a single issue
|
||||||
|
- Performance improvement for the repository viewer
|
||||||
|
|
||||||
|
### 4.7.1 - 28 Nov 2016
|
||||||
|
- Bug fix: group repositories are not shown in the your repositories list on the sidebar
|
||||||
|
- Small performance improvement of the dashboard
|
||||||
|
|
||||||
|
### 4.7 - 26 Nov 2016
|
||||||
|
- New permission system
|
||||||
|
- Dropdown filter for issue labels, milestones and assignees
|
||||||
|
- Keep sidebar folding status
|
||||||
|
- Link from milestone label to the issue list
|
||||||
|
|
||||||
|
### 4.6 - 29 Oct 2016
|
||||||
|
- Add disable option for forking
|
||||||
|
- Add History button to wiki page
|
||||||
|
- Git repository URL redirection for GitHub compatibility
|
||||||
|
- Get-Content API improvement
|
||||||
|
- Indicate who is group master in Members tab in group view
|
||||||
|
|
||||||
|
### 4.5 - 29 Sep 2016
|
||||||
|
- Attach files by dropping into textarea
|
||||||
|
- Issues / Pull requests switcher in dashboard
|
||||||
|
- HikariCP could be configured in `GITBUCKET_HOME/database.conf`
|
||||||
|
- Improve Cookie security
|
||||||
|
- Display commit count on the history button
|
||||||
|
- Improve mobile view
|
||||||
|
|
||||||
|
### 4.4 - 28 Aug 2016
|
||||||
|
- Import a SQL dump file to the database
|
||||||
|
- `go get` support in private repositories
|
||||||
|
- Sort milestones by due date
|
||||||
|
- apache-sshd has been updated to 1.2.0
|
||||||
|
|
||||||
|
### 4.3 - 30 Jul 2016
|
||||||
|
- Emoji support by [gitbucket-emoji-plugin](https://github.com/gitbucket/gitbucket-emoji-plugin)
|
||||||
|
- User name suggestion
|
||||||
|
- Add new web APIs and basic authentication support for API access
|
||||||
|
- Root Endpoint
|
||||||
|
- [List endpoints](https://developer.github.com/v3/#root-endpoint)
|
||||||
|
- [List Branches](https://developer.github.com/v3/repos/branches/#list-branches)
|
||||||
|
- [Get contents](https://developer.github.com/v3/repos/contents/#get-contents)
|
||||||
|
- [Get a Reference](https://developer.github.com/v3/git/refs/#get-a-reference)
|
||||||
|
- [List Collaborators](https://developer.github.com/v3/repos/collaborators/#list-collaborators)
|
||||||
|
- [List user repositories](https://developer.github.com/v3/repos/#list-user-repositories)
|
||||||
|
- [Get a group](https://developer.github.com/v3/orgs/#get-an-organization)
|
||||||
|
- [List group repositories](https://developer.github.com/v3/repos/#list-organization-repositories)
|
||||||
|
- Add new extension points
|
||||||
|
- `assetsMapping` : Supplies resources in plugin classpath as web assets
|
||||||
|
- `suggestionProvider` : Provides suggestion in the Markdown editing textarea
|
||||||
|
- `textDecorator` : Decorate text nodes in HTML which is converted from Markdown
|
||||||
|
|
||||||
|
### 4.2.1 - 3 Jul 2016
|
||||||
|
- Fix migration bug
|
||||||
|
|
||||||
|
This is hotfix for a critical bug in migration. If you are new installation, use 4.2.0. But if you have an exisiting installation and it had been updated to 4.0 from 3.x, you must update to 4.2.1.
|
||||||
|
|
||||||
|
### 4.2 - 2 Jul 2016
|
||||||
- New UI based on [AdminLTE](https://github.com/almasaeed2010/AdminLTE)
|
- New UI based on [AdminLTE](https://github.com/almasaeed2010/AdminLTE)
|
||||||
- git gc
|
- git gc
|
||||||
- Issues and Wiki have been possible to be disabled
|
- Issues and Wiki have been possible to be disabled
|
||||||
- SMTP configuration test mail
|
- SMTP configuration test mail
|
||||||
|
|
||||||
### 4.1 - 4 Jun 2016
|
### 4.1 - 4 Jun 2016
|
||||||
|
|
||||||
- Generic ssh user
|
- Generic ssh user
|
||||||
- Improve branch protection UI
|
- Improve branch protection UI
|
||||||
- Default value of pull request title
|
- Default value of pull request title
|
||||||
|
|
||||||
### 4.0 - 30 Apr 2016
|
### 4.0 - 30 Apr 2016
|
||||||
|
|
||||||
- MySQL and PostgreSQL support
|
- MySQL and PostgreSQL support
|
||||||
- Data export and import
|
- Data export and import
|
||||||
- Migration system has been switched to [solidbase](https://github.com/gitbucket/solidbase)
|
- Migration system has been switched to [solidbase](https://github.com/gitbucket/solidbase)
|
||||||
@@ -86,7 +146,6 @@ Release Notes
|
|||||||
**Note:** You can upgrade to GitBucket 4.0 from 3.14. If your GitBucket is 3.13 or before, you have to upgrade 3.14 at first.
|
**Note:** You can upgrade to GitBucket 4.0 from 3.14. If your GitBucket is 3.13 or before, you have to upgrade 3.14 at first.
|
||||||
|
|
||||||
### 3.14 - 30 Apr 2016
|
### 3.14 - 30 Apr 2016
|
||||||
|
|
||||||
- File attachment and search for wiki pages
|
- File attachment and search for wiki pages
|
||||||
- New extension points to add menus
|
- New extension points to add menus
|
||||||
- Content-Type of webhooks has been choosable
|
- Content-Type of webhooks has been choosable
|
||||||
|
|||||||
72
build.sbt
72
build.sbt
@@ -1,6 +1,6 @@
|
|||||||
val Organization = "gitbucket"
|
val Organization = "io.github.gitbucket"
|
||||||
val Name = "gitbucket"
|
val Name = "gitbucket"
|
||||||
val GitBucketVersion = "4.2.0"
|
val GitBucketVersion = "4.8"
|
||||||
val ScalatraVersion = "2.4.1"
|
val ScalatraVersion = "2.4.1"
|
||||||
val JettyVersion = "9.3.9.v20160517"
|
val JettyVersion = "9.3.9.v20160517"
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@ scalaVersion := "2.11.8"
|
|||||||
// dependency settings
|
// dependency settings
|
||||||
resolvers ++= Seq(
|
resolvers ++= Seq(
|
||||||
Classpaths.typesafeReleases,
|
Classpaths.typesafeReleases,
|
||||||
|
Resolver.jcenterRepo,
|
||||||
"amateras" at "http://amateras.sourceforge.jp/mvn/",
|
"amateras" at "http://amateras.sourceforge.jp/mvn/",
|
||||||
"sonatype-snapshot" at "https://oss.sonatype.org/content/repositories/snapshots/",
|
"sonatype-snapshot" at "https://oss.sonatype.org/content/repositories/snapshots/",
|
||||||
"amateras-snapshot" at "http://amateras.sourceforge.jp/mvn-snapshot/"
|
"amateras-snapshot" at "http://amateras.sourceforge.jp/mvn-snapshot/"
|
||||||
@@ -29,11 +30,11 @@ libraryDependencies ++= Seq(
|
|||||||
"io.github.gitbucket" %% "scalatra-forms" % "1.0.0",
|
"io.github.gitbucket" %% "scalatra-forms" % "1.0.0",
|
||||||
"commons-io" % "commons-io" % "2.4",
|
"commons-io" % "commons-io" % "2.4",
|
||||||
"io.github.gitbucket" % "solidbase" % "1.0.0",
|
"io.github.gitbucket" % "solidbase" % "1.0.0",
|
||||||
"io.github.gitbucket" % "markedj" % "1.0.9-SNAPSHOT",
|
"io.github.gitbucket" % "markedj" % "1.0.9",
|
||||||
"org.apache.commons" % "commons-compress" % "1.11",
|
"org.apache.commons" % "commons-compress" % "1.11",
|
||||||
"org.apache.commons" % "commons-email" % "1.4",
|
"org.apache.commons" % "commons-email" % "1.4",
|
||||||
"org.apache.httpcomponents" % "httpclient" % "4.5.1",
|
"org.apache.httpcomponents" % "httpclient" % "4.5.1",
|
||||||
"org.apache.sshd" % "apache-sshd" % "1.0.0",
|
"org.apache.sshd" % "apache-sshd" % "1.2.0",
|
||||||
"org.apache.tika" % "tika-core" % "1.13",
|
"org.apache.tika" % "tika-core" % "1.13",
|
||||||
"com.typesafe.slick" %% "slick" % "2.1.0",
|
"com.typesafe.slick" %% "slick" % "2.1.0",
|
||||||
"com.novell.ldap" % "jldap" % "2009-10-07",
|
"com.novell.ldap" % "jldap" % "2009-10-07",
|
||||||
@@ -45,19 +46,17 @@ libraryDependencies ++= Seq(
|
|||||||
"com.typesafe" % "config" % "1.3.0",
|
"com.typesafe" % "config" % "1.3.0",
|
||||||
"com.typesafe.akka" %% "akka-actor" % "2.3.15",
|
"com.typesafe.akka" %% "akka-actor" % "2.3.15",
|
||||||
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.0.0",
|
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.0.0",
|
||||||
|
"com.github.bkromhout" % "java-diff-utils" % "2.1.1",
|
||||||
|
"org.cache2k" % "cache2k-all" % "1.0.0.CR1",
|
||||||
"com.enragedginger" %% "akka-quartz-scheduler" % "1.4.0-akka-2.3.x" exclude("c3p0","c3p0"),
|
"com.enragedginger" %% "akka-quartz-scheduler" % "1.4.0-akka-2.3.x" exclude("c3p0","c3p0"),
|
||||||
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
|
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
|
||||||
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
|
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
|
||||||
"junit" % "junit" % "4.12" % "test",
|
"junit" % "junit" % "4.12" % "test",
|
||||||
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
|
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
|
||||||
"org.scalaz" %% "scalaz-core" % "7.2.4" % "test",
|
|
||||||
"com.wix" % "wix-embedded-mysql" % "1.0.3" % "test",
|
"com.wix" % "wix-embedded-mysql" % "1.0.3" % "test",
|
||||||
"ru.yandex.qatools.embed" % "postgresql-embedded" % "1.14" % "test"
|
"ru.yandex.qatools.embed" % "postgresql-embedded" % "1.14" % "test"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Twirl settings
|
|
||||||
play.twirl.sbt.Import.TwirlKeys.templateImports += "gitbucket.core._"
|
|
||||||
|
|
||||||
// Compiler settings
|
// Compiler settings
|
||||||
scalacOptions := Seq("-deprecation", "-language:postfixOps", "-Ybackend:GenBCode", "-Ydelambdafy:method", "-target:jvm-1.8")
|
scalacOptions := Seq("-deprecation", "-language:postfixOps", "-Ybackend:GenBCode", "-Ydelambdafy:method", "-target:jvm-1.8")
|
||||||
javacOptions in compile ++= Seq("-target", "8", "-source", "8")
|
javacOptions in compile ++= Seq("-target", "8", "-source", "8")
|
||||||
@@ -109,7 +108,6 @@ libraryDependencies ++= Seq(
|
|||||||
|
|
||||||
val executableKey = TaskKey[File]("executable")
|
val executableKey = TaskKey[File]("executable")
|
||||||
executableKey := {
|
executableKey := {
|
||||||
import org.apache.ivy.util.ChecksumHelper
|
|
||||||
import java.util.jar.{ Manifest => JarManifest }
|
import java.util.jar.{ Manifest => JarManifest }
|
||||||
import java.util.jar.Attributes.{ Name => AttrName }
|
import java.util.jar.Attributes.{ Name => AttrName }
|
||||||
|
|
||||||
@@ -167,9 +165,55 @@ executableKey := {
|
|||||||
log info s"built executable webapp ${outputFile}"
|
log info s"built executable webapp ${outputFile}"
|
||||||
outputFile
|
outputFile
|
||||||
}
|
}
|
||||||
/*
|
publishTo <<= version { (v: String) =>
|
||||||
Keys.artifact in (Compile, executableKey) ~= {
|
val nexus = "https://oss.sonatype.org/"
|
||||||
_ copy (`type` = "war", extension = "war"))
|
if (v.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
|
||||||
|
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
|
||||||
}
|
}
|
||||||
addArtifact(Keys.artifact in (Compile, executableKey), executableKey)
|
publishMavenStyle := true
|
||||||
*/
|
pomIncludeRepository := { _ => false }
|
||||||
|
pomExtra := (
|
||||||
|
<url>https://github.com/gitbucket/gitbucket</url>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>The Apache Software License, Version 2.0</name>
|
||||||
|
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<scm>
|
||||||
|
<url>https://github.com/gitbucket/gitbucket</url>
|
||||||
|
<connection>scm:git:https://github.com/gitbucket/gitbucket.git</connection>
|
||||||
|
</scm>
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>takezoe</id>
|
||||||
|
<name>Naoki Takezoe</name>
|
||||||
|
<url>https://github.com/takezoe</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>shimamoto</id>
|
||||||
|
<name>Takako Shimamoto</name>
|
||||||
|
<url>https://github.com/shimamoto</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>tanacasino</id>
|
||||||
|
<name>Tomofumi Tanaka</name>
|
||||||
|
<url>https://github.com/tanacasino</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>mrkm4ntr</id>
|
||||||
|
<name>Shintaro Murakami</name>
|
||||||
|
<url>https://github.com/mrkm4ntr</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>nazoking</id>
|
||||||
|
<name>nazoking</name>
|
||||||
|
<url>https://github.com/nazoking</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>McFoggy</id>
|
||||||
|
<name>Matthieu Brouillard</name>
|
||||||
|
<url>https://github.com/McFoggy</url>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
)
|
||||||
|
|||||||
@@ -46,9 +46,10 @@ $ sbt executable
|
|||||||
|
|
||||||
### Deploy assembly jar file
|
### Deploy assembly jar file
|
||||||
|
|
||||||
For plug-in development, we have to publish the assembly jar file to the public Maven repository by `release/deploy-assembly-jar.sh`.
|
For plug-in development, we have to publish the GitBucket jar file to the Maven central repository as well. At first, hit following command to publish artifacts to the sonatype OSS repository:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ cd release/
|
$ sbt publish-signed
|
||||||
$ ./deploy-assembly-jar.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Then operate release sequence at https://oss.sonatype.org/.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
sbt.version=0.13.11
|
sbt.version=0.13.12
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
|
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
|
||||||
|
|
||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.4")
|
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.4")
|
||||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
|
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
|
||||||
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "2.1.0")
|
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "2.1.0")
|
||||||
addSbtPlugin("fi.gekkio.sbtplugins" % "sbt-jrebel-plugin" % "0.10.0")
|
addSbtPlugin("fi.gekkio.sbtplugins" % "sbt-jrebel-plugin" % "0.10.0")
|
||||||
|
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
. ./env.sh
|
|
||||||
|
|
||||||
cd ../
|
|
||||||
./sbt.sh clean assembly
|
|
||||||
|
|
||||||
cd release
|
|
||||||
|
|
||||||
if [[ "$GITBUCKET_VERSION" =~ -SNAPSHOT$ ]]; then
|
|
||||||
MVN_DEPLOY_PATH=mvn-snapshot
|
|
||||||
else
|
|
||||||
MVN_DEPLOY_PATH=mvn
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $MVN_DEPLOY_PATH
|
|
||||||
|
|
||||||
mvn deploy:deploy-file \
|
|
||||||
-DgroupId=gitbucket\
|
|
||||||
-DartifactId=gitbucket-assembly\
|
|
||||||
-Dversion=$GITBUCKET_VERSION\
|
|
||||||
-Dpackaging=jar\
|
|
||||||
-Dfile=../target/scala-2.11/gitbucket-assembly-$GITBUCKET_VERSION.jar\
|
|
||||||
-DrepositoryId=sourceforge.jp\
|
|
||||||
-Durl=scp://shell.sourceforge.jp/home/groups/a/am/amateras/htdocs/$MVN_DEPLOY_PATH/
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
export GITBUCKET_VERSION=`cat ../build.sbt | grep 'val GitBucketVersion' | cut -d \" -f 2`
|
|
||||||
echo "GITBUCKET_VERSION: $GITBUCKET_VERSION"
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>jp.sf.amateras</groupId>
|
|
||||||
<artifactId>gitbucket-assembly</artifactId>
|
|
||||||
<version>0.0.1</version>
|
|
||||||
<build>
|
|
||||||
<extensions>
|
|
||||||
<extension>
|
|
||||||
<groupId>org.apache.maven.wagon</groupId>
|
|
||||||
<artifactId>wagon-ssh</artifactId>
|
|
||||||
<version>2.10</version>
|
|
||||||
</extension>
|
|
||||||
</extensions>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
Binary file not shown.
2
sbt.bat
2
sbt.bat
@@ -1,2 +1,2 @@
|
|||||||
set SCRIPT_DIR=%~dp0
|
set SCRIPT_DIR=%~dp0
|
||||||
java %JAVA_OPTS% -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar "%SCRIPT_DIR%\sbt-launch-0.13.9.jar" %*
|
java %JAVA_OPTS% -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar "%SCRIPT_DIR%\sbt-launch-0.13.12.jar" %*
|
||||||
|
|||||||
2
sbt.sh
2
sbt.sh
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
java $JAVA_OPTS -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar `dirname $0`/sbt-launch-0.13.9.jar "$@"
|
java $JAVA_OPTS -Dsbt.log.noformat=true -XX:+CMSClassUnloadingEnabled -Xmx512M -Xss2M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar `dirname $0`/sbt-launch-0.13.12.jar "$@"
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.security.ProtectionDomain;
|
import java.security.ProtectionDomain;
|
||||||
|
|
||||||
public class JettyLauncher {
|
public class JettyLauncher {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
String host = null;
|
String host = null;
|
||||||
int port = 8080;
|
int port = 8080;
|
||||||
|
InetSocketAddress address = null;
|
||||||
String contextPath = "/";
|
String contextPath = "/";
|
||||||
boolean forceHttps = false;
|
boolean forceHttps = false;
|
||||||
|
|
||||||
@@ -29,7 +31,13 @@ public class JettyLauncher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Server server = new Server(port);
|
if(host != null) {
|
||||||
|
address = new InetSocketAddress(host, port);
|
||||||
|
} else {
|
||||||
|
address = new InetSocketAddress(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
Server server = new Server(address);
|
||||||
|
|
||||||
// SelectChannelConnector connector = new SelectChannelConnector();
|
// SelectChannelConnector connector = new SelectChannelConnector();
|
||||||
// if(host != null) {
|
// if(host != null) {
|
||||||
@@ -60,6 +68,8 @@ public class JettyLauncher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server.setHandler(context);
|
server.setHandler(context);
|
||||||
|
server.setStopAtShutdown(true);
|
||||||
|
server.setStopTimeout(7_000);
|
||||||
server.start();
|
server.start();
|
||||||
server.join();
|
server.join();
|
||||||
}
|
}
|
||||||
|
|||||||
6
src/main/resources/update/gitbucket-core_4.6.xml
Normal file
6
src/main/resources/update/gitbucket-core_4.6.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="REPOSITORY">
|
||||||
|
<column name="ALLOW_FORK" type="boolean" nullable="false" defaultValueBoolean="true"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
2
src/main/resources/update/gitbucket-core_4.7.sql
Normal file
2
src/main/resources/update/gitbucket-core_4.7.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- DELETE COLLABORATORS IN GROUP REPOSITORIES
|
||||||
|
DELETE FROM COLLABORATOR WHERE USER_NAME IN (SELECT USER_NAME FROM ACCOUNT WHERE GROUP_ACCOUNT = TRUE)
|
||||||
33
src/main/resources/update/gitbucket-core_4.7.xml
Normal file
33
src/main/resources/update/gitbucket-core_4.7.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="COLLABORATOR">
|
||||||
|
<column name="ROLE" type="varchar(10)" nullable="false" defaultValue="ADMIN"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="REPOSITORY">
|
||||||
|
<column name="WIKI_OPTION" type="varchar(10)" nullable="false" defaultValue="DISABLE"/>
|
||||||
|
<column name="ISSUES_OPTION" type="varchar(10)" nullable="false" defaultValue="DISABLE"/>
|
||||||
|
</addColumn>
|
||||||
|
<update tableName="REPOSITORY">
|
||||||
|
<column name="WIKI_OPTION" value="DISABLE"/>
|
||||||
|
<where>ENABLE_WIKI = FALSE</where>
|
||||||
|
</update>
|
||||||
|
<update tableName="REPOSITORY">
|
||||||
|
<column name="WIKI_OPTION" value="PRIVATE"/>
|
||||||
|
<where>ENABLE_WIKI = TRUE AND ALLOW_WIKI_EDITING = FALSE</where>
|
||||||
|
</update>
|
||||||
|
<update tableName="REPOSITORY">
|
||||||
|
<column name="WIKI_OPTION" value="PUBLIC"/>
|
||||||
|
<where>ENABLE_WIKI = TRUE AND ALLOW_WIKI_EDITING = TRUE</where>
|
||||||
|
</update>
|
||||||
|
<update tableName="REPOSITORY">
|
||||||
|
<column name="ISSUES_OPTION" value="DISABLE"/>
|
||||||
|
<where>ENABLE_ISSUES = FALSE</where>
|
||||||
|
</update>
|
||||||
|
<update tableName="REPOSITORY">
|
||||||
|
<column name="ISSUES_OPTION" value="PUBLIC"/>
|
||||||
|
<where>ENABLE_ISSUES = TRUE</where>
|
||||||
|
</update>
|
||||||
|
<dropColumn tableName="REPOSITORY" columnName="ENABLE_WIKI"/>
|
||||||
|
<dropColumn tableName="REPOSITORY" columnName="ALLOW_WIKI_EDITING"/>
|
||||||
|
<dropColumn tableName="REPOSITORY" columnName="ENABLE_ISSUES"/>
|
||||||
|
</changeSet>
|
||||||
@@ -1,24 +1,33 @@
|
|||||||
|
|
||||||
import gitbucket.core.controller._
|
|
||||||
import gitbucket.core.plugin.PluginRegistry
|
|
||||||
import gitbucket.core.servlet.{AccessTokenAuthenticationFilter, BasicAuthenticationFilter, Database, TransactionFilter}
|
|
||||||
import gitbucket.core.util.Directory
|
|
||||||
|
|
||||||
import java.util.EnumSet
|
import java.util.EnumSet
|
||||||
import javax.servlet._
|
import javax.servlet._
|
||||||
|
|
||||||
|
import gitbucket.core.controller._
|
||||||
|
import gitbucket.core.plugin.PluginRegistry
|
||||||
|
import gitbucket.core.service.SystemSettingsService
|
||||||
|
import gitbucket.core.servlet._
|
||||||
|
import gitbucket.core.util.Directory
|
||||||
import org.scalatra._
|
import org.scalatra._
|
||||||
|
|
||||||
|
|
||||||
class ScalatraBootstrap extends LifeCycle {
|
class ScalatraBootstrap extends LifeCycle with SystemSettingsService {
|
||||||
override def init(context: ServletContext) {
|
override def init(context: ServletContext) {
|
||||||
|
|
||||||
|
val settings = loadSystemSettings()
|
||||||
|
if(settings.baseUrl.exists(_.startsWith("https://"))) {
|
||||||
|
context.getSessionCookieConfig.setSecure(true)
|
||||||
|
}
|
||||||
|
|
||||||
// Register TransactionFilter and BasicAuthenticationFilter at first
|
// Register TransactionFilter and BasicAuthenticationFilter at first
|
||||||
context.addFilter("transactionFilter", new TransactionFilter)
|
context.addFilter("transactionFilter", new TransactionFilter)
|
||||||
context.getFilterRegistration("transactionFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/*")
|
context.getFilterRegistration("transactionFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/*")
|
||||||
context.addFilter("basicAuthenticationFilter", new BasicAuthenticationFilter)
|
context.addFilter("gitAuthenticationFilter", new GitAuthenticationFilter)
|
||||||
context.getFilterRegistration("basicAuthenticationFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/git/*")
|
context.getFilterRegistration("gitAuthenticationFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/git/*")
|
||||||
context.addFilter("accessTokenAuthenticationFilter", new AccessTokenAuthenticationFilter)
|
context.addFilter("apiAuthenticationFilter", new ApiAuthenticationFilter)
|
||||||
context.getFilterRegistration("accessTokenAuthenticationFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/api/v3/*")
|
context.getFilterRegistration("apiAuthenticationFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/api/v3/*")
|
||||||
|
context.addFilter("ghCompatRepositoryAccessFilter", new GHCompatRepositoryAccessFilter)
|
||||||
|
context.getFilterRegistration("ghCompatRepositoryAccessFilter").addMappingForUrlPatterns(EnumSet.allOf(classOf[DispatcherType]), true, "/*")
|
||||||
|
|
||||||
// Register controllers
|
// Register controllers
|
||||||
context.mount(new AnonymousAccessController, "/*")
|
context.mount(new AnonymousAccessController, "/*")
|
||||||
|
|
||||||
|
|||||||
@@ -11,5 +11,18 @@ object GitBucketCoreModule extends Module("gitbucket-core",
|
|||||||
new Version("4.1.0"),
|
new Version("4.1.0"),
|
||||||
new Version("4.2.0",
|
new Version("4.2.0",
|
||||||
new LiquibaseMigration("update/gitbucket-core_4.2.xml")
|
new LiquibaseMigration("update/gitbucket-core_4.2.xml")
|
||||||
)
|
),
|
||||||
|
new Version("4.2.1"),
|
||||||
|
new Version("4.3.0"),
|
||||||
|
new Version("4.4.0"),
|
||||||
|
new Version("4.5.0"),
|
||||||
|
new Version("4.6.0",
|
||||||
|
new LiquibaseMigration("update/gitbucket-core_4.6.xml")
|
||||||
|
),
|
||||||
|
new Version("4.7.0",
|
||||||
|
new LiquibaseMigration("update/gitbucket-core_4.7.xml"),
|
||||||
|
new SqlMigration("update/gitbucket-core_4.7.sql")
|
||||||
|
),
|
||||||
|
new Version("4.7.1"),
|
||||||
|
new Version("4.8")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,3 +14,10 @@ case class ApiBranch(
|
|||||||
"self" -> ApiPath(s"/api/v3/repos/${repositoryName.fullName}/branches/${name}"),
|
"self" -> ApiPath(s"/api/v3/repos/${repositoryName.fullName}/branches/${name}"),
|
||||||
"html" -> ApiPath(s"/${repositoryName.fullName}/tree/${name}"))
|
"html" -> ApiPath(s"/${repositoryName.fullName}/tree/${name}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case class ApiBranchCommit(sha: String)
|
||||||
|
|
||||||
|
case class ApiBranchForList(
|
||||||
|
name: String,
|
||||||
|
commit: ApiBranchCommit
|
||||||
|
)
|
||||||
|
|||||||
18
src/main/scala/gitbucket/core/api/ApiContents.scala
Normal file
18
src/main/scala/gitbucket/core/api/ApiContents.scala
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
import gitbucket.core.util.JGitUtil.FileInfo
|
||||||
|
import org.apache.commons.codec.binary.Base64
|
||||||
|
|
||||||
|
case class ApiContents(`type`: String, name: String, content: Option[String], encoding: Option[String])
|
||||||
|
|
||||||
|
object ApiContents{
|
||||||
|
def apply(fileInfo: FileInfo, content: Option[Array[Byte]]): ApiContents = {
|
||||||
|
if(fileInfo.isDirectory) {
|
||||||
|
ApiContents("dir", fileInfo.name, None, None)
|
||||||
|
} else {
|
||||||
|
content.map(arr =>
|
||||||
|
ApiContents("file", fileInfo.name, Some(Base64.encodeBase64String(arr)), Some("base64"))
|
||||||
|
).getOrElse(ApiContents("file", fileInfo.name, None, None))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
src/main/scala/gitbucket/core/api/ApiEndPoint.scala
Normal file
3
src/main/scala/gitbucket/core/api/ApiEndPoint.scala
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
case class ApiEndPoint(rate_limit_url: ApiPath = ApiPath("/api/v3/rate_limit"))
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package gitbucket.core.api
|
package gitbucket.core.api
|
||||||
|
|
||||||
import gitbucket.core.model.{Issue, PullRequest}
|
import gitbucket.core.model.{Account, Issue, IssueComment, PullRequest}
|
||||||
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
|
|
||||||
@@ -15,6 +14,9 @@ case class ApiPullRequest(
|
|||||||
head: ApiPullRequest.Commit,
|
head: ApiPullRequest.Commit,
|
||||||
base: ApiPullRequest.Commit,
|
base: ApiPullRequest.Commit,
|
||||||
mergeable: Option[Boolean],
|
mergeable: Option[Boolean],
|
||||||
|
merged: Boolean,
|
||||||
|
merged_at: Option[Date],
|
||||||
|
merged_by: Option[ApiUser],
|
||||||
title: String,
|
title: String,
|
||||||
body: String,
|
body: String,
|
||||||
user: ApiUser) {
|
user: ApiUser) {
|
||||||
@@ -31,7 +33,14 @@ case class ApiPullRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
object ApiPullRequest{
|
object ApiPullRequest{
|
||||||
def apply(issue: Issue, pullRequest: PullRequest, headRepo: ApiRepository, baseRepo: ApiRepository, user: ApiUser): ApiPullRequest =
|
def apply(
|
||||||
|
issue: Issue,
|
||||||
|
pullRequest: PullRequest,
|
||||||
|
headRepo: ApiRepository,
|
||||||
|
baseRepo: ApiRepository,
|
||||||
|
user: ApiUser,
|
||||||
|
mergedComment: Option[(IssueComment, Account)]
|
||||||
|
): ApiPullRequest =
|
||||||
ApiPullRequest(
|
ApiPullRequest(
|
||||||
number = issue.issueId,
|
number = issue.issueId,
|
||||||
updated_at = issue.updatedDate,
|
updated_at = issue.updatedDate,
|
||||||
@@ -45,6 +54,9 @@ object ApiPullRequest{
|
|||||||
ref = pullRequest.branch,
|
ref = pullRequest.branch,
|
||||||
repo = baseRepo)(issue.userName),
|
repo = baseRepo)(issue.userName),
|
||||||
mergeable = None, // TODO: need check mergeable.
|
mergeable = None, // TODO: need check mergeable.
|
||||||
|
merged = mergedComment.isDefined,
|
||||||
|
merged_at = mergedComment.map { case (comment, _) => comment.registeredDate },
|
||||||
|
merged_by = mergedComment.map { case (_, account) => ApiUser(account) },
|
||||||
title = issue.title,
|
title = issue.title,
|
||||||
body = issue.content.getOrElse(""),
|
body = issue.content.getOrElse(""),
|
||||||
user = user
|
user = user
|
||||||
|
|||||||
5
src/main/scala/gitbucket/core/api/ApiRef.scala
Normal file
5
src/main/scala/gitbucket/core/api/ApiRef.scala
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
case class ApiObject(sha: String)
|
||||||
|
|
||||||
|
case class ApiRef(ref: String, `object`: ApiObject)
|
||||||
@@ -13,6 +13,7 @@ case class ApiUser(
|
|||||||
created_at: Date) {
|
created_at: Date) {
|
||||||
val url = ApiPath(s"/api/v3/users/${login}")
|
val url = ApiPath(s"/api/v3/users/${login}")
|
||||||
val html_url = ApiPath(s"/${login}")
|
val html_url = ApiPath(s"/${login}")
|
||||||
|
val avatar_url = ApiPath(s"/${login}/_avatar")
|
||||||
// val followers_url = ApiPath(s"/api/v3/users/${login}/followers")
|
// val followers_url = ApiPath(s"/api/v3/users/${login}/followers")
|
||||||
// val following_url = ApiPath(s"/api/v3/users/${login}/following{/other_user}")
|
// val following_url = ApiPath(s"/api/v3/users/${login}/following{/other_user}")
|
||||||
// val gists_url = ApiPath(s"/api/v3/users/${login}/gists{/gist_id}")
|
// val gists_url = ApiPath(s"/api/v3/users/${login}/gists{/gist_id}")
|
||||||
@@ -29,7 +30,7 @@ object ApiUser{
|
|||||||
def apply(user: Account): ApiUser = ApiUser(
|
def apply(user: Account): ApiUser = ApiUser(
|
||||||
login = user.userName,
|
login = user.userName,
|
||||||
email = user.mailAddress,
|
email = user.mailAddress,
|
||||||
`type` = if(user.isGroupAccount){ "Organization" }else{ "User" },
|
`type` = if(user.isGroupAccount){ "Organization" } else { "User" },
|
||||||
site_admin = user.isAdmin,
|
site_admin = user.isAdmin,
|
||||||
created_at = user.registeredDate
|
created_at = user.registeredDate
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ case class CreateARepository(
|
|||||||
auto_init: Boolean = false
|
auto_init: Boolean = false
|
||||||
) {
|
) {
|
||||||
def isValid: Boolean = {
|
def isValid: Boolean = {
|
||||||
name.length<=40 &&
|
name.length <= 100 &&
|
||||||
name.matches("[a-zA-Z0-9\\-\\+_.]+") &&
|
name.matches("[a-zA-Z0-9\\-\\+_.]+") &&
|
||||||
!name.startsWith("_") &&
|
!name.startsWith("_") &&
|
||||||
!name.startsWith("-")
|
!name.startsWith("-")
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import gitbucket.core.util._
|
|||||||
import io.github.gitbucket.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
import org.scalatra.i18n.Messages
|
import org.scalatra.i18n.Messages
|
||||||
|
import org.scalatra.BadRequest
|
||||||
|
|
||||||
|
|
||||||
class AccountController extends AccountControllerBase
|
class AccountController extends AccountControllerBase
|
||||||
@@ -38,7 +39,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
case class PersonalTokenForm(note: String)
|
case class PersonalTokenForm(note: String)
|
||||||
|
|
||||||
val newForm = mapping(
|
val newForm = mapping(
|
||||||
"userName" -> trim(label("User name" , text(required, maxlength(100), identifier, uniqueUserName))),
|
"userName" -> trim(label("User name" , text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
||||||
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress()))),
|
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress()))),
|
||||||
@@ -68,7 +69,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
case class EditGroupForm(groupName: String, url: Option[String], fileId: Option[String], members: String, clearImage: Boolean)
|
case class EditGroupForm(groupName: String, url: Option[String], fileId: Option[String], members: String, clearImage: Boolean)
|
||||||
|
|
||||||
val newGroupForm = mapping(
|
val newGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members)))
|
"members" -> trim(label("Members" ,text(required, members)))
|
||||||
@@ -120,7 +121,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
// Members
|
// Members
|
||||||
case "members" if(account.isGroupAccount) => {
|
case "members" if(account.isGroupAccount) => {
|
||||||
val members = getGroupMembers(account.userName)
|
val members = getGroupMembers(account.userName)
|
||||||
gitbucket.core.account.html.members(account, members.map(_.userName),
|
gitbucket.core.account.html.members(account, members,
|
||||||
context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager }))
|
context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager }))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +134,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager }))
|
context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
get("/:userName.atom") {
|
get("/:userName.atom") {
|
||||||
@@ -156,7 +157,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map { x =>
|
getAccountByUserName(userName).map { x =>
|
||||||
html.edit(x, flash.get("info"), flash.get("error"))
|
html.edit(x, flash.get("info"), flash.get("error"))
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:userName/_edit", editForm)(oneselfOnly { form =>
|
post("/:userName/_edit", editForm)(oneselfOnly { form =>
|
||||||
@@ -172,7 +173,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
flash += "info" -> "Account information has been updated."
|
flash += "info" -> "Account information has been updated."
|
||||||
redirect(s"/${userName}/_edit")
|
redirect(s"/${userName}/_edit")
|
||||||
|
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:userName/_delete")(oneselfOnly {
|
get("/:userName/_delete")(oneselfOnly {
|
||||||
@@ -196,14 +197,14 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
session.invalidate
|
session.invalidate
|
||||||
redirect("/")
|
redirect("/")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:userName/_ssh")(oneselfOnly {
|
get("/:userName/_ssh")(oneselfOnly {
|
||||||
val userName = params("userName")
|
val userName = params("userName")
|
||||||
getAccountByUserName(userName).map { x =>
|
getAccountByUserName(userName).map { x =>
|
||||||
html.ssh(x, getPublicKeys(x.userName))
|
html.ssh(x, getPublicKeys(x.userName))
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:userName/_ssh", sshKeyForm)(oneselfOnly { form =>
|
post("/:userName/_ssh", sshKeyForm)(oneselfOnly { form =>
|
||||||
@@ -234,7 +235,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
case _ => None
|
case _ => None
|
||||||
}
|
}
|
||||||
html.application(x, tokens, generatedToken)
|
html.application(x, tokens, generatedToken)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:userName/_personalToken", personalTokenForm)(oneselfOnly { form =>
|
post("/:userName/_personalToken", personalTokenForm)(oneselfOnly { form =>
|
||||||
@@ -260,7 +261,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
} else {
|
} else {
|
||||||
html.register()
|
html.register()
|
||||||
}
|
}
|
||||||
} else NotFound
|
} else NotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
post("/register", newForm){ form =>
|
post("/register", newForm){ form =>
|
||||||
@@ -268,7 +269,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.url)
|
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.url)
|
||||||
updateImage(form.userName, form.fileId, false)
|
updateImage(form.userName, form.fileId, false)
|
||||||
redirect("/signin")
|
redirect("/signin")
|
||||||
} else NotFound
|
} else NotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
get("/groups/new")(usersOnly {
|
get("/groups/new")(usersOnly {
|
||||||
@@ -318,18 +319,18 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
// Update GROUP_MEMBER
|
// Update GROUP_MEMBER
|
||||||
updateGroupMembers(form.groupName, members)
|
updateGroupMembers(form.groupName, members)
|
||||||
// Update COLLABORATOR for group repositories
|
// // Update COLLABORATOR for group repositories
|
||||||
getRepositoryNamesOfUser(form.groupName).foreach { repositoryName =>
|
// getRepositoryNamesOfUser(form.groupName).foreach { repositoryName =>
|
||||||
removeCollaborators(form.groupName, repositoryName)
|
// removeCollaborators(form.groupName, repositoryName)
|
||||||
members.foreach { case (userName, isManager) =>
|
// members.foreach { case (userName, isManager) =>
|
||||||
addCollaborator(form.groupName, repositoryName, userName)
|
// addCollaborator(form.groupName, repositoryName, userName)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
updateImage(form.groupName, form.fileId, form.clearImage)
|
updateImage(form.groupName, form.fileId, form.clearImage)
|
||||||
redirect(s"/${form.groupName}")
|
redirect(s"/${form.groupName}")
|
||||||
|
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -355,76 +356,80 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/fork")(readableUsersOnly { repository =>
|
get("/:owner/:repository/fork")(readableUsersOnly { repository =>
|
||||||
val loginAccount = context.loginAccount.get
|
if(repository.repository.options.allowFork){
|
||||||
val loginUserName = loginAccount.userName
|
val loginAccount = context.loginAccount.get
|
||||||
val groups = getGroupsByUserName(loginUserName)
|
val loginUserName = loginAccount.userName
|
||||||
groups match {
|
val groups = getGroupsByUserName(loginUserName)
|
||||||
case _: List[String] =>
|
groups match {
|
||||||
val managerPermissions = groups.map { group =>
|
case _: List[String] =>
|
||||||
val members = getGroupMembers(group)
|
val managerPermissions = groups.map { group =>
|
||||||
context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager })
|
val members = getGroupMembers(group)
|
||||||
}
|
context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager })
|
||||||
helper.html.forkrepository(
|
}
|
||||||
repository,
|
helper.html.forkrepository(
|
||||||
(groups zip managerPermissions).toMap
|
repository,
|
||||||
)
|
(groups zip managerPermissions).toMap
|
||||||
case _ => redirect(s"/${loginUserName}")
|
)
|
||||||
}
|
case _ => redirect(s"/${loginUserName}")
|
||||||
|
}
|
||||||
|
} else BadRequest()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/fork", accountForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/fork", accountForm)(readableUsersOnly { (form, repository) =>
|
||||||
val loginAccount = context.loginAccount.get
|
if(repository.repository.options.allowFork){
|
||||||
val loginUserName = loginAccount.userName
|
val loginAccount = context.loginAccount.get
|
||||||
val accountName = form.accountName
|
val loginUserName = loginAccount.userName
|
||||||
|
val accountName = form.accountName
|
||||||
|
|
||||||
LockUtil.lock(s"${accountName}/${repository.name}"){
|
LockUtil.lock(s"${accountName}/${repository.name}"){
|
||||||
if(getRepository(accountName, repository.name).isDefined ||
|
if(getRepository(accountName, repository.name).isDefined ||
|
||||||
(accountName != loginUserName && !getGroupsByUserName(loginUserName).contains(accountName))){
|
(accountName != loginUserName && !getGroupsByUserName(loginUserName).contains(accountName))){
|
||||||
// redirect to the repository if repository already exists
|
// redirect to the repository if repository already exists
|
||||||
redirect(s"/${accountName}/${repository.name}")
|
redirect(s"/${accountName}/${repository.name}")
|
||||||
} else {
|
} else {
|
||||||
// Insert to the database at first
|
// Insert to the database at first
|
||||||
val originUserName = repository.repository.originUserName.getOrElse(repository.owner)
|
val originUserName = repository.repository.originUserName.getOrElse(repository.owner)
|
||||||
val originRepositoryName = repository.repository.originRepositoryName.getOrElse(repository.name)
|
val originRepositoryName = repository.repository.originRepositoryName.getOrElse(repository.name)
|
||||||
|
|
||||||
insertRepository(
|
insertRepository(
|
||||||
repositoryName = repository.name,
|
repositoryName = repository.name,
|
||||||
userName = accountName,
|
userName = accountName,
|
||||||
description = repository.repository.description,
|
description = repository.repository.description,
|
||||||
isPrivate = repository.repository.isPrivate,
|
isPrivate = repository.repository.isPrivate,
|
||||||
originRepositoryName = Some(originRepositoryName),
|
originRepositoryName = Some(originRepositoryName),
|
||||||
originUserName = Some(originUserName),
|
originUserName = Some(originUserName),
|
||||||
parentRepositoryName = Some(repository.name),
|
parentRepositoryName = Some(repository.name),
|
||||||
parentUserName = Some(repository.owner)
|
parentUserName = Some(repository.owner)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Add collaborators for group repository
|
// // Add collaborators for group repository
|
||||||
val ownerAccount = getAccountByUserName(accountName).get
|
// val ownerAccount = getAccountByUserName(accountName).get
|
||||||
if(ownerAccount.isGroupAccount){
|
// if(ownerAccount.isGroupAccount){
|
||||||
getGroupMembers(accountName).foreach { member =>
|
// getGroupMembers(accountName).foreach { member =>
|
||||||
addCollaborator(accountName, repository.name, member.userName)
|
// addCollaborator(accountName, repository.name, member.userName)
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Insert default labels
|
||||||
|
insertDefaultLabels(accountName, repository.name)
|
||||||
|
|
||||||
|
// clone repository actually
|
||||||
|
JGitUtil.cloneRepository(
|
||||||
|
getRepositoryDir(repository.owner, repository.name),
|
||||||
|
getRepositoryDir(accountName, repository.name))
|
||||||
|
|
||||||
|
// Create Wiki repository
|
||||||
|
JGitUtil.cloneRepository(
|
||||||
|
getWikiRepositoryDir(repository.owner, repository.name),
|
||||||
|
getWikiRepositoryDir(accountName, repository.name))
|
||||||
|
|
||||||
|
// Record activity
|
||||||
|
recordForkActivity(repository.owner, repository.name, loginUserName, accountName)
|
||||||
|
// redirect to the repository
|
||||||
|
redirect(s"/${accountName}/${repository.name}")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert default labels
|
|
||||||
insertDefaultLabels(accountName, repository.name)
|
|
||||||
|
|
||||||
// clone repository actually
|
|
||||||
JGitUtil.cloneRepository(
|
|
||||||
getRepositoryDir(repository.owner, repository.name),
|
|
||||||
getRepositoryDir(accountName, repository.name))
|
|
||||||
|
|
||||||
// Create Wiki repository
|
|
||||||
JGitUtil.cloneRepository(
|
|
||||||
getWikiRepositoryDir(repository.owner, repository.name),
|
|
||||||
getWikiRepositoryDir(accountName, repository.name))
|
|
||||||
|
|
||||||
// Record activity
|
|
||||||
recordForkActivity(repository.owner, repository.name, loginUserName, accountName)
|
|
||||||
// redirect to the repository
|
|
||||||
redirect(s"/${accountName}/${repository.name}")
|
|
||||||
}
|
}
|
||||||
}
|
} else BadRequest()
|
||||||
})
|
})
|
||||||
|
|
||||||
private def existsAccount: Constraint = new Constraint(){
|
private def existsAccount: Constraint = new Constraint(){
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import gitbucket.core.service.PullRequestService._
|
|||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import gitbucket.core.util.JGitUtil.CommitInfo
|
import gitbucket.core.util.JGitUtil._
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
|
import gitbucket.core.view.helpers.{renderMarkup, isRenderable}
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.scalatra.{NoContent, UnprocessableEntity, Created}
|
import org.scalatra.{NoContent, UnprocessableEntity, Created}
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
@@ -21,6 +22,7 @@ class ApiController extends ApiControllerBase
|
|||||||
with IssuesService
|
with IssuesService
|
||||||
with LabelsService
|
with LabelsService
|
||||||
with PullRequestService
|
with PullRequestService
|
||||||
|
with CommitsService
|
||||||
with CommitStatusService
|
with CommitStatusService
|
||||||
with RepositoryCreationService
|
with RepositoryCreationService
|
||||||
with HandleCommentService
|
with HandleCommentService
|
||||||
@@ -34,7 +36,7 @@ class ApiController extends ApiControllerBase
|
|||||||
with GroupManagerAuthenticator
|
with GroupManagerAuthenticator
|
||||||
with ReferrerAuthenticator
|
with ReferrerAuthenticator
|
||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with CollaboratorsAuthenticator
|
with WritableUsersAuthenticator
|
||||||
|
|
||||||
trait ApiControllerBase extends ControllerBase {
|
trait ApiControllerBase extends ControllerBase {
|
||||||
self: RepositoryService
|
self: RepositoryService
|
||||||
@@ -51,26 +53,160 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
with GroupManagerAuthenticator
|
with GroupManagerAuthenticator
|
||||||
with ReferrerAuthenticator
|
with ReferrerAuthenticator
|
||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with CollaboratorsAuthenticator =>
|
with WritableUsersAuthenticator =>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/#root-endpoint
|
||||||
|
*/
|
||||||
|
get("/api/v3/") {
|
||||||
|
JsonFormat(ApiEndPoint())
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/orgs/#get-an-organization
|
||||||
|
*/
|
||||||
|
get("/api/v3/orgs/:groupName") {
|
||||||
|
getAccountByUserName(params("groupName")).filter(account => account.isGroupAccount).map { account =>
|
||||||
|
JsonFormat(ApiUser(account))
|
||||||
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://developer.github.com/v3/users/#get-a-single-user
|
* https://developer.github.com/v3/users/#get-a-single-user
|
||||||
*/
|
*/
|
||||||
get("/api/v3/users/:userName") {
|
get("/api/v3/users/:userName") {
|
||||||
getAccountByUserName(params("userName")).map { account =>
|
getAccountByUserName(params("userName")).filterNot(account => account.isGroupAccount).map { account =>
|
||||||
JsonFormat(ApiUser(account))
|
JsonFormat(ApiUser(account))
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/#list-organization-repositories
|
||||||
|
*/
|
||||||
|
get("/api/v3/orgs/:orgName/repos") {
|
||||||
|
JsonFormat(getVisibleRepositories(context.loginAccount, Some(params("orgName"))).map{ r => ApiRepository(r, getAccountByUserName(r.owner).get)})
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/#list-user-repositories
|
||||||
|
*/
|
||||||
|
get("/api/v3/users/:userName/repos") {
|
||||||
|
JsonFormat(getVisibleRepositories(context.loginAccount, Some(params("userName"))).map{ r => ApiRepository(r, getAccountByUserName(r.owner).get)})
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://developer.github.com/v3/repos/branches/#list-branches
|
||||||
|
*/
|
||||||
|
get ("/api/v3/repos/:owner/:repo/branches")(referrersOnly { repository =>
|
||||||
|
JsonFormat(JGitUtil.getBranches(
|
||||||
|
owner = repository.owner,
|
||||||
|
name = repository.name,
|
||||||
|
defaultBranch = repository.repository.defaultBranch,
|
||||||
|
origin = repository.repository.originUserName.isEmpty
|
||||||
|
).map { br =>
|
||||||
|
ApiBranchForList(br.name, ApiBranchCommit(br.commitId))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://developer.github.com/v3/repos/contents/#get-contents
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repo/contents/*")(referrersOnly { repository =>
|
||||||
|
def getFileInfo(git: Git, revision: String, pathStr: String): Option[FileInfo] = {
|
||||||
|
val path = new java.io.File(pathStr)
|
||||||
|
val dirName = path.getParent match {
|
||||||
|
case null => "."
|
||||||
|
case s => s
|
||||||
|
}
|
||||||
|
getFileList(git, revision, dirName).find(f => f.name.equals(path.getName))
|
||||||
|
}
|
||||||
|
|
||||||
|
val path = multiParams("splat").head match {
|
||||||
|
case s if s.isEmpty => "."
|
||||||
|
case s => s
|
||||||
|
}
|
||||||
|
val refStr = params.getOrElse("ref", repository.repository.defaultBranch)
|
||||||
|
|
||||||
|
using(Git.open(getRepositoryDir(params("owner"), params("repo")))){ git =>
|
||||||
|
val fileList = getFileList(git, refStr, path)
|
||||||
|
if (fileList.isEmpty) { // file or NotFound
|
||||||
|
getFileInfo(git, refStr, path).flatMap(f => {
|
||||||
|
val largeFile = params.get("large_file").exists(s => s.equals("true"))
|
||||||
|
val content = getContentFromId(git, f.id, largeFile)
|
||||||
|
request.getHeader("Accept") match {
|
||||||
|
case "application/vnd.github.v3.raw" => {
|
||||||
|
contentType = "application/vnd.github.v3.raw"
|
||||||
|
content
|
||||||
|
}
|
||||||
|
case "application/vnd.github.v3.html" if isRenderable(f.name) => {
|
||||||
|
contentType = "application/vnd.github.v3.html"
|
||||||
|
content.map(c =>
|
||||||
|
List(
|
||||||
|
"<div data-path=\"", path, "\" id=\"file\">", "<article>",
|
||||||
|
renderMarkup(path.split("/").toList, new String(c), refStr, repository, false, false, true).body,
|
||||||
|
"</article>", "</div>"
|
||||||
|
).mkString
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case "application/vnd.github.v3.html" => {
|
||||||
|
contentType = "application/vnd.github.v3.html"
|
||||||
|
content.map(c =>
|
||||||
|
List(
|
||||||
|
"<div data-path=\"", path, "\" id=\"file\">", "<div class=\"plain\">", "<pre>",
|
||||||
|
play.twirl.api.HtmlFormat.escape(new String(c)).body,
|
||||||
|
"</pre>", "</div>", "</div>"
|
||||||
|
).mkString
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case _ =>
|
||||||
|
Some(JsonFormat(ApiContents(f, content)))
|
||||||
|
}
|
||||||
|
}).getOrElse(NotFound())
|
||||||
|
} else { // directory
|
||||||
|
JsonFormat(fileList.map{f => ApiContents(f, None)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://developer.github.com/v3/git/refs/#get-a-reference
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repo/git/*") (referrersOnly { repository =>
|
||||||
|
val revstr = multiParams("splat").head
|
||||||
|
using(Git.open(getRepositoryDir(params("owner"), params("repo")))) { git =>
|
||||||
|
//JsonFormat( (revstr, git.getRepository().resolve(revstr)) )
|
||||||
|
// getRef is deprecated by jgit-4.2. use exactRef() or findRef()
|
||||||
|
val sha = git.getRepository().getRef(revstr).getObjectId().name()
|
||||||
|
JsonFormat(ApiRef(revstr, ApiObject(sha)))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/repos/collaborators/#list-collaborators
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repo/collaborators") (referrersOnly { repository =>
|
||||||
|
// TODO Should ApiUser take permission? getCollaboratorUserNames does not return owner group members.
|
||||||
|
JsonFormat(getCollaboratorUserNames(params("owner"), params("repo")).map(u => ApiUser(getAccountByUserName(u).get)))
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://developer.github.com/v3/users/#get-the-authenticated-user
|
* https://developer.github.com/v3/users/#get-the-authenticated-user
|
||||||
*/
|
*/
|
||||||
get("/api/v3/user") {
|
get("/api/v3/user") {
|
||||||
context.loginAccount.map { account =>
|
context.loginAccount.map { account =>
|
||||||
JsonFormat(ApiUser(account))
|
JsonFormat(ApiUser(account))
|
||||||
} getOrElse Unauthorized
|
} getOrElse Unauthorized()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List user's own repository
|
||||||
|
* https://developer.github.com/v3/repos/#list-your-repositories
|
||||||
|
*/
|
||||||
|
get("/api/v3/user/repos")(usersOnly{
|
||||||
|
JsonFormat(getVisibleRepositories(context.loginAccount, Option(context.loginAccount.get.userName)).map{
|
||||||
|
r => ApiRepository(r, getAccountByUserName(r.owner).get)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create user repository
|
* Create user repository
|
||||||
* https://developer.github.com/v3/repos/#create
|
* https://developer.github.com/v3/repos/#create
|
||||||
@@ -92,7 +228,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +252,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,7 +261,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
patch("/api/v3/repos/:owner/:repo/branches/:branch")(ownerOnly { repository =>
|
patch("/api/v3/repos/:owner/:repo/branches/:branch")(ownerOnly { repository =>
|
||||||
import gitbucket.core.api._
|
import gitbucket.core.api._
|
||||||
(for{
|
(for{
|
||||||
branch <- params.get("branch") if repository.branchList.find(_ == branch).isDefined
|
branch <- params.get("branch") if repository.branchList.find(_ == branch).isDefined
|
||||||
protection <- extractFromJsonBody[ApiBranchProtection.EnablingAndDisabling].map(_.protection)
|
protection <- extractFromJsonBody[ApiBranchProtection.EnablingAndDisabling].map(_.protection)
|
||||||
} yield {
|
} yield {
|
||||||
if(protection.enabled){
|
if(protection.enabled){
|
||||||
@@ -134,7 +270,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
disableBranchProtection(repository.owner, repository.name, branch)
|
disableBranchProtection(repository.owner, repository.name, branch)
|
||||||
}
|
}
|
||||||
JsonFormat(ApiBranch(branch, protection)(RepositoryName(repository)))
|
JsonFormat(ApiBranch(branch, protection)(RepositoryName(repository)))
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,16 +283,29 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
org.scalatra.NotFound(ApiError("Rate limiting is not enabled."))
|
org.scalatra.NotFound(ApiError("Rate limiting is not enabled."))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/#get-a-single-issue
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/issues/:id")(referrersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
issueId <- params("id").toIntOpt
|
||||||
|
issue <- getIssue(repository.owner, repository.name, issueId.toString)
|
||||||
|
openedUser <- getAccountByUserName(issue.openedUserName)
|
||||||
|
} yield {
|
||||||
|
JsonFormat(ApiIssue(issue, RepositoryName(repository), ApiUser(openedUser)))
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
|
* https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
|
||||||
*/
|
*/
|
||||||
get("/api/v3/repos/:owner/:repository/issues/:id/comments")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/issues/:id/comments")(referrersOnly { repository =>
|
||||||
(for{
|
(for{
|
||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
comments = getCommentsForApi(repository.owner, repository.name, issueId.toInt)
|
comments = getCommentsForApi(repository.owner, repository.name, issueId.toInt)
|
||||||
} yield {
|
} 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)
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,7 +321,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
issueComment <- getComment(repository.owner, repository.name, id.toString())
|
issueComment <- getComment(repository.owner, repository.name, id.toString())
|
||||||
} yield {
|
} yield {
|
||||||
JsonFormat(ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(context.loginAccount.get), issue.isPullRequest))
|
JsonFormat(ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(context.loginAccount.get), issue.isPullRequest))
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,7 +348,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
* Create a label
|
* Create a label
|
||||||
* https://developer.github.com/v3/issues/labels/#create-a-label
|
* https://developer.github.com/v3/issues/labels/#create-a-label
|
||||||
*/
|
*/
|
||||||
post("/api/v3/repos/:owner/:repository/labels")(collaboratorsOnly { repository =>
|
post("/api/v3/repos/:owner/:repository/labels")(writableUsersOnly { repository =>
|
||||||
(for{
|
(for{
|
||||||
data <- extractFromJsonBody[CreateALabel] if data.isValid
|
data <- extractFromJsonBody[CreateALabel] if data.isValid
|
||||||
} yield {
|
} yield {
|
||||||
@@ -224,7 +373,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
* Update a label
|
* Update a label
|
||||||
* https://developer.github.com/v3/issues/labels/#update-a-label
|
* https://developer.github.com/v3/issues/labels/#update-a-label
|
||||||
*/
|
*/
|
||||||
patch("/api/v3/repos/:owner/:repository/labels/:labelName")(collaboratorsOnly { repository =>
|
patch("/api/v3/repos/:owner/:repository/labels/:labelName")(writableUsersOnly { repository =>
|
||||||
(for{
|
(for{
|
||||||
data <- extractFromJsonBody[CreateALabel] if data.isValid
|
data <- extractFromJsonBody[CreateALabel] if data.isValid
|
||||||
} yield {
|
} yield {
|
||||||
@@ -234,12 +383,14 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
updateLabel(repository.owner, repository.name, label.labelId, data.name, data.color)
|
updateLabel(repository.owner, repository.name, label.labelId, data.name, data.color)
|
||||||
JsonFormat(ApiLabel(
|
JsonFormat(ApiLabel(
|
||||||
getLabel(repository.owner, repository.name, label.labelId).get,
|
getLabel(repository.owner, repository.name, label.labelId).get,
|
||||||
RepositoryName(repository)))
|
RepositoryName(repository)
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
// TODO ApiError should support errors field to enhance compatibility of GitHub API
|
// TODO ApiError should support errors field to enhance compatibility of GitHub API
|
||||||
UnprocessableEntity(ApiError(
|
UnprocessableEntity(ApiError(
|
||||||
"Validation Failed",
|
"Validation Failed",
|
||||||
Some("https://developer.github.com/v3/issues/labels/#create-a-label")))
|
Some("https://developer.github.com/v3/issues/labels/#create-a-label")
|
||||||
|
))
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
@@ -250,7 +401,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
* Delete a label
|
* Delete a label
|
||||||
* https://developer.github.com/v3/issues/labels/#delete-a-label
|
* https://developer.github.com/v3/issues/labels/#delete-a-label
|
||||||
*/
|
*/
|
||||||
delete("/api/v3/repos/:owner/:repository/labels/:labelName")(collaboratorsOnly { repository =>
|
delete("/api/v3/repos/:owner/:repository/labels/:labelName")(writableUsersOnly { repository =>
|
||||||
LockUtil.lock(RepositoryName(repository).fullName) {
|
LockUtil.lock(RepositoryName(repository).fullName) {
|
||||||
getLabel(repository.owner, repository.name, params("labelName")).map { label =>
|
getLabel(repository.owner, repository.name, params("labelName")).map { label =>
|
||||||
deleteLabel(repository.owner, repository.name, label.labelId)
|
deleteLabel(repository.owner, repository.name, label.labelId)
|
||||||
@@ -278,11 +429,12 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
JsonFormat(issues.map { case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner) =>
|
JsonFormat(issues.map { case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner) =>
|
||||||
ApiPullRequest(
|
ApiPullRequest(
|
||||||
issue,
|
issue = issue,
|
||||||
pullRequest,
|
pullRequest = pullRequest,
|
||||||
ApiRepository(headRepo, ApiUser(headOwner)),
|
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
|
||||||
ApiRepository(repository, ApiUser(baseOwner)),
|
baseRepo = ApiRepository(repository, ApiUser(baseOwner)),
|
||||||
ApiUser(issueUser)
|
user = ApiUser(issueUser),
|
||||||
|
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -292,21 +444,23 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
get("/api/v3/repos/:owner/:repository/pulls/:id")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/pulls/:id")(referrersOnly { repository =>
|
||||||
(for{
|
(for{
|
||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
(issue, pullRequest) <- getPullRequest(repository.owner, repository.name, issueId)
|
(issue, pullRequest) <- getPullRequest(repository.owner, repository.name, issueId)
|
||||||
users = getAccountsByUserNames(Set(repository.owner, pullRequest.requestUserName, issue.openedUserName), Set())
|
users = getAccountsByUserNames(Set(repository.owner, pullRequest.requestUserName, issue.openedUserName), Set.empty)
|
||||||
baseOwner <- users.get(repository.owner)
|
baseOwner <- users.get(repository.owner)
|
||||||
headOwner <- users.get(pullRequest.requestUserName)
|
headOwner <- users.get(pullRequest.requestUserName)
|
||||||
issueUser <- users.get(issue.openedUserName)
|
issueUser <- users.get(issue.openedUserName)
|
||||||
headRepo <- getRepository(pullRequest.requestUserName, pullRequest.requestRepositoryName)
|
headRepo <- getRepository(pullRequest.requestUserName, pullRequest.requestRepositoryName)
|
||||||
} yield {
|
} yield {
|
||||||
JsonFormat(ApiPullRequest(
|
JsonFormat(ApiPullRequest(
|
||||||
issue,
|
issue = issue,
|
||||||
pullRequest,
|
pullRequest = pullRequest,
|
||||||
ApiRepository(headRepo, ApiUser(headOwner)),
|
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
|
||||||
ApiRepository(repository, ApiUser(baseOwner)),
|
baseRepo = ApiRepository(repository, ApiUser(baseOwner)),
|
||||||
ApiUser(issueUser)))
|
user = ApiUser(issueUser),
|
||||||
}).getOrElse(NotFound)
|
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||||
|
))
|
||||||
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -321,11 +475,11 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
val oldId = git.getRepository.resolve(pullreq.commitIdFrom)
|
val oldId = git.getRepository.resolve(pullreq.commitIdFrom)
|
||||||
val newId = git.getRepository.resolve(pullreq.commitIdTo)
|
val newId = git.getRepository.resolve(pullreq.commitIdTo)
|
||||||
val repoFullName = RepositoryName(repository)
|
val repoFullName = RepositoryName(repository)
|
||||||
val commits = git.log.addRange(oldId, newId).call.iterator.asScala.map(c => ApiCommitListItem(new CommitInfo(c), repoFullName)).toList
|
val commits = git.log.addRange(oldId, newId).call.iterator.asScala.map { c => ApiCommitListItem(new CommitInfo(c), repoFullName) }.toList
|
||||||
JsonFormat(commits)
|
JsonFormat(commits)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -338,19 +492,19 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
/**
|
/**
|
||||||
* https://developer.github.com/v3/repos/statuses/#create-a-status
|
* https://developer.github.com/v3/repos/statuses/#create-a-status
|
||||||
*/
|
*/
|
||||||
post("/api/v3/repos/:owner/:repo/statuses/:sha")(collaboratorsOnly { repository =>
|
post("/api/v3/repos/:owner/:repo/statuses/:sha")(writableUsersOnly { repository =>
|
||||||
(for{
|
(for{
|
||||||
ref <- params.get("sha")
|
ref <- params.get("sha")
|
||||||
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
||||||
data <- extractFromJsonBody[CreateAStatus] if data.isValid
|
data <- extractFromJsonBody[CreateAStatus] if data.isValid
|
||||||
creator <- context.loginAccount
|
creator <- context.loginAccount
|
||||||
state <- CommitState.valueOf(data.state)
|
state <- CommitState.valueOf(data.state)
|
||||||
statusId = createCommitStatus(repository.owner, repository.name, sha, data.context.getOrElse("default"),
|
statusId = createCommitStatus(repository.owner, repository.name, sha, data.context.getOrElse("default"),
|
||||||
state, data.target_url, data.description, new java.util.Date(), creator)
|
state, data.target_url, data.description, new java.util.Date(), creator)
|
||||||
status <- getCommitStatus(repository.owner, repository.name, statusId)
|
status <- getCommitStatus(repository.owner, repository.name, statusId)
|
||||||
} yield {
|
} yield {
|
||||||
JsonFormat(ApiCommitStatus(status, ApiUser(creator)))
|
JsonFormat(ApiCommitStatus(status, ApiUser(creator)))
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -366,7 +520,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
JsonFormat(getCommitStatuesWithCreator(repository.owner, repository.name, sha).map{ case(status, creator) =>
|
JsonFormat(getCommitStatuesWithCreator(repository.owner, repository.name, sha).map{ case(status, creator) =>
|
||||||
ApiCommitStatus(status, ApiUser(creator))
|
ApiCommitStatus(status, ApiUser(creator))
|
||||||
})
|
})
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -385,17 +539,17 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
get("/api/v3/repos/:owner/:repo/commits/:ref/status")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repo/commits/:ref/status")(referrersOnly { repository =>
|
||||||
(for{
|
(for{
|
||||||
ref <- params.get("ref")
|
ref <- params.get("ref")
|
||||||
owner <- getAccountByUserName(repository.owner)
|
owner <- getAccountByUserName(repository.owner)
|
||||||
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
sha <- JGitUtil.getShaByRef(repository.owner, repository.name, ref)
|
||||||
} yield {
|
} yield {
|
||||||
val statuses = getCommitStatuesWithCreator(repository.owner, repository.name, sha)
|
val statuses = getCommitStatuesWithCreator(repository.owner, repository.name, sha)
|
||||||
JsonFormat(ApiCombinedCommitStatus(sha, statuses, ApiRepository(repository, owner)))
|
JsonFormat(ApiCombinedCommitStatus(sha, statuses, ApiRepository(repository, owner)))
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean =
|
private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean =
|
||||||
hasWritePermission(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ case class Context(settings: SystemSettingsService.SystemSettings, loginAccount:
|
|||||||
case agent if agent.contains("Win") => "windows"
|
case agent if agent.contains("Win") => "windows"
|
||||||
case _ => null
|
case _ => null
|
||||||
}
|
}
|
||||||
|
val sidebarCollapse = request.getSession.getAttribute("sidebar-collapse") != null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get object from cache.
|
* Get object from cache.
|
||||||
@@ -244,4 +245,13 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
.map { _ => "Mail address is already registered." }
|
.map { _ => "Mail address is already registered." }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val allReservedNames = Set("git", "admin", "upload", "api")
|
||||||
|
protected def reservedNames(): Constraint = new Constraint(){
|
||||||
|
override def validate(name: String, value: String, messages: Messages): Option[String] = if(allReservedNames.contains(value)){
|
||||||
|
Some(s"${value} is reserved")
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.dashboard.html
|
import gitbucket.core.dashboard.html
|
||||||
import gitbucket.core.service.{RepositoryService, PullRequestService, AccountService, IssuesService}
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.{StringUtil, Keys, UsersAuthenticator}
|
import gitbucket.core.util.{Keys, UsersAuthenticator}
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.service.IssuesService._
|
import gitbucket.core.service.IssuesService._
|
||||||
|
|
||||||
class DashboardController extends DashboardControllerBase
|
class DashboardController extends DashboardControllerBase
|
||||||
with IssuesService with PullRequestService with RepositoryService with AccountService
|
with IssuesService with PullRequestService with RepositoryService with AccountService with CommitsService
|
||||||
with UsersAuthenticator
|
with UsersAuthenticator
|
||||||
|
|
||||||
trait DashboardControllerBase extends ControllerBase {
|
trait DashboardControllerBase extends ControllerBase {
|
||||||
@@ -15,20 +15,7 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
with UsersAuthenticator =>
|
with UsersAuthenticator =>
|
||||||
|
|
||||||
get("/dashboard/issues")(usersOnly {
|
get("/dashboard/issues")(usersOnly {
|
||||||
val q = request.getParameter("q")
|
searchIssues("created_by")
|
||||||
val account = context.loginAccount.get
|
|
||||||
Option(q).map { q =>
|
|
||||||
val condition = IssueSearchCondition(q, Map[String, Int]())
|
|
||||||
q match {
|
|
||||||
case q if(q.contains("is:pr")) => redirect(s"/dashboard/pulls?q=${StringUtil.urlEncode(q)}")
|
|
||||||
case q if(q.contains(s"author:${account.userName}")) => redirect(s"/dashboard/issues/created_by${condition.toURL}")
|
|
||||||
case q if(q.contains(s"assignee:${account.userName}")) => redirect(s"/dashboard/issues/assigned${condition.toURL}")
|
|
||||||
case q if(q.contains(s"mentions:${account.userName}")) => redirect(s"/dashboard/issues/mentioned${condition.toURL}")
|
|
||||||
case _ => searchIssues("created_by")
|
|
||||||
}
|
|
||||||
} getOrElse {
|
|
||||||
searchIssues("created_by")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/issues/assigned")(usersOnly {
|
get("/dashboard/issues/assigned")(usersOnly {
|
||||||
@@ -44,20 +31,7 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/pulls")(usersOnly {
|
get("/dashboard/pulls")(usersOnly {
|
||||||
val q = request.getParameter("q")
|
searchPullRequests("created_by")
|
||||||
val account = context.loginAccount.get
|
|
||||||
Option(q).map { q =>
|
|
||||||
val condition = IssueSearchCondition(q, Map[String, Int]())
|
|
||||||
q match {
|
|
||||||
case q if(q.contains("is:issue")) => redirect(s"/dashboard/issues?q=${StringUtil.urlEncode(q)}")
|
|
||||||
case q if(q.contains(s"author:${account.userName}")) => redirect(s"/dashboard/pulls/created_by${condition.toURL}")
|
|
||||||
case q if(q.contains(s"assignee:${account.userName}")) => redirect(s"/dashboard/pulls/assigned${condition.toURL}")
|
|
||||||
case q if(q.contains(s"mentions:${account.userName}")) => redirect(s"/dashboard/pulls/mentioned${condition.toURL}")
|
|
||||||
case _ => searchPullRequests("created_by")
|
|
||||||
}
|
|
||||||
} getOrElse {
|
|
||||||
searchPullRequests("created_by")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/dashboard/pulls/created_by")(usersOnly {
|
get("/dashboard/pulls/created_by")(usersOnly {
|
||||||
@@ -73,14 +47,7 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
private def getOrCreateCondition(key: String, filter: String, userName: String) = {
|
private def getOrCreateCondition(key: String, filter: String, userName: String) = {
|
||||||
val condition = session.putAndGet(key, if(request.hasQueryString){
|
val condition = IssueSearchCondition(request)
|
||||||
val q = request.getParameter("q")
|
|
||||||
if(q == null){
|
|
||||||
IssueSearchCondition(request)
|
|
||||||
} else {
|
|
||||||
IssueSearchCondition(q, Map[String, Int]())
|
|
||||||
}
|
|
||||||
} else session.getAs[IssueSearchCondition](key).getOrElse(IssueSearchCondition()))
|
|
||||||
|
|
||||||
filter match {
|
filter match {
|
||||||
case "assigned" => condition.copy(assigned = Some(Some(userName)), author = None, mentioned = None)
|
case "assigned" => condition.copy(assigned = Some(Some(userName)), author = None, mentioned = None)
|
||||||
@@ -109,7 +76,7 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
},
|
},
|
||||||
filter,
|
filter,
|
||||||
getGroupNames(userName),
|
getGroupNames(userName),
|
||||||
getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true),
|
Nil,
|
||||||
getUserRepositories(userName, withoutPhysicalInfo = true))
|
getUserRepositories(userName, withoutPhysicalInfo = true))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +101,7 @@ trait DashboardControllerBase extends ControllerBase {
|
|||||||
},
|
},
|
||||||
filter,
|
filter,
|
||||||
getGroupNames(userName),
|
getGroupNames(userName),
|
||||||
getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true),
|
Nil,
|
||||||
getUserRepositories(userName, withoutPhysicalInfo = true))
|
getUserRepositories(userName, withoutPhysicalInfo = true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class FileUploadController extends ScalatraServlet with FileUploadSupport with R
|
|||||||
// Check whether logged-in user is collaborator
|
// Check whether logged-in user is collaborator
|
||||||
collaboratorsOnly(owner, repository, loginAccount){
|
collaboratorsOnly(owner, repository, loginAccount){
|
||||||
execute({ (file, fileId) =>
|
execute({ (file, fileId) =>
|
||||||
val fileName = file.getName
|
val fileName = file.getName
|
||||||
LockUtil.lock(s"${owner}/${repository}/wiki") {
|
LockUtil.lock(s"${owner}/${repository}/wiki") {
|
||||||
using(Git.open(Directory.getWikiRepositoryDir(owner, repository))) { git =>
|
using(Git.open(Directory.getWikiRepositoryDir(owner, repository))) { git =>
|
||||||
val builder = DirCache.newInCore.builder()
|
val builder = DirCache.newInCore.builder()
|
||||||
@@ -75,19 +75,14 @@ class FileUploadController extends ScalatraServlet with FileUploadSupport with R
|
|||||||
}
|
}
|
||||||
}, FileUtil.isUploadableType)
|
}, FileUtil.isUploadableType)
|
||||||
}
|
}
|
||||||
} getOrElse BadRequest
|
} getOrElse BadRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
post("/import") {
|
post("/import") {
|
||||||
|
import JDBCUtil._
|
||||||
session.get(Keys.Session.LoginAccount).collect { case loginAccount: Account if loginAccount.isAdmin =>
|
session.get(Keys.Session.LoginAccount).collect { case loginAccount: Account if loginAccount.isAdmin =>
|
||||||
execute({ (file, fileId) =>
|
execute({ (file, fileId) =>
|
||||||
if(file.getName.endsWith(".xml")){
|
request2Session(request).conn.importAsSQL(file.getInputStream)
|
||||||
import JDBCUtil._
|
|
||||||
val conn = request2Session(request).conn
|
|
||||||
conn.importAsXML(file.getInputStream)
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException("Import is available for only the XML file.")
|
|
||||||
}
|
|
||||||
}, _ => true)
|
}, _ => true)
|
||||||
}
|
}
|
||||||
redirect("/admin/data")
|
redirect("/admin/data")
|
||||||
@@ -98,7 +93,7 @@ class FileUploadController extends ScalatraServlet with FileUploadSupport with R
|
|||||||
loginAccount match {
|
loginAccount match {
|
||||||
case x if(x.isAdmin) => action
|
case x if(x.isAdmin) => action
|
||||||
case x if(getCollaborators(owner, repository).contains(x.userName)) => action
|
case x if(getCollaborators(owner, repository).contains(x.userName)) => action
|
||||||
case _ => BadRequest
|
case _ => BadRequest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,10 +101,9 @@ class FileUploadController extends ScalatraServlet with FileUploadSupport with R
|
|||||||
case Some(file) if(mimeTypeChcker(file.name)) =>
|
case Some(file) if(mimeTypeChcker(file.name)) =>
|
||||||
defining(FileUtil.generateFileId){ fileId =>
|
defining(FileUtil.generateFileId){ fileId =>
|
||||||
f(file, fileId)
|
f(file, fileId)
|
||||||
|
|
||||||
Ok(fileId)
|
Ok(fileId)
|
||||||
}
|
}
|
||||||
case _ => BadRequest
|
case _ => BadRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import gitbucket.core.model.Account
|
|||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
import gitbucket.core.util.{LDAPUtil, Keys, UsersAuthenticator, ReferrerAuthenticator, StringUtil}
|
import gitbucket.core.util.{Keys, LDAPUtil, ReferrerAuthenticator, StringUtil, UsersAuthenticator}
|
||||||
|
|
||||||
import io.github.gitbucket.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
|
import org.scalatra.Ok
|
||||||
|
|
||||||
|
|
||||||
class IndexController extends IndexControllerBase
|
class IndexController extends IndexControllerBase
|
||||||
@@ -36,23 +36,11 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
|
|
||||||
get("/"){
|
get("/"){
|
||||||
val loginAccount = context.loginAccount
|
context.loginAccount.map { account =>
|
||||||
if(loginAccount.isEmpty) {
|
val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName)
|
||||||
gitbucket.core.html.index(getRecentActivities(),
|
gitbucket.core.html.index(getRecentActivitiesByOwners(visibleOwnerSet), Nil, getUserRepositories(account.userName, withoutPhysicalInfo = true))
|
||||||
getVisibleRepositories(loginAccount, withoutPhysicalInfo = true),
|
}.getOrElse {
|
||||||
loginAccount.map{ account => getUserRepositories(account.userName, withoutPhysicalInfo = true) }.getOrElse(Nil)
|
gitbucket.core.html.index(getRecentActivities(), getVisibleRepositories(None, withoutPhysicalInfo = true), Nil)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
val loginUserName = loginAccount.get.userName
|
|
||||||
val loginUserGroups = getGroupsByUserName(loginUserName)
|
|
||||||
var visibleOwnerSet : Set[String] = Set(loginUserName)
|
|
||||||
|
|
||||||
visibleOwnerSet ++= loginUserGroups
|
|
||||||
|
|
||||||
gitbucket.core.html.index(getRecentActivitiesByOwners(visibleOwnerSet),
|
|
||||||
getVisibleRepositories(loginAccount, withoutPhysicalInfo = true),
|
|
||||||
loginAccount.map{ account => getUserRepositories(account.userName, withoutPhysicalInfo = true) }.getOrElse(Nil)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +69,15 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
xml.feed(getRecentActivities())
|
xml.feed(getRecentActivities())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get("/sidebar-collapse"){
|
||||||
|
if(params("collapse") == "true"){
|
||||||
|
session.setAttribute("sidebar-collapse", "true")
|
||||||
|
} else {
|
||||||
|
session.setAttribute("sidebar-collapse", null)
|
||||||
|
}
|
||||||
|
Ok()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set account information into HttpSession and redirect.
|
* Set account information into HttpSession and redirect.
|
||||||
*/
|
*/
|
||||||
@@ -108,29 +105,35 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
get("/_user/proposals")(usersOnly {
|
get("/_user/proposals")(usersOnly {
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
|
val user = params("user").toBoolean
|
||||||
|
val group = params("group").toBoolean
|
||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
Map("options" -> getAllUsers(false).filter(!_.isGroupAccount).map(_.userName).toArray)
|
Map("options" -> (
|
||||||
|
getAllUsers(false)
|
||||||
|
.withFilter { t => (user, group) match {
|
||||||
|
case (true, true) => true
|
||||||
|
case (true, false) => !t.isGroupAccount
|
||||||
|
case (false, true) => t.isGroupAccount
|
||||||
|
case (false, false) => false
|
||||||
|
}}.map { t => t.userName }
|
||||||
|
))
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON API for checking user existence.
|
* JSON API for checking user or group existence.
|
||||||
|
* Returns a single string which is any of "group", "user" or "".
|
||||||
*/
|
*/
|
||||||
post("/_user/existence")(usersOnly {
|
post("/_user/existence")(usersOnly {
|
||||||
getAccountByUserName(params("userName")).map { account =>
|
getAccountByUserName(params("userName")).map { account =>
|
||||||
if(params.get("userOnly").isDefined) !account.isGroupAccount else true
|
if(account.isGroupAccount) "group" else "user"
|
||||||
} getOrElse false
|
} getOrElse ""
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO Move to RepositoryViwerController?
|
|
||||||
post("/search", searchForm){ form =>
|
|
||||||
redirect(s"/${form.owner}/${form.repository}/search?q=${StringUtil.urlEncode(form.query)}")
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Move to RepositoryViwerController?
|
// TODO Move to RepositoryViwerController?
|
||||||
get("/:owner/:repository/search")(referrersOnly { repository =>
|
get("/:owner/:repository/search")(referrersOnly { repository =>
|
||||||
defining(params("q").trim, params.getOrElse("type", "code")){ case (query, target) =>
|
defining(params.getOrElse("q", "").trim, params.getOrElse("type", "code")){ case (query, target) =>
|
||||||
val page = try {
|
val page = try {
|
||||||
val i = params.getOrElse("page", "1").toInt
|
val i = params.getOrElse("page", "1").toInt
|
||||||
if(i <= 0) 1 else i
|
if(i <= 0) 1 else i
|
||||||
} catch {
|
} catch {
|
||||||
@@ -139,23 +142,31 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
target.toLowerCase match {
|
target.toLowerCase match {
|
||||||
case "issue" => gitbucket.core.search.html.issues(
|
case "issue" => gitbucket.core.search.html.issues(
|
||||||
countFiles(repository.owner, repository.name, query),
|
if(query.nonEmpty) searchIssues(repository.owner, repository.name, query) else Nil,
|
||||||
searchIssues(repository.owner, repository.name, query),
|
|
||||||
countWikiPages(repository.owner, repository.name, query),
|
|
||||||
query, page, repository)
|
query, page, repository)
|
||||||
|
|
||||||
case "wiki" => gitbucket.core.search.html.wiki(
|
case "wiki" => gitbucket.core.search.html.wiki(
|
||||||
countFiles(repository.owner, repository.name, query),
|
if(query.nonEmpty) searchWikiPages(repository.owner, repository.name, query) else Nil,
|
||||||
countIssues(repository.owner, repository.name, query),
|
|
||||||
searchWikiPages(repository.owner, repository.name, query),
|
|
||||||
query, page, repository)
|
query, page, repository)
|
||||||
|
|
||||||
case _ => gitbucket.core.search.html.code(
|
case _ => gitbucket.core.search.html.code(
|
||||||
searchFiles(repository.owner, repository.name, query),
|
if(query.nonEmpty) searchFiles(repository.owner, repository.name, query) else Nil,
|
||||||
countIssues(repository.owner, repository.name, query),
|
|
||||||
countWikiPages(repository.owner, repository.name, query),
|
|
||||||
query, page, repository)
|
query, page, repository)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
get("/search"){
|
||||||
|
val query = params.getOrElse("query", "").trim.toLowerCase
|
||||||
|
val visibleRepositories = getVisibleRepositories(context.loginAccount, None)
|
||||||
|
val repositories = visibleRepositories.filter { repository =>
|
||||||
|
repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0
|
||||||
|
}
|
||||||
|
context.loginAccount.map { account =>
|
||||||
|
gitbucket.core.search.html.repositories(query, repositories, Nil, getUserRepositories(account.userName, withoutPhysicalInfo = true))
|
||||||
|
}.getOrElse {
|
||||||
|
gitbucket.core.search.html.repositories(query, repositories, visibleRepositories, Nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,24 +2,45 @@ package gitbucket.core.controller
|
|||||||
|
|
||||||
import gitbucket.core.issues.html
|
import gitbucket.core.issues.html
|
||||||
import gitbucket.core.service.IssuesService._
|
import gitbucket.core.service.IssuesService._
|
||||||
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
import gitbucket.core.view
|
import gitbucket.core.view
|
||||||
import gitbucket.core.view.Markdown
|
import gitbucket.core.view.Markdown
|
||||||
|
|
||||||
import io.github.gitbucket.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.scalatra.Ok
|
import org.scalatra.Ok
|
||||||
|
|
||||||
|
|
||||||
class IssuesController extends IssuesControllerBase
|
class IssuesController extends IssuesControllerBase
|
||||||
with IssuesService with RepositoryService with AccountService with LabelsService with MilestonesService with ActivityService with HandleCommentService
|
with IssuesService
|
||||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator with PullRequestService with WebHookIssueCommentService
|
with RepositoryService
|
||||||
|
with AccountService
|
||||||
|
with LabelsService
|
||||||
|
with MilestonesService
|
||||||
|
with ActivityService
|
||||||
|
with HandleCommentService
|
||||||
|
with ReadableUsersAuthenticator
|
||||||
|
with ReferrerAuthenticator
|
||||||
|
with WritableUsersAuthenticator
|
||||||
|
with PullRequestService
|
||||||
|
with WebHookIssueCommentService
|
||||||
|
with CommitsService
|
||||||
|
|
||||||
trait IssuesControllerBase extends ControllerBase {
|
trait IssuesControllerBase extends ControllerBase {
|
||||||
self: IssuesService with RepositoryService with AccountService with LabelsService with MilestonesService with ActivityService with HandleCommentService
|
self: IssuesService
|
||||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator with PullRequestService with WebHookIssueCommentService =>
|
with RepositoryService
|
||||||
|
with AccountService
|
||||||
|
with LabelsService
|
||||||
|
with MilestonesService
|
||||||
|
with ActivityService
|
||||||
|
with HandleCommentService
|
||||||
|
with ReadableUsersAuthenticator
|
||||||
|
with ReferrerAuthenticator
|
||||||
|
with WritableUsersAuthenticator
|
||||||
|
with PullRequestService
|
||||||
|
with WebHookIssueCommentService =>
|
||||||
|
|
||||||
case class IssueCreateForm(title: String, content: Option[String],
|
case class IssueCreateForm(title: String, content: Option[String],
|
||||||
assignedUserName: Option[String], milestoneId: Option[Int], labelNames: Option[String])
|
assignedUserName: Option[String], milestoneId: Option[Int], labelNames: Option[String])
|
||||||
@@ -67,145 +88,149 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
_,
|
_,
|
||||||
getComments(owner, name, issueId.toInt),
|
getComments(owner, name, issueId.toInt),
|
||||||
getIssueLabels(owner, name, issueId.toInt),
|
getIssueLabels(owner, name, issueId.toInt),
|
||||||
(getCollaborators(owner, name) ::: (if(getAccountByUserName(owner).get.isGroupAccount) Nil else List(owner))).sorted,
|
getAssignableUserNames(owner, name),
|
||||||
getMilestonesWithIssueCount(owner, name),
|
getMilestonesWithIssueCount(owner, name),
|
||||||
getLabels(owner, name),
|
getLabels(owner, name),
|
||||||
hasWritePermission(owner, name, context.loginAccount),
|
isEditable(repository),
|
||||||
|
isManageable(repository),
|
||||||
repository)
|
repository)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/new")(readableUsersOnly { repository =>
|
get("/:owner/:repository/issues/new")(readableUsersOnly { repository =>
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
if(isEditable(repository)){ // TODO Should this check is provided by authenticator?
|
||||||
html.create(
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
(getCollaborators(owner, name) ::: (if(getAccountByUserName(owner).get.isGroupAccount) Nil else List(owner))).sorted,
|
html.create(
|
||||||
|
getAssignableUserNames(owner, name),
|
||||||
getMilestones(owner, name),
|
getMilestones(owner, name),
|
||||||
getLabels(owner, name),
|
getLabels(owner, name),
|
||||||
hasWritePermission(owner, name, context.loginAccount),
|
isManageable(repository),
|
||||||
repository)
|
repository)
|
||||||
}
|
}
|
||||||
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
if(isEditable(repository)){ // TODO Should this check is provided by authenticator?
|
||||||
val writable = hasWritePermission(owner, name, context.loginAccount)
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
val userName = context.loginAccount.get.userName
|
val manageable = isManageable(repository)
|
||||||
|
val userName = context.loginAccount.get.userName
|
||||||
|
|
||||||
// insert issue
|
// insert issue
|
||||||
val issueId = createIssue(owner, name, userName, form.title, form.content,
|
val issueId = createIssue(owner, name, userName, form.title, form.content,
|
||||||
if(writable) form.assignedUserName else None,
|
if (manageable) form.assignedUserName else None,
|
||||||
if(writable) form.milestoneId else None)
|
if (manageable) form.milestoneId else None)
|
||||||
|
|
||||||
// insert labels
|
// insert labels
|
||||||
if(writable){
|
if (manageable) {
|
||||||
form.labelNames.map { value =>
|
form.labelNames.map { value =>
|
||||||
val labels = getLabels(owner, name)
|
val labels = getLabels(owner, name)
|
||||||
value.split(",").foreach { labelName =>
|
value.split(",").foreach { labelName =>
|
||||||
labels.find(_.labelName == labelName).map { label =>
|
labels.find(_.labelName == labelName).map { label =>
|
||||||
registerIssueLabel(owner, name, issueId, label.labelId)
|
registerIssueLabel(owner, name, issueId, label.labelId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// record activity
|
// record activity
|
||||||
recordCreateIssueActivity(owner, name, userName, issueId, form.title)
|
recordCreateIssueActivity(owner, name, userName, issueId, form.title)
|
||||||
|
|
||||||
getIssue(owner, name, issueId.toString).foreach { issue =>
|
getIssue(owner, name, issueId.toString).foreach { issue =>
|
||||||
// extract references and create refer comment
|
// extract references and create refer comment
|
||||||
createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse(""), context.loginAccount.get)
|
createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse(""), context.loginAccount.get)
|
||||||
|
|
||||||
// call web hooks
|
// call web hooks
|
||||||
callIssuesWebHook("opened", repository, issue, context.baseUrl, context.loginAccount.get)
|
callIssuesWebHook("opened", repository, issue, context.baseUrl, context.loginAccount.get)
|
||||||
|
|
||||||
// notifications
|
// notifications
|
||||||
Notifier().toNotify(repository, issue, form.content.getOrElse("")){
|
Notifier().toNotify(repository, issue, form.content.getOrElse("")) {
|
||||||
Notifier.msgIssue(s"${context.baseUrl}/${owner}/${name}/issues/${issueId}")
|
Notifier.msgIssue(s"${context.baseUrl}/${owner}/${name}/issues/${issueId}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/issues/${issueId}")
|
redirect(s"/${owner}/${name}/issues/${issueId}")
|
||||||
}
|
}
|
||||||
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/edit_title/:id", issueTitleEditForm)(readableUsersOnly { (title, repository) =>
|
ajaxPost("/:owner/:repository/issues/edit_title/:id", issueTitleEditForm)(readableUsersOnly { (title, repository) =>
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
getIssue(owner, name, params("id")).map { issue =>
|
getIssue(owner, name, params("id")).map { issue =>
|
||||||
if(isEditable(owner, name, issue.openedUserName)){
|
if(isEditableContent(owner, name, issue.openedUserName)){
|
||||||
// update issue
|
// update issue
|
||||||
updateIssue(owner, name, issue.issueId, title, issue.content)
|
updateIssue(owner, name, issue.issueId, title, issue.content)
|
||||||
// extract references and create refer comment
|
// extract references and create refer comment
|
||||||
createReferComment(owner, name, issue.copy(title = title), title, context.loginAccount.get)
|
createReferComment(owner, name, issue.copy(title = title), title, context.loginAccount.get)
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
|
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/edit/:id", issueEditForm)(readableUsersOnly { (content, repository) =>
|
ajaxPost("/:owner/:repository/issues/edit/:id", issueEditForm)(readableUsersOnly { (content, repository) =>
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
getIssue(owner, name, params("id")).map { issue =>
|
getIssue(owner, name, params("id")).map { issue =>
|
||||||
if(isEditable(owner, name, issue.openedUserName)){
|
if(isEditableContent(owner, name, issue.openedUserName)){
|
||||||
// update issue
|
// update issue
|
||||||
updateIssue(owner, name, issue.issueId, issue.title, content)
|
updateIssue(owner, name, issue.issueId, issue.title, content)
|
||||||
// extract references and create refer comment
|
// extract references and create refer comment
|
||||||
createReferComment(owner, name, issue, content.getOrElse(""), context.loginAccount.get)
|
createReferComment(owner, name, issue, content.getOrElse(""), context.loginAccount.get)
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
|
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
||||||
val actionOpt = params.get("action").filter(_ => isEditable(issue.userName, issue.repositoryName, issue.openedUserName))
|
val actionOpt = params.get("action").filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName))
|
||||||
handleComment(issue, Some(form.content), repository, actionOpt) map { case (issue, id) =>
|
handleComment(issue, Some(form.content), repository, actionOpt) map { case (issue, id) =>
|
||||||
redirect(s"/${repository.owner}/${repository.name}/${
|
redirect(s"/${repository.owner}/${repository.name}/${
|
||||||
if(issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}")
|
if(issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issue_comments/state", issueStateForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issue_comments/state", issueStateForm)(readableUsersOnly { (form, repository) =>
|
||||||
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
getIssue(repository.owner, repository.name, form.issueId.toString).flatMap { issue =>
|
||||||
val actionOpt = params.get("action").filter(_ => isEditable(issue.userName, issue.repositoryName, issue.openedUserName))
|
val actionOpt = params.get("action").filter(_ => isEditableContent(issue.userName, issue.repositoryName, issue.openedUserName))
|
||||||
handleComment(issue, form.content, repository, actionOpt) map { case (issue, id) =>
|
handleComment(issue, form.content, repository, actionOpt) map { case (issue, id) =>
|
||||||
redirect(s"/${repository.owner}/${repository.name}/${
|
redirect(s"/${repository.owner}/${repository.name}/${
|
||||||
if(issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}")
|
if(issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issue_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/issue_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
getComment(owner, name, params("id")).map { comment =>
|
getComment(owner, name, params("id")).map { comment =>
|
||||||
if(isEditable(owner, name, comment.commentedUserName)){
|
if(isEditableContent(owner, name, comment.commentedUserName)){
|
||||||
updateComment(comment.commentId, form.content)
|
updateComment(comment.commentId, form.content)
|
||||||
redirect(s"/${owner}/${name}/issue_comments/_data/${comment.commentId}")
|
redirect(s"/${owner}/${name}/issue_comments/_data/${comment.commentId}")
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issue_comments/delete/:id")(readableUsersOnly { repository =>
|
ajaxPost("/:owner/:repository/issue_comments/delete/:id")(readableUsersOnly { repository =>
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
getComment(owner, name, params("id")).map { comment =>
|
getComment(owner, name, params("id")).map { comment =>
|
||||||
if(isEditable(owner, name, comment.commentedUserName)){
|
if(isEditableContent(owner, name, comment.commentedUserName)){
|
||||||
Ok(deleteComment(comment.commentId))
|
Ok(deleteComment(comment.commentId))
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issues/_data/:id")(readableUsersOnly { repository =>
|
ajaxGet("/:owner/:repository/issues/_data/:id")(readableUsersOnly { repository =>
|
||||||
getIssue(repository.owner, repository.name, params("id")) map { x =>
|
getIssue(repository.owner, repository.name, params("id")) map { x =>
|
||||||
if(isEditable(x.userName, x.repositoryName, x.openedUserName)){
|
if(isEditableContent(x.userName, x.repositoryName, x.openedUserName)){
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editissue(
|
case t if t == "html" => html.editissue(x.content, x.issueId, repository)
|
||||||
x.content, x.issueId, x.userName, x.repositoryName)
|
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
@@ -219,21 +244,20 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
enableAnchor = true,
|
enableAnchor = true,
|
||||||
enableLineBreaks = true,
|
enableLineBreaks = true,
|
||||||
enableTaskList = true,
|
enableTaskList = true,
|
||||||
hasWritePermission = isEditable(x.userName, x.repositoryName, x.openedUserName)
|
hasWritePermission = true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issue_comments/_data/:id")(readableUsersOnly { repository =>
|
ajaxGet("/:owner/:repository/issue_comments/_data/:id")(readableUsersOnly { repository =>
|
||||||
getComment(repository.owner, repository.name, params("id")) map { x =>
|
getComment(repository.owner, repository.name, params("id")) map { x =>
|
||||||
if(isEditable(x.userName, x.repositoryName, x.commentedUserName)){
|
if(isEditableContent(x.userName, x.repositoryName, x.commentedUserName)){
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editcomment(
|
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
|
||||||
x.content, x.commentId, x.userName, x.repositoryName)
|
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
@@ -246,51 +270,51 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
enableAnchor = true,
|
enableAnchor = true,
|
||||||
enableLineBreaks = true,
|
enableLineBreaks = true,
|
||||||
enableTaskList = true,
|
enableTaskList = true,
|
||||||
hasWritePermission = isEditable(x.userName, x.repositoryName, x.commentedUserName)
|
hasWritePermission = true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/new/label")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/new/label")(writableUsersOnly { repository =>
|
||||||
val labelNames = params("labelNames").split(",")
|
val labelNames = params("labelNames").split(",")
|
||||||
val labels = getLabels(repository.owner, repository.name).filter(x => labelNames.contains(x.labelName))
|
val labels = getLabels(repository.owner, repository.name).filter(x => labelNames.contains(x.labelName))
|
||||||
html.labellist(labels)
|
html.labellist(labels)
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/label/new")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/label/new")(writableUsersOnly { repository =>
|
||||||
defining(params("id").toInt){ issueId =>
|
defining(params("id").toInt){ issueId =>
|
||||||
registerIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt)
|
registerIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt)
|
||||||
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/label/delete")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/label/delete")(writableUsersOnly { repository =>
|
||||||
defining(params("id").toInt){ issueId =>
|
defining(params("id").toInt){ issueId =>
|
||||||
deleteIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt)
|
deleteIssueLabel(repository.owner, repository.name, issueId, params("labelId").toInt)
|
||||||
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
html.labellist(getIssueLabels(repository.owner, repository.name, issueId))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/assign")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/assign")(writableUsersOnly { repository =>
|
||||||
updateAssignedUserName(repository.owner, repository.name, params("id").toInt, assignedUserName("assignedUserName"))
|
updateAssignedUserName(repository.owner, repository.name, params("id").toInt, assignedUserName("assignedUserName"))
|
||||||
Ok("updated")
|
Ok("updated")
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/:id/milestone")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/:id/milestone")(writableUsersOnly { repository =>
|
||||||
updateMilestoneId(repository.owner, repository.name, params("id").toInt, milestoneId("milestoneId"))
|
updateMilestoneId(repository.owner, repository.name, params("id").toInt, milestoneId("milestoneId"))
|
||||||
milestoneId("milestoneId").map { milestoneId =>
|
milestoneId("milestoneId").map { milestoneId =>
|
||||||
getMilestonesWithIssueCount(repository.owner, repository.name)
|
getMilestonesWithIssueCount(repository.owner, repository.name)
|
||||||
.find(_._1.milestoneId == milestoneId).map { case (_, openCount, closeCount) =>
|
.find(_._1.milestoneId == milestoneId).map { case (_, openCount, closeCount) =>
|
||||||
gitbucket.core.issues.milestones.html.progress(openCount + closeCount, closeCount)
|
gitbucket.core.issues.milestones.html.progress(openCount + closeCount, closeCount)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
} getOrElse Ok()
|
} getOrElse Ok()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/state")(collaboratorsOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/state")(writableUsersOnly { repository =>
|
||||||
defining(params.get("value")){ action =>
|
defining(params.get("value")){ action =>
|
||||||
action match {
|
action match {
|
||||||
case Some("open") => executeBatch(repository) { issueId =>
|
case Some("open") => executeBatch(repository) { issueId =>
|
||||||
@@ -308,17 +332,17 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/label")(collaboratorsOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/label")(writableUsersOnly { repository =>
|
||||||
params("value").toIntOpt.map{ labelId =>
|
params("value").toIntOpt.map{ labelId =>
|
||||||
executeBatch(repository) { issueId =>
|
executeBatch(repository) { issueId =>
|
||||||
getIssueLabel(repository.owner, repository.name, issueId, labelId) getOrElse {
|
getIssueLabel(repository.owner, repository.name, issueId, labelId) getOrElse {
|
||||||
registerIssueLabel(repository.owner, repository.name, issueId, labelId)
|
registerIssueLabel(repository.owner, repository.name, issueId, labelId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/assign")(collaboratorsOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/assign")(writableUsersOnly { repository =>
|
||||||
defining(assignedUserName("value")){ value =>
|
defining(assignedUserName("value")){ value =>
|
||||||
executeBatch(repository) {
|
executeBatch(repository) {
|
||||||
updateAssignedUserName(repository.owner, repository.name, _, value)
|
updateAssignedUserName(repository.owner, repository.name, _, value)
|
||||||
@@ -326,7 +350,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/batchedit/milestone")(collaboratorsOnly { repository =>
|
post("/:owner/:repository/issues/batchedit/milestone")(writableUsersOnly { repository =>
|
||||||
defining(milestoneId("value")){ value =>
|
defining(milestoneId("value")){ value =>
|
||||||
executeBatch(repository) {
|
executeBatch(repository) {
|
||||||
updateMilestoneId(repository.owner, repository.name, _, value)
|
updateMilestoneId(repository.owner, repository.name, _, value)
|
||||||
@@ -342,15 +366,12 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
RawData(FileUtil.getMimeType(file.getName), file)
|
RawData(FileUtil.getMimeType(file.getName), file)
|
||||||
}
|
}
|
||||||
case _ => None
|
case _ => None
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
val assignedUserName = (key: String) => params.get(key) filter (_.trim != "")
|
val assignedUserName = (key: String) => params.get(key) filter (_.trim != "")
|
||||||
val milestoneId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
|
val milestoneId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
|
||||||
|
|
||||||
private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean =
|
|
||||||
hasWritePermission(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
|
||||||
|
|
||||||
private def executeBatch(repository: RepositoryService.RepositoryInfo)(execute: Int => Unit) = {
|
private def executeBatch(repository: RepositoryService.RepositoryInfo)(execute: Int => Unit) = {
|
||||||
params("checked").split(',') map(_.toInt) foreach execute
|
params("checked").split(',') map(_.toInt) foreach execute
|
||||||
params("from") match {
|
params("from") match {
|
||||||
@@ -361,37 +382,51 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
private def searchIssues(repository: RepositoryService.RepositoryInfo) = {
|
private def searchIssues(repository: RepositoryService.RepositoryInfo) = {
|
||||||
defining(repository.owner, repository.name){ case (owner, repoName) =>
|
defining(repository.owner, repository.name){ case (owner, repoName) =>
|
||||||
val page = IssueSearchCondition.page(request)
|
val page = IssueSearchCondition.page(request)
|
||||||
val sessionKey = Keys.Session.Issues(owner, repoName)
|
|
||||||
|
|
||||||
// retrieve search condition
|
// retrieve search condition
|
||||||
val condition = session.putAndGet(sessionKey,
|
val condition = IssueSearchCondition(request)
|
||||||
if(request.hasQueryString){
|
|
||||||
val q = request.getParameter("q")
|
|
||||||
if(q == null || q.trim.isEmpty){
|
|
||||||
IssueSearchCondition(request)
|
|
||||||
} else {
|
|
||||||
IssueSearchCondition(q, getMilestones(owner, repoName).map(x => (x.title, x.milestoneId)).toMap)
|
|
||||||
}
|
|
||||||
} else session.getAs[IssueSearchCondition](sessionKey).getOrElse(IssueSearchCondition())
|
|
||||||
)
|
|
||||||
|
|
||||||
html.list(
|
html.list(
|
||||||
"issues",
|
"issues",
|
||||||
searchIssue(condition, false, (page - 1) * IssueLimit, IssueLimit, owner -> repoName),
|
searchIssue(condition, false, (page - 1) * IssueLimit, IssueLimit, owner -> repoName),
|
||||||
page,
|
page,
|
||||||
if(!getAccountByUserName(owner).exists(_.isGroupAccount)){
|
getAssignableUserNames(owner, repoName),
|
||||||
(getCollaborators(owner, repoName) :+ owner).sorted
|
|
||||||
} else {
|
|
||||||
getCollaborators(owner, repoName)
|
|
||||||
},
|
|
||||||
getMilestones(owner, repoName),
|
getMilestones(owner, repoName),
|
||||||
getLabels(owner, repoName),
|
getLabels(owner, repoName),
|
||||||
countIssue(condition.copy(state = "open" ), false, owner -> repoName),
|
countIssue(condition.copy(state = "open" ), false, owner -> repoName),
|
||||||
countIssue(condition.copy(state = "closed"), false, owner -> repoName),
|
countIssue(condition.copy(state = "closed"), false, owner -> repoName),
|
||||||
condition,
|
condition,
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(owner, repoName, context.loginAccount))
|
isEditable(repository),
|
||||||
|
isManageable(repository))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an logged-in user can manage issues.
|
||||||
|
*/
|
||||||
|
private def isManageable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||||
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an logged-in user can post issues.
|
||||||
|
*/
|
||||||
|
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||||
|
repository.repository.options.issuesOption match {
|
||||||
|
case "ALL" => !repository.repository.isPrivate && context.loginAccount.isDefined
|
||||||
|
case "PUBLIC" => hasGuestRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
case "PRIVATE" => hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
case "DISABLE" => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an issue or a comment is editable by a logged-in user.
|
||||||
|
*/
|
||||||
|
private def isEditableContent(owner: String, repository: String, author: String)(implicit context: Context): Boolean = {
|
||||||
|
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package gitbucket.core.controller
|
|||||||
|
|
||||||
import gitbucket.core.issues.labels.html
|
import gitbucket.core.issues.labels.html
|
||||||
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, LabelsService}
|
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, LabelsService}
|
||||||
import gitbucket.core.util.{ReferrerAuthenticator, CollaboratorsAuthenticator}
|
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import io.github.gitbucket.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.scalatra.i18n.Messages
|
import org.scalatra.i18n.Messages
|
||||||
@@ -10,11 +10,11 @@ import org.scalatra.Ok
|
|||||||
|
|
||||||
class LabelsController extends LabelsControllerBase
|
class LabelsController extends LabelsControllerBase
|
||||||
with LabelsService with IssuesService with RepositoryService with AccountService
|
with LabelsService with IssuesService with RepositoryService with AccountService
|
||||||
with ReferrerAuthenticator with CollaboratorsAuthenticator
|
with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||||
|
|
||||||
trait LabelsControllerBase extends ControllerBase {
|
trait LabelsControllerBase extends ControllerBase {
|
||||||
self: LabelsService with IssuesService with RepositoryService
|
self: LabelsService with IssuesService with RepositoryService
|
||||||
with ReferrerAuthenticator with CollaboratorsAuthenticator =>
|
with ReferrerAuthenticator with WritableUsersAuthenticator =>
|
||||||
|
|
||||||
case class LabelForm(labelName: String, color: String)
|
case class LabelForm(labelName: String, color: String)
|
||||||
|
|
||||||
@@ -29,40 +29,40 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
getLabels(repository.owner, repository.name),
|
getLabels(repository.owner, repository.name),
|
||||||
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issues/labels/new")(collaboratorsOnly { repository =>
|
ajaxGet("/:owner/:repository/issues/labels/new")(writableUsersOnly { repository =>
|
||||||
html.edit(None, repository)
|
html.edit(None, repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/labels/new", labelForm)(collaboratorsOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/issues/labels/new", labelForm)(writableUsersOnly { (form, repository) =>
|
||||||
val labelId = createLabel(repository.owner, repository.name, form.labelName, form.color.substring(1))
|
val labelId = createLabel(repository.owner, repository.name, form.labelName, form.color.substring(1))
|
||||||
html.label(
|
html.label(
|
||||||
getLabel(repository.owner, repository.name, labelId).get,
|
getLabel(repository.owner, repository.name, labelId).get,
|
||||||
// TODO futility
|
// TODO futility
|
||||||
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issues/labels/:labelId/edit")(collaboratorsOnly { repository =>
|
ajaxGet("/:owner/:repository/issues/labels/:labelId/edit")(writableUsersOnly { repository =>
|
||||||
getLabel(repository.owner, repository.name, params("labelId").toInt).map { label =>
|
getLabel(repository.owner, repository.name, params("labelId").toInt).map { label =>
|
||||||
html.edit(Some(label), repository)
|
html.edit(Some(label), repository)
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/labels/:labelId/edit", labelForm)(collaboratorsOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/issues/labels/:labelId/edit", labelForm)(writableUsersOnly { (form, repository) =>
|
||||||
updateLabel(repository.owner, repository.name, params("labelId").toInt, form.labelName, form.color.substring(1))
|
updateLabel(repository.owner, repository.name, params("labelId").toInt, form.labelName, form.color.substring(1))
|
||||||
html.label(
|
html.label(
|
||||||
getLabel(repository.owner, repository.name, params("labelId").toInt).get,
|
getLabel(repository.owner, repository.name, params("labelId").toInt).get,
|
||||||
// TODO futility
|
// TODO futility
|
||||||
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
countIssueGroupByLabels(repository.owner, repository.name, IssuesService.IssueSearchCondition(), Map.empty),
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/labels/:labelId/delete")(collaboratorsOnly { repository =>
|
ajaxPost("/:owner/:repository/issues/labels/:labelId/delete")(writableUsersOnly { repository =>
|
||||||
deleteLabel(repository.owner, repository.name, params("labelId").toInt)
|
deleteLabel(repository.owner, repository.name, params("labelId").toInt)
|
||||||
Ok()
|
Ok()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ package gitbucket.core.controller
|
|||||||
|
|
||||||
import gitbucket.core.issues.milestones.html
|
import gitbucket.core.issues.milestones.html
|
||||||
import gitbucket.core.service.{RepositoryService, MilestonesService, AccountService}
|
import gitbucket.core.service.{RepositoryService, MilestonesService, AccountService}
|
||||||
import gitbucket.core.util.{ReferrerAuthenticator, CollaboratorsAuthenticator}
|
import gitbucket.core.util.{ReferrerAuthenticator, WritableUsersAuthenticator}
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import io.github.gitbucket.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
|
|
||||||
class MilestonesController extends MilestonesControllerBase
|
class MilestonesController extends MilestonesControllerBase
|
||||||
with MilestonesService with RepositoryService with AccountService
|
with MilestonesService with RepositoryService with AccountService
|
||||||
with ReferrerAuthenticator with CollaboratorsAuthenticator
|
with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||||
|
|
||||||
trait MilestonesControllerBase extends ControllerBase {
|
trait MilestonesControllerBase extends ControllerBase {
|
||||||
self: MilestonesService with RepositoryService
|
self: MilestonesService with RepositoryService
|
||||||
with ReferrerAuthenticator with CollaboratorsAuthenticator =>
|
with ReferrerAuthenticator with WritableUsersAuthenticator =>
|
||||||
|
|
||||||
case class MilestoneForm(title: String, description: Option[String], dueDate: Option[java.util.Date])
|
case class MilestoneForm(title: String, description: Option[String], dueDate: Option[java.util.Date])
|
||||||
|
|
||||||
@@ -27,58 +27,58 @@ trait MilestonesControllerBase extends ControllerBase {
|
|||||||
params.getOrElse("state", "open"),
|
params.getOrElse("state", "open"),
|
||||||
getMilestonesWithIssueCount(repository.owner, repository.name),
|
getMilestonesWithIssueCount(repository.owner, repository.name),
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/new")(collaboratorsOnly {
|
get("/:owner/:repository/issues/milestones/new")(writableUsersOnly {
|
||||||
html.edit(None, _)
|
html.edit(None, _)
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/milestones/new", milestoneForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/issues/milestones/new", milestoneForm)(writableUsersOnly { (form, repository) =>
|
||||||
createMilestone(repository.owner, repository.name, form.title, form.description, form.dueDate)
|
createMilestone(repository.owner, repository.name, form.title, form.description, form.dueDate)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/:milestoneId/edit")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/issues/milestones/:milestoneId/edit")(writableUsersOnly { repository =>
|
||||||
params("milestoneId").toIntOpt.map{ milestoneId =>
|
params("milestoneId").toIntOpt.map{ milestoneId =>
|
||||||
html.edit(getMilestone(repository.owner, repository.name, milestoneId), repository)
|
html.edit(getMilestone(repository.owner, repository.name, milestoneId), repository)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/milestones/:milestoneId/edit", milestoneForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/issues/milestones/:milestoneId/edit", milestoneForm)(writableUsersOnly { (form, repository) =>
|
||||||
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
||||||
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
||||||
updateMilestone(milestone.copy(title = form.title, description = form.description, dueDate = form.dueDate))
|
updateMilestone(milestone.copy(title = form.title, description = form.description, dueDate = form.dueDate))
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/:milestoneId/close")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/issues/milestones/:milestoneId/close")(writableUsersOnly { repository =>
|
||||||
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
||||||
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
||||||
closeMilestone(milestone)
|
closeMilestone(milestone)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/:milestoneId/open")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/issues/milestones/:milestoneId/open")(writableUsersOnly { repository =>
|
||||||
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
||||||
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
||||||
openMilestone(milestone)
|
openMilestone(milestone)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/milestones/:milestoneId/delete")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/issues/milestones/:milestoneId/delete")(writableUsersOnly { repository =>
|
||||||
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
params("milestoneId").toIntOpt.flatMap{ milestoneId =>
|
||||||
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
getMilestone(repository.owner, repository.name, milestoneId).map { milestone =>
|
||||||
deleteMilestone(repository.owner, repository.name, milestone.milestoneId)
|
deleteMilestone(repository.owner, repository.name, milestone.milestoneId)
|
||||||
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
redirect(s"/${repository.owner}/${repository.name}/issues/milestones")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,36 +6,32 @@ import gitbucket.core.service.CommitStatusService
|
|||||||
import gitbucket.core.service.MergeService
|
import gitbucket.core.service.MergeService
|
||||||
import gitbucket.core.service.IssuesService._
|
import gitbucket.core.service.IssuesService._
|
||||||
import gitbucket.core.service.PullRequestService._
|
import gitbucket.core.service.PullRequestService._
|
||||||
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.JGitUtil._
|
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
import gitbucket.core.view
|
|
||||||
import gitbucket.core.view.helpers
|
|
||||||
|
|
||||||
import io.github.gitbucket.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.lib.PersonIdent
|
import org.eclipse.jgit.lib.PersonIdent
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
|
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
|
|
||||||
class PullRequestsController extends PullRequestsControllerBase
|
class PullRequestsController extends PullRequestsControllerBase
|
||||||
with RepositoryService with AccountService with IssuesService with PullRequestService with MilestonesService with LabelsService
|
with RepositoryService with AccountService with IssuesService with PullRequestService with MilestonesService with LabelsService
|
||||||
with CommitsService with ActivityService with WebHookPullRequestService with ReferrerAuthenticator with CollaboratorsAuthenticator
|
with CommitsService with ActivityService with WebHookPullRequestService
|
||||||
|
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||||
with CommitStatusService with MergeService with ProtectedBranchService
|
with CommitStatusService with MergeService with ProtectedBranchService
|
||||||
|
|
||||||
|
|
||||||
trait PullRequestsControllerBase extends ControllerBase {
|
trait PullRequestsControllerBase extends ControllerBase {
|
||||||
self: RepositoryService with AccountService with IssuesService with MilestonesService with LabelsService
|
self: RepositoryService with AccountService with IssuesService with MilestonesService with LabelsService
|
||||||
with CommitsService with ActivityService with PullRequestService with WebHookPullRequestService with ReferrerAuthenticator with CollaboratorsAuthenticator
|
with CommitsService with ActivityService with PullRequestService with WebHookPullRequestService
|
||||||
|
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator
|
||||||
with CommitStatusService with MergeService with ProtectedBranchService =>
|
with CommitStatusService with MergeService with ProtectedBranchService =>
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(classOf[PullRequestsControllerBase])
|
|
||||||
|
|
||||||
val pullRequestForm = mapping(
|
val pullRequestForm = mapping(
|
||||||
"title" -> trim(label("Title" , text(required, maxlength(100)))),
|
"title" -> trim(label("Title" , text(required, maxlength(100)))),
|
||||||
"content" -> trim(label("Content", optional(text()))),
|
"content" -> trim(label("Content", optional(text()))),
|
||||||
@@ -94,17 +90,18 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
(commits.flatten.map(commit => getCommitComments(owner, name, commit.id, true)).flatten.toList ::: getComments(owner, name, issueId))
|
(commits.flatten.map(commit => getCommitComments(owner, name, commit.id, true)).flatten.toList ::: getComments(owner, name, issueId))
|
||||||
.sortWith((a, b) => a.registeredDate before b.registeredDate),
|
.sortWith((a, b) => a.registeredDate before b.registeredDate),
|
||||||
getIssueLabels(owner, name, issueId),
|
getIssueLabels(owner, name, issueId),
|
||||||
(getCollaborators(owner, name) ::: (if(getAccountByUserName(owner).get.isGroupAccount) Nil else List(owner))).sorted,
|
getAssignableUserNames(owner, name),
|
||||||
getMilestonesWithIssueCount(owner, name),
|
getMilestonesWithIssueCount(owner, name),
|
||||||
getLabels(owner, name),
|
getLabels(owner, name),
|
||||||
commits,
|
commits,
|
||||||
diffs,
|
diffs,
|
||||||
hasWritePermission(owner, name, context.loginAccount),
|
isEditable(repository),
|
||||||
|
isManageable(repository),
|
||||||
repository,
|
repository,
|
||||||
flash.toMap.map(f => f._1 -> f._2.toString))
|
flash.toMap.map(f => f._1 -> f._2.toString))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/pull/:id/mergeguide")(referrersOnly { repository =>
|
ajaxGet("/:owner/:repository/pull/:id/mergeguide")(referrersOnly { repository =>
|
||||||
@@ -115,7 +112,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
val hasConflict = LockUtil.lock(s"${owner}/${name}"){
|
val hasConflict = LockUtil.lock(s"${owner}/${name}"){
|
||||||
checkConflict(owner, name, pullreq.branch, issueId)
|
checkConflict(owner, name, pullreq.branch, issueId)
|
||||||
}
|
}
|
||||||
val hasMergePermission = hasWritePermission(owner, name, context.loginAccount)
|
val hasMergePermission = hasDeveloperRole(owner, name, context.loginAccount)
|
||||||
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.branch)
|
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.branch)
|
||||||
val mergeStatus = PullRequestService.MergeStatus(
|
val mergeStatus = PullRequestService.MergeStatus(
|
||||||
hasConflict = hasConflict,
|
hasConflict = hasConflict,
|
||||||
@@ -125,7 +122,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
needStatusCheck = context.loginAccount.map{ u =>
|
needStatusCheck = context.loginAccount.map{ u =>
|
||||||
branchProtection.needStatusCheck(u.userName)
|
branchProtection.needStatusCheck(u.userName)
|
||||||
}.getOrElse(true),
|
}.getOrElse(true),
|
||||||
hasUpdatePermission = hasWritePermission(pullreq.requestUserName, pullreq.requestRepositoryName, context.loginAccount) &&
|
hasUpdatePermission = hasDeveloperRole(pullreq.requestUserName, pullreq.requestRepositoryName, context.loginAccount) &&
|
||||||
context.loginAccount.map{ u =>
|
context.loginAccount.map{ u =>
|
||||||
!getProtectedBranchInfo(pullreq.requestUserName, pullreq.requestRepositoryName, pullreq.requestBranch).needStatusCheck(u.userName)
|
!getProtectedBranchInfo(pullreq.requestUserName, pullreq.requestRepositoryName, pullreq.requestBranch).needStatusCheck(u.userName)
|
||||||
}.getOrElse(false),
|
}.getOrElse(false),
|
||||||
@@ -138,10 +135,10 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
repository,
|
repository,
|
||||||
getRepository(pullreq.requestUserName, pullreq.requestRepositoryName).get)
|
getRepository(pullreq.requestUserName, pullreq.requestRepositoryName).get)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/pull/:id/delete/*")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/pull/:id/delete/*")(writableUsersOnly { repository =>
|
||||||
params("id").toIntOpt.map { issueId =>
|
params("id").toIntOpt.map { issueId =>
|
||||||
val branchName = multiParams("splat").head
|
val branchName = multiParams("splat").head
|
||||||
val userName = context.loginAccount.get.userName
|
val userName = context.loginAccount.get.userName
|
||||||
@@ -153,27 +150,27 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
createComment(repository.owner, repository.name, userName, issueId, branchName, "delete_branch")
|
createComment(repository.owner, repository.name, userName, issueId, branchName, "delete_branch")
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/pull/:id/update_branch")(referrersOnly { baseRepository =>
|
post("/:owner/:repository/pull/:id/update_branch")(writableUsersOnly { baseRepository =>
|
||||||
(for {
|
(for {
|
||||||
issueId <- params("id").toIntOpt
|
issueId <- params("id").toIntOpt
|
||||||
loginAccount <- context.loginAccount
|
loginAccount <- context.loginAccount
|
||||||
(issue, pullreq) <- getPullRequest(baseRepository.owner, baseRepository.name, issueId)
|
(issue, pullreq) <- getPullRequest(baseRepository.owner, baseRepository.name, issueId)
|
||||||
owner = pullreq.requestUserName
|
owner = pullreq.requestUserName
|
||||||
name = pullreq.requestRepositoryName
|
name = pullreq.requestRepositoryName
|
||||||
if hasWritePermission(owner, name, context.loginAccount)
|
if hasDeveloperRole(owner, name, context.loginAccount)
|
||||||
} yield {
|
} yield {
|
||||||
|
val repository = getRepository(owner, name).get
|
||||||
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.requestBranch)
|
val branchProtection = getProtectedBranchInfo(owner, name, pullreq.requestBranch)
|
||||||
if(branchProtection.needStatusCheck(loginAccount.userName)){
|
if(branchProtection.needStatusCheck(loginAccount.userName)){
|
||||||
flash += "error" -> s"branch ${pullreq.requestBranch} is protected need status check."
|
flash += "error" -> s"branch ${pullreq.requestBranch} is protected need status check."
|
||||||
} else {
|
} else {
|
||||||
val repository = getRepository(owner, name).get
|
|
||||||
LockUtil.lock(s"${owner}/${name}"){
|
LockUtil.lock(s"${owner}/${name}"){
|
||||||
val alias = if(pullreq.repositoryName == pullreq.requestRepositoryName && pullreq.userName == pullreq.requestUserName){
|
val alias = if(pullreq.repositoryName == pullreq.requestRepositoryName && pullreq.userName == pullreq.requestUserName){
|
||||||
pullreq.branch
|
pullreq.branch
|
||||||
}else{
|
} else {
|
||||||
s"${pullreq.userName}:${pullreq.branch}"
|
s"${pullreq.userName}:${pullreq.branch}"
|
||||||
}
|
}
|
||||||
val existIds = using(Git.open(Directory.getRepositoryDir(owner, name))) { git => JGitUtil.getAllCommitIds(git) }.toSet
|
val existIds = using(Git.open(Directory.getRepositoryDir(owner, name))) { git => JGitUtil.getAllCommitIds(git) }.toSet
|
||||||
@@ -187,11 +184,10 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
using(Git.open(Directory.getRepositoryDir(owner, name))) { git =>
|
using(Git.open(Directory.getRepositoryDir(owner, name))) { git =>
|
||||||
// after update branch
|
// after update branch
|
||||||
|
|
||||||
val newCommitId = git.getRepository.resolve(s"refs/heads/${pullreq.requestBranch}")
|
val newCommitId = git.getRepository.resolve(s"refs/heads/${pullreq.requestBranch}")
|
||||||
val commits = git.log.addRange(oldId, newCommitId).call.iterator.asScala.map(c => new JGitUtil.CommitInfo(c)).toList
|
val commits = git.log.addRange(oldId, newCommitId).call.iterator.asScala.map(c => new JGitUtil.CommitInfo(c)).toList
|
||||||
|
|
||||||
commits.foreach{ commit =>
|
commits.foreach { commit =>
|
||||||
if(!existIds.contains(commit.id)){
|
if(!existIds.contains(commit.id)){
|
||||||
createIssueComment(owner, name, commit)
|
createIssueComment(owner, name, commit)
|
||||||
}
|
}
|
||||||
@@ -220,12 +216,13 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
flash += "info" -> s"Merge branch '${alias}' into ${pullreq.requestBranch}"
|
flash += "info" -> s"Merge branch '${alias}' into ${pullreq.requestBranch}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
|
||||||
}
|
}
|
||||||
}) getOrElse NotFound
|
redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}")
|
||||||
|
|
||||||
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/pull/:id/merge", mergeForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/pull/:id/merge", mergeForm)(writableUsersOnly { (form, repository) =>
|
||||||
params("id").toIntOpt.flatMap { issueId =>
|
params("id").toIntOpt.flatMap { issueId =>
|
||||||
val owner = repository.owner
|
val owner = repository.owner
|
||||||
val name = repository.name
|
val name = repository.name
|
||||||
@@ -273,7 +270,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/compare")(referrersOnly { forkedRepository =>
|
get("/:owner/:repository/compare")(referrersOnly { forkedRepository =>
|
||||||
@@ -290,7 +287,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
redirect(s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${originUserName}:${oldBranch}...${newBranch}")
|
redirect(s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${originUserName}:${oldBranch}...${newBranch}")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
case _ => {
|
case _ => {
|
||||||
using(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))){ git =>
|
using(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))){ git =>
|
||||||
@@ -374,8 +371,8 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
forkedRepository,
|
forkedRepository,
|
||||||
originRepository,
|
originRepository,
|
||||||
forkedRepository,
|
forkedRepository,
|
||||||
hasWritePermission(originRepository.owner, originRepository.name, context.loginAccount),
|
hasDeveloperRole(originRepository.owner, originRepository.name, context.loginAccount),
|
||||||
(getCollaborators(originRepository.owner, originRepository.name) ::: (if(getAccountByUserName(originRepository.owner).get.isGroupAccount) Nil else List(originRepository.owner))).sorted,
|
getAssignableUserNames(originRepository.owner, originRepository.name),
|
||||||
getMilestones(originRepository.owner, originRepository.name),
|
getMilestones(originRepository.owner, originRepository.name),
|
||||||
getLabels(originRepository.owner, originRepository.name)
|
getLabels(originRepository.owner, originRepository.name)
|
||||||
)
|
)
|
||||||
@@ -386,10 +383,10 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
s"${forkedOwner}:${newId.map(_ => forkedId).getOrElse(forkedRepository.repository.defaultBranch)}")
|
s"${forkedOwner}:${newId.map(_ => forkedId).getOrElse(forkedRepository.repository.defaultBranch)}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/compare/*...*/mergecheck")(collaboratorsOnly { forkedRepository =>
|
ajaxGet("/:owner/:repository/compare/*...*/mergecheck")(readableUsersOnly { forkedRepository =>
|
||||||
val Seq(origin, forked) = multiParams("splat")
|
val Seq(origin, forked) = multiParams("splat")
|
||||||
val (originOwner, tmpOriginBranch) = parseCompareIdentifie(origin, forkedRepository.owner)
|
val (originOwner, tmpOriginBranch) = parseCompareIdentifie(origin, forkedRepository.owner)
|
||||||
val (forkedOwner, tmpForkedBranch) = parseCompareIdentifie(forked, forkedRepository.owner)
|
val (forkedOwner, tmpForkedBranch) = parseCompareIdentifie(forked, forkedRepository.owner)
|
||||||
@@ -416,67 +413,71 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
html.mergecheck(conflict)
|
html.mergecheck(conflict)
|
||||||
}
|
}
|
||||||
}) getOrElse NotFound
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/pulls/new", pullRequestForm)(referrersOnly { (form, repository) =>
|
post("/:owner/:repository/pulls/new", pullRequestForm)(readableUsersOnly { (form, repository) =>
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
val writable = hasWritePermission(owner, name, context.loginAccount)
|
val manageable = isManageable(repository)
|
||||||
val loginUserName = context.loginAccount.get.userName
|
val editable = isEditable(repository)
|
||||||
|
|
||||||
val issueId = createIssue(
|
if(editable) {
|
||||||
owner = repository.owner,
|
val loginUserName = context.loginAccount.get.userName
|
||||||
repository = repository.name,
|
|
||||||
loginUser = loginUserName,
|
|
||||||
title = form.title,
|
|
||||||
content = form.content,
|
|
||||||
assignedUserName = if(writable) form.assignedUserName else None,
|
|
||||||
milestoneId = if(writable) form.milestoneId else None,
|
|
||||||
isPullRequest = true)
|
|
||||||
|
|
||||||
createPullRequest(
|
val issueId = createIssue(
|
||||||
originUserName = repository.owner,
|
owner = repository.owner,
|
||||||
originRepositoryName = repository.name,
|
repository = repository.name,
|
||||||
issueId = issueId,
|
loginUser = loginUserName,
|
||||||
originBranch = form.targetBranch,
|
title = form.title,
|
||||||
requestUserName = form.requestUserName,
|
content = form.content,
|
||||||
requestRepositoryName = form.requestRepositoryName,
|
assignedUserName = if (manageable) form.assignedUserName else None,
|
||||||
requestBranch = form.requestBranch,
|
milestoneId = if (manageable) form.milestoneId else None,
|
||||||
commitIdFrom = form.commitIdFrom,
|
isPullRequest = true)
|
||||||
commitIdTo = form.commitIdTo)
|
|
||||||
|
|
||||||
// insert labels
|
createPullRequest(
|
||||||
if(writable){
|
originUserName = repository.owner,
|
||||||
form.labelNames.map { value =>
|
originRepositoryName = repository.name,
|
||||||
val labels = getLabels(owner, name)
|
issueId = issueId,
|
||||||
value.split(",").foreach { labelName =>
|
originBranch = form.targetBranch,
|
||||||
labels.find(_.labelName == labelName).map { label =>
|
requestUserName = form.requestUserName,
|
||||||
registerIssueLabel(repository.owner, repository.name, issueId, label.labelId)
|
requestRepositoryName = form.requestRepositoryName,
|
||||||
|
requestBranch = form.requestBranch,
|
||||||
|
commitIdFrom = form.commitIdFrom,
|
||||||
|
commitIdTo = form.commitIdTo)
|
||||||
|
|
||||||
|
// insert labels
|
||||||
|
if (manageable) {
|
||||||
|
form.labelNames.map { value =>
|
||||||
|
val labels = getLabels(owner, name)
|
||||||
|
value.split(",").foreach { labelName =>
|
||||||
|
labels.find(_.labelName == labelName).map { label =>
|
||||||
|
registerIssueLabel(repository.owner, repository.name, issueId, label.labelId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// fetch requested branch
|
// fetch requested branch
|
||||||
fetchAsPullRequest(owner, name, form.requestUserName, form.requestRepositoryName, form.requestBranch, issueId)
|
fetchAsPullRequest(owner, name, form.requestUserName, form.requestRepositoryName, form.requestBranch, issueId)
|
||||||
|
|
||||||
// record activity
|
// record activity
|
||||||
recordPullRequestActivity(owner, name, loginUserName, issueId, form.title)
|
recordPullRequestActivity(owner, name, loginUserName, issueId, form.title)
|
||||||
|
|
||||||
// call web hook
|
// call web hook
|
||||||
callPullRequestWebHook("opened", repository, issueId, context.baseUrl, context.loginAccount.get)
|
callPullRequestWebHook("opened", repository, issueId, context.baseUrl, context.loginAccount.get)
|
||||||
|
|
||||||
getIssue(owner, name, issueId.toString) foreach { issue =>
|
getIssue(owner, name, issueId.toString) foreach { issue =>
|
||||||
// extract references and create refer comment
|
// extract references and create refer comment
|
||||||
createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse(""), context.loginAccount.get)
|
createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse(""), context.loginAccount.get)
|
||||||
|
|
||||||
// notifications
|
// notifications
|
||||||
Notifier().toNotify(repository, issue, form.content.getOrElse("")){
|
Notifier().toNotify(repository, issue, form.content.getOrElse("")) {
|
||||||
Notifier.msgPullRequest(s"${context.baseUrl}/${owner}/${name}/pull/${issueId}")
|
Notifier.msgPullRequest(s"${context.baseUrl}/${owner}/${name}/pull/${issueId}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/pull/${issueId}")
|
redirect(s"/${owner}/${name}/pull/${issueId}")
|
||||||
|
} else Unauthorized()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -494,53 +495,45 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
(defaultOwner, value)
|
(defaultOwner, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def getRequestCompareInfo(userName: String, repositoryName: String, branch: String,
|
|
||||||
requestUserName: String, requestRepositoryName: String, requestCommitId: String): (Seq[Seq[CommitInfo]], Seq[DiffInfo]) =
|
|
||||||
using(
|
|
||||||
Git.open(getRepositoryDir(userName, repositoryName)),
|
|
||||||
Git.open(getRepositoryDir(requestUserName, requestRepositoryName))
|
|
||||||
){ (oldGit, newGit) =>
|
|
||||||
val oldId = oldGit.getRepository.resolve(branch)
|
|
||||||
val newId = newGit.getRepository.resolve(requestCommitId)
|
|
||||||
|
|
||||||
val commits = newGit.log.addRange(oldId, newId).call.iterator.asScala.map { revCommit =>
|
|
||||||
new CommitInfo(revCommit)
|
|
||||||
}.toList.splitWith { (commit1, commit2) =>
|
|
||||||
helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
|
||||||
}
|
|
||||||
|
|
||||||
val diffs = JGitUtil.getDiffs(newGit, oldId.getName, newId.getName, true)
|
|
||||||
|
|
||||||
(commits, diffs)
|
|
||||||
}
|
|
||||||
|
|
||||||
private def searchPullRequests(userName: Option[String], repository: RepositoryService.RepositoryInfo) =
|
private def searchPullRequests(userName: Option[String], repository: RepositoryService.RepositoryInfo) =
|
||||||
defining(repository.owner, repository.name){ case (owner, repoName) =>
|
defining(repository.owner, repository.name){ case (owner, repoName) =>
|
||||||
val page = IssueSearchCondition.page(request)
|
val page = IssueSearchCondition.page(request)
|
||||||
val sessionKey = Keys.Session.Pulls(owner, repoName)
|
|
||||||
|
|
||||||
// retrieve search condition
|
// retrieve search condition
|
||||||
val condition = session.putAndGet(sessionKey,
|
val condition = IssueSearchCondition(request)
|
||||||
if(request.hasQueryString) IssueSearchCondition(request)
|
|
||||||
else session.getAs[IssueSearchCondition](sessionKey).getOrElse(IssueSearchCondition())
|
|
||||||
)
|
|
||||||
|
|
||||||
gitbucket.core.issues.html.list(
|
gitbucket.core.issues.html.list(
|
||||||
"pulls",
|
"pulls",
|
||||||
searchIssue(condition, true, (page - 1) * PullRequestLimit, PullRequestLimit, owner -> repoName),
|
searchIssue(condition, true, (page - 1) * PullRequestLimit, PullRequestLimit, owner -> repoName),
|
||||||
page,
|
page,
|
||||||
if(!getAccountByUserName(owner).exists(_.isGroupAccount)){
|
getAssignableUserNames(owner, repoName),
|
||||||
(getCollaborators(owner, repoName) :+ owner).sorted
|
|
||||||
} else {
|
|
||||||
getCollaborators(owner, repoName)
|
|
||||||
},
|
|
||||||
getMilestones(owner, repoName),
|
getMilestones(owner, repoName),
|
||||||
getLabels(owner, repoName),
|
getLabels(owner, repoName),
|
||||||
countIssue(condition.copy(state = "open" ), true, owner -> repoName),
|
countIssue(condition.copy(state = "open" ), true, owner -> repoName),
|
||||||
countIssue(condition.copy(state = "closed"), true, owner -> repoName),
|
countIssue(condition.copy(state = "closed"), true, owner -> repoName),
|
||||||
condition,
|
condition,
|
||||||
repository,
|
repository,
|
||||||
hasWritePermission(owner, repoName, context.loginAccount))
|
isEditable(repository),
|
||||||
|
isManageable(repository))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an logged-in user can manage pull requests.
|
||||||
|
*/
|
||||||
|
private def isManageable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||||
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an logged-in user can post pull requests.
|
||||||
|
*/
|
||||||
|
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||||
|
repository.repository.options.issuesOption match {
|
||||||
|
case "ALL" => !repository.repository.isPrivate && context.loginAccount.isDefined
|
||||||
|
case "PUBLIC" => hasGuestRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
case "PRIVATE" => hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
case "DISABLE" => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,22 +31,22 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
description: Option[String],
|
description: Option[String],
|
||||||
isPrivate: Boolean,
|
isPrivate: Boolean,
|
||||||
enableIssues: Boolean,
|
issuesOption: String,
|
||||||
externalIssuesUrl: Option[String],
|
externalIssuesUrl: Option[String],
|
||||||
enableWiki: Boolean,
|
wikiOption: String,
|
||||||
allowWikiEditing: Boolean,
|
externalWikiUrl: Option[String],
|
||||||
externalWikiUrl: Option[String]
|
allowFork: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
val optionsForm = mapping(
|
val optionsForm = mapping(
|
||||||
"repositoryName" -> trim(label("Repository Name" , text(required, maxlength(40), identifier, renameRepositoryName))),
|
"repositoryName" -> trim(label("Repository Name" , text(required, maxlength(100), identifier, renameRepositoryName))),
|
||||||
"description" -> trim(label("Description" , optional(text()))),
|
"description" -> trim(label("Description" , optional(text()))),
|
||||||
"isPrivate" -> trim(label("Repository Type" , boolean())),
|
"isPrivate" -> trim(label("Repository Type" , boolean())),
|
||||||
"enableIssues" -> trim(label("Enable Issues" , boolean())),
|
"issuesOption" -> trim(label("Issues Option" , text(required, featureOption))),
|
||||||
"externalIssuesUrl" -> trim(label("External Issues URL", optional(text(maxlength(200))))),
|
"externalIssuesUrl" -> trim(label("External Issues URL", optional(text(maxlength(200))))),
|
||||||
"enableWiki" -> trim(label("Enable Wiki" , boolean())),
|
"wikiOption" -> trim(label("Wiki Option" , text(required, featureOption))),
|
||||||
"allowWikiEditing" -> trim(label("Allow Wiki Editing" , boolean())),
|
"externalWikiUrl" -> trim(label("External Wiki URL" , optional(text(maxlength(200))))),
|
||||||
"externalWikiUrl" -> trim(label("External Wiki URL" , optional(text(maxlength(200)))))
|
"allowFork" -> trim(label("Allow Forking" , boolean()))
|
||||||
)(OptionsForm.apply)
|
)(OptionsForm.apply)
|
||||||
|
|
||||||
// for default branch
|
// for default branch
|
||||||
@@ -56,12 +56,12 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
"defaultBranch" -> trim(label("Default Branch" , text(required, maxlength(100))))
|
"defaultBranch" -> trim(label("Default Branch" , text(required, maxlength(100))))
|
||||||
)(DefaultBranchForm.apply)
|
)(DefaultBranchForm.apply)
|
||||||
|
|
||||||
// for collaborator addition
|
// // for collaborator addition
|
||||||
case class CollaboratorForm(userName: String)
|
// case class CollaboratorForm(userName: String)
|
||||||
|
//
|
||||||
val collaboratorForm = mapping(
|
// val collaboratorForm = mapping(
|
||||||
"userName" -> trim(label("Username", text(required, collaborator)))
|
// "userName" -> trim(label("Username", text(required, collaborator)))
|
||||||
)(CollaboratorForm.apply)
|
// )(CollaboratorForm.apply)
|
||||||
|
|
||||||
// for web hook url addition
|
// for web hook url addition
|
||||||
case class WebHookForm(url: String, events: Set[WebHook.Event], ctype: WebHookContentType, token: Option[String])
|
case class WebHookForm(url: String, events: Set[WebHook.Event], ctype: WebHookContentType, token: Option[String])
|
||||||
@@ -107,11 +107,11 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
repository.repository.parentUserName.map { _ =>
|
repository.repository.parentUserName.map { _ =>
|
||||||
repository.repository.isPrivate
|
repository.repository.isPrivate
|
||||||
} getOrElse form.isPrivate,
|
} getOrElse form.isPrivate,
|
||||||
form.enableIssues,
|
form.issuesOption,
|
||||||
form.externalIssuesUrl,
|
form.externalIssuesUrl,
|
||||||
form.enableWiki,
|
form.wikiOption,
|
||||||
form.allowWikiEditing,
|
form.externalWikiUrl,
|
||||||
form.externalWikiUrl
|
form.allowFork
|
||||||
)
|
)
|
||||||
// Change repository name
|
// Change repository name
|
||||||
if(repository.name != form.repositoryName){
|
if(repository.name != form.repositoryName){
|
||||||
@@ -175,22 +175,12 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
repository)
|
repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
post("/:owner/:repository/settings/collaborators")(ownerOnly { repository =>
|
||||||
* Add the collaborator.
|
val collaborators = params("collaborators")
|
||||||
*/
|
removeCollaborators(repository.owner, repository.name)
|
||||||
post("/:owner/:repository/settings/collaborators/add", collaboratorForm)(ownerOnly { (form, repository) =>
|
collaborators.split(",").withFilter(_.nonEmpty).map { collaborator =>
|
||||||
if(!getAccountByUserName(repository.owner).get.isGroupAccount){
|
val userName :: role :: Nil = collaborator.split(":").toList
|
||||||
addCollaborator(repository.owner, repository.name, form.userName)
|
addCollaborator(repository.owner, repository.name, userName, role)
|
||||||
}
|
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/collaborators")
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the collaborator.
|
|
||||||
*/
|
|
||||||
get("/:owner/:repository/settings/collaborators/remove")(ownerOnly { repository =>
|
|
||||||
if(!getAccountByUserName(repository.owner).get.isGroupAccount){
|
|
||||||
removeCollaborator(repository.owner, repository.name, params("name"))
|
|
||||||
}
|
}
|
||||||
redirect(s"/${repository.owner}/${repository.name}/settings/collaborators")
|
redirect(s"/${repository.owner}/${repository.name}/settings/collaborators")
|
||||||
})
|
})
|
||||||
@@ -248,7 +238,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
val dummyWebHookInfo = WebHook(repository.owner, repository.name, url, ctype, token)
|
val dummyWebHookInfo = WebHook(repository.owner, repository.name, url, ctype, token)
|
||||||
val dummyPayload = {
|
val dummyPayload = {
|
||||||
val ownerAccount = getAccountByUserName(repository.owner).get
|
val ownerAccount = getAccountByUserName(repository.owner).get
|
||||||
val commits = if(repository.commitCount == 0) List.empty else git.log
|
val commits = if(JGitUtil.isEmpty(git)) List.empty else git.log
|
||||||
.add(git.getRepository.resolve(repository.repository.defaultBranch))
|
.add(git.getRepository.resolve(repository.repository.defaultBranch))
|
||||||
.setMaxCount(4)
|
.setMaxCount(4)
|
||||||
.call.iterator.asScala.map(new CommitInfo(_)).toList
|
.call.iterator.asScala.map(new CommitInfo(_)).toList
|
||||||
@@ -297,7 +287,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
get("/:owner/:repository/settings/hooks/edit")(ownerOnly { repository =>
|
get("/:owner/:repository/settings/hooks/edit")(ownerOnly { repository =>
|
||||||
getWebHook(repository.owner, repository.name, params("url")).map{ case (webhook, events) =>
|
getWebHook(repository.owner, repository.name, params("url")).map{ case (webhook, events) =>
|
||||||
html.edithooks(webhook, events, repository, flash.get("info"), false)
|
html.edithooks(webhook, events, repository, flash.get("info"), false)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -394,20 +384,20 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Provides Constraint to validate the collaborator name.
|
// * Provides Constraint to validate the collaborator name.
|
||||||
*/
|
// */
|
||||||
private def collaborator: Constraint = new Constraint(){
|
// private def collaborator: Constraint = new Constraint(){
|
||||||
override def validate(name: String, value: String, messages: Messages): Option[String] =
|
// override def validate(name: String, value: String, messages: Messages): Option[String] =
|
||||||
getAccountByUserName(value) match {
|
// getAccountByUserName(value) match {
|
||||||
case None => Some("User does not exist.")
|
// case None => Some("User does not exist.")
|
||||||
case Some(x) if(x.isGroupAccount)
|
//// case Some(x) if(x.isGroupAccount)
|
||||||
=> Some("User does not exist.")
|
//// => Some("User does not exist.")
|
||||||
case Some(x) if(x.userName == params("owner") || getCollaborators(params("owner"), params("repository")).contains(x.userName))
|
// case Some(x) if(x.userName == params("owner") || getCollaborators(params("owner"), params("repository")).contains(x.userName))
|
||||||
=> Some("User can access this repository already.")
|
// => Some(value + " is repository owner.") // TODO also group members?
|
||||||
case _ => None
|
// case _ => None
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicate check for the rename repository name.
|
* Duplicate check for the rename repository name.
|
||||||
@@ -421,6 +411,15 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private def featureOption: Constraint = new Constraint(){
|
||||||
|
override def validate(name: String, value: String, params: Map[String, String], messages: Messages): Option[String] =
|
||||||
|
if(Seq("DISABLE", "PRIVATE", "PUBLIC", "ALL").contains(value)) None else Some("Option is invalid.")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Constraint to validate the repository transfer user.
|
* Provides Constraint to validate the repository transfer user.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import org.scalatra._
|
|||||||
|
|
||||||
class RepositoryViewerController extends RepositoryViewerControllerBase
|
class RepositoryViewerController extends RepositoryViewerControllerBase
|
||||||
with RepositoryService with AccountService with ActivityService with IssuesService with WebHookService with CommitsService
|
with RepositoryService with AccountService with ActivityService with IssuesService with WebHookService with CommitsService
|
||||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator with PullRequestService with CommitStatusService
|
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator with PullRequestService with CommitStatusService
|
||||||
with WebHookPullRequestService with WebHookPullRequestReviewCommentService with ProtectedBranchService
|
with WebHookPullRequestService with WebHookPullRequestReviewCommentService with ProtectedBranchService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +39,7 @@ class RepositoryViewerController extends RepositoryViewerControllerBase
|
|||||||
*/
|
*/
|
||||||
trait RepositoryViewerControllerBase extends ControllerBase {
|
trait RepositoryViewerControllerBase extends ControllerBase {
|
||||||
self: RepositoryService with AccountService with ActivityService with IssuesService with WebHookService with CommitsService
|
self: RepositoryService with AccountService with ActivityService with IssuesService with WebHookService with CommitsService
|
||||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator with PullRequestService with CommitStatusService
|
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator with PullRequestService with CommitStatusService
|
||||||
with WebHookPullRequestService with WebHookPullRequestReviewCommentService with ProtectedBranchService =>
|
with WebHookPullRequestService with WebHookPullRequestReviewCommentService with ProtectedBranchService =>
|
||||||
|
|
||||||
ArchiveCommand.registerFormat("zip", new ZipFormat)
|
ArchiveCommand.registerFormat("zip", new ZipFormat)
|
||||||
@@ -110,22 +110,27 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
enableLineBreaks = params("enableLineBreaks").toBoolean,
|
enableLineBreaks = params("enableLineBreaks").toBoolean,
|
||||||
enableTaskList = params("enableTaskList").toBoolean,
|
enableTaskList = params("enableTaskList").toBoolean,
|
||||||
enableAnchor = false,
|
enableAnchor = false,
|
||||||
hasWritePermission = hasWritePermission(repository.owner, repository.name, context.loginAccount)
|
hasWritePermission = hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the file list of the repository root and the default branch.
|
* Displays the file list of the repository root and the default branch.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository")(referrersOnly {
|
get("/:owner/:repository") {
|
||||||
fileList(_)
|
params.get("go-get") match {
|
||||||
})
|
case Some("1") => defining(request.paths){ paths =>
|
||||||
|
getRepository(paths(0), paths(1)).map(gitbucket.core.html.goget(_))getOrElse NotFound()
|
||||||
|
}
|
||||||
|
case _ => referrersOnly(fileList(_))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the file list of the specified path and branch.
|
* Displays the file list of the specified path and branch.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/tree/*")(referrersOnly { repository =>
|
get("/:owner/:repository/tree/*")(referrersOnly { repository =>
|
||||||
val (id, path) = splitPath(repository, multiParams("splat").head)
|
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||||
if(path.isEmpty){
|
if(path.isEmpty){
|
||||||
fileList(repository, id)
|
fileList(repository, id)
|
||||||
} else {
|
} else {
|
||||||
@@ -137,7 +142,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
* Displays the commit list of the specified resource.
|
* Displays the commit list of the specified resource.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/commits/*")(referrersOnly { repository =>
|
get("/:owner/:repository/commits/*")(referrersOnly { repository =>
|
||||||
val (branchName, path) = splitPath(repository, multiParams("splat").head)
|
val (branchName, path) = repository.splitPath(multiParams("splat").head)
|
||||||
val page = params.get("page").flatMap(_.toIntOpt).getOrElse(1)
|
val page = params.get("page").flatMap(_.toIntOpt).getOrElse(1)
|
||||||
|
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
@@ -146,22 +151,22 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
html.commits(if(path.isEmpty) Nil else path.split("/").toList, branchName, repository,
|
html.commits(if(path.isEmpty) Nil else path.split("/").toList, branchName, repository,
|
||||||
logs.splitWith{ (commit1, commit2) =>
|
logs.splitWith{ (commit1, commit2) =>
|
||||||
view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
||||||
}, page, hasNext, hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
}, page, hasNext, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
case Left(_) => NotFound
|
case Left(_) => NotFound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/new/*")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/new/*")(writableUsersOnly { repository =>
|
||||||
val (branch, path) = splitPath(repository, multiParams("splat").head)
|
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
||||||
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch).needStatusCheck(context.loginAccount.get.userName)
|
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch).needStatusCheck(context.loginAccount.get.userName)
|
||||||
html.editor(branch, repository, if(path.length == 0) Nil else path.split("/").toList,
|
html.editor(branch, repository, if(path.length == 0) Nil else path.split("/").toList,
|
||||||
None, JGitUtil.ContentInfo("text", None, Some("UTF-8")),
|
None, JGitUtil.ContentInfo("text", None, Some("UTF-8")),
|
||||||
protectedBranch)
|
protectedBranch)
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/edit/*")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/edit/*")(writableUsersOnly { repository =>
|
||||||
val (branch, path) = splitPath(repository, multiParams("splat").head)
|
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
||||||
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch).needStatusCheck(context.loginAccount.get.userName)
|
val protectedBranch = getProtectedBranchInfo(repository.owner, repository.name, branch).needStatusCheck(context.loginAccount.get.userName)
|
||||||
|
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
@@ -172,12 +177,12 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
html.editor(branch, repository, paths.take(paths.size - 1).toList, Some(paths.last),
|
html.editor(branch, repository, paths.take(paths.size - 1).toList, Some(paths.last),
|
||||||
JGitUtil.getContentInfo(git, path, objectId),
|
JGitUtil.getContentInfo(git, path, objectId),
|
||||||
protectedBranch)
|
protectedBranch)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/remove/*")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/remove/*")(writableUsersOnly { repository =>
|
||||||
val (branch, path) = splitPath(repository, multiParams("splat").head)
|
val (branch, path) = repository.splitPath(multiParams("splat").head)
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(branch))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(branch))
|
||||||
|
|
||||||
@@ -185,11 +190,11 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val paths = path.split("/")
|
val paths = path.split("/")
|
||||||
html.delete(branch, repository, paths.take(paths.size - 1).toList, paths.last,
|
html.delete(branch, repository, paths.take(paths.size - 1).toList, paths.last,
|
||||||
JGitUtil.getContentInfo(git, path, objectId))
|
JGitUtil.getContentInfo(git, path, objectId))
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/create", editorForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/create", editorForm)(writableUsersOnly { (form, repository) =>
|
||||||
commitFile(
|
commitFile(
|
||||||
repository = repository,
|
repository = repository,
|
||||||
branch = form.branch,
|
branch = form.branch,
|
||||||
@@ -206,7 +211,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
}")
|
}")
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/update", editorForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/update", editorForm)(writableUsersOnly { (form, repository) =>
|
||||||
commitFile(
|
commitFile(
|
||||||
repository = repository,
|
repository = repository,
|
||||||
branch = form.branch,
|
branch = form.branch,
|
||||||
@@ -227,7 +232,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
}")
|
}")
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/remove", deleteForm)(collaboratorsOnly { (form, repository) =>
|
post("/:owner/:repository/remove", deleteForm)(writableUsersOnly { (form, repository) =>
|
||||||
commitFile(repository, form.branch, form.path, None, Some(form.fileName), "", "",
|
commitFile(repository, form.branch, form.path, None, Some(form.fileName), "", "",
|
||||||
form.message.getOrElse(s"Delete ${form.fileName}"))
|
form.message.getOrElse(s"Delete ${form.fileName}"))
|
||||||
|
|
||||||
@@ -235,7 +240,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/raw/*")(referrersOnly { repository =>
|
get("/:owner/:repository/raw/*")(referrersOnly { repository =>
|
||||||
val (id, path) = splitPath(repository, multiParams("splat").head)
|
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||||
getPathObjectId(git, path, revCommit).flatMap { objectId =>
|
getPathObjectId(git, path, revCommit).flatMap { objectId =>
|
||||||
@@ -245,7 +250,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
loader.copyTo(response.outputStream)
|
loader.copyTo(response.outputStream)
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -253,7 +258,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
* Displays the file content of the specified branch or commit.
|
* Displays the file content of the specified branch or commit.
|
||||||
*/
|
*/
|
||||||
val blobRoute = get("/:owner/:repository/blob/*")(referrersOnly { repository =>
|
val blobRoute = get("/:owner/:repository/blob/*")(referrersOnly { repository =>
|
||||||
val (id, path) = splitPath(repository, multiParams("splat").head)
|
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||||
val raw = params.get("raw").getOrElse("false").toBoolean
|
val raw = params.get("raw").getOrElse("false").toBoolean
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||||
@@ -265,15 +270,15 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
response.setContentLength(loader.getSize.toInt)
|
response.setContentLength(loader.getSize.toInt)
|
||||||
loader.copyTo(response.outputStream)
|
loader.copyTo(response.outputStream)
|
||||||
()
|
()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
} else {
|
} else {
|
||||||
html.blob(id, repository, path.split("/").toList,
|
html.blob(id, repository, path.split("/").toList,
|
||||||
JGitUtil.getContentInfo(git, path, objectId),
|
JGitUtil.getContentInfo(git, path, objectId),
|
||||||
new JGitUtil.CommitInfo(JGitUtil.getLastModifiedCommit(git, revCommit, path)),
|
new JGitUtil.CommitInfo(JGitUtil.getLastModifiedCommit(git, revCommit, path)),
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount),
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||||
request.paths(2) == "blame")
|
request.paths(2) == "blame")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -285,7 +290,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
* Blame data.
|
* Blame data.
|
||||||
*/
|
*/
|
||||||
ajaxGet("/:owner/:repository/get-blame/*")(referrersOnly { repository =>
|
ajaxGet("/:owner/:repository/get-blame/*")(referrersOnly { repository =>
|
||||||
val (id, path) = splitPath(repository, multiParams("splat").head)
|
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
val last = git.log.add(git.getRepository.resolve(id)).addPath(path).setMaxCount(1).call.iterator.next.name
|
val last = git.log.add(git.getRepository.resolve(id)).addPath(path).setMaxCount(1).call.iterator.next.name
|
||||||
@@ -323,13 +328,13 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
html.commit(id, new JGitUtil.CommitInfo(revCommit),
|
html.commit(id, new JGitUtil.CommitInfo(revCommit),
|
||||||
JGitUtil.getBranchesOfCommit(git, revCommit.getName),
|
JGitUtil.getBranchesOfCommit(git, revCommit.getName),
|
||||||
JGitUtil.getTagsOfCommit(git, revCommit.getName),
|
JGitUtil.getTagsOfCommit(git, revCommit.getName),
|
||||||
getCommitComments(repository.owner, repository.name, id, false),
|
getCommitComments(repository.owner, repository.name, id, true),
|
||||||
repository, diffs, oldCommitId, hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
repository, diffs, oldCommitId, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
case e:MissingObjectException => NotFound
|
case e:MissingObjectException => NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -353,7 +358,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
html.commentform(
|
html.commentform(
|
||||||
commitId = id,
|
commitId = id,
|
||||||
fileName, oldLineNumber, newLineNumber, issueId,
|
fileName, oldLineNumber, newLineNumber, issueId,
|
||||||
hasWritePermission = hasWritePermission(repository.owner, repository.name, context.loginAccount),
|
hasWritePermission = hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||||
repository = repository
|
repository = repository
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -369,15 +374,14 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
callPullRequestReviewCommentWebHook("create", comment, repository, issueId, context.baseUrl, context.loginAccount.get)
|
callPullRequestReviewCommentWebHook("create", comment, repository, issueId, context.baseUrl, context.loginAccount.get)
|
||||||
case None => recordCommentCommitActivity(repository.owner, repository.name, context.loginAccount.get.userName, id, form.content)
|
case None => recordCommentCommitActivity(repository.owner, repository.name, context.loginAccount.get.userName, id, form.content)
|
||||||
}
|
}
|
||||||
helper.html.commitcomment(comment, hasWritePermission(repository.owner, repository.name, context.loginAccount), repository)
|
helper.html.commitcomment(comment, hasDeveloperRole(repository.owner, repository.name, context.loginAccount), repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/commit_comments/_data/:id")(readableUsersOnly { repository =>
|
ajaxGet("/:owner/:repository/commit_comments/_data/:id")(readableUsersOnly { repository =>
|
||||||
getCommitComment(repository.owner, repository.name, params("id")) map { x =>
|
getCommitComment(repository.owner, repository.name, params("id")) map { x =>
|
||||||
if(isEditable(x.userName, x.repositoryName, x.commentedUserName)){
|
if(isEditable(x.userName, x.repositoryName, x.commentedUserName)){
|
||||||
params.get("dataType") collect {
|
params.get("dataType") collect {
|
||||||
case t if t == "html" => html.editcomment(
|
case t if t == "html" => html.editcomment(x.content, x.commentId, repository)
|
||||||
x.content, x.commentId, x.userName, x.repositoryName)
|
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
contentType = formats("json")
|
contentType = formats("json")
|
||||||
org.json4s.jackson.Serialization.write(
|
org.json4s.jackson.Serialization.write(
|
||||||
@@ -389,12 +393,12 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
enableRefsLink = true,
|
enableRefsLink = true,
|
||||||
enableAnchor = true,
|
enableAnchor = true,
|
||||||
enableLineBreaks = true,
|
enableLineBreaks = true,
|
||||||
hasWritePermission = isEditable(x.userName, x.repositoryName, x.commentedUserName)
|
hasWritePermission = true
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/commit_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
ajaxPost("/:owner/:repository/commit_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
@@ -403,8 +407,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
if(isEditable(owner, name, comment.commentedUserName)){
|
if(isEditable(owner, name, comment.commentedUserName)){
|
||||||
updateCommitComment(comment.commentId, form.content)
|
updateCommitComment(comment.commentId, form.content)
|
||||||
redirect(s"/${owner}/${name}/commit_comments/_data/${comment.commentId}")
|
redirect(s"/${owner}/${name}/commit_comments/_data/${comment.commentId}")
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -413,8 +417,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
getCommitComment(owner, name, params("id")).map { comment =>
|
getCommitComment(owner, name, params("id")).map { comment =>
|
||||||
if(isEditable(owner, name, comment.commentedUserName)){
|
if(isEditable(owner, name, comment.commentedUserName)){
|
||||||
Ok(deleteCommitComment(comment.commentId))
|
Ok(deleteCommitComment(comment.commentId))
|
||||||
} else Unauthorized
|
} else Unauthorized()
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -433,13 +437,13 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
.map(br => (br, getPullRequestByRequestCommit(repository.owner, repository.name, repository.repository.defaultBranch, br.name, br.commitId), protectedBranches.contains(br.name)))
|
.map(br => (br, getPullRequestByRequestCommit(repository.owner, repository.name, repository.repository.defaultBranch, br.name, br.commitId), protectedBranches.contains(br.name)))
|
||||||
.reverse
|
.reverse
|
||||||
|
|
||||||
html.branches(branches, hasWritePermission(repository.owner, repository.name, context.loginAccount), repository)
|
html.branches(branches, hasDeveloperRole(repository.owner, repository.name, context.loginAccount), repository)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a branch.
|
* Creates a branch.
|
||||||
*/
|
*/
|
||||||
post("/:owner/:repository/branches")(collaboratorsOnly { repository =>
|
post("/:owner/:repository/branches")(writableUsersOnly { repository =>
|
||||||
val newBranchName = params.getOrElse("new", halt(400))
|
val newBranchName = params.getOrElse("new", halt(400))
|
||||||
val fromBranchName = params.getOrElse("from", halt(400))
|
val fromBranchName = params.getOrElse("from", halt(400))
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
@@ -457,7 +461,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
/**
|
/**
|
||||||
* Deletes branch.
|
* Deletes branch.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/delete/*")(collaboratorsOnly { repository =>
|
get("/:owner/:repository/delete/*")(writableUsersOnly { repository =>
|
||||||
val branchName = multiParams("splat").head
|
val branchName = multiParams("splat").head
|
||||||
val userName = context.loginAccount.get.userName
|
val userName = context.loginAccount.get.userName
|
||||||
if(repository.repository.defaultBranch != branchName){
|
if(repository.repository.defaultBranch != branchName){
|
||||||
@@ -485,23 +489,25 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
archiveRepository(name, ".zip", repository)
|
archiveRepository(name, ".zip", repository)
|
||||||
case name if name.endsWith(".tar.gz") =>
|
case name if name.endsWith(".tar.gz") =>
|
||||||
archiveRepository(name, ".tar.gz", repository)
|
archiveRepository(name, ".tar.gz", repository)
|
||||||
case _ => BadRequest
|
case _ => BadRequest()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/network/members")(referrersOnly { repository =>
|
get("/:owner/:repository/network/members")(referrersOnly { repository =>
|
||||||
html.forked(
|
if(repository.repository.options.allowFork) {
|
||||||
getRepository(
|
html.forked(
|
||||||
repository.repository.originUserName.getOrElse(repository.owner),
|
getRepository(
|
||||||
repository.repository.originRepositoryName.getOrElse(repository.name)),
|
repository.repository.originUserName.getOrElse(repository.owner),
|
||||||
getForkedRepositories(
|
repository.repository.originRepositoryName.getOrElse(repository.name)),
|
||||||
repository.repository.originUserName.getOrElse(repository.owner),
|
getForkedRepositories(
|
||||||
repository.repository.originRepositoryName.getOrElse(repository.name)),
|
repository.repository.originUserName.getOrElse(repository.owner),
|
||||||
context.loginAccount match {
|
repository.repository.originRepositoryName.getOrElse(repository.name)),
|
||||||
case None => List()
|
context.loginAccount match {
|
||||||
case account: Option[Account] => getGroupsByUserName(account.get.userName)
|
case None => List()
|
||||||
}, // groups of current user
|
case account: Option[Account] => getGroupsByUserName(account.get.userName)
|
||||||
repository)
|
}, // groups of current user
|
||||||
|
repository)
|
||||||
|
} else BadRequest()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -512,7 +518,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val ref = multiParams("splat").head
|
val ref = multiParams("splat").head
|
||||||
JGitUtil.getTreeId(git, ref).map{ treeId =>
|
JGitUtil.getTreeId(git, ref).map{ treeId =>
|
||||||
html.find(ref, treeId, repository)
|
html.find(ref, treeId, repository)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -527,17 +533,6 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
private def splitPath(repository: RepositoryService.RepositoryInfo, path: String): (String, String) = {
|
|
||||||
val id = repository.branchList.collectFirst {
|
|
||||||
case branch if(path == branch || path.startsWith(branch + "/")) => branch
|
|
||||||
} orElse repository.tags.collectFirst {
|
|
||||||
case tag if(path == tag.name || path.startsWith(tag.name + "/")) => tag.name
|
|
||||||
} getOrElse path.split("/")(0)
|
|
||||||
|
|
||||||
(id, path.substring(id.length).stripPrefix("/"))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private val readmeFiles = PluginRegistry().renderableExtensions.map { extension =>
|
private val readmeFiles = PluginRegistry().renderableExtensions.map { extension =>
|
||||||
s"readme.${extension}"
|
s"readme.${extension}"
|
||||||
} ++ Seq("readme.txt", "readme")
|
} ++ Seq("readme.txt", "readme")
|
||||||
@@ -551,10 +546,10 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
* @return HTML of the file list
|
* @return HTML of the file list
|
||||||
*/
|
*/
|
||||||
private def fileList(repository: RepositoryService.RepositoryInfo, revstr: String = "", path: String = ".") = {
|
private def fileList(repository: RepositoryService.RepositoryInfo, revstr: String = "", path: String = ".") = {
|
||||||
if(repository.commitCount == 0){
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
html.guide(repository, hasWritePermission(repository.owner, repository.name, context.loginAccount))
|
if(JGitUtil.isEmpty(git)){
|
||||||
} else {
|
html.guide(repository, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
} else {
|
||||||
// get specified commit
|
// get specified commit
|
||||||
JGitUtil.getDefaultBranch(git, repository, revstr).map { case (objectId, revision) =>
|
JGitUtil.getDefaultBranch(git, repository, revstr).map { case (objectId, revision) =>
|
||||||
defining(JGitUtil.getRevCommitFromId(git, objectId)) { revCommit =>
|
defining(JGitUtil.getRevCommitFromId(git, objectId)) { revCommit =>
|
||||||
@@ -574,11 +569,16 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
html.files(revision, repository,
|
html.files(revision, repository,
|
||||||
if(path == ".") Nil else path.split("/").toList, // current path
|
if(path == ".") Nil else path.split("/").toList, // current path
|
||||||
new JGitUtil.CommitInfo(lastModifiedCommit), // last modified commit
|
new JGitUtil.CommitInfo(lastModifiedCommit), // last modified commit
|
||||||
files, readme, hasWritePermission(repository.owner, repository.name, context.loginAccount),
|
JGitUtil.getCommitCount(repository.owner, repository.name, revision),
|
||||||
|
files,
|
||||||
|
readme,
|
||||||
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||||
getPullRequestFromBranch(repository.owner, repository.name, revstr, repository.repository.defaultBranch),
|
getPullRequestFromBranch(repository.owner, repository.name, revstr, repository.repository.defaultBranch),
|
||||||
flash.get("info"), flash.get("error"))
|
flash.get("info"),
|
||||||
|
flash.get("error")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -598,14 +598,18 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val headName = s"refs/heads/${branch}"
|
val headName = s"refs/heads/${branch}"
|
||||||
val headTip = git.getRepository.resolve(headName)
|
val headTip = git.getRepository.resolve(headName)
|
||||||
|
|
||||||
JGitUtil.processTree(git, headTip){ (path, tree) =>
|
val permission = JGitUtil.processTree(git, headTip){ (path, tree) =>
|
||||||
|
// Add all entries except the editing file
|
||||||
if(!newPath.exists(_ == path) && !oldPath.exists(_ == path)){
|
if(!newPath.exists(_ == path) && !oldPath.exists(_ == path)){
|
||||||
builder.add(JGitUtil.createDirCacheEntry(path, tree.getEntryFileMode, tree.getEntryObjectId))
|
builder.add(JGitUtil.createDirCacheEntry(path, tree.getEntryFileMode, tree.getEntryObjectId))
|
||||||
}
|
}
|
||||||
}
|
// Retrieve permission if file exists to keep it
|
||||||
|
oldPath.collect { case x if x == path => tree.getEntryFileMode.getBits }
|
||||||
|
}.flatten.headOption
|
||||||
|
|
||||||
newPath.foreach { newPath =>
|
newPath.foreach { newPath =>
|
||||||
builder.add(JGitUtil.createDirCacheEntry(newPath, FileMode.REGULAR_FILE,
|
builder.add(JGitUtil.createDirCacheEntry(newPath,
|
||||||
|
permission.map { bits => FileMode.fromBits(bits) } getOrElse FileMode.REGULAR_FILE,
|
||||||
inserter.insert(Constants.OBJ_BLOB, content.getBytes(charset))))
|
inserter.insert(Constants.OBJ_BLOB, content.getBytes(charset))))
|
||||||
}
|
}
|
||||||
builder.finish()
|
builder.finish()
|
||||||
@@ -628,8 +632,11 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
updatePullRequests(repository.owner, repository.name, branch)
|
updatePullRequests(repository.owner, repository.name, branch)
|
||||||
|
|
||||||
// record activity
|
// record activity
|
||||||
recordPushActivity(repository.owner, repository.name, loginAccount.userName, branch,
|
val commitInfo = new CommitInfo(JGitUtil.getRevCommitFromId(git, commitId))
|
||||||
List(new CommitInfo(JGitUtil.getRevCommitFromId(git, commitId))))
|
recordPushActivity(repository.owner, repository.name, loginAccount.userName, branch, List(commitInfo))
|
||||||
|
|
||||||
|
// create issue comment by commit message
|
||||||
|
createIssueComment(repository.owner, repository.name, commitInfo)
|
||||||
|
|
||||||
// close issue by commit message
|
// close issue by commit message
|
||||||
closeIssuesFromMessage(message, loginAccount.userName, repository.owner, repository.name)
|
closeIssuesFromMessage(message, loginAccount.userName, repository.owner, repository.name)
|
||||||
@@ -689,7 +696,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean =
|
private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean =
|
||||||
hasWritePermission(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
||||||
|
|
||||||
override protected def renderUncaughtException(e: Throwable)(implicit request: HttpServletRequest, response: HttpServletResponse): Unit = {
|
override protected def renderUncaughtException(e: Throwable)(implicit request: HttpServletRequest, response: HttpServletResponse): Unit = {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import gitbucket.core.util.Directory._
|
|||||||
import gitbucket.core.util.StringUtil._
|
import gitbucket.core.util.StringUtil._
|
||||||
import io.github.gitbucket.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.apache.commons.io.{FileUtils, IOUtils}
|
import org.apache.commons.io.{FileUtils, IOUtils}
|
||||||
import org.apache.commons.mail.{DefaultAuthenticator, HtmlEmail}
|
|
||||||
import org.scalatra.i18n.Messages
|
import org.scalatra.i18n.Messages
|
||||||
|
|
||||||
class SystemSettingsController extends SystemSettingsControllerBase
|
class SystemSettingsController extends SystemSettingsControllerBase
|
||||||
@@ -104,7 +103,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
|
|
||||||
val newUserForm = mapping(
|
val newUserForm = mapping(
|
||||||
"userName" -> trim(label("Username" ,text(required, maxlength(100), identifier, uniqueUserName))),
|
"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(20)))),
|
||||||
"fullName" -> trim(label("Full Name" ,text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name" ,text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address" ,text(required, maxlength(100), uniqueMailAddress()))),
|
"mailAddress" -> trim(label("Mail Address" ,text(required, maxlength(100), uniqueMailAddress()))),
|
||||||
@@ -126,7 +125,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
)(EditUserForm.apply)
|
)(EditUserForm.apply)
|
||||||
|
|
||||||
val newGroupForm = mapping(
|
val newGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members)))
|
"members" -> trim(label("Members" ,text(required, members)))
|
||||||
@@ -234,7 +233,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
updateImage(userName, form.fileId, form.clearImage)
|
updateImage(userName, form.fileId, form.clearImage)
|
||||||
redirect("/admin/users")
|
redirect("/admin/users")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/admin/users/_newgroup")(adminOnly {
|
get("/admin/users/_newgroup")(adminOnly {
|
||||||
@@ -280,19 +279,19 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
} else {
|
} else {
|
||||||
// Update GROUP_MEMBER
|
// Update GROUP_MEMBER
|
||||||
updateGroupMembers(form.groupName, members)
|
updateGroupMembers(form.groupName, members)
|
||||||
// Update COLLABORATOR for group repositories
|
// // Update COLLABORATOR for group repositories
|
||||||
getRepositoryNamesOfUser(form.groupName).foreach { repositoryName =>
|
// getRepositoryNamesOfUser(form.groupName).foreach { repositoryName =>
|
||||||
removeCollaborators(form.groupName, repositoryName)
|
// removeCollaborators(form.groupName, repositoryName)
|
||||||
members.foreach { case (userName, isManager) =>
|
// members.foreach { case (userName, isManager) =>
|
||||||
addCollaborator(form.groupName, repositoryName, userName)
|
// addCollaborator(form.groupName, repositoryName, userName)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
updateImage(form.groupName, form.fileId, form.clearImage)
|
updateImage(form.groupName, form.fileId, form.clearImage)
|
||||||
redirect("/admin/users")
|
redirect("/admin/users")
|
||||||
|
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -304,12 +303,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
post("/admin/export")(adminOnly {
|
post("/admin/export")(adminOnly {
|
||||||
import gitbucket.core.util.JDBCUtil._
|
import gitbucket.core.util.JDBCUtil._
|
||||||
val session = request2Session(request)
|
val file = request2Session(request).conn.exportAsSQL(request.getParameterValues("tableNames").toSeq)
|
||||||
val file = if(params("type") == "sql"){
|
|
||||||
session.conn.exportAsSQL(request.getParameterValues("tableNames").toSeq)
|
|
||||||
} else {
|
|
||||||
session.conn.exportAsXML(request.getParameterValues("tableNames").toSeq)
|
|
||||||
}
|
|
||||||
|
|
||||||
contentType = "application/octet-stream"
|
contentType = "application/octet-stream"
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName)
|
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName)
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import org.scalatra.i18n.Messages
|
|||||||
|
|
||||||
class WikiController extends WikiControllerBase
|
class WikiController extends WikiControllerBase
|
||||||
with WikiService with RepositoryService with AccountService with ActivityService
|
with WikiService with RepositoryService with AccountService with ActivityService
|
||||||
with CollaboratorsAuthenticator with ReferrerAuthenticator
|
with ReadableUsersAuthenticator with ReferrerAuthenticator
|
||||||
|
|
||||||
trait WikiControllerBase extends ControllerBase {
|
trait WikiControllerBase extends ControllerBase {
|
||||||
self: WikiService with RepositoryService with ActivityService with CollaboratorsAuthenticator with ReferrerAuthenticator =>
|
self: WikiService with RepositoryService with ActivityService with ReadableUsersAuthenticator with ReferrerAuthenticator =>
|
||||||
|
|
||||||
case class WikiPageEditForm(pageName: String, content: String, message: Option[String], currentPageName: String, id: String)
|
case class WikiPageEditForm(pageName: String, content: String, message: Option[String], currentPageName: String, id: String)
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
using(Git.open(getWikiRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getWikiRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
JGitUtil.getCommitLog(git, "master", path = pageName + ".md") match {
|
JGitUtil.getCommitLog(git, "master", path = pageName + ".md") match {
|
||||||
case Right((logs, hasNext)) => html.history(Some(pageName), logs, repository)
|
case Right((logs, hasNext)) => html.history(Some(pageName), logs, repository, isEditable(repository))
|
||||||
case Left(_) => NotFound()
|
case Left(_) => NotFound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_revert/:commitId")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_revert/:commitId")(readableUsersOnly { repository =>
|
||||||
if(isEditable(repository)){
|
if(isEditable(repository)){
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||||
@@ -101,7 +101,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/_revert/:commitId")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/_revert/:commitId")(readableUsersOnly { repository =>
|
||||||
if(isEditable(repository)){
|
if(isEditable(repository)){
|
||||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||||
|
|
||||||
@@ -114,14 +114,14 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_edit")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_edit")(readableUsersOnly { repository =>
|
||||||
if(isEditable(repository)){
|
if(isEditable(repository)){
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
html.edit(pageName, getWikiPage(repository.owner, repository.name, pageName), repository)
|
html.edit(pageName, getWikiPage(repository.owner, repository.name, pageName), repository)
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/wiki/_edit", editForm)(referrersOnly { (form, repository) =>
|
post("/:owner/:repository/wiki/_edit", editForm)(readableUsersOnly { (form, repository) =>
|
||||||
if(isEditable(repository)){
|
if(isEditable(repository)){
|
||||||
defining(context.loginAccount.get){ loginAccount =>
|
defining(context.loginAccount.get){ loginAccount =>
|
||||||
saveWikiPage(
|
saveWikiPage(
|
||||||
@@ -146,13 +146,13 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/_new")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/_new")(readableUsersOnly { repository =>
|
||||||
if(isEditable(repository)){
|
if(isEditable(repository)){
|
||||||
html.edit("", None, repository)
|
html.edit("", None, repository)
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/wiki/_new", newForm)(referrersOnly { (form, repository) =>
|
post("/:owner/:repository/wiki/_new", newForm)(readableUsersOnly { (form, repository) =>
|
||||||
if(isEditable(repository)){
|
if(isEditable(repository)){
|
||||||
defining(context.loginAccount.get){ loginAccount =>
|
defining(context.loginAccount.get){ loginAccount =>
|
||||||
saveWikiPage(repository.owner, repository.name, form.currentPageName, form.pageName,
|
saveWikiPage(repository.owner, repository.name, form.currentPageName, form.pageName,
|
||||||
@@ -170,7 +170,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/:page/_delete")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/:page/_delete")(readableUsersOnly { repository =>
|
||||||
if(isEditable(repository)){
|
if(isEditable(repository)){
|
||||||
val pageName = StringUtil.urlDecode(params("page"))
|
val pageName = StringUtil.urlDecode(params("page"))
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/wiki/_pages")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/_pages")(referrersOnly { repository =>
|
||||||
html.pages(getWikiPageList(repository.owner, repository.name), repository, isEditable(repository))
|
html.pages(getWikiPageList(repository.owner, repository.name), repository, isEditable(repository))
|
||||||
})
|
})
|
||||||
@@ -190,7 +190,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
get("/:owner/:repository/wiki/_history")(referrersOnly { repository =>
|
get("/:owner/:repository/wiki/_history")(referrersOnly { repository =>
|
||||||
using(Git.open(getWikiRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getWikiRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
JGitUtil.getCommitLog(git, "master") match {
|
JGitUtil.getCommitLog(git, "master") match {
|
||||||
case Right((logs, hasNext)) => html.history(None, logs, repository)
|
case Right((logs, hasNext)) => html.history(None, logs, repository, isEditable(repository))
|
||||||
case Left(_) => NotFound()
|
case Left(_) => NotFound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
getFileContent(repository.owner, repository.name, path).map { bytes =>
|
getFileContent(repository.owner, repository.name, path).map { bytes =>
|
||||||
RawData(FileUtil.getContentType(path, bytes), bytes)
|
RawData(FileUtil.getContentType(path, bytes), bytes)
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
private def unique: Constraint = new Constraint(){
|
private def unique: Constraint = new Constraint(){
|
||||||
@@ -240,9 +240,13 @@ trait WikiControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
private def targetWikiPage = getWikiPage(params("owner"), params("repository"), params("pageName"))
|
private def targetWikiPage = getWikiPage(params("owner"), params("repository"), params("pageName"))
|
||||||
|
|
||||||
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean =
|
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||||
repository.repository.allowWikiEditing || (
|
repository.repository.options.wikiOption match {
|
||||||
hasWritePermission(repository.owner, repository.name, context.loginAccount)
|
case "ALL" => !repository.repository.isPrivate && context.loginAccount.isDefined
|
||||||
)
|
case "PUBLIC" => hasGuestRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
case "PRIVATE" => hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
case "DISABLE" => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ trait CollaboratorComponent extends TemplateComponent { self: Profile =>
|
|||||||
|
|
||||||
class Collaborators(tag: Tag) extends Table[Collaborator](tag, "COLLABORATOR") with BasicTemplate {
|
class Collaborators(tag: Tag) extends Table[Collaborator](tag, "COLLABORATOR") with BasicTemplate {
|
||||||
val collaboratorName = column[String]("COLLABORATOR_NAME")
|
val collaboratorName = column[String]("COLLABORATOR_NAME")
|
||||||
def * = (userName, repositoryName, collaboratorName) <> (Collaborator.tupled, Collaborator.unapply)
|
val role = column[String]("ROLE")
|
||||||
|
def * = (userName, repositoryName, collaboratorName, role) <> (Collaborator.tupled, Collaborator.unapply)
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
||||||
byRepository(owner, repository) && (collaboratorName === collaborator.bind)
|
byRepository(owner, repository) && (collaboratorName === collaborator.bind)
|
||||||
@@ -17,5 +18,23 @@ trait CollaboratorComponent extends TemplateComponent { self: Profile =>
|
|||||||
case class Collaborator(
|
case class Collaborator(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
collaboratorName: String
|
collaboratorName: String,
|
||||||
|
role: String
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sealed abstract class Role(val name: String)
|
||||||
|
|
||||||
|
object Role {
|
||||||
|
object ADMIN extends Role("ADMIN")
|
||||||
|
object DEVELOPER extends Role("DEVELOPER")
|
||||||
|
object GUEST extends Role("GUEST")
|
||||||
|
|
||||||
|
// val values: Vector[Permission] = Vector(ADMIN, WRITE, READ)
|
||||||
|
//
|
||||||
|
// private val map: Map[String, Permission] = values.map(enum => enum.name -> enum).toMap
|
||||||
|
//
|
||||||
|
// def apply(name: String): Permission = map(name)
|
||||||
|
//
|
||||||
|
// def valueOf(name: String): Option[Permission] = map.get(name)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,24 +7,61 @@ trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
|||||||
lazy val Repositories = TableQuery[Repositories]
|
lazy val Repositories = TableQuery[Repositories]
|
||||||
|
|
||||||
class Repositories(tag: Tag) extends Table[Repository](tag, "REPOSITORY") with BasicTemplate {
|
class Repositories(tag: Tag) extends Table[Repository](tag, "REPOSITORY") with BasicTemplate {
|
||||||
val isPrivate = column[Boolean]("PRIVATE")
|
val isPrivate = column[Boolean]("PRIVATE")
|
||||||
val description = column[String]("DESCRIPTION")
|
val description = column[String]("DESCRIPTION")
|
||||||
val defaultBranch = column[String]("DEFAULT_BRANCH")
|
val defaultBranch = column[String]("DEFAULT_BRANCH")
|
||||||
val registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
val registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||||
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
val lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE")
|
val lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE")
|
||||||
val originUserName = column[String]("ORIGIN_USER_NAME")
|
val originUserName = column[String]("ORIGIN_USER_NAME")
|
||||||
val originRepositoryName = column[String]("ORIGIN_REPOSITORY_NAME")
|
val originRepositoryName = column[String]("ORIGIN_REPOSITORY_NAME")
|
||||||
val parentUserName = column[String]("PARENT_USER_NAME")
|
val parentUserName = column[String]("PARENT_USER_NAME")
|
||||||
val parentRepositoryName = column[String]("PARENT_REPOSITORY_NAME")
|
val parentRepositoryName = column[String]("PARENT_REPOSITORY_NAME")
|
||||||
val enableIssues = column[Boolean]("ENABLE_ISSUES")
|
val issuesOption = column[String]("ISSUES_OPTION")
|
||||||
val externalIssuesUrl = column[String]("EXTERNAL_ISSUES_URL")
|
val externalIssuesUrl = column[String]("EXTERNAL_ISSUES_URL")
|
||||||
val enableWiki = column[Boolean]("ENABLE_WIKI")
|
val wikiOption = column[String]("WIKI_OPTION")
|
||||||
val allowWikiEditing = column[Boolean]("ALLOW_WIKI_EDITING")
|
val externalWikiUrl = column[String]("EXTERNAL_WIKI_URL")
|
||||||
val externalWikiUrl = column[String]("EXTERNAL_WIKI_URL")
|
val allowFork = column[Boolean]("ALLOW_FORK")
|
||||||
def * = (userName, repositoryName, isPrivate, description.?, defaultBranch,
|
|
||||||
registeredDate, updatedDate, lastActivityDate, originUserName.?, originRepositoryName.?, parentUserName.?, parentRepositoryName.?,
|
def * = (
|
||||||
enableIssues, externalIssuesUrl.?, enableWiki, allowWikiEditing, externalWikiUrl.?) <> (Repository.tupled, Repository.unapply)
|
(userName, repositoryName, isPrivate, description.?, defaultBranch,
|
||||||
|
registeredDate, updatedDate, lastActivityDate, originUserName.?, originRepositoryName.?, parentUserName.?, parentRepositoryName.?),
|
||||||
|
(issuesOption, externalIssuesUrl.?, wikiOption, externalWikiUrl.?, allowFork)
|
||||||
|
).shaped <> (
|
||||||
|
{ case (repository, options) =>
|
||||||
|
Repository(
|
||||||
|
repository._1,
|
||||||
|
repository._2,
|
||||||
|
repository._3,
|
||||||
|
repository._4,
|
||||||
|
repository._5,
|
||||||
|
repository._6,
|
||||||
|
repository._7,
|
||||||
|
repository._8,
|
||||||
|
repository._9,
|
||||||
|
repository._10,
|
||||||
|
repository._11,
|
||||||
|
repository._12,
|
||||||
|
RepositoryOptions.tupled.apply(options)
|
||||||
|
)
|
||||||
|
}, { (r: Repository) =>
|
||||||
|
Some(((
|
||||||
|
r.userName,
|
||||||
|
r.repositoryName,
|
||||||
|
r.isPrivate,
|
||||||
|
r.description,
|
||||||
|
r.defaultBranch,
|
||||||
|
r.registeredDate,
|
||||||
|
r.updatedDate,
|
||||||
|
r.lastActivityDate,
|
||||||
|
r.originUserName,
|
||||||
|
r.originRepositoryName,
|
||||||
|
r.parentUserName,
|
||||||
|
r.parentRepositoryName
|
||||||
|
),(
|
||||||
|
RepositoryOptions.unapply(r.options).get
|
||||||
|
)))
|
||||||
|
})
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository)
|
def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository)
|
||||||
}
|
}
|
||||||
@@ -43,9 +80,13 @@ case class Repository(
|
|||||||
originRepositoryName: Option[String],
|
originRepositoryName: Option[String],
|
||||||
parentUserName: Option[String],
|
parentUserName: Option[String],
|
||||||
parentRepositoryName: Option[String],
|
parentRepositoryName: Option[String],
|
||||||
enableIssues: Boolean,
|
options: RepositoryOptions
|
||||||
externalIssuesUrl: Option[String],
|
)
|
||||||
enableWiki: Boolean,
|
|
||||||
allowWikiEditing: Boolean,
|
case class RepositoryOptions(
|
||||||
externalWikiUrl: Option[String]
|
issuesOption: String,
|
||||||
|
externalIssuesUrl: Option[String],
|
||||||
|
wikiOption: String,
|
||||||
|
externalWikiUrl: Option[String],
|
||||||
|
allowFork: Boolean
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -149,6 +149,36 @@ abstract class Plugin {
|
|||||||
*/
|
*/
|
||||||
def dashboardTabs(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(Context) => Option[Link]] = Nil
|
def dashboardTabs(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(Context) => Option[Link]] = Nil
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override to add assets mappings.
|
||||||
|
*/
|
||||||
|
val assetsMappings: Seq[(String, String)] = Nil
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override to add assets mappings.
|
||||||
|
*/
|
||||||
|
def assetsMappings(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(String, String)] = Nil
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override to add text decorators.
|
||||||
|
*/
|
||||||
|
val textDecorators: Seq[TextDecorator] = Nil
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override to add text decorators.
|
||||||
|
*/
|
||||||
|
def textDecorators(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[TextDecorator] = Nil
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override to add suggestion provider.
|
||||||
|
*/
|
||||||
|
val suggestionProviders: Seq[SuggestionProvider] = Nil
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override to add suggestion provider.
|
||||||
|
*/
|
||||||
|
def suggestionProviders(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[SuggestionProvider] = Nil
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is invoked in initialization of plugin system.
|
* This method is invoked in initialization of plugin system.
|
||||||
* Register plugin functionality to PluginRegistry.
|
* Register plugin functionality to PluginRegistry.
|
||||||
@@ -193,6 +223,15 @@ abstract class Plugin {
|
|||||||
(dashboardTabs ++ dashboardTabs(registry, context, settings)).foreach { dashboardTab =>
|
(dashboardTabs ++ dashboardTabs(registry, context, settings)).foreach { dashboardTab =>
|
||||||
registry.addDashboardTab(dashboardTab)
|
registry.addDashboardTab(dashboardTab)
|
||||||
}
|
}
|
||||||
|
(assetsMappings ++ assetsMappings(registry, context, settings)).foreach { assetMapping =>
|
||||||
|
registry.addAssetsMapping((assetMapping._1, assetMapping._2, getClass.getClassLoader))
|
||||||
|
}
|
||||||
|
(textDecorators ++ textDecorators(registry, context, settings)).foreach { textDecorator =>
|
||||||
|
registry.addTextDecorator(textDecorator)
|
||||||
|
}
|
||||||
|
(suggestionProviders ++ suggestionProviders(registry, context, settings)).foreach { suggestionProvider =>
|
||||||
|
registry.addSuggestionProvider(suggestionProvider)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import gitbucket.core.util.ControlUtil._
|
|||||||
import gitbucket.core.util.DatabaseConfig
|
import gitbucket.core.util.DatabaseConfig
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import io.github.gitbucket.solidbase.Solidbase
|
import io.github.gitbucket.solidbase.Solidbase
|
||||||
|
import io.github.gitbucket.solidbase.manager.JDBCVersionManager
|
||||||
import io.github.gitbucket.solidbase.model.Module
|
import io.github.gitbucket.solidbase.model.Module
|
||||||
import liquibase.database.core.H2Database
|
|
||||||
import org.apache.commons.codec.binary.{Base64, StringUtils}
|
import org.apache.commons.codec.binary.{Base64, StringUtils}
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
@@ -42,10 +42,13 @@ class PluginRegistry {
|
|||||||
private val systemSettingMenus = new ListBuffer[(Context) => Option[Link]]
|
private val systemSettingMenus = new ListBuffer[(Context) => Option[Link]]
|
||||||
private val accountSettingMenus = new ListBuffer[(Context) => Option[Link]]
|
private val accountSettingMenus = new ListBuffer[(Context) => Option[Link]]
|
||||||
private val dashboardTabs = new ListBuffer[(Context) => Option[Link]]
|
private val dashboardTabs = new ListBuffer[(Context) => Option[Link]]
|
||||||
|
private val assetsMappings = new ListBuffer[(String, String, ClassLoader)]
|
||||||
|
private val textDecorators = new ListBuffer[TextDecorator]
|
||||||
|
|
||||||
def addPlugin(pluginInfo: PluginInfo): Unit = {
|
private val suggestionProviders = new ListBuffer[SuggestionProvider]
|
||||||
plugins += pluginInfo
|
suggestionProviders += new UserNameSuggestionProvider()
|
||||||
}
|
|
||||||
|
def addPlugin(pluginInfo: PluginInfo): Unit = plugins += pluginInfo
|
||||||
|
|
||||||
def getPlugins(): List[PluginInfo] = plugins.toList
|
def getPlugins(): List[PluginInfo] = plugins.toList
|
||||||
|
|
||||||
@@ -66,42 +69,26 @@ class PluginRegistry {
|
|||||||
|
|
||||||
def getImage(id: String): String = images(id)
|
def getImage(id: String): String = images(id)
|
||||||
|
|
||||||
def addController(path: String, controller: ControllerBase): Unit = {
|
def addController(path: String, controller: ControllerBase): Unit = controllers += ((controller, path))
|
||||||
controllers += ((controller, path))
|
|
||||||
}
|
|
||||||
|
|
||||||
@deprecated("Use addController(path: String, controller: ControllerBase) instead", "3.4.0")
|
@deprecated("Use addController(path: String, controller: ControllerBase) instead", "3.4.0")
|
||||||
def addController(controller: ControllerBase, path: String): Unit = {
|
def addController(controller: ControllerBase, path: String): Unit = addController(path, controller)
|
||||||
addController(path, controller)
|
|
||||||
}
|
|
||||||
|
|
||||||
def getControllers(): Seq[(ControllerBase, String)] = controllers.toSeq
|
def getControllers(): Seq[(ControllerBase, String)] = controllers.toSeq
|
||||||
|
|
||||||
def addJavaScript(path: String, script: String): Unit = {
|
def addJavaScript(path: String, script: String): Unit = javaScripts += ((path, script))
|
||||||
javaScripts += ((path, script))
|
|
||||||
}
|
|
||||||
|
|
||||||
def getJavaScript(currentPath: String): List[String] = {
|
def getJavaScript(currentPath: String): List[String] = javaScripts.filter(x => currentPath.matches(x._1)).toList.map(_._2)
|
||||||
javaScripts.filter(x => currentPath.matches(x._1)).toList.map(_._2)
|
|
||||||
}
|
|
||||||
|
|
||||||
def addRenderer(extension: String, renderer: Renderer): Unit = {
|
def addRenderer(extension: String, renderer: Renderer): Unit = renderers += ((extension, renderer))
|
||||||
renderers += ((extension, renderer))
|
|
||||||
}
|
|
||||||
|
|
||||||
def getRenderer(extension: String): Renderer = {
|
def getRenderer(extension: String): Renderer = renderers.get(extension).getOrElse(DefaultRenderer)
|
||||||
renderers.get(extension).getOrElse(DefaultRenderer)
|
|
||||||
}
|
|
||||||
|
|
||||||
def renderableExtensions: Seq[String] = renderers.keys.toSeq
|
def renderableExtensions: Seq[String] = renderers.keys.toSeq
|
||||||
|
|
||||||
def addRepositoryRouting(routing: GitRepositoryRouting): Unit = {
|
def addRepositoryRouting(routing: GitRepositoryRouting): Unit = repositoryRoutings += routing
|
||||||
repositoryRoutings += routing
|
|
||||||
}
|
|
||||||
|
|
||||||
def getRepositoryRoutings(): Seq[GitRepositoryRouting] = {
|
def getRepositoryRoutings(): Seq[GitRepositoryRouting] = repositoryRoutings.toSeq
|
||||||
repositoryRoutings.toSeq
|
|
||||||
}
|
|
||||||
|
|
||||||
def getRepositoryRouting(repositoryPath: String): Option[GitRepositoryRouting] = {
|
def getRepositoryRouting(repositoryPath: String): Option[GitRepositoryRouting] = {
|
||||||
PluginRegistry().getRepositoryRoutings().find {
|
PluginRegistry().getRepositoryRoutings().find {
|
||||||
@@ -111,54 +98,49 @@ class PluginRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def addReceiveHook(commitHook: ReceiveHook): Unit = {
|
def addReceiveHook(commitHook: ReceiveHook): Unit = receiveHooks += commitHook
|
||||||
receiveHooks += commitHook
|
|
||||||
}
|
|
||||||
|
|
||||||
def getReceiveHooks: Seq[ReceiveHook] = receiveHooks.toSeq
|
def getReceiveHooks: Seq[ReceiveHook] = receiveHooks.toSeq
|
||||||
|
|
||||||
def addGlobalMenu(globalMenu: (Context) => Option[Link]): Unit = {
|
def addGlobalMenu(globalMenu: (Context) => Option[Link]): Unit = globalMenus += globalMenu
|
||||||
globalMenus += globalMenu
|
|
||||||
}
|
|
||||||
|
|
||||||
def getGlobalMenus: Seq[(Context) => Option[Link]] = globalMenus.toSeq
|
def getGlobalMenus: Seq[(Context) => Option[Link]] = globalMenus.toSeq
|
||||||
|
|
||||||
def addRepositoryMenu(repositoryMenu: (RepositoryInfo, Context) => Option[Link]): Unit = {
|
def addRepositoryMenu(repositoryMenu: (RepositoryInfo, Context) => Option[Link]): Unit = repositoryMenus += repositoryMenu
|
||||||
repositoryMenus += repositoryMenu
|
|
||||||
}
|
|
||||||
|
|
||||||
def getRepositoryMenus: Seq[(RepositoryInfo, Context) => Option[Link]] = repositoryMenus.toSeq
|
def getRepositoryMenus: Seq[(RepositoryInfo, Context) => Option[Link]] = repositoryMenus.toSeq
|
||||||
|
|
||||||
def addRepositorySettingTab(repositorySettingTab: (RepositoryInfo, Context) => Option[Link]): Unit = {
|
def addRepositorySettingTab(repositorySettingTab: (RepositoryInfo, Context) => Option[Link]): Unit = repositorySettingTabs += repositorySettingTab
|
||||||
repositorySettingTabs += repositorySettingTab
|
|
||||||
}
|
|
||||||
|
|
||||||
def getRepositorySettingTabs: Seq[(RepositoryInfo, Context) => Option[Link]] = repositorySettingTabs.toSeq
|
def getRepositorySettingTabs: Seq[(RepositoryInfo, Context) => Option[Link]] = repositorySettingTabs.toSeq
|
||||||
|
|
||||||
def addProfileTab(profileTab: (Account, Context) => Option[Link]): Unit = {
|
def addProfileTab(profileTab: (Account, Context) => Option[Link]): Unit = profileTabs += profileTab
|
||||||
profileTabs += profileTab
|
|
||||||
}
|
|
||||||
|
|
||||||
def getProfileTabs: Seq[(Account, Context) => Option[Link]] = profileTabs.toSeq
|
def getProfileTabs: Seq[(Account, Context) => Option[Link]] = profileTabs.toSeq
|
||||||
|
|
||||||
def addSystemSettingMenu(systemSettingMenu: (Context) => Option[Link]): Unit = {
|
def addSystemSettingMenu(systemSettingMenu: (Context) => Option[Link]): Unit = systemSettingMenus += systemSettingMenu
|
||||||
systemSettingMenus += systemSettingMenu
|
|
||||||
}
|
|
||||||
|
|
||||||
def getSystemSettingMenus: Seq[(Context) => Option[Link]] = systemSettingMenus.toSeq
|
def getSystemSettingMenus: Seq[(Context) => Option[Link]] = systemSettingMenus.toSeq
|
||||||
|
|
||||||
def addAccountSettingMenu(accountSettingMenu: (Context) => Option[Link]): Unit = {
|
def addAccountSettingMenu(accountSettingMenu: (Context) => Option[Link]): Unit = accountSettingMenus += accountSettingMenu
|
||||||
accountSettingMenus += accountSettingMenu
|
|
||||||
}
|
|
||||||
|
|
||||||
def getAccountSettingMenus: Seq[(Context) => Option[Link]] = accountSettingMenus.toSeq
|
def getAccountSettingMenus: Seq[(Context) => Option[Link]] = accountSettingMenus.toSeq
|
||||||
|
|
||||||
def addDashboardTab(dashboardTab: (Context) => Option[Link]): Unit = {
|
def addDashboardTab(dashboardTab: (Context) => Option[Link]): Unit = dashboardTabs += dashboardTab
|
||||||
dashboardTabs += dashboardTab
|
|
||||||
}
|
|
||||||
|
|
||||||
def getDashboardTabs: Seq[(Context) => Option[Link]] = dashboardTabs.toSeq
|
def getDashboardTabs: Seq[(Context) => Option[Link]] = dashboardTabs.toSeq
|
||||||
|
|
||||||
|
def addAssetsMapping(assetsMapping: (String, String, ClassLoader)): Unit = assetsMappings += assetsMapping
|
||||||
|
|
||||||
|
def getAssetsMappings: Seq[(String, String, ClassLoader)] = assetsMappings.toSeq
|
||||||
|
|
||||||
|
def addTextDecorator(textDecorator: TextDecorator): Unit = textDecorators += textDecorator
|
||||||
|
|
||||||
|
def getTextDecorators: Seq[TextDecorator] = textDecorators.toSeq
|
||||||
|
|
||||||
|
def addSuggestionProvider(suggestionProvider: SuggestionProvider): Unit = suggestionProviders += suggestionProvider
|
||||||
|
|
||||||
|
def getSuggestionProviders: Seq[SuggestionProvider] = suggestionProviders.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -180,6 +162,8 @@ object PluginRegistry {
|
|||||||
*/
|
*/
|
||||||
def initialize(context: ServletContext, settings: SystemSettings, conn: java.sql.Connection): Unit = {
|
def initialize(context: ServletContext, settings: SystemSettings, conn: java.sql.Connection): Unit = {
|
||||||
val pluginDir = new File(PluginHome)
|
val pluginDir = new File(PluginHome)
|
||||||
|
val manager = new JDBCVersionManager(conn)
|
||||||
|
|
||||||
if(pluginDir.exists && pluginDir.isDirectory){
|
if(pluginDir.exists && pluginDir.isDirectory){
|
||||||
pluginDir.listFiles(new FilenameFilter {
|
pluginDir.listFiles(new FilenameFilter {
|
||||||
override def accept(dir: File, name: String): Boolean = name.endsWith(".jar")
|
override def accept(dir: File, name: String): Boolean = name.endsWith(".jar")
|
||||||
@@ -192,19 +176,26 @@ object PluginRegistry {
|
|||||||
val solidbase = new Solidbase()
|
val solidbase = new Solidbase()
|
||||||
solidbase.migrate(conn, classLoader, DatabaseConfig.liquiDriver, new Module(plugin.pluginId, plugin.versions: _*))
|
solidbase.migrate(conn, classLoader, DatabaseConfig.liquiDriver, new Module(plugin.pluginId, plugin.versions: _*))
|
||||||
|
|
||||||
|
// Check version
|
||||||
|
val databaseVersion = manager.getCurrentVersion(plugin.pluginId)
|
||||||
|
val pluginVersion = plugin.versions.last.getVersion
|
||||||
|
if(databaseVersion != pluginVersion){
|
||||||
|
throw new IllegalStateException(s"Plugin version is ${pluginVersion}, but database version is ${databaseVersion}")
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
plugin.initialize(instance, context, settings)
|
plugin.initialize(instance, context, settings)
|
||||||
instance.addPlugin(PluginInfo(
|
instance.addPlugin(PluginInfo(
|
||||||
pluginId = plugin.pluginId,
|
pluginId = plugin.pluginId,
|
||||||
pluginName = plugin.pluginName,
|
pluginName = plugin.pluginName,
|
||||||
version = plugin.versions.head.getVersion,
|
pluginVersion = plugin.versions.last.getVersion,
|
||||||
description = plugin.description,
|
description = plugin.description,
|
||||||
pluginClass = plugin
|
pluginClass = plugin
|
||||||
))
|
))
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
case e: Throwable => {
|
case e: Throwable => {
|
||||||
logger.error(s"Error during plugin initialization", e)
|
logger.error(s"Error during plugin initialization: ${pluginJar.getAbsolutePath}", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,7 +222,7 @@ case class Link(id: String, label: String, path: String, icon: Option[String] =
|
|||||||
case class PluginInfo(
|
case class PluginInfo(
|
||||||
pluginId: String,
|
pluginId: String,
|
||||||
pluginName: String,
|
pluginName: String,
|
||||||
version: String,
|
pluginVersion: String,
|
||||||
description: String,
|
description: String,
|
||||||
pluginClass: Plugin
|
pluginClass: Plugin
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package gitbucket.core.plugin
|
||||||
|
|
||||||
|
import gitbucket.core.controller.Context
|
||||||
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
|
|
||||||
|
trait SuggestionProvider {
|
||||||
|
|
||||||
|
val id: String
|
||||||
|
val prefix: String
|
||||||
|
val suffix: String = " "
|
||||||
|
val context: Seq[String]
|
||||||
|
|
||||||
|
def values(repository: RepositoryInfo): Seq[String]
|
||||||
|
def template(implicit context: Context): String = "value"
|
||||||
|
def additionalScript(implicit context: Context): String = ""
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class UserNameSuggestionProvider extends SuggestionProvider {
|
||||||
|
override val id: String = "user"
|
||||||
|
override val prefix: String = "@"
|
||||||
|
override val context: Seq[String] = Seq("issues")
|
||||||
|
override def values(repository: RepositoryInfo): Seq[String] = Nil
|
||||||
|
override def template(implicit context: Context): String = "'@' + value"
|
||||||
|
override def additionalScript(implicit context: Context): String =
|
||||||
|
s"""$$.get('${context.path}/_user/proposals', { query: '', user: true, group: false }, function (data) { user = data.options; });"""
|
||||||
|
}
|
||||||
10
src/main/scala/gitbucket/core/plugin/TextDecorator.scala
Normal file
10
src/main/scala/gitbucket/core/plugin/TextDecorator.scala
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package gitbucket.core.plugin
|
||||||
|
|
||||||
|
import gitbucket.core.controller.Context
|
||||||
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
|
|
||||||
|
trait TextDecorator {
|
||||||
|
|
||||||
|
def decorate(text: String, repository: RepositoryInfo)(implicit context: Context): String
|
||||||
|
|
||||||
|
}
|
||||||
@@ -181,12 +181,11 @@ trait AccountService {
|
|||||||
def removeUserRelatedData(userName: String)(implicit s: Session): Unit = {
|
def removeUserRelatedData(userName: String)(implicit s: Session): Unit = {
|
||||||
GroupMembers.filter(_.userName === userName.bind).delete
|
GroupMembers.filter(_.userName === userName.bind).delete
|
||||||
Collaborators.filter(_.collaboratorName === userName.bind).delete
|
Collaborators.filter(_.collaboratorName === userName.bind).delete
|
||||||
Repositories.filter(_.userName === userName.bind).delete
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def getGroupNames(userName: String)(implicit s: Session): List[String] = {
|
def getGroupNames(userName: String)(implicit s: Session): List[String] = {
|
||||||
List(userName) ++
|
List(userName) ++
|
||||||
Collaborators.filter(_.collaboratorName === userName.bind).sortBy(_.userName).map(_.userName).list
|
Collaborators.filter(_.collaboratorName === userName.bind).sortBy(_.userName).map(_.userName).list.distinct
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,18 @@ trait CommitsService {
|
|||||||
updatedDate = currentDate,
|
updatedDate = currentDate,
|
||||||
issueId = issueId)
|
issueId = issueId)
|
||||||
|
|
||||||
|
def updateCommitCommentPosition(commentId: Int, commitId: String, oldLine: Option[Int], newLine: Option[Int])(implicit s: Session): Unit =
|
||||||
|
CommitComments.filter(_.byPrimaryKey(commentId))
|
||||||
|
.map { t =>
|
||||||
|
(t.commitId, t.oldLine, t.newLine)
|
||||||
|
}.update(commitId, oldLine, newLine)
|
||||||
|
|
||||||
def updateCommitComment(commentId: Int, content: String)(implicit s: Session) =
|
def updateCommitComment(commentId: Int, content: String)(implicit s: Session) =
|
||||||
CommitComments
|
CommitComments
|
||||||
.filter (_.byPrimaryKey(commentId))
|
.filter (_.byPrimaryKey(commentId))
|
||||||
.map { t =>
|
.map { t =>
|
||||||
t.content -> t.updatedDate
|
t.content -> t.updatedDate
|
||||||
}.update (content, currentDate)
|
}.update (content, currentDate)
|
||||||
|
|
||||||
def deleteCommitComment(commentId: Int)(implicit s: Session) =
|
def deleteCommitComment(commentId: Int)(implicit s: Session) =
|
||||||
CommitComments filter (_.byPrimaryKey(commentId)) delete
|
CommitComments filter (_.byPrimaryKey(commentId)) delete
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ trait HandleCommentService {
|
|||||||
with WebHookService with WebHookIssueCommentService with WebHookPullRequestService =>
|
with WebHookService with WebHookIssueCommentService with WebHookPullRequestService =>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see [[https://github.com/takezoe/gitbucket/wiki/CommentAction]]
|
* @see [[https://github.com/gitbucket/gitbucket/wiki/CommentAction]]
|
||||||
*/
|
*/
|
||||||
def handleComment(issue: Issue, content: Option[String], repository: RepositoryService.RepositoryInfo, actionOpt: Option[String])
|
def handleComment(issue: Issue, content: Option[String], repository: RepositoryService.RepositoryInfo, actionOpt: Option[String])
|
||||||
(implicit context: Context, s: Session) = {
|
(implicit context: Context, s: Session) = {
|
||||||
@@ -54,18 +54,20 @@ trait HandleCommentService {
|
|||||||
|
|
||||||
// call web hooks
|
// call web hooks
|
||||||
action match {
|
action match {
|
||||||
case None => commentId.map{ commentIdSome => callIssueCommentWebHook(repository, issue, commentIdSome, context.loginAccount.get) }
|
case None => commentId.map { commentIdSome => callIssueCommentWebHook(repository, issue, commentIdSome, context.loginAccount.get) }
|
||||||
case Some(act) => val webHookAction = act match {
|
case Some(act) => {
|
||||||
case "open" => "opened"
|
val webHookAction = act match {
|
||||||
case "reopen" => "reopened"
|
case "open" => "opened"
|
||||||
case "close" => "closed"
|
case "reopen" => "reopened"
|
||||||
case _ => act
|
case "close" => "closed"
|
||||||
}
|
case _ => act
|
||||||
if(issue.isPullRequest){
|
}
|
||||||
|
if (issue.isPullRequest) {
|
||||||
callPullRequestWebHook(webHookAction, repository, issue.issueId, context.baseUrl, context.loginAccount.get)
|
callPullRequestWebHook(webHookAction, repository, issue.issueId, context.baseUrl, context.loginAccount.get)
|
||||||
} else {
|
} else {
|
||||||
callIssuesWebHook(webHookAction, repository, issue, context.baseUrl, context.loginAccount.get)
|
callIssuesWebHook(webHookAction, repository, issue, context.baseUrl, context.loginAccount.get)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// notifications
|
// notifications
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ import scala.slick.jdbc.{StaticQuery => Q}
|
|||||||
import Q.interpolation
|
import Q.interpolation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
trait IssuesService {
|
trait IssuesService {
|
||||||
self: AccountService =>
|
self: AccountService with RepositoryService =>
|
||||||
import IssuesService._
|
import IssuesService._
|
||||||
|
|
||||||
def getIssue(owner: String, repository: String, issueId: String)(implicit s: Session) =
|
def getIssue(owner: String, repository: String, issueId: String)(implicit s: Session) =
|
||||||
@@ -34,6 +35,10 @@ trait IssuesService {
|
|||||||
.map{ case ((t1, t2), t3) => (t1, t2, t3) }
|
.map{ case ((t1, t2), t3) => (t1, t2, t3) }
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
def getMergedComment(owner: String, repository: String, issueId: Int)(implicit s: Session): Option[(IssueComment, Account)] = {
|
||||||
|
getCommentsForApi(owner, repository, issueId).collectFirst { case (comment, account, _) if comment.action == "merged" => (comment, account) }
|
||||||
|
}
|
||||||
|
|
||||||
def getComment(owner: String, repository: String, commentId: String)(implicit s: Session) =
|
def getComment(owner: String, repository: String, commentId: String)(implicit s: Session) =
|
||||||
if (commentId forall (_.isDigit))
|
if (commentId forall (_.isDigit))
|
||||||
IssueComments filter { t =>
|
IssueComments filter { t =>
|
||||||
@@ -163,66 +168,62 @@ trait IssuesService {
|
|||||||
(implicit s: Session): List[IssueInfo] = {
|
(implicit s: Session): List[IssueInfo] = {
|
||||||
// get issues and comment count and labels
|
// get issues and comment count and labels
|
||||||
val result = searchIssueQueryBase(condition, pullRequest, offset, limit, repos)
|
val result = searchIssueQueryBase(condition, pullRequest, offset, limit, repos)
|
||||||
.leftJoin (IssueLabels) .on { case ((t1, t2), t3) => t1.byIssue(t3.userName, t3.repositoryName, t3.issueId) }
|
.leftJoin (IssueLabels) .on { case (((t1, t2), i), t3) => t1.byIssue(t3.userName, t3.repositoryName, t3.issueId) }
|
||||||
.leftJoin (Labels) .on { case (((t1, t2), t3), t4) => t3.byLabel(t4.userName, t4.repositoryName, t4.labelId) }
|
.leftJoin (Labels) .on { case ((((t1, t2), i), t3), t4) => t3.byLabel(t4.userName, t4.repositoryName, t4.labelId) }
|
||||||
.leftJoin (Milestones) .on { case ((((t1, t2), t3), t4), t5) => t1.byMilestone(t5.userName, t5.repositoryName, t5.milestoneId) }
|
.leftJoin (Milestones) .on { case (((((t1, t2), i), t3), t4), t5) => t1.byMilestone(t5.userName, t5.repositoryName, t5.milestoneId) }
|
||||||
.map { case ((((t1, t2), t3), t4), t5) =>
|
.sortBy { case (((((t1, t2), i), t3), t4), t5) => i asc }
|
||||||
(t1, t2.commentCount, t4.labelId.?, t4.labelName.?, t4.color.?, t5.title.?)
|
.map { case (((((t1, t2), i), t3), t4), t5) => (t1, t2.commentCount, t4.labelId.?, t4.labelName.?, t4.color.?, t5.title.?) }
|
||||||
}
|
.list
|
||||||
.list
|
.splitWith { (c1, c2) => c1._1.userName == c2._1.userName && c1._1.repositoryName == c2._1.repositoryName && c1._1.issueId == c2._1.issueId }
|
||||||
.splitWith { (c1, c2) =>
|
|
||||||
c1._1.userName == c2._1.userName &&
|
|
||||||
c1._1.repositoryName == c2._1.repositoryName &&
|
|
||||||
c1._1.issueId == c2._1.issueId
|
|
||||||
}
|
|
||||||
val status = getCommitStatues(result.map(_.head._1).map(is => (is.userName, is.repositoryName, is.issueId)))
|
val status = getCommitStatues(result.map(_.head._1).map(is => (is.userName, is.repositoryName, is.issueId)))
|
||||||
|
|
||||||
result.map { issues => issues.head match {
|
result.map { issues => issues.head match {
|
||||||
case (issue, commentCount, _, _, _, milestone) =>
|
case (issue, commentCount, _, _, _, milestone) =>
|
||||||
IssueInfo(issue,
|
IssueInfo(issue,
|
||||||
issues.flatMap { t => t._3.map (
|
issues.flatMap { t => t._3.map (
|
||||||
Label(issue.userName, issue.repositoryName, _, t._4.get, t._5.get)
|
Label(issue.userName, issue.repositoryName, _, t._4.get, t._5.get)
|
||||||
)} toList,
|
)} toList,
|
||||||
milestone,
|
milestone,
|
||||||
commentCount,
|
commentCount,
|
||||||
status.get(issue.userName, issue.repositoryName, issue.issueId))
|
status.get(issue.userName, issue.repositoryName, issue.issueId))
|
||||||
}} toList
|
}} toList
|
||||||
}
|
}
|
||||||
|
|
||||||
/** for api
|
/** for api
|
||||||
* @return (issue, issueUser, commentCount, pullRequest, headRepo, headOwner)
|
* @return (issue, issueUser, commentCount, pullRequest, headRepo, headOwner)
|
||||||
*/
|
*/
|
||||||
def searchPullRequestByApi(condition: IssueSearchCondition, offset: Int, limit: Int, repos: (String, String)*)
|
def searchPullRequestByApi(condition: IssueSearchCondition, offset: Int, limit: Int, repos: (String, String)*)
|
||||||
(implicit s: Session): List[(Issue, Account, Int, PullRequest, Repository, Account)] = {
|
(implicit s: Session): List[(Issue, Account, Int, PullRequest, Repository, Account)] = {
|
||||||
// get issues and comment count and labels
|
// get issues and comment count and labels
|
||||||
searchIssueQueryBase(condition, true, offset, limit, repos)
|
searchIssueQueryBase(condition, true, offset, limit, repos)
|
||||||
.innerJoin(PullRequests).on { case ((t1, t2), t3) => t3.byPrimaryKey(t1.userName, t1.repositoryName, t1.issueId) }
|
.innerJoin(PullRequests).on { case (((t1, t2), i), t3) => t3.byPrimaryKey(t1.userName, t1.repositoryName, t1.issueId) }
|
||||||
.innerJoin(Repositories).on { case (((t1, t2), t3), t4) => t4.byRepository(t1.userName, t1.repositoryName) }
|
.innerJoin(Repositories).on { case ((((t1, t2), i), t3), t4) => t4.byRepository(t1.userName, t1.repositoryName) }
|
||||||
.innerJoin(Accounts).on { case ((((t1, t2), t3), t4), t5) => t5.userName === t1.openedUserName }
|
.innerJoin(Accounts).on { case (((((t1, t2), i), t3), t4), t5) => t5.userName === t1.openedUserName }
|
||||||
.innerJoin(Accounts).on { case (((((t1, t2), t3), t4), t5), t6) => t6.userName === t4.userName }
|
.innerJoin(Accounts).on { case ((((((t1, t2), i), t3), t4), t5), t6) => t6.userName === t4.userName }
|
||||||
.map { case (((((t1, t2), t3), t4), t5), t6) =>
|
.sortBy { case ((((((t1, t2), i), t3), t4), t5), t6) => i asc }
|
||||||
(t1, t5, t2.commentCount, t3, t4, t6)
|
.map { case ((((((t1, t2), i), t3), t4), t5), t6) => (t1, t5, t2.commentCount, t3, t4, t6) }
|
||||||
}
|
|
||||||
.list
|
.list
|
||||||
}
|
}
|
||||||
|
|
||||||
private def searchIssueQueryBase(condition: IssueSearchCondition, pullRequest: Boolean, offset: Int, limit: Int, repos: Seq[(String, String)])
|
private def searchIssueQueryBase(condition: IssueSearchCondition, pullRequest: Boolean, offset: Int, limit: Int, repos: Seq[(String, String)])
|
||||||
(implicit s: Session) =
|
(implicit s: Session) =
|
||||||
searchIssueQuery(repos, condition, pullRequest)
|
searchIssueQuery(repos, condition, pullRequest)
|
||||||
.innerJoin(IssueOutline).on { (t1, t2) => t1.byIssue(t2.userName, t2.repositoryName, t2.issueId) }
|
.innerJoin(IssueOutline).on { (t1, t2) => t1.byIssue(t2.userName, t2.repositoryName, t2.issueId) }
|
||||||
.sortBy { case (t1, t2) =>
|
.sortBy { case (t1, t2) => t1.issueId desc }
|
||||||
(condition.sort match {
|
.sortBy { case (t1, t2) =>
|
||||||
case "created" => t1.registeredDate
|
(condition.sort match {
|
||||||
case "comments" => t2.commentCount
|
case "created" => t1.registeredDate
|
||||||
case "updated" => t1.updatedDate
|
case "comments" => t2.commentCount
|
||||||
}) match {
|
case "updated" => t1.updatedDate
|
||||||
case sort => condition.direction match {
|
}) match {
|
||||||
case "asc" => sort asc
|
case sort => condition.direction match {
|
||||||
case "desc" => sort desc
|
case "asc" => sort asc
|
||||||
}
|
case "desc" => sort desc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.drop(offset).take(limit)
|
}
|
||||||
|
.drop(offset).take(limit).zipWithIndex
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -437,6 +438,11 @@ trait IssuesService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getAssignableUserNames(owner: String, repository: String)(implicit s: Session): List[String] = {
|
||||||
|
(getCollaboratorUserNames(owner, repository, Seq(Role.ADMIN, Role.DEVELOPER)) :::
|
||||||
|
(if (getAccountByUserName(owner).get.isGroupAccount) getGroupMembers(owner).map(_.userName) else List(owner))).distinct.sorted
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object IssuesService {
|
object IssuesService {
|
||||||
@@ -518,50 +524,6 @@ object IssuesService {
|
|||||||
if(value == null || value.isEmpty || (allow.nonEmpty && !allow.contains(value))) None else Some(value)
|
if(value == null || value.isEmpty || (allow.nonEmpty && !allow.contains(value))) None else Some(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Restores IssueSearchCondition instance from filter query.
|
|
||||||
*/
|
|
||||||
def apply(filter: String, milestones: Map[String, Int]): IssueSearchCondition = {
|
|
||||||
val conditions = filter.split("[ \t]+").flatMap { x =>
|
|
||||||
x.split(":") match {
|
|
||||||
case Array(key, value) => Some((key, value))
|
|
||||||
case _ => None
|
|
||||||
}
|
|
||||||
}.groupBy(_._1).map { case (key, values) =>
|
|
||||||
key -> values.map(_._2).toSeq
|
|
||||||
}
|
|
||||||
|
|
||||||
val (sort, direction) = conditions.get("sort").flatMap(_.headOption).getOrElse("created-desc") match {
|
|
||||||
case "created-asc" => ("created" , "asc" )
|
|
||||||
case "comments-desc" => ("comments", "desc")
|
|
||||||
case "comments-asc" => ("comments", "asc" )
|
|
||||||
case "updated-desc" => ("comments", "desc")
|
|
||||||
case "updated-asc" => ("comments", "asc" )
|
|
||||||
case _ => ("created" , "desc")
|
|
||||||
}
|
|
||||||
|
|
||||||
IssueSearchCondition(
|
|
||||||
conditions.get("label").map(_.toSet).getOrElse(Set.empty),
|
|
||||||
conditions.get("milestone").flatMap(_.headOption) match {
|
|
||||||
case None => None
|
|
||||||
case Some("none") => Some(None)
|
|
||||||
case Some(x) => Some(Some(x))
|
|
||||||
},
|
|
||||||
conditions.get("author").flatMap(_.headOption),
|
|
||||||
conditions.get("assignee").flatMap(_.headOption) match {
|
|
||||||
case None => None
|
|
||||||
case Some("none") => Some(None)
|
|
||||||
case Some(x) => Some(Some(x))
|
|
||||||
},
|
|
||||||
conditions.get("mentions").flatMap(_.headOption),
|
|
||||||
conditions.get("is").getOrElse(Seq.empty).find(x => x == "open" || x == "closed").getOrElse("open"),
|
|
||||||
sort,
|
|
||||||
direction,
|
|
||||||
conditions.get("visibility").flatMap(_.headOption),
|
|
||||||
conditions.get("group").map(_.toSet).getOrElse(Set.empty)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores IssueSearchCondition instance from request parameters.
|
* Restores IssueSearchCondition instance from request parameters.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ trait MilestonesService {
|
|||||||
|
|
||||||
def getMilestonesWithIssueCount(owner: String, repository: String)(implicit s: Session): List[(Milestone, Int, Int)] = {
|
def getMilestonesWithIssueCount(owner: String, repository: String)(implicit s: Session): List[(Milestone, Int, Int)] = {
|
||||||
val counts = Issues
|
val counts = Issues
|
||||||
.filter { t => (t.byRepository(owner, repository)) && (t.milestoneId.? isDefined) }
|
.filter { t => t.byRepository(owner, repository) && (t.milestoneId.? isDefined) }
|
||||||
.groupBy { t => t.milestoneId -> t.closed }
|
.groupBy { t => t.milestoneId -> t.closed }
|
||||||
.map { case (t1, t2) => t1._1 -> t1._2 -> t2.length }
|
.map { case (t1, t2) => t1._1 -> t1._2 -> t2.length }
|
||||||
.toMap
|
.toMap
|
||||||
@@ -52,6 +52,6 @@ trait MilestonesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def getMilestones(owner: String, repository: String)(implicit s: Session): List[Milestone] =
|
def getMilestones(owner: String, repository: String)(implicit s: Session): List[Milestone] =
|
||||||
Milestones.filter(_.byRepository(owner, repository)).sortBy(_.milestoneId asc).list
|
Milestones.filter(_.byRepository(owner, repository)).sortBy(t => (t.dueDate.asc, t.closedDate.desc, t.milestoneId.desc)).list
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ object ProtectedBranchService {
|
|||||||
def getStopReason(isAllowNonFastForwards: Boolean, command: ReceiveCommand, pusher: String)(implicit session: Session): Option[String] = {
|
def getStopReason(isAllowNonFastForwards: Boolean, command: ReceiveCommand, pusher: String)(implicit session: Session): Option[String] = {
|
||||||
if(enabled){
|
if(enabled){
|
||||||
command.getType() match {
|
command.getType() match {
|
||||||
case ReceiveCommand.Type.UPDATE|ReceiveCommand.Type.UPDATE_NONFASTFORWARD if isAllowNonFastForwards =>
|
case ReceiveCommand.Type.UPDATE_NONFASTFORWARD if isAllowNonFastForwards =>
|
||||||
Some("Cannot force-push to a protected branch")
|
Some("Cannot force-push to a protected branch")
|
||||||
case ReceiveCommand.Type.UPDATE|ReceiveCommand.Type.UPDATE_NONFASTFORWARD if needStatusCheck(pusher) =>
|
case ReceiveCommand.Type.UPDATE|ReceiveCommand.Type.UPDATE_NONFASTFORWARD if needStatusCheck(pusher) =>
|
||||||
unSuccessedContexts(command.getNewId.name) match {
|
unSuccessedContexts(command.getNewId.name) match {
|
||||||
@@ -98,7 +98,7 @@ object ProtectedBranchService {
|
|||||||
Some("Cannot delete a protected branch")
|
Some("Cannot delete a protected branch")
|
||||||
case _ => None
|
case _ => None
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,22 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.model.{Account, Issue, PullRequest, WebHook, CommitStatus, CommitState}
|
import difflib.{Delta, DiffUtils}
|
||||||
|
import gitbucket.core.model.{Session => _, _}
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
|
import gitbucket.core.util.ControlUtil._
|
||||||
|
import gitbucket.core.util.Directory._
|
||||||
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.JGitUtil
|
import gitbucket.core.util.JGitUtil
|
||||||
|
import gitbucket.core.util.JGitUtil.{CommitInfo, DiffInfo}
|
||||||
|
import gitbucket.core.view
|
||||||
|
import gitbucket.core.view.helpers
|
||||||
|
import org.eclipse.jgit.api.Git
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
|
|
||||||
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
trait PullRequestService { self: IssuesService =>
|
|
||||||
|
trait PullRequestService { self: IssuesService with CommitsService =>
|
||||||
import PullRequestService._
|
import PullRequestService._
|
||||||
|
|
||||||
def getPullRequest(owner: String, repository: String, issueId: Int)
|
def getPullRequest(owner: String, repository: String, issueId: Int)
|
||||||
@@ -111,9 +121,26 @@ trait PullRequestService { self: IssuesService =>
|
|||||||
def updatePullRequests(owner: String, repository: String, branch: String)(implicit s: Session): Unit =
|
def updatePullRequests(owner: String, repository: String, branch: String)(implicit s: Session): Unit =
|
||||||
getPullRequestsByRequest(owner, repository, branch, false).foreach { pullreq =>
|
getPullRequestsByRequest(owner, repository, branch, false).foreach { pullreq =>
|
||||||
if(Repositories.filter(_.byRepository(pullreq.userName, pullreq.repositoryName)).exists.run){
|
if(Repositories.filter(_.byRepository(pullreq.userName, pullreq.repositoryName)).exists.run){
|
||||||
|
// Update the git repository
|
||||||
val (commitIdTo, commitIdFrom) = JGitUtil.updatePullRequest(
|
val (commitIdTo, commitIdFrom) = JGitUtil.updatePullRequest(
|
||||||
pullreq.userName, pullreq.repositoryName, pullreq.branch, pullreq.issueId,
|
pullreq.userName, pullreq.repositoryName, pullreq.branch, pullreq.issueId,
|
||||||
pullreq.requestUserName, pullreq.requestRepositoryName, pullreq.requestBranch)
|
pullreq.requestUserName, pullreq.requestRepositoryName, pullreq.requestBranch)
|
||||||
|
|
||||||
|
// Collect comment positions
|
||||||
|
val positions = getCommitComments(pullreq.userName, pullreq.repositoryName, pullreq.commitIdTo, true)
|
||||||
|
.collect {
|
||||||
|
case CommitComment(_, _, _, commentId, _, _, Some(file), None, Some(newLine), _, _, _) => (file, commentId, Right(newLine))
|
||||||
|
case CommitComment(_, _, _, commentId, _, _, Some(file), Some(oldLine), None, _, _, _) => (file, commentId, Left(oldLine))
|
||||||
|
}
|
||||||
|
.groupBy { case (file, _, _) => file }
|
||||||
|
.map { case (file, comments) => file ->
|
||||||
|
comments.map { case (_, commentId, lineNumber) => (commentId, lineNumber) }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update comments position
|
||||||
|
updatePullRequestCommentPositions(positions, pullreq.requestUserName, pullreq.requestRepositoryName, pullreq.commitIdTo, commitIdTo)
|
||||||
|
|
||||||
|
// Update commit id in the PULL_REQUEST table
|
||||||
updateCommitId(pullreq.userName, pullreq.repositoryName, pullreq.issueId, commitIdTo, commitIdFrom)
|
updateCommitId(pullreq.userName, pullreq.repositoryName, pullreq.issueId, commitIdTo, commitIdFrom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,6 +164,78 @@ trait PullRequestService { self: IssuesService =>
|
|||||||
.firstOption
|
.firstOption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def updatePullRequestCommentPositions(positions: Map[String, Seq[(Int, Either[Int, Int])]], userName: String, repositoryName: String,
|
||||||
|
oldCommitId: String, newCommitId: String)(implicit s: Session): Unit = {
|
||||||
|
|
||||||
|
val (_, diffs) = getRequestCompareInfo(userName, repositoryName, oldCommitId, userName, repositoryName, newCommitId)
|
||||||
|
|
||||||
|
val patchs = positions.map { case (file, _) =>
|
||||||
|
diffs.find(x => x.oldPath == file).map { diff =>
|
||||||
|
(diff.oldContent, diff.newContent) match {
|
||||||
|
case (Some(oldContent), Some(newContent)) => {
|
||||||
|
val oldLines = oldContent.replace("\r\n", "\n").split("\n")
|
||||||
|
val newLines = newContent.replace("\r\n", "\n").split("\n")
|
||||||
|
file -> Option(DiffUtils.diff(oldLines.toList.asJava, newLines.toList.asJava))
|
||||||
|
}
|
||||||
|
case _ =>
|
||||||
|
file -> None
|
||||||
|
}
|
||||||
|
}.getOrElse {
|
||||||
|
file -> None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
positions.foreach { case (file, comments) =>
|
||||||
|
patchs(file) match {
|
||||||
|
case Some(patch) => file -> comments.foreach { case (commentId, lineNumber) => lineNumber match {
|
||||||
|
case Left(oldLine) => updateCommitCommentPosition(commentId, newCommitId, Some(oldLine), None)
|
||||||
|
case Right(newLine) =>
|
||||||
|
var counter = newLine
|
||||||
|
patch.getDeltas.asScala.filter(_.getOriginal.getPosition < newLine).foreach { delta =>
|
||||||
|
delta.getType match {
|
||||||
|
case Delta.TYPE.CHANGE =>
|
||||||
|
if(delta.getOriginal.getPosition <= newLine - 1 && newLine <= delta.getOriginal.getPosition + delta.getRevised.getLines.size){
|
||||||
|
counter = -1
|
||||||
|
} else {
|
||||||
|
counter = counter + (delta.getRevised.getLines.size - delta.getOriginal.getLines.size)
|
||||||
|
}
|
||||||
|
case Delta.TYPE.INSERT => counter = counter + delta.getRevised.getLines.size
|
||||||
|
case Delta.TYPE.DELETE => counter = counter - delta.getOriginal.getLines.size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(counter >= 0){
|
||||||
|
updateCommitCommentPosition(commentId, newCommitId, None, Some(counter))
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
case _ => comments.foreach { case (commentId, lineNumber) => lineNumber match {
|
||||||
|
case Right(oldLine) => updateCommitCommentPosition(commentId, newCommitId, Some(oldLine), None)
|
||||||
|
case Left(newLine) => updateCommitCommentPosition(commentId, newCommitId, None, Some(newLine))
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getRequestCompareInfo(userName: String, repositoryName: String, branch: String,
|
||||||
|
requestUserName: String, requestRepositoryName: String, requestCommitId: String): (Seq[Seq[CommitInfo]], Seq[DiffInfo]) =
|
||||||
|
using(
|
||||||
|
Git.open(getRepositoryDir(userName, repositoryName)),
|
||||||
|
Git.open(getRepositoryDir(requestUserName, requestRepositoryName))
|
||||||
|
){ (oldGit, newGit) =>
|
||||||
|
val oldId = oldGit.getRepository.resolve(branch)
|
||||||
|
val newId = newGit.getRepository.resolve(requestCommitId)
|
||||||
|
|
||||||
|
val commits = newGit.log.addRange(oldId, newId).call.iterator.asScala.map { revCommit =>
|
||||||
|
new CommitInfo(revCommit)
|
||||||
|
}.toList.splitWith { (commit1, commit2) =>
|
||||||
|
helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
val diffs = JGitUtil.getDiffs(newGit, oldId.getName, newId.getName, true)
|
||||||
|
|
||||||
|
(commits, diffs)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object PullRequestService {
|
object PullRequestService {
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ trait RepositoryCreationService {
|
|||||||
// Insert to the database at first
|
// Insert to the database at first
|
||||||
insertRepository(name, owner, description, isPrivate)
|
insertRepository(name, owner, description, isPrivate)
|
||||||
|
|
||||||
// Add collaborators for group repository
|
// // Add collaborators for group repository
|
||||||
if(ownerAccount.isGroupAccount){
|
// if(ownerAccount.isGroupAccount){
|
||||||
getGroupMembers(owner).foreach { member =>
|
// getGroupMembers(owner).foreach { member =>
|
||||||
addCollaborator(owner, name, member.userName)
|
// addCollaborator(owner, name, member.userName)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Insert default labels
|
// Insert default labels
|
||||||
insertDefaultLabels(owner, name)
|
insertDefaultLabels(owner, name)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.controller.Context
|
import gitbucket.core.controller.Context
|
||||||
import gitbucket.core.model.{Collaborator, Repository, Account}
|
import gitbucket.core.model.{Collaborator, Repository, RepositoryOptions, Account, Role}
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import gitbucket.core.util.JGitUtil
|
import gitbucket.core.util.JGitUtil
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
@@ -37,11 +37,13 @@ trait RepositoryService { self: AccountService =>
|
|||||||
originRepositoryName = originRepositoryName,
|
originRepositoryName = originRepositoryName,
|
||||||
parentUserName = parentUserName,
|
parentUserName = parentUserName,
|
||||||
parentRepositoryName = parentRepositoryName,
|
parentRepositoryName = parentRepositoryName,
|
||||||
enableIssues = true,
|
options = RepositoryOptions(
|
||||||
externalIssuesUrl = None,
|
issuesOption = "PUBLIC", // TODO DISABLE for the forked repository?
|
||||||
enableWiki = true,
|
externalIssuesUrl = None,
|
||||||
allowWikiEditing = true,
|
wikiOption = "PUBLIC", // TODO DISABLE for the forked repository?
|
||||||
externalWikiUrl = None
|
externalWikiUrl = None,
|
||||||
|
allowFork = true
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
IssueId insert (userName, repositoryName, 0)
|
IssueId insert (userName, repositoryName, 0)
|
||||||
@@ -121,11 +123,8 @@ trait RepositoryService { self: AccountService =>
|
|||||||
repositoryName = newRepositoryName
|
repositoryName = newRepositoryName
|
||||||
)) :_*)
|
)) :_*)
|
||||||
|
|
||||||
if(account.isGroupAccount){
|
// TODO Drop transfered owner from collaborators?
|
||||||
Collaborators.insertAll(getGroupMembers(newUserName).map(m => Collaborator(newUserName, newRepositoryName, m.userName)) :_*)
|
Collaborators.insertAll(collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
||||||
} else {
|
|
||||||
Collaborators.insertAll(collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update activity messages
|
// Update activity messages
|
||||||
Activities.filter { t =>
|
Activities.filter { t =>
|
||||||
@@ -224,7 +223,7 @@ trait RepositoryService { self: AccountService =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the repositories without private repository that user does not have access right.
|
* Returns the repositories except private repository that user does not have access right.
|
||||||
* Include public repository, private own repository and private but collaborator repository.
|
* Include public repository, private own repository and private but collaborator repository.
|
||||||
*
|
*
|
||||||
* @param userName the user name of collaborator
|
* @param userName the user name of collaborator
|
||||||
@@ -233,8 +232,10 @@ trait RepositoryService { self: AccountService =>
|
|||||||
def getAllRepositories(userName: String)(implicit s: Session): List[(String, String)] = {
|
def getAllRepositories(userName: String)(implicit s: Session): List[(String, String)] = {
|
||||||
Repositories.filter { t1 =>
|
Repositories.filter { t1 =>
|
||||||
(t1.isPrivate === false.bind) ||
|
(t1.isPrivate === false.bind) ||
|
||||||
(t1.userName === userName.bind) ||
|
(t1.userName === userName.bind) || (t1.userName in (GroupMembers.filter(_.userName === userName.bind).map(_.groupName))) ||
|
||||||
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && (t2.collaboratorName === userName.bind)} exists)
|
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) &&
|
||||||
|
((t2.collaboratorName === userName.bind) || (t2.collaboratorName in GroupMembers.filter(_.userName === userName.bind).map(_.groupName)))
|
||||||
|
} exists)
|
||||||
}.sortBy(_.lastActivityDate desc).map{ t =>
|
}.sortBy(_.lastActivityDate desc).map{ t =>
|
||||||
(t.userName, t.repositoryName)
|
(t.userName, t.repositoryName)
|
||||||
}.list
|
}.list
|
||||||
@@ -243,8 +244,10 @@ trait RepositoryService { self: AccountService =>
|
|||||||
def getUserRepositories(userName: String, withoutPhysicalInfo: Boolean = false)
|
def getUserRepositories(userName: String, withoutPhysicalInfo: Boolean = false)
|
||||||
(implicit s: Session): List[RepositoryInfo] = {
|
(implicit s: Session): List[RepositoryInfo] = {
|
||||||
Repositories.filter { t1 =>
|
Repositories.filter { t1 =>
|
||||||
(t1.userName === userName.bind) ||
|
(t1.userName === userName.bind) || (t1.userName in (GroupMembers.filter(_.userName === userName.bind).map(_.groupName))) ||
|
||||||
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && (t2.collaboratorName === userName.bind)} exists)
|
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) &&
|
||||||
|
((t2.collaboratorName === userName.bind) || (t2.collaboratorName in GroupMembers.filter(_.userName === userName.bind).map(_.groupName)))
|
||||||
|
} exists)
|
||||||
}.sortBy(_.lastActivityDate desc).list.map{ repository =>
|
}.sortBy(_.lastActivityDate desc).list.map{ repository =>
|
||||||
new RepositoryInfo(
|
new RepositoryInfo(
|
||||||
if(withoutPhysicalInfo){
|
if(withoutPhysicalInfo){
|
||||||
@@ -279,8 +282,13 @@ trait RepositoryService { self: AccountService =>
|
|||||||
case Some(x) if(x.isAdmin) => Repositories
|
case Some(x) if(x.isAdmin) => Repositories
|
||||||
// for Normal Users
|
// for Normal Users
|
||||||
case Some(x) if(!x.isAdmin) =>
|
case Some(x) if(!x.isAdmin) =>
|
||||||
Repositories filter { t => (t.isPrivate === false.bind) || (t.userName === x.userName) ||
|
Repositories filter { t =>
|
||||||
(Collaborators.filter { t2 => t2.byRepository(t.userName, t.repositoryName) && (t2.collaboratorName === x.userName.bind)} exists)
|
(t.isPrivate === false.bind) || (t.userName === x.userName) ||
|
||||||
|
(t.userName in GroupMembers.filter(_.userName === x.userName.bind).map(_.groupName)) ||
|
||||||
|
(Collaborators.filter { t2 =>
|
||||||
|
t2.byRepository(t.userName, t.repositoryName) &&
|
||||||
|
((t2.collaboratorName === x.userName.bind) || (t2.collaboratorName in GroupMembers.filter(_.userName === x.userName.bind).map(_.groupName)))
|
||||||
|
} exists)
|
||||||
}
|
}
|
||||||
// for Guests
|
// for Guests
|
||||||
case None => Repositories filter(_.isPrivate === false.bind)
|
case None => Repositories filter(_.isPrivate === false.bind)
|
||||||
@@ -320,11 +328,12 @@ trait RepositoryService { self: AccountService =>
|
|||||||
*/
|
*/
|
||||||
def saveRepositoryOptions(userName: String, repositoryName: String,
|
def saveRepositoryOptions(userName: String, repositoryName: String,
|
||||||
description: Option[String], isPrivate: Boolean,
|
description: Option[String], isPrivate: Boolean,
|
||||||
enableIssues: Boolean, externalIssuesUrl: Option[String],
|
issuesOption: String, externalIssuesUrl: Option[String],
|
||||||
enableWiki: Boolean, allowWikiEditing: Boolean, externalWikiUrl: Option[String])(implicit s: Session): Unit =
|
wikiOption: String, externalWikiUrl: Option[String],
|
||||||
|
allowFork: Boolean)(implicit s: Session): Unit =
|
||||||
Repositories.filter(_.byRepository(userName, repositoryName))
|
Repositories.filter(_.byRepository(userName, repositoryName))
|
||||||
.map { r => (r.description.?, r.isPrivate, r.enableIssues, r.externalIssuesUrl.?, r.enableWiki, r.allowWikiEditing, r.externalWikiUrl.?, r.updatedDate) }
|
.map { r => (r.description.?, r.isPrivate, r.issuesOption, r.externalIssuesUrl.?, r.wikiOption, r.externalWikiUrl.?, r.allowFork, r.updatedDate) }
|
||||||
.update (description, isPrivate, enableIssues, externalIssuesUrl, enableWiki, allowWikiEditing, externalWikiUrl, currentDate)
|
.update (description, isPrivate, issuesOption, externalIssuesUrl, wikiOption, externalWikiUrl, allowFork, currentDate)
|
||||||
|
|
||||||
def saveRepositoryDefaultBranch(userName: String, repositoryName: String,
|
def saveRepositoryDefaultBranch(userName: String, repositoryName: String,
|
||||||
defaultBranch: String)(implicit s: Session): Unit =
|
defaultBranch: String)(implicit s: Session): Unit =
|
||||||
@@ -333,49 +342,64 @@ trait RepositoryService { self: AccountService =>
|
|||||||
.update (defaultBranch)
|
.update (defaultBranch)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add collaborator to the repository.
|
* Add collaborator (user or group) to the repository.
|
||||||
*
|
|
||||||
* @param userName the user name of the repository owner
|
|
||||||
* @param repositoryName the repository name
|
|
||||||
* @param collaboratorName the collaborator name
|
|
||||||
*/
|
*/
|
||||||
def addCollaborator(userName: String, repositoryName: String, collaboratorName: String)(implicit s: Session): Unit =
|
def addCollaborator(userName: String, repositoryName: String, collaboratorName: String, role: String)(implicit s: Session): Unit =
|
||||||
Collaborators insert Collaborator(userName, repositoryName, collaboratorName)
|
Collaborators insert Collaborator(userName, repositoryName, collaboratorName, role)
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove collaborator from the repository.
|
|
||||||
*
|
|
||||||
* @param userName the user name of the repository owner
|
|
||||||
* @param repositoryName the repository name
|
|
||||||
* @param collaboratorName the collaborator name
|
|
||||||
*/
|
|
||||||
def removeCollaborator(userName: String, repositoryName: String, collaboratorName: String)(implicit s: Session): Unit =
|
|
||||||
Collaborators.filter(_.byPrimaryKey(userName, repositoryName, collaboratorName)).delete
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all collaborators from the repository.
|
* Remove all collaborators from the repository.
|
||||||
*
|
|
||||||
* @param userName the user name of the repository owner
|
|
||||||
* @param repositoryName the repository name
|
|
||||||
*/
|
*/
|
||||||
def removeCollaborators(userName: String, repositoryName: String)(implicit s: Session): Unit =
|
def removeCollaborators(userName: String, repositoryName: String)(implicit s: Session): Unit =
|
||||||
Collaborators.filter(_.byRepository(userName, repositoryName)).delete
|
Collaborators.filter(_.byRepository(userName, repositoryName)).delete
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of collaborators name which is sorted with ascending order.
|
* Returns the list of collaborators name (user name or group name) which is sorted with ascending order.
|
||||||
*
|
|
||||||
* @param userName the user name of the repository owner
|
|
||||||
* @param repositoryName the repository name
|
|
||||||
* @return the list of collaborators name
|
|
||||||
*/
|
*/
|
||||||
def getCollaborators(userName: String, repositoryName: String)(implicit s: Session): List[String] =
|
def getCollaborators(userName: String, repositoryName: String)(implicit s: Session): List[(Collaborator, Boolean)] =
|
||||||
Collaborators.filter(_.byRepository(userName, repositoryName)).sortBy(_.collaboratorName).map(_.collaboratorName).list
|
Collaborators
|
||||||
|
.innerJoin(Accounts).on(_.collaboratorName === _.userName)
|
||||||
|
.filter { case (t1, t2) => t1.byRepository(userName, repositoryName) }
|
||||||
|
.map { case (t1, t2) => (t1, t2.groupAccount) }
|
||||||
|
.sortBy { case (t1, t2) => t1.collaboratorName }
|
||||||
|
.list
|
||||||
|
|
||||||
def hasWritePermission(owner: String, repository: String, loginAccount: Option[Account])(implicit s: Session): Boolean = {
|
/**
|
||||||
|
* Returns the list of all collaborator name and permission which is sorted with ascending order.
|
||||||
|
* If a group is added as a collaborator, this method returns users who are belong to that group.
|
||||||
|
*/
|
||||||
|
def getCollaboratorUserNames(userName: String, repositoryName: String, filter: Seq[Role] = Nil)(implicit s: Session): List[String] = {
|
||||||
|
val q1 = Collaborators
|
||||||
|
.innerJoin(Accounts).on { case (t1, t2) => (t1.collaboratorName === t2.userName) && (t2.groupAccount === false.bind) }
|
||||||
|
.filter { case (t1, t2) => t1.byRepository(userName, repositoryName) }
|
||||||
|
.map { case (t1, t2) => (t1.collaboratorName, t1.role) }
|
||||||
|
|
||||||
|
val q2 = Collaborators
|
||||||
|
.innerJoin(Accounts).on { case (t1, t2) => (t1.collaboratorName === t2.userName) && (t2.groupAccount === true.bind) }
|
||||||
|
.innerJoin(GroupMembers).on { case ((t1, t2), t3) => t2.userName === t3.groupName }
|
||||||
|
.filter { case ((t1, t2), t3) => t1.byRepository(userName, repositoryName) }
|
||||||
|
.map { case ((t1, t2), t3) => (t3.userName, t1.role) }
|
||||||
|
|
||||||
|
q1.union(q2).list.filter { x => filter.isEmpty || filter.exists(_.name == x._2) }.map(_._1)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def hasDeveloperRole(owner: String, repository: String, loginAccount: Option[Account])(implicit s: Session): Boolean = {
|
||||||
loginAccount match {
|
loginAccount match {
|
||||||
case Some(a) if(a.isAdmin) => true
|
case Some(a) if(a.isAdmin) => true
|
||||||
case Some(a) if(a.userName == owner) => true
|
case Some(a) if(a.userName == owner) => true
|
||||||
case Some(a) if(getCollaborators(owner, repository).contains(a.userName)) => true
|
case Some(a) if(getGroupMembers(owner).exists(_.userName == a.userName)) => true
|
||||||
|
case Some(a) if(getCollaboratorUserNames(owner, repository, Seq(Role.ADMIN, Role.DEVELOPER)).contains(a.userName)) => true
|
||||||
|
case _ => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def hasGuestRole(owner: String, repository: String, loginAccount: Option[Account])(implicit s: Session): Boolean = {
|
||||||
|
loginAccount match {
|
||||||
|
case Some(a) if(a.isAdmin) => true
|
||||||
|
case Some(a) if(a.userName == owner) => true
|
||||||
|
case Some(a) if(getGroupMembers(owner).exists(_.userName == a.userName)) => true
|
||||||
|
case Some(a) if(getCollaboratorUserNames(owner, repository, Seq(Role.ADMIN, Role.DEVELOPER, Role.GUEST)).contains(a.userName)) => true
|
||||||
case _ => false
|
case _ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,29 +421,33 @@ trait RepositoryService { self: AccountService =>
|
|||||||
object RepositoryService {
|
object RepositoryService {
|
||||||
|
|
||||||
case class RepositoryInfo(owner: String, name: String, repository: Repository,
|
case class RepositoryInfo(owner: String, name: String, repository: Repository,
|
||||||
issueCount: Int, pullCount: Int, commitCount: Int, forkedCount: Int,
|
issueCount: Int, pullCount: Int, forkedCount: Int,
|
||||||
branchList: Seq[String], tags: Seq[JGitUtil.TagInfo], managers: Seq[String]) {
|
branchList: Seq[String], tags: Seq[JGitUtil.TagInfo], managers: Seq[String]) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates instance with issue count and pull request count.
|
* Creates instance with issue count and pull request count.
|
||||||
*/
|
*/
|
||||||
def this(repo: JGitUtil.RepositoryInfo, model: Repository, issueCount: Int, pullCount: Int, forkedCount: Int, managers: Seq[String]) =
|
def this(repo: JGitUtil.RepositoryInfo, model: Repository, issueCount: Int, pullCount: Int, forkedCount: Int, managers: Seq[String]) =
|
||||||
this(
|
this(repo.owner, repo.name, model, issueCount, pullCount, forkedCount, repo.branchList, repo.tags, managers)
|
||||||
repo.owner, repo.name, model,
|
|
||||||
issueCount, pullCount, repo.commitCount, forkedCount,
|
|
||||||
repo.branchList, repo.tags, managers)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates instance without issue count and pull request count.
|
* Creates instance without issue count and pull request count.
|
||||||
*/
|
*/
|
||||||
def this(repo: JGitUtil.RepositoryInfo, model: Repository, forkedCount: Int, managers: Seq[String]) =
|
def this(repo: JGitUtil.RepositoryInfo, model: Repository, forkedCount: Int, managers: Seq[String]) =
|
||||||
this(
|
this(repo.owner, repo.name, model, 0, 0, forkedCount, repo.branchList, repo.tags, managers)
|
||||||
repo.owner, repo.name, model,
|
|
||||||
0, 0, repo.commitCount, forkedCount,
|
|
||||||
repo.branchList, repo.tags, managers)
|
|
||||||
|
|
||||||
def httpUrl(implicit context: Context): String = RepositoryService.httpUrl(owner, name)
|
def httpUrl(implicit context: Context): String = RepositoryService.httpUrl(owner, name)
|
||||||
def sshUrl(implicit context: Context): Option[String] = RepositoryService.sshUrl(owner, name)
|
def sshUrl(implicit context: Context): Option[String] = RepositoryService.sshUrl(owner, name)
|
||||||
|
|
||||||
|
def splitPath(path: String): (String, String) = {
|
||||||
|
val id = branchList.collectFirst {
|
||||||
|
case branch if(path == branch || path.startsWith(branch + "/")) => branch
|
||||||
|
} orElse tags.collectFirst {
|
||||||
|
case tag if(path == tag.name || path.startsWith(tag.name + "/")) => tag.name
|
||||||
|
} getOrElse path.split("/")(0)
|
||||||
|
|
||||||
|
(id, path.substring(id.length).stripPrefix("/"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def httpUrl(owner: String, name: String)(implicit context: Context): String = s"${context.baseUrl}/git/${owner}/${name}.git"
|
def httpUrl(owner: String, name: String)(implicit context: Context): String = s"${context.baseUrl}/git/${owner}/${name}.git"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import Implicits.request2Session
|
|||||||
* It may be called many times in one request, so each method stores
|
* It may be called many times in one request, so each method stores
|
||||||
* its result into the cache which available during a request.
|
* its result into the cache which available during a request.
|
||||||
*/
|
*/
|
||||||
trait RequestCache extends SystemSettingsService with AccountService with IssuesService {
|
trait RequestCache extends SystemSettingsService with AccountService with IssuesService with RepositoryService {
|
||||||
|
|
||||||
private implicit def context2Session(implicit context: Context): Session =
|
private implicit def context2Session(implicit context: Context): Session =
|
||||||
request2Session(context.request)
|
request2Session(context.request)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ trait SystemSettingsService {
|
|||||||
getValue(props, AllowAccountRegistration, false),
|
getValue(props, AllowAccountRegistration, false),
|
||||||
getValue(props, AllowAnonymousAccess, true),
|
getValue(props, AllowAnonymousAccess, true),
|
||||||
getValue(props, IsCreateRepoOptionPublic, true),
|
getValue(props, IsCreateRepoOptionPublic, true),
|
||||||
getValue(props, Gravatar, true),
|
getValue(props, Gravatar, false),
|
||||||
getValue(props, Notification, false),
|
getValue(props, Notification, false),
|
||||||
getOptionValue[Int](props, ActivityLogLimit, None),
|
getOptionValue[Int](props, ActivityLogLimit, None),
|
||||||
getValue(props, Ssh, false),
|
getValue(props, Ssh, false),
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream
|
import java.util.Date
|
||||||
|
|
||||||
import fr.brouillard.oss.security.xhub.XHub
|
import fr.brouillard.oss.security.xhub.XHub
|
||||||
import fr.brouillard.oss.security.xhub.XHub.{XHubDigest, XHubConverter}
|
import fr.brouillard.oss.security.xhub.XHub.{XHubConverter, XHubDigest}
|
||||||
import gitbucket.core.api._
|
import gitbucket.core.api._
|
||||||
import gitbucket.core.model.{WebHook, Account, Issue, PullRequest, IssueComment, WebHookEvent, CommitComment}
|
import gitbucket.core.model.{Account, CommitComment, Issue, IssueComment, PullRequest, WebHook, WebHookEvent}
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import org.apache.http.client.utils.URLEncodedUtils
|
import org.apache.http.client.utils.URLEncodedUtils
|
||||||
import profile.simple._
|
import profile.simple._
|
||||||
@@ -17,11 +18,13 @@ import org.apache.http.message.BasicNameValuePair
|
|||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.lib.ObjectId
|
import org.eclipse.jgit.lib.ObjectId
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
import scala.concurrent._
|
import scala.concurrent._
|
||||||
import org.apache.http.HttpRequest
|
import org.apache.http.HttpRequest
|
||||||
import org.apache.http.HttpResponse
|
import org.apache.http.HttpResponse
|
||||||
import gitbucket.core.model.WebHookContentType
|
import gitbucket.core.model.WebHookContentType
|
||||||
import org.apache.http.client.entity.EntityBuilder
|
import org.apache.http.client.entity.EntityBuilder
|
||||||
|
import org.apache.http.entity.ContentType
|
||||||
|
|
||||||
|
|
||||||
trait WebHookService {
|
trait WebHookService {
|
||||||
@@ -33,15 +36,15 @@ trait WebHookService {
|
|||||||
def getWebHooks(owner: String, repository: String)(implicit s: Session): List[(WebHook, Set[WebHook.Event])] =
|
def getWebHooks(owner: String, repository: String)(implicit s: Session): List[(WebHook, Set[WebHook.Event])] =
|
||||||
WebHooks.filter(_.byRepository(owner, repository))
|
WebHooks.filter(_.byRepository(owner, repository))
|
||||||
.innerJoin(WebHookEvents).on { (w, t) => t.byWebHook(w) }
|
.innerJoin(WebHookEvents).on { (w, t) => t.byWebHook(w) }
|
||||||
.map{ case (w,t) => w -> t.event }
|
.map { case (w,t) => w -> t.event }
|
||||||
.list.groupBy(_._1).mapValues(_.map(_._2).toSet).toList.sortBy(_._1.url)
|
.list.groupBy(_._1).mapValues(_.map(_._2).toSet).toList.sortBy(_._1.url)
|
||||||
|
|
||||||
/** get All WebHook informations of repository event */
|
/** get All WebHook informations of repository event */
|
||||||
def getWebHooksByEvent(owner: String, repository: String, event: WebHook.Event)(implicit s: Session): List[WebHook] =
|
def getWebHooksByEvent(owner: String, repository: String, event: WebHook.Event)(implicit s: Session): List[WebHook] =
|
||||||
WebHooks.filter(_.byRepository(owner, repository))
|
WebHooks.filter(_.byRepository(owner, repository))
|
||||||
.innerJoin(WebHookEvents).on { (wh, whe) => whe.byWebHook(wh) }
|
.innerJoin(WebHookEvents).on { (wh, whe) => whe.byWebHook(wh) }
|
||||||
.filter{ case (wh, whe) => whe.event === event.bind}
|
.filter { case (wh, whe) => whe.event === event.bind}
|
||||||
.map{ case (wh, whe) => wh }
|
.map { case (wh, whe) => wh }
|
||||||
.list.distinct
|
.list.distinct
|
||||||
|
|
||||||
/** get All WebHook information from repository to url */
|
/** get All WebHook information from repository to url */
|
||||||
@@ -49,12 +52,12 @@ trait WebHookService {
|
|||||||
WebHooks
|
WebHooks
|
||||||
.filter(_.byPrimaryKey(owner, repository, url))
|
.filter(_.byPrimaryKey(owner, repository, url))
|
||||||
.innerJoin(WebHookEvents).on { (w, t) => t.byWebHook(w) }
|
.innerJoin(WebHookEvents).on { (w, t) => t.byWebHook(w) }
|
||||||
.map{ case (w,t) => w -> t.event }
|
.map { case (w,t) => w -> t.event }
|
||||||
.list.groupBy(_._1).mapValues(_.map(_._2).toSet).headOption
|
.list.groupBy(_._1).mapValues(_.map(_._2).toSet).headOption
|
||||||
|
|
||||||
def addWebHook(owner: String, repository: String, url :String, events: Set[WebHook.Event], ctype: WebHookContentType, token: Option[String])(implicit s: Session): Unit = {
|
def addWebHook(owner: String, repository: String, url :String, events: Set[WebHook.Event], ctype: WebHookContentType, token: Option[String])(implicit s: Session): Unit = {
|
||||||
WebHooks insert WebHook(owner, repository, url, ctype, token)
|
WebHooks insert WebHook(owner, repository, url, ctype, token)
|
||||||
events.toSet.map{ event: WebHook.Event =>
|
events.map { event: WebHook.Event =>
|
||||||
WebHookEvents insert WebHookEvent(owner, repository, url, event)
|
WebHookEvents insert WebHookEvent(owner, repository, url, event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,7 +65,7 @@ trait WebHookService {
|
|||||||
def updateWebHook(owner: String, repository: String, url :String, events: Set[WebHook.Event], ctype: WebHookContentType, token: Option[String])(implicit s: Session): Unit = {
|
def updateWebHook(owner: String, repository: String, url :String, events: Set[WebHook.Event], ctype: WebHookContentType, token: Option[String])(implicit s: Session): Unit = {
|
||||||
WebHooks.filter(_.byPrimaryKey(owner, repository, url)).map(w => (w.ctype, w.token)).update((ctype, token))
|
WebHooks.filter(_.byPrimaryKey(owner, repository, url)).map(w => (w.ctype, w.token)).update((ctype, token))
|
||||||
WebHookEvents.filter(_.byWebHook(owner, repository, url)).delete
|
WebHookEvents.filter(_.byWebHook(owner, repository, url)).delete
|
||||||
events.toSet.map{ event: WebHook.Event =>
|
events.map { event: WebHook.Event =>
|
||||||
WebHookEvents insert WebHookEvent(owner, repository, url, event)
|
WebHookEvents insert WebHookEvent(owner, repository, url, event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +84,7 @@ trait WebHookService {
|
|||||||
def callWebHook(event: WebHook.Event, webHooks: List[WebHook], payload: WebHookPayload)
|
def callWebHook(event: WebHook.Event, webHooks: List[WebHook], payload: WebHookPayload)
|
||||||
(implicit c: JsonFormat.Context): List[(WebHook, String, Future[HttpRequest], Future[HttpResponse])] = {
|
(implicit c: JsonFormat.Context): List[(WebHook, String, Future[HttpRequest], Future[HttpResponse])] = {
|
||||||
import org.apache.http.impl.client.HttpClientBuilder
|
import org.apache.http.impl.client.HttpClientBuilder
|
||||||
import ExecutionContext.Implicits.global
|
import ExecutionContext.Implicits.global // TODO Shouldn't use the default execution context
|
||||||
import org.apache.http.protocol.HttpContext
|
import org.apache.http.protocol.HttpContext
|
||||||
import org.apache.http.client.methods.HttpPost
|
import org.apache.http.client.methods.HttpPost
|
||||||
|
|
||||||
@@ -91,7 +94,7 @@ trait WebHookService {
|
|||||||
webHooks.map { webHook =>
|
webHooks.map { webHook =>
|
||||||
val reqPromise = Promise[HttpRequest]
|
val reqPromise = Promise[HttpRequest]
|
||||||
val f = Future {
|
val f = Future {
|
||||||
val itcp = new org.apache.http.HttpRequestInterceptor{
|
val itcp = new org.apache.http.HttpRequestInterceptor {
|
||||||
def process(res: HttpRequest, ctx: HttpContext): Unit = {
|
def process(res: HttpRequest, ctx: HttpContext): Unit = {
|
||||||
reqPromise.success(res)
|
reqPromise.success(res)
|
||||||
}
|
}
|
||||||
@@ -118,7 +121,7 @@ trait WebHookService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case WebHookContentType.JSON => {
|
case WebHookContentType.JSON => {
|
||||||
httpPost.setEntity(EntityBuilder.create().setText(json).build())
|
httpPost.setEntity(EntityBuilder.create().setContentType(ContentType.APPLICATION_JSON).setText(json).build())
|
||||||
if (webHook.token.exists(_.trim.nonEmpty)) {
|
if (webHook.token.exists(_.trim.nonEmpty)) {
|
||||||
httpPost.addHeader("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA1, webHook.token.orNull, json.getBytes("UTF-8")))
|
httpPost.addHeader("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA1, webHook.token.orNull, json.getBytes("UTF-8")))
|
||||||
}
|
}
|
||||||
@@ -129,8 +132,8 @@ trait WebHookService {
|
|||||||
httpPost.releaseConnection()
|
httpPost.releaseConnection()
|
||||||
logger.debug(s"end web hook invocation for ${webHook}")
|
logger.debug(s"end web hook invocation for ${webHook}")
|
||||||
res
|
res
|
||||||
}catch{
|
} catch {
|
||||||
case e:Throwable => {
|
case e: Throwable => {
|
||||||
if(!reqPromise.isCompleted){
|
if(!reqPromise.isCompleted){
|
||||||
reqPromise.failure(e)
|
reqPromise.failure(e)
|
||||||
}
|
}
|
||||||
@@ -168,11 +171,11 @@ trait WebHookPullRequestService extends WebHookService {
|
|||||||
issueUser <- users.get(issue.openedUserName)
|
issueUser <- users.get(issue.openedUserName)
|
||||||
} yield {
|
} yield {
|
||||||
WebHookIssuesPayload(
|
WebHookIssuesPayload(
|
||||||
action = action,
|
action = action,
|
||||||
number = issue.issueId,
|
number = issue.issueId,
|
||||||
repository = ApiRepository(repository, ApiUser(repoOwner)),
|
repository = ApiRepository(repository, ApiUser(repoOwner)),
|
||||||
issue = ApiIssue(issue, RepositoryName(repository), ApiUser(issueUser)),
|
issue = ApiIssue(issue, RepositoryName(repository), ApiUser(issueUser)),
|
||||||
sender = ApiUser(sender))
|
sender = ApiUser(sender))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,7 +201,9 @@ trait WebHookPullRequestService extends WebHookService {
|
|||||||
headOwner = headOwner,
|
headOwner = headOwner,
|
||||||
baseRepository = repository,
|
baseRepository = repository,
|
||||||
baseOwner = baseOwner,
|
baseOwner = baseOwner,
|
||||||
sender = sender)
|
sender = sender,
|
||||||
|
mergedComment = getMergedComment(repository.owner, repository.name, issueId)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,7 +242,10 @@ trait WebHookPullRequestService extends WebHookService {
|
|||||||
headOwner = headOwner,
|
headOwner = headOwner,
|
||||||
baseRepository = baseRepo,
|
baseRepository = baseRepo,
|
||||||
baseOwner = baseOwner,
|
baseOwner = baseOwner,
|
||||||
sender = sender)
|
sender = sender,
|
||||||
|
mergedComment = getMergedComment(baseRepo.owner, baseRepo.name, issue.issueId)
|
||||||
|
)
|
||||||
|
|
||||||
callWebHook(WebHook.PullRequest, webHooks, payload)
|
callWebHook(WebHook.PullRequest, webHooks, payload)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,7 +275,9 @@ trait WebHookPullRequestReviewCommentService extends WebHookService {
|
|||||||
headOwner = headOwner,
|
headOwner = headOwner,
|
||||||
baseRepository = repository,
|
baseRepository = repository,
|
||||||
baseOwner = baseOwner,
|
baseOwner = baseOwner,
|
||||||
sender = sender)
|
sender = sender,
|
||||||
|
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,11 +375,21 @@ object WebHookService {
|
|||||||
headOwner: Account,
|
headOwner: Account,
|
||||||
baseRepository: RepositoryInfo,
|
baseRepository: RepositoryInfo,
|
||||||
baseOwner: Account,
|
baseOwner: Account,
|
||||||
sender: Account): WebHookPullRequestPayload = {
|
sender: Account,
|
||||||
|
mergedComment: Option[(IssueComment, Account)]): WebHookPullRequestPayload = {
|
||||||
|
|
||||||
val headRepoPayload = ApiRepository(headRepository, headOwner)
|
val headRepoPayload = ApiRepository(headRepository, headOwner)
|
||||||
val baseRepoPayload = ApiRepository(baseRepository, baseOwner)
|
val baseRepoPayload = ApiRepository(baseRepository, baseOwner)
|
||||||
val senderPayload = ApiUser(sender)
|
val senderPayload = ApiUser(sender)
|
||||||
val pr = ApiPullRequest(issue, pullRequest, headRepoPayload, baseRepoPayload, ApiUser(issueUser))
|
val pr = ApiPullRequest(
|
||||||
|
issue = issue,
|
||||||
|
pullRequest = pullRequest,
|
||||||
|
headRepo = headRepoPayload,
|
||||||
|
baseRepo = baseRepoPayload,
|
||||||
|
user = ApiUser(issueUser),
|
||||||
|
mergedComment = mergedComment
|
||||||
|
)
|
||||||
|
|
||||||
WebHookPullRequestPayload(
|
WebHookPullRequestPayload(
|
||||||
action = action,
|
action = action,
|
||||||
number = issue.issueId,
|
number = issue.issueId,
|
||||||
@@ -389,7 +409,7 @@ object WebHookService {
|
|||||||
sender: ApiUser
|
sender: ApiUser
|
||||||
) extends WebHookPayload
|
) extends WebHookPayload
|
||||||
|
|
||||||
object WebHookIssueCommentPayload{
|
object WebHookIssueCommentPayload {
|
||||||
def apply(
|
def apply(
|
||||||
issue: Issue,
|
issue: Issue,
|
||||||
issueUser: Account,
|
issueUser: Account,
|
||||||
@@ -415,28 +435,42 @@ object WebHookService {
|
|||||||
sender: ApiUser
|
sender: ApiUser
|
||||||
) extends WebHookPayload
|
) extends WebHookPayload
|
||||||
|
|
||||||
object WebHookPullRequestReviewCommentPayload{
|
object WebHookPullRequestReviewCommentPayload {
|
||||||
def apply(
|
def apply(
|
||||||
action: String,
|
action: String,
|
||||||
comment: CommitComment,
|
comment: CommitComment,
|
||||||
issue: Issue,
|
issue: Issue,
|
||||||
issueUser: Account,
|
issueUser: Account,
|
||||||
pullRequest: PullRequest,
|
pullRequest: PullRequest,
|
||||||
headRepository: RepositoryInfo,
|
headRepository: RepositoryInfo,
|
||||||
headOwner: Account,
|
headOwner: Account,
|
||||||
baseRepository: RepositoryInfo,
|
baseRepository: RepositoryInfo,
|
||||||
baseOwner: Account,
|
baseOwner: Account,
|
||||||
sender: Account
|
sender: Account,
|
||||||
) : WebHookPullRequestReviewCommentPayload = {
|
mergedComment: Option[(IssueComment, Account)]
|
||||||
|
) : WebHookPullRequestReviewCommentPayload = {
|
||||||
val headRepoPayload = ApiRepository(headRepository, headOwner)
|
val headRepoPayload = ApiRepository(headRepository, headOwner)
|
||||||
val baseRepoPayload = ApiRepository(baseRepository, baseOwner)
|
val baseRepoPayload = ApiRepository(baseRepository, baseOwner)
|
||||||
val senderPayload = ApiUser(sender)
|
val senderPayload = ApiUser(sender)
|
||||||
|
|
||||||
WebHookPullRequestReviewCommentPayload(
|
WebHookPullRequestReviewCommentPayload(
|
||||||
action = action,
|
action = action,
|
||||||
comment = ApiPullRequestReviewComment(comment, senderPayload, RepositoryName(baseRepository), issue.issueId),
|
comment = ApiPullRequestReviewComment(
|
||||||
pull_request = ApiPullRequest(issue, pullRequest, headRepoPayload, baseRepoPayload, ApiUser(issueUser)),
|
comment = comment,
|
||||||
repository = baseRepoPayload,
|
commentedUser = senderPayload,
|
||||||
sender = senderPayload)
|
repositoryName = RepositoryName(baseRepository),
|
||||||
|
issueId = issue.issueId
|
||||||
|
),
|
||||||
|
pull_request = ApiPullRequest(
|
||||||
|
issue = issue,
|
||||||
|
pullRequest = pullRequest,
|
||||||
|
headRepo = headRepoPayload,
|
||||||
|
baseRepo = baseRepoPayload,
|
||||||
|
user = ApiUser(issueUser),
|
||||||
|
mergedComment = mergedComment
|
||||||
|
),
|
||||||
|
repository = baseRepoPayload,
|
||||||
|
sender = senderPayload)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,14 @@ import javax.servlet._
|
|||||||
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
||||||
|
|
||||||
import gitbucket.core.model.Account
|
import gitbucket.core.model.Account
|
||||||
import gitbucket.core.service.AccessTokenService
|
import gitbucket.core.service.SystemSettingsService.SystemSettings
|
||||||
import gitbucket.core.util.Keys
|
import gitbucket.core.service.{AccessTokenService, AccountService, SystemSettingsService}
|
||||||
|
import gitbucket.core.util.{AuthUtil, Keys}
|
||||||
import org.scalatra.servlet.ServletApiImplicits._
|
import org.scalatra.servlet.ServletApiImplicits._
|
||||||
import org.scalatra._
|
import org.scalatra._
|
||||||
|
|
||||||
|
|
||||||
class AccessTokenAuthenticationFilter extends Filter with AccessTokenService {
|
class ApiAuthenticationFilter extends Filter with AccessTokenService with AccountService with SystemSettingsService {
|
||||||
private val tokenHeaderPrefix = "token "
|
|
||||||
|
|
||||||
override def init(filterConfig: FilterConfig): Unit = {}
|
override def init(filterConfig: FilterConfig): Unit = {}
|
||||||
|
|
||||||
@@ -23,9 +22,9 @@ class AccessTokenAuthenticationFilter extends Filter with AccessTokenService {
|
|||||||
implicit val session = req.getAttribute(Keys.Request.DBSession).asInstanceOf[slick.jdbc.JdbcBackend#Session]
|
implicit val session = req.getAttribute(Keys.Request.DBSession).asInstanceOf[slick.jdbc.JdbcBackend#Session]
|
||||||
val response = res.asInstanceOf[HttpServletResponse]
|
val response = res.asInstanceOf[HttpServletResponse]
|
||||||
Option(request.getHeader("Authorization")).map{
|
Option(request.getHeader("Authorization")).map{
|
||||||
case auth if auth.startsWith("token ") => AccessTokenService.getAccountByAccessToken(auth.substring(6).trim).toRight(Unit)
|
case auth if auth.startsWith("token ") => AccessTokenService.getAccountByAccessToken(auth.substring(6).trim).toRight(())
|
||||||
// TODO Basic Authentication Support
|
case auth if auth.startsWith("Basic ") => doBasicAuth(auth, loadSystemSettings(), request).toRight(())
|
||||||
case _ => Left(Unit)
|
case _ => Left(())
|
||||||
}.orElse{
|
}.orElse{
|
||||||
Option(request.getSession.getAttribute(Keys.Session.LoginAccount).asInstanceOf[Account]).map(Right(_))
|
Option(request.getSession.getAttribute(Keys.Session.LoginAccount).asInstanceOf[Account]).map(Right(_))
|
||||||
} match {
|
} match {
|
||||||
@@ -40,4 +39,10 @@ class AccessTokenAuthenticationFilter extends Filter with AccessTokenService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def doBasicAuth(auth: String, settings: SystemSettings, request: HttpServletRequest): Option[Account] = {
|
||||||
|
implicit val session = request.getAttribute(Keys.Request.DBSession).asInstanceOf[slick.jdbc.JdbcBackend#Session]
|
||||||
|
val Array(username, password) = AuthUtil.decodeAuthHeader(auth).split(":", 2)
|
||||||
|
authenticate(settings, username, password)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package gitbucket.core.servlet
|
||||||
|
|
||||||
|
import javax.servlet._
|
||||||
|
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
||||||
|
|
||||||
|
import gitbucket.core.service.SystemSettingsService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A controller to provide GitHub compatible URL for Git clients.
|
||||||
|
*/
|
||||||
|
class GHCompatRepositoryAccessFilter extends Filter with SystemSettingsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pattern of GitHub compatible repository URL.
|
||||||
|
* <code>/:user/:repo.git/</code>
|
||||||
|
*/
|
||||||
|
private val githubRepositoryPattern = """^/[^/]+/[^/]+\.git/.*""".r
|
||||||
|
|
||||||
|
override def init(filterConfig: FilterConfig) = {}
|
||||||
|
|
||||||
|
override def doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain) = {
|
||||||
|
implicit val request = req.asInstanceOf[HttpServletRequest]
|
||||||
|
val response = res.asInstanceOf[HttpServletResponse]
|
||||||
|
val requestPath = request.getRequestURI.substring(request.getContextPath.length)
|
||||||
|
requestPath match {
|
||||||
|
case githubRepositoryPattern() =>
|
||||||
|
response.sendRedirect(baseUrl + "/git" + requestPath)
|
||||||
|
|
||||||
|
case _ =>
|
||||||
|
chain.doFilter(req, res)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override def destroy() = {}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,16 +5,16 @@ import javax.servlet.http._
|
|||||||
import gitbucket.core.plugin.{GitRepositoryFilter, GitRepositoryRouting, PluginRegistry}
|
import gitbucket.core.plugin.{GitRepositoryFilter, GitRepositoryRouting, PluginRegistry}
|
||||||
import gitbucket.core.service.SystemSettingsService.SystemSettings
|
import gitbucket.core.service.SystemSettingsService.SystemSettings
|
||||||
import gitbucket.core.service.{RepositoryService, AccountService, SystemSettingsService}
|
import gitbucket.core.service.{RepositoryService, AccountService, SystemSettingsService}
|
||||||
import gitbucket.core.util.{Keys, Implicits}
|
import gitbucket.core.util.{Keys, Implicits, AuthUtil}
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import Implicits._
|
import Implicits._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides BASIC Authentication for [[GitRepositoryServlet]].
|
* Provides BASIC Authentication for [[GitRepositoryServlet]].
|
||||||
*/
|
*/
|
||||||
class BasicAuthenticationFilter extends Filter with RepositoryService with AccountService with SystemSettingsService {
|
class GitAuthenticationFilter extends Filter with RepositoryService with AccountService with SystemSettingsService {
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(classOf[BasicAuthenticationFilter])
|
private val logger = LoggerFactory.getLogger(classOf[GitAuthenticationFilter])
|
||||||
|
|
||||||
def init(config: FilterConfig) = {}
|
def init(config: FilterConfig) = {}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
|
|||||||
} catch {
|
} catch {
|
||||||
case ex: Exception => {
|
case ex: Exception => {
|
||||||
logger.error("error", ex)
|
logger.error("error", ex)
|
||||||
requireAuth(response)
|
AuthUtil.requireAuth(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
|
|||||||
|
|
||||||
val account = for {
|
val account = for {
|
||||||
auth <- Option(request.getHeader("Authorization"))
|
auth <- Option(request.getHeader("Authorization"))
|
||||||
Array(username, password) = decodeAuthHeader(auth).split(":", 2)
|
Array(username, password) = AuthUtil.decodeAuthHeader(auth).split(":", 2)
|
||||||
account <- authenticate(settings, username, password)
|
account <- authenticate(settings, username, password)
|
||||||
} yield {
|
} yield {
|
||||||
request.setAttribute(Keys.Request.UserName, account.userName)
|
request.setAttribute(Keys.Request.UserName, account.userName)
|
||||||
@@ -64,7 +64,7 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
|
|||||||
if(filter.filter(request.gitRepositoryPath, account.map(_.userName), settings, isUpdating)){
|
if(filter.filter(request.gitRepositoryPath, account.map(_.userName), settings, isUpdating)){
|
||||||
chain.doFilter(request, response)
|
chain.doFilter(request, response)
|
||||||
} else {
|
} else {
|
||||||
requireAuth(response)
|
AuthUtil.requireAuth(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,10 +81,10 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
|
|||||||
} else {
|
} else {
|
||||||
val passed = for {
|
val passed = for {
|
||||||
auth <- Option(request.getHeader("Authorization"))
|
auth <- Option(request.getHeader("Authorization"))
|
||||||
Array(username, password) = decodeAuthHeader(auth).split(":", 2)
|
Array(username, password) = AuthUtil.decodeAuthHeader(auth).split(":", 2)
|
||||||
account <- authenticate(settings, username, password)
|
account <- authenticate(settings, username, password)
|
||||||
} yield if(isUpdating || repository.repository.isPrivate){
|
} yield if(isUpdating || repository.repository.isPrivate){
|
||||||
if(hasWritePermission(repository.owner, repository.name, Some(account))){
|
if(hasDeveloperRole(repository.owner, repository.name, Some(account))){
|
||||||
request.setAttribute(Keys.Request.UserName, account.userName)
|
request.setAttribute(Keys.Request.UserName, account.userName)
|
||||||
true
|
true
|
||||||
} else false
|
} else false
|
||||||
@@ -93,7 +93,7 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
|
|||||||
if(passed.getOrElse(false)){
|
if(passed.getOrElse(false)){
|
||||||
chain.doFilter(request, response)
|
chain.doFilter(request, response)
|
||||||
} else {
|
} else {
|
||||||
requireAuth(response)
|
AuthUtil.requireAuth(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,17 +108,4 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def requireAuth(response: HttpServletResponse): Unit = {
|
|
||||||
response.setHeader("WWW-Authenticate", "BASIC realm=\"GitBucket\"")
|
|
||||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED)
|
|
||||||
}
|
|
||||||
|
|
||||||
private def decodeAuthHeader(header: String): String = {
|
|
||||||
try {
|
|
||||||
new String(new sun.misc.BASE64Decoder().decodeBuffer(header.substring(6)))
|
|
||||||
} catch {
|
|
||||||
case _: Throwable => ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
|
|||||||
* Provides Git repository via HTTP.
|
* Provides Git repository via HTTP.
|
||||||
*
|
*
|
||||||
* This servlet provides only Git repository functionality.
|
* This servlet provides only Git repository functionality.
|
||||||
* Authentication is provided by [[BasicAuthenticationFilter]].
|
* Authentication is provided by [[GitAuthenticationFilter]].
|
||||||
*/
|
*/
|
||||||
class GitRepositoryServlet extends GitServlet with SystemSettingsService {
|
class GitRepositoryServlet extends GitServlet with SystemSettingsService {
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ import scala.collection.JavaConverters._
|
|||||||
class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl: String)(implicit session: Session)
|
class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl: String)(implicit session: Session)
|
||||||
extends PostReceiveHook with PreReceiveHook
|
extends PostReceiveHook with PreReceiveHook
|
||||||
with RepositoryService with AccountService with IssuesService with ActivityService with PullRequestService with WebHookService
|
with RepositoryService with AccountService with IssuesService with ActivityService with PullRequestService with WebHookService
|
||||||
with WebHookPullRequestService with ProtectedBranchService {
|
with WebHookPullRequestService with CommitsService {
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(classOf[CommitLogHook])
|
private val logger = LoggerFactory.getLogger(classOf[CommitLogHook])
|
||||||
private var existIds: Seq[String] = Nil
|
private var existIds: Seq[String] = Nil
|
||||||
@@ -139,6 +139,8 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
|||||||
def onPostReceive(receivePack: ReceivePack, commands: java.util.Collection[ReceiveCommand]): Unit = {
|
def onPostReceive(receivePack: ReceivePack, commands: java.util.Collection[ReceiveCommand]): Unit = {
|
||||||
try {
|
try {
|
||||||
using(Git.open(Directory.getRepositoryDir(owner, repository))) { git =>
|
using(Git.open(Directory.getRepositoryDir(owner, repository))) { git =>
|
||||||
|
JGitUtil.removeCache(git)
|
||||||
|
|
||||||
val pushedIds = scala.collection.mutable.Set[String]()
|
val pushedIds = scala.collection.mutable.Set[String]()
|
||||||
commands.asScala.foreach { command =>
|
commands.asScala.foreach { command =>
|
||||||
logger.debug(s"commandType: ${command.getType}, refName: ${command.getRefName}")
|
logger.debug(s"commandType: ${command.getType}, refName: ${command.getRefName}")
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import org.apache.commons.io.FileUtils
|
|||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import akka.actor.{Actor, Props, ActorSystem}
|
import akka.actor.{Actor, Props, ActorSystem}
|
||||||
import com.typesafe.akka.extension.quartz.QuartzSchedulerExtension
|
import com.typesafe.akka.extension.quartz.QuartzSchedulerExtension
|
||||||
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize GitBucket system.
|
* Initialize GitBucket system.
|
||||||
@@ -35,6 +36,7 @@ class InitializeListener extends ServletContextListener with SystemSettingsServi
|
|||||||
|
|
||||||
Database() withTransaction { session =>
|
Database() withTransaction { session =>
|
||||||
val conn = session.conn
|
val conn = session.conn
|
||||||
|
val manager = new JDBCVersionManager(conn)
|
||||||
|
|
||||||
// Check version
|
// Check version
|
||||||
val versionFile = new File(GitBucketHome, "version")
|
val versionFile = new File(GitBucketHome, "version")
|
||||||
@@ -56,9 +58,8 @@ class InitializeListener extends ServletContextListener with SystemSettingsServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Change form
|
// Change form
|
||||||
val manager = new JDBCVersionManager(conn)
|
|
||||||
manager.initialize()
|
manager.initialize()
|
||||||
manager.updateVersion(GitBucketCoreModule.getModuleId, "4.0")
|
manager.updateVersion(GitBucketCoreModule.getModuleId, "4.0.0")
|
||||||
conn.select("SELECT PLUGIN_ID, VERSION FROM PLUGIN"){ rs =>
|
conn.select("SELECT PLUGIN_ID, VERSION FROM PLUGIN"){ rs =>
|
||||||
manager.updateVersion(rs.getString("PLUGIN_ID"), rs.getString("VERSION"))
|
manager.updateVersion(rs.getString("PLUGIN_ID"), rs.getString("VERSION"))
|
||||||
}
|
}
|
||||||
@@ -77,6 +78,19 @@ class InitializeListener extends ServletContextListener with SystemSettingsServi
|
|||||||
val solidbase = new Solidbase()
|
val solidbase = new Solidbase()
|
||||||
solidbase.migrate(conn, Thread.currentThread.getContextClassLoader, DatabaseConfig.liquiDriver, GitBucketCoreModule)
|
solidbase.migrate(conn, Thread.currentThread.getContextClassLoader, DatabaseConfig.liquiDriver, GitBucketCoreModule)
|
||||||
|
|
||||||
|
// Rescue code for users who updated from 3.14 to 4.0.0
|
||||||
|
// https://github.com/gitbucket/gitbucket/issues/1227
|
||||||
|
val currentVersion = manager.getCurrentVersion(GitBucketCoreModule.getModuleId)
|
||||||
|
val databaseVersion = if(currentVersion == "4.0"){
|
||||||
|
manager.updateVersion(GitBucketCoreModule.getModuleId, "4.0.0")
|
||||||
|
"4.0.0"
|
||||||
|
} else currentVersion
|
||||||
|
|
||||||
|
val gitbucketVersion = GitBucketCoreModule.getVersions.asScala.last.getVersion
|
||||||
|
if(databaseVersion != gitbucketVersion){
|
||||||
|
throw new IllegalStateException(s"Initialization failed. GitBucket version is ${gitbucketVersion}, but database version is ${databaseVersion}.")
|
||||||
|
}
|
||||||
|
|
||||||
// Load plugins
|
// Load plugins
|
||||||
logger.info("Initialize plugins")
|
logger.info("Initialize plugins")
|
||||||
PluginRegistry.initialize(event.getServletContext, loadSystemSettings(), conn)
|
PluginRegistry.initialize(event.getServletContext, loadSystemSettings(), conn)
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package gitbucket.core.servlet
|
||||||
|
|
||||||
|
import javax.servlet.http.{HttpServlet, HttpServletRequest, HttpServletResponse}
|
||||||
|
|
||||||
|
import gitbucket.core.plugin.PluginRegistry
|
||||||
|
import gitbucket.core.util.FileUtil
|
||||||
|
import org.apache.commons.io.IOUtils
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supply assets which are provided by plugins.
|
||||||
|
*/
|
||||||
|
class PluginAssetsServlet extends HttpServlet {
|
||||||
|
|
||||||
|
override def doGet(req: HttpServletRequest, resp: HttpServletResponse): Unit = {
|
||||||
|
val assetsMappings = PluginRegistry().getAssetsMappings
|
||||||
|
val path = req.getRequestURI.substring(req.getContextPath.length)
|
||||||
|
|
||||||
|
assetsMappings
|
||||||
|
.find { case (prefix, _, _) => path.startsWith("/plugin-assets" + prefix) }
|
||||||
|
.flatMap { case (prefix, resourcePath, classLoader) =>
|
||||||
|
val resourceName = path.substring(("/plugin-assets" + prefix).length)
|
||||||
|
Option(classLoader.getResourceAsStream(resourcePath.replaceFirst("^/", "") + resourceName))
|
||||||
|
}
|
||||||
|
.map { in =>
|
||||||
|
try {
|
||||||
|
val bytes = IOUtils.toByteArray(in)
|
||||||
|
resp.setContentLength(bytes.length)
|
||||||
|
resp.setContentType(FileUtil.getContentType(path, bytes))
|
||||||
|
resp.getOutputStream.write(bytes)
|
||||||
|
} finally {
|
||||||
|
in.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.getOrElse {
|
||||||
|
resp.setStatus(404)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -52,6 +52,13 @@ object Database {
|
|||||||
config.setJdbcUrl(DatabaseConfig.url)
|
config.setJdbcUrl(DatabaseConfig.url)
|
||||||
config.setUsername(DatabaseConfig.user)
|
config.setUsername(DatabaseConfig.user)
|
||||||
config.setPassword(DatabaseConfig.password)
|
config.setPassword(DatabaseConfig.password)
|
||||||
|
config.setAutoCommit(false)
|
||||||
|
DatabaseConfig.connectionTimeout.foreach(config.setConnectionTimeout)
|
||||||
|
DatabaseConfig.idleTimeout.foreach(config.setIdleTimeout)
|
||||||
|
DatabaseConfig.maxLifetime.foreach(config.setMaxLifetime)
|
||||||
|
DatabaseConfig.minimumIdle.foreach(config.setMinimumIdle)
|
||||||
|
DatabaseConfig.maximumPoolSize.foreach(config.setMaximumPoolSize)
|
||||||
|
|
||||||
logger.debug("load database connection pool")
|
logger.debug("load database connection pool")
|
||||||
new HikariDataSource(config)
|
new HikariDataSource(config)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import ControlUtil._
|
|||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import Directory._
|
import Directory._
|
||||||
import org.eclipse.jgit.transport.{ReceivePack, UploadPack}
|
import org.eclipse.jgit.transport.{ReceivePack, UploadPack}
|
||||||
import org.apache.sshd.server.command.UnknownCommand
|
import org.apache.sshd.server.scp.UnknownCommand
|
||||||
import org.eclipse.jgit.errors.RepositoryNotFoundException
|
import org.eclipse.jgit.errors.RepositoryNotFoundException
|
||||||
|
|
||||||
object GitCommand {
|
object GitCommand {
|
||||||
@@ -36,7 +36,7 @@ abstract class GitCommand extends Command with SessionAware {
|
|||||||
override def run(): Unit = {
|
override def run(): Unit = {
|
||||||
authUser match {
|
authUser match {
|
||||||
case Some(authUser) =>
|
case Some(authUser) =>
|
||||||
Database() withSession { implicit session =>
|
Database() withTransaction { implicit session =>
|
||||||
try {
|
try {
|
||||||
runTask(authUser)
|
runTask(authUser)
|
||||||
callback.onExit(0)
|
callback.onExit(0)
|
||||||
@@ -92,7 +92,7 @@ abstract class DefaultGitCommand(val owner: String, val repoName: String) extend
|
|||||||
protected def isWritableUser(username: String, repositoryInfo: RepositoryService.RepositoryInfo)
|
protected def isWritableUser(username: String, repositoryInfo: RepositoryService.RepositoryInfo)
|
||||||
(implicit session: Session): Boolean =
|
(implicit session: Session): Boolean =
|
||||||
getAccountByUserName(username) match {
|
getAccountByUserName(username) match {
|
||||||
case Some(account) => hasWritePermission(repositoryInfo.owner, repositoryInfo.name, Some(account))
|
case Some(account) => hasDeveloperRole(repositoryInfo.owner, repositoryInfo.name, Some(account))
|
||||||
case None => false
|
case None => false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import gitbucket.core.service.SshKeyService
|
|||||||
import gitbucket.core.servlet.Database
|
import gitbucket.core.servlet.Database
|
||||||
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator
|
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator
|
||||||
import org.apache.sshd.server.session.ServerSession
|
import org.apache.sshd.server.session.ServerSession
|
||||||
import org.apache.sshd.common.session.Session
|
import org.apache.sshd.common.AttributeStore
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
object PublicKeyAuthenticator {
|
object PublicKeyAuthenticator {
|
||||||
// put in the ServerSession here to be read by GitCommand later
|
// put in the ServerSession here to be read by GitCommand later
|
||||||
private val userNameSessionKey = new Session.AttributeKey[String]
|
private val userNameSessionKey = new AttributeStore.AttributeKey[String]
|
||||||
|
|
||||||
def putUserName(serverSession:ServerSession, userName:String):Unit =
|
def putUserName(serverSession:ServerSession, userName:String):Unit =
|
||||||
serverSession.setAttribute(userNameSessionKey, userName)
|
serverSession.setAttribute(userNameSessionKey, userName)
|
||||||
|
|||||||
21
src/main/scala/gitbucket/core/util/AuthUtil.scala
Normal file
21
src/main/scala/gitbucket/core/util/AuthUtil.scala
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package gitbucket.core.util
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides HTTP (Basic) Authentication related functions.
|
||||||
|
*/
|
||||||
|
object AuthUtil {
|
||||||
|
def requireAuth(response: HttpServletResponse): Unit = {
|
||||||
|
response.setHeader("WWW-Authenticate", "BASIC realm=\"GitBucket\"")
|
||||||
|
response.sendError(HttpServletResponse.SC_UNAUTHORIZED)
|
||||||
|
}
|
||||||
|
|
||||||
|
def decodeAuthHeader(header: String): String = {
|
||||||
|
try {
|
||||||
|
new String(new sun.misc.BASE64Decoder().decodeBuffer(header.substring(6)))
|
||||||
|
} catch {
|
||||||
|
case _: Throwable => ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package gitbucket.core.util
|
package gitbucket.core.util
|
||||||
|
|
||||||
import gitbucket.core.controller.ControllerBase
|
import gitbucket.core.controller.ControllerBase
|
||||||
import gitbucket.core.service.{RepositoryService, AccountService}
|
import gitbucket.core.service.{AccountService, RepositoryService}
|
||||||
|
import gitbucket.core.model.Role
|
||||||
import RepositoryService.RepositoryInfo
|
import RepositoryService.RepositoryInfo
|
||||||
import Implicits._
|
import Implicits._
|
||||||
import ControlUtil._
|
import ControlUtil._
|
||||||
@@ -40,9 +41,9 @@ trait OwnerAuthenticator { self: ControllerBase with RepositoryService with Acco
|
|||||||
context.loginAccount match {
|
context.loginAccount match {
|
||||||
case Some(x) if(x.isAdmin) => action(repository)
|
case Some(x) if(x.isAdmin) => action(repository)
|
||||||
case Some(x) if(repository.owner == x.userName) => action(repository)
|
case Some(x) if(repository.owner == x.userName) => action(repository)
|
||||||
case Some(x) if(getGroupMembers(repository.owner).exists { member =>
|
// TODO Repository management is allowed for only group managers?
|
||||||
member.userName == x.userName && member.isManager == true
|
case Some(x) if(getGroupMembers(repository.owner).exists { m => m.userName == x.userName && m.isManager == true }) => action(repository)
|
||||||
}) => action(repository)
|
case Some(x) if(getCollaboratorUserNames(paths(0), paths(1), Seq(Role.ADMIN)).contains(x.userName)) => action(repository)
|
||||||
case _ => Unauthorized()
|
case _ => Unauthorized()
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
@@ -86,32 +87,9 @@ trait AdminAuthenticator { self: ControllerBase =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows only collaborators and administrators.
|
* Allows only guests and signed in users who can access the repository.
|
||||||
*/
|
*/
|
||||||
trait CollaboratorsAuthenticator { self: ControllerBase with RepositoryService =>
|
trait ReferrerAuthenticator { self: ControllerBase with RepositoryService with AccountService =>
|
||||||
protected def collaboratorsOnly(action: (RepositoryInfo) => Any) = { authenticate(action) }
|
|
||||||
protected def collaboratorsOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) }
|
|
||||||
|
|
||||||
private def authenticate(action: (RepositoryInfo) => Any) = {
|
|
||||||
{
|
|
||||||
defining(request.paths){ paths =>
|
|
||||||
getRepository(paths(0), paths(1)).map { repository =>
|
|
||||||
context.loginAccount match {
|
|
||||||
case Some(x) if(x.isAdmin) => action(repository)
|
|
||||||
case Some(x) if(paths(0) == x.userName) => action(repository)
|
|
||||||
case Some(x) if(getCollaborators(paths(0), paths(1)).contains(x.userName)) => action(repository)
|
|
||||||
case _ => Unauthorized()
|
|
||||||
}
|
|
||||||
} getOrElse NotFound()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows only the repository owner (or manager for group repository) and administrators.
|
|
||||||
*/
|
|
||||||
trait ReferrerAuthenticator { self: ControllerBase with RepositoryService =>
|
|
||||||
protected def referrersOnly(action: (RepositoryInfo) => Any) = { authenticate(action) }
|
protected def referrersOnly(action: (RepositoryInfo) => Any) = { authenticate(action) }
|
||||||
protected def referrersOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) }
|
protected def referrersOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) }
|
||||||
|
|
||||||
@@ -125,7 +103,8 @@ trait ReferrerAuthenticator { self: ControllerBase with RepositoryService =>
|
|||||||
context.loginAccount match {
|
context.loginAccount match {
|
||||||
case Some(x) if(x.isAdmin) => action(repository)
|
case Some(x) if(x.isAdmin) => action(repository)
|
||||||
case Some(x) if(paths(0) == x.userName) => action(repository)
|
case Some(x) if(paths(0) == x.userName) => action(repository)
|
||||||
case Some(x) if(getCollaborators(paths(0), paths(1)).contains(x.userName)) => action(repository)
|
case Some(x) if(getGroupMembers(repository.owner).exists(_.userName == x.userName)) => action(repository)
|
||||||
|
case Some(x) if(getCollaboratorUserNames(paths(0), paths(1)).contains(x.userName)) => action(repository)
|
||||||
case _ => Unauthorized()
|
case _ => Unauthorized()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,9 +115,9 @@ trait ReferrerAuthenticator { self: ControllerBase with RepositoryService =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows only signed in users which can access the repository.
|
* Allows only signed in users who have read permission for the repository.
|
||||||
*/
|
*/
|
||||||
trait ReadableUsersAuthenticator { self: ControllerBase with RepositoryService =>
|
trait ReadableUsersAuthenticator { self: ControllerBase with RepositoryService with AccountService =>
|
||||||
protected def readableUsersOnly(action: (RepositoryInfo) => Any) = { authenticate(action) }
|
protected def readableUsersOnly(action: (RepositoryInfo) => Any) = { authenticate(action) }
|
||||||
protected def readableUsersOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) }
|
protected def readableUsersOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) }
|
||||||
|
|
||||||
@@ -150,7 +129,32 @@ trait ReadableUsersAuthenticator { self: ControllerBase with RepositoryService =
|
|||||||
case Some(x) if(x.isAdmin) => action(repository)
|
case Some(x) if(x.isAdmin) => action(repository)
|
||||||
case Some(x) if(!repository.repository.isPrivate) => action(repository)
|
case Some(x) if(!repository.repository.isPrivate) => action(repository)
|
||||||
case Some(x) if(paths(0) == x.userName) => action(repository)
|
case Some(x) if(paths(0) == x.userName) => action(repository)
|
||||||
case Some(x) if(getCollaborators(paths(0), paths(1)).contains(x.userName)) => action(repository)
|
case Some(x) if(getGroupMembers(repository.owner).exists(_.userName == x.userName)) => action(repository)
|
||||||
|
case Some(x) if(getCollaboratorUserNames(paths(0), paths(1)).contains(x.userName)) => action(repository)
|
||||||
|
case _ => Unauthorized()
|
||||||
|
}
|
||||||
|
} getOrElse NotFound()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows only signed in users who have write permission for the repository.
|
||||||
|
*/
|
||||||
|
trait WritableUsersAuthenticator { self: ControllerBase with RepositoryService with AccountService =>
|
||||||
|
protected def writableUsersOnly(action: (RepositoryInfo) => Any) = { authenticate(action) }
|
||||||
|
protected def writableUsersOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) }
|
||||||
|
|
||||||
|
private def authenticate(action: (RepositoryInfo) => Any) = {
|
||||||
|
{
|
||||||
|
defining(request.paths){ paths =>
|
||||||
|
getRepository(paths(0), paths(1)).map { repository =>
|
||||||
|
context.loginAccount match {
|
||||||
|
case Some(x) if(x.isAdmin) => action(repository)
|
||||||
|
case Some(x) if(paths(0) == x.userName) => action(repository)
|
||||||
|
case Some(x) if(getGroupMembers(repository.owner).exists(_.userName == x.userName)) => action(repository)
|
||||||
|
case Some(x) if(getCollaboratorUserNames(paths(0), paths(1), Seq(Role.ADMIN, Role.DEVELOPER)).contains(x.userName)) => action(repository)
|
||||||
case _ => Unauthorized()
|
case _ => Unauthorized()
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ object DatabaseConfig {
|
|||||||
| url = "jdbc:h2:${DatabaseHome};MVCC=true"
|
| url = "jdbc:h2:${DatabaseHome};MVCC=true"
|
||||||
| user = "sa"
|
| user = "sa"
|
||||||
| password = "sa"
|
| password = "sa"
|
||||||
|
|# connectionTimeout = 30000
|
||||||
|
|# idleTimeout = 600000
|
||||||
|
|# maxLifetime = 1800000
|
||||||
|
|# minimumIdle = 10
|
||||||
|
|# maximumPoolSize = 10
|
||||||
|}
|
|}
|
||||||
|""".stripMargin, "UTF-8")
|
|""".stripMargin, "UTF-8")
|
||||||
}
|
}
|
||||||
@@ -28,12 +33,21 @@ object DatabaseConfig {
|
|||||||
def url(directory: Option[String]): String =
|
def url(directory: Option[String]): String =
|
||||||
dbUrl.replace("${DatabaseHome}", directory.getOrElse(DatabaseHome))
|
dbUrl.replace("${DatabaseHome}", directory.getOrElse(DatabaseHome))
|
||||||
|
|
||||||
lazy val url: String = url(None)
|
lazy val url : String = url(None)
|
||||||
lazy val user: String = config.getString("db.user")
|
lazy val user : String = config.getString("db.user")
|
||||||
lazy val password: String = config.getString("db.password")
|
lazy val password : String = config.getString("db.password")
|
||||||
lazy val jdbcDriver: String = DatabaseType(url).jdbcDriver
|
lazy val jdbcDriver : String = DatabaseType(url).jdbcDriver
|
||||||
lazy val slickDriver: slick.driver.JdbcProfile = DatabaseType(url).slickDriver
|
lazy val slickDriver : slick.driver.JdbcProfile = DatabaseType(url).slickDriver
|
||||||
lazy val liquiDriver: AbstractJdbcDatabase = DatabaseType(url).liquiDriver
|
lazy val liquiDriver : AbstractJdbcDatabase = DatabaseType(url).liquiDriver
|
||||||
|
lazy val connectionTimeout : Option[Long] = getOptionValue("db.connectionTimeout", config.getLong)
|
||||||
|
lazy val idleTimeout : Option[Long] = getOptionValue("db.idleTimeout" , config.getLong)
|
||||||
|
lazy val maxLifetime : Option[Long] = getOptionValue("db.maxLifetime" , config.getLong)
|
||||||
|
lazy val minimumIdle : Option[Int] = getOptionValue("db.minimumIdle" , config.getInt)
|
||||||
|
lazy val maximumPoolSize : Option[Int] = getOptionValue("db.maximumPoolSize" , config.getInt)
|
||||||
|
|
||||||
|
private def getOptionValue[T](path: String, f: String => T): Option[T] = {
|
||||||
|
if(config.hasPath(path)) Some(f(path)) else None
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import gitbucket.core.api.JsonFormat
|
|||||||
import gitbucket.core.controller.Context
|
import gitbucket.core.controller.Context
|
||||||
import gitbucket.core.servlet.Database
|
import gitbucket.core.servlet.Database
|
||||||
|
|
||||||
|
import java.util.regex.Pattern.quote
|
||||||
|
|
||||||
import javax.servlet.http.{HttpSession, HttpServletRequest}
|
import javax.servlet.http.{HttpSession, HttpServletRequest}
|
||||||
|
|
||||||
import scala.util.matching.Regex
|
import scala.util.matching.Regex
|
||||||
@@ -73,7 +75,7 @@ object Implicits {
|
|||||||
|
|
||||||
def hasAttribute(name: String): Boolean = request.getAttribute(name) != null
|
def hasAttribute(name: String): Boolean = request.getAttribute(name) != null
|
||||||
|
|
||||||
def gitRepositoryPath: String = request.getRequestURI.replaceFirst("^/git/", "/")
|
def gitRepositoryPath: String = request.getRequestURI.replaceFirst("^" + quote(request.getContextPath) + "/git/", "/")
|
||||||
|
|
||||||
def baseUrl:String = {
|
def baseUrl:String = {
|
||||||
val url = request.getRequestURL.toString
|
val url = request.getRequestURL.toString
|
||||||
@@ -83,12 +85,6 @@ object Implicits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
implicit class RichSession(session: HttpSession){
|
implicit class RichSession(session: HttpSession){
|
||||||
|
|
||||||
def putAndGet[T](key: String, value: T): T = {
|
|
||||||
session.setAttribute(key, value)
|
|
||||||
value
|
|
||||||
}
|
|
||||||
|
|
||||||
def getAndRemove[T](key: String): Option[T] = {
|
def getAndRemove[T](key: String): Option[T] = {
|
||||||
val value = session.getAttribute(key).asInstanceOf[T]
|
val value = session.getAttribute(key).asInstanceOf[T]
|
||||||
if(value == null){
|
if(value == null){
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ package gitbucket.core.util
|
|||||||
import java.io._
|
import java.io._
|
||||||
import java.sql._
|
import java.sql._
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import javax.xml.stream.{XMLStreamConstants, XMLInputFactory, XMLOutputFactory}
|
|
||||||
import ControlUtil._
|
import ControlUtil._
|
||||||
import scala.StringBuilder
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.collection.mutable
|
|
||||||
import scala.collection.mutable.ListBuffer
|
import scala.collection.mutable.ListBuffer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides implicit class which extends java.sql.Connection.
|
* Provides implicit class which extends java.sql.Connection.
|
||||||
* This is used in automatic migration in [[servlet.AutoUpdateListener]].
|
* This is used in following points:
|
||||||
|
*
|
||||||
|
* - Automatic migration in [[gitbucket.core.servlet.InitializeListener]]
|
||||||
|
* - Data importing / exporting in [[gitbucket.core.controller.SystemSettingsController]] and [[gitbucket.core.controller.FileUploadController]]
|
||||||
*/
|
*/
|
||||||
object JDBCUtil {
|
object JDBCUtil {
|
||||||
|
|
||||||
@@ -64,65 +64,38 @@ object JDBCUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def importAsXML(in: InputStream): Unit = {
|
def importAsSQL(in: InputStream): Unit = {
|
||||||
conn.setAutoCommit(false)
|
conn.setAutoCommit(false)
|
||||||
try {
|
try {
|
||||||
val factory = XMLInputFactory.newInstance()
|
using(in){ in =>
|
||||||
using(factory.createXMLStreamReader(in, "UTF-8")){ reader =>
|
var out = new ByteArrayOutputStream()
|
||||||
// stateful objects
|
|
||||||
var elementName = ""
|
|
||||||
var insertTable = ""
|
|
||||||
var insertColumns = Map.empty[String, (String, String)]
|
|
||||||
|
|
||||||
while(reader.hasNext){
|
var length = 0
|
||||||
reader.next()
|
val bytes = new scala.Array[Byte](1024 * 8)
|
||||||
|
var stringLiteral = false
|
||||||
|
|
||||||
reader.getEventType match {
|
while({ length = in.read(bytes); length != -1 }){
|
||||||
case XMLStreamConstants.START_ELEMENT =>
|
for(i <- 0 to length - 1){
|
||||||
elementName = reader.getName.getLocalPart
|
val c = bytes(i)
|
||||||
if(elementName == "insert"){
|
if(c == '\''){
|
||||||
insertTable = reader.getAttributeValue(null, "table")
|
stringLiteral = !stringLiteral
|
||||||
} else if(elementName == "delete"){
|
}
|
||||||
val tableName = reader.getAttributeValue(null, "table")
|
if(c == ';' && !stringLiteral){
|
||||||
conn.update(s"DELETE FROM ${tableName}")
|
val sql = new String(out.toByteArray, "UTF-8")
|
||||||
} else if(elementName == "column"){
|
conn.update(sql.trim)
|
||||||
val columnName = reader.getAttributeValue(null, "name")
|
out = new ByteArrayOutputStream()
|
||||||
val columnType = reader.getAttributeValue(null, "type")
|
} else {
|
||||||
val columnValue = reader.getElementText
|
out.write(c)
|
||||||
insertColumns = insertColumns + (columnName -> (columnType, columnValue))
|
}
|
||||||
}
|
|
||||||
case XMLStreamConstants.END_ELEMENT =>
|
|
||||||
// Execute insert statement
|
|
||||||
reader.getName.getLocalPart match {
|
|
||||||
case "insert" => {
|
|
||||||
val sb = new StringBuilder()
|
|
||||||
sb.append(s"INSERT INTO ${insertTable} (")
|
|
||||||
sb.append(insertColumns.map { case (columnName, _) => columnName }.mkString(", "))
|
|
||||||
sb.append(") VALUES (")
|
|
||||||
sb.append(insertColumns.map { case (_, (columnType, columnValue)) =>
|
|
||||||
if(columnType == null || columnValue == null){
|
|
||||||
"NULL"
|
|
||||||
} else if(columnType == "string"){
|
|
||||||
"'" + columnValue.replace("'", "''") + "'"
|
|
||||||
} else if(columnType == "timestamp"){
|
|
||||||
"'" + columnValue + "'"
|
|
||||||
} else {
|
|
||||||
columnValue.toString
|
|
||||||
}
|
|
||||||
}.mkString(", "))
|
|
||||||
sb.append(")")
|
|
||||||
|
|
||||||
conn.update(sb.toString)
|
|
||||||
|
|
||||||
insertColumns = Map.empty[String, (String, String)] // Clear column information
|
|
||||||
}
|
|
||||||
case _ => // Nothing to do
|
|
||||||
}
|
|
||||||
case _ => // Nothing to do
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
val remain = out.toByteArray
|
||||||
|
if(remain.length != 0){
|
||||||
|
val sql = new String(remain, "UTF-8")
|
||||||
|
conn.update(sql.trim)
|
||||||
|
}
|
||||||
|
}
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
@@ -133,68 +106,6 @@ object JDBCUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def exportAsXML(targetTables: Seq[String]): File = {
|
|
||||||
val dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
|
|
||||||
val file = File.createTempFile("gitbucket-export-", ".xml")
|
|
||||||
|
|
||||||
val factory = XMLOutputFactory.newInstance()
|
|
||||||
using(factory.createXMLStreamWriter(new FileOutputStream(file), "UTF-8")){ writer =>
|
|
||||||
val dbMeta = conn.getMetaData
|
|
||||||
val allTablesInDatabase = allTablesOrderByDependencies(dbMeta)
|
|
||||||
|
|
||||||
writer.writeStartDocument("UTF-8", "1.0")
|
|
||||||
writer.writeStartElement("tables")
|
|
||||||
|
|
||||||
println(allTablesInDatabase.mkString(", "))
|
|
||||||
|
|
||||||
allTablesInDatabase.reverse.foreach { tableName =>
|
|
||||||
if (targetTables.contains(tableName)) {
|
|
||||||
writer.writeStartElement("delete")
|
|
||||||
writer.writeAttribute("table", tableName)
|
|
||||||
writer.writeEndElement()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allTablesInDatabase.foreach { tableName =>
|
|
||||||
if (targetTables.contains(tableName)) {
|
|
||||||
select(s"SELECT * FROM ${tableName}") { rs =>
|
|
||||||
writer.writeStartElement("insert")
|
|
||||||
writer.writeAttribute("table", tableName)
|
|
||||||
val rsMeta = rs.getMetaData
|
|
||||||
(1 to rsMeta.getColumnCount).foreach { i =>
|
|
||||||
val columnName = rsMeta.getColumnName(i)
|
|
||||||
val (columnType, columnValue) = if(rs.getObject(columnName) == null){
|
|
||||||
(null, null)
|
|
||||||
} else {
|
|
||||||
rsMeta.getColumnType(i) match {
|
|
||||||
case Types.BOOLEAN | Types.BIT => ("boolean", rs.getBoolean(columnName))
|
|
||||||
case Types.VARCHAR | Types.CLOB | Types.CHAR | Types.LONGVARCHAR => ("string", rs.getString(columnName))
|
|
||||||
case Types.INTEGER => ("int", rs.getInt(columnName))
|
|
||||||
case Types.TIMESTAMP => ("timestamp", dateFormat.format(rs.getTimestamp(columnName)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writer.writeStartElement("column")
|
|
||||||
writer.writeAttribute("name", columnName)
|
|
||||||
if(columnType != null){
|
|
||||||
writer.writeAttribute("type", columnType)
|
|
||||||
}
|
|
||||||
if(columnValue != null){
|
|
||||||
writer.writeCharacters(columnValue.toString)
|
|
||||||
}
|
|
||||||
writer.writeEndElement()
|
|
||||||
}
|
|
||||||
writer.writeEndElement()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.writeEndElement()
|
|
||||||
writer.writeEndDocument()
|
|
||||||
}
|
|
||||||
|
|
||||||
file
|
|
||||||
}
|
|
||||||
|
|
||||||
def exportAsSQL(targetTables: Seq[String]): File = {
|
def exportAsSQL(targetTables: Seq[String]): File = {
|
||||||
val dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
|
val dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
|
||||||
val file = File.createTempFile("gitbucket-export-", ".sql")
|
val file = File.createTempFile("gitbucket-export-", ".sql")
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.eclipse.jgit.api.Git
|
|||||||
import Directory._
|
import Directory._
|
||||||
import StringUtil._
|
import StringUtil._
|
||||||
import ControlUtil._
|
import ControlUtil._
|
||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
import org.eclipse.jgit.lib._
|
import org.eclipse.jgit.lib._
|
||||||
@@ -16,7 +17,11 @@ import org.eclipse.jgit.diff.DiffEntry.ChangeType
|
|||||||
import org.eclipse.jgit.errors.{ConfigInvalidException, MissingObjectException}
|
import org.eclipse.jgit.errors.{ConfigInvalidException, MissingObjectException}
|
||||||
import org.eclipse.jgit.transport.RefSpec
|
import org.eclipse.jgit.transport.RefSpec
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import org.eclipse.jgit.api.errors.{JGitInternalException, InvalidRefNameException, RefAlreadyExistsException, NoHeadException}
|
import java.util.concurrent.TimeUnit
|
||||||
|
import java.util.function.Consumer
|
||||||
|
|
||||||
|
import org.cache2k.{Cache2kBuilder, CacheEntry}
|
||||||
|
import org.eclipse.jgit.api.errors.{InvalidRefNameException, JGitInternalException, NoHeadException, RefAlreadyExistsException}
|
||||||
import org.eclipse.jgit.dircache.DirCacheEntry
|
import org.eclipse.jgit.dircache.DirCacheEntry
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
@@ -32,14 +37,11 @@ object JGitUtil {
|
|||||||
*
|
*
|
||||||
* @param owner the user name of the repository owner
|
* @param owner the user name of the repository owner
|
||||||
* @param name the repository name
|
* @param name the repository name
|
||||||
* @param commitCount the commit count. If the repository has over 1000 commits then this property is 1001.
|
|
||||||
* @param branchList the list of branch names
|
* @param branchList the list of branch names
|
||||||
* @param tags the list of tags
|
* @param tags the list of tags
|
||||||
*/
|
*/
|
||||||
case class RepositoryInfo(owner: String, name: String, commitCount: Int, branchList: List[String], tags: List[TagInfo]){
|
case class RepositoryInfo(owner: String, name: String, branchList: List[String], tags: List[TagInfo]){
|
||||||
def this(owner: String, name: String) = {
|
def this(owner: String, name: String) = this(owner, name, Nil, Nil)
|
||||||
this(owner, name, 0, Nil, Nil)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,20 +171,54 @@ object JGitUtil {
|
|||||||
revWalk.dispose
|
revWalk.dispose
|
||||||
revCommit
|
revCommit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val cache = new Cache2kBuilder[String, Int]() {}
|
||||||
|
.name("commit-count")
|
||||||
|
.expireAfterWrite(24, TimeUnit.HOURS)
|
||||||
|
.entryCapacity(10000)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
def removeCache(git: Git): Unit = {
|
||||||
|
val dir = git.getRepository.getDirectory
|
||||||
|
val keyPrefix = dir.getAbsolutePath + "@"
|
||||||
|
|
||||||
|
cache.forEach(new Consumer[CacheEntry[String, Int]] {
|
||||||
|
override def accept(entry: CacheEntry[String, Int]): Unit = {
|
||||||
|
if(entry.getKey.startsWith(keyPrefix)){
|
||||||
|
cache.remove(entry.getKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of commits in the specified branch or commit.
|
||||||
|
* If the specified branch has over 10000 commits, this method returns 100001.
|
||||||
|
*/
|
||||||
|
def getCommitCount(owner: String, repository: String, branch: String): Int = {
|
||||||
|
val dir = getRepositoryDir(owner, repository)
|
||||||
|
val key = dir.getAbsolutePath + "@" + branch
|
||||||
|
val entry = cache.getEntry(key)
|
||||||
|
|
||||||
|
if(entry == null) {
|
||||||
|
using(Git.open(dir)) { git =>
|
||||||
|
val commitId = git.getRepository.resolve(branch)
|
||||||
|
val commitCount = git.log.add(commitId).call.iterator.asScala.take(10001).size
|
||||||
|
cache.put(key, commitCount)
|
||||||
|
commitCount
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entry.getValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the repository information. It contains branch names and tag names.
|
* Returns the repository information. It contains branch names and tag names.
|
||||||
*/
|
*/
|
||||||
def getRepositoryInfo(owner: String, repository: String): RepositoryInfo = {
|
def getRepositoryInfo(owner: String, repository: String): RepositoryInfo = {
|
||||||
using(Git.open(getRepositoryDir(owner, repository))){ git =>
|
using(Git.open(getRepositoryDir(owner, repository))){ git =>
|
||||||
try {
|
try {
|
||||||
// get commit count
|
RepositoryInfo(owner, repository,
|
||||||
val commitCount = git.log.all.call.iterator.asScala.map(_ => 1).take(10001).sum
|
|
||||||
|
|
||||||
RepositoryInfo(
|
|
||||||
owner, repository,
|
|
||||||
// commit count
|
|
||||||
commitCount,
|
|
||||||
// branches
|
// branches
|
||||||
git.branchList.call.asScala.map { ref =>
|
git.branchList.call.asScala.map { ref =>
|
||||||
ref.getName.stripPrefix("refs/heads/")
|
ref.getName.stripPrefix("refs/heads/")
|
||||||
@@ -195,9 +231,7 @@ object JGitUtil {
|
|||||||
)
|
)
|
||||||
} catch {
|
} catch {
|
||||||
// not initialized
|
// not initialized
|
||||||
case e: NoHeadException => RepositoryInfo(
|
case e: NoHeadException => RepositoryInfo(owner, repository, Nil, Nil)
|
||||||
owner, repository, 0, Nil, Nil)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,8 +246,8 @@ object JGitUtil {
|
|||||||
*/
|
*/
|
||||||
def getFileList(git: Git, revision: String, path: String = "."): List[FileInfo] = {
|
def getFileList(git: Git, revision: String, path: String = "."): List[FileInfo] = {
|
||||||
using(new RevWalk(git.getRepository)){ revWalk =>
|
using(new RevWalk(git.getRepository)){ revWalk =>
|
||||||
val objectId = git.getRepository.resolve(revision)
|
val objectId = git.getRepository.resolve(revision)
|
||||||
if(objectId==null) return Nil
|
if(objectId == null) return Nil
|
||||||
val revCommit = revWalk.parseCommit(objectId)
|
val revCommit = revWalk.parseCommit(objectId)
|
||||||
|
|
||||||
def useTreeWalk(rev:RevCommit)(f:TreeWalk => Any): Unit = if (path == ".") {
|
def useTreeWalk(rev:RevCommit)(f:TreeWalk => Any): Unit = if (path == ".") {
|
||||||
@@ -255,14 +289,14 @@ object JGitUtil {
|
|||||||
revIterator:java.util.Iterator[RevCommit]): List[(ObjectId, FileMode, String, Option[String], RevCommit)] ={
|
revIterator:java.util.Iterator[RevCommit]): List[(ObjectId, FileMode, String, Option[String], RevCommit)] ={
|
||||||
if(restList.isEmpty){
|
if(restList.isEmpty){
|
||||||
result
|
result
|
||||||
}else if(!revIterator.hasNext){ // maybe, revCommit has only 1 log. other case, restList be empty
|
} else if(!revIterator.hasNext){ // maybe, revCommit has only 1 log. other case, restList be empty
|
||||||
result ++ restList.map{ case (tuple, map) => tupleAdd(tuple, map.values.headOption.getOrElse(revCommit)) }
|
result ++ restList.map { case (tuple, map) => tupleAdd(tuple, map.values.headOption.getOrElse(revCommit)) }
|
||||||
}else{
|
} else {
|
||||||
val newCommit = revIterator.next
|
val newCommit = revIterator.next
|
||||||
val (thisTimeChecks,skips) = restList.partition{ case (tuple, parentsMap) => parentsMap.contains(newCommit) }
|
val (thisTimeChecks,skips) = restList.partition { case (tuple, parentsMap) => parentsMap.contains(newCommit) }
|
||||||
if(thisTimeChecks.isEmpty){
|
if(thisTimeChecks.isEmpty){
|
||||||
findLastCommits(result, restList, revIterator)
|
findLastCommits(result, restList, revIterator)
|
||||||
}else{
|
} else {
|
||||||
var nextRest = skips
|
var nextRest = skips
|
||||||
var nextResult = result
|
var nextResult = result
|
||||||
// Map[(name, oid), (tuple, parentsMap)]
|
// Map[(name, oid), (tuple, parentsMap)]
|
||||||
@@ -270,20 +304,20 @@ object JGitUtil {
|
|||||||
lazy val newParentsMap = newCommit.getParents.map(_ -> newCommit).toMap
|
lazy val newParentsMap = newCommit.getParents.map(_ -> newCommit).toMap
|
||||||
useTreeWalk(newCommit){ walk =>
|
useTreeWalk(newCommit){ walk =>
|
||||||
while(walk.next){
|
while(walk.next){
|
||||||
rest.remove(walk.getNameString -> walk.getObjectId(0)).map{ case (tuple, _) =>
|
rest.remove(walk.getNameString -> walk.getObjectId(0)).map { case (tuple, _) =>
|
||||||
if(newParentsMap.isEmpty){
|
if(newParentsMap.isEmpty){
|
||||||
nextResult +:= tupleAdd(tuple, newCommit)
|
nextResult +:= tupleAdd(tuple, newCommit)
|
||||||
}else{
|
} else {
|
||||||
nextRest +:= tuple -> newParentsMap
|
nextRest +:= tuple -> newParentsMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rest.values.map{ case (tuple, parentsMap) =>
|
rest.values.map { case (tuple, parentsMap) =>
|
||||||
val restParentsMap = parentsMap - newCommit
|
val restParentsMap = parentsMap - newCommit
|
||||||
if(restParentsMap.isEmpty){
|
if(restParentsMap.isEmpty){
|
||||||
nextResult +:= tupleAdd(tuple, parentsMap(newCommit))
|
nextResult +:= tupleAdd(tuple, parentsMap(newCommit))
|
||||||
}else{
|
} else {
|
||||||
nextRest +:= tuple -> restParentsMap
|
nextRest +:= tuple -> restParentsMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,7 +329,7 @@ object JGitUtil {
|
|||||||
var fileList: List[(ObjectId, FileMode, String, Option[String])] = Nil
|
var fileList: List[(ObjectId, FileMode, String, Option[String])] = Nil
|
||||||
useTreeWalk(revCommit){ treeWalk =>
|
useTreeWalk(revCommit){ treeWalk =>
|
||||||
while (treeWalk.next()) {
|
while (treeWalk.next()) {
|
||||||
val linkUrl =if (treeWalk.getFileMode(0) == FileMode.GITLINK) {
|
val linkUrl = if (treeWalk.getFileMode(0) == FileMode.GITLINK) {
|
||||||
getSubmodules(git, revCommit.getTree).find(_.path == treeWalk.getPathString).map(_.url)
|
getSubmodules(git, revCommit.getTree).find(_.path == treeWalk.getPathString).map(_.url)
|
||||||
} else None
|
} else None
|
||||||
fileList +:= (treeWalk.getObjectId(0), treeWalk.getFileMode(0), treeWalk.getNameString, linkUrl)
|
fileList +:= (treeWalk.getObjectId(0), treeWalk.getFileMode(0), treeWalk.getNameString, linkUrl)
|
||||||
@@ -345,7 +379,7 @@ object JGitUtil {
|
|||||||
def getTreeId(git: Git, revision: String): Option[String] = {
|
def getTreeId(git: Git, revision: String): Option[String] = {
|
||||||
using(new RevWalk(git.getRepository)){ revWalk =>
|
using(new RevWalk(git.getRepository)){ revWalk =>
|
||||||
val objectId = git.getRepository.resolve(revision)
|
val objectId = git.getRepository.resolve(revision)
|
||||||
if(objectId==null) return None
|
if(objectId == null) return None
|
||||||
val revCommit = revWalk.parseCommit(objectId)
|
val revCommit = revWalk.parseCommit(objectId)
|
||||||
Some(revCommit.getTree.name)
|
Some(revCommit.getTree.name)
|
||||||
}
|
}
|
||||||
@@ -357,7 +391,7 @@ object JGitUtil {
|
|||||||
def getAllFileListByTreeId(git: Git, treeId: String): List[String] = {
|
def getAllFileListByTreeId(git: Git, treeId: String): List[String] = {
|
||||||
using(new RevWalk(git.getRepository)){ revWalk =>
|
using(new RevWalk(git.getRepository)){ revWalk =>
|
||||||
val objectId = git.getRepository.resolve(treeId+"^{tree}")
|
val objectId = git.getRepository.resolve(treeId+"^{tree}")
|
||||||
if(objectId==null) return Nil
|
if(objectId == null) return Nil
|
||||||
using(new TreeWalk(git.getRepository)){ treeWalk =>
|
using(new TreeWalk(git.getRepository)){ treeWalk =>
|
||||||
treeWalk.addTree(objectId)
|
treeWalk.addTree(objectId)
|
||||||
treeWalk.setRecursive(true)
|
treeWalk.setRecursive(true)
|
||||||
@@ -705,6 +739,8 @@ object JGitUtil {
|
|||||||
refUpdate.setNewObjectId(newHeadId)
|
refUpdate.setNewObjectId(newHeadId)
|
||||||
refUpdate.update()
|
refUpdate.update()
|
||||||
|
|
||||||
|
removeCache(git)
|
||||||
|
|
||||||
newHeadId
|
newHeadId
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,14 +866,16 @@ object JGitUtil {
|
|||||||
existIds.toSeq
|
existIds.toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
def processTree(git: Git, id: ObjectId)(f: (String, CanonicalTreeParser) => Unit) = {
|
def processTree[T](git: Git, id: ObjectId)(f: (String, CanonicalTreeParser) => T): Seq[T] = {
|
||||||
using(new RevWalk(git.getRepository)){ revWalk =>
|
using(new RevWalk(git.getRepository)){ revWalk =>
|
||||||
using(new TreeWalk(git.getRepository)){ treeWalk =>
|
using(new TreeWalk(git.getRepository)){ treeWalk =>
|
||||||
val index = treeWalk.addTree(revWalk.parseTree(id))
|
val index = treeWalk.addTree(revWalk.parseTree(id))
|
||||||
treeWalk.setRecursive(true)
|
treeWalk.setRecursive(true)
|
||||||
|
val result = new collection.mutable.ListBuffer[T]()
|
||||||
while(treeWalk.next){
|
while(treeWalk.next){
|
||||||
f(treeWalk.getPathString, treeWalk.getTree(index, classOf[CanonicalTreeParser]))
|
result += f(treeWalk.getPathString, treeWalk.getTree(index, classOf[CanonicalTreeParser]))
|
||||||
}
|
}
|
||||||
|
result.toSeq
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -875,6 +913,7 @@ object JGitUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last modified commit of specified path
|
* Returns the last modified commit of specified path
|
||||||
|
*
|
||||||
* @param git the Git object
|
* @param git the Git object
|
||||||
* @param startCommit the search base commit id
|
* @param startCommit the search base commit id
|
||||||
* @param path the path of target file or directory
|
* @param path the path of target file or directory
|
||||||
@@ -957,6 +996,7 @@ object JGitUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns sha1
|
* Returns sha1
|
||||||
|
*
|
||||||
* @param owner repository owner
|
* @param owner repository owner
|
||||||
* @param name repository name
|
* @param name repository name
|
||||||
* @param revstr A git object references expression
|
* @param revstr A git object references expression
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ trait Notifier extends RepositoryService with AccountService with IssuesService
|
|||||||
(
|
(
|
||||||
// individual repository's owner
|
// individual repository's owner
|
||||||
issue.userName ::
|
issue.userName ::
|
||||||
|
// group members of group repository
|
||||||
|
getGroupMembers(issue.userName).map(_.userName) :::
|
||||||
// collaborators
|
// collaborators
|
||||||
getCollaborators(issue.userName, issue.repositoryName) :::
|
getCollaboratorUserNames(issue.userName, issue.repositoryName) :::
|
||||||
// participants
|
// participants
|
||||||
issue.openedUserName ::
|
issue.openedUserName ::
|
||||||
getComments(issue.userName, issue.repositoryName, issue.issueId).map(_.commentedUserName)
|
getComments(issue.userName, issue.repositoryName, issue.issueId).map(_.commentedUserName)
|
||||||
@@ -107,6 +109,9 @@ class Mailer(private val smtp: Smtp) extends Notifier {
|
|||||||
}
|
}
|
||||||
smtp.ssl.foreach { ssl =>
|
smtp.ssl.foreach { ssl =>
|
||||||
email.setSSLOnConnect(ssl)
|
email.setSSLOnConnect(ssl)
|
||||||
|
if(ssl == true) {
|
||||||
|
email.setSslSmtpPort(smtp.port.get.toString)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
smtp.fromAddress
|
smtp.fromAddress
|
||||||
.map (_ -> smtp.fromName.getOrElse(context.loginAccount.get.userName))
|
.map (_ -> smtp.fromName.getOrElse(context.loginAccount.get.userName))
|
||||||
|
|||||||
@@ -86,8 +86,9 @@ object StringUtil {
|
|||||||
*@param message the message which may contains issue id
|
*@param message the message which may contains issue id
|
||||||
* @return the iterator of issue id
|
* @return the iterator of issue id
|
||||||
*/
|
*/
|
||||||
def extractIssueId(message: String): Iterator[String] =
|
def extractIssueId(message: String): Seq[String] =
|
||||||
"(^|\\W)#(\\d+)(\\W|$)".r.findAllIn(message).matchData.map(_.group(2))
|
"(^|\\W)#(\\d+)(\\W|$)".r
|
||||||
|
.findAllIn(message).matchData.map(_.group(2)).toSeq.distinct
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract close issue id like ```close #issueId ``` from the given message.
|
* Extract close issue id like ```close #issueId ``` from the given message.
|
||||||
@@ -95,7 +96,8 @@ object StringUtil {
|
|||||||
* @param message the message which may contains close command
|
* @param message the message which may contains close command
|
||||||
* @return the iterator of issue id
|
* @return the iterator of issue id
|
||||||
*/
|
*/
|
||||||
def extractCloseId(message: String): Iterator[String] =
|
def extractCloseId(message: String): Seq[String] =
|
||||||
"(?i)(?<!\\w)(?:fix(?:e[sd])?|resolve[sd]?|close[sd]?)\\s+#(\\d+)(?!\\w)".r.findAllIn(message).matchData.map(_.group(1))
|
"(?i)(?<!\\w)(?:fix(?:e[sd])?|resolve[sd]?|close[sd]?)\\s+#(\\d+)(?!\\w)".r
|
||||||
|
.findAllIn(message).matchData.map(_.group(1)).toSeq.distinct
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ trait LinkConverter { self: RequestCache =>
|
|||||||
// convert username/project@SHA to link
|
// convert username/project@SHA to link
|
||||||
.replaceBy("(?<=(^|\\W))([a-zA-Z0-9\\-_]+)/([a-zA-Z0-9\\-_\\.]+)@([a-f0-9]{40})(?=(\\W|$))".r){ m =>
|
.replaceBy("(?<=(^|\\W))([a-zA-Z0-9\\-_]+)/([a-zA-Z0-9\\-_\\.]+)@([a-f0-9]{40})(?=(\\W|$))".r){ m =>
|
||||||
getAccountByUserName(m.group(2)).map { _ =>
|
getAccountByUserName(m.group(2)).map { _ =>
|
||||||
s"""<a href="${context.path}/${m.group(2)}/${m.group(3)}/commit/${m.group(4)}">${m.group(2)}/${m.group(3)}@${m.group(4).substring(0, 7)}</a>"""
|
s"""<code><a href="${context.path}/${m.group(2)}/${m.group(3)}/commit/${m.group(4)}">${m.group(2)}/${m.group(3)}@${m.group(4).substring(0, 7)}</a></code>"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ trait LinkConverter { self: RequestCache =>
|
|||||||
// convert username@SHA to link
|
// convert username@SHA to link
|
||||||
.replaceBy( ("(?<=(^|\\W))([a-zA-Z0-9\\-_]+)@([a-f0-9]{40})(?=(\\W|$))").r ) { m =>
|
.replaceBy( ("(?<=(^|\\W))([a-zA-Z0-9\\-_]+)@([a-f0-9]{40})(?=(\\W|$))").r ) { m =>
|
||||||
getAccountByUserName(m.group(2)).map { _ =>
|
getAccountByUserName(m.group(2)).map { _ =>
|
||||||
s"""<a href="${context.path}/${m.group(2)}/${repository.name}/commit/${m.group(3)}">${m.group(2)}@${m.group(3).substring(0, 7)}</a>"""
|
s"""<code><a href="${context.path}/${m.group(2)}/${repository.name}/commit/${m.group(3)}">${m.group(2)}@${m.group(3).substring(0, 7)}</a></code>"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ trait LinkConverter { self: RequestCache =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// convert issue id to link
|
// convert issue id to link
|
||||||
.replaceBy(("(?<=(^|\\W))(GH-|" + issueIdPrefix + ")([0-9]+)(?=(\\W|$))").r){ m =>
|
.replaceBy(("(?<=(^|\\W))(GH-|(?<!&)" + issueIdPrefix + ")([0-9]+)(?=(\\W|$))").r){ m =>
|
||||||
val prefix = if(m.group(2) == "issue:") "#" else m.group(2)
|
val prefix = if(m.group(2) == "issue:") "#" else m.group(2)
|
||||||
getIssue(repository.owner, repository.name, m.group(3)) match {
|
getIssue(repository.owner, repository.name, m.group(3)) match {
|
||||||
case Some(issue) if(issue.isPullRequest) =>
|
case Some(issue) if(issue.isPullRequest) =>
|
||||||
@@ -93,6 +93,8 @@ trait LinkConverter { self: RequestCache =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// convert commit id to link
|
// convert commit id to link
|
||||||
.replaceAll("(?<=(^|[^\\w/@]))([a-f0-9]{40})(?=(\\W|$))", s"""<a href="${context.path}/${repository.owner}/${repository.name}/commit/$$2">$$2</a>""")
|
.replaceBy("(?<=(^|[^\\w/@]))([a-f0-9]{40})(?=(\\W|$))".r){ m =>
|
||||||
|
Some(s"""<code><a href="${context.path}/${repository.owner}/${repository.name}/commit/${m.group(2)}">${m.group(2).substring(0, 7)}</a></code>""")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ object Markdown {
|
|||||||
val renderer = new GitBucketMarkedRenderer(options, repository,
|
val renderer = new GitBucketMarkedRenderer(options, repository,
|
||||||
enableWikiLink, enableRefsLink, enableAnchor, enableTaskList, hasWritePermission, pages)
|
enableWikiLink, enableRefsLink, enableAnchor, enableTaskList, hasWritePermission, pages)
|
||||||
|
|
||||||
|
//helpers.decorateHtml(Marked.marked(source, options, renderer), repository)
|
||||||
Marked.marked(source, options, renderer)
|
Marked.marked(source, options, renderer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,11 +110,10 @@ object Markdown {
|
|||||||
override def text(text: String): String = {
|
override def text(text: String): String = {
|
||||||
// convert commit id and username to link.
|
// convert commit id and username to link.
|
||||||
val t1 = if(enableRefsLink) convertRefsLinks(text, repository, "#", false) else text
|
val t1 = if(enableRefsLink) convertRefsLinks(text, repository, "#", false) else text
|
||||||
|
|
||||||
// convert task list to checkbox.
|
// convert task list to checkbox.
|
||||||
val t2 = if(enableTaskList) convertCheckBox(t1, hasWritePermission) else t1
|
val t2 = if(enableTaskList) convertCheckBox(t1, hasWritePermission) else t1
|
||||||
|
// decorate by TextDecorator plugins
|
||||||
t2
|
helpers.decorateHtml(t2, repository)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def link(href: String, title: String, text: String): String = {
|
override def link(href: String, title: String, text: String): String = {
|
||||||
@@ -147,21 +147,23 @@ object Markdown {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def fixUrl(url: String, isImage: Boolean = false): String = {
|
private def fixUrl(url: String, isImage: Boolean = false): String = {
|
||||||
|
lazy val urlWithRawParam: String = url + (if(isImage && !url.endsWith("?raw=true")) "?raw=true" else "")
|
||||||
|
|
||||||
if(url.startsWith("http://") || url.startsWith("https://") || url.startsWith("/")){
|
if(url.startsWith("http://") || url.startsWith("https://") || url.startsWith("/")){
|
||||||
url
|
url
|
||||||
} else if(url.startsWith("#")){
|
} else if(url.startsWith("#")){
|
||||||
("#" + generateAnchorName(url.substring(1)))
|
("#" + generateAnchorName(url.substring(1)))
|
||||||
} else if(!enableWikiLink){
|
} else if(!enableWikiLink){
|
||||||
if(context.currentPath.contains("/blob/")){
|
if(context.currentPath.contains("/blob/")){
|
||||||
url + (if(isImage) "?raw=true" else "")
|
urlWithRawParam
|
||||||
} else if(context.currentPath.contains("/tree/")){
|
} else if(context.currentPath.contains("/tree/")){
|
||||||
val paths = context.currentPath.split("/")
|
val paths = context.currentPath.split("/")
|
||||||
val branch = if(paths.length > 3) paths.drop(4).mkString("/") else repository.repository.defaultBranch
|
val branch = if(paths.length > 3) paths.drop(4).mkString("/") else repository.repository.defaultBranch
|
||||||
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/blob/" + branch + "/" + url + (if(isImage) "?raw=true" else "")
|
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/blob/" + branch + "/" + urlWithRawParam
|
||||||
} else {
|
} else {
|
||||||
val paths = context.currentPath.split("/")
|
val paths = context.currentPath.split("/")
|
||||||
val branch = if(paths.length > 3) paths.last else repository.repository.defaultBranch
|
val branch = if(paths.length > 3) paths.last else repository.repository.defaultBranch
|
||||||
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/blob/" + branch + "/" + url + (if(isImage) "?raw=true" else "")
|
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/blob/" + branch + "/" + urlWithRawParam
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/wiki/_blob/" + url
|
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/wiki/_blob/" + url
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import java.util.{Date, Locale, TimeZone}
|
|||||||
|
|
||||||
import gitbucket.core.controller.Context
|
import gitbucket.core.controller.Context
|
||||||
import gitbucket.core.model.CommitState
|
import gitbucket.core.model.CommitState
|
||||||
import gitbucket.core.plugin.{RenderRequest, PluginRegistry}
|
import gitbucket.core.plugin.{PluginRegistry, RenderRequest}
|
||||||
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
import gitbucket.core.service.{RepositoryService, RequestCache}
|
import gitbucket.core.service.{RepositoryService, RequestCache}
|
||||||
import gitbucket.core.util.{FileUtil, JGitUtil, StringUtil}
|
import gitbucket.core.util.{FileUtil, JGitUtil, StringUtil}
|
||||||
|
|
||||||
import play.twirl.api.{Html, HtmlFormat}
|
import play.twirl.api.{Html, HtmlFormat}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,7 +151,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
|||||||
* Converts commit id, issue id and username to the link.
|
* Converts commit id, issue id and username to the link.
|
||||||
*/
|
*/
|
||||||
def link(value: String, repository: RepositoryService.RepositoryInfo)(implicit context: Context): Html =
|
def link(value: String, repository: RepositoryService.RepositoryInfo)(implicit context: Context): Html =
|
||||||
Html(convertRefsLinks(value, repository))
|
Html(decorateHtml(convertRefsLinks(value, repository), repository))
|
||||||
|
|
||||||
def cut(value: String, length: Int): String =
|
def cut(value: String, length: Int): String =
|
||||||
if(value.length > length){
|
if(value.length > length){
|
||||||
@@ -316,10 +316,18 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
|||||||
case CommitState.FAILURE => "Failed"
|
case CommitState.FAILURE => "Failed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render a given object as the JSON string.
|
||||||
|
*/
|
||||||
|
def json(obj: AnyRef): String = {
|
||||||
|
implicit val formats = org.json4s.DefaultFormats
|
||||||
|
org.json4s.jackson.Serialization.write(obj)
|
||||||
|
}
|
||||||
|
|
||||||
// This pattern comes from: http://stackoverflow.com/a/4390768/1771641 (extract-url-from-string)
|
// This pattern comes from: http://stackoverflow.com/a/4390768/1771641 (extract-url-from-string)
|
||||||
private[this] val detectAndRenderLinksRegex = """(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,13}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))""".r
|
private[this] val detectAndRenderLinksRegex = """(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,13}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))""".r
|
||||||
|
|
||||||
def detectAndRenderLinks(text: String): Html = {
|
def detectAndRenderLinks(text: String, repository: RepositoryInfo)(implicit context: Context): String = {
|
||||||
val matches = detectAndRenderLinksRegex.findAllMatchIn(text).toSeq
|
val matches = detectAndRenderLinksRegex.findAllMatchIn(text).toSeq
|
||||||
|
|
||||||
val (x, pos) = matches.foldLeft((collection.immutable.Seq.empty[Html], 0)){ case ((x, pos), m) =>
|
val (x, pos) = matches.foldLeft((collection.immutable.Seq.empty[Html], 0)){ case ((x, pos), m) =>
|
||||||
@@ -333,6 +341,43 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
|||||||
// append rest fragment
|
// append rest fragment
|
||||||
val out = if (pos < text.length) x :+ HtmlFormat.escape(text.substring(pos)) else x
|
val out = if (pos < text.length) x :+ HtmlFormat.escape(text.substring(pos)) else x
|
||||||
|
|
||||||
HtmlFormat.fill(out)
|
decorateHtml(HtmlFormat.fill(out).toString, repository)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def decorateHtml(html: String, repository: RepositoryInfo)(implicit context: Context): String = {
|
||||||
|
PluginRegistry().getTextDecorators.foldLeft(html){ case (html, decorator) =>
|
||||||
|
val text = new StringBuilder()
|
||||||
|
val result = new StringBuilder()
|
||||||
|
var tag = false
|
||||||
|
|
||||||
|
html.foreach { c =>
|
||||||
|
c match {
|
||||||
|
case '<' if tag == false => {
|
||||||
|
tag = true
|
||||||
|
if(text.nonEmpty){
|
||||||
|
result.append(decorator.decorate(text.toString, repository))
|
||||||
|
text.setLength(0)
|
||||||
|
}
|
||||||
|
result.append(c)
|
||||||
|
}
|
||||||
|
case '>' if tag == true => {
|
||||||
|
tag = false
|
||||||
|
result.append(c)
|
||||||
|
}
|
||||||
|
case _ if tag == false => {
|
||||||
|
text.append(c)
|
||||||
|
}
|
||||||
|
case _ if tag == true => {
|
||||||
|
result.append(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(text.nonEmpty){
|
||||||
|
result.append(decorator.decorate(text.toString, repository))
|
||||||
|
}
|
||||||
|
|
||||||
|
result.toString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
@(account: gitbucket.core.model.Account,
|
@(account: gitbucket.core.model.Account,
|
||||||
groupNames: List[String],
|
groupNames: List[String],
|
||||||
activities: List[gitbucket.core.model.Activity])(implicit context: gitbucket.core.controller.Context)
|
activities: List[gitbucket.core.model.Activity])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@import gitbucket.core.view.helpers
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.account.html.main(account, groupNames, "activity"){
|
||||||
@main(account, groupNames, "activity"){
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a href="@path/@{account.userName}.atom"><img src="@assets/common/images/feed.png" alt="activities"></a>
|
<a href="@context.path/@{account.userName}.atom"><img src="@{helpers.assets}/common/images/feed.png" alt="activities"></a>
|
||||||
</div>
|
</div>
|
||||||
@helper.html.activities(activities)
|
@gitbucket.core.helper.html.activities(activities)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
@(account: gitbucket.core.model.Account,
|
@(account: gitbucket.core.model.Account,
|
||||||
personalTokens: List[gitbucket.core.model.AccessToken],
|
personalTokens: List[gitbucket.core.model.AccessToken],
|
||||||
gneratedToken: Option[(gitbucket.core.model.AccessToken, String)])(implicit context: gitbucket.core.controller.Context)
|
gneratedToken: Option[(gitbucket.core.model.AccessToken, String)])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@gitbucket.core.html.main("Applications"){
|
||||||
@import gitbucket.core.view.helpers._
|
|
||||||
@html.main("Applications"){
|
|
||||||
<div class="container body">
|
<div class="container body">
|
||||||
@menu("application", settings.ssh){
|
@gitbucket.core.account.html.menu("application", context.settings.ssh){
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading strong">Personal access tokens</div>
|
<div class="panel-heading strong">Personal access tokens</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@@ -15,14 +13,14 @@
|
|||||||
Tokens you have generated that can be used to access the GitBucket API.
|
Tokens you have generated that can be used to access the GitBucket API.
|
||||||
<hr style="margin-top: 10px;">
|
<hr style="margin-top: 10px;">
|
||||||
}
|
}
|
||||||
@gneratedToken.map{ case (token, tokenString) =>
|
@gneratedToken.map { case (token, tokenString) =>
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
Make sure to copy your new personal access token now. You won't be able to see it again!
|
Make sure to copy your new personal access token now. You won't be able to see it again!
|
||||||
</div>
|
</div>
|
||||||
<a href="@path/@account.userName/_personalToken/delete/@token.accessTokenId" class="btn btn-sm btn-danger pull-right">Delete</a>
|
<a href="@context.path/@account.userName/_personalToken/delete/@token.accessTokenId" class="btn btn-sm btn-danger pull-right">Delete</a>
|
||||||
<div style="width: 50%;">
|
<div style="width: 50%;">
|
||||||
@helper.html.copy("generated-token-copy", tokenString){
|
@gitbucket.core.helper.html.copy("generated-token", "generated-token-copy", tokenString){
|
||||||
<input type="text" value="@tokenString" class="form-control input-sm" readonly>
|
<input type="text" value="@tokenString" class="form-control input-sm" id="generated-token" readonly>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<hr style="margin-top: 10px;">
|
<hr style="margin-top: 10px;">
|
||||||
@@ -32,11 +30,11 @@
|
|||||||
<hr>
|
<hr>
|
||||||
}
|
}
|
||||||
<strong style="line-height: 30px;">@token.note</strong>
|
<strong style="line-height: 30px;">@token.note</strong>
|
||||||
<a href="@path/@account.userName/_personalToken/delete/@token.accessTokenId" class="btn btn-sm btn-danger pull-right">Delete</a>
|
<a href="@context.path/@account.userName/_personalToken/delete/@token.accessTokenId" class="btn btn-sm btn-danger pull-right">Delete</a>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form method="POST" action="@path/@account.userName/_personalToken" validate="true">
|
<form method="POST" action="@context.path/@account.userName/_personalToken" validate="true">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading strong">Generate new token</div>
|
<div class="panel-heading strong">Generate new token</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
@(account: gitbucket.core.model.Account, info: Option[Any], error: Option[Any])(implicit context: gitbucket.core.controller.Context)
|
@(account: gitbucket.core.model.Account, info: Option[Any], error: Option[Any])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import gitbucket.core.util.LDAPUtil
|
@import gitbucket.core.util.LDAPUtil
|
||||||
@import context._
|
@import gitbucket.core.view.helpers
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.html.main("Edit your profile"){
|
||||||
@html.main("Edit your profile"){
|
|
||||||
<div class="container body">
|
<div class="container body">
|
||||||
@menu("profile", settings.ssh){
|
@gitbucket.core.account.html.menu("profile", context.settings.ssh){
|
||||||
@helper.html.information(info)
|
@gitbucket.core.helper.html.information(info)
|
||||||
@helper.html.error(error)
|
@gitbucket.core.helper.html.error(error)
|
||||||
@if(LDAPUtil.isDummyMailAddress(account)){<div class="alert alert-danger">Please register your mail address.</div>}
|
@if(LDAPUtil.isDummyMailAddress(account)){<div class="alert alert-danger">Please register your mail address.</div>}
|
||||||
<form action="@url(account.userName)/_edit" method="POST" validate="true">
|
<form action="@helpers.url(account.userName)/_edit" method="POST" validate="true">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading strong">Profile</div>
|
<div class="panel-heading strong">Profile</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@@ -42,7 +41,7 @@
|
|||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
<label for="avatar" class="strong">Image (optional):</label>
|
<label for="avatar" class="strong">Image (optional):</label>
|
||||||
@helper.html.uploadavatar(Some(account))
|
@gitbucket.core.helper.html.uploadavatar(Some(account))
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -50,10 +49,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a href="@path/@account.userName/_delete" class="btn btn-danger" id="delete">Delete account</a>
|
<a href="@context.path/@account.userName/_delete" class="btn btn-danger" id="delete">Delete account</a>
|
||||||
</div>
|
</div>
|
||||||
<input type="submit" class="btn btn-success" value="Save"/>
|
<input type="submit" class="btn btn-success" value="Save"/>
|
||||||
@if(!LDAPUtil.isDummyMailAddress(account)){<a href="@url(account.userName)" class="btn btn-default">Cancel</a>}
|
@if(!LDAPUtil.isDummyMailAddress(account)){<a href="@helpers.url(account.userName)" class="btn btn-default">Cancel</a>}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
@(account: Option[gitbucket.core.model.Account], members: List[gitbucket.core.model.GroupMember])(implicit context: gitbucket.core.controller.Context)
|
@(account: Option[gitbucket.core.model.Account], members: List[gitbucket.core.model.GroupMember])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@import gitbucket.core.view.helpers
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.html.main(if(account.isEmpty) "Create group" else "Edit group"){
|
||||||
@html.main(if(account.isEmpty) "Create group" else "Edit group"){
|
|
||||||
<div class="content-wrapper main-center">
|
<div class="content-wrapper main-center">
|
||||||
<div class="content body">
|
<div class="content body">
|
||||||
<h2>@{if(account.isEmpty) "Create group" else "Edit group"}</h2>
|
<h2>@{if(account.isEmpty) "Create group" else "Edit group"}</h2>
|
||||||
<form id="form" method="post" action="@if(account.isEmpty){@path/groups/new} else {@path/@account.get.userName/_editgroup}" validate="true">
|
<form id="form" method="post" action="@if(account.isEmpty){@context.path/groups/new} else {@context.path/@account.get.userName/_editgroup}" validate="true">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
@@ -24,7 +23,7 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
<label for="avatar" class="strong">Image (Optional)</label>
|
<label for="avatar" class="strong">Image (Optional)</label>
|
||||||
@helper.html.uploadavatar(account)
|
@gitbucket.core.helper.html.uploadavatar(account)
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-7">
|
<div class="col-md-7">
|
||||||
@@ -32,7 +31,7 @@
|
|||||||
<label class="strong">Members</label>
|
<label class="strong">Members</label>
|
||||||
<ul id="member-list" class="collaborator">
|
<ul id="member-list" class="collaborator">
|
||||||
</ul>
|
</ul>
|
||||||
@helper.html.account("memberName", 200)
|
@gitbucket.core.helper.html.account("memberName", 200, true, false)
|
||||||
<input type="button" class="btn btn-default" value="Add" id="addMember"/>
|
<input type="button" class="btn btn-default" value="Add" id="addMember"/>
|
||||||
<input type="hidden" id="members" name="members" value="@members.map(member => member.userName + ":" + member.isManager).mkString(",")"/>
|
<input type="hidden" id="members" name="members" value="@members.map(member => member.userName + ":" + member.isManager).mkString(",")"/>
|
||||||
<div>
|
<div>
|
||||||
@@ -44,12 +43,12 @@
|
|||||||
<fieldset class="border-top">
|
<fieldset class="border-top">
|
||||||
@if(account.isDefined){
|
@if(account.isDefined){
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a href="@url(account.get.userName)/_deletegroup" id="delete" class="btn btn-danger">Delete Group</a>
|
<a href="@helpers.url(account.get.userName)/_deletegroup" id="delete" class="btn btn-danger">Delete group</a>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<input type="submit" class="btn btn-success" value="@if(account.isEmpty){Create Group} else {Update Group}"/>
|
<input type="submit" class="btn btn-success" value="@if(account.isEmpty){Create group} else {Update group}"/>
|
||||||
@if(account.isDefined){
|
@if(account.isDefined){
|
||||||
<a href="@url(account.get.userName)" class="btn btn-default">Cancel</a>
|
<a href="@helpers.url(account.get.userName)" class="btn btn-default">Cancel</a>
|
||||||
}
|
}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
@@ -81,15 +80,14 @@ $(function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check existence
|
// check existence
|
||||||
$.post('@path/_user/existence', {
|
$.post('@context.path/_user/existence', { 'userName': userName },
|
||||||
'userName': userName
|
function(data, status){
|
||||||
}, function(data, status){
|
if(data == 'user'){
|
||||||
if(data == 'true'){
|
addMemberHTML(userName, false);
|
||||||
addMemberHTML(userName, false);
|
} else {
|
||||||
} else {
|
$('#error-members').text('User does not exist.');
|
||||||
$('#error-members').text('User does not exist.');
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.remove', function(){
|
$(document).on('click', '.remove', function(){
|
||||||
@@ -125,7 +123,7 @@ $(function(){
|
|||||||
.append(memberButton)
|
.append(memberButton)
|
||||||
.append(managerButton))
|
.append(managerButton))
|
||||||
.append(' ')
|
.append(' ')
|
||||||
.append($('<a>').attr('href', '@path/' + userName).text(userName))
|
.append($('<a>').attr('href', '@context.path/' + userName).text(userName))
|
||||||
.append(' ')
|
.append(' ')
|
||||||
.append($('<a href="#" class="remove pull-right">(remove)</a>')));
|
.append($('<a href="#" class="remove pull-right">(remove)</a>')));
|
||||||
}
|
}
|
||||||
@@ -138,4 +136,4 @@ $(function(){
|
|||||||
$('#members').val(members);
|
$('#members').val(members);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
@(account: gitbucket.core.model.Account, groupNames: List[String], active: String,
|
@(account: gitbucket.core.model.Account, groupNames: List[String], active: String,
|
||||||
isGroupManager: Boolean = false)(body: Html)(implicit context: gitbucket.core.controller.Context)
|
isGroupManager: Boolean = false)(body: Html)(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@import gitbucket.core.view.helpers
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.html.main(account.userName){
|
||||||
@html.main(account.userName){
|
|
||||||
<div class="main-sidebar">
|
<div class="main-sidebar">
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<div class="user-panel">
|
<div class="user-panel">
|
||||||
<div class="pull-left image">@avatar(account.userName, 40)</div>
|
<div class="pull-left image">@helpers.avatar(account.userName, 40)</div>
|
||||||
<div class="pull-left info">
|
<div class="pull-left info">
|
||||||
<p>@account.userName</p>
|
<p>@account.userName</p>
|
||||||
@account.fullName
|
@account.fullName
|
||||||
@@ -19,44 +18,44 @@
|
|||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
<p style="color: white;">
|
<p style="color: white;">
|
||||||
<i class="octicon octicon-clock"></i> Joined on @date(account.registeredDate)
|
<i class="octicon octicon-clock"></i> Joined on @helpers.date(account.registeredDate)
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@if(groupNames.nonEmpty){
|
@if(groupNames.nonEmpty){
|
||||||
<ul class="sidebar-menu">
|
<ul class="sidebar-menu">
|
||||||
<li class="header">Groups</li>
|
<li class="header">Groups</li>
|
||||||
@groupNames.map { groupName =>
|
@groupNames.map { groupName =>
|
||||||
<li>@avatarLink(groupName, 20, tooltip = true, label = true)</li>
|
<li>@helpers.avatarLink(groupName, 20, tooltip = true, label = true)</li>
|
||||||
}
|
}
|
||||||
</div>
|
</ul>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<div class="content body">
|
<div class="content body">
|
||||||
<ul class="nav nav-tabs" style="margin-bottom: 5px;">
|
<ul class="nav nav-tabs" style="margin-bottom: 5px;">
|
||||||
<li@if(active == "repositories"){ class="active"}><a href="@url(account.userName)?tab=repositories">Repositories</a></li>
|
<li@if(active == "repositories"){ class="active"}><a href="@helpers.url(account.userName)?tab=repositories">Repositories</a></li>
|
||||||
@if(account.isGroupAccount){
|
@if(account.isGroupAccount){
|
||||||
<li@if(active == "members"){ class="active"}><a href="@url(account.userName)?tab=members">Members</a></li>
|
<li@if(active == "members"){ class="active"}><a href="@helpers.url(account.userName)?tab=members">Members</a></li>
|
||||||
} else {
|
} else {
|
||||||
<li@if(active == "activity"){ class="active"}><a href="@url(account.userName)?tab=activity">Public Activity</a></li>
|
<li@if(active == "activity"){ class="active"}><a href="@helpers.url(account.userName)?tab=activity">Public activity</a></li>
|
||||||
}
|
}
|
||||||
@gitbucket.core.plugin.PluginRegistry().getProfileTabs.map { tab =>
|
@gitbucket.core.plugin.PluginRegistry().getProfileTabs.map { tab =>
|
||||||
@tab(account, context).map { link =>
|
@tab(account, context).map { link =>
|
||||||
<li@if(active == link.id){ class="active"}><a href="@path/@link.path">@link.label</a></li>
|
<li@if(active == link.id){ class="active"}><a href="@context.path/@link.path">@link.label</a></li>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@if(loginAccount.isDefined && loginAccount.get.userName == account.userName){
|
@if(context.loginAccount.isDefined && context.loginAccount.get.userName == account.userName){
|
||||||
<li class="pull-right">
|
<li class="pull-right">
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<a href="@url(account.userName)/_edit" class="btn btn-default">Edit Your Profile</a>
|
<a href="@helpers.url(account.userName)/_edit" class="btn btn-default">Edit your profile</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
@if(loginAccount.isDefined && account.isGroupAccount && isGroupManager){
|
@if(context.loginAccount.isDefined && account.isGroupAccount && isGroupManager){
|
||||||
<li class="pull-right">
|
<li class="pull-right">
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<a href="@url(account.userName)/_editgroup" class="btn btn-default">Edit Group</a>
|
<a href="@helpers.url(account.userName)/_editgroup" class="btn btn-default">Edit group</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
@(account: gitbucket.core.model.Account, members: List[String], isGroupManager: Boolean)(implicit context: gitbucket.core.controller.Context)
|
@(account: gitbucket.core.model.Account, members: List[gitbucket.core.model.GroupMember], isGroupManager: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@import gitbucket.core.view.helpers
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.account.html.main(account, Nil, "members", isGroupManager){
|
||||||
@main(account, Nil, "members", isGroupManager){
|
|
||||||
@if(members.isEmpty){
|
@if(members.isEmpty){
|
||||||
No members
|
No members
|
||||||
} else {
|
} else {
|
||||||
@members.map { userName =>
|
@members.map { member =>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<div class="block-header">
|
<div class="block-header">
|
||||||
@avatar(userName, 20) <a href="@url(userName)">@userName</a>
|
@helpers.avatar(member.userName, 20) <a href="@helpers.url(member.userName)">@member.userName</a>
|
||||||
|
@if(member.isManager){ (Manager) }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
@(active: String, ssh: Boolean)(body: Html)(implicit context: gitbucket.core.controller.Context)
|
@(active: String, ssh: Boolean)(body: Html)(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
|
||||||
<div class="main-sidebar">
|
<div class="main-sidebar">
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<ul class="sidebar-menu">
|
<ul class="sidebar-menu">
|
||||||
<li@if(active=="profile"){ class="active"}>
|
<li@if(active=="profile"){ class="active"}>
|
||||||
<a href="@path/@loginAccount.get.userName/_edit">Profile</a>
|
<a href="@context.path/@context.loginAccount.get.userName/_edit">Profile</a>
|
||||||
</li>
|
</li>
|
||||||
@if(ssh){
|
@if(ssh){
|
||||||
<li@if(active=="ssh"){ class="active"}>
|
<li@if(active=="ssh"){ class="active"}>
|
||||||
<a href="@path/@loginAccount.get.userName/_ssh">SSH Keys</a>
|
<a href="@context.path/@context.loginAccount.get.userName/_ssh">SSH Keys</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
<li@if(active=="application"){ class="active"}>
|
<li@if(active=="application"){ class="active"}>
|
||||||
<a href="@path/@loginAccount.get.userName/_application">Applications</a>
|
<a href="@context.path/@context.loginAccount.get.userName/_application">Applications</a>
|
||||||
</li>
|
</li>
|
||||||
@gitbucket.core.plugin.PluginRegistry().getAccountSettingMenus.map { menu =>
|
@gitbucket.core.plugin.PluginRegistry().getAccountSettingMenus.map { menu =>
|
||||||
@menu(context).map { link =>
|
@menu(context).map { link =>
|
||||||
<li@if(active==link.id){ class="active"}>
|
<li@if(active==link.id){ class="active"}>
|
||||||
<a href="@path/@link.path">@link.label</a>
|
<a href="@context.path/@link.path">@link.label</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,30 @@
|
|||||||
@(groupNames: List[String],
|
@(groupNames: List[String],
|
||||||
isCreateRepoOptionPublic: Boolean)(implicit context: gitbucket.core.controller.Context)
|
isCreateRepoOptionPublic: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@import gitbucket.core.view.helpers
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.html.main("Create a New Repository"){
|
||||||
@html.main("Create a New Repository"){
|
|
||||||
<div class="content-wrapper main-center">
|
<div class="content-wrapper main-center">
|
||||||
<div class="content body">
|
<div class="content body">
|
||||||
<h2>Create a new repository</h2>
|
<h2>Create a new repository</h2>
|
||||||
<p class="muted">
|
<p class="muted">
|
||||||
A repository contains all the files for your project, including the revision history.
|
A repository contains all the files for your project, including the revision history.
|
||||||
</p>
|
</p>
|
||||||
<form id="form" method="post" action="@path/new" validate="true">
|
<form id="form" method="post" action="@context.path/new" validate="true">
|
||||||
<fieldset class="border-top form-group">
|
<fieldset class="border-top form-group">
|
||||||
<dl style="float: left;">
|
<dl style="float: left;">
|
||||||
<dt>Owner</dt>
|
<dt>Owner</dt>
|
||||||
<dd style="margin-left: 0px;">
|
<dd style="margin-left: 0px;">
|
||||||
<div class="btn-group" id="owner-dropdown">
|
<div class="btn-group" id="owner-dropdown">
|
||||||
<button class="btn dropdown-toggle btn-default" data-toggle="dropdown">
|
<button class="btn dropdown-toggle btn-default" data-toggle="dropdown">
|
||||||
<span class="strong">@avatar(loginAccount.get.userName, 20) @loginAccount.get.userName</span>
|
<span class="strong">@helpers.avatar(context.loginAccount.get.userName, 20) @context.loginAccount.get.userName</span>
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="javascript:void(0);" data-name="@loginAccount.get.userName"><i class="octicon octicon-check"></i> <span>@avatar(loginAccount.get.userName, 20) @loginAccount.get.userName</span></a></li>
|
<li><a href="javascript:void(0);" data-name="@context.loginAccount.get.userName"><i class="octicon octicon-check"></i> <span>@helpers.avatar(context.loginAccount.get.userName, 20) @context.loginAccount.get.userName</span></a></li>
|
||||||
@groupNames.map { groupName =>
|
@groupNames.map { groupName =>
|
||||||
<li><a href="javascript:void(0);" data-name="@groupName"><i class="octicon"></i> <span>@avatar(groupName, 20) @groupName</span></a></li>
|
<li><a href="javascript:void(0);" data-name="@groupName"><i class="octicon"></i> <span>@helpers.avatar(groupName, 20) @groupName</span></a></li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
<input type="hidden" name="owner" id="owner" value="@loginAccount.get.userName"/>
|
<input type="hidden" name="owner" id="owner" value="@context.loginAccount.get.userName"/>
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
@()(implicit context: gitbucket.core.controller.Context)
|
@()(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@gitbucket.core.html.main("Create your account"){
|
||||||
@import gitbucket.core.view.helpers._
|
|
||||||
@html.main("Create your account"){
|
|
||||||
<div class="content-wrapper main-center">
|
<div class="content-wrapper main-center">
|
||||||
<div class="content body">
|
<div class="content body">
|
||||||
<h2>Create your account</h2>
|
<h2>Create your account</h2>
|
||||||
<form action="@path/register" method="POST" validate="true">
|
<form action="@context.path/register" method="POST" validate="true">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
@@ -39,7 +37,7 @@
|
|||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="avatar" class="strong">Image (optional):</label>
|
<label for="avatar" class="strong">Image (optional):</label>
|
||||||
@helper.html.uploadavatar(None)
|
@gitbucket.core.helper.html.uploadavatar(None)
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,31 +1,30 @@
|
|||||||
@(account: gitbucket.core.model.Account, groupNames: List[String],
|
@(account: gitbucket.core.model.Account, groupNames: List[String],
|
||||||
repositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo],
|
repositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo],
|
||||||
isGroupManager: Boolean)(implicit context: gitbucket.core.controller.Context)
|
isGroupManager: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@import gitbucket.core.view.helpers
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.account.html.main(account, groupNames, "repositories", isGroupManager){
|
||||||
@main(account, groupNames, "repositories", isGroupManager){
|
|
||||||
@if(repositories.isEmpty){
|
@if(repositories.isEmpty){
|
||||||
No repositories
|
No repositories
|
||||||
} else {
|
} else {
|
||||||
@repositories.map { repository =>
|
@repositories.map { repository =>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<div class="repository-icon">
|
<div class="repository-icon">
|
||||||
@helper.html.repositoryicon(repository, true)
|
@gitbucket.core.helper.html.repositoryicon(repository, true)
|
||||||
</div>
|
</div>
|
||||||
<div class="repository-content">
|
<div class="repository-content">
|
||||||
<div class="block-header">
|
<div class="block-header">
|
||||||
<a href="@url(repository)">@repository.name</a>
|
<a href="@helpers.url(repository)">@repository.name</a>
|
||||||
@if(repository.repository.isPrivate){
|
@if(repository.repository.isPrivate){
|
||||||
<i class="octicon octicon-lock"></i>
|
<i class="octicon octicon-lock"></i>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@if(repository.repository.originUserName.isDefined){
|
@if(repository.repository.originUserName.isDefined){
|
||||||
<div class="small muted">forked from <a href="@path/@repository.repository.parentUserName/@repository.repository.parentRepositoryName">@repository.repository.parentUserName/@repository.repository.parentRepositoryName</a></div>
|
<div class="small muted">forked from <a href="@context.path/@repository.repository.parentUserName/@repository.repository.parentRepositoryName">@repository.repository.parentUserName/@repository.repository.parentRepositoryName</a></div>
|
||||||
}
|
}
|
||||||
@if(repository.repository.description.isDefined){
|
@if(repository.repository.description.isDefined){
|
||||||
<div>@repository.repository.description</div>
|
<div>@repository.repository.description</div>
|
||||||
}
|
}
|
||||||
<div><span class="muted small">Updated @helper.html.datetimeago(repository.repository.lastActivityDate)</span></div>
|
<div><span class="muted small">Updated @gitbucket.core.helper.html.datetimeago(repository.repository.lastActivityDate)</span></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
@(account: gitbucket.core.model.Account, sshKeys: List[gitbucket.core.model.SshKey])(implicit context: gitbucket.core.controller.Context)
|
@(account: gitbucket.core.model.Account, sshKeys: List[gitbucket.core.model.SshKey])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import gitbucket.core.ssh.SshUtil
|
@import gitbucket.core.ssh.SshUtil
|
||||||
@import context._
|
@gitbucket.core.html.main("SSH Keys"){
|
||||||
@import gitbucket.core.view.helpers._
|
|
||||||
@html.main("SSH Keys"){
|
|
||||||
<div class="container body">
|
<div class="container body">
|
||||||
@menu("ssh", settings.ssh){
|
@gitbucket.core.account.html.menu("ssh", context.settings.ssh){
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading strong">SSH Keys</div>
|
<div class="panel-heading strong">SSH Keys</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@@ -16,11 +14,11 @@
|
|||||||
<hr>
|
<hr>
|
||||||
}
|
}
|
||||||
<strong style="line-height: 30px;">@key.title</strong> (@SshUtil.fingerPrint(key.publicKey).getOrElse("Key is invalid."))
|
<strong style="line-height: 30px;">@key.title</strong> (@SshUtil.fingerPrint(key.publicKey).getOrElse("Key is invalid."))
|
||||||
<a href="@path/@account.userName/_ssh/delete/@key.sshKeyId" class="btn btn-sm btn-danger pull-right">Delete</a>
|
<a href="@context.path/@account.userName/_ssh/delete/@key.sshKeyId" class="btn btn-sm btn-danger pull-right">Delete</a>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form method="POST" action="@path/@account.userName/_ssh" validate="true">
|
<form method="POST" action="@context.path/@account.userName/_ssh" validate="true">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading strong">Add an SSH Key</div>
|
<div class="panel-heading strong">Add an SSH Key</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
@(tableNames: Seq[String])(implicit context: gitbucket.core.controller.Context)
|
@(tableNames: Seq[String])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@gitbucket.core.html.main("Data export / import"){
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.admin.html.menu("data") {
|
||||||
@html.main("Data export / import"){
|
|
||||||
@admin.html.menu("data") {
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading strong">Export</div>
|
<div class="panel-heading strong">Export</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form class="form form-horizontal" action="@path/admin/export" method="POST">
|
<form class="form form-horizontal" action="@context.path/admin/export" method="POST">
|
||||||
@tableNames.map { tableName =>
|
@tableNames.map { tableName =>
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
@@ -15,24 +13,14 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<input type="submit" class="btn btn-success pull-right" value="Export">
|
<input type="submit" class="btn btn-success pull-right" value="Export">
|
||||||
<div class="radio pull-right" style="margin-right: 10px;">
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="type" value="sql">SQL
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="radio pull-right" style="margin-right: 10px;">
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="type" value="xml" checked>XML
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading strong">Import (only XML)</div>
|
<div class="panel-heading strong">Import</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form class="form form-horizontal" action="@path/upload/import" method="POST" enctype="multipart/form-data" id="import-form">
|
<form class="form form-horizontal" action="@context.path/upload/import" method="POST" enctype="multipart/form-data" id="import-form">
|
||||||
<input type="file" name="file" id="file">
|
<input type="file" name="file" id="file">
|
||||||
<input type="submit" class="btn btn-success pull-right" value="Import" id="import">
|
<input type="submit" class="btn btn-success pull-right" value="Import" id="import">
|
||||||
</form>
|
</form>
|
||||||
@@ -44,10 +32,10 @@
|
|||||||
$(function(){
|
$(function(){
|
||||||
$('#import-form').submit(function(){
|
$('#import-form').submit(function(){
|
||||||
if($('#file').val() == ''){
|
if($('#file').val() == ''){
|
||||||
alert('Choose an import XML file.');
|
alert('Choose an import SQL file.');
|
||||||
return false;
|
return false;
|
||||||
} else if(!$('#file').val().endsWith(".xml")){
|
} else if(!$('#file').val().endsWith(".sql")){
|
||||||
alert('Import is available for only the XML file.');
|
alert('Import is available for only the SQL file.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return confirm('All existing data is deleted before importing.\nAre you sure?');
|
return confirm('All existing data is deleted before importing.\nAre you sure?');
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
@(active: String)(body: Html)(implicit context: gitbucket.core.controller.Context)
|
@(active: String)(body: Html)(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
|
||||||
<div class="main-sidebar">
|
<div class="main-sidebar">
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<ul class="sidebar-menu" id="system-admin-menu-container">
|
<ul class="sidebar-menu" id="system-admin-menu-container">
|
||||||
<li@if(active=="users"){ class="active"}>
|
<li@if(active=="users"){ class="active"}>
|
||||||
<a href="@path/admin/users">User Management</a>
|
<a href="@context.path/admin/users">User management</a>
|
||||||
</li>
|
</li>
|
||||||
<li@if(active=="system"){ class="active"}>
|
<li@if(active=="system"){ class="active"}>
|
||||||
<a href="@path/admin/system">System Settings</a>
|
<a href="@context.path/admin/system">System settings</a>
|
||||||
</li>
|
</li>
|
||||||
<li@if(active=="plugins"){ class="active"}>
|
<li@if(active=="plugins"){ class="active"}>
|
||||||
<a href="@path/admin/plugins">Plugins</a>
|
<a href="@context.path/admin/plugins">Plugins</a>
|
||||||
</li>
|
</li>
|
||||||
<li@if(active=="data"){ class="active"}>
|
<li@if(active=="data"){ class="active"}>
|
||||||
<a href="@path/admin/data">Data export / import</a>
|
<a href="@context.path/admin/data">Data export / import</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="@path/console/login.jsp" target="_blank">H2 Console</a>
|
<a href="@context.path/console/login.jsp" target="_blank">H2 console</a>
|
||||||
</li>
|
</li>
|
||||||
@gitbucket.core.plugin.PluginRegistry().getSystemSettingMenus.map { menu =>
|
@gitbucket.core.plugin.PluginRegistry().getSystemSettingMenus.map { menu =>
|
||||||
@menu(context).map { link =>
|
@menu(context).map { link =>
|
||||||
<li@if(active==link.id){ class="active"}>
|
<li@if(active==link.id){ class="active"}>
|
||||||
<a href="@path/@link.path">@link.label</a>
|
<a href="@context.path/@link.path">@link.label</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
@(plugins: List[gitbucket.core.plugin.PluginInfo])(implicit context: gitbucket.core.controller.Context)
|
@(plugins: List[gitbucket.core.plugin.PluginInfo])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@gitbucket.core.html.main("Plugins"){
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.admin.html.menu("plugins") {
|
||||||
@html.main("Plugins"){
|
|
||||||
@admin.html.menu("plugins") {
|
|
||||||
<h1>Installed plugins</h1>
|
<h1>Installed plugins</h1>
|
||||||
|
|
||||||
@if(plugins.size > 0) {
|
@if(plugins.size > 0) {
|
||||||
<ul>
|
<ul>
|
||||||
@plugins.map {plugin =>
|
@plugins.map { plugin =>
|
||||||
<li><a href="#@plugin.pluginId">@plugin.pluginId:@plugin.version</a></li>
|
<li><a href="#@plugin.pluginId">@plugin.pluginId:@plugin.pluginVersion</a></li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@plugins.map {plugin =>
|
@plugins.map { plugin =>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading strong">@plugin.pluginName</div>
|
<div class="panel-heading strong">@plugin.pluginName</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@@ -22,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-md-2">Version</label>
|
<label class="col-md-2">Version</label>
|
||||||
<span class="col-md-10">@plugin.version</span>
|
<span class="col-md-10">@plugin.pluginVersion</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-md-2">Name</label>
|
<label class="col-md-2">Name</label>
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
@(info: Option[Any])(implicit context: gitbucket.core.controller.Context)
|
@(info: Option[Any])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@gitbucket.core.html.main("System settings"){
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.admin.html.menu("system"){
|
||||||
@import gitbucket.core.util.Directory._
|
@gitbucket.core.helper.html.information(info)
|
||||||
@html.main("System Settings"){
|
<form action="@context.path/admin/system" method="POST" validate="true" class="form-horizontal">
|
||||||
@menu("system"){
|
|
||||||
@helper.html.information(info)
|
|
||||||
<form action="@path/admin/system" method="POST" validate="true" class="form-horizontal">
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading strong">System Settings</div>
|
<div class="panel-heading strong">System settings</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<!--====================================================================-->
|
<!--====================================================================-->
|
||||||
<!-- System properties -->
|
<!-- System properties -->
|
||||||
@@ -19,7 +16,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>GITBUCKET_HOME</td>
|
<td>GITBUCKET_HOME</td>
|
||||||
<td>@GitBucketHome</td>
|
<td>@gitbucket.core.util.Directory.GitBucketHome</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>DATABASE_URL</td>
|
<td>DATABASE_URL</td>
|
||||||
@@ -33,7 +30,7 @@
|
|||||||
<label><span class="strong">Base URL</span> (e.g. <code>http://example.com/gitbucket</code>)</label>
|
<label><span class="strong">Base URL</span> (e.g. <code>http://example.com/gitbucket</code>)</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" name="baseUrl" id="baseUrl" class="form-control" value="@settings.baseUrl"/>
|
<input type="text" name="baseUrl" id="baseUrl" class="form-control" value="@context.settings.baseUrl"/>
|
||||||
<span id="error-baseUrl" class="error"></span>
|
<span id="error-baseUrl" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -48,7 +45,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<label><span class="strong">Information</span> (HTML is available)</label>
|
<label><span class="strong">Information</span> (HTML is available)</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<textarea name="information" class="form-control" style="height: 100px;">@settings.information</textarea>
|
<textarea name="information" class="form-control" style="height: 100px;">@context.settings.information</textarea>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<!--====================================================================-->
|
<!--====================================================================-->
|
||||||
<!-- Account registration -->
|
<!-- Account registration -->
|
||||||
@@ -57,11 +54,11 @@
|
|||||||
<label class="strong">Account registration</label>
|
<label class="strong">Account registration</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="allowAccountRegistration" value="true"@if(settings.allowAccountRegistration){ checked}>
|
<input type="radio" name="allowAccountRegistration" value="true"@if(context.settings.allowAccountRegistration){ checked}>
|
||||||
<span class="strong">Allow</span> <span class="normal">- Users can create accounts by themselves.</span>
|
<span class="strong">Allow</span> <span class="normal">- Users can create accounts by themselves.</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="allowAccountRegistration" value="false"@if(!settings.allowAccountRegistration){ checked}>
|
<input type="radio" name="allowAccountRegistration" value="false"@if(!context.settings.allowAccountRegistration){ checked}>
|
||||||
<span class="strong">Deny</span> - <span class="normal">Only administrators can create accounts.</span>
|
<span class="strong">Deny</span> - <span class="normal">Only administrators can create accounts.</span>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -69,11 +66,11 @@
|
|||||||
<label class="strong">Default option to create a new repository</label>
|
<label class="strong">Default option to create a new repository</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="isCreateRepoOptionPublic" value="true"@if(settings.isCreateRepoOptionPublic){ checked}>
|
<input type="radio" name="isCreateRepoOptionPublic" value="true"@if(context.settings.isCreateRepoOptionPublic){ checked}>
|
||||||
<span class="strong">Public</span> <span class="normal">- All users and guests can read that repository.</span>
|
<span class="strong">Public</span> <span class="normal">- All users and guests can read that repository.</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="isCreateRepoOptionPublic" value="false"@if(!settings.isCreateRepoOptionPublic){ checked}>
|
<input type="radio" name="isCreateRepoOptionPublic" value="false"@if(!context.settings.isCreateRepoOptionPublic){ checked}>
|
||||||
<span class="strong">Private</span> <span class="normal">- Only collaborators can read that repository.</span>
|
<span class="strong">Private</span> <span class="normal">- Only collaborators can read that repository.</span>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -84,11 +81,11 @@
|
|||||||
<label class="strong">Anonymous access</label>
|
<label class="strong">Anonymous access</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="allowAnonymousAccess" value="true"@if(settings.allowAnonymousAccess){ checked}>
|
<input type="radio" name="allowAnonymousAccess" value="true"@if(context.settings.allowAnonymousAccess){ checked}>
|
||||||
<span class="strong">Allow</span> <span class="normal">- Anyone can view public repositories, user/group profiles.</span>
|
<span class="strong">Allow</span> <span class="normal">- Anyone can view public repositories, user/group profiles.</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="allowAnonymousAccess" value="false"@if(!settings.allowAnonymousAccess){ checked}>
|
<input type="radio" name="allowAnonymousAccess" value="false"@if(!context.settings.allowAnonymousAccess){ checked}>
|
||||||
<span class="strong">Deny</span> <span class="normal">- Users must authenticate before viewing any information.</span>
|
<span class="strong">Deny</span> <span class="normal">- Users must authenticate before viewing any information.</span>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -101,7 +98,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="activityLogLimit">Limit</label>
|
<label class="control-label col-md-3" for="activityLogLimit">Limit</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="activityLogLimit" name="activityLogLimit" class="form-control input-mini" value="@settings.activityLogLimit"/>
|
<input type="text" id="activityLogLimit" name="activityLogLimit" class="form-control input-mini" value="@context.settings.activityLogLimit"/>
|
||||||
<span id="error-activityLogLimit" class="error"></span>
|
<span id="error-activityLogLimit" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -113,7 +110,7 @@
|
|||||||
<label class="strong">Services</label>
|
<label class="strong">Services</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" name="gravatar"@if(settings.gravatar){ checked}/>
|
<input type="checkbox" name="gravatar"@if(context.settings.gravatar){ checked}/>
|
||||||
Use Gravatar for Profile-Images
|
Use Gravatar for Profile-Images
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -124,7 +121,7 @@
|
|||||||
<label class="strong">SSH access</label>
|
<label class="strong">SSH access</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" id="ssh" name="ssh"@if(settings.ssh){ checked}/>
|
<input type="checkbox" id="ssh" name="ssh"@if(context.settings.ssh){ checked}/>
|
||||||
Enable SSH access to git repository
|
Enable SSH access to git repository
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -132,14 +129,14 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="sshHost">SSH Host</label>
|
<label class="control-label col-md-3" for="sshHost">SSH Host</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="sshHost" name="sshHost" class="form-control" value="@settings.sshHost"/>
|
<input type="text" id="sshHost" name="sshHost" class="form-control" value="@context.settings.sshHost"/>
|
||||||
<span id="error-sshHost" class="error"></span>
|
<span id="error-sshHost" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="sshPort">SSH Port</label>
|
<label class="control-label col-md-3" for="sshPort">SSH Port</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="sshPort" name="sshPort" class="form-control" value="@settings.sshPort"/>
|
<input type="text" id="sshPort" name="sshPort" class="form-control" value="@context.settings.sshPort"/>
|
||||||
<span id="error-sshPort" class="error"></span>
|
<span id="error-sshPort" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,7 +151,7 @@
|
|||||||
<label class="strong">Authentication</label>
|
<label class="strong">Authentication</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" id="ldapAuthentication" name="ldapAuthentication"@if(settings.ldap){ checked} />
|
<input type="checkbox" id="ldapAuthentication" name="ldapAuthentication"@if(context.settings.ldap){ checked} />
|
||||||
LDAP
|
LDAP
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -162,82 +159,82 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="ldapHost">LDAP Host</label>
|
<label class="control-label col-md-3" for="ldapHost">LDAP Host</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="ldapHost" name="ldap.host" class="form-control" value="@settings.ldap.map(_.host)"/>
|
<input type="text" id="ldapHost" name="ldap.host" class="form-control" value="@context.settings.ldap.map(_.host)"/>
|
||||||
<span id="error-ldap_host" class="error"></span>
|
<span id="error-ldap_host" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="ldapPort">LDAP Port</label>
|
<label class="control-label col-md-3" for="ldapPort">LDAP Port</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="ldapPort" name="ldap.port" class="form-control input-mini" value="@settings.ldap.map(_.port)"/>
|
<input type="text" id="ldapPort" name="ldap.port" class="form-control input-mini" value="@context.settings.ldap.map(_.port)"/>
|
||||||
<span id="error-ldap_port" class="error"></span>
|
<span id="error-ldap_port" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="ldapBindDN">Bind DN</label>
|
<label class="control-label col-md-3" for="ldapBindDN">Bind DN</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="ldapBindDN" name="ldap.bindDN" class="form-control" value="@settings.ldap.map(_.bindDN)"/>
|
<input type="text" id="ldapBindDN" name="ldap.bindDN" class="form-control" value="@context.settings.ldap.map(_.bindDN)"/>
|
||||||
<span id="error-ldap_bindDN" class="error"></span>
|
<span id="error-ldap_bindDN" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="ldapBindPassword">Bind Password</label>
|
<label class="control-label col-md-3" for="ldapBindPassword">Bind Password</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="password" id="ldapBindPassword" name="ldap.bindPassword" class="form-control" value="@settings.ldap.map(_.bindPassword)"/>
|
<input type="password" id="ldapBindPassword" name="ldap.bindPassword" class="form-control" value="@context.settings.ldap.map(_.bindPassword)"/>
|
||||||
<span id="error-ldap_bindPassword" class="error"></span>
|
<span id="error-ldap_bindPassword" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="ldapBaseDN">Base DN</label>
|
<label class="control-label col-md-3" for="ldapBaseDN">Base DN</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="ldapBaseDN" name="ldap.baseDN" class="form-control" value="@settings.ldap.map(_.baseDN)"/>
|
<input type="text" id="ldapBaseDN" name="ldap.baseDN" class="form-control" value="@context.settings.ldap.map(_.baseDN)"/>
|
||||||
<span id="error-ldap_baseDN" class="error"></span>
|
<span id="error-ldap_baseDN" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="ldapUserNameAttribute">User name attribute</label>
|
<label class="control-label col-md-3" for="ldapUserNameAttribute">User name attribute</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="ldapUserNameAttribute" name="ldap.userNameAttribute" class="form-control" value="@settings.ldap.map(_.userNameAttribute)"/>
|
<input type="text" id="ldapUserNameAttribute" name="ldap.userNameAttribute" class="form-control" value="@context.settings.ldap.map(_.userNameAttribute)"/>
|
||||||
<span id="error-ldap_userNameAttribute" class="error"></span>
|
<span id="error-ldap_userNameAttribute" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="ldapAdditionalFilterCondition">Additional filter condition</label>
|
<label class="control-label col-md-3" for="ldapAdditionalFilterCondition">Additional filter condition</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="ldapAdditionalFilterCondition" name="ldap.additionalFilterCondition" class="form-control" value="@settings.ldap.map(_.additionalFilterCondition)"/>
|
<input type="text" id="ldapAdditionalFilterCondition" name="ldap.additionalFilterCondition" class="form-control" value="@context.settings.ldap.map(_.additionalFilterCondition)"/>
|
||||||
<span id="error-ldap_additionalFilterCondition" class="error"></span>
|
<span id="error-ldap_additionalFilterCondition" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="ldapFullNameAttribute">Full name attribute</label>
|
<label class="control-label col-md-3" for="ldapFullNameAttribute">Full name attribute</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="ldapFullNameAttribute" name="ldap.fullNameAttribute" class="form-control" value="@settings.ldap.map(_.fullNameAttribute)"/>
|
<input type="text" id="ldapFullNameAttribute" name="ldap.fullNameAttribute" class="form-control" value="@context.settings.ldap.map(_.fullNameAttribute)"/>
|
||||||
<span id="error-ldap_fullNameAttribute" class="error"></span>
|
<span id="error-ldap_fullNameAttribute" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="ldapMailAttribute">Mail address attribute</label>
|
<label class="control-label col-md-3" for="ldapMailAttribute">Mail address attribute</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="ldapMailAttribute" name="ldap.mailAttribute" class="form-control" value="@settings.ldap.map(_.mailAttribute)"/>
|
<input type="text" id="ldapMailAttribute" name="ldap.mailAttribute" class="form-control" value="@context.settings.ldap.map(_.mailAttribute)"/>
|
||||||
<span id="error-ldap_mailAttribute" class="error"></span>
|
<span id="error-ldap_mailAttribute" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3">Enable TLS</label>
|
<label class="control-label col-md-3">Enable TLS</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="checkbox" name="ldap.tls"@if(settings.ldap.flatMap(_.tls).getOrElse(false)){ checked}/>
|
<input type="checkbox" name="ldap.tls"@if(context.settings.ldap.flatMap(_.tls).getOrElse(false)){ checked}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3">Enable SSL</label>
|
<label class="control-label col-md-3">Enable SSL</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="checkbox" name="ldap.ssl"@if(settings.ldap.flatMap(_.ssl).getOrElse(false)){ checked}/>
|
<input type="checkbox" name="ldap.ssl"@if(context.settings.ldap.flatMap(_.ssl).getOrElse(false)){ checked}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="ldapBindDN">Keystore</label>
|
<label class="control-label col-md-3" for="ldapBindDN">Keystore</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="ldapKeystore" name="ldap.keystore" class="form-control" value="@settings.ldap.map(_.keystore)"/>
|
<input type="text" id="ldapKeystore" name="ldap.keystore" class="form-control" value="@context.settings.ldap.map(_.keystore)"/>
|
||||||
<span id="error-ldap_keystore" class="error"></span>
|
<span id="error-ldap_keystore" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -249,7 +246,7 @@
|
|||||||
<label class="strong">Notifications</label>
|
<label class="strong">Notifications</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" id="notification" name="notification"@if(settings.notification){ checked}/>
|
<input type="checkbox" id="notification" name="notification"@if(context.settings.notification){ checked}/>
|
||||||
Send notifications
|
Send notifications
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -260,7 +257,7 @@
|
|||||||
<label class="strong">Communication</label>
|
<label class="strong">Communication</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" id="useSMTP" name="useSMTP" @if(settings.useSMTP){ checked}/>
|
<input type="checkbox" id="useSMTP" name="useSMTP" @if(context.settings.useSMTP){ checked}/>
|
||||||
SMTP
|
SMTP
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -268,45 +265,45 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="smtpHost">SMTP Host</label>
|
<label class="control-label col-md-3" for="smtpHost">SMTP Host</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="smtpHost" name="smtp.host" class="form-control" value="@settings.smtp.map(_.host)"/>
|
<input type="text" id="smtpHost" name="smtp.host" class="form-control" value="@context.settings.smtp.map(_.host)"/>
|
||||||
<span id="error-smtp_host" class="error"></span>
|
<span id="error-smtp_host" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="smtpPort">SMTP Port</label>
|
<label class="control-label col-md-3" for="smtpPort">SMTP Port</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="smtpPort" name="smtp.port" class="form-control input-mini" value="@settings.smtp.map(_.port)"/>
|
<input type="text" id="smtpPort" name="smtp.port" class="form-control input-mini" value="@context.settings.smtp.map(_.port)"/>
|
||||||
<span id="error-smtp_port" class="error"></span>
|
<span id="error-smtp_port" class="error"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="smtpUser">SMTP User</label>
|
<label class="control-label col-md-3" for="smtpUser">SMTP User</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="smtpUser" name="smtp.user" class="form-control" value="@settings.smtp.map(_.user)"/>
|
<input type="text" id="smtpUser" name="smtp.user" class="form-control" value="@context.settings.smtp.map(_.user)"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="smtpPassword">SMTP Password</label>
|
<label class="control-label col-md-3" for="smtpPassword">SMTP Password</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="password" id="smtpPassword" name="smtp.password" class="form-control" value="@settings.smtp.map(_.password)"/>
|
<input type="password" id="smtpPassword" name="smtp.password" class="form-control" value="@context.settings.smtp.map(_.password)"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="smtpPassword">Enable SSL</label>
|
<label class="control-label col-md-3" for="smtpPassword">Enable SSL</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="checkbox" id="smtpSsl" name="smtp.ssl"@if(settings.smtp.flatMap(_.ssl).getOrElse(false)){ checked}/>
|
<input type="checkbox" id="smtpSsl" name="smtp.ssl"@if(context.settings.smtp.flatMap(_.ssl).getOrElse(false)){ checked}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="fromAddress">FROM Address</label>
|
<label class="control-label col-md-3" for="fromAddress">FROM Address</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="fromAddress" name="smtp.fromAddress" class="form-control" value="@settings.smtp.map(_.fromAddress)"/>
|
<input type="text" id="fromAddress" name="smtp.fromAddress" class="form-control" value="@context.settings.smtp.map(_.fromAddress)"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-md-3" for="fromName">FROM Name</label>
|
<label class="control-label col-md-3" for="fromName">FROM Name</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" id="fromName" name="smtp.fromName" class="form-control" value="@settings.smtp.map(_.fromName)"/>
|
<input type="text" id="fromName" name="smtp.fromName" class="form-control" value="@context.settings.smtp.map(_.fromName)"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
@@ -346,7 +343,7 @@ $(function(){
|
|||||||
alert('Destination is required.');
|
alert('Destination is required.');
|
||||||
$('#testAddress').focus();
|
$('#testAddress').focus();
|
||||||
} else {
|
} else {
|
||||||
$.post('@path/admin/system/sendmail', {
|
$.post('@context.path/admin/system/sendmail', {
|
||||||
'smtp.host': host,
|
'smtp.host': host,
|
||||||
'smtp.port': port,
|
'smtp.port': port,
|
||||||
'smtp.user': user,
|
'smtp.user': user,
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
@(account: Option[gitbucket.core.model.Account], error: Option[Any] = None)(implicit context: gitbucket.core.controller.Context)
|
@(account: Option[gitbucket.core.model.Account], error: Option[Any] = None)(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@gitbucket.core.html.main(if(account.isEmpty) "New user" else "Update user"){
|
||||||
@html.main(if(account.isEmpty) "New User" else "Update User"){
|
@gitbucket.core.admin.html.menu("users"){
|
||||||
@admin.html.menu("users"){
|
@gitbucket.core.helper.html.error(error)
|
||||||
@helper.html.error(error)
|
<form method="POST" action="@if(account.isEmpty){@context.path/admin/users/_newuser} else {@context.path/admin/users/@account.get.userName/_edituser}" validate="true">
|
||||||
<form method="POST" action="@if(account.isEmpty){@path/admin/users/_newuser} else {@path/admin/users/@account.get.userName/_edituser}" validate="true">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
@@ -71,13 +70,13 @@
|
|||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
<label for="avatar" class="strong">Image (Optional)</label>
|
<label for="avatar" class="strong">Image (Optional)</label>
|
||||||
@helper.html.uploadavatar(account)
|
@gitbucket.core.helper.html.uploadavatar(account)
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<fieldset class="border-top">
|
<fieldset class="border-top">
|
||||||
<input type="submit" class="btn btn-success" value="@if(account.isEmpty){Create User} else {Update User}"/>
|
<input type="submit" class="btn btn-success" value="@if(account.isEmpty){Create user} else {Update user}"/>
|
||||||
<a href="@path/admin/users" class="btn btn-default">Cancel</a>
|
<a href="@context.path/admin/users" class="btn btn-default">Cancel</a>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
@(account: Option[gitbucket.core.model.Account], members: List[gitbucket.core.model.GroupMember])(implicit context: gitbucket.core.controller.Context)
|
@(account: Option[gitbucket.core.model.Account], members: List[gitbucket.core.model.GroupMember])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@gitbucket.core.html.main(if(account.isEmpty) "New group" else "Update group"){
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.admin.html.menu("users"){
|
||||||
@html.main(if(account.isEmpty) "New Group" else "Update Group"){
|
<form method="POST" action="@if(account.isEmpty){@context.path/admin/users/_newgroup} else {@context.path/admin/users/@account.get.userName/_editgroup}" validate="true">
|
||||||
@admin.html.menu("users"){
|
|
||||||
<form method="POST" action="@if(account.isEmpty){@path/admin/users/_newgroup} else {@path/admin/users/@account.get.userName/_editgroup}" validate="true">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
@@ -28,7 +26,7 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
<label for="avatar" class="strong">Image (Optional)</label>
|
<label for="avatar" class="strong">Image (Optional)</label>
|
||||||
@helper.html.uploadavatar(account)
|
@gitbucket.core.helper.html.uploadavatar(account)
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
@@ -36,7 +34,7 @@
|
|||||||
<label class="strong">Members</label>
|
<label class="strong">Members</label>
|
||||||
<ul id="member-list" class="collaborator">
|
<ul id="member-list" class="collaborator">
|
||||||
</ul>
|
</ul>
|
||||||
@helper.html.account("memberName", 200)
|
@gitbucket.core.helper.html.account("memberName", 200, true, false)
|
||||||
<input type="button" class="btn btn-default" value="Add" id="addMember"/>
|
<input type="button" class="btn btn-default" value="Add" id="addMember"/>
|
||||||
<input type="hidden" id="members" name="members" value="@members.map(member => member.userName + ":" + member.isManager).mkString(",")"/>
|
<input type="hidden" id="members" name="members" value="@members.map(member => member.userName + ":" + member.isManager).mkString(",")"/>
|
||||||
<div>
|
<div>
|
||||||
@@ -46,8 +44,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<fieldset class="border-top">
|
<fieldset class="border-top">
|
||||||
<input type="submit" class="btn btn-success" value="@if(account.isEmpty){Create Group} else {Update Group}"/>
|
<input type="submit" class="btn btn-success" value="@if(account.isEmpty){Create group} else {Update group}"/>
|
||||||
<a href="@path/admin/users" class="btn btn-default">Cancel</a>
|
<a href="@context.path/admin/users" class="btn btn-default">Cancel</a>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
@@ -77,16 +75,14 @@ $(function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check existence
|
// check existence
|
||||||
$.post('@path/_user/existence', {
|
$.post('@context.path/_user/existence', { 'userName': userName },
|
||||||
'userName': userName,
|
function(data, status){
|
||||||
'userOnly': true
|
if(data == 'user'){
|
||||||
}, function(data, status){
|
addMemberHTML(userName, false);
|
||||||
if(data == 'true'){
|
} else {
|
||||||
addMemberHTML(userName, false);
|
$('#error-members').text('User does not exist.');
|
||||||
} else {
|
}
|
||||||
$('#error-members').text('User does not exist.');
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.remove', function(){
|
$(document).on('click', '.remove', function(){
|
||||||
@@ -118,7 +114,7 @@ $(function(){
|
|||||||
.append(memberButton)
|
.append(memberButton)
|
||||||
.append(managerButton))
|
.append(managerButton))
|
||||||
.append(' ')
|
.append(' ')
|
||||||
.append($('<a>').attr('href', '@path/' + userName).text(userName))
|
.append($('<a>').attr('href', '@context.path/' + userName).text(userName))
|
||||||
.append(' ')
|
.append(' ')
|
||||||
.append($('<a href="#" class="remove pull-right">(remove)</a>')));
|
.append($('<a href="#" class="remove pull-right">(remove)</a>')));
|
||||||
}
|
}
|
||||||
@@ -131,4 +127,4 @@ $(function(){
|
|||||||
$('#members').val(members);
|
$('#members').val(members);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
@(users: List[gitbucket.core.model.Account], members: Map[String, List[String]], includeRemoved: Boolean)(implicit context: gitbucket.core.controller.Context)
|
@(users: List[gitbucket.core.model.Account], members: Map[String, List[String]], includeRemoved: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@import gitbucket.core.view.helpers
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.html.main("Manage Users"){
|
||||||
@html.main("Manage Users"){
|
@gitbucket.core.admin.html.menu("users"){
|
||||||
@admin.html.menu("users"){
|
|
||||||
<div class="pull-right" style="margin-bottom: 4px;">
|
<div class="pull-right" style="margin-bottom: 4px;">
|
||||||
<a href="@path/admin/users/_newuser" class="btn btn-default">New User</a>
|
<a href="@context.path/admin/users/_newuser" class="btn btn-default">New user</a>
|
||||||
<a href="@path/admin/users/_newgroup" class="btn btn-default">New Group</a>
|
<a href="@context.path/admin/users/_newgroup" class="btn btn-default">New group</a>
|
||||||
</div>
|
</div>
|
||||||
<label for="includeRemoved">
|
<label for="includeRemoved">
|
||||||
<input type="checkbox" id="includeRemoved" name="includeRemoved" @if(includeRemoved){checked}/>
|
<input type="checkbox" id="includeRemoved" name="includeRemoved" @if(includeRemoved){checked}/>
|
||||||
@@ -17,14 +16,14 @@
|
|||||||
<td @if(account.isRemoved){style="background-color: #dddddd;"}>
|
<td @if(account.isRemoved){style="background-color: #dddddd;"}>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
@if(account.isGroupAccount){
|
@if(account.isGroupAccount){
|
||||||
<a href="@path/admin/users/@account.userName/_editgroup">Edit</a>
|
<a href="@context.path/admin/users/@account.userName/_editgroup">Edit</a>
|
||||||
} else {
|
} else {
|
||||||
<a href="@path/admin/users/@account.userName/_edituser">Edit</a>
|
<a href="@context.path/admin/users/@account.userName/_edituser">Edit</a>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="strong">
|
<div class="strong">
|
||||||
@avatar(account.userName, 20)
|
@helpers.avatar(account.userName, 20)
|
||||||
<a href="@url(account.userName)">@account.userName</a>
|
<a href="@helpers.url(account.userName)">@account.userName</a>
|
||||||
@if(account.isGroupAccount){
|
@if(account.isGroupAccount){
|
||||||
(Group)
|
(Group)
|
||||||
} else {
|
} else {
|
||||||
@@ -36,7 +35,7 @@
|
|||||||
}
|
}
|
||||||
@if(account.isGroupAccount){
|
@if(account.isGroupAccount){
|
||||||
@members(account.userName).map { userName =>
|
@members(account.userName).map { userName =>
|
||||||
@avatar(userName, 20, tooltip = true)
|
@helpers.avatar(userName, 20, tooltip = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -50,10 +49,10 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span class="muted">Registered:</span> @datetime(account.registeredDate)
|
<span class="muted">Registered:</span> @helpers.datetime(account.registeredDate)
|
||||||
<span class="muted">Updated:</span> @datetime(account.updatedDate)
|
<span class="muted">Updated:</span> @helpers.datetime(account.updatedDate)
|
||||||
@if(!account.isGroupAccount){
|
@if(!account.isGroupAccount){
|
||||||
<span class="muted">Last Login:</span> @account.lastLoginDate.map(datetime)
|
<span class="muted">Last Login:</span> @account.lastLoginDate.map(helpers.datetime)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -65,7 +64,7 @@
|
|||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$('#includeRemoved').click(function(){
|
$('#includeRemoved').click(function(){
|
||||||
location.href = '@path/admin/users?includeRemoved=' + this.checked;
|
location.href = '@context.path/admin/users?includeRemoved=' + this.checked;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -2,62 +2,61 @@
|
|||||||
closedCount: Int,
|
closedCount: Int,
|
||||||
condition: gitbucket.core.service.IssuesService.IssueSearchCondition,
|
condition: gitbucket.core.service.IssuesService.IssueSearchCondition,
|
||||||
groups: List[String])(implicit context: gitbucket.core.controller.Context)
|
groups: List[String])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@import gitbucket.core.view.helpers
|
||||||
@import gitbucket.core.view.helpers._
|
|
||||||
<div id="table-issues-control">
|
<div id="table-issues-control">
|
||||||
@helper.html.dropdown("Visibility"){
|
@gitbucket.core.helper.html.dropdown("Visibility"){
|
||||||
<li>
|
<li>
|
||||||
<a href="@(condition.copy(visibility = (if(condition.visibility == Some("private")) None else Some("private"))).toURL)">
|
<a href="@(condition.copy(visibility = (if(condition.visibility == Some("private")) None else Some("private"))).toURL)">
|
||||||
@helper.html.checkicon(condition.visibility == Some("private"))
|
@gitbucket.core.helper.html.checkicon(condition.visibility == Some("private"))
|
||||||
Private repository only
|
Private repository only
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="@(condition.copy(visibility = (if(condition.visibility == Some("public")) None else Some("public"))).toURL)">
|
<a href="@(condition.copy(visibility = (if(condition.visibility == Some("public")) None else Some("public"))).toURL)">
|
||||||
@helper.html.checkicon(condition.visibility == Some("public"))
|
@gitbucket.core.helper.html.checkicon(condition.visibility == Some("public"))
|
||||||
Public repository only
|
Public repository only
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
@helper.html.dropdown("Organization"){
|
@gitbucket.core.helper.html.dropdown("Organization"){
|
||||||
@groups.map { group =>
|
@groups.map { group =>
|
||||||
<li>
|
<li>
|
||||||
<a href="@((if(condition.groups.contains(group)) condition.copy(groups = condition.groups - group) else condition.copy(groups = condition.groups + group)).toURL)">
|
<a href="@((if(condition.groups.contains(group)) condition.copy(groups = condition.groups - group) else condition.copy(groups = condition.groups + group)).toURL)">
|
||||||
@helper.html.checkicon(condition.groups.contains(group))
|
@gitbucket.core.helper.html.checkicon(condition.groups.contains(group))
|
||||||
@avatar(group, 20) @group
|
@helpers.avatar(group, 20) @group
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@helper.html.dropdown("Sort"){
|
@gitbucket.core.helper.html.dropdown("Sort"){
|
||||||
<li>
|
<li>
|
||||||
<a href="@condition.copy(sort="created", direction="desc").toURL">
|
<a href="@condition.copy(sort="created", direction="desc").toURL">
|
||||||
@helper.html.checkicon(condition.sort == "created" && condition.direction == "desc") Newest
|
@gitbucket.core.helper.html.checkicon(condition.sort == "created" && condition.direction == "desc") Newest
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="@condition.copy(sort="created", direction="asc" ).toURL">
|
<a href="@condition.copy(sort="created", direction="asc" ).toURL">
|
||||||
@helper.html.checkicon(condition.sort == "created" && condition.direction == "asc") Oldest
|
@gitbucket.core.helper.html.checkicon(condition.sort == "created" && condition.direction == "asc") Oldest
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="@condition.copy(sort="comments", direction="desc").toURL">
|
<a href="@condition.copy(sort="comments", direction="desc").toURL">
|
||||||
@helper.html.checkicon(condition.sort == "comments" && condition.direction == "desc") Most commented
|
@gitbucket.core.helper.html.checkicon(condition.sort == "comments" && condition.direction == "desc") Most commented
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="@condition.copy(sort="comments", direction="asc" ).toURL">
|
<a href="@condition.copy(sort="comments", direction="asc" ).toURL">
|
||||||
@helper.html.checkicon(condition.sort == "comments" && condition.direction == "asc") Least commented
|
@gitbucket.core.helper.html.checkicon(condition.sort == "comments" && condition.direction == "asc") Least commented
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="@condition.copy(sort="updated", direction="desc").toURL">
|
<a href="@condition.copy(sort="updated", direction="desc").toURL">
|
||||||
@helper.html.checkicon(condition.sort == "updated" && condition.direction == "desc") Recently updated
|
@gitbucket.core.helper.html.checkicon(condition.sort == "updated" && condition.direction == "desc") Recently updated
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="@condition.copy(sort="updated", direction="asc" ).toURL">
|
<a href="@condition.copy(sort="updated", direction="asc" ).toURL">
|
||||||
@helper.html.checkicon(condition.sort == "updated" && condition.direction == "asc") Least recently updated
|
@gitbucket.core.helper.html.checkicon(condition.sort == "updated" && condition.direction == "asc") Least recently updated
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,12 @@
|
|||||||
groups: List[String],
|
groups: List[String],
|
||||||
recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo],
|
recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo],
|
||||||
userRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo])(implicit context: gitbucket.core.controller.Context)
|
userRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@gitbucket.core.html.main("Issues"){
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.dashboard.html.sidebar(recentRepositories, userRepositories){
|
||||||
@html.main("Issues"){
|
@gitbucket.core.dashboard.html.tab("issues")
|
||||||
@sidebar(recentRepositories, userRepositories){
|
|
||||||
@dashboard.html.tab("issues")
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@issuesnavi(filter, openCount, closedCount, condition)
|
@gitbucket.core.dashboard.html.issuesnavi("issues", filter, openCount, closedCount, condition)
|
||||||
@issueslist(issues, page, openCount, closedCount, condition, filter, groups)
|
@gitbucket.core.dashboard.html.issueslist(issues, page, openCount, closedCount, condition, filter, groups)
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,14 @@
|
|||||||
condition: gitbucket.core.service.IssuesService.IssueSearchCondition,
|
condition: gitbucket.core.service.IssuesService.IssueSearchCondition,
|
||||||
filter: String,
|
filter: String,
|
||||||
groups: List[String])(implicit context: gitbucket.core.controller.Context)
|
groups: List[String])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@import gitbucket.core.view.helpers
|
||||||
@import gitbucket.core.view.helpers._
|
|
||||||
@import gitbucket.core.service.IssuesService
|
@import gitbucket.core.service.IssuesService
|
||||||
@import gitbucket.core.service.IssuesService.IssueInfo
|
@import gitbucket.core.service.IssuesService.IssueInfo
|
||||||
<table class="table table-bordered table-hover table-issues">
|
<table class="table table-bordered table-hover table-issues">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="background-color: #eee;">
|
<th style="background-color: #eee;">
|
||||||
@dashboard.html.header(openCount, closedCount, condition, groups)
|
@gitbucket.core.dashboard.html.header(openCount, closedCount, condition, groups)
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -21,11 +20,11 @@
|
|||||||
@issues.map { case IssueInfo(issue, labels, milestone, commentCount, commitStatus) =>
|
@issues.map { case IssueInfo(issue, labels, milestone, commentCount, commitStatus) =>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-top: 12px; padding-bottom: 12px;">
|
<td style="padding-top: 12px; padding-bottom: 12px;">
|
||||||
<a href="@path/@issue.userName/@issue.repositoryName">@issue.userName/@issue.repositoryName</a> ・
|
<a href="@context.path/@issue.userName/@issue.repositoryName">@issue.userName/@issue.repositoryName</a> ・
|
||||||
@if(issue.isPullRequest){
|
@if(issue.isPullRequest){
|
||||||
<a href="@path/@issue.userName/@issue.repositoryName/pull/@issue.issueId" class="issue-title">@issue.title</a>
|
<a href="@context.path/@issue.userName/@issue.repositoryName/pull/@issue.issueId" class="issue-title">@issue.title</a>
|
||||||
} else {
|
} else {
|
||||||
<a href="@path/@issue.userName/@issue.repositoryName/issues/@issue.issueId" class="issue-title">@issue.title</a>
|
<a href="@context.path/@issue.userName/@issue.repositoryName/issues/@issue.issueId" class="issue-title">@issue.title</a>
|
||||||
}
|
}
|
||||||
@gitbucket.core.issues.html.commitstatus(issue, commitStatus)
|
@gitbucket.core.issues.html.commitstatus(issue, commitStatus)
|
||||||
@labels.map { label =>
|
@labels.map { label =>
|
||||||
@@ -33,20 +32,20 @@
|
|||||||
}
|
}
|
||||||
<span class="pull-right muted">
|
<span class="pull-right muted">
|
||||||
@issue.assignedUserName.map { userName =>
|
@issue.assignedUserName.map { userName =>
|
||||||
@avatar(userName, 20, tooltip = true)
|
@helpers.avatar(userName, 20, tooltip = true)
|
||||||
}
|
}
|
||||||
@if(commentCount > 0){
|
@if(commentCount > 0){
|
||||||
<a href="@path/@issue.userName/@issue.repositoryName/issues/@issue.issueId" class="issue-comment-count">
|
<a href="@context.path/@issue.userName/@issue.repositoryName/issues/@issue.issueId" class="issue-comment-count">
|
||||||
<i class="octicon octicon-comment active"></i> @commentCount
|
<i class="octicon octicon-comment active"></i> @commentCount
|
||||||
</a>
|
</a>
|
||||||
} else {
|
} else {
|
||||||
<a href="@path/@issue.userName/@issue.repositoryName/issues/@issue.issueId" class="issue-comment-count" style="color: silver;">
|
<a href="@context.path/@issue.userName/@issue.repositoryName/issues/@issue.issueId" class="issue-comment-count" style="color: silver;">
|
||||||
<i class="octicon octicon-comment"></i> @commentCount
|
<i class="octicon octicon-comment"></i> @commentCount
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
<div class="small muted" style="margin-top: 2px;">
|
<div class="small muted" style="margin-top: 2px;">
|
||||||
#@issue.issueId opened by @user(issue.openedUserName, styleClass="username") @datetime(issue.registeredDate)
|
#@issue.issueId opened by @helpers.user(issue.openedUserName, styleClass="username") @helpers.datetime(issue.registeredDate)
|
||||||
@milestone.map { milestone =>
|
@milestone.map { milestone =>
|
||||||
<span style="margin: 20px;"><a href="@condition.copy(milestone = Some(Some(milestone))).toURL" class="username"><i class="octicon octicon-milestone"></i> @milestone</a></span>
|
<span style="margin: 20px;"><a href="@condition.copy(milestone = Some(Some(milestone))).toURL" class="username"><i class="octicon octicon-milestone"></i> @milestone</a></span>
|
||||||
}
|
}
|
||||||
@@ -64,5 +63,5 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
@helper.html.paginator(page, (if(condition.state == "open") openCount else closedCount), IssuesService.IssueLimit, 10, condition.toURL)
|
@gitbucket.core.helper.html.paginator(page, (if(condition.state == "open") openCount else closedCount), IssuesService.IssueLimit, 10, condition.toURL)
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
@(filter: String,
|
@(active: String,
|
||||||
|
filter: String,
|
||||||
openCount: Int,
|
openCount: Int,
|
||||||
closedCount: Int,
|
closedCount: Int,
|
||||||
condition: gitbucket.core.service.IssuesService.IssueSearchCondition)(implicit context: gitbucket.core.controller.Context)
|
condition: gitbucket.core.service.IssuesService.IssueSearchCondition)(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
|
||||||
@import gitbucket.core.view.helpers._
|
|
||||||
<ul class="nav nav-pills pull-left" style="line-height: 14px; margin-bottom: 10px;">
|
<ul class="nav nav-pills pull-left" style="line-height: 14px; margin-bottom: 10px;">
|
||||||
<li class="@(if(condition.state == "open"){"active"})">
|
<li class="@(if(condition.state == "open"){"active"})">
|
||||||
<a href="@condition.copy(state = "open").toURL">Open <span class="badge">@openCount</span></a>
|
<a href="@condition.copy(state = "open").toURL">Open <span class="badge">@openCount</span></a>
|
||||||
@@ -11,15 +10,18 @@
|
|||||||
<li class="@(if(condition.state == "closed"){"active"})">
|
<li class="@(if(condition.state == "closed"){"active"})">
|
||||||
<a href="@condition.copy(state = "closed").toURL">Closed <span class="badge">@closedCount</span></a>
|
<a href="@condition.copy(state = "closed").toURL">Closed <span class="badge">@closedCount</span></a>
|
||||||
</li>
|
</li>
|
||||||
@*
|
|
||||||
<li class="@if(filter == "created_by"){active}">
|
|
||||||
<a href="@path/dashboard/@active/created_by@condition.copy(author = None, assigned = None).toURL">Created</a>
|
|
||||||
</li>
|
|
||||||
<li class="@if(filter == "assigned"){active}">
|
|
||||||
<a href="@path/dashboard/@active/assigned@condition.copy(author = None, assigned = None).toURL">Assigned</a>
|
|
||||||
</li>
|
|
||||||
<li class="@if(filter == "mentioned"){active}">
|
|
||||||
<a href="@path/dashboard/@active/mentioned@condition.copy(author = None, assigned = None).toURL">Mentioned</a>
|
|
||||||
</li>
|
|
||||||
*@
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<div class="btn-group pull-right" data-toggle="buttons">
|
||||||
|
<a class="switch btn btn-default @if(filter == "created_by"){active}" href="@context.path/dashboard/@active/created_by@condition.copy(author = None, assigned = None).toURL">Created</a>
|
||||||
|
<a class="switch btn btn-default @if(filter == "assigned" ){active}" href="@context.path/dashboard/@active/assigned@condition.copy(author = None, assigned = None).toURL">Assigned</a>
|
||||||
|
<a class="switch btn btn-default @if(filter == "mentioned" ){active}" href="@context.path/dashboard/@active/mentioned@condition.copy(author = None, assigned = None).toURL">Mentioned</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
$('a.switch').click(function(){
|
||||||
|
location.href = $(this).attr('href');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -7,14 +7,12 @@
|
|||||||
groups: List[String],
|
groups: List[String],
|
||||||
recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo],
|
recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo],
|
||||||
userRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo])(implicit context: gitbucket.core.controller.Context)
|
userRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo])(implicit context: gitbucket.core.controller.Context)
|
||||||
@import context._
|
@gitbucket.core.html.main("Pull requests"){
|
||||||
@import gitbucket.core.view.helpers._
|
@gitbucket.core.dashboard.html.sidebar(recentRepositories, userRepositories){
|
||||||
@html.main("Pull Requests"){
|
@gitbucket.core.dashboard.html.tab("pulls")
|
||||||
@sidebar(recentRepositories, userRepositories){
|
|
||||||
@dashboard.html.tab("pulls")
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@issuesnavi(filter, openCount, closedCount, condition)
|
@gitbucket.core.dashboard.html.issuesnavi("pulls", filter, openCount, closedCount, condition)
|
||||||
@issueslist(issues, page, openCount, closedCount, condition, filter, groups)
|
@gitbucket.core.dashboard.html.issueslist(issues, page, openCount, closedCount, condition, filter, groups)
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user