mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 04:56:02 +01:00
Compare commits
221 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea498f269e | ||
|
|
98b6d16de7 | ||
|
|
4bcfe837b1 | ||
|
|
5721cbf6f4 | ||
|
|
200760cc56 | ||
|
|
28f77e7357 | ||
|
|
c0d9689022 | ||
|
|
7f436831fe | ||
|
|
96360f1266 | ||
|
|
4eb31b9ecc | ||
|
|
1e24cc4daf | ||
|
|
cf64f9e64f | ||
|
|
a538d030e9 | ||
|
|
b13e70e787 | ||
|
|
aacfb091b2 | ||
|
|
768a3b1756 | ||
|
|
925408db31 | ||
|
|
31e0c6aa1d | ||
|
|
4de80c3027 | ||
|
|
2b986609bf | ||
|
|
43b932304d | ||
|
|
fcc015a0f8 | ||
|
|
67eaf19add | ||
|
|
3008b51dbe | ||
|
|
ee65ae3e49 | ||
|
|
da64cf8800 | ||
|
|
ca0302723d | ||
|
|
026f5e2f26 | ||
|
|
ea4414f1a5 | ||
|
|
53977bdf80 | ||
|
|
952d1954d9 | ||
|
|
fbd34dc89f | ||
|
|
79d41ba57b | ||
|
|
ab1adc48f8 | ||
|
|
422eda927e | ||
|
|
39e55bde2d | ||
|
|
6ec533990f | ||
|
|
7a6a2471b1 | ||
|
|
7d9f308492 | ||
|
|
e8888ac191 | ||
|
|
afad27ee01 | ||
|
|
1ed8e287b3 | ||
|
|
202f56b6a0 | ||
|
|
e72a192e4a | ||
|
|
d3afb35fb0 | ||
|
|
306c9e45be | ||
|
|
fd8add4fcd | ||
|
|
5a510d5703 | ||
|
|
6c66fb130b | ||
|
|
7bb860dcd8 | ||
|
|
b64caa8f06 | ||
|
|
c7ece57842 | ||
|
|
161c5513df | ||
|
|
538c1d7a9a | ||
|
|
123c17d442 | ||
|
|
6b7fd7fb7b | ||
|
|
0c0fde3077 | ||
|
|
1cf6950e70 | ||
|
|
5eddeba3ef | ||
|
|
75f4903ffb | ||
|
|
9727259d0c | ||
|
|
6bb664e592 | ||
|
|
f106dea3d9 | ||
|
|
982cc15052 | ||
|
|
1ef3299574 | ||
|
|
49f0795b5f | ||
|
|
af697d8155 | ||
|
|
81a779d1d9 | ||
|
|
7c484297d7 | ||
|
|
a91e46f3e9 | ||
|
|
5f18de06f5 | ||
|
|
bef5b5f22e | ||
|
|
092e832d21 | ||
|
|
cd836f331e | ||
|
|
53537eaa09 | ||
|
|
8515ef5b26 | ||
|
|
a2524608c7 | ||
|
|
127ddcef6d | ||
|
|
076bc9e2d6 | ||
|
|
d19b2778fe | ||
|
|
4d947aef7b | ||
|
|
1f3fc62a0e | ||
|
|
8b089837f9 | ||
|
|
4c4327b569 | ||
|
|
d72e9b2692 | ||
|
|
e021868a96 | ||
|
|
0c3cf5b140 | ||
|
|
32bd52d74d | ||
|
|
55f52b7f78 | ||
|
|
4ef45d3987 | ||
|
|
ebc6121526 | ||
|
|
8a36acb673 | ||
|
|
9efe438697 | ||
|
|
4c7540451e | ||
|
|
cdeaede8bf | ||
|
|
ad73e1d529 | ||
|
|
68e858541d | ||
|
|
709e423a6d | ||
|
|
392139c061 | ||
|
|
64db3e7842 | ||
|
|
14e8071713 | ||
|
|
cea09fa766 | ||
|
|
019767e8c3 | ||
|
|
3c34689e7d | ||
|
|
d3cca0685a | ||
|
|
72049c5bdf | ||
|
|
d636413471 | ||
|
|
d1c6cbf55a | ||
|
|
e439a2f5f7 | ||
|
|
ecde6aefbf | ||
|
|
b95d912542 | ||
|
|
eb50b74b4a | ||
|
|
d460185317 | ||
|
|
2297ef0bec | ||
|
|
8d7ec16ed0 | ||
|
|
4dfc9fc456 | ||
|
|
3b99e619db | ||
|
|
9cded1b4de | ||
|
|
bfc88a489a | ||
|
|
f2a213f32a | ||
|
|
9663d21ce8 | ||
|
|
30c8d3c39c | ||
|
|
88e72bee2c | ||
|
|
c67441b6d4 | ||
|
|
e1802978d3 | ||
|
|
1ccdc79051 | ||
|
|
3ca0d35a1b | ||
|
|
7bbeceec97 | ||
|
|
1295e621ce | ||
|
|
5f4580399b | ||
|
|
8d735205aa | ||
|
|
64f15e015f | ||
|
|
a95abf7397 | ||
|
|
3054834b91 | ||
|
|
572ea5bf47 | ||
|
|
cad4d76138 | ||
|
|
892f2d5f41 | ||
|
|
1e3bd9ebc0 | ||
|
|
e93e32b349 | ||
|
|
9c9876c918 | ||
|
|
8d30d68a4a | ||
|
|
88a8552d4d | ||
|
|
7608a41f9c | ||
|
|
7f7c55aeee | ||
|
|
2ebed8ef94 | ||
|
|
2904bcf4a7 | ||
|
|
6630fa2f37 | ||
|
|
351e63e7b6 | ||
|
|
ea0f35a0a1 | ||
|
|
623c53e169 | ||
|
|
3e6fd2caf8 | ||
|
|
39f1aa4487 | ||
|
|
8ffd905a9f | ||
|
|
668f9ef919 | ||
|
|
ffb9bb10f5 | ||
|
|
2618f54442 | ||
|
|
6b3218dd43 | ||
|
|
56a9b7b0f1 | ||
|
|
4f4afc5686 | ||
|
|
1d03e83d95 | ||
|
|
5698692b26 | ||
|
|
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 | ||
|
|
64248d1fce | ||
|
|
b5ca7ca0e1 | ||
|
|
7fa921e7e5 | ||
|
|
47a55354fe | ||
|
|
c64428e37f | ||
|
|
5a94125585 | ||
|
|
34bcc85dcc | ||
|
|
2b5f74b9f3 | ||
|
|
c2538e772f | ||
|
|
f4a489f4e6 | ||
|
|
6370a72d81 | ||
|
|
e612991424 | ||
|
|
4bef6a4eeb | ||
|
|
4eba7070da | ||
|
|
161e6dc809 | ||
|
|
7937944c10 | ||
|
|
89dfaeeb93 | ||
|
|
77641185af | ||
|
|
4f78a3615c | ||
|
|
bfbf90158b | ||
|
|
825b2f9ebf | ||
|
|
82b056bd43 | ||
|
|
4c417daee5 | ||
|
|
28c47dd9c7 | ||
|
|
cd62220ba0 | ||
|
|
96e6aa89e3 |
1
.github/CONTRIBUTING.md
vendored
1
.github/CONTRIBUTING.md
vendored
@@ -4,4 +4,3 @@
|
|||||||
- If you can't find same question and report, send it to [gitter room](https://gitter.im/gitbucket/gitbucket) before raising an issue.
|
- If you can't find same question and report, send it to [gitter room](https://gitter.im/gitbucket/gitbucket) before raising an issue.
|
||||||
- We can also support in Japaneses other than English at [gitter room for Japanese](https://gitter.im/gitbucket/gitbucket_ja).
|
- We can also support in Japaneses other than English at [gitter room for Japanese](https://gitter.im/gitbucket/gitbucket_ja).
|
||||||
- Write an issue in English. At least, write subject in English.
|
- Write an issue in English. At least, write subject in English.
|
||||||
- First priority of GitBucket is easy installation and reproduce GitHub behavior, so we might reject if your request is against it.
|
|
||||||
|
|||||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -5,4 +5,4 @@
|
|||||||
- [] verified that project is compiling
|
- [] verified that project is compiling
|
||||||
- [] verified that tests are passing
|
- [] verified that tests are passing
|
||||||
- [] squashed my commits as appropriate *(keep several commits if it is relevant to understand the PR)*
|
- [] squashed my commits as appropriate *(keep several commits if it is relevant to understand the PR)*
|
||||||
- [] [marked as closed](https://help.github.com/articles/closing-issues-via-commit-messages/) all issue ID that this PR should correct
|
- [] [marked as closed using commit message](https://help.github.com/articles/closing-issues-via-commit-messages/) all issue ID that this PR should correct
|
||||||
|
|||||||
@@ -8,4 +8,11 @@ before_script:
|
|||||||
- sudo apt-get install libaio1
|
- sudo apt-get install libaio1
|
||||||
- sudo /etc/init.d/mysql stop
|
- sudo /etc/init.d/mysql stop
|
||||||
- sudo /etc/init.d/postgresql stop
|
- sudo /etc/init.d/postgresql stop
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.ivy2/cache
|
||||||
|
- $HOME/.sbt/boot
|
||||||
|
- $HOME/.sbt/launchers
|
||||||
|
- $HOME/.coursier
|
||||||
|
- $HOME/.embedmysql
|
||||||
|
- $HOME/.embedpostgresql
|
||||||
|
|||||||
88
README.md
88
README.md
@@ -2,69 +2,89 @@ GitBucket [](htt
|
|||||||
=========
|
=========
|
||||||
|
|
||||||
GitBucket is a Git platform powered by Scala offering:
|
GitBucket is a Git platform powered by Scala offering:
|
||||||
- easy installation
|
- Easy installation
|
||||||
- high extensibility by plugins
|
- High extensibility by plugins
|
||||||
- API compatibility with Github
|
- API compatibility with GitHub
|
||||||
|
|
||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
The current version of GitBucket provides a basic features below:
|
The current version of GitBucket provides a basic features below:
|
||||||
|
|
||||||
- Public / Private Git repository (http and ssh access)
|
- Public / Private Git repository (http and ssh access)
|
||||||
- Repository viewer and online file editing
|
- GitLFS support
|
||||||
- Wiki
|
- Repository viewer includes online file editor
|
||||||
- Issues / Pull request
|
- Issues, Pull request and Wiki for repositories
|
||||||
- Email notification
|
- Activity timeline and email notification
|
||||||
- Simple user and group management with LDAP integration
|
- Account and group management with LDAP integration
|
||||||
- Plug-in system
|
- Plug-in system
|
||||||
|
|
||||||
If you want to try the development version of GitBucket, see [Developer's Guide](https://github.com/gitbucket/gitbucket/blob/master/doc/how_to_run.md).
|
If you want to try the development version of GitBucket, see the [Developer's Guide](https://github.com/gitbucket/gitbucket/blob/master/doc/how_to_run.md).
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
--------
|
--------
|
||||||
GitBucket requires **Java8**. You have to install beforehand when it's not installed.
|
GitBucket requires **Java8**. You have to install it if it is not already installed.
|
||||||
|
|
||||||
1. Download latest **gitbucket.war** from [the release page](https://github.com/gitbucket/gitbucket/releases).
|
1. Download the latest **gitbucket.war** from [the releases page](https://github.com/gitbucket/gitbucket/releases) and run it by `java -jar gitbucket.war`.
|
||||||
2. Deploy it to the Servlet 3.0 container such as Tomcat 7.x, Jetty 8.x, GlassFish 3.x or higher.
|
2. Go to `http://[hostname]:8080/` and log in with **root** / **root**.
|
||||||
3. Access **http://[hostname]:[port]/gitbucket/** using your web browser and logged-in with **root** / **root**.
|
|
||||||
|
|
||||||
or you can start GitBucket by `java -jar gitbucket.war` without servlet container. In this case, GitBucket URL is **http://[hostname]:8080/**. You can specify following options.
|
You can specify following options:
|
||||||
|
|
||||||
- --port=[NUMBER]
|
- `--port=[NUMBER]`
|
||||||
- --prefix=[CONTEXTPATH]
|
- `--prefix=[CONTEXTPATH]`
|
||||||
- --host=[HOSTNAME]
|
- `--host=[HOSTNAME]`
|
||||||
- --gitbucket.home=[DATA_DIR]
|
- `--gitbucket.home=[DATA_DIR]`
|
||||||
|
- `--temp_dir=[TEMP_DIR]`
|
||||||
|
|
||||||
To upgrade GitBucket, only replace gitbucket.war after stop GitBucket. All GitBucket data is stored in HOME/.gitbucket. So if you want to back up GitBucket data, copy this directory to the other disk.
|
`TEMP_DIR` is used as the [temporary directory for the jetty application context](https://www.eclipse.org/jetty/documentation/9.3.x/ref-temporary-directories.html). This is the directory into which the `gitbucket.war` file is unpacked, the source files are compiled, etc. If given this parameter **must** match the path of an existing directory or the application will quit reporting an error; if not given the path used will be a `tmp` directory inside the gitbucket home.
|
||||||
|
|
||||||
About installation on Mac or Windows Server (with IIS), configuration of Apache or Nginx and also integration with other tools or services such as Jenkins or Slack, see [Wiki](https://github.com/gitbucket/gitbucket/wiki).
|
You can also deploy `gitbucket.war` to a servlet container which supports Servlet 3.0 (like Jetty, Tomcat, JBoss, etc)
|
||||||
|
|
||||||
Plug-ins
|
For more information about installation on Mac or Windows Server (with IIS), or configuration of Apache or Nginx and also integration with other tools or services such as Jenkins or Slack, see [Wiki](https://github.com/gitbucket/gitbucket/wiki).
|
||||||
|
|
||||||
|
To upgrade GitBucket, replace `gitbucket.war` with the new version, after stopping GitBucket. All GitBucket data is stored in `HOME/.gitbucket` by default. So if you want to back up GitBucket's data, copy this directory to the backup location.
|
||||||
|
|
||||||
|
Plugins
|
||||||
--------
|
--------
|
||||||
GitBucket has the plug-in system to extend GitBucket from outside of GitBucket. Some plug-ins are available now:
|
GitBucket has a plug-in system to allow extensions to GitBucket. We provide some official plug-ins:
|
||||||
|
|
||||||
- [gitbucket-gist-plugin](https://github.com/gitbucket/gitbucket-gist-plugin)
|
- [gitbucket-gist-plugin](https://github.com/gitbucket/gitbucket-gist-plugin)
|
||||||
- [gitbucket-announce-plugin](https://github.com/gitbucket-plugins/gitbucket-announce-plugin)
|
|
||||||
- [gitbucket-h2-backup-plugin](https://github.com/gitbucket-plugins/gitbucket-h2-backup-plugin)
|
|
||||||
- [gitbucket-desktopnotify-plugin](https://github.com/yoshiyoshifujii/gitbucket-desktopnotify-plugin)
|
|
||||||
- [gitbucket-commitgraphs-plugin](https://github.com/yoshiyoshifujii/gitbucket-commitgraphs-plugin)
|
|
||||||
- [gitbucket-asciidoctor-plugin](https://github.com/lefou/gitbucket-asciidoctor-plugin)
|
|
||||||
- [gitbucket-network-plugin](https://github.com/mrkm4ntr/gitbucket-network-plugin)
|
|
||||||
- [gitbucket-emoji-plugin](https://github.com/gitbucket/gitbucket-emoji-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 more plugins made by the community at [GitBucket community plugins](http://gitbucket-plugins.github.io/).
|
||||||
|
|
||||||
Support
|
Support
|
||||||
--------
|
--------
|
||||||
|
|
||||||
- If you have any question about GitBucket, send it to [gitter room](https://gitter.im/gitbucket/gitbucket) before raise an issue.
|
- If you have any questions about GitBucket, send it to the [gitter room](https://gitter.im/gitbucket/gitbucket) before opening an issue.
|
||||||
- Make sure check whether there is a same question or request in the past.
|
- Make sure check whether there is the same question or request in the past.
|
||||||
- When raise a new issue, write subject in **English** at least.
|
- When raise a new issue, write at least the subject in **English**.
|
||||||
- We can also support in Japaneses other than English at [gitter room for Japanese](https://gitter.im/gitbucket/gitbucket_ja).
|
- We can also provide support in Japanese at [gitter room for Japanese](https://gitter.im/gitbucket/gitbucket_ja).
|
||||||
- First priority of GitBucket is easy installation and API compatibility with GitHub, so we might reject if your request is against it.
|
- The first priority of GitBucket is easy installation and API compatibility with GitHub, so we might reject if your request is against it.
|
||||||
|
|
||||||
Release Notes
|
Release Notes
|
||||||
-------------
|
-------------
|
||||||
|
### 4.10 - 25 Feb 2017
|
||||||
|
- Update to Scala 2.12 and Scalatra 2.5
|
||||||
|
- Display file size in the file viewer
|
||||||
|
|
||||||
|
### 4.9 - 29 Jan 2017
|
||||||
|
- GitLFS support
|
||||||
|
- Template for issues and pull requests
|
||||||
|
- Manual label color editing
|
||||||
|
- Account description
|
||||||
|
- `--tmp-dir` option for standalone mode
|
||||||
|
- More APIs for issues
|
||||||
|
- [List issues for a repository](https://developer.github.com/v3/issues/#list-issues-for-a-repository)
|
||||||
|
- [Create an issue](https://developer.github.com/v3/issues/#create-an-issue)
|
||||||
|
|
||||||
|
### 4.8 - 23 Dec 2016
|
||||||
|
- Search for repository names from the global header
|
||||||
|
- Filter repositories on the sidebar of the dashboard
|
||||||
|
- Search issues and wiki
|
||||||
|
- Keep pull request comments after new commits are pushed
|
||||||
|
- New web API to get a single issue
|
||||||
|
- Performance improvement for the repository viewer
|
||||||
|
|
||||||
### 4.7.1 - 28 Nov 2016
|
### 4.7.1 - 28 Nov 2016
|
||||||
- Bug fix: group repositories are not shown in the your repositories list on the sidebar
|
- Bug fix: group repositories are not shown in the your repositories list on the sidebar
|
||||||
- Small performance improvement of the dashboard
|
- Small performance improvement of the dashboard
|
||||||
|
|||||||
34
build.sbt
34
build.sbt
@@ -1,7 +1,7 @@
|
|||||||
val Organization = "io.github.gitbucket"
|
val Organization = "io.github.gitbucket"
|
||||||
val Name = "gitbucket"
|
val Name = "gitbucket"
|
||||||
val GitBucketVersion = "4.7.1"
|
val GitBucketVersion = "4.10.0"
|
||||||
val ScalatraVersion = "2.4.1"
|
val ScalatraVersion = "2.5.0"
|
||||||
val JettyVersion = "9.3.9.v20160517"
|
val JettyVersion = "9.3.9.v20160517"
|
||||||
|
|
||||||
lazy val root = (project in file(".")).enablePlugins(SbtTwirl, JettyPlugin)
|
lazy val root = (project in file(".")).enablePlugins(SbtTwirl, JettyPlugin)
|
||||||
@@ -10,23 +10,23 @@ sourcesInBase := false
|
|||||||
organization := Organization
|
organization := Organization
|
||||||
name := Name
|
name := Name
|
||||||
version := GitBucketVersion
|
version := GitBucketVersion
|
||||||
scalaVersion := "2.11.8"
|
scalaVersion := "2.12.1"
|
||||||
|
|
||||||
// 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/"
|
||||||
)
|
)
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"org.scala-lang.modules" %% "scala-java8-compat" % "0.7.0",
|
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % "4.6.0.201612231935-r",
|
||||||
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % "4.1.2.201602141800-r",
|
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % "4.6.0.201612231935-r",
|
||||||
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % "4.1.2.201602141800-r",
|
|
||||||
"org.scalatra" %% "scalatra" % ScalatraVersion,
|
"org.scalatra" %% "scalatra" % ScalatraVersion,
|
||||||
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
|
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
|
||||||
"org.json4s" %% "json4s-jackson" % "3.3.0",
|
"org.json4s" %% "json4s-jackson" % "3.5.0",
|
||||||
"io.github.gitbucket" %% "scalatra-forms" % "1.0.0",
|
"io.github.gitbucket" %% "scalatra-forms" % "1.1.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",
|
"io.github.gitbucket" % "markedj" % "1.0.9",
|
||||||
@@ -35,7 +35,8 @@ libraryDependencies ++= Seq(
|
|||||||
"org.apache.httpcomponents" % "httpclient" % "4.5.1",
|
"org.apache.httpcomponents" % "httpclient" % "4.5.1",
|
||||||
"org.apache.sshd" % "apache-sshd" % "1.2.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.github.takezoe" %% "blocking-slick-32" % "0.0.7",
|
||||||
|
"joda-time" % "joda-time" % "2.9.6",
|
||||||
"com.novell.ldap" % "jldap" % "2009-10-07",
|
"com.novell.ldap" % "jldap" % "2009-10-07",
|
||||||
"com.h2database" % "h2" % "1.4.192",
|
"com.h2database" % "h2" % "1.4.192",
|
||||||
"mysql" % "mysql-connector-java" % "5.1.39",
|
"mysql" % "mysql-connector-java" % "5.1.39",
|
||||||
@@ -43,19 +44,22 @@ libraryDependencies ++= Seq(
|
|||||||
"ch.qos.logback" % "logback-classic" % "1.1.7",
|
"ch.qos.logback" % "logback-classic" % "1.1.7",
|
||||||
"com.zaxxer" % "HikariCP" % "2.4.6",
|
"com.zaxxer" % "HikariCP" % "2.4.6",
|
||||||
"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.4.12",
|
||||||
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.0.0",
|
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.0.0",
|
||||||
"com.enragedginger" %% "akka-quartz-scheduler" % "1.4.0-akka-2.3.x" exclude("c3p0","c3p0"),
|
"com.github.bkromhout" % "java-diff-utils" % "2.1.1",
|
||||||
|
"org.cache2k" % "cache2k-all" % "1.0.0.CR1",
|
||||||
|
"com.enragedginger" %% "akka-quartz-scheduler" % "1.6.0-akka-2.4.x" exclude("c3p0","c3p0"),
|
||||||
|
"net.coobird" % "thumbnailator" % "0.4.8",
|
||||||
"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",
|
||||||
"com.wix" % "wix-embedded-mysql" % "1.0.3" % "test",
|
"com.wix" % "wix-embedded-mysql" % "2.1.4" % "test",
|
||||||
"ru.yandex.qatools.embed" % "postgresql-embedded" % "1.14" % "test"
|
"ru.yandex.qatools.embed" % "postgresql-embedded" % "1.14" % "test"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Compiler settings
|
// Compiler settings
|
||||||
scalacOptions := Seq("-deprecation", "-language:postfixOps", "-Ybackend:GenBCode", "-Ydelambdafy:method", "-target:jvm-1.8")
|
scalacOptions := Seq("-deprecation", "-language:postfixOps", "-Ydelambdafy:method", "-target:jvm-1.8")
|
||||||
javacOptions in compile ++= Seq("-target", "8", "-source", "8")
|
javacOptions in compile ++= Seq("-target", "8", "-source", "8")
|
||||||
javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml"
|
javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml"
|
||||||
|
|
||||||
@@ -162,9 +166,9 @@ executableKey := {
|
|||||||
log info s"built executable webapp ${outputFile}"
|
log info s"built executable webapp ${outputFile}"
|
||||||
outputFile
|
outputFile
|
||||||
}
|
}
|
||||||
publishTo <<= version { (v: String) =>
|
publishTo := {
|
||||||
val nexus = "https://oss.sonatype.org/"
|
val nexus = "https://oss.sonatype.org/"
|
||||||
if (v.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
|
if (version.value.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
|
||||||
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
|
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
|
||||||
}
|
}
|
||||||
publishMavenStyle := true
|
publishMavenStyle := true
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
RPM spec file and init script for Red Hat Enterprise Linux 6.x.
|
RPM spec file and init script for Red Hat Enterprise Linux 6.x.
|
||||||
|
|
||||||
To create RPM:
|
To create RPM:
|
||||||
|
|
||||||
1. Edit `../../gitbucket.conf` to suit.
|
1. Edit `../../gitbucket.conf` to suit.
|
||||||
2. Edit `gitbucket.init` to suit.
|
2. Edit `gitbucket.init` to suit.
|
||||||
3. Edit `gitbucket.spec` to suit.
|
3. Edit `gitbucket.spec` to suit.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
sbt.version=0.13.12
|
sbt.version=0.13.13
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
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.3.0")
|
||||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
|
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
|
||||||
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "2.1.0")
|
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "2.1.1")
|
||||||
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")
|
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")
|
||||||
|
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15")
|
||||||
|
|||||||
1
project/project/plugins.sbt
Normal file
1
project/project/plugins.sbt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15")
|
||||||
@@ -12,6 +12,7 @@ public class JettyLauncher {
|
|||||||
int port = 8080;
|
int port = 8080;
|
||||||
InetSocketAddress address = null;
|
InetSocketAddress address = null;
|
||||||
String contextPath = "/";
|
String contextPath = "/";
|
||||||
|
String tmpDirPath="";
|
||||||
boolean forceHttps = false;
|
boolean forceHttps = false;
|
||||||
|
|
||||||
for(String arg: args) {
|
for(String arg: args) {
|
||||||
@@ -24,8 +25,13 @@ public class JettyLauncher {
|
|||||||
port = Integer.parseInt(dim[1]);
|
port = Integer.parseInt(dim[1]);
|
||||||
} else if(dim[0].equals("--prefix")) {
|
} else if(dim[0].equals("--prefix")) {
|
||||||
contextPath = dim[1];
|
contextPath = dim[1];
|
||||||
|
if(!contextPath.startsWith("/")){
|
||||||
|
contextPath = "/" + contextPath;
|
||||||
|
}
|
||||||
} else if(dim[0].equals("--gitbucket.home")){
|
} else if(dim[0].equals("--gitbucket.home")){
|
||||||
System.setProperty("gitbucket.home", dim[1]);
|
System.setProperty("gitbucket.home", dim[1]);
|
||||||
|
} else if(dim[0].equals("--temp_dir")){
|
||||||
|
tmpDirPath = dim[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,10 +56,22 @@ public class JettyLauncher {
|
|||||||
|
|
||||||
WebAppContext context = new WebAppContext();
|
WebAppContext context = new WebAppContext();
|
||||||
|
|
||||||
File tmpDir = new File(getGitBucketHome(), "tmp");
|
File tmpDir;
|
||||||
|
if(tmpDirPath.equals("")){
|
||||||
|
tmpDir = new File(getGitBucketHome(), "tmp");
|
||||||
if(!tmpDir.exists()){
|
if(!tmpDir.exists()){
|
||||||
tmpDir.mkdirs();
|
tmpDir.mkdirs();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tmpDir = new File(tmpDirPath);
|
||||||
|
if(!tmpDir.exists()){
|
||||||
|
throw new java.io.FileNotFoundException(
|
||||||
|
String.format("temp_dir \"%s\" not found", tmpDirPath));
|
||||||
|
} else if(!tmpDir.isDirectory()) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("temp_dir \"%s\" is not a directory", tmpDirPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
context.setTempDirectory(tmpDir);
|
context.setTempDirectory(tmpDir);
|
||||||
|
|
||||||
ProtectionDomain domain = JettyLauncher.class.getProtectionDomain();
|
ProtectionDomain domain = JettyLauncher.class.getProtectionDomain();
|
||||||
|
|||||||
6
src/main/resources/update/gitbucket-core_4.9.xml
Normal file
6
src/main/resources/update/gitbucket-core_4.9.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="ACCOUNT">
|
||||||
|
<column name="DESCRIPTION" type="text" nullable="true" />
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
@@ -23,5 +23,10 @@ object GitBucketCoreModule extends Module("gitbucket-core",
|
|||||||
new LiquibaseMigration("update/gitbucket-core_4.7.xml"),
|
new LiquibaseMigration("update/gitbucket-core_4.7.xml"),
|
||||||
new SqlMigration("update/gitbucket-core_4.7.sql")
|
new SqlMigration("update/gitbucket-core_4.7.sql")
|
||||||
),
|
),
|
||||||
new Version("4.7.1")
|
new Version("4.7.1"),
|
||||||
|
new Version("4.8"),
|
||||||
|
new Version("4.9.0",
|
||||||
|
new LiquibaseMigration("update/gitbucket-core_4.9.xml")
|
||||||
|
),
|
||||||
|
new Version("4.10.0")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
11
src/main/scala/gitbucket/core/api/CreateAnIssue.scala
Normal file
11
src/main/scala/gitbucket/core/api/CreateAnIssue.scala
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package gitbucket.core.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/#create-an-issue
|
||||||
|
*/
|
||||||
|
case class CreateAnIssue(
|
||||||
|
title: String,
|
||||||
|
body: Option[String],
|
||||||
|
assignees: List[String],
|
||||||
|
milestone: Option[Int],
|
||||||
|
labels: List[String])
|
||||||
@@ -29,10 +29,10 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
with AccessTokenService with WebHookService with RepositoryCreationService =>
|
with AccessTokenService with WebHookService with RepositoryCreationService =>
|
||||||
|
|
||||||
case class AccountNewForm(userName: String, password: String, fullName: String, mailAddress: String,
|
case class AccountNewForm(userName: String, password: String, fullName: String, mailAddress: String,
|
||||||
url: Option[String], fileId: Option[String])
|
description: Option[String], url: Option[String], fileId: Option[String])
|
||||||
|
|
||||||
case class AccountEditForm(password: Option[String], fullName: String, mailAddress: String,
|
case class AccountEditForm(password: Option[String], fullName: String, mailAddress: String,
|
||||||
url: Option[String], fileId: Option[String], clearImage: Boolean)
|
description: Option[String], url: Option[String], fileId: Option[String], clearImage: Boolean)
|
||||||
|
|
||||||
case class SshKeyForm(title: String, publicKey: String)
|
case class SshKeyForm(title: String, publicKey: String)
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
||||||
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress()))),
|
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress()))),
|
||||||
|
"description" -> trim(label("bio" , optional(text()))),
|
||||||
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" , optional(text())))
|
"fileId" -> trim(label("File ID" , optional(text())))
|
||||||
)(AccountNewForm.apply)
|
)(AccountNewForm.apply)
|
||||||
@@ -51,6 +52,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"password" -> trim(label("Password" , optional(text(maxlength(20))))),
|
"password" -> trim(label("Password" , optional(text(maxlength(20))))),
|
||||||
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress("userName")))),
|
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress("userName")))),
|
||||||
|
"description" -> trim(label("bio" , optional(text()))),
|
||||||
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" , optional(text()))),
|
"fileId" -> trim(label("File ID" , optional(text()))),
|
||||||
"clearImage" -> trim(label("Clear image" , boolean()))
|
"clearImage" -> trim(label("Clear image" , boolean()))
|
||||||
@@ -65,11 +67,12 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"note" -> trim(label("Token", text(required, maxlength(100))))
|
"note" -> trim(label("Token", text(required, maxlength(100))))
|
||||||
)(PersonalTokenForm.apply)
|
)(PersonalTokenForm.apply)
|
||||||
|
|
||||||
case class NewGroupForm(groupName: String, url: Option[String], fileId: Option[String], members: String)
|
case class NewGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String], members: String)
|
||||||
case class EditGroupForm(groupName: String, url: Option[String], fileId: Option[String], members: String, clearImage: Boolean)
|
case class EditGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String], members: String, clearImage: Boolean)
|
||||||
|
|
||||||
val newGroupForm = mapping(
|
val newGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
|
"description" -> trim(label("Group description", optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members)))
|
"members" -> trim(label("Members" ,text(required, members)))
|
||||||
@@ -77,6 +80,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
val editGroupForm = mapping(
|
val editGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
||||||
|
"description" -> trim(label("Group description", optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members))),
|
"members" -> trim(label("Members" ,text(required, members))),
|
||||||
@@ -167,6 +171,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
password = form.password.map(sha1).getOrElse(account.password),
|
password = form.password.map(sha1).getOrElse(account.password),
|
||||||
fullName = form.fullName,
|
fullName = form.fullName,
|
||||||
mailAddress = form.mailAddress,
|
mailAddress = form.mailAddress,
|
||||||
|
description = form.description,
|
||||||
url = form.url))
|
url = form.url))
|
||||||
|
|
||||||
updateImage(userName, form.fileId, form.clearImage)
|
updateImage(userName, form.fileId, form.clearImage)
|
||||||
@@ -266,7 +271,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
post("/register", newForm){ form =>
|
post("/register", newForm){ form =>
|
||||||
if(context.settings.allowAccountRegistration){
|
if(context.settings.allowAccountRegistration){
|
||||||
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.url)
|
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.description, form.url)
|
||||||
updateImage(form.userName, form.fileId, false)
|
updateImage(form.userName, form.fileId, false)
|
||||||
redirect("/signin")
|
redirect("/signin")
|
||||||
} else NotFound()
|
} else NotFound()
|
||||||
@@ -277,7 +282,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/groups/new", newGroupForm)(usersOnly { form =>
|
post("/groups/new", newGroupForm)(usersOnly { form =>
|
||||||
createGroup(form.groupName, form.url)
|
createGroup(form.groupName, form.description, form.url)
|
||||||
updateGroupMembers(form.groupName, form.members.split(",").map {
|
updateGroupMembers(form.groupName, form.members.split(",").map {
|
||||||
_.split(":") match {
|
_.split(":") match {
|
||||||
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
||||||
@@ -315,7 +320,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
}.toList){ case (groupName, members) =>
|
}.toList){ case (groupName, members) =>
|
||||||
getAccountByUserName(groupName, true).map { account =>
|
getAccountByUserName(groupName, true).map { account =>
|
||||||
updateGroup(groupName, form.url, false)
|
updateGroup(groupName, form.description, form.url, false)
|
||||||
|
|
||||||
// Update GROUP_MEMBER
|
// Update GROUP_MEMBER
|
||||||
updateGroupMembers(form.groupName, members)
|
updateGroupMembers(form.groupName, members)
|
||||||
|
|||||||
@@ -21,9 +21,12 @@ class ApiController extends ApiControllerBase
|
|||||||
with ProtectedBranchService
|
with ProtectedBranchService
|
||||||
with IssuesService
|
with IssuesService
|
||||||
with LabelsService
|
with LabelsService
|
||||||
|
with MilestonesService
|
||||||
with PullRequestService
|
with PullRequestService
|
||||||
|
with CommitsService
|
||||||
with CommitStatusService
|
with CommitStatusService
|
||||||
with RepositoryCreationService
|
with RepositoryCreationService
|
||||||
|
with IssueCreationService
|
||||||
with HandleCommentService
|
with HandleCommentService
|
||||||
with WebHookService
|
with WebHookService
|
||||||
with WebHookPullRequestService
|
with WebHookPullRequestService
|
||||||
@@ -43,9 +46,11 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
with ProtectedBranchService
|
with ProtectedBranchService
|
||||||
with IssuesService
|
with IssuesService
|
||||||
with LabelsService
|
with LabelsService
|
||||||
|
with MilestonesService
|
||||||
with PullRequestService
|
with PullRequestService
|
||||||
with CommitStatusService
|
with CommitStatusService
|
||||||
with RepositoryCreationService
|
with RepositoryCreationService
|
||||||
|
with IssueCreationService
|
||||||
with HandleCommentService
|
with HandleCommentService
|
||||||
with OwnerAuthenticator
|
with OwnerAuthenticator
|
||||||
with UsersAuthenticator
|
with UsersAuthenticator
|
||||||
@@ -54,6 +59,13 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
with ReadableUsersAuthenticator
|
with ReadableUsersAuthenticator
|
||||||
with WritableUsersAuthenticator =>
|
with WritableUsersAuthenticator =>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 404 for non-implemented api
|
||||||
|
*/
|
||||||
|
get("/api/v3/*") {
|
||||||
|
NotFound()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://developer.github.com/v3/#root-endpoint
|
* https://developer.github.com/v3/#root-endpoint
|
||||||
*/
|
*/
|
||||||
@@ -132,9 +144,12 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
val largeFile = params.get("large_file").exists(s => s.equals("true"))
|
val largeFile = params.get("large_file").exists(s => s.equals("true"))
|
||||||
val content = getContentFromId(git, f.id, largeFile)
|
val content = getContentFromId(git, f.id, largeFile)
|
||||||
request.getHeader("Accept") match {
|
request.getHeader("Accept") match {
|
||||||
case "application/vnd.github.v3.raw" =>
|
case "application/vnd.github.v3.raw" => {
|
||||||
|
contentType = "application/vnd.github.v3.raw"
|
||||||
content
|
content
|
||||||
case "application/vnd.github.v3.html" if isRenderable(f.name) =>
|
}
|
||||||
|
case "application/vnd.github.v3.html" if isRenderable(f.name) => {
|
||||||
|
contentType = "application/vnd.github.v3.html"
|
||||||
content.map(c =>
|
content.map(c =>
|
||||||
List(
|
List(
|
||||||
"<div data-path=\"", path, "\" id=\"file\">", "<article>",
|
"<div data-path=\"", path, "\" id=\"file\">", "<article>",
|
||||||
@@ -142,7 +157,9 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
"</article>", "</div>"
|
"</article>", "</div>"
|
||||||
).mkString
|
).mkString
|
||||||
)
|
)
|
||||||
case "application/vnd.github.v3.html" =>
|
}
|
||||||
|
case "application/vnd.github.v3.html" => {
|
||||||
|
contentType = "application/vnd.github.v3.html"
|
||||||
content.map(c =>
|
content.map(c =>
|
||||||
List(
|
List(
|
||||||
"<div data-path=\"", path, "\" id=\"file\">", "<div class=\"plain\">", "<pre>",
|
"<div data-path=\"", path, "\" id=\"file\">", "<div class=\"plain\">", "<pre>",
|
||||||
@@ -150,6 +167,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
"</pre>", "</div>", "</div>"
|
"</pre>", "</div>", "</div>"
|
||||||
).mkString
|
).mkString
|
||||||
)
|
)
|
||||||
|
}
|
||||||
case _ =>
|
case _ =>
|
||||||
Some(JsonFormat(ApiContents(f, content)))
|
Some(JsonFormat(ApiContents(f, content)))
|
||||||
}
|
}
|
||||||
@@ -168,7 +186,7 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
using(Git.open(getRepositoryDir(params("owner"), params("repo")))) { git =>
|
using(Git.open(getRepositoryDir(params("owner"), params("repo")))) { git =>
|
||||||
//JsonFormat( (revstr, git.getRepository().resolve(revstr)) )
|
//JsonFormat( (revstr, git.getRepository().resolve(revstr)) )
|
||||||
// getRef is deprecated by jgit-4.2. use exactRef() or findRef()
|
// getRef is deprecated by jgit-4.2. use exactRef() or findRef()
|
||||||
val sha = git.getRepository().getRef(revstr).getObjectId().name()
|
val sha = git.getRepository().exactRef(revstr).getObjectId().name()
|
||||||
JsonFormat(ApiRef(revstr, ApiObject(sha)))
|
JsonFormat(ApiRef(revstr, ApiObject(sha)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -276,6 +294,68 @@ 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/#list-issues-for-a-repository
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/issues")(referrersOnly { repository =>
|
||||||
|
val page = IssueSearchCondition.page(request)
|
||||||
|
// TODO: more api spec condition
|
||||||
|
val condition = IssueSearchCondition(request)
|
||||||
|
val baseOwner = getAccountByUserName(repository.owner).get
|
||||||
|
|
||||||
|
val issues: List[(Issue, Account)] =
|
||||||
|
searchIssueByApi(
|
||||||
|
condition = condition,
|
||||||
|
offset = (page - 1) * PullRequestLimit,
|
||||||
|
limit = PullRequestLimit,
|
||||||
|
repos = repository.owner -> repository.name
|
||||||
|
)
|
||||||
|
|
||||||
|
JsonFormat(issues.map { case (issue, issueUser) =>
|
||||||
|
ApiIssue(
|
||||||
|
issue = issue,
|
||||||
|
repositoryName = RepositoryName(repository),
|
||||||
|
user = ApiUser(issueUser)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/#get-a-single-issue
|
||||||
|
*/
|
||||||
|
get("/api/v3/repos/:owner/:repository/issues/:id")(referrersOnly { repository =>
|
||||||
|
(for{
|
||||||
|
issueId <- params("id").toIntOpt
|
||||||
|
issue <- getIssue(repository.owner, repository.name, issueId.toString)
|
||||||
|
openedUser <- getAccountByUserName(issue.openedUserName)
|
||||||
|
} yield {
|
||||||
|
JsonFormat(ApiIssue(issue, RepositoryName(repository), ApiUser(openedUser)))
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://developer.github.com/v3/issues/#create-an-issue
|
||||||
|
*/
|
||||||
|
post("/api/v3/repos/:owner/:repository/issues")(readableUsersOnly { repository =>
|
||||||
|
if(isIssueEditable(repository)){ // TODO Should this check is provided by authenticator?
|
||||||
|
(for{
|
||||||
|
data <- extractFromJsonBody[CreateAnIssue]
|
||||||
|
loginAccount <- context.loginAccount
|
||||||
|
} yield {
|
||||||
|
val milestone = data.milestone.flatMap(getMilestone(repository.owner, repository.name, _))
|
||||||
|
val issue = createIssue(
|
||||||
|
repository,
|
||||||
|
data.title,
|
||||||
|
data.body,
|
||||||
|
data.assignees.headOption,
|
||||||
|
milestone.map(_.milestoneId),
|
||||||
|
data.labels,
|
||||||
|
loginAccount)
|
||||||
|
JsonFormat(ApiIssue(issue, RepositoryName(repository), ApiUser(loginAccount)))
|
||||||
|
}) getOrElse NotFound()
|
||||||
|
} else Unauthorized()
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
|
* https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
|
||||||
*/
|
*/
|
||||||
@@ -363,12 +443,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()
|
||||||
}
|
}
|
||||||
@@ -407,11 +489,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)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -423,18 +506,20 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
(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),
|
||||||
|
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||||
|
))
|
||||||
}) getOrElse NotFound()
|
}) getOrElse NotFound()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -450,7 +535,7 @@ 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import gitbucket.core.util.Implicits._
|
|||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
|
|
||||||
import io.github.gitbucket.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.apache.commons.io.FileUtils
|
|
||||||
import org.json4s._
|
import org.json4s._
|
||||||
import org.scalatra._
|
import org.scalatra._
|
||||||
import org.scalatra.i18n._
|
import org.scalatra.i18n._
|
||||||
@@ -20,6 +19,8 @@ import javax.servlet.{FilterChain, ServletResponse, ServletRequest}
|
|||||||
|
|
||||||
import scala.util.Try
|
import scala.util.Try
|
||||||
|
|
||||||
|
import net.coobird.thumbnailator.Thumbnails
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides generic features for controller implementations.
|
* Provides generic features for controller implementations.
|
||||||
@@ -57,7 +58,7 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
// Redirect to dashboard
|
// Redirect to dashboard
|
||||||
httpResponse.sendRedirect(baseUrl + "/")
|
httpResponse.sendRedirect(baseUrl + "/")
|
||||||
}
|
}
|
||||||
} else if(path.startsWith("/git/")){
|
} else if(path.startsWith("/git/") || path.startsWith("/git-lfs/")){
|
||||||
// Git repository
|
// Git repository
|
||||||
chain.doFilter(request, response)
|
chain.doFilter(request, response)
|
||||||
} else {
|
} else {
|
||||||
@@ -225,10 +226,13 @@ trait AccountManagementControllerBase extends ControllerBase {
|
|||||||
} else {
|
} else {
|
||||||
fileId.map { fileId =>
|
fileId.map { fileId =>
|
||||||
val filename = "avatar." + FileUtil.getExtension(session.getAndRemove(Keys.Session.Upload(fileId)).get)
|
val filename = "avatar." + FileUtil.getExtension(session.getAndRemove(Keys.Session.Upload(fileId)).get)
|
||||||
FileUtils.moveFile(
|
val uploadDir = getUserUploadDir(userName)
|
||||||
new java.io.File(getTemporaryDir(session.getId), fileId),
|
if(!uploadDir.exists){
|
||||||
new java.io.File(getUserUploadDir(userName), filename)
|
uploadDir.mkdirs()
|
||||||
)
|
}
|
||||||
|
Thumbnails.of(new java.io.File(getTemporaryDir(session.getId), fileId))
|
||||||
|
.size(324, 324)
|
||||||
|
.toFile(new java.io.File(uploadDir, filename))
|
||||||
updateAvatarImage(userName, Some(filename))
|
updateAvatarImage(userName, Some(filename))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -76,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))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import gitbucket.core.model.Account
|
import gitbucket.core.model.Account
|
||||||
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
import gitbucket.core.service.{AccountService, RepositoryService}
|
import gitbucket.core.service.{AccountService, RepositoryService}
|
||||||
import gitbucket.core.servlet.Database
|
import gitbucket.core.servlet.Database
|
||||||
import gitbucket.core.util._
|
import gitbucket.core.util._
|
||||||
@@ -9,11 +10,10 @@ import gitbucket.core.util.Directory._
|
|||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.dircache.DirCache
|
import org.eclipse.jgit.dircache.DirCache
|
||||||
import org.eclipse.jgit.lib.{FileMode, Constants}
|
import org.eclipse.jgit.lib.{Constants, FileMode}
|
||||||
import org.scalatra
|
|
||||||
import org.scalatra._
|
import org.scalatra._
|
||||||
import org.scalatra.servlet.{MultipartConfig, FileUploadSupport, FileItem}
|
import org.scalatra.servlet.{FileItem, FileUploadSupport, MultipartConfig}
|
||||||
import org.apache.commons.io.{IOUtils, FileUtils}
|
import org.apache.commons.io.{FileUtils, IOUtils}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Ajax based file upload functionality.
|
* Provides Ajax based file upload functionality.
|
||||||
@@ -46,7 +46,7 @@ class FileUploadController extends ScalatraServlet with FileUploadSupport with R
|
|||||||
val repository = params("repository")
|
val repository = params("repository")
|
||||||
|
|
||||||
// Check whether logged-in user is collaborator
|
// Check whether logged-in user is collaborator
|
||||||
collaboratorsOnly(owner, repository, loginAccount){
|
onlyWikiEditable(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") {
|
||||||
@@ -88,13 +88,17 @@ class FileUploadController extends ScalatraServlet with FileUploadSupport with R
|
|||||||
redirect("/admin/data")
|
redirect("/admin/data")
|
||||||
}
|
}
|
||||||
|
|
||||||
private def collaboratorsOnly(owner: String, repository: String, loginAccount: Account)(action: => Any): Any = {
|
private def onlyWikiEditable(owner: String, repository: String, loginAccount: Account)(action: => Any): Any = {
|
||||||
implicit val session = Database.getSession(request)
|
implicit val session = Database.getSession(request)
|
||||||
loginAccount match {
|
getRepository(owner, repository) match {
|
||||||
case x if(x.isAdmin) => action
|
case Some(x) => x.repository.options.wikiOption match {
|
||||||
case x if(getCollaborators(owner, repository).contains(x.userName)) => action
|
case "ALL" if !x.repository.isPrivate => action
|
||||||
|
case "PUBLIC" if hasGuestRole(owner, repository, Some(loginAccount)) => action
|
||||||
|
case "PRIVATE" if hasDeveloperRole(owner, repository, Some(loginAccount)) => action
|
||||||
case _ => BadRequest()
|
case _ => BadRequest()
|
||||||
}
|
}
|
||||||
|
case None => BadRequest()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def execute(f: (FileItem, String) => Unit, mimeTypeChcker: (String) => Boolean) = fileParams.get("file") match {
|
private def execute(f: (FileItem, String) => Unit, mimeTypeChcker: (String) => Boolean) = fileParams.get("file") match {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ 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.{Keys, LDAPUtil, ReferrerAuthenticator, StringUtil, UsersAuthenticator}
|
import gitbucket.core.util.{Keys, LDAPUtil, ReferrerAuthenticator, UsersAuthenticator}
|
||||||
import io.github.gitbucket.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.scalatra.Ok
|
import org.scalatra.Ok
|
||||||
|
|
||||||
@@ -49,13 +49,18 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
if(redirect.isDefined && redirect.get.startsWith("/")){
|
if(redirect.isDefined && redirect.get.startsWith("/")){
|
||||||
flash += Keys.Flash.Redirect -> redirect.get
|
flash += Keys.Flash.Redirect -> redirect.get
|
||||||
}
|
}
|
||||||
gitbucket.core.html.signin()
|
gitbucket.core.html.signin(flash.get("userName"), flash.get("password"), flash.get("error"))
|
||||||
}
|
}
|
||||||
|
|
||||||
post("/signin", signinForm){ form =>
|
post("/signin", signinForm){ form =>
|
||||||
authenticate(context.settings, form.userName, form.password) match {
|
authenticate(context.settings, form.userName, form.password) match {
|
||||||
case Some(account) => signin(account)
|
case Some(account) => signin(account)
|
||||||
case None => redirect("/signin")
|
case None => {
|
||||||
|
flash += "userName" -> form.userName
|
||||||
|
flash += "password" -> form.password
|
||||||
|
flash += "error" -> "Sorry, your Username and/or Password is incorrect. Please try again."
|
||||||
|
redirect("/signin")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,14 +135,9 @@ trait IndexControllerBase extends ControllerBase {
|
|||||||
} getOrElse ""
|
} 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
|
||||||
@@ -147,23 +147,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,7 +2,6 @@ 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._
|
||||||
@@ -10,16 +9,39 @@ 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.{BadRequest, 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 WritableUsersAuthenticator with PullRequestService with WebHookIssueCommentService
|
with RepositoryService
|
||||||
|
with AccountService
|
||||||
|
with LabelsService
|
||||||
|
with MilestonesService
|
||||||
|
with ActivityService
|
||||||
|
with HandleCommentService
|
||||||
|
with IssueCreationService
|
||||||
|
with ReadableUsersAuthenticator
|
||||||
|
with ReferrerAuthenticator
|
||||||
|
with WritableUsersAuthenticator
|
||||||
|
with PullRequestService
|
||||||
|
with WebHookIssueCommentService
|
||||||
|
with CommitsService
|
||||||
|
|
||||||
trait IssuesControllerBase extends ControllerBase {
|
trait IssuesControllerBase extends ControllerBase {
|
||||||
self: IssuesService with RepositoryService with AccountService with LabelsService with MilestonesService with ActivityService with HandleCommentService
|
self: IssuesService
|
||||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator with PullRequestService with WebHookIssueCommentService =>
|
with RepositoryService
|
||||||
|
with AccountService
|
||||||
|
with LabelsService
|
||||||
|
with MilestonesService
|
||||||
|
with ActivityService
|
||||||
|
with HandleCommentService
|
||||||
|
with IssueCreationService
|
||||||
|
with ReadableUsersAuthenticator
|
||||||
|
with ReferrerAuthenticator
|
||||||
|
with WritableUsersAuthenticator
|
||||||
|
with PullRequestService
|
||||||
|
with WebHookIssueCommentService =>
|
||||||
|
|
||||||
case class IssueCreateForm(title: String, content: Option[String],
|
case class IssueCreateForm(title: String, content: Option[String],
|
||||||
assignedUserName: Option[String], milestoneId: Option[Int], labelNames: Option[String])
|
assignedUserName: Option[String], milestoneId: Option[Int], labelNames: Option[String])
|
||||||
@@ -70,67 +92,39 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
getAssignableUserNames(owner, name),
|
getAssignableUserNames(owner, name),
|
||||||
getMilestonesWithIssueCount(owner, name),
|
getMilestonesWithIssueCount(owner, name),
|
||||||
getLabels(owner, name),
|
getLabels(owner, name),
|
||||||
isEditable(repository),
|
isIssueEditable(repository),
|
||||||
isManageable(repository),
|
isIssueManageable(repository),
|
||||||
repository)
|
repository)
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/new")(readableUsersOnly { repository =>
|
get("/:owner/:repository/issues/new")(readableUsersOnly { repository =>
|
||||||
if(isEditable(repository)){ // TODO Should this check is provided by authenticator?
|
if(isIssueEditable(repository)){ // TODO Should this check is provided by authenticator?
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
html.create(
|
html.create(
|
||||||
getAssignableUserNames(owner, name),
|
getAssignableUserNames(owner, name),
|
||||||
getMilestones(owner, name),
|
getMilestones(owner, name),
|
||||||
getLabels(owner, name),
|
getLabels(owner, name),
|
||||||
isManageable(repository),
|
isIssueManageable(repository),
|
||||||
|
getContentTemplate(repository, "ISSUE_TEMPLATE"),
|
||||||
repository)
|
repository)
|
||||||
}
|
}
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
||||||
if(isEditable(repository)){ // TODO Should this check is provided by authenticator?
|
if(isIssueEditable(repository)){ // TODO Should this check is provided by authenticator?
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
val issue = createIssue(
|
||||||
val manageable = isManageable(repository)
|
repository,
|
||||||
val userName = context.loginAccount.get.userName
|
form.title,
|
||||||
|
form.content,
|
||||||
|
form.assignedUserName,
|
||||||
|
form.milestoneId,
|
||||||
|
form.labelNames.toArray.flatMap(_.split(",")),
|
||||||
|
context.loginAccount.get)
|
||||||
|
|
||||||
// insert issue
|
redirect(s"/${issue.userName}/${issue.repositoryName}/issues/${issue.issueId}")
|
||||||
val issueId = createIssue(owner, name, userName, form.title, form.content,
|
|
||||||
if (manageable) form.assignedUserName else None,
|
|
||||||
if (manageable) form.milestoneId else None)
|
|
||||||
|
|
||||||
// insert labels
|
|
||||||
if (manageable) {
|
|
||||||
form.labelNames.map { value =>
|
|
||||||
val labels = getLabels(owner, name)
|
|
||||||
value.split(",").foreach { labelName =>
|
|
||||||
labels.find(_.labelName == labelName).map { label =>
|
|
||||||
registerIssueLabel(owner, name, issueId, label.labelId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// record activity
|
|
||||||
recordCreateIssueActivity(owner, name, userName, issueId, form.title)
|
|
||||||
|
|
||||||
getIssue(owner, name, issueId.toString).foreach { issue =>
|
|
||||||
// extract references and create refer comment
|
|
||||||
createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse(""), context.loginAccount.get)
|
|
||||||
|
|
||||||
// call web hooks
|
|
||||||
callIssuesWebHook("opened", repository, issue, context.baseUrl, context.loginAccount.get)
|
|
||||||
|
|
||||||
// notifications
|
|
||||||
Notifier().toNotify(repository, issue, form.content.getOrElse("")) {
|
|
||||||
Notifier.msgIssue(s"${context.baseUrl}/${owner}/${name}/issues/${issueId}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
redirect(s"/${owner}/${name}/issues/${issueId}")
|
|
||||||
}
|
|
||||||
} else Unauthorized()
|
} else Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -306,7 +300,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
handleComment(issue, None, repository, Some("close"))
|
handleComment(issue, None, repository, Some("close"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case _ => // TODO BadRequest
|
case _ => BadRequest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -377,27 +371,8 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
countIssue(condition.copy(state = "closed"), false, owner -> repoName),
|
countIssue(condition.copy(state = "closed"), false, owner -> repoName),
|
||||||
condition,
|
condition,
|
||||||
repository,
|
repository,
|
||||||
isEditable(repository),
|
isIssueEditable(repository),
|
||||||
isManageable(repository))
|
isIssueManageable(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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,5 +382,4 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
private def isEditableContent(owner: String, repository: String, author: String)(implicit context: Context): Boolean = {
|
private def isEditableContent(owner: String, repository: String, author: String)(implicit context: Context): Boolean = {
|
||||||
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ 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
|
||||||
@@ -371,6 +368,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
forkedId,
|
forkedId,
|
||||||
oldId.getName,
|
oldId.getName,
|
||||||
newId.getName,
|
newId.getName,
|
||||||
|
getContentTemplate(originRepository, "PULL_REQUEST_TEMPLATE"),
|
||||||
forkedRepository,
|
forkedRepository,
|
||||||
originRepository,
|
originRepository,
|
||||||
forkedRepository,
|
forkedRepository,
|
||||||
@@ -427,7 +425,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
if(editable) {
|
if(editable) {
|
||||||
val loginUserName = context.loginAccount.get.userName
|
val loginUserName = context.loginAccount.get.userName
|
||||||
|
|
||||||
val issueId = createIssue(
|
val issueId = insertIssue(
|
||||||
owner = repository.owner,
|
owner = repository.owner,
|
||||||
repository = repository.name,
|
repository = repository.name,
|
||||||
loginUser = loginUserName,
|
loginUser = loginUserName,
|
||||||
@@ -498,26 +496,6 @@ 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)
|
||||||
|
|||||||
@@ -119,13 +119,25 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
renameRepository(repository.owner, repository.name, repository.owner, form.repositoryName)
|
renameRepository(repository.owner, repository.name, repository.owner, form.repositoryName)
|
||||||
// Move git repository
|
// Move git repository
|
||||||
defining(getRepositoryDir(repository.owner, repository.name)){ dir =>
|
defining(getRepositoryDir(repository.owner, repository.name)){ dir =>
|
||||||
|
if(dir.isDirectory){
|
||||||
FileUtils.moveDirectory(dir, getRepositoryDir(repository.owner, form.repositoryName))
|
FileUtils.moveDirectory(dir, getRepositoryDir(repository.owner, form.repositoryName))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Move wiki repository
|
// Move wiki repository
|
||||||
defining(getWikiRepositoryDir(repository.owner, repository.name)){ dir =>
|
defining(getWikiRepositoryDir(repository.owner, repository.name)){ dir =>
|
||||||
|
if(dir.isDirectory) {
|
||||||
FileUtils.moveDirectory(dir, getWikiRepositoryDir(repository.owner, form.repositoryName))
|
FileUtils.moveDirectory(dir, getWikiRepositoryDir(repository.owner, form.repositoryName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Move lfs directory
|
||||||
|
defining(getLfsDir(repository.owner, repository.name)){ dir =>
|
||||||
|
if(dir.isDirectory) {
|
||||||
|
FileUtils.moveDirectory(dir, getLfsDir(repository.owner, form.repositoryName))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Delete parent directory
|
||||||
|
FileUtil.deleteDirectoryIfEmpty(getRepositoryFilesDir(repository.owner, repository.name))
|
||||||
|
}
|
||||||
flash += "info" -> "Repository settings has been updated."
|
flash += "info" -> "Repository settings has been updated."
|
||||||
redirect(s"/${repository.owner}/${form.repositoryName}/settings/options")
|
redirect(s"/${repository.owner}/${form.repositoryName}/settings/options")
|
||||||
})
|
})
|
||||||
@@ -238,7 +250,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
|
||||||
@@ -317,13 +329,25 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
renameRepository(repository.owner, repository.name, form.newOwner, repository.name)
|
renameRepository(repository.owner, repository.name, form.newOwner, repository.name)
|
||||||
// Move git repository
|
// Move git repository
|
||||||
defining(getRepositoryDir(repository.owner, repository.name)){ dir =>
|
defining(getRepositoryDir(repository.owner, repository.name)){ dir =>
|
||||||
|
if(dir.isDirectory){
|
||||||
FileUtils.moveDirectory(dir, getRepositoryDir(form.newOwner, repository.name))
|
FileUtils.moveDirectory(dir, getRepositoryDir(form.newOwner, repository.name))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Move wiki repository
|
// Move wiki repository
|
||||||
defining(getWikiRepositoryDir(repository.owner, repository.name)){ dir =>
|
defining(getWikiRepositoryDir(repository.owner, repository.name)){ dir =>
|
||||||
|
if(dir.isDirectory) {
|
||||||
FileUtils.moveDirectory(dir, getWikiRepositoryDir(form.newOwner, repository.name))
|
FileUtils.moveDirectory(dir, getWikiRepositoryDir(form.newOwner, repository.name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Move lfs directory
|
||||||
|
defining(getLfsDir(repository.owner, repository.name)){ dir =>
|
||||||
|
if(dir.isDirectory()) {
|
||||||
|
FileUtils.moveDirectory(dir, getLfsDir(form.newOwner, repository.name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Delere parent directory
|
||||||
|
FileUtil.deleteDirectoryIfEmpty(getRepositoryFilesDir(repository.owner, repository.name))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
redirect(s"/${form.newOwner}/${repository.name}")
|
redirect(s"/${form.newOwner}/${repository.name}")
|
||||||
})
|
})
|
||||||
@@ -338,6 +362,9 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
|||||||
FileUtils.deleteDirectory(getRepositoryDir(repository.owner, repository.name))
|
FileUtils.deleteDirectory(getRepositoryDir(repository.owner, repository.name))
|
||||||
FileUtils.deleteDirectory(getWikiRepositoryDir(repository.owner, repository.name))
|
FileUtils.deleteDirectory(getWikiRepositoryDir(repository.owner, repository.name))
|
||||||
FileUtils.deleteDirectory(getTemporaryDir(repository.owner, repository.name))
|
FileUtils.deleteDirectory(getTemporaryDir(repository.owner, repository.name))
|
||||||
|
val lfsDir = getLfsDir(repository.owner, repository.name)
|
||||||
|
FileUtils.deleteDirectory(lfsDir)
|
||||||
|
FileUtil.deleteDirectoryIfEmpty(lfsDir.getParentFile())
|
||||||
}
|
}
|
||||||
redirect(s"/${repository.owner}")
|
redirect(s"/${repository.owner}")
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package gitbucket.core.controller
|
package gitbucket.core.controller
|
||||||
|
|
||||||
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
|
import java.io.FileInputStream
|
||||||
|
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
||||||
|
|
||||||
import gitbucket.core.plugin.PluginRegistry
|
import gitbucket.core.plugin.PluginRegistry
|
||||||
import gitbucket.core.repo.html
|
import gitbucket.core.repo.html
|
||||||
@@ -16,9 +17,8 @@ import gitbucket.core.model.{Account, WebHook}
|
|||||||
import gitbucket.core.service.WebHookService._
|
import gitbucket.core.service.WebHookService._
|
||||||
import gitbucket.core.view
|
import gitbucket.core.view
|
||||||
import gitbucket.core.view.helpers
|
import gitbucket.core.view.helpers
|
||||||
|
|
||||||
import io.github.gitbucket.scalatra.forms._
|
import io.github.gitbucket.scalatra.forms._
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.eclipse.jgit.api.{ArchiveCommand, Git}
|
import org.eclipse.jgit.api.{ArchiveCommand, Git}
|
||||||
import org.eclipse.jgit.archive.{TgzFormat, ZipFormat}
|
import org.eclipse.jgit.archive.{TgzFormat, ZipFormat}
|
||||||
import org.eclipse.jgit.dircache.DirCache
|
import org.eclipse.jgit.dircache.DirCache
|
||||||
@@ -102,7 +102,18 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
post("/:owner/:repository/_preview")(referrersOnly { repository =>
|
post("/:owner/:repository/_preview")(referrersOnly { repository =>
|
||||||
contentType = "text/html"
|
contentType = "text/html"
|
||||||
helpers.markdown(
|
val filename = params.get("filename")
|
||||||
|
filename match {
|
||||||
|
case Some(f) => helpers.renderMarkup(
|
||||||
|
filePath = List(f),
|
||||||
|
fileContent = params("content"),
|
||||||
|
branch = "master",
|
||||||
|
repository = repository,
|
||||||
|
enableWikiLink = params("enableWikiLink").toBoolean,
|
||||||
|
enableRefsLink = params("enableRefsLink").toBoolean,
|
||||||
|
enableAnchor = false
|
||||||
|
)
|
||||||
|
case None => helpers.markdown(
|
||||||
markdown = params("content"),
|
markdown = params("content"),
|
||||||
repository = repository,
|
repository = repository,
|
||||||
enableWikiLink = params("enableWikiLink").toBoolean,
|
enableWikiLink = params("enableWikiLink").toBoolean,
|
||||||
@@ -112,6 +123,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
enableAnchor = false,
|
enableAnchor = false,
|
||||||
hasWritePermission = hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
hasWritePermission = hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,7 +173,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val (branch, path) = repository.splitPath(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, None, Some("UTF-8")),
|
||||||
protectedBranch)
|
protectedBranch)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -243,13 +255,9 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val (id, path) = repository.splitPath(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 =>
|
|
||||||
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
getPathObjectId(git, path, revCommit).map { objectId =>
|
||||||
contentType = FileUtil.getMimeType(path)
|
responseRawFile(git, objectId, path, repository)
|
||||||
response.setContentLength(loader.getSize.toInt)
|
|
||||||
loader.copyTo(response.outputStream)
|
|
||||||
()
|
|
||||||
}
|
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -265,23 +273,57 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
getPathObjectId(git, path, revCommit).map { objectId =>
|
getPathObjectId(git, path, revCommit).map { objectId =>
|
||||||
if(raw){
|
if(raw){
|
||||||
// Download (This route is left for backword compatibility)
|
// Download (This route is left for backword compatibility)
|
||||||
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
responseRawFile(git, objectId, path, repository)
|
||||||
contentType = FileUtil.getMimeType(path)
|
|
||||||
response.setContentLength(loader.getSize.toInt)
|
|
||||||
loader.copyTo(response.outputStream)
|
|
||||||
()
|
|
||||||
} 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)),
|
||||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||||
request.paths(2) == "blame")
|
request.paths(2) == "blame",
|
||||||
|
isLfsFile(git, objectId))
|
||||||
}
|
}
|
||||||
} getOrElse NotFound()
|
} getOrElse NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
private def isLfsFile(git: Git, objectId: ObjectId): Boolean = {
|
||||||
|
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
||||||
|
if(loader.isLarge){
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
new String(loader.getCachedBytes, "UTF-8").startsWith("version https://git-lfs.github.com/spec/v1")
|
||||||
|
}
|
||||||
|
}.getOrElse(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private def responseRawFile(git: Git, objectId: ObjectId, path: String,
|
||||||
|
repository: RepositoryService.RepositoryInfo): Unit = {
|
||||||
|
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
||||||
|
contentType = FileUtil.getMimeType(path)
|
||||||
|
|
||||||
|
if(loader.isLarge){
|
||||||
|
response.setContentLength(loader.getSize.toInt)
|
||||||
|
loader.copyTo(response.outputStream)
|
||||||
|
} else {
|
||||||
|
val bytes = loader.getCachedBytes
|
||||||
|
val text = new String(bytes, "UTF-8")
|
||||||
|
|
||||||
|
val attrs = JGitUtil.getLfsObjects(text)
|
||||||
|
if(attrs.nonEmpty) {
|
||||||
|
response.setContentLength(attrs("size").toInt)
|
||||||
|
val oid = attrs("oid").split(":")(1)
|
||||||
|
|
||||||
|
using(new FileInputStream(FileUtil.getLfsFilePath(repository.owner, repository.name, oid))){ in =>
|
||||||
|
IOUtils.copy(in, response.getOutputStream)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
response.setContentLength(loader.getSize.toInt)
|
||||||
|
response.getOutputStream.write(bytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get("/:owner/:repository/blame/*"){
|
get("/:owner/:repository/blame/*"){
|
||||||
blobRoute.action()
|
blobRoute.action()
|
||||||
}
|
}
|
||||||
@@ -328,7 +370,7 @@ 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, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
repository, diffs, oldCommitId, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -546,10 +588,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 =>
|
||||||
|
if(JGitUtil.isEmpty(git)){
|
||||||
html.guide(repository, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
html.guide(repository, hasDeveloperRole(repository.owner, repository.name, context.loginAccount))
|
||||||
} else {
|
} else {
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
|
||||||
// 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 =>
|
||||||
@@ -569,9 +611,14 @@ 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, hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
JGitUtil.getCommitCount(repository.owner, repository.name, lastModifiedCommit.getName),
|
||||||
|
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()
|
||||||
}
|
}
|
||||||
@@ -666,11 +713,6 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
private def archiveRepository(name: String, suffix: String, repository: RepositoryService.RepositoryInfo): Unit = {
|
private def archiveRepository(name: String, suffix: String, repository: RepositoryService.RepositoryInfo): Unit = {
|
||||||
val revision = name.stripSuffix(suffix)
|
val revision = name.stripSuffix(suffix)
|
||||||
val workDir = getDownloadWorkDir(repository.owner, repository.name, session.getId)
|
|
||||||
if(workDir.exists) {
|
|
||||||
FileUtils.deleteDirectory(workDir)
|
|
||||||
}
|
|
||||||
workDir.mkdirs
|
|
||||||
|
|
||||||
val filename = repository.name + "-" +
|
val filename = repository.name + "-" +
|
||||||
(if(revision.length == 40) revision.substring(0, 10) else revision).replace('/', '_') + suffix
|
(if(revision.length == 40) revision.substring(0, 10) else revision).replace('/', '_') + suffix
|
||||||
@@ -684,7 +726,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
git.archive
|
git.archive
|
||||||
.setFormat(suffix.tail)
|
.setFormat(suffix.tail)
|
||||||
.setTree(revCommit.getTree)
|
.setTree(revCommit)
|
||||||
.setOutputStream(response.getOutputStream)
|
.setOutputStream(response.getOutputStream)
|
||||||
.call()
|
.call()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
"user" -> trim(label("SMTP User", optional(text()))),
|
"user" -> trim(label("SMTP User", optional(text()))),
|
||||||
"password" -> trim(label("SMTP Password", optional(text()))),
|
"password" -> trim(label("SMTP Password", optional(text()))),
|
||||||
"ssl" -> trim(label("Enable SSL", optional(boolean()))),
|
"ssl" -> trim(label("Enable SSL", optional(boolean()))),
|
||||||
|
"starttls" -> trim(label("Enable STARTTLS", optional(boolean()))),
|
||||||
"fromAddress" -> trim(label("FROM Address", optional(text()))),
|
"fromAddress" -> trim(label("FROM Address", optional(text()))),
|
||||||
"fromName" -> trim(label("FROM Name", optional(text())))
|
"fromName" -> trim(label("FROM Name", optional(text())))
|
||||||
)(Smtp.apply)),
|
)(Smtp.apply)),
|
||||||
@@ -77,6 +78,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
"user" -> trim(label("SMTP User", optional(text()))),
|
"user" -> trim(label("SMTP User", optional(text()))),
|
||||||
"password" -> trim(label("SMTP Password", optional(text()))),
|
"password" -> trim(label("SMTP Password", optional(text()))),
|
||||||
"ssl" -> trim(label("Enable SSL", optional(boolean()))),
|
"ssl" -> trim(label("Enable SSL", optional(boolean()))),
|
||||||
|
"starttls" -> trim(label("Enable STARTTLS", optional(boolean()))),
|
||||||
"fromAddress" -> trim(label("FROM Address", optional(text()))),
|
"fromAddress" -> trim(label("FROM Address", optional(text()))),
|
||||||
"fromName" -> trim(label("FROM Name", optional(text())))
|
"fromName" -> trim(label("FROM Name", optional(text())))
|
||||||
)(Smtp.apply),
|
)(Smtp.apply),
|
||||||
@@ -89,16 +91,16 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
case class NewUserForm(userName: String, password: String, fullName: String,
|
case class NewUserForm(userName: String, password: String, fullName: String,
|
||||||
mailAddress: String, isAdmin: Boolean,
|
mailAddress: String, isAdmin: Boolean,
|
||||||
url: Option[String], fileId: Option[String])
|
description: Option[String], url: Option[String], fileId: Option[String])
|
||||||
|
|
||||||
case class EditUserForm(userName: String, password: Option[String], fullName: String,
|
case class EditUserForm(userName: String, password: Option[String], fullName: String,
|
||||||
mailAddress: String, isAdmin: Boolean, url: Option[String],
|
mailAddress: String, isAdmin: Boolean, description: Option[String], url: Option[String],
|
||||||
fileId: Option[String], clearImage: Boolean, isRemoved: Boolean)
|
fileId: Option[String], clearImage: Boolean, isRemoved: Boolean)
|
||||||
|
|
||||||
case class NewGroupForm(groupName: String, url: Option[String], fileId: Option[String],
|
case class NewGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String],
|
||||||
members: String)
|
members: String)
|
||||||
|
|
||||||
case class EditGroupForm(groupName: String, url: Option[String], fileId: Option[String],
|
case class EditGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String],
|
||||||
members: String, clearImage: Boolean, isRemoved: Boolean)
|
members: String, clearImage: Boolean, isRemoved: Boolean)
|
||||||
|
|
||||||
|
|
||||||
@@ -108,6 +110,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
"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()))),
|
||||||
"isAdmin" -> trim(label("User Type" ,boolean())),
|
"isAdmin" -> trim(label("User Type" ,boolean())),
|
||||||
|
"description" -> trim(label("bio" ,optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text())))
|
"fileId" -> trim(label("File ID" ,optional(text())))
|
||||||
)(NewUserForm.apply)
|
)(NewUserForm.apply)
|
||||||
@@ -118,6 +121,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
"fullName" -> trim(label("Full Name" ,text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name" ,text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address" ,text(required, maxlength(100), uniqueMailAddress("userName")))),
|
"mailAddress" -> trim(label("Mail Address" ,text(required, maxlength(100), uniqueMailAddress("userName")))),
|
||||||
"isAdmin" -> trim(label("User Type" ,boolean())),
|
"isAdmin" -> trim(label("User Type" ,boolean())),
|
||||||
|
"description" -> trim(label("bio" ,optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"clearImage" -> trim(label("Clear image" ,boolean())),
|
"clearImage" -> trim(label("Clear image" ,boolean())),
|
||||||
@@ -126,6 +130,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
val newGroupForm = mapping(
|
val newGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
|
"description" -> trim(label("Group description", optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members)))
|
"members" -> trim(label("Members" ,text(required, members)))
|
||||||
@@ -133,6 +138,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
val editGroupForm = mapping(
|
val editGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
||||||
|
"description" -> trim(label("Group description", optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members))),
|
"members" -> trim(label("Members" ,text(required, members))),
|
||||||
@@ -164,7 +170,8 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
post("/admin/system/sendmail", sendMailForm)(adminOnly { form =>
|
post("/admin/system/sendmail", sendMailForm)(adminOnly { form =>
|
||||||
try {
|
try {
|
||||||
new Mailer(form.smtp).send(form.testAddress,
|
new Mailer(form.smtp).send(form.testAddress,
|
||||||
"Test message from GitBucket", "This is a test message from GitBucket.")
|
"Test message from GitBucket", "This is a test message from GitBucket.",
|
||||||
|
context.loginAccount.get)
|
||||||
|
|
||||||
"Test mail has been sent to: " + form.testAddress
|
"Test mail has been sent to: " + form.testAddress
|
||||||
|
|
||||||
@@ -193,7 +200,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/users/_newuser", newUserForm)(adminOnly { form =>
|
post("/admin/users/_newuser", newUserForm)(adminOnly { form =>
|
||||||
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, form.isAdmin, form.url)
|
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, form.isAdmin, form.description, form.url)
|
||||||
updateImage(form.userName, form.fileId, false)
|
updateImage(form.userName, form.fileId, false)
|
||||||
redirect("/admin/users")
|
redirect("/admin/users")
|
||||||
})
|
})
|
||||||
@@ -227,6 +234,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
fullName = form.fullName,
|
fullName = form.fullName,
|
||||||
mailAddress = form.mailAddress,
|
mailAddress = form.mailAddress,
|
||||||
isAdmin = form.isAdmin,
|
isAdmin = form.isAdmin,
|
||||||
|
description = form.description,
|
||||||
url = form.url,
|
url = form.url,
|
||||||
isRemoved = form.isRemoved))
|
isRemoved = form.isRemoved))
|
||||||
|
|
||||||
@@ -241,7 +249,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/users/_newgroup", newGroupForm)(adminOnly { form =>
|
post("/admin/users/_newgroup", newGroupForm)(adminOnly { form =>
|
||||||
createGroup(form.groupName, form.url)
|
createGroup(form.groupName, form.description, form.url)
|
||||||
updateGroupMembers(form.groupName, form.members.split(",").map {
|
updateGroupMembers(form.groupName, form.members.split(",").map {
|
||||||
_.split(":") match {
|
_.split(":") match {
|
||||||
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
||||||
@@ -264,7 +272,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
}.toList){ case (groupName, members) =>
|
}.toList){ case (groupName, members) =>
|
||||||
getAccountByUserName(groupName, true).map { account =>
|
getAccountByUserName(groupName, true).map { account =>
|
||||||
updateGroup(groupName, form.url, form.isRemoved)
|
updateGroup(groupName, form.url, form.description, form.isRemoved)
|
||||||
|
|
||||||
if(form.isRemoved){
|
if(form.isRemoved){
|
||||||
// Remove from GROUP_MEMBER
|
// Remove from GROUP_MEMBER
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ package gitbucket.core.model
|
|||||||
|
|
||||||
|
|
||||||
trait AccessTokenComponent { self: Profile =>
|
trait AccessTokenComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
|
|
||||||
lazy val AccessTokens = TableQuery[AccessTokens]
|
lazy val AccessTokens = TableQuery[AccessTokens]
|
||||||
|
|
||||||
class AccessTokens(tag: Tag) extends Table[AccessToken](tag, "ACCESS_TOKEN") {
|
class AccessTokens(tag: Tag) extends Table[AccessToken](tag, "ACCESS_TOKEN") {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait AccountComponent { self: Profile =>
|
trait AccountComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
import self._
|
import self._
|
||||||
|
|
||||||
lazy val Accounts = TableQuery[Accounts]
|
lazy val Accounts = TableQuery[Accounts]
|
||||||
@@ -19,7 +19,8 @@ trait AccountComponent { self: Profile =>
|
|||||||
val image = column[String]("IMAGE")
|
val image = column[String]("IMAGE")
|
||||||
val groupAccount = column[Boolean]("GROUP_ACCOUNT")
|
val groupAccount = column[Boolean]("GROUP_ACCOUNT")
|
||||||
val removed = column[Boolean]("REMOVED")
|
val removed = column[Boolean]("REMOVED")
|
||||||
def * = (userName, fullName, mailAddress, password, isAdmin, url.?, registeredDate, updatedDate, lastLoginDate.?, image.?, groupAccount, removed) <> (Account.tupled, Account.unapply)
|
val description = column[String]("DESCRIPTION")
|
||||||
|
def * = (userName, fullName, mailAddress, password, isAdmin, url.?, registeredDate, updatedDate, lastLoginDate.?, image.?, groupAccount, removed, description.?) <> (Account.tupled, Account.unapply)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,5 +36,6 @@ case class Account(
|
|||||||
lastLoginDate: Option[java.util.Date],
|
lastLoginDate: Option[java.util.Date],
|
||||||
image: Option[String],
|
image: Option[String],
|
||||||
isGroupAccount: Boolean,
|
isGroupAccount: Boolean,
|
||||||
isRemoved: Boolean
|
isRemoved: Boolean,
|
||||||
|
description: Option[String]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait ActivityComponent extends TemplateComponent { self: Profile =>
|
trait ActivityComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
import self._
|
import self._
|
||||||
|
|
||||||
lazy val Activities = TableQuery[Activities]
|
lazy val Activities = TableQuery[Activities]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
protected[model] trait TemplateComponent { self: Profile =>
|
protected[model] trait TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
|
|
||||||
trait BasicTemplate { self: Table[_] =>
|
trait BasicTemplate { self: Table[_] =>
|
||||||
val userName = column[String]("USER_NAME")
|
val userName = column[String]("USER_NAME")
|
||||||
@@ -10,7 +10,7 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
def byRepository(owner: String, repository: String) =
|
def byRepository(owner: String, repository: String) =
|
||||||
(userName === owner.bind) && (repositoryName === repository.bind)
|
(userName === owner.bind) && (repositoryName === repository.bind)
|
||||||
|
|
||||||
def byRepository(userName: Column[String], repositoryName: Column[String]) =
|
def byRepository(userName: Rep[String], repositoryName: Rep[String]) =
|
||||||
(this.userName === userName) && (this.repositoryName === repositoryName)
|
(this.userName === userName) && (this.repositoryName === repositoryName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
def byIssue(owner: String, repository: String, issueId: Int) =
|
def byIssue(owner: String, repository: String, issueId: Int) =
|
||||||
byRepository(owner, repository) && (this.issueId === issueId.bind)
|
byRepository(owner, repository) && (this.issueId === issueId.bind)
|
||||||
|
|
||||||
def byIssue(userName: Column[String], repositoryName: Column[String], issueId: Column[Int]) =
|
def byIssue(userName: Rep[String], repositoryName: Rep[String], issueId: Rep[Int]) =
|
||||||
byRepository(userName, repositoryName) && (this.issueId === issueId)
|
byRepository(userName, repositoryName) && (this.issueId === issueId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
def byLabel(owner: String, repository: String, labelId: Int) =
|
def byLabel(owner: String, repository: String, labelId: Int) =
|
||||||
byRepository(owner, repository) && (this.labelId === labelId.bind)
|
byRepository(owner, repository) && (this.labelId === labelId.bind)
|
||||||
|
|
||||||
def byLabel(userName: Column[String], repositoryName: Column[String], labelId: Column[Int]) =
|
def byLabel(userName: Rep[String], repositoryName: Rep[String], labelId: Rep[Int]) =
|
||||||
byRepository(userName, repositoryName) && (this.labelId === labelId)
|
byRepository(userName, repositoryName) && (this.labelId === labelId)
|
||||||
|
|
||||||
def byLabel(owner: String, repository: String, labelName: String) =
|
def byLabel(owner: String, repository: String, labelName: String) =
|
||||||
@@ -44,7 +44,7 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
def byMilestone(owner: String, repository: String, milestoneId: Int) =
|
def byMilestone(owner: String, repository: String, milestoneId: Int) =
|
||||||
byRepository(owner, repository) && (this.milestoneId === milestoneId.bind)
|
byRepository(owner, repository) && (this.milestoneId === milestoneId.bind)
|
||||||
|
|
||||||
def byMilestone(userName: Column[String], repositoryName: Column[String], milestoneId: Column[Int]) =
|
def byMilestone(userName: Rep[String], repositoryName: Rep[String], milestoneId: Rep[Int]) =
|
||||||
byRepository(userName, repositoryName) && (this.milestoneId === milestoneId)
|
byRepository(userName, repositoryName) && (this.milestoneId === milestoneId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,13 +54,13 @@ protected[model] trait TemplateComponent { self: Profile =>
|
|||||||
def byCommit(owner: String, repository: String, commitId: String) =
|
def byCommit(owner: String, repository: String, commitId: String) =
|
||||||
byRepository(owner, repository) && (this.commitId === commitId)
|
byRepository(owner, repository) && (this.commitId === commitId)
|
||||||
|
|
||||||
def byCommit(owner: Column[String], repository: Column[String], commitId: Column[String]) =
|
def byCommit(owner: Rep[String], repository: Rep[String], commitId: Rep[String]) =
|
||||||
byRepository(userName, repositoryName) && (this.commitId === commitId)
|
byRepository(userName, repositoryName) && (this.commitId === commitId)
|
||||||
}
|
}
|
||||||
|
|
||||||
trait BranchTemplate extends BasicTemplate{ self: Table[_] =>
|
trait BranchTemplate extends BasicTemplate{ self: Table[_] =>
|
||||||
val branch = column[String]("BRANCH")
|
val branch = column[String]("BRANCH")
|
||||||
def byBranch(owner: String, repository: String, branchName: String) = byRepository(owner, repository) && (branch === branchName.bind)
|
def byBranch(owner: String, repository: String, branchName: String) = byRepository(owner, repository) && (branch === branchName.bind)
|
||||||
def byBranch(owner: Column[String], repository: Column[String], branchName: Column[String]) = byRepository(owner, repository) && (this.branch === branchName)
|
def byBranch(owner: Rep[String], repository: Rep[String], branchName: Rep[String]) = byRepository(owner, repository) && (this.branch === branchName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait CollaboratorComponent extends TemplateComponent { self: Profile =>
|
trait CollaboratorComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
|
|
||||||
lazy val Collaborators = TableQuery[Collaborators]
|
lazy val Collaborators = TableQuery[Collaborators]
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ trait Comment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trait IssueCommentComponent extends TemplateComponent { self: Profile =>
|
trait IssueCommentComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
import self._
|
import self._
|
||||||
|
|
||||||
lazy val IssueComments = new TableQuery(tag => new IssueComments(tag)){
|
lazy val IssueComments = TableQuery[IssueComments]
|
||||||
def autoInc = this returning this.map(_.commentId)
|
|
||||||
}
|
|
||||||
|
|
||||||
class IssueComments(tag: Tag) extends Table[IssueComment](tag, "ISSUE_COMMENT") with IssueTemplate {
|
class IssueComments(tag: Tag) extends Table[IssueComment](tag, "ISSUE_COMMENT") with IssueTemplate {
|
||||||
val commentId = column[Int]("COMMENT_ID", O AutoInc)
|
val commentId = column[Int]("COMMENT_ID", O AutoInc)
|
||||||
@@ -39,12 +37,10 @@ case class IssueComment (
|
|||||||
) extends Comment
|
) extends Comment
|
||||||
|
|
||||||
trait CommitCommentComponent extends TemplateComponent { self: Profile =>
|
trait CommitCommentComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
import self._
|
import self._
|
||||||
|
|
||||||
lazy val CommitComments = new TableQuery(tag => new CommitComments(tag)){
|
lazy val CommitComments = TableQuery[CommitComments]
|
||||||
def autoInc = this returning this.map(_.commentId)
|
|
||||||
}
|
|
||||||
|
|
||||||
class CommitComments(tag: Tag) extends Table[CommitComment](tag, "COMMIT_COMMENT") with CommitTemplate {
|
class CommitComments(tag: Tag) extends Table[CommitComment](tag, "COMMIT_COMMENT") with CommitTemplate {
|
||||||
val commentId = column[Int]("COMMENT_ID", O AutoInc)
|
val commentId = column[Int]("COMMENT_ID", O AutoInc)
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
import scala.slick.lifted.MappedTo
|
|
||||||
import scala.slick.jdbc._
|
|
||||||
|
|
||||||
trait CommitStatusComponent extends TemplateComponent { self: Profile =>
|
trait CommitStatusComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
import self._
|
import self._
|
||||||
|
|
||||||
implicit val commitStateColumnType = MappedColumnType.base[CommitState, String](b => b.name , i => CommitState(i))
|
implicit val commitStateColumnType = MappedColumnType.base[CommitState, String](b => b.name , i => CommitState(i))
|
||||||
@@ -90,7 +87,5 @@ object CommitState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
implicit val getResult: GetResult[CommitState] = GetResult(r => CommitState(r.<<))
|
|
||||||
implicit val getResultOpt: GetResult[Option[CommitState]] = GetResult(r => r.<<?[String].map(CommitState(_)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait GroupMemberComponent { self: Profile =>
|
trait GroupMemberComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
|
|
||||||
lazy val GroupMembers = TableQuery[GroupMembers]
|
lazy val GroupMembers = TableQuery[GroupMembers]
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait IssueComponent extends TemplateComponent { self: Profile =>
|
trait IssueComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
import self._
|
import self._
|
||||||
|
|
||||||
lazy val IssueId = TableQuery[IssueId]
|
lazy val IssueId = TableQuery[IssueId]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait IssueLabelComponent extends TemplateComponent { self: Profile =>
|
trait IssueLabelComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
|
|
||||||
lazy val IssueLabels = TableQuery[IssueLabels]
|
lazy val IssueLabels = TableQuery[IssueLabels]
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait LabelComponent extends TemplateComponent { self: Profile =>
|
trait LabelComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
|
|
||||||
lazy val Labels = TableQuery[Labels]
|
lazy val Labels = TableQuery[Labels]
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ trait LabelComponent extends TemplateComponent { self: Profile =>
|
|||||||
def * = (userName, repositoryName, labelId, labelName, color) <> (Label.tupled, Label.unapply)
|
def * = (userName, repositoryName, labelId, labelName, color) <> (Label.tupled, Label.unapply)
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, labelId: Int) = byLabel(owner, repository, labelId)
|
def byPrimaryKey(owner: String, repository: String, labelId: Int) = byLabel(owner, repository, labelId)
|
||||||
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], labelId: Column[Int]) = byLabel(userName, repositoryName, labelId)
|
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], labelId: Rep[Int]) = byLabel(userName, repositoryName, labelId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait MilestoneComponent extends TemplateComponent { self: Profile =>
|
trait MilestoneComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
import self._
|
import self._
|
||||||
|
|
||||||
lazy val Milestones = TableQuery[Milestones]
|
lazy val Milestones = TableQuery[Milestones]
|
||||||
@@ -15,7 +15,7 @@ trait MilestoneComponent extends TemplateComponent { self: Profile =>
|
|||||||
def * = (userName, repositoryName, milestoneId, title, description.?, dueDate.?, closedDate.?) <> (Milestone.tupled, Milestone.unapply)
|
def * = (userName, repositoryName, milestoneId, title, description.?, dueDate.?, closedDate.?) <> (Milestone.tupled, Milestone.unapply)
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) = byMilestone(owner, repository, milestoneId)
|
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) = byMilestone(owner, repository, milestoneId)
|
||||||
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], milestoneId: Column[Int]) = byMilestone(userName, repositoryName, milestoneId)
|
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], milestoneId: Rep[Int]) = byMilestone(userName, repositoryName, milestoneId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
import gitbucket.core.util.DatabaseConfig
|
import gitbucket.core.util.DatabaseConfig
|
||||||
|
import com.github.takezoe.slick.blocking.BlockingJdbcProfile
|
||||||
|
|
||||||
trait Profile {
|
trait Profile {
|
||||||
val profile: slick.driver.JdbcProfile
|
val profile: BlockingJdbcProfile
|
||||||
import profile.simple._
|
import profile.blockingApi._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* java.util.Date Mapped Column Types
|
* java.util.Date Mapped Column Types
|
||||||
@@ -17,8 +18,8 @@ trait Profile {
|
|||||||
/**
|
/**
|
||||||
* Extends Column to add conditional condition
|
* Extends Column to add conditional condition
|
||||||
*/
|
*/
|
||||||
implicit class RichColumn(c1: Column[Boolean]){
|
implicit class RichColumn(c1: Rep[Boolean]){
|
||||||
def &&(c2: => Column[Boolean], guard: => Boolean): Column[Boolean] = if(guard) c1 && c2 else c1
|
def &&(c2: => Rep[Boolean], guard: => Boolean): Rep[Boolean] = if(guard) c1 && c2 else c1
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
import scala.slick.lifted.MappedTo
|
|
||||||
import scala.slick.jdbc._
|
|
||||||
|
|
||||||
trait ProtectedBranchComponent extends TemplateComponent { self: Profile =>
|
trait ProtectedBranchComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
import self._
|
import self._
|
||||||
|
|
||||||
lazy val ProtectedBranches = TableQuery[ProtectedBranches]
|
lazy val ProtectedBranches = TableQuery[ProtectedBranches]
|
||||||
@@ -12,7 +9,7 @@ trait ProtectedBranchComponent extends TemplateComponent { self: Profile =>
|
|||||||
val statusCheckAdmin = column[Boolean]("STATUS_CHECK_ADMIN")
|
val statusCheckAdmin = column[Boolean]("STATUS_CHECK_ADMIN")
|
||||||
def * = (userName, repositoryName, branch, statusCheckAdmin) <> (ProtectedBranch.tupled, ProtectedBranch.unapply)
|
def * = (userName, repositoryName, branch, statusCheckAdmin) <> (ProtectedBranch.tupled, ProtectedBranch.unapply)
|
||||||
def byPrimaryKey(userName: String, repositoryName: String, branch: String) = byBranch(userName, repositoryName, branch)
|
def byPrimaryKey(userName: String, repositoryName: String, branch: String) = byBranch(userName, repositoryName, branch)
|
||||||
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], branch: Column[String]) = byBranch(userName, repositoryName, branch)
|
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], branch: Rep[String]) = byBranch(userName, repositoryName, branch)
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy val ProtectedBranchContexts = TableQuery[ProtectedBranchContexts]
|
lazy val ProtectedBranchContexts = TableQuery[ProtectedBranchContexts]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait PullRequestComponent extends TemplateComponent { self: Profile =>
|
trait PullRequestComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
|
|
||||||
lazy val PullRequests = TableQuery[PullRequests]
|
lazy val PullRequests = TableQuery[PullRequests]
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ trait PullRequestComponent extends TemplateComponent { self: Profile =>
|
|||||||
def * = (userName, repositoryName, issueId, branch, requestUserName, requestRepositoryName, requestBranch, commitIdFrom, commitIdTo) <> (PullRequest.tupled, PullRequest.unapply)
|
def * = (userName, repositoryName, issueId, branch, requestUserName, requestRepositoryName, requestBranch, commitIdFrom, commitIdTo) <> (PullRequest.tupled, PullRequest.unapply)
|
||||||
|
|
||||||
def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) = byIssue(userName, repositoryName, issueId)
|
def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) = byIssue(userName, repositoryName, issueId)
|
||||||
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], issueId: Column[Int]) = byIssue(userName, repositoryName, issueId)
|
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], issueId: Rep[Int]) = byIssue(userName, repositoryName, issueId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
import self._
|
import self._
|
||||||
|
|
||||||
lazy val Repositories = TableQuery[Repositories]
|
lazy val Repositories = TableQuery[Repositories]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait SshKeyComponent { self: Profile =>
|
trait SshKeyComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
|
|
||||||
lazy val SshKeys = TableQuery[SshKeys]
|
lazy val SshKeys = TableQuery[SshKeys]
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait WebHookComponent extends TemplateComponent { self: Profile =>
|
trait WebHookComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
|
|
||||||
implicit val whContentTypeColumnType = MappedColumnType.base[WebHookContentType, String](whct => whct.code , code => WebHookContentType.valueOf(code))
|
implicit val whContentTypeColumnType = MappedColumnType.base[WebHookContentType, String](whct => whct.code , code => WebHookContentType.valueOf(code))
|
||||||
|
|
||||||
@@ -9,19 +9,18 @@ trait WebHookComponent extends TemplateComponent { self: Profile =>
|
|||||||
|
|
||||||
class WebHooks(tag: Tag) extends Table[WebHook](tag, "WEB_HOOK") with BasicTemplate {
|
class WebHooks(tag: Tag) extends Table[WebHook](tag, "WEB_HOOK") with BasicTemplate {
|
||||||
val url = column[String]("URL")
|
val url = column[String]("URL")
|
||||||
val token = column[Option[String]]("TOKEN", O.Nullable)
|
val token = column[Option[String]]("TOKEN")
|
||||||
val ctype = column[WebHookContentType]("CTYPE", O.NotNull)
|
val ctype = column[WebHookContentType]("CTYPE")
|
||||||
def * = (userName, repositoryName, url, ctype, token) <> ((WebHook.apply _).tupled, WebHook.unapply)
|
def * = (userName, repositoryName, url, ctype, token) <> ((WebHook.apply _).tupled, WebHook.unapply)
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, url: String) = byRepository(owner, repository) && (this.url === url.bind)
|
def byPrimaryKey(owner: String, repository: String, url: String) = byRepository(owner, repository) && (this.url === url.bind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case class WebHookContentType(val code: String, val ctype: String)
|
abstract sealed case class WebHookContentType(code: String, ctype: String)
|
||||||
|
|
||||||
object WebHookContentType {
|
object WebHookContentType {
|
||||||
object JSON extends WebHookContentType("json", "application/json")
|
object JSON extends WebHookContentType("json", "application/json")
|
||||||
|
|
||||||
object FORM extends WebHookContentType("form", "application/x-www-form-urlencoded")
|
object FORM extends WebHookContentType("form", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
val values: Vector[WebHookContentType] = Vector(JSON, FORM)
|
val values: Vector[WebHookContentType] = Vector(JSON, FORM)
|
||||||
@@ -43,7 +42,8 @@ case class WebHook(
|
|||||||
)
|
)
|
||||||
|
|
||||||
object WebHook {
|
object WebHook {
|
||||||
sealed class Event(var name: String)
|
abstract sealed class Event(val name: String)
|
||||||
|
|
||||||
case object CommitComment extends Event("commit_comment")
|
case object CommitComment extends Event("commit_comment")
|
||||||
case object Create extends Event("create")
|
case object Create extends Event("create")
|
||||||
case object Delete extends Event("delete")
|
case object Delete extends Event("delete")
|
||||||
@@ -63,9 +63,30 @@ object WebHook {
|
|||||||
case object Status extends Event("status")
|
case object Status extends Event("status")
|
||||||
case object TeamAdd extends Event("team_add")
|
case object TeamAdd extends Event("team_add")
|
||||||
case object Watch extends Event("watch")
|
case object Watch extends Event("watch")
|
||||||
|
|
||||||
object Event{
|
object Event{
|
||||||
val values = List(CommitComment,Create,Delete,Deployment,DeploymentStatus,Fork,Gollum,IssueComment,Issues,Member,PageBuild,Public,PullRequest,PullRequestReviewComment,Push,Release,Status,TeamAdd,Watch)
|
val values = List(
|
||||||
private val map:Map[String,Event] = values.map(e => e.name -> e).toMap
|
CommitComment,
|
||||||
|
Create,
|
||||||
|
Delete,
|
||||||
|
Deployment,
|
||||||
|
DeploymentStatus,
|
||||||
|
Fork,
|
||||||
|
Gollum,
|
||||||
|
IssueComment,
|
||||||
|
Issues,
|
||||||
|
Member,
|
||||||
|
PageBuild,
|
||||||
|
Public,
|
||||||
|
PullRequest,
|
||||||
|
PullRequestReviewComment,
|
||||||
|
Push,
|
||||||
|
Release,
|
||||||
|
Status,
|
||||||
|
TeamAdd,
|
||||||
|
Watch
|
||||||
|
)
|
||||||
|
private val map: Map[String,Event] = values.map(e => e.name -> e).toMap
|
||||||
def valueOf(name: String): Event = map(name)
|
def valueOf(name: String): Event = map(name)
|
||||||
def valueOpt(name: String): Option[Event] = map.get(name)
|
def valueOpt(name: String): Option[Event] = map.get(name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package gitbucket.core.model
|
package gitbucket.core.model
|
||||||
|
|
||||||
trait WebHookEventComponent extends TemplateComponent { self: Profile =>
|
trait WebHookEventComponent extends TemplateComponent { self: Profile =>
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
import gitbucket.core.model.Profile.WebHooks
|
import gitbucket.core.model.Profile.WebHooks
|
||||||
|
|
||||||
lazy val WebHookEvents = TableQuery[WebHookEvents]
|
lazy val WebHookEvents = TableQuery[WebHookEvents]
|
||||||
@@ -14,7 +14,7 @@ trait WebHookEventComponent extends TemplateComponent { self: Profile =>
|
|||||||
def * = (userName, repositoryName, url, event) <> ((WebHookEvent.apply _).tupled, WebHookEvent.unapply)
|
def * = (userName, repositoryName, url, event) <> ((WebHookEvent.apply _).tupled, WebHookEvent.unapply)
|
||||||
|
|
||||||
def byWebHook(owner: String, repository: String, url: String) = byRepository(owner, repository) && (this.url === url.bind)
|
def byWebHook(owner: String, repository: String, url: String) = byRepository(owner, repository) && (this.url === url.bind)
|
||||||
def byWebHook(owner: Column[String], repository: Column[String], url: Column[String]) =
|
def byWebHook(owner: Rep[String], repository: Rep[String], url: Rep[String]) =
|
||||||
byRepository(userName, repositoryName) && (this.url === url)
|
byRepository(userName, repositoryName) && (this.url === url)
|
||||||
def byWebHook(webhook: WebHooks) =
|
def byWebHook(webhook: WebHooks) =
|
||||||
byRepository(webhook.userName, webhook.repositoryName) && (this.url === webhook.url)
|
byRepository(webhook.userName, webhook.repositoryName) && (this.url === webhook.url)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package gitbucket.core.plugin
|
|||||||
|
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import org.eclipse.jgit.transport.{ReceivePack, ReceiveCommand}
|
import org.eclipse.jgit.transport.{ReceivePack, ReceiveCommand}
|
||||||
import profile.simple._
|
import profile.api._
|
||||||
|
|
||||||
trait ReceiveHook {
|
trait ReceiveHook {
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package gitbucket.core.plugin
|
package gitbucket.core.plugin
|
||||||
|
|
||||||
import scala.slick.jdbc.JdbcBackend.Session
|
import slick.jdbc.JdbcBackend.Session
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Slick Session to Plug-ins.
|
* Provides Slick Session to Plug-ins.
|
||||||
|
|||||||
@@ -23,5 +23,5 @@ class UserNameSuggestionProvider extends SuggestionProvider {
|
|||||||
override def values(repository: RepositoryInfo): Seq[String] = Nil
|
override def values(repository: RepositoryInfo): Seq[String] = Nil
|
||||||
override def template(implicit context: Context): String = "'@' + value"
|
override def template(implicit context: Context): String = "'@' + value"
|
||||||
override def additionalScript(implicit context: Context): String =
|
override def additionalScript(implicit context: Context): String =
|
||||||
s"""$$.get('${context.path}/_user/proposals', { query: '' }, function (data) { user = data.options; });"""
|
s"""$$.get('${context.path}/_user/proposals', { query: '', user: true, group: false }, function (data) { user = data.options; });"""
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import profile.simple._
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
|
|
||||||
import gitbucket.core.model.{Account, AccessToken}
|
import gitbucket.core.model.{Account, AccessToken}
|
||||||
import gitbucket.core.util.StringUtil
|
import gitbucket.core.util.StringUtil
|
||||||
|
|
||||||
@@ -20,28 +19,30 @@ trait AccessTokenService {
|
|||||||
def tokenToHash(token: String): String = StringUtil.sha1(token)
|
def tokenToHash(token: String): String = StringUtil.sha1(token)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @retuen (TokenId, Token)
|
* @return (TokenId, Token)
|
||||||
*/
|
*/
|
||||||
def generateAccessToken(userName: String, note: String)(implicit s: Session): (Int, String) = {
|
def generateAccessToken(userName: String, note: String)(implicit s: Session): (Int, String) = {
|
||||||
var token: String = null
|
var token: String = null
|
||||||
var hash: String = null
|
var hash: String = null
|
||||||
do{
|
|
||||||
|
do {
|
||||||
token = makeAccessTokenString
|
token = makeAccessTokenString
|
||||||
hash = tokenToHash(token)
|
hash = tokenToHash(token)
|
||||||
}while(AccessTokens.filter(_.tokenHash === hash.bind).exists.run)
|
//} while (AccessTokens.filter(_.tokenHash === hash.bind).exists.run)
|
||||||
|
} while (AccessTokens.filter(_.tokenHash === hash.bind).exists.run)
|
||||||
val newToken = AccessToken(
|
val newToken = AccessToken(
|
||||||
userName = userName,
|
userName = userName,
|
||||||
note = note,
|
note = note,
|
||||||
tokenHash = hash)
|
tokenHash = hash)
|
||||||
val tokenId = (AccessTokens returning AccessTokens.map(_.accessTokenId)) += newToken
|
val tokenId = (AccessTokens returning AccessTokens.map(_.accessTokenId)) insert newToken
|
||||||
(tokenId, token)
|
(tokenId, token)
|
||||||
}
|
}
|
||||||
|
|
||||||
def getAccountByAccessToken(token: String)(implicit s: Session): Option[Account] =
|
def getAccountByAccessToken(token: String)(implicit s: Session): Option[Account] =
|
||||||
Accounts
|
Accounts
|
||||||
.innerJoin(AccessTokens)
|
.join(AccessTokens)
|
||||||
.filter{ case (ac, t) => (ac.userName === t.userName) && (t.tokenHash === tokenToHash(token).bind) && (ac.removed === false.bind) }
|
.filter { case (ac, t) => (ac.userName === t.userName) && (t.tokenHash === tokenToHash(token).bind) && (ac.removed === false.bind) }
|
||||||
.map{ case (ac, t) => ac }
|
.map { case (ac, t) => ac }
|
||||||
.firstOption
|
.firstOption
|
||||||
|
|
||||||
def getAccessTokens(userName: String)(implicit s: Session): List[AccessToken] =
|
def getAccessTokens(userName: String)(implicit s: Session): List[AccessToken] =
|
||||||
|
|||||||
@@ -1,26 +1,32 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
import gitbucket.core.model.{GroupMember, Account}
|
import gitbucket.core.model.{GroupMember, Account}
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import gitbucket.core.util.{StringUtil, LDAPUtil}
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import gitbucket.core.service.SystemSettingsService.SystemSettings
|
|
||||||
import profile.simple._
|
|
||||||
import StringUtil._
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
// TODO Why is direct import required?
|
|
||||||
import gitbucket.core.model.Profile.dateColumnType
|
import gitbucket.core.model.Profile.dateColumnType
|
||||||
|
import gitbucket.core.util.{StringUtil, LDAPUtil}
|
||||||
|
import StringUtil._
|
||||||
|
import gitbucket.core.service.SystemSettingsService.SystemSettings
|
||||||
|
|
||||||
trait AccountService {
|
trait AccountService {
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(classOf[AccountService])
|
private val logger = LoggerFactory.getLogger(classOf[AccountService])
|
||||||
|
|
||||||
def authenticate(settings: SystemSettings, userName: String, password: String)(implicit s: Session): Option[Account] =
|
def authenticate(settings: SystemSettings, userName: String, password: String)(implicit s: Session): Option[Account] = {
|
||||||
if(settings.ldapAuthentication){
|
val account = if (settings.ldapAuthentication) {
|
||||||
ldapAuthentication(settings, userName, password)
|
ldapAuthentication(settings, userName, password)
|
||||||
} else {
|
} else {
|
||||||
defaultAuthentication(userName, password)
|
defaultAuthentication(userName, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(account.isEmpty){
|
||||||
|
logger.info(s"Failed to authenticate: $userName")
|
||||||
|
}
|
||||||
|
|
||||||
|
account
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticate by internal database.
|
* Authenticate by internal database.
|
||||||
*/
|
*/
|
||||||
@@ -61,14 +67,14 @@ trait AccountService {
|
|||||||
defaultAuthentication(userName, password)
|
defaultAuthentication(userName, password)
|
||||||
}
|
}
|
||||||
case None => {
|
case None => {
|
||||||
createAccount(ldapUserInfo.userName, "", ldapUserInfo.fullName, ldapUserInfo.mailAddress, false, None)
|
createAccount(ldapUserInfo.userName, "", ldapUserInfo.fullName, ldapUserInfo.mailAddress, false, None, None)
|
||||||
getAccountByUserName(ldapUserInfo.userName)
|
getAccountByUserName(ldapUserInfo.userName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case Left(errorMessage) => {
|
case Left(errorMessage) => {
|
||||||
logger.info(s"LDAP Authentication Failed: ${errorMessage}")
|
logger.info(s"LDAP error: ${errorMessage}")
|
||||||
defaultAuthentication(userName, password)
|
defaultAuthentication(userName, password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +109,7 @@ trait AccountService {
|
|||||||
} else false
|
} else false
|
||||||
}
|
}
|
||||||
|
|
||||||
def createAccount(userName: String, password: String, fullName: String, mailAddress: String, isAdmin: Boolean, url: Option[String])
|
def createAccount(userName: String, password: String, fullName: String, mailAddress: String, isAdmin: Boolean, description: Option[String], url: Option[String])
|
||||||
(implicit s: Session): Unit =
|
(implicit s: Session): Unit =
|
||||||
Accounts insert Account(
|
Accounts insert Account(
|
||||||
userName = userName,
|
userName = userName,
|
||||||
@@ -117,12 +123,13 @@ trait AccountService {
|
|||||||
lastLoginDate = None,
|
lastLoginDate = None,
|
||||||
image = None,
|
image = None,
|
||||||
isGroupAccount = false,
|
isGroupAccount = false,
|
||||||
isRemoved = false)
|
isRemoved = false,
|
||||||
|
description = description)
|
||||||
|
|
||||||
def updateAccount(account: Account)(implicit s: Session): Unit =
|
def updateAccount(account: Account)(implicit s: Session): Unit =
|
||||||
Accounts
|
Accounts
|
||||||
.filter { a => a.userName === account.userName.bind }
|
.filter { a => a.userName === account.userName.bind }
|
||||||
.map { a => (a.password, a.fullName, a.mailAddress, a.isAdmin, a.url.?, a.registeredDate, a.updatedDate, a.lastLoginDate.?, a.removed) }
|
.map { a => (a.password, a.fullName, a.mailAddress, a.isAdmin, a.url.?, a.registeredDate, a.updatedDate, a.lastLoginDate.?, a.removed, a.description.?) }
|
||||||
.update (
|
.update (
|
||||||
account.password,
|
account.password,
|
||||||
account.fullName,
|
account.fullName,
|
||||||
@@ -132,7 +139,8 @@ trait AccountService {
|
|||||||
account.registeredDate,
|
account.registeredDate,
|
||||||
currentDate,
|
currentDate,
|
||||||
account.lastLoginDate,
|
account.lastLoginDate,
|
||||||
account.isRemoved)
|
account.isRemoved,
|
||||||
|
account.description)
|
||||||
|
|
||||||
def updateAvatarImage(userName: String, image: Option[String])(implicit s: Session): Unit =
|
def updateAvatarImage(userName: String, image: Option[String])(implicit s: Session): Unit =
|
||||||
Accounts.filter(_.userName === userName.bind).map(_.image.?).update(image)
|
Accounts.filter(_.userName === userName.bind).map(_.image.?).update(image)
|
||||||
@@ -140,7 +148,7 @@ trait AccountService {
|
|||||||
def updateLastLoginDate(userName: String)(implicit s: Session): Unit =
|
def updateLastLoginDate(userName: String)(implicit s: Session): Unit =
|
||||||
Accounts.filter(_.userName === userName.bind).map(_.lastLoginDate).update(currentDate)
|
Accounts.filter(_.userName === userName.bind).map(_.lastLoginDate).update(currentDate)
|
||||||
|
|
||||||
def createGroup(groupName: String, url: Option[String])(implicit s: Session): Unit =
|
def createGroup(groupName: String, description: Option[String], url: Option[String])(implicit s: Session): Unit =
|
||||||
Accounts insert Account(
|
Accounts insert Account(
|
||||||
userName = groupName,
|
userName = groupName,
|
||||||
password = "",
|
password = "",
|
||||||
@@ -153,10 +161,13 @@ trait AccountService {
|
|||||||
lastLoginDate = None,
|
lastLoginDate = None,
|
||||||
image = None,
|
image = None,
|
||||||
isGroupAccount = true,
|
isGroupAccount = true,
|
||||||
isRemoved = false)
|
isRemoved = false,
|
||||||
|
description = description)
|
||||||
|
|
||||||
def updateGroup(groupName: String, url: Option[String], removed: Boolean)(implicit s: Session): Unit =
|
def updateGroup(groupName: String, description: Option[String], url: Option[String], removed: Boolean)(implicit s: Session): Unit =
|
||||||
Accounts.filter(_.userName === groupName.bind).map(t => t.url.? -> t.removed).update(url, removed)
|
Accounts.filter(_.userName === groupName.bind)
|
||||||
|
.map(t => (t.url.?, t.description.?, t.removed))
|
||||||
|
.update(url, description, removed)
|
||||||
|
|
||||||
def updateGroupMembers(groupName: String, members: List[(String, Boolean)])(implicit s: Session): Unit = {
|
def updateGroupMembers(groupName: String, members: List[(String, Boolean)])(implicit s: Session): Unit = {
|
||||||
GroupMembers.filter(_.groupName === groupName.bind).delete
|
GroupMembers.filter(_.groupName === groupName.bind).delete
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.model.Activity
|
import gitbucket.core.model.Activity
|
||||||
import gitbucket.core.model.Profile._
|
|
||||||
import gitbucket.core.util.JGitUtil
|
import gitbucket.core.util.JGitUtil
|
||||||
import profile.simple._
|
import gitbucket.core.model.Profile._
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
|
|
||||||
trait ActivityService {
|
trait ActivityService {
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ trait ActivityService {
|
|||||||
|
|
||||||
def getActivitiesByUser(activityUserName: String, isPublic: Boolean)(implicit s: Session): List[Activity] =
|
def getActivitiesByUser(activityUserName: String, isPublic: Boolean)(implicit s: Session): List[Activity] =
|
||||||
Activities
|
Activities
|
||||||
.innerJoin(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
|
.join(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
|
||||||
.filter { case (t1, t2) =>
|
.filter { case (t1, t2) =>
|
||||||
if(isPublic){
|
if(isPublic){
|
||||||
(t1.activityUserName === activityUserName.bind) && (t2.isPrivate === false.bind)
|
(t1.activityUserName === activityUserName.bind) && (t2.isPrivate === false.bind)
|
||||||
@@ -30,7 +30,7 @@ trait ActivityService {
|
|||||||
|
|
||||||
def getRecentActivities()(implicit s: Session): List[Activity] =
|
def getRecentActivities()(implicit s: Session): List[Activity] =
|
||||||
Activities
|
Activities
|
||||||
.innerJoin(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
|
.join(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
|
||||||
.filter { case (t1, t2) => t2.isPrivate === false.bind }
|
.filter { case (t1, t2) => t2.isPrivate === false.bind }
|
||||||
.sortBy { case (t1, t2) => t1.activityId desc }
|
.sortBy { case (t1, t2) => t1.activityId desc }
|
||||||
.map { case (t1, t2) => t1 }
|
.map { case (t1, t2) => t1 }
|
||||||
@@ -39,7 +39,7 @@ trait ActivityService {
|
|||||||
|
|
||||||
def getRecentActivitiesByOwners(owners : Set[String])(implicit s: Session): List[Activity] =
|
def getRecentActivitiesByOwners(owners : Set[String])(implicit s: Session): List[Activity] =
|
||||||
Activities
|
Activities
|
||||||
.innerJoin(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
|
.join(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
|
||||||
.filter { case (t1, t2) => (t2.isPrivate === false.bind) || (t2.userName inSetBind owners) }
|
.filter { case (t1, t2) => (t2.isPrivate === false.bind) || (t2.userName inSetBind owners) }
|
||||||
.sortBy { case (t1, t2) => t1.activityId desc }
|
.sortBy { case (t1, t2) => t1.activityId desc }
|
||||||
.map { case (t1, t2) => t1 }
|
.map { case (t1, t2) => t1 }
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import profile.simple._
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
|
|
||||||
import gitbucket.core.model.{CommitState, CommitStatus, Account}
|
|
||||||
import gitbucket.core.util.Implicits._
|
|
||||||
import gitbucket.core.util.StringUtil._
|
|
||||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
|
||||||
import org.joda.time.LocalDateTime
|
|
||||||
import gitbucket.core.model.Profile.dateColumnType
|
import gitbucket.core.model.Profile.dateColumnType
|
||||||
|
import gitbucket.core.model.{CommitState, CommitStatus, Account}
|
||||||
|
|
||||||
trait CommitStatusService {
|
trait CommitStatusService {
|
||||||
/** insert or update */
|
/** insert or update */
|
||||||
@@ -23,7 +18,7 @@ trait CommitStatusService {
|
|||||||
}.update((state, targetUrl, now, creator.userName, description))
|
}.update((state, targetUrl, now, creator.userName, description))
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
case None => (CommitStatuses returning CommitStatuses.map(_.commitStatusId)) += CommitStatus(
|
case None => (CommitStatuses returning CommitStatuses.map(_.commitStatusId)) insert CommitStatus(
|
||||||
userName = userName,
|
userName = userName,
|
||||||
repositoryName = repositoryName,
|
repositoryName = repositoryName,
|
||||||
commitId = sha,
|
commitId = sha,
|
||||||
@@ -49,7 +44,7 @@ trait CommitStatusService {
|
|||||||
CommitStatuses.filter(t => t.byRepository(userName, repositoryName)).filter(t => t.updatedDate > time.bind).groupBy(_.context).map(_._1).list
|
CommitStatuses.filter(t => t.byRepository(userName, repositoryName)).filter(t => t.updatedDate > time.bind).groupBy(_.context).map(_._1).list
|
||||||
|
|
||||||
def getCommitStatuesWithCreator(userName: String, repositoryName: String, sha: String)(implicit s: Session) :List[(CommitStatus, Account)] =
|
def getCommitStatuesWithCreator(userName: String, repositoryName: String, sha: String)(implicit s: Session) :List[(CommitStatus, Account)] =
|
||||||
byCommitStatues(userName, repositoryName, sha).innerJoin(Accounts).filter { case (t, a) => t.creator === a.userName }.list
|
byCommitStatues(userName, repositoryName, sha).join(Accounts).filter { case (t, a) => t.creator === a.userName }.list
|
||||||
|
|
||||||
protected def byCommitStatues(userName: String, repositoryName: String, sha: String)(implicit s: Session) =
|
protected def byCommitStatues(userName: String, repositoryName: String, sha: String)(implicit s: Session) =
|
||||||
CommitStatuses.filter(t => t.byCommit(userName, repositoryName, sha)).sortBy(_.updatedDate desc)
|
CommitStatuses.filter(t => t.byCommit(userName, repositoryName, sha)).sortBy(_.updatedDate desc)
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.model.CommitComment
|
import gitbucket.core.model.CommitComment
|
||||||
import gitbucket.core.util.{StringUtil, Implicits}
|
|
||||||
|
|
||||||
import scala.slick.jdbc.{StaticQuery => Q}
|
|
||||||
import Q.interpolation
|
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import profile.simple._
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import Implicits._
|
import gitbucket.core.model.Profile.dateColumnType
|
||||||
import StringUtil._
|
|
||||||
|
|
||||||
|
|
||||||
trait CommitsService {
|
trait CommitsService {
|
||||||
|
|
||||||
@@ -29,7 +23,7 @@ trait CommitsService {
|
|||||||
def createCommitComment(owner: String, repository: String, commitId: String, loginUser: String,
|
def createCommitComment(owner: String, repository: String, commitId: String, loginUser: String,
|
||||||
content: String, fileName: Option[String], oldLine: Option[Int], newLine: Option[Int],
|
content: String, fileName: Option[String], oldLine: Option[Int], newLine: Option[Int],
|
||||||
issueId: Option[Int])(implicit s: Session): Int =
|
issueId: Option[Int])(implicit s: Session): Int =
|
||||||
CommitComments.autoInc insert CommitComment(
|
CommitComments returning CommitComments.map(_.commentId) insert CommitComment(
|
||||||
userName = owner,
|
userName = owner,
|
||||||
repositoryName = repository,
|
repositoryName = repository,
|
||||||
commitId = commitId,
|
commitId = commitId,
|
||||||
@@ -42,12 +36,18 @@ trait CommitsService {
|
|||||||
updatedDate = currentDate,
|
updatedDate = currentDate,
|
||||||
issueId = issueId)
|
issueId = issueId)
|
||||||
|
|
||||||
def updateCommitComment(commentId: Int, content: String)(implicit s: Session) =
|
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) = {
|
||||||
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
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package gitbucket.core.service
|
|||||||
import gitbucket.core.controller.Context
|
import gitbucket.core.controller.Context
|
||||||
import gitbucket.core.model.Issue
|
import gitbucket.core.model.Issue
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.util.Notifier
|
import gitbucket.core.util.Notifier
|
||||||
import profile.simple._
|
|
||||||
|
|
||||||
trait HandleCommentService {
|
trait HandleCommentService {
|
||||||
self: RepositoryService with IssuesService with ActivityService
|
self: RepositoryService with IssuesService with ActivityService
|
||||||
@@ -17,9 +17,9 @@ trait HandleCommentService {
|
|||||||
*/
|
*/
|
||||||
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) = {
|
||||||
|
context.loginAccount.flatMap { loginAccount =>
|
||||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
val userName = context.loginAccount.get.userName
|
val userName = loginAccount.userName
|
||||||
|
|
||||||
val (action, recordActivity) = actionOpt
|
val (action, recordActivity) = actionOpt
|
||||||
.collect {
|
.collect {
|
||||||
@@ -49,12 +49,12 @@ trait HandleCommentService {
|
|||||||
|
|
||||||
// extract references and create refer comment
|
// extract references and create refer comment
|
||||||
content.map { content =>
|
content.map { content =>
|
||||||
createReferComment(owner, name, issue, content, context.loginAccount.get)
|
createReferComment(owner, name, issue, content, loginAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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, loginAccount) }
|
||||||
case Some(act) => {
|
case Some(act) => {
|
||||||
val webHookAction = act match {
|
val webHookAction = act match {
|
||||||
case "open" => "opened"
|
case "open" => "opened"
|
||||||
@@ -63,9 +63,9 @@ trait HandleCommentService {
|
|||||||
case _ => act
|
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, loginAccount)
|
||||||
} else {
|
} else {
|
||||||
callIssuesWebHook(webHookAction, repository, issue, context.baseUrl, context.loginAccount.get)
|
callIssuesWebHook(webHookAction, repository, issue, context.baseUrl, loginAccount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,5 +89,6 @@ trait HandleCommentService {
|
|||||||
commentId.map( issue -> _ )
|
commentId.map( issue -> _ )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package gitbucket.core.service
|
||||||
|
|
||||||
|
import gitbucket.core.controller.Context
|
||||||
|
import gitbucket.core.model.{Account, Issue}
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
|
import gitbucket.core.util.Notifier
|
||||||
|
import gitbucket.core.util.Implicits._
|
||||||
|
|
||||||
|
// TODO: Merged with IssuesService?
|
||||||
|
trait IssueCreationService {
|
||||||
|
|
||||||
|
self: RepositoryService with WebHookIssueCommentService with LabelsService with IssuesService with ActivityService =>
|
||||||
|
|
||||||
|
def createIssue(repository: RepositoryInfo, title:String, body:Option[String],
|
||||||
|
assignee: Option[String], milestoneId: Option[Int], labelNames: Seq[String],
|
||||||
|
loginAccount: Account)(implicit context: Context, s: Session) : Issue = {
|
||||||
|
|
||||||
|
val owner = repository.owner
|
||||||
|
val name = repository.name
|
||||||
|
val userName = loginAccount.userName
|
||||||
|
val manageable = isIssueManageable(repository)
|
||||||
|
|
||||||
|
// insert issue
|
||||||
|
val issueId = insertIssue(owner, name, userName, title, body,
|
||||||
|
if (manageable) assignee else None,
|
||||||
|
if (manageable) milestoneId else None)
|
||||||
|
val issue: Issue = getIssue(owner, name, issueId.toString).get
|
||||||
|
|
||||||
|
// insert labels
|
||||||
|
if (manageable) {
|
||||||
|
val labels = getLabels(owner, name)
|
||||||
|
labelNames.map { labelName =>
|
||||||
|
labels.find(_.labelName == labelName).map { label =>
|
||||||
|
registerIssueLabel(owner, name, issueId, label.labelId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// record activity
|
||||||
|
recordCreateIssueActivity(owner, name, userName, issueId, title)
|
||||||
|
|
||||||
|
// extract references and create refer comment
|
||||||
|
createReferComment(owner, name, issue, title + " " + body.getOrElse(""), loginAccount)
|
||||||
|
|
||||||
|
// call web hooks
|
||||||
|
callIssuesWebHook("opened", repository, issue, context.baseUrl, loginAccount)
|
||||||
|
|
||||||
|
// notifications
|
||||||
|
Notifier().toNotify(repository, issue, body.getOrElse("")) {
|
||||||
|
Notifier.msgIssue(s"${context.baseUrl}/${owner}/${name}/issues/${issueId}")
|
||||||
|
}
|
||||||
|
issue
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an logged-in user can manage issues.
|
||||||
|
*/
|
||||||
|
protected def isIssueManageable(repository: RepositoryInfo)(implicit context: Context, s: Session): Boolean = {
|
||||||
|
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether an logged-in user can post issues.
|
||||||
|
*/
|
||||||
|
protected def isIssueEditable(repository: RepositoryInfo)(implicit context: Context, s: Session): 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.model.Profile._
|
|
||||||
import gitbucket.core.util.JGitUtil.CommitInfo
|
import gitbucket.core.util.JGitUtil.CommitInfo
|
||||||
import gitbucket.core.util.StringUtil
|
|
||||||
import profile.simple._
|
|
||||||
|
|
||||||
import gitbucket.core.util.StringUtil._
|
import gitbucket.core.util.StringUtil._
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.model._
|
import gitbucket.core.model.{Issue, PullRequest, IssueComment, IssueLabel, Label, Account, Repository, CommitState, Role}
|
||||||
|
import gitbucket.core.model.Profile._
|
||||||
|
import gitbucket.core.model.Profile.profile._
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
|
import gitbucket.core.model.Profile.dateColumnType
|
||||||
|
|
||||||
import scala.slick.jdbc.{StaticQuery => Q}
|
|
||||||
import Q.interpolation
|
|
||||||
|
|
||||||
|
|
||||||
trait IssuesService {
|
trait IssuesService {
|
||||||
@@ -23,17 +21,21 @@ trait IssuesService {
|
|||||||
else None
|
else None
|
||||||
|
|
||||||
def getComments(owner: String, repository: String, issueId: Int)(implicit s: Session) =
|
def getComments(owner: String, repository: String, issueId: Int)(implicit s: Session) =
|
||||||
IssueComments filter (_.byIssue(owner, repository, issueId)) list
|
IssueComments filter (_.byIssue(owner, repository, issueId)) sortBy(_.commentId asc) list
|
||||||
|
|
||||||
/** @return IssueComment and commentedUser and Issue */
|
/** @return IssueComment and commentedUser and Issue */
|
||||||
def getCommentsForApi(owner: String, repository: String, issueId: Int)(implicit s: Session): List[(IssueComment, Account, Issue)] =
|
def getCommentsForApi(owner: String, repository: String, issueId: Int)(implicit s: Session): List[(IssueComment, Account, Issue)] =
|
||||||
IssueComments.filter(_.byIssue(owner, repository, issueId))
|
IssueComments.filter(_.byIssue(owner, repository, issueId))
|
||||||
.filter(_.action inSetBind Set("comment" , "close_comment", "reopen_comment"))
|
.filter(_.action inSetBind Set("comment" , "close_comment", "reopen_comment"))
|
||||||
.innerJoin(Accounts).on( (t1, t2) => t1.commentedUserName === t2.userName )
|
.join(Accounts).on( (t1, t2) => t1.commentedUserName === t2.userName )
|
||||||
.innerJoin(Issues).on{ case ((t1, t2), t3) => t3.byIssue(t1.userName, t1.repositoryName, t1.issueId) }
|
.join(Issues).on{ case ((t1, t2), t3) => t3.byIssue(t1.userName, t1.repositoryName, t1.issueId) }
|
||||||
.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 =>
|
||||||
@@ -43,7 +45,7 @@ trait IssuesService {
|
|||||||
|
|
||||||
def getIssueLabels(owner: String, repository: String, issueId: Int)(implicit s: Session) =
|
def getIssueLabels(owner: String, repository: String, issueId: Int)(implicit s: Session) =
|
||||||
IssueLabels
|
IssueLabels
|
||||||
.innerJoin(Labels).on { (t1, t2) =>
|
.join(Labels).on { (t1, t2) =>
|
||||||
t1.byLabel(t2.userName, t2.repositoryName, t2.labelId)
|
t1.byLabel(t2.userName, t2.repositoryName, t2.labelId)
|
||||||
}
|
}
|
||||||
.filter ( _._1.byIssue(owner, repository, issueId) )
|
.filter ( _._1.byIssue(owner, repository, issueId) )
|
||||||
@@ -77,10 +79,10 @@ trait IssuesService {
|
|||||||
filterUser: Map[String, String])(implicit s: Session): Map[String, Int] = {
|
filterUser: Map[String, String])(implicit s: Session): Map[String, Int] = {
|
||||||
|
|
||||||
searchIssueQuery(Seq(owner -> repository), condition.copy(labels = Set.empty), false)
|
searchIssueQuery(Seq(owner -> repository), condition.copy(labels = Set.empty), false)
|
||||||
.innerJoin(IssueLabels).on { (t1, t2) =>
|
.join(IssueLabels).on { (t1, t2) =>
|
||||||
t1.byIssue(t2.userName, t2.repositoryName, t2.issueId)
|
t1.byIssue(t2.userName, t2.repositoryName, t2.issueId)
|
||||||
}
|
}
|
||||||
.innerJoin(Labels).on { case ((t1, t2), t3) =>
|
.join(Labels).on { case ((t1, t2), t3) =>
|
||||||
t2.byLabel(t3.userName, t3.repositoryName, t3.labelId)
|
t2.byLabel(t3.userName, t3.repositoryName, t3.labelId)
|
||||||
}
|
}
|
||||||
.groupBy { case ((t1, t2), t3) =>
|
.groupBy { case ((t1, t2), t3) =>
|
||||||
@@ -89,63 +91,27 @@ trait IssuesService {
|
|||||||
.map { case (labelName, t) =>
|
.map { case (labelName, t) =>
|
||||||
labelName -> t.length
|
labelName -> t.length
|
||||||
}
|
}
|
||||||
.toMap
|
.list.toMap
|
||||||
}
|
}
|
||||||
|
|
||||||
def getCommitStatues(issueList:Seq[(String, String, Int)])(implicit s: Session) :Map[(String, String, Int), CommitStatusInfo] ={
|
def getCommitStatues(userName: String, repositoryName: String, issueId: Int)(implicit s: Session): Option[CommitStatusInfo] = {
|
||||||
if(issueList.isEmpty){
|
val status = PullRequests
|
||||||
Map.empty
|
.filter { pr => (pr.userName === userName.bind) && (pr.repositoryName === repositoryName.bind) && (pr.issueId === issueId.bind) }
|
||||||
|
.join(CommitStatuses).on((pr, cs) => pr.userName === cs.userName && pr.repositoryName === cs.repositoryName && pr.commitIdTo === cs.commitId)
|
||||||
|
.list
|
||||||
|
|
||||||
|
if(status.nonEmpty){
|
||||||
|
val (_, cs) = status.head
|
||||||
|
Some(CommitStatusInfo(
|
||||||
|
count = status.length,
|
||||||
|
successCount = status.filter(_._2.state == CommitState.SUCCESS).length,
|
||||||
|
context = (if(status.length == 1) Some(cs.context) else None),
|
||||||
|
state = (if(status.length == 1) Some(cs.state) else None),
|
||||||
|
targetUrl = (if(status.length == 1) cs.targetUrl else None),
|
||||||
|
description = (if(status.length == 1) cs.description else None)
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
import scala.slick.jdbc._
|
None
|
||||||
val issueIdQuery = issueList.map(i => "(PR.USER_NAME=? AND PR.REPOSITORY_NAME=? AND PR.ISSUE_ID=?)").mkString(" OR ")
|
|
||||||
implicit val qset = SetParameter[Seq[(String, String, Int)]] {
|
|
||||||
case (seq, pp) =>
|
|
||||||
for (a <- seq) {
|
|
||||||
pp.setString(a._1)
|
|
||||||
pp.setString(a._2)
|
|
||||||
pp.setInt(a._3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
import gitbucket.core.model.Profile.commitStateColumnType
|
|
||||||
val query = Q.query[Seq[(String, String, Int)], (String, String, Int, Int, Int, Option[String], Option[CommitState], Option[String], Option[String])](s"""
|
|
||||||
SELECT
|
|
||||||
SUMM.USER_NAME,
|
|
||||||
SUMM.REPOSITORY_NAME,
|
|
||||||
SUMM.ISSUE_ID,
|
|
||||||
CS_ALL,
|
|
||||||
CS_SUCCESS,
|
|
||||||
CSD.CONTEXT,
|
|
||||||
CSD.STATE,
|
|
||||||
CSD.TARGET_URL,
|
|
||||||
CSD.DESCRIPTION
|
|
||||||
FROM (
|
|
||||||
SELECT
|
|
||||||
PR.USER_NAME,
|
|
||||||
PR.REPOSITORY_NAME,
|
|
||||||
PR.ISSUE_ID,
|
|
||||||
COUNT(CS.STATE) AS CS_ALL,
|
|
||||||
CSS.CS_SUCCESS AS CS_SUCCESS,
|
|
||||||
PR.COMMIT_ID_TO AS COMMIT_ID
|
|
||||||
FROM PULL_REQUEST PR
|
|
||||||
JOIN COMMIT_STATUS CS
|
|
||||||
ON PR.USER_NAME = CS.USER_NAME AND PR.REPOSITORY_NAME = CS.REPOSITORY_NAME AND PR.COMMIT_ID_TO = CS.COMMIT_ID
|
|
||||||
JOIN (
|
|
||||||
SELECT
|
|
||||||
COUNT(*) AS CS_SUCCESS,
|
|
||||||
USER_NAME,
|
|
||||||
REPOSITORY_NAME,
|
|
||||||
COMMIT_ID
|
|
||||||
FROM COMMIT_STATUS WHERE STATE = 'success' GROUP BY USER_NAME, REPOSITORY_NAME, COMMIT_ID
|
|
||||||
) CSS ON PR.USER_NAME = CSS.USER_NAME AND PR.REPOSITORY_NAME = CSS.REPOSITORY_NAME AND PR.COMMIT_ID_TO = CSS.COMMIT_ID
|
|
||||||
WHERE $issueIdQuery
|
|
||||||
GROUP BY PR.USER_NAME, PR.REPOSITORY_NAME, PR.ISSUE_ID, CSS.CS_SUCCESS
|
|
||||||
) as SUMM
|
|
||||||
LEFT OUTER JOIN COMMIT_STATUS CSD
|
|
||||||
ON SUMM.CS_ALL = 1 AND SUMM.COMMIT_ID = CSD.COMMIT_ID""");
|
|
||||||
query(issueList).list.map {
|
|
||||||
case(userName, repositoryName, issueId, count, successCount, context, state, targetUrl, description) =>
|
|
||||||
(userName, repositoryName, issueId) -> CommitStatusInfo(count, successCount, context, state, targetUrl, description)
|
|
||||||
}.toMap
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,28 +129,39 @@ 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), i), t3) => t1.byIssue(t3.userName, t3.repositoryName, t3.issueId) }
|
.joinLeft (IssueLabels) .on { case (((t1, t2), i), t3) => t1.byIssue(t3.userName, t3.repositoryName, t3.issueId) }
|
||||||
.leftJoin (Labels) .on { case ((((t1, t2), i), t3), t4) => t3.byLabel(t4.userName, t4.repositoryName, t4.labelId) }
|
.joinLeft (Labels) .on { case ((((t1, t2), i), t3), t4) => t3.map(_.byLabel(t4.userName, t4.repositoryName, t4.labelId)) }
|
||||||
.leftJoin (Milestones) .on { case (((((t1, t2), i), t3), t4), t5) => t1.byMilestone(t5.userName, t5.repositoryName, t5.milestoneId) }
|
.joinLeft (Milestones) .on { case (((((t1, t2), i), t3), t4), t5) => t1.byMilestone(t5.userName, t5.repositoryName, t5.milestoneId) }
|
||||||
.sortBy { case (((((t1, t2), i), t3), t4), t5) => i asc }
|
.sortBy { case (((((t1, t2), i), t3), t4), t5) => i asc }
|
||||||
.map { case (((((t1, t2), i), t3), t4), t5) => (t1, t2.commentCount, t4.labelId.?, t4.labelName.?, t4.color.?, t5.title.?) }
|
.map { case (((((t1, t2), i), t3), t4), t5) =>
|
||||||
|
(t1, t2.commentCount, t4.map(_.labelId), t4.map(_.labelName), t4.map(_.color), t5.map(_.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)))
|
|
||||||
|
|
||||||
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))} toList,
|
||||||
Label(issue.userName, issue.repositoryName, _, t._4.get, t._5.get)
|
|
||||||
)} toList,
|
|
||||||
milestone,
|
milestone,
|
||||||
commentCount,
|
commentCount,
|
||||||
status.get(issue.userName, issue.repositoryName, issue.issueId))
|
getCommitStatues(issue.userName, issue.repositoryName, issue.issueId))
|
||||||
}} toList
|
}} toList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** for api
|
||||||
|
* @return (issue, issueUser, commentCount)
|
||||||
|
*/
|
||||||
|
def searchIssueByApi(condition: IssueSearchCondition, offset: Int, limit: Int, repos: (String, String)*)
|
||||||
|
(implicit s: Session): List[(Issue, Account)] = {
|
||||||
|
// get issues and comment count and labels
|
||||||
|
searchIssueQueryBase(condition, false, offset, limit, repos)
|
||||||
|
.join(Accounts).on { case (((t1, t2), i), t3) => t3.userName === t1.openedUserName }
|
||||||
|
.sortBy { case (((t1, t2), i), t3) => i asc }
|
||||||
|
.map { case (((t1, t2), i), t3) => (t1, t3) }
|
||||||
|
.list
|
||||||
|
}
|
||||||
|
|
||||||
/** for api
|
/** for api
|
||||||
* @return (issue, issueUser, commentCount, pullRequest, headRepo, headOwner)
|
* @return (issue, issueUser, commentCount, pullRequest, headRepo, headOwner)
|
||||||
*/
|
*/
|
||||||
@@ -192,10 +169,10 @@ trait IssuesService {
|
|||||||
(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), i), t3) => t3.byPrimaryKey(t1.userName, t1.repositoryName, t1.issueId) }
|
.join(PullRequests).on { case (((t1, t2), i), t3) => t3.byPrimaryKey(t1.userName, t1.repositoryName, t1.issueId) }
|
||||||
.innerJoin(Repositories).on { case ((((t1, t2), i), t3), t4) => t4.byRepository(t1.userName, t1.repositoryName) }
|
.join(Repositories).on { case ((((t1, t2), i), t3), t4) => t4.byRepository(t1.userName, t1.repositoryName) }
|
||||||
.innerJoin(Accounts).on { case (((((t1, t2), i), t3), t4), t5) => t5.userName === t1.openedUserName }
|
.join(Accounts).on { case (((((t1, t2), i), t3), t4), t5) => t5.userName === t1.openedUserName }
|
||||||
.innerJoin(Accounts).on { case ((((((t1, t2), i), t3), t4), t5), t6) => t6.userName === t4.userName }
|
.join(Accounts).on { case ((((((t1, t2), i), t3), t4), t5), t6) => t6.userName === t4.userName }
|
||||||
.sortBy { case ((((((t1, t2), i), t3), t4), t5), t6) => i asc }
|
.sortBy { case ((((((t1, t2), i), t3), t4), t5), t6) => i asc }
|
||||||
.map { case ((((((t1, t2), i), t3), t4), t5), t6) => (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
|
||||||
@@ -204,17 +181,21 @@ trait IssuesService {
|
|||||||
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) }
|
.join(IssueOutline).on { (t1, t2) => t1.byIssue(t2.userName, t2.repositoryName, t2.issueId) }
|
||||||
.sortBy { case (t1, t2) => t1.issueId desc }
|
.sortBy { case (t1, t2) => t1.issueId desc }
|
||||||
.sortBy { case (t1, t2) =>
|
.sortBy { case (t1, t2) =>
|
||||||
(condition.sort match {
|
condition.sort match {
|
||||||
case "created" => t1.registeredDate
|
case "created" => condition.direction match {
|
||||||
case "comments" => t2.commentCount
|
case "asc" => t1.registeredDate asc
|
||||||
case "updated" => t1.updatedDate
|
case "desc" => t1.registeredDate desc
|
||||||
}) match {
|
}
|
||||||
case sort => condition.direction match {
|
case "comments" => condition.direction match {
|
||||||
case "asc" => sort asc
|
case "asc" => t2.commentCount asc
|
||||||
case "desc" => sort desc
|
case "desc" => t2.commentCount desc
|
||||||
|
}
|
||||||
|
case "updated" => condition.direction match {
|
||||||
|
case "asc" => t1.updatedDate asc
|
||||||
|
case "desc" => t1.updatedDate desc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,7 +209,7 @@ trait IssuesService {
|
|||||||
Issues filter { t1 =>
|
Issues filter { t1 =>
|
||||||
repos
|
repos
|
||||||
.map { case (owner, repository) => t1.byRepository(owner, repository) }
|
.map { case (owner, repository) => t1.byRepository(owner, repository) }
|
||||||
.foldLeft[Column[Boolean]](false) ( _ || _ ) &&
|
.foldLeft[Rep[Boolean]](false) ( _ || _ ) &&
|
||||||
(t1.closed === (condition.state == "closed").bind) &&
|
(t1.closed === (condition.state == "closed").bind) &&
|
||||||
(t1.milestoneId.? isEmpty, condition.milestone == Some(None)) &&
|
(t1.milestoneId.? isEmpty, condition.milestone == Some(None)) &&
|
||||||
(t1.assignedUserName.? isEmpty, condition.assigned == Some(None)) &&
|
(t1.assignedUserName.? isEmpty, condition.assigned == Some(None)) &&
|
||||||
@@ -264,7 +245,7 @@ trait IssuesService {
|
|||||||
} exists), condition.mentioned.isDefined)
|
} exists), condition.mentioned.isDefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
def createIssue(owner: String, repository: String, loginUser: String, title: String, content: Option[String],
|
def insertIssue(owner: String, repository: String, loginUser: String, title: String, content: Option[String],
|
||||||
assignedUserName: Option[String], milestoneId: Option[Int],
|
assignedUserName: Option[String], milestoneId: Option[Int],
|
||||||
isPullRequest: Boolean = false)(implicit s: Session) =
|
isPullRequest: Boolean = false)(implicit s: Session) =
|
||||||
// next id number
|
// next id number
|
||||||
@@ -298,8 +279,8 @@ trait IssuesService {
|
|||||||
IssueLabels filter(_.byPrimaryKey(owner, repository, issueId, labelId)) delete
|
IssueLabels filter(_.byPrimaryKey(owner, repository, issueId, labelId)) delete
|
||||||
|
|
||||||
def createComment(owner: String, repository: String, loginUser: String,
|
def createComment(owner: String, repository: String, loginUser: String,
|
||||||
issueId: Int, content: String, action: String)(implicit s: Session): Int =
|
issueId: Int, content: String, action: String)(implicit s: Session): Int = {
|
||||||
IssueComments.autoInc insert IssueComment(
|
IssueComments returning IssueComments.map(_.commentId) insert IssueComment(
|
||||||
userName = owner,
|
userName = owner,
|
||||||
repositoryName = repository,
|
repositoryName = repository,
|
||||||
issueId = issueId,
|
issueId = issueId,
|
||||||
@@ -308,15 +289,14 @@ trait IssuesService {
|
|||||||
content = content,
|
content = content,
|
||||||
registeredDate = currentDate,
|
registeredDate = currentDate,
|
||||||
updatedDate = currentDate)
|
updatedDate = currentDate)
|
||||||
|
}
|
||||||
|
|
||||||
def updateIssue(owner: String, repository: String, issueId: Int,
|
def updateIssue(owner: String, repository: String, issueId: Int, title: String, content: Option[String])(implicit s: Session) = {
|
||||||
title: String, content: Option[String])(implicit s: Session) =
|
|
||||||
Issues
|
Issues
|
||||||
.filter (_.byPrimaryKey(owner, repository, issueId))
|
.filter (_.byPrimaryKey(owner, repository, issueId))
|
||||||
.map { t =>
|
.map { t => (t.title, t.content.?, t.updatedDate) }
|
||||||
(t.title, t.content.?, t.updatedDate)
|
|
||||||
}
|
|
||||||
.update (title, content, currentDate)
|
.update (title, content, currentDate)
|
||||||
|
}
|
||||||
|
|
||||||
def updateAssignedUserName(owner: String, repository: String, issueId: Int,
|
def updateAssignedUserName(owner: String, repository: String, issueId: Int,
|
||||||
assignedUserName: Option[String])(implicit s: Session) =
|
assignedUserName: Option[String])(implicit s: Session) =
|
||||||
@@ -326,24 +306,16 @@ trait IssuesService {
|
|||||||
milestoneId: Option[Int])(implicit s: Session) =
|
milestoneId: Option[Int])(implicit s: Session) =
|
||||||
Issues.filter (_.byPrimaryKey(owner, repository, issueId)).map(_.milestoneId?).update (milestoneId)
|
Issues.filter (_.byPrimaryKey(owner, repository, issueId)).map(_.milestoneId?).update (milestoneId)
|
||||||
|
|
||||||
def updateComment(commentId: Int, content: String)(implicit s: Session) =
|
def updateComment(commentId: Int, content: String)(implicit s: Session) = {
|
||||||
IssueComments
|
IssueComments.filter (_.byPrimaryKey(commentId)).map(t => (t.content, t.updatedDate)).update(content, currentDate)
|
||||||
.filter (_.byPrimaryKey(commentId))
|
|
||||||
.map { t =>
|
|
||||||
t.content -> t.updatedDate
|
|
||||||
}
|
}
|
||||||
.update (content, currentDate)
|
|
||||||
|
|
||||||
def deleteComment(commentId: Int)(implicit s: Session) =
|
def deleteComment(commentId: Int)(implicit s: Session) =
|
||||||
IssueComments filter (_.byPrimaryKey(commentId)) delete
|
IssueComments filter (_.byPrimaryKey(commentId)) delete
|
||||||
|
|
||||||
def updateClosed(owner: String, repository: String, issueId: Int, closed: Boolean)(implicit s: Session) =
|
def updateClosed(owner: String, repository: String, issueId: Int, closed: Boolean)(implicit s: Session) = {
|
||||||
Issues
|
(Issues filter (_.byPrimaryKey(owner, repository, issueId)) map(t => (t.closed, t.updatedDate))).update((closed, currentDate))
|
||||||
.filter (_.byPrimaryKey(owner, repository, issueId))
|
|
||||||
.map { t =>
|
|
||||||
t.closed -> t.updatedDate
|
|
||||||
}
|
}
|
||||||
.update (closed, currentDate)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search issues by keyword.
|
* Search issues by keyword.
|
||||||
@@ -355,13 +327,13 @@ trait IssuesService {
|
|||||||
*/
|
*/
|
||||||
def searchIssuesByKeyword(owner: String, repository: String, query: String)
|
def searchIssuesByKeyword(owner: String, repository: String, query: String)
|
||||||
(implicit s: Session): List[(Issue, Int, String)] = {
|
(implicit s: Session): List[(Issue, Int, String)] = {
|
||||||
import slick.driver.JdbcDriver.likeEncode
|
//import slick.driver.JdbcDriver.likeEncode
|
||||||
val keywords = splitWords(query.toLowerCase)
|
val keywords = splitWords(query.toLowerCase)
|
||||||
|
|
||||||
// Search Issue
|
// Search Issue
|
||||||
val issues = Issues
|
val issues = Issues
|
||||||
.filter(_.byRepository(owner, repository))
|
.filter(_.byRepository(owner, repository))
|
||||||
.innerJoin(IssueOutline).on { case (t1, t2) =>
|
.join(IssueOutline).on { case (t1, t2) =>
|
||||||
t1.byIssue(t2.userName, t2.repositoryName, t2.issueId)
|
t1.byIssue(t2.userName, t2.repositoryName, t2.issueId)
|
||||||
}
|
}
|
||||||
.filter { case (t1, t2) =>
|
.filter { case (t1, t2) =>
|
||||||
@@ -377,10 +349,10 @@ trait IssuesService {
|
|||||||
// Search IssueComment
|
// Search IssueComment
|
||||||
val comments = IssueComments
|
val comments = IssueComments
|
||||||
.filter(_.byRepository(owner, repository))
|
.filter(_.byRepository(owner, repository))
|
||||||
.innerJoin(Issues).on { case (t1, t2) =>
|
.join(Issues).on { case (t1, t2) =>
|
||||||
t1.byIssue(t2.userName, t2.repositoryName, t2.issueId)
|
t1.byIssue(t2.userName, t2.repositoryName, t2.issueId)
|
||||||
}
|
}
|
||||||
.innerJoin(IssueOutline).on { case ((t1, t2), t3) =>
|
.join(IssueOutline).on { case ((t1, t2), t3) =>
|
||||||
t2.byIssue(t3.userName, t3.repositoryName, t3.issueId)
|
t2.byIssue(t3.userName, t3.repositoryName, t3.issueId)
|
||||||
}
|
}
|
||||||
.filter { case ((t1, t2), t3) =>
|
.filter { case ((t1, t2), t3) =>
|
||||||
@@ -412,7 +384,7 @@ trait IssuesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def createReferComment(owner: String, repository: String, fromIssue: Issue, message: String, loginAccount: Account)(implicit s: Session) = {
|
def createReferComment(owner: String, repository: String, fromIssue: Issue, message: String, loginAccount: Account)(implicit s: Session) = {
|
||||||
StringUtil.extractIssueId(message).foreach { issueId =>
|
extractIssueId(message).foreach { issueId =>
|
||||||
val content = fromIssue.issueId + ":" + fromIssue.title
|
val content = fromIssue.issueId + ":" + fromIssue.title
|
||||||
if(getIssue(owner, repository, issueId).isDefined){
|
if(getIssue(owner, repository, issueId).isDefined){
|
||||||
// Not add if refer comment already exist.
|
// Not add if refer comment already exist.
|
||||||
@@ -424,7 +396,7 @@ trait IssuesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def createIssueComment(owner: String, repository: String, commit: CommitInfo)(implicit s: Session) = {
|
def createIssueComment(owner: String, repository: String, commit: CommitInfo)(implicit s: Session) = {
|
||||||
StringUtil.extractIssueId(commit.fullMessage).foreach { issueId =>
|
extractIssueId(commit.fullMessage).foreach { issueId =>
|
||||||
if(getIssue(owner, repository, issueId).isDefined){
|
if(getIssue(owner, repository, issueId).isDefined){
|
||||||
getAccountByMailAddress(commit.committerEmailAddress).foreach { account =>
|
getAccountByMailAddress(commit.committerEmailAddress).foreach { account =>
|
||||||
createComment(owner, repository, account.userName, issueId.toInt, commit.fullMessage + " " + commit.id, "commit")
|
createComment(owner, repository, account.userName, issueId.toInt, commit.fullMessage + " " + commit.id, "commit")
|
||||||
@@ -484,6 +456,7 @@ object IssuesService {
|
|||||||
case ("comments", "asc" ) => Some("sort:comments-asc")
|
case ("comments", "asc" ) => Some("sort:comments-asc")
|
||||||
case ("updated" , "desc") => Some("sort:updated-desc")
|
case ("updated" , "desc") => Some("sort:updated-desc")
|
||||||
case ("updated" , "asc" ) => Some("sort:updated-asc")
|
case ("updated" , "asc" ) => Some("sort:updated-asc")
|
||||||
|
case x => throw new MatchError(x)
|
||||||
},
|
},
|
||||||
visibility.map(visibility => s"visibility:${visibility}")
|
visibility.map(visibility => s"visibility:${visibility}")
|
||||||
).flatten ++
|
).flatten ++
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package gitbucket.core.service
|
|||||||
|
|
||||||
import gitbucket.core.model.Label
|
import gitbucket.core.model.Label
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import profile.simple._
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
|
|
||||||
trait LabelsService {
|
trait LabelsService {
|
||||||
|
|
||||||
@@ -15,13 +15,14 @@ trait LabelsService {
|
|||||||
def getLabel(owner: String, repository: String, labelName: String)(implicit s: Session): Option[Label] =
|
def getLabel(owner: String, repository: String, labelName: String)(implicit s: Session): Option[Label] =
|
||||||
Labels.filter(_.byLabel(owner, repository, labelName)).firstOption
|
Labels.filter(_.byLabel(owner, repository, labelName)).firstOption
|
||||||
|
|
||||||
def createLabel(owner: String, repository: String, labelName: String, color: String)(implicit s: Session): Int =
|
def createLabel(owner: String, repository: String, labelName: String, color: String)(implicit s: Session): Int = {
|
||||||
Labels returning Labels.map(_.labelId) += Label(
|
Labels returning Labels.map(_.labelId) insert Label(
|
||||||
userName = owner,
|
userName = owner,
|
||||||
repositoryName = repository,
|
repositoryName = repository,
|
||||||
labelName = labelName,
|
labelName = labelName,
|
||||||
color = color
|
color = color
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
def updateLabel(owner: String, repository: String, labelId: Int, labelName: String, color: String)
|
def updateLabel(owner: String, repository: String, labelId: Int, labelName: String, color: String)
|
||||||
(implicit s: Session): Unit =
|
(implicit s: Session): Unit =
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.model.Account
|
import gitbucket.core.model.Account
|
||||||
import gitbucket.core.util.LockUtil
|
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import gitbucket.core.util.Implicits._
|
|
||||||
import gitbucket.core.util.ControlUtil._
|
import gitbucket.core.util.ControlUtil._
|
||||||
|
|
||||||
import org.eclipse.jgit.merge.MergeStrategy
|
import org.eclipse.jgit.merge.MergeStrategy
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ package gitbucket.core.service
|
|||||||
|
|
||||||
import gitbucket.core.model.Milestone
|
import gitbucket.core.model.Milestone
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import profile.simple._
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
// TODO Why is direct import required?
|
|
||||||
import gitbucket.core.model.Profile.dateColumnType
|
import gitbucket.core.model.Profile.dateColumnType
|
||||||
|
|
||||||
trait MilestonesService {
|
trait MilestonesService {
|
||||||
@@ -44,6 +43,7 @@ trait MilestonesService {
|
|||||||
.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 }
|
||||||
|
.list
|
||||||
.toMap
|
.toMap
|
||||||
|
|
||||||
getMilestones(owner, repository).map { milestone =>
|
getMilestones(owner, repository).map { milestone =>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.model._
|
import gitbucket.core.model.{ProtectedBranch, ProtectedBranchContext, CommitState}
|
||||||
import gitbucket.core.model.Profile._
|
|
||||||
import gitbucket.core.plugin.ReceiveHook
|
import gitbucket.core.plugin.ReceiveHook
|
||||||
import profile.simple._
|
import gitbucket.core.model.Profile._
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
|
|
||||||
import org.eclipse.jgit.transport.{ReceivePack, ReceiveCommand}
|
import org.eclipse.jgit.transport.{ReceivePack, ReceiveCommand}
|
||||||
|
|
||||||
@@ -12,14 +12,14 @@ trait ProtectedBranchService {
|
|||||||
import ProtectedBranchService._
|
import ProtectedBranchService._
|
||||||
private def getProtectedBranchInfoOpt(owner: String, repository: String, branch: String)(implicit session: Session): Option[ProtectedBranchInfo] =
|
private def getProtectedBranchInfoOpt(owner: String, repository: String, branch: String)(implicit session: Session): Option[ProtectedBranchInfo] =
|
||||||
ProtectedBranches
|
ProtectedBranches
|
||||||
.leftJoin(ProtectedBranchContexts)
|
.joinLeft(ProtectedBranchContexts)
|
||||||
.on{ case (pb, c) => pb.byBranch(c.userName, c.repositoryName, c.branch) }
|
.on { case (pb, c) => pb.byBranch(c.userName, c.repositoryName, c.branch) }
|
||||||
.map{ case (pb, c) => pb -> c.context.? }
|
.map { case (pb, c) => pb -> c.map(_.context) }
|
||||||
.filter(_._1.byPrimaryKey(owner, repository, branch))
|
.filter(_._1.byPrimaryKey(owner, repository, branch))
|
||||||
.list
|
.list
|
||||||
.groupBy(_._1)
|
.groupBy(_._1)
|
||||||
.map(p => p._1 -> p._2.flatMap(_._2))
|
.map { p => p._1 -> p._2.flatMap(_._2) }
|
||||||
.map{ case (t1, contexts) =>
|
.map { case (t1, contexts) =>
|
||||||
new ProtectedBranchInfo(t1.userName, t1.repositoryName, true, contexts, t1.statusCheckAdmin)
|
new ProtectedBranchInfo(t1.userName, t1.repositoryName, true, contexts, t1.statusCheckAdmin)
|
||||||
}.headOption
|
}.headOption
|
||||||
|
|
||||||
@@ -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,21 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.model.{Account, Issue, PullRequest, WebHook, CommitStatus, CommitState}
|
import gitbucket.core.model.{Issue, PullRequest, CommitStatus, CommitState, CommitComment}
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
|
import difflib.{Delta, DiffUtils}
|
||||||
|
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 profile.simple._
|
import gitbucket.core.util.JGitUtil.{CommitInfo, DiffInfo}
|
||||||
|
import gitbucket.core.view
|
||||||
|
import gitbucket.core.view.helpers
|
||||||
|
import org.eclipse.jgit.api.Git
|
||||||
|
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)
|
||||||
@@ -26,7 +35,7 @@ trait PullRequestService { self: IssuesService =>
|
|||||||
def getPullRequestCountGroupByUser(closed: Boolean, owner: Option[String], repository: Option[String])
|
def getPullRequestCountGroupByUser(closed: Boolean, owner: Option[String], repository: Option[String])
|
||||||
(implicit s: Session): List[PullRequestCount] =
|
(implicit s: Session): List[PullRequestCount] =
|
||||||
PullRequests
|
PullRequests
|
||||||
.innerJoin(Issues).on { (t1, t2) => t1.byPrimaryKey(t2.userName, t2.repositoryName, t2.issueId) }
|
.join(Issues).on { (t1, t2) => t1.byPrimaryKey(t2.userName, t2.repositoryName, t2.issueId) }
|
||||||
.filter { case (t1, t2) =>
|
.filter { case (t1, t2) =>
|
||||||
(t2.closed === closed.bind) &&
|
(t2.closed === closed.bind) &&
|
||||||
(t1.userName === owner.get.bind, owner.isDefined) &&
|
(t1.userName === owner.get.bind, owner.isDefined) &&
|
||||||
@@ -73,7 +82,7 @@ trait PullRequestService { self: IssuesService =>
|
|||||||
def getPullRequestsByRequest(userName: String, repositoryName: String, branch: String, closed: Boolean)
|
def getPullRequestsByRequest(userName: String, repositoryName: String, branch: String, closed: Boolean)
|
||||||
(implicit s: Session): List[PullRequest] =
|
(implicit s: Session): List[PullRequest] =
|
||||||
PullRequests
|
PullRequests
|
||||||
.innerJoin(Issues).on { (t1, t2) => t1.byPrimaryKey(t2.userName, t2.repositoryName, t2.issueId) }
|
.join(Issues).on { (t1, t2) => t1.byPrimaryKey(t2.userName, t2.repositoryName, t2.issueId) }
|
||||||
.filter { case (t1, t2) =>
|
.filter { case (t1, t2) =>
|
||||||
(t1.requestUserName === userName.bind) &&
|
(t1.requestUserName === userName.bind) &&
|
||||||
(t1.requestRepositoryName === repositoryName.bind) &&
|
(t1.requestRepositoryName === repositoryName.bind) &&
|
||||||
@@ -93,7 +102,7 @@ trait PullRequestService { self: IssuesService =>
|
|||||||
def getPullRequestFromBranch(userName: String, repositoryName: String, branch: String, defaultBranch: String)
|
def getPullRequestFromBranch(userName: String, repositoryName: String, branch: String, defaultBranch: String)
|
||||||
(implicit s: Session): Option[(PullRequest, Issue)] =
|
(implicit s: Session): Option[(PullRequest, Issue)] =
|
||||||
PullRequests
|
PullRequests
|
||||||
.innerJoin(Issues).on { (t1, t2) => t1.byPrimaryKey(t2.userName, t2.repositoryName, t2.issueId) }
|
.join(Issues).on { (t1, t2) => t1.byPrimaryKey(t2.userName, t2.repositoryName, t2.issueId) }
|
||||||
.filter { case (t1, t2) =>
|
.filter { case (t1, t2) =>
|
||||||
(t1.requestUserName === userName.bind) &&
|
(t1.requestUserName === userName.bind) &&
|
||||||
(t1.requestRepositoryName === repositoryName.bind) &&
|
(t1.requestRepositoryName === repositoryName.bind) &&
|
||||||
@@ -111,9 +120,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +150,7 @@ trait PullRequestService { self: IssuesService =>
|
|||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
PullRequests
|
PullRequests
|
||||||
.innerJoin(Issues).on { (t1, t2) => t1.byPrimaryKey(t2.userName, t2.repositoryName, t2.issueId) }
|
.join(Issues).on { (t1, t2) => t1.byPrimaryKey(t2.userName, t2.repositoryName, t2.issueId) }
|
||||||
.filter { case (t1, t2) =>
|
.filter { case (t1, t2) =>
|
||||||
(t1.userName === userName.bind) &&
|
(t1.userName === userName.bind) &&
|
||||||
(t1.repositoryName === repositoryName.bind) &&
|
(t1.repositoryName === repositoryName.bind) &&
|
||||||
@@ -137,6 +163,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 {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
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
|
import gitbucket.core.util.JGitUtil
|
||||||
@@ -8,7 +8,6 @@ import gitbucket.core.model.Account
|
|||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.dircache.DirCache
|
import org.eclipse.jgit.dircache.DirCache
|
||||||
import org.eclipse.jgit.lib.{FileMode, Constants}
|
import org.eclipse.jgit.lib.{FileMode, Constants}
|
||||||
import profile.simple._
|
|
||||||
|
|
||||||
trait RepositoryCreationService {
|
trait RepositoryCreationService {
|
||||||
self: AccountService with RepositoryService with LabelsService with WikiService with ActivityService =>
|
self: AccountService with RepositoryService with LabelsService with WikiService with ActivityService =>
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import org.eclipse.jgit.revwalk.RevWalk
|
|||||||
import org.eclipse.jgit.treewalk.TreeWalk
|
import org.eclipse.jgit.treewalk.TreeWalk
|
||||||
import org.eclipse.jgit.lib.FileMode
|
import org.eclipse.jgit.lib.FileMode
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import profile.simple._
|
|
||||||
|
|
||||||
trait RepositorySearchService { self: IssuesService =>
|
trait RepositorySearchService { self: IssuesService =>
|
||||||
import RepositorySearchService._
|
import RepositorySearchService._
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
import gitbucket.core.controller.Context
|
import gitbucket.core.controller.Context
|
||||||
import gitbucket.core.model.{Collaborator, Repository, RepositoryOptions, Account, Role}
|
import gitbucket.core.util._
|
||||||
|
import gitbucket.core.util.ControlUtil._
|
||||||
|
import gitbucket.core.model.{Account, Collaborator, Repository, RepositoryOptions, Role}
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import gitbucket.core.util.JGitUtil
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import profile.simple._
|
import gitbucket.core.model.Profile.dateColumnType
|
||||||
|
import gitbucket.core.util.JGitUtil.FileInfo
|
||||||
|
import org.eclipse.jgit.api.Git
|
||||||
|
|
||||||
trait RepositoryService { self: AccountService =>
|
trait RepositoryService { self: AccountService =>
|
||||||
import RepositoryService._
|
import RepositoryService._
|
||||||
@@ -122,6 +126,11 @@ trait RepositoryService { self: AccountService =>
|
|||||||
userName = newUserName,
|
userName = newUserName,
|
||||||
repositoryName = newRepositoryName
|
repositoryName = newRepositoryName
|
||||||
)) :_*)
|
)) :_*)
|
||||||
|
IssueLabels.insertAll(issueLabels.map(x => x.copy(
|
||||||
|
labelId = newLabelMap(oldLabelMap(x.labelId)),
|
||||||
|
userName = newUserName,
|
||||||
|
repositoryName = newRepositoryName
|
||||||
|
)) :_*)
|
||||||
|
|
||||||
// TODO Drop transfered owner from collaborators?
|
// TODO Drop transfered owner from collaborators?
|
||||||
Collaborators.insertAll(collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
Collaborators.insertAll(collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
||||||
@@ -241,8 +250,7 @@ trait RepositoryService { self: AccountService =>
|
|||||||
}.list
|
}.list
|
||||||
}
|
}
|
||||||
|
|
||||||
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 in (GroupMembers.filter(_.userName === userName.bind).map(_.groupName))) ||
|
(t1.userName === userName.bind) || (t1.userName in (GroupMembers.filter(_.userName === userName.bind).map(_.groupName))) ||
|
||||||
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) &&
|
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) &&
|
||||||
@@ -320,8 +328,9 @@ trait RepositoryService { self: AccountService =>
|
|||||||
/**
|
/**
|
||||||
* Updates the last activity date of the repository.
|
* Updates the last activity date of the repository.
|
||||||
*/
|
*/
|
||||||
def updateLastActivityDate(userName: String, repositoryName: String)(implicit s: Session): Unit =
|
def updateLastActivityDate(userName: String, repositoryName: String)(implicit s: Session): Unit = {
|
||||||
Repositories.filter(_.byRepository(userName, repositoryName)).map(_.lastActivityDate).update(currentDate)
|
Repositories.filter(_.byRepository(userName, repositoryName)).map(_.lastActivityDate).update(currentDate)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save repository options.
|
* Save repository options.
|
||||||
@@ -358,7 +367,7 @@ trait RepositoryService { self: AccountService =>
|
|||||||
*/
|
*/
|
||||||
def getCollaborators(userName: String, repositoryName: String)(implicit s: Session): List[(Collaborator, Boolean)] =
|
def getCollaborators(userName: String, repositoryName: String)(implicit s: Session): List[(Collaborator, Boolean)] =
|
||||||
Collaborators
|
Collaborators
|
||||||
.innerJoin(Accounts).on(_.collaboratorName === _.userName)
|
.join(Accounts).on(_.collaboratorName === _.userName)
|
||||||
.filter { case (t1, t2) => t1.byRepository(userName, repositoryName) }
|
.filter { case (t1, t2) => t1.byRepository(userName, repositoryName) }
|
||||||
.map { case (t1, t2) => (t1, t2.groupAccount) }
|
.map { case (t1, t2) => (t1, t2.groupAccount) }
|
||||||
.sortBy { case (t1, t2) => t1.collaboratorName }
|
.sortBy { case (t1, t2) => t1.collaboratorName }
|
||||||
@@ -370,13 +379,13 @@ trait RepositoryService { self: AccountService =>
|
|||||||
*/
|
*/
|
||||||
def getCollaboratorUserNames(userName: String, repositoryName: String, filter: Seq[Role] = Nil)(implicit s: Session): List[String] = {
|
def getCollaboratorUserNames(userName: String, repositoryName: String, filter: Seq[Role] = Nil)(implicit s: Session): List[String] = {
|
||||||
val q1 = Collaborators
|
val q1 = Collaborators
|
||||||
.innerJoin(Accounts).on { case (t1, t2) => (t1.collaboratorName === t2.userName) && (t2.groupAccount === false.bind) }
|
.join(Accounts).on { case (t1, t2) => (t1.collaboratorName === t2.userName) && (t2.groupAccount === false.bind) }
|
||||||
.filter { case (t1, t2) => t1.byRepository(userName, repositoryName) }
|
.filter { case (t1, t2) => t1.byRepository(userName, repositoryName) }
|
||||||
.map { case (t1, t2) => (t1.collaboratorName, t1.role) }
|
.map { case (t1, t2) => (t1.collaboratorName, t1.role) }
|
||||||
|
|
||||||
val q2 = Collaborators
|
val q2 = Collaborators
|
||||||
.innerJoin(Accounts).on { case (t1, t2) => (t1.collaboratorName === t2.userName) && (t2.groupAccount === true.bind) }
|
.join(Accounts).on { case (t1, t2) => (t1.collaboratorName === t2.userName) && (t2.groupAccount === true.bind) }
|
||||||
.innerJoin(GroupMembers).on { case ((t1, t2), t3) => t2.userName === t3.groupName }
|
.join(GroupMembers).on { case ((t1, t2), t3) => t2.userName === t3.groupName }
|
||||||
.filter { case ((t1, t2), t3) => t1.byRepository(userName, repositoryName) }
|
.filter { case ((t1, t2), t3) => t1.byRepository(userName, repositoryName) }
|
||||||
.map { case ((t1, t2), t3) => (t3.userName, t1.role) }
|
.map { case ((t1, t2), t3) => (t3.userName, t1.role) }
|
||||||
|
|
||||||
@@ -416,31 +425,55 @@ trait RepositoryService { self: AccountService =>
|
|||||||
}
|
}
|
||||||
.sortBy(_.userName asc).map(t => t.userName -> t.repositoryName).list
|
.sortBy(_.userName asc).map(t => t.userName -> t.repositoryName).list
|
||||||
|
|
||||||
|
private val templateExtensions = Seq("md", "markdown")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns content of template set per repository.
|
||||||
|
*
|
||||||
|
* @param repository the repository information
|
||||||
|
* @param fileBaseName the file basename without extension of template
|
||||||
|
* @return The content of template if the repository has it, otherwise empty string.
|
||||||
|
*/
|
||||||
|
def getContentTemplate(repository: RepositoryInfo, fileBaseName: String)(implicit s: Session): String = {
|
||||||
|
val withExtFilenames = templateExtensions.map(extension => s"${fileBaseName.toLowerCase()}.${extension}")
|
||||||
|
|
||||||
|
def choiceTemplate(files: List[FileInfo]): Option[FileInfo] =
|
||||||
|
files.find { f =>
|
||||||
|
f.name.toLowerCase() == fileBaseName
|
||||||
|
}.orElse {
|
||||||
|
files.find(f => withExtFilenames.contains(f.name.toLowerCase()))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get template file from project root. When didn't find, will lookup default folder.
|
||||||
|
using(Git.open(Directory.getRepositoryDir(repository.owner, repository.name))) { git =>
|
||||||
|
choiceTemplate(JGitUtil.getFileList(git, repository.repository.defaultBranch, ".")).orElse {
|
||||||
|
choiceTemplate(JGitUtil.getFileList(git, repository.repository.defaultBranch, ".gitbucket"))
|
||||||
|
}.map { file =>
|
||||||
|
JGitUtil.getContentFromId(git, file.id, true).collect {
|
||||||
|
case bytes if FileUtil.isText(bytes) => StringUtil.convertFromByteArray(bytes)
|
||||||
|
}
|
||||||
|
} getOrElse None
|
||||||
|
} getOrElse ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -454,7 +487,6 @@ object RepositoryService {
|
|||||||
|
|
||||||
(id, path.substring(id.length).stripPrefix("/"))
|
(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"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package gitbucket.core.service
|
|||||||
|
|
||||||
import gitbucket.core.model.SshKey
|
import gitbucket.core.model.SshKey
|
||||||
import gitbucket.core.model.Profile._
|
import gitbucket.core.model.Profile._
|
||||||
import profile.simple._
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
|
|
||||||
trait SshKeyService {
|
trait SshKeyService {
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ trait SystemSettingsService {
|
|||||||
smtp.user.foreach(props.setProperty(SmtpUser, _))
|
smtp.user.foreach(props.setProperty(SmtpUser, _))
|
||||||
smtp.password.foreach(props.setProperty(SmtpPassword, _))
|
smtp.password.foreach(props.setProperty(SmtpPassword, _))
|
||||||
smtp.ssl.foreach(x => props.setProperty(SmtpSsl, x.toString))
|
smtp.ssl.foreach(x => props.setProperty(SmtpSsl, x.toString))
|
||||||
|
smtp.starttls.foreach(x => props.setProperty(SmtpStarttls, x.toString))
|
||||||
smtp.fromAddress.foreach(props.setProperty(SmtpFromAddress, _))
|
smtp.fromAddress.foreach(props.setProperty(SmtpFromAddress, _))
|
||||||
smtp.fromName.foreach(props.setProperty(SmtpFromName, _))
|
smtp.fromName.foreach(props.setProperty(SmtpFromName, _))
|
||||||
}
|
}
|
||||||
@@ -87,6 +88,7 @@ trait SystemSettingsService {
|
|||||||
getOptionValue(props, SmtpUser, None),
|
getOptionValue(props, SmtpUser, None),
|
||||||
getOptionValue(props, SmtpPassword, None),
|
getOptionValue(props, SmtpPassword, None),
|
||||||
getOptionValue[Boolean](props, SmtpSsl, None),
|
getOptionValue[Boolean](props, SmtpSsl, None),
|
||||||
|
getOptionValue[Boolean](props, SmtpStarttls, None),
|
||||||
getOptionValue(props, SmtpFromAddress, None),
|
getOptionValue(props, SmtpFromAddress, None),
|
||||||
getOptionValue(props, SmtpFromName, None)))
|
getOptionValue(props, SmtpFromName, None)))
|
||||||
} else {
|
} else {
|
||||||
@@ -168,6 +170,7 @@ object SystemSettingsService {
|
|||||||
user: Option[String],
|
user: Option[String],
|
||||||
password: Option[String],
|
password: Option[String],
|
||||||
ssl: Option[Boolean],
|
ssl: Option[Boolean],
|
||||||
|
starttls: Option[Boolean],
|
||||||
fromAddress: Option[String],
|
fromAddress: Option[String],
|
||||||
fromName: Option[String])
|
fromName: Option[String])
|
||||||
|
|
||||||
@@ -176,6 +179,9 @@ object SystemSettingsService {
|
|||||||
port:Int,
|
port:Int,
|
||||||
genericUser:String)
|
genericUser:String)
|
||||||
|
|
||||||
|
case class Lfs(
|
||||||
|
serverUrl: Option[String])
|
||||||
|
|
||||||
val DefaultSshPort = 29418
|
val DefaultSshPort = 29418
|
||||||
val DefaultSmtpPort = 25
|
val DefaultSmtpPort = 25
|
||||||
val DefaultLdapPort = 389
|
val DefaultLdapPort = 389
|
||||||
@@ -197,6 +203,7 @@ object SystemSettingsService {
|
|||||||
private val SmtpUser = "smtp.user"
|
private val SmtpUser = "smtp.user"
|
||||||
private val SmtpPassword = "smtp.password"
|
private val SmtpPassword = "smtp.password"
|
||||||
private val SmtpSsl = "smtp.ssl"
|
private val SmtpSsl = "smtp.ssl"
|
||||||
|
private val SmtpStarttls = "smtp.starttls"
|
||||||
private val SmtpFromAddress = "smtp.from_address"
|
private val SmtpFromAddress = "smtp.from_address"
|
||||||
private val SmtpFromName = "smtp.from_name"
|
private val SmtpFromName = "smtp.from_name"
|
||||||
private val LdapAuthentication = "ldap_authentication"
|
private val LdapAuthentication = "ldap_authentication"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package gitbucket.core.service
|
package gitbucket.core.service
|
||||||
|
|
||||||
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 gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import org.apache.http.client.utils.URLEncodedUtils
|
import org.apache.http.client.utils.URLEncodedUtils
|
||||||
import profile.simple._
|
|
||||||
import gitbucket.core.util.JGitUtil.CommitInfo
|
import gitbucket.core.util.JGitUtil.CommitInfo
|
||||||
import gitbucket.core.util.RepositoryName
|
import gitbucket.core.util.RepositoryName
|
||||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
@@ -16,7 +16,9 @@ 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 scala.util.{Success, Failure}
|
||||||
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
|
||||||
@@ -32,15 +34,15 @@ trait WebHookService {
|
|||||||
/** get All WebHook informations of repository */
|
/** get All WebHook informations of repository */
|
||||||
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) }
|
.join(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) }
|
.join(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
|
||||||
|
|
||||||
@@ -48,13 +50,13 @@ trait WebHookService {
|
|||||||
def getWebHook(owner: String, repository: String, url: String)(implicit s: Session): Option[(WebHook, Set[WebHook.Event])] =
|
def getWebHook(owner: String, repository: String, url: String)(implicit s: Session): Option[(WebHook, Set[WebHook.Event])] =
|
||||||
WebHooks
|
WebHooks
|
||||||
.filter(_.byPrimaryKey(owner, repository, url))
|
.filter(_.byPrimaryKey(owner, repository, url))
|
||||||
.innerJoin(WebHookEvents).on { (w, t) => t.byWebHook(w) }
|
.join(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 +64,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 +83,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 +93,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)
|
||||||
}
|
}
|
||||||
@@ -129,8 +131,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)
|
||||||
}
|
}
|
||||||
@@ -138,11 +140,9 @@ trait WebHookService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.onSuccess {
|
f.onComplete {
|
||||||
case s => logger.debug(s"Success: web hook request to ${webHook.url}")
|
case Success(_) => logger.debug(s"Success: web hook request to ${webHook.url}")
|
||||||
}
|
case Failure(t) => logger.error(s"Failed: web hook request to ${webHook.url}", t)
|
||||||
f.onFailure {
|
|
||||||
case t => logger.error(s"Failed: web hook request to ${webHook.url}", t)
|
|
||||||
}
|
}
|
||||||
(webHook, json, reqPromise.future, f)
|
(webHook, json, reqPromise.future, f)
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,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 +239,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 +272,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 +372,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 +406,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,7 +432,7 @@ 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,
|
||||||
@@ -426,15 +443,29 @@ object WebHookService {
|
|||||||
headOwner: Account,
|
headOwner: Account,
|
||||||
baseRepository: RepositoryInfo,
|
baseRepository: RepositoryInfo,
|
||||||
baseOwner: Account,
|
baseOwner: Account,
|
||||||
sender: Account
|
sender: Account,
|
||||||
|
mergedComment: Option[(IssueComment, Account)]
|
||||||
) : WebHookPullRequestReviewCommentPayload = {
|
) : 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,
|
||||||
|
commentedUser = 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,
|
repository = baseRepoPayload,
|
||||||
sender = senderPayload)
|
sender = senderPayload)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import gitbucket.core.model.Account
|
|||||||
import gitbucket.core.service.SystemSettingsService.SystemSettings
|
import gitbucket.core.service.SystemSettingsService.SystemSettings
|
||||||
import gitbucket.core.service.{AccessTokenService, AccountService, SystemSettingsService}
|
import gitbucket.core.service.{AccessTokenService, AccountService, SystemSettingsService}
|
||||||
import gitbucket.core.util.{AuthUtil, Keys}
|
import gitbucket.core.util.{AuthUtil, Keys}
|
||||||
import org.scalatra.servlet.ServletApiImplicits._
|
|
||||||
import org.scalatra._
|
|
||||||
|
|
||||||
|
|
||||||
class ApiAuthenticationFilter extends Filter with AccessTokenService with AccountService with SystemSettingsService {
|
class ApiAuthenticationFilter extends Filter with AccessTokenService with AccountService with SystemSettingsService {
|
||||||
|
|||||||
@@ -20,12 +20,13 @@ class GHCompatRepositoryAccessFilter extends Filter with SystemSettingsService {
|
|||||||
|
|
||||||
override def doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain) = {
|
override def doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain) = {
|
||||||
implicit val request = req.asInstanceOf[HttpServletRequest]
|
implicit val request = req.asInstanceOf[HttpServletRequest]
|
||||||
|
val agent = request.getHeader("USER-AGENT")
|
||||||
val response = res.asInstanceOf[HttpServletResponse]
|
val response = res.asInstanceOf[HttpServletResponse]
|
||||||
val requestPath = request.getRequestURI.substring(request.getContextPath.length)
|
val requestPath = request.getRequestURI.substring(request.getContextPath.length)
|
||||||
requestPath match {
|
|
||||||
case githubRepositoryPattern() =>
|
|
||||||
response.sendRedirect(baseUrl + "/git" + requestPath)
|
|
||||||
|
|
||||||
|
requestPath match {
|
||||||
|
case githubRepositoryPattern() if agent != null && agent.toLowerCase.indexOf("git") >= 0 =>
|
||||||
|
response.sendRedirect(baseUrl + "/git" + requestPath)
|
||||||
case _ =>
|
case _ =>
|
||||||
chain.doFilter(req, res)
|
chain.doFilter(req, res)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import gitbucket.core.plugin.{GitRepositoryFilter, GitRepositoryRouting, PluginR
|
|||||||
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, AuthUtil}
|
import gitbucket.core.util.{Keys, Implicits, AuthUtil}
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import Implicits._
|
import Implicits._
|
||||||
|
|
||||||
@@ -70,42 +71,47 @@ class GitAuthenticationFilter extends Filter with RepositoryService with Account
|
|||||||
|
|
||||||
private def defaultRepository(request: HttpServletRequest, response: HttpServletResponse, chain: FilterChain,
|
private def defaultRepository(request: HttpServletRequest, response: HttpServletResponse, chain: FilterChain,
|
||||||
settings: SystemSettings, isUpdating: Boolean): Unit = {
|
settings: SystemSettings, isUpdating: Boolean): Unit = {
|
||||||
implicit val r = request
|
val action = request.paths match {
|
||||||
|
|
||||||
request.paths match {
|
|
||||||
case Array(_, repositoryOwner, repositoryName, _*) =>
|
case Array(_, repositoryOwner, repositoryName, _*) =>
|
||||||
|
Database() withSession { implicit session =>
|
||||||
getRepository(repositoryOwner, repositoryName.replaceFirst("\\.wiki\\.git$|\\.git$", "")) match {
|
getRepository(repositoryOwner, repositoryName.replaceFirst("\\.wiki\\.git$|\\.git$", "")) match {
|
||||||
case Some(repository) => {
|
case Some(repository) => {
|
||||||
if(!isUpdating && !repository.repository.isPrivate && settings.allowAnonymousAccess){
|
val execute = if (!isUpdating && !repository.repository.isPrivate && settings.allowAnonymousAccess) {
|
||||||
chain.doFilter(request, response)
|
// Authentication is not required
|
||||||
|
true
|
||||||
} else {
|
} else {
|
||||||
|
// Authentication is required
|
||||||
val passed = for {
|
val passed = for {
|
||||||
auth <- Option(request.getHeader("Authorization"))
|
auth <- Option(request.getHeader("Authorization"))
|
||||||
Array(username, password) = AuthUtil.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(hasDeveloperRole(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
|
||||||
} else true
|
} else true
|
||||||
|
passed.getOrElse(false)
|
||||||
|
}
|
||||||
|
|
||||||
if(passed.getOrElse(false)){
|
if (execute) {
|
||||||
chain.doFilter(request, response)
|
() => chain.doFilter(request, response)
|
||||||
} else {
|
} else {
|
||||||
AuthUtil.requireAuth(response)
|
() => AuthUtil.requireAuth(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
case None => () => {
|
||||||
case None => {
|
|
||||||
logger.debug(s"Repository ${repositoryOwner}/${repositoryName} is not found.")
|
logger.debug(s"Repository ${repositoryOwner}/${repositoryName} is not found.")
|
||||||
response.sendError(HttpServletResponse.SC_NOT_FOUND)
|
response.sendError(HttpServletResponse.SC_NOT_FOUND)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case _ => {
|
}
|
||||||
|
case _ => () => {
|
||||||
logger.debug(s"Not enough path arguments: ${request.paths}")
|
logger.debug(s"Not enough path arguments: ${request.paths}")
|
||||||
response.sendError(HttpServletResponse.SC_NOT_FOUND)
|
response.sendError(HttpServletResponse.SC_NOT_FOUND)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package gitbucket.core.servlet
|
||||||
|
|
||||||
|
import java.io.{File, FileInputStream, FileOutputStream}
|
||||||
|
import java.text.MessageFormat
|
||||||
|
import javax.servlet.http.{HttpServlet, HttpServletRequest, HttpServletResponse}
|
||||||
|
|
||||||
|
import gitbucket.core.util.{FileUtil, StringUtil}
|
||||||
|
import org.apache.commons.io.{FileUtils, IOUtils}
|
||||||
|
import org.json4s.jackson.Serialization._
|
||||||
|
import org.apache.http.HttpStatus
|
||||||
|
import gitbucket.core.util.ControlUtil._
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides GitLFS Transfer API
|
||||||
|
* https://github.com/git-lfs/git-lfs/blob/master/docs/api/basic-transfers.md
|
||||||
|
*/
|
||||||
|
class GitLfsTransferServlet extends HttpServlet {
|
||||||
|
|
||||||
|
private implicit val jsonFormats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||||
|
private val LongObjectIdLength = 32
|
||||||
|
private val LongObjectIdStringLength = LongObjectIdLength * 2
|
||||||
|
|
||||||
|
override protected def doGet(req: HttpServletRequest, res: HttpServletResponse): Unit = {
|
||||||
|
for {
|
||||||
|
(owner, repository, oid) <- getPathInfo(req, res) if checkToken(req, oid)
|
||||||
|
} yield {
|
||||||
|
val file = new File(FileUtil.getLfsFilePath(owner, repository, oid))
|
||||||
|
if(file.exists()){
|
||||||
|
res.setStatus(HttpStatus.SC_OK)
|
||||||
|
res.setContentType("application/octet-stream")
|
||||||
|
res.setContentLength(file.length.toInt)
|
||||||
|
using(new FileInputStream(file), res.getOutputStream){ (in, out) =>
|
||||||
|
IOUtils.copy(in, out)
|
||||||
|
out.flush()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sendError(res, HttpStatus.SC_NOT_FOUND,
|
||||||
|
MessageFormat.format("Object ''{0}'' not found", oid))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override protected def doPut(req: HttpServletRequest, res: HttpServletResponse): Unit = {
|
||||||
|
for {
|
||||||
|
(owner, repository, oid) <- getPathInfo(req, res) if checkToken(req, oid)
|
||||||
|
} yield {
|
||||||
|
val file = new File(FileUtil.getLfsFilePath(owner, repository, oid))
|
||||||
|
FileUtils.forceMkdir(file.getParentFile)
|
||||||
|
using(req.getInputStream, new FileOutputStream(file)){ (in, out) =>
|
||||||
|
IOUtils.copy(in, out)
|
||||||
|
}
|
||||||
|
res.setStatus(HttpStatus.SC_OK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private def checkToken(req: HttpServletRequest, oid: String): Boolean = {
|
||||||
|
val token = req.getHeader("Authorization")
|
||||||
|
if(token != null){
|
||||||
|
val Array(expireAt, targetOid) = StringUtil.decodeBlowfish(token).split(" ")
|
||||||
|
oid == targetOid && expireAt.toLong > System.currentTimeMillis
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private def getPathInfo(req: HttpServletRequest, res: HttpServletResponse): Option[(String, String, String)] = {
|
||||||
|
req.getRequestURI.substring(1).split("/").reverse match {
|
||||||
|
case Array(oid, repository, owner, _*) => Some((owner, repository, oid))
|
||||||
|
case _ => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private def sendError(res: HttpServletResponse, status: Int, message: String): Unit = {
|
||||||
|
res.setStatus(status)
|
||||||
|
using(res.getWriter()){ out =>
|
||||||
|
out.write(write(GitLfs.Error(message)))
|
||||||
|
out.flush()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package gitbucket.core.servlet
|
package gitbucket.core.servlet
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
import gitbucket.core.api
|
import gitbucket.core.api
|
||||||
import gitbucket.core.model.{Session, WebHook}
|
import gitbucket.core.model.WebHook
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import gitbucket.core.plugin.{GitRepositoryRouting, PluginRegistry}
|
import gitbucket.core.plugin.{GitRepositoryRouting, PluginRegistry}
|
||||||
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
||||||
import gitbucket.core.service.WebHookService._
|
import gitbucket.core.service.WebHookService._
|
||||||
@@ -11,16 +13,16 @@ 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 org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.eclipse.jgit.http.server.GitServlet
|
import org.eclipse.jgit.http.server.GitServlet
|
||||||
import org.eclipse.jgit.lib._
|
import org.eclipse.jgit.lib._
|
||||||
import org.eclipse.jgit.transport._
|
import org.eclipse.jgit.transport._
|
||||||
import org.eclipse.jgit.transport.resolver._
|
import org.eclipse.jgit.transport.resolver._
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
import javax.servlet.ServletConfig
|
import javax.servlet.ServletConfig
|
||||||
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
|
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
||||||
|
|
||||||
|
import org.json4s.jackson.Serialization._
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,6 +34,7 @@ import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
|
|||||||
class GitRepositoryServlet extends GitServlet with SystemSettingsService {
|
class GitRepositoryServlet extends GitServlet with SystemSettingsService {
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(classOf[GitRepositoryServlet])
|
private val logger = LoggerFactory.getLogger(classOf[GitRepositoryServlet])
|
||||||
|
private implicit val jsonFormats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||||
|
|
||||||
override def init(config: ServletConfig): Unit = {
|
override def init(config: ServletConfig): Unit = {
|
||||||
setReceivePackFactory(new GitBucketReceivePackFactory())
|
setReceivePackFactory(new GitBucketReceivePackFactory())
|
||||||
@@ -45,15 +48,75 @@ class GitRepositoryServlet extends GitServlet with SystemSettingsService {
|
|||||||
override def service(req: HttpServletRequest, res: HttpServletResponse): Unit = {
|
override def service(req: HttpServletRequest, res: HttpServletResponse): Unit = {
|
||||||
val agent = req.getHeader("USER-AGENT")
|
val agent = req.getHeader("USER-AGENT")
|
||||||
val index = req.getRequestURI.indexOf(".git")
|
val index = req.getRequestURI.indexOf(".git")
|
||||||
if(index >= 0 && (agent == null || agent.toLowerCase.indexOf("git/") < 0)){
|
if(index >= 0 && (agent == null || agent.toLowerCase.indexOf("git") < 0)){
|
||||||
// redirect for browsers
|
// redirect for browsers
|
||||||
val paths = req.getRequestURI.substring(0, index).split("/")
|
val paths = req.getRequestURI.substring(0, index).split("/")
|
||||||
res.sendRedirect(baseUrl(req) + "/" + paths.dropRight(1).last + "/" + paths.last)
|
res.sendRedirect(baseUrl(req) + "/" + paths.dropRight(1).last + "/" + paths.last)
|
||||||
|
|
||||||
|
} else if(req.getMethod.toUpperCase == "POST" && req.getRequestURI.endsWith("/info/lfs/objects/batch")){
|
||||||
|
serviceGitLfsBatchAPI(req, res)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// response for git client
|
// response for git client
|
||||||
super.service(req, res)
|
super.service(req, res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides GitLFS Batch API
|
||||||
|
* https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md
|
||||||
|
*/
|
||||||
|
protected def serviceGitLfsBatchAPI(req: HttpServletRequest, res: HttpServletResponse): Unit = {
|
||||||
|
val batchRequest = read[GitLfs.BatchRequest](req.getInputStream)
|
||||||
|
val settings = loadSystemSettings()
|
||||||
|
|
||||||
|
settings.baseUrl match {
|
||||||
|
case None => {
|
||||||
|
throw new IllegalStateException("lfs.server_url is not configured.")
|
||||||
|
}
|
||||||
|
case Some(baseUrl) => {
|
||||||
|
val index = req.getRequestURI.indexOf(".git")
|
||||||
|
if(index >= 0){
|
||||||
|
req.getRequestURI.substring(0, index).split("/").reverse match {
|
||||||
|
case Array(repository, owner, _*) =>
|
||||||
|
val timeout = System.currentTimeMillis + (60000 * 10) // 10 min.
|
||||||
|
val batchResponse = batchRequest.operation match {
|
||||||
|
case "upload" =>
|
||||||
|
GitLfs.BatchUploadResponse("basic", batchRequest.objects.map { requestObject =>
|
||||||
|
GitLfs.BatchResponseObject(requestObject.oid, requestObject.size, true,
|
||||||
|
GitLfs.Actions(
|
||||||
|
upload = Some(GitLfs.Action(
|
||||||
|
href = baseUrl + "/git-lfs/" + owner + "/" + repository + "/" + requestObject.oid,
|
||||||
|
header = Map("Authorization" -> StringUtil.encodeBlowfish(timeout + " " + requestObject.oid)),
|
||||||
|
expires_at = new Date(timeout)
|
||||||
|
))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
case "download" =>
|
||||||
|
GitLfs.BatchUploadResponse("basic", batchRequest.objects.map { requestObject =>
|
||||||
|
GitLfs.BatchResponseObject(requestObject.oid, requestObject.size, true,
|
||||||
|
GitLfs.Actions(
|
||||||
|
download = Some(GitLfs.Action(
|
||||||
|
href = baseUrl + "/git-lfs/" + owner + "/" + repository + "/" + requestObject.oid,
|
||||||
|
header = Map("Authorization" -> StringUtil.encodeBlowfish(timeout + " " + requestObject.oid)),
|
||||||
|
expires_at = new Date(timeout)
|
||||||
|
))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
res.setContentType("application/vnd.git-lfs+json")
|
||||||
|
using(res.getWriter){ out =>
|
||||||
|
out.print(write(batchResponse))
|
||||||
|
out.flush()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GitBucketRepositoryResolver(parent: FileResolver[HttpServletRequest]) extends RepositoryResolver[HttpServletRequest] {
|
class GitBucketRepositoryResolver(parent: FileResolver[HttpServletRequest]) extends RepositoryResolver[HttpServletRequest] {
|
||||||
@@ -107,15 +170,16 @@ class GitBucketReceivePackFactory extends ReceivePackFactory[HttpServletRequest]
|
|||||||
|
|
||||||
import scala.collection.JavaConverters._
|
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
|
||||||
|
|
||||||
def onPreReceive(receivePack: ReceivePack, commands: java.util.Collection[ReceiveCommand]): Unit = {
|
def onPreReceive(receivePack: ReceivePack, commands: java.util.Collection[ReceiveCommand]): Unit = {
|
||||||
|
Database() withTransaction { implicit session =>
|
||||||
try {
|
try {
|
||||||
commands.asScala.foreach { command =>
|
commands.asScala.foreach { command =>
|
||||||
// call pre-commit hook
|
// call pre-commit hook
|
||||||
@@ -135,10 +199,14 @@ 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 = {
|
||||||
|
Database() withTransaction { implicit session =>
|
||||||
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}")
|
||||||
@@ -154,13 +222,22 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val repositoryInfo = getRepository(owner, repository).get
|
||||||
|
|
||||||
|
// Update default branch if repository is empty and pushed branch is not current default branch
|
||||||
|
if(JGitUtil.isEmpty(git) && commits.nonEmpty && branchName != repositoryInfo.repository.defaultBranch){
|
||||||
|
saveRepositoryDefaultBranch(owner, repository, branchName)
|
||||||
|
// Change repository HEAD
|
||||||
|
using(Git.open(Directory.getRepositoryDir(owner, repository))) { git =>
|
||||||
|
git.getRepository.updateRef(Constants.HEAD, true).link(Constants.R_HEADS + branchName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve all issue count in the repository
|
// Retrieve all issue count in the repository
|
||||||
val issueCount =
|
val issueCount =
|
||||||
countIssue(IssueSearchCondition(state = "open"), false, owner -> repository) +
|
countIssue(IssueSearchCondition(state = "open"), false, owner -> repository) +
|
||||||
countIssue(IssueSearchCondition(state = "closed"), false, owner -> repository)
|
countIssue(IssueSearchCondition(state = "closed"), false, owner -> repository)
|
||||||
|
|
||||||
val repositoryInfo = getRepository(owner, repository).get
|
|
||||||
|
|
||||||
// Extract new commit and apply issue comment
|
// Extract new commit and apply issue comment
|
||||||
val defaultBranch = repositoryInfo.repository.defaultBranch
|
val defaultBranch = repositoryInfo.repository.defaultBranch
|
||||||
val newCommits = commits.flatMap { commit =>
|
val newCommits = commits.flatMap { commit =>
|
||||||
@@ -169,7 +246,7 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
|||||||
pushedIds.add(commit.id)
|
pushedIds.add(commit.id)
|
||||||
createIssueComment(owner, repository, commit)
|
createIssueComment(owner, repository, commit)
|
||||||
// close issues
|
// close issues
|
||||||
if(refName(1) == "heads" && branchName == defaultBranch && command.getType == ReceiveCommand.Type.UPDATE){
|
if (refName(1) == "heads" && branchName == defaultBranch && command.getType == ReceiveCommand.Type.UPDATE) {
|
||||||
closeIssuesFromMessage(commit.fullMessage, pusher, owner, repository)
|
closeIssuesFromMessage(commit.fullMessage, pusher, owner, repository)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,14 +255,14 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// record activity
|
// record activity
|
||||||
if(refName(1) == "heads"){
|
if (refName(1) == "heads") {
|
||||||
command.getType match {
|
command.getType match {
|
||||||
case ReceiveCommand.Type.CREATE => recordCreateBranchActivity(owner, repository, pusher, branchName)
|
case ReceiveCommand.Type.CREATE => recordCreateBranchActivity(owner, repository, pusher, branchName)
|
||||||
case ReceiveCommand.Type.UPDATE => recordPushActivity(owner, repository, pusher, branchName, newCommits)
|
case ReceiveCommand.Type.UPDATE => recordPushActivity(owner, repository, pusher, branchName, newCommits)
|
||||||
case ReceiveCommand.Type.DELETE => recordDeleteBranchActivity(owner, repository, pusher, branchName)
|
case ReceiveCommand.Type.DELETE => recordDeleteBranchActivity(owner, repository, pusher, branchName)
|
||||||
case _ =>
|
case _ =>
|
||||||
}
|
}
|
||||||
} else if(refName(1) == "tags"){
|
} else if (refName(1) == "tags") {
|
||||||
command.getType match {
|
command.getType match {
|
||||||
case ReceiveCommand.Type.CREATE => recordCreateTagActivity(owner, repository, pusher, branchName, newCommits)
|
case ReceiveCommand.Type.CREATE => recordCreateTagActivity(owner, repository, pusher, branchName, newCommits)
|
||||||
case ReceiveCommand.Type.DELETE => recordDeleteTagActivity(owner, repository, pusher, branchName, newCommits)
|
case ReceiveCommand.Type.DELETE => recordDeleteTagActivity(owner, repository, pusher, branchName, newCommits)
|
||||||
@@ -193,13 +270,13 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(refName(1) == "heads"){
|
if (refName(1) == "heads") {
|
||||||
command.getType match {
|
command.getType match {
|
||||||
case ReceiveCommand.Type.CREATE |
|
case ReceiveCommand.Type.CREATE |
|
||||||
ReceiveCommand.Type.UPDATE |
|
ReceiveCommand.Type.UPDATE |
|
||||||
ReceiveCommand.Type.UPDATE_NONFASTFORWARD =>
|
ReceiveCommand.Type.UPDATE_NONFASTFORWARD =>
|
||||||
updatePullRequests(owner, repository, branchName)
|
updatePullRequests(owner, repository, branchName)
|
||||||
getAccountByUserName(pusher).map{ pusherAccount =>
|
getAccountByUserName(pusher).map { pusherAccount =>
|
||||||
callPullRequestWebHookByRequestBranch("synchronize", repositoryInfo, branchName, baseUrl, pusherAccount)
|
callPullRequestWebHookByRequestBranch("synchronize", repositoryInfo, branchName, baseUrl, pusherAccount)
|
||||||
}
|
}
|
||||||
case _ =>
|
case _ =>
|
||||||
@@ -207,8 +284,8 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// call web hook
|
// call web hook
|
||||||
callWebHookOf(owner, repository, WebHook.Push){
|
callWebHookOf(owner, repository, WebHook.Push) {
|
||||||
for(pusherAccount <- getAccountByUserName(pusher);
|
for (pusherAccount <- getAccountByUserName(pusher);
|
||||||
ownerAccount <- getAccountByUserName(owner)) yield {
|
ownerAccount <- getAccountByUserName(owner)) yield {
|
||||||
WebHookPushPayload(git, pusherAccount, command.getRefName, repositoryInfo, newCommits, ownerAccount,
|
WebHookPushPayload(git, pusherAccount, command.getRefName, repositoryInfo, newCommits, ownerAccount,
|
||||||
newId = command.getNewId(), oldId = command.getOldId())
|
newId = command.getNewId(), oldId = command.getOldId())
|
||||||
@@ -228,5 +305,48 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
object GitLfs {
|
||||||
|
|
||||||
|
case class BatchRequest(
|
||||||
|
operation: String,
|
||||||
|
transfers: Seq[String],
|
||||||
|
objects: Seq[BatchRequestObject]
|
||||||
|
)
|
||||||
|
|
||||||
|
case class BatchRequestObject(
|
||||||
|
oid: String,
|
||||||
|
size: Long
|
||||||
|
)
|
||||||
|
|
||||||
|
case class BatchUploadResponse(
|
||||||
|
transfer: String,
|
||||||
|
objects: Seq[BatchResponseObject]
|
||||||
|
)
|
||||||
|
|
||||||
|
case class BatchResponseObject(
|
||||||
|
oid: String,
|
||||||
|
size: Long,
|
||||||
|
authenticated: Boolean,
|
||||||
|
actions: Actions
|
||||||
|
)
|
||||||
|
|
||||||
|
case class Actions(
|
||||||
|
download: Option[Action] = None,
|
||||||
|
upload: Option[Action] = None
|
||||||
|
)
|
||||||
|
|
||||||
|
case class Action(
|
||||||
|
href: String,
|
||||||
|
header: Map[String, String] = Map.empty,
|
||||||
|
expires_at: Date
|
||||||
|
)
|
||||||
|
|
||||||
|
case class Error(
|
||||||
|
message: String
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import gitbucket.core.service.{ActivityService, SystemSettingsService}
|
|||||||
import gitbucket.core.util.DatabaseConfig
|
import gitbucket.core.util.DatabaseConfig
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import gitbucket.core.util.JDBCUtil._
|
import gitbucket.core.util.JDBCUtil._
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import io.github.gitbucket.solidbase.Solidbase
|
import io.github.gitbucket.solidbase.Solidbase
|
||||||
import io.github.gitbucket.solidbase.manager.JDBCVersionManager
|
import io.github.gitbucket.solidbase.manager.JDBCVersionManager
|
||||||
import javax.servlet.{ServletContextListener, ServletContextEvent}
|
import javax.servlet.{ServletContextListener, ServletContextEvent}
|
||||||
@@ -27,6 +28,20 @@ class InitializeListener extends ServletContextListener with SystemSettingsServi
|
|||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(classOf[InitializeListener])
|
private val logger = LoggerFactory.getLogger(classOf[InitializeListener])
|
||||||
|
|
||||||
|
// ActorSystem for Quartz scheduler
|
||||||
|
private val system = ActorSystem("job", ConfigFactory.parseString(
|
||||||
|
"""
|
||||||
|
|akka {
|
||||||
|
| quartz {
|
||||||
|
| schedules {
|
||||||
|
| Daily {
|
||||||
|
| expression = "0 0 0 * * ?"
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
|}
|
||||||
|
""".stripMargin))
|
||||||
|
|
||||||
override def contextInitialized(event: ServletContextEvent): Unit = {
|
override def contextInitialized(event: ServletContextEvent): Unit = {
|
||||||
val dataDir = event.getServletContext.getInitParameter("gitbucket.home")
|
val dataDir = event.getServletContext.getInitParameter("gitbucket.home")
|
||||||
if(dataDir != null){
|
if(dataDir != null){
|
||||||
@@ -97,25 +112,16 @@ class InitializeListener extends ServletContextListener with SystemSettingsServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start Quartz scheduler
|
// Start Quartz scheduler
|
||||||
val system = ActorSystem("job", ConfigFactory.parseString(
|
|
||||||
"""
|
|
||||||
|akka {
|
|
||||||
| quartz {
|
|
||||||
| schedules {
|
|
||||||
| Daily {
|
|
||||||
| expression = "0 0 0 * * ?"
|
|
||||||
| }
|
|
||||||
| }
|
|
||||||
| }
|
|
||||||
|}
|
|
||||||
""".stripMargin))
|
|
||||||
|
|
||||||
val scheduler = QuartzSchedulerExtension(system)
|
val scheduler = QuartzSchedulerExtension(system)
|
||||||
|
|
||||||
scheduler.schedule("Daily", system.actorOf(Props[DeleteOldActivityActor]), "DeleteOldActivity")
|
scheduler.schedule("Daily", system.actorOf(Props[DeleteOldActivityActor]), "DeleteOldActivity")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override def contextDestroyed(event: ServletContextEvent): Unit = {
|
override def contextDestroyed(event: ServletContextEvent): Unit = {
|
||||||
|
// Shutdown Quartz scheduler
|
||||||
|
system.terminate()
|
||||||
// Shutdown plugins
|
// Shutdown plugins
|
||||||
PluginRegistry.shutdown(event.getServletContext, loadSystemSettings())
|
PluginRegistry.shutdown(event.getServletContext, loadSystemSettings())
|
||||||
// Close datasource
|
// Close datasource
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.scalatra.ScalatraBase
|
|||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import slick.jdbc.JdbcBackend.{Database => SlickDatabase, Session}
|
import slick.jdbc.JdbcBackend.{Database => SlickDatabase, Session}
|
||||||
import gitbucket.core.util.Keys
|
import gitbucket.core.util.Keys
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls the transaction with the open session in view pattern.
|
* Controls the transaction with the open session in view pattern.
|
||||||
@@ -21,15 +22,16 @@ class TransactionFilter extends Filter {
|
|||||||
def destroy(): Unit = {}
|
def destroy(): Unit = {}
|
||||||
|
|
||||||
def doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain): Unit = {
|
def doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain): Unit = {
|
||||||
if(req.asInstanceOf[HttpServletRequest].getServletPath().startsWith("/assets/")){
|
val servletPath = req.asInstanceOf[HttpServletRequest].getServletPath()
|
||||||
// assets don't need transaction
|
if(servletPath.startsWith("/assets/") || servletPath == "/git" || servletPath == "/git-lfs"){
|
||||||
|
// assets and git-lfs don't need transaction
|
||||||
chain.doFilter(req, res)
|
chain.doFilter(req, res)
|
||||||
} else {
|
} else {
|
||||||
Database() withTransaction { session =>
|
Database() withTransaction { session =>
|
||||||
// Register Scalatra error callback to rollback transaction
|
// Register Scalatra error callback to rollback transaction
|
||||||
ScalatraBase.onFailure { _ =>
|
ScalatraBase.onFailure { _ =>
|
||||||
logger.debug("Rolled back transaction")
|
logger.debug("Rolled back transaction")
|
||||||
session.rollback()
|
session.conn.rollback()
|
||||||
}(req.asInstanceOf[HttpServletRequest])
|
}(req.asInstanceOf[HttpServletRequest])
|
||||||
|
|
||||||
logger.debug("begin transaction")
|
logger.debug("begin transaction")
|
||||||
@@ -64,7 +66,7 @@ object Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val db: SlickDatabase = {
|
private val db: SlickDatabase = {
|
||||||
SlickDatabase.forDataSource(dataSource)
|
SlickDatabase.forDataSource(dataSource, Some(dataSource.getMaximumPoolSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
def apply(): SlickDatabase = db
|
def apply(): SlickDatabase = db
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package gitbucket.core.ssh
|
package gitbucket.core.ssh
|
||||||
|
|
||||||
import gitbucket.core.model.Session
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import gitbucket.core.plugin.{GitRepositoryRouting, PluginRegistry}
|
import gitbucket.core.plugin.{GitRepositoryRouting, PluginRegistry}
|
||||||
import gitbucket.core.service.{RepositoryService, AccountService, SystemSettingsService}
|
import gitbucket.core.service.{AccountService, RepositoryService, SystemSettingsService}
|
||||||
import gitbucket.core.servlet.{Database, CommitLogHook}
|
import gitbucket.core.servlet.{CommitLogHook, Database}
|
||||||
import gitbucket.core.util.{Directory, ControlUtil}
|
import gitbucket.core.util.{ControlUtil, Directory}
|
||||||
import org.apache.sshd.server.{CommandFactory, Environment, ExitCallback, Command, SessionAware}
|
import org.apache.sshd.server.{Command, CommandFactory, Environment, ExitCallback, SessionAware}
|
||||||
import org.apache.sshd.server.session.ServerSession
|
import org.apache.sshd.server.session.ServerSession
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.io.{File, InputStream, OutputStream}
|
import java.io.{File, InputStream, OutputStream}
|
||||||
|
|
||||||
import ControlUtil._
|
import ControlUtil._
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import Directory._
|
import Directory._
|
||||||
@@ -30,13 +31,12 @@ abstract class GitCommand extends Command with SessionAware {
|
|||||||
@volatile protected var callback: ExitCallback = null
|
@volatile protected var callback: ExitCallback = null
|
||||||
@volatile private var authUser:Option[String] = None
|
@volatile private var authUser:Option[String] = None
|
||||||
|
|
||||||
protected def runTask(authUser: String)(implicit session: Session): Unit
|
protected def runTask(authUser: String): Unit
|
||||||
|
|
||||||
private def newTask(): Runnable = new Runnable {
|
private def newTask(): Runnable = new Runnable {
|
||||||
override def run(): Unit = {
|
override def run(): Unit = {
|
||||||
authUser match {
|
authUser match {
|
||||||
case Some(authUser) =>
|
case Some(authUser) =>
|
||||||
Database() withTransaction { implicit session =>
|
|
||||||
try {
|
try {
|
||||||
runTask(authUser)
|
runTask(authUser)
|
||||||
callback.onExit(0)
|
callback.onExit(0)
|
||||||
@@ -48,7 +48,6 @@ abstract class GitCommand extends Command with SessionAware {
|
|||||||
logger.error(e.getMessage, e)
|
logger.error(e.getMessage, e)
|
||||||
callback.onExit(1)
|
callback.onExit(1)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
case None =>
|
case None =>
|
||||||
val message = "User not authenticated"
|
val message = "User not authenticated"
|
||||||
logger.error(message)
|
logger.error(message)
|
||||||
@@ -102,9 +101,14 @@ abstract class DefaultGitCommand(val owner: String, val repoName: String) extend
|
|||||||
class DefaultGitUploadPack(owner: String, repoName: String) extends DefaultGitCommand(owner, repoName)
|
class DefaultGitUploadPack(owner: String, repoName: String) extends DefaultGitCommand(owner, repoName)
|
||||||
with RepositoryService with AccountService {
|
with RepositoryService with AccountService {
|
||||||
|
|
||||||
override protected def runTask(user: String)(implicit session: Session): Unit = {
|
override protected def runTask(user: String): Unit = {
|
||||||
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", "")).foreach { repositoryInfo =>
|
val execute = Database() withSession { implicit session =>
|
||||||
if(!repositoryInfo.repository.isPrivate || isWritableUser(user, repositoryInfo)){
|
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", "")).map { repositoryInfo =>
|
||||||
|
!repositoryInfo.repository.isPrivate || isWritableUser(user, repositoryInfo)
|
||||||
|
}.getOrElse(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(execute){
|
||||||
using(Git.open(getRepositoryDir(owner, repoName))) { git =>
|
using(Git.open(getRepositoryDir(owner, repoName))) { git =>
|
||||||
val repository = git.getRepository
|
val repository = git.getRepository
|
||||||
val upload = new UploadPack(repository)
|
val upload = new UploadPack(repository)
|
||||||
@@ -112,19 +116,23 @@ class DefaultGitUploadPack(owner: String, repoName: String) extends DefaultGitCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DefaultGitReceivePack(owner: String, repoName: String, baseUrl: String) extends DefaultGitCommand(owner, repoName)
|
class DefaultGitReceivePack(owner: String, repoName: String, baseUrl: String) extends DefaultGitCommand(owner, repoName)
|
||||||
with RepositoryService with AccountService {
|
with RepositoryService with AccountService {
|
||||||
|
|
||||||
override protected def runTask(user: String)(implicit session: Session): Unit = {
|
override protected def runTask(user: String): Unit = {
|
||||||
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", "")).foreach { repositoryInfo =>
|
val execute = Database() withSession { implicit session =>
|
||||||
if(isWritableUser(user, repositoryInfo)){
|
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", "")).map { repositoryInfo =>
|
||||||
|
isWritableUser(user, repositoryInfo)
|
||||||
|
}.getOrElse(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(execute) {
|
||||||
using(Git.open(getRepositoryDir(owner, repoName))) { git =>
|
using(Git.open(getRepositoryDir(owner, repoName))) { git =>
|
||||||
val repository = git.getRepository
|
val repository = git.getRepository
|
||||||
val receive = new ReceivePack(repository)
|
val receive = new ReceivePack(repository)
|
||||||
if(!repoName.endsWith(".wiki")){
|
if (!repoName.endsWith(".wiki")) {
|
||||||
val hook = new CommitLogHook(owner, repoName, user, baseUrl)
|
val hook = new CommitLogHook(owner, repoName, user, baseUrl)
|
||||||
receive.setPreReceiveHook(hook)
|
receive.setPreReceiveHook(hook)
|
||||||
receive.setPostReceiveHook(hook)
|
receive.setPostReceiveHook(hook)
|
||||||
@@ -133,14 +141,17 @@ class DefaultGitReceivePack(owner: String, repoName: String, baseUrl: String) ex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PluginGitUploadPack(repoName: String, routing: GitRepositoryRouting) extends GitCommand
|
class PluginGitUploadPack(repoName: String, routing: GitRepositoryRouting) extends GitCommand
|
||||||
with SystemSettingsService {
|
with SystemSettingsService {
|
||||||
|
|
||||||
override protected def runTask(user: String)(implicit session: Session): Unit = {
|
override protected def runTask(user: String): Unit = {
|
||||||
if(routing.filter.filter("/" + repoName, Some(user), loadSystemSettings(), false)){
|
val execute = Database() withSession { implicit session =>
|
||||||
|
routing.filter.filter("/" + repoName, Some(user), loadSystemSettings(), false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(execute){
|
||||||
val path = routing.urlPattern.r.replaceFirstIn(repoName, routing.localPath)
|
val path = routing.urlPattern.r.replaceFirstIn(repoName, routing.localPath)
|
||||||
using(Git.open(new File(Directory.GitBucketHome, path))){ git =>
|
using(Git.open(new File(Directory.GitBucketHome, path))){ git =>
|
||||||
val repository = git.getRepository
|
val repository = git.getRepository
|
||||||
@@ -154,8 +165,11 @@ class PluginGitUploadPack(repoName: String, routing: GitRepositoryRouting) exten
|
|||||||
class PluginGitReceivePack(repoName: String, routing: GitRepositoryRouting) extends GitCommand
|
class PluginGitReceivePack(repoName: String, routing: GitRepositoryRouting) extends GitCommand
|
||||||
with SystemSettingsService {
|
with SystemSettingsService {
|
||||||
|
|
||||||
override protected def runTask(user: String)(implicit session: Session): Unit = {
|
override protected def runTask(user: String): Unit = {
|
||||||
if(routing.filter.filter("/" + repoName, Some(user), loadSystemSettings(), true)){
|
val execute = Database() withSession { implicit session =>
|
||||||
|
routing.filter.filter("/" + repoName, Some(user), loadSystemSettings(), true)
|
||||||
|
}
|
||||||
|
if(execute){
|
||||||
val path = routing.urlPattern.r.replaceFirstIn(repoName, routing.localPath)
|
val path = routing.urlPattern.r.replaceFirstIn(repoName, routing.localPath)
|
||||||
using(Git.open(new File(Directory.GitBucketHome, path))){ git =>
|
using(Git.open(new File(Directory.GitBucketHome, path))){ git =>
|
||||||
val repository = git.getRepository
|
val repository = git.getRepository
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package gitbucket.core.ssh
|
package gitbucket.core.ssh
|
||||||
|
|
||||||
import gitbucket.core.service.SystemSettingsService
|
|
||||||
import gitbucket.core.service.SystemSettingsService.SshAddress
|
import gitbucket.core.service.SystemSettingsService.SshAddress
|
||||||
import org.apache.sshd.common.Factory
|
import org.apache.sshd.common.Factory
|
||||||
import org.apache.sshd.server.{Environment, ExitCallback, Command}
|
import org.apache.sshd.server.{Environment, ExitCallback, Command}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package gitbucket.core.ssh
|
|||||||
|
|
||||||
import java.security.PublicKey
|
import java.security.PublicKey
|
||||||
|
|
||||||
import gitbucket.core.model.SshKey
|
|
||||||
import gitbucket.core.service.SshKeyService
|
import gitbucket.core.service.SshKeyService
|
||||||
import gitbucket.core.servlet.Database
|
import gitbucket.core.servlet.Database
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
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.AttributeStore
|
import org.apache.sshd.common.AttributeStore
|
||||||
|
|||||||
@@ -20,6 +20,20 @@ object ControlUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def using[A <% { def close(): Unit }, B <% { def close(): Unit }, C](resource1: A, resource2: B)(f: (A, B) => C): C =
|
||||||
|
try f(resource1, resource2) finally {
|
||||||
|
if(resource1 != null){
|
||||||
|
ignoring(classOf[Throwable]) {
|
||||||
|
resource1.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(resource2 != null){
|
||||||
|
ignoring(classOf[Throwable]) {
|
||||||
|
resource2.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def using[T](git: Git)(f: Git => T): T =
|
def using[T](git: Git)(f: Git => T): T =
|
||||||
try f(git) finally git.getRepository.close()
|
try f(git) finally git.getRepository.close()
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package gitbucket.core.util
|
|||||||
|
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
import Directory._
|
import Directory._
|
||||||
|
import com.github.takezoe.slick.blocking.{BlockingH2Driver, BlockingMySQLDriver, BlockingJdbcProfile}
|
||||||
import liquibase.database.AbstractJdbcDatabase
|
import liquibase.database.AbstractJdbcDatabase
|
||||||
import liquibase.database.core.{PostgresDatabase, MySQLDatabase, H2Database}
|
import liquibase.database.core.{H2Database, MySQLDatabase, PostgresDatabase}
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
|
|
||||||
object DatabaseConfig {
|
object DatabaseConfig {
|
||||||
@@ -37,7 +39,7 @@ object DatabaseConfig {
|
|||||||
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 : BlockingJdbcProfile = 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 connectionTimeout : Option[Long] = getOptionValue("db.connectionTimeout", config.getLong)
|
||||||
lazy val idleTimeout : Option[Long] = getOptionValue("db.idleTimeout" , config.getLong)
|
lazy val idleTimeout : Option[Long] = getOptionValue("db.idleTimeout" , config.getLong)
|
||||||
@@ -53,7 +55,7 @@ object DatabaseConfig {
|
|||||||
|
|
||||||
sealed trait DatabaseType {
|
sealed trait DatabaseType {
|
||||||
val jdbcDriver: String
|
val jdbcDriver: String
|
||||||
val slickDriver: slick.driver.JdbcProfile
|
val slickDriver: BlockingJdbcProfile
|
||||||
val liquiDriver: AbstractJdbcDatabase
|
val liquiDriver: AbstractJdbcDatabase
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,25 +75,27 @@ object DatabaseType {
|
|||||||
|
|
||||||
object H2 extends DatabaseType {
|
object H2 extends DatabaseType {
|
||||||
val jdbcDriver = "org.h2.Driver"
|
val jdbcDriver = "org.h2.Driver"
|
||||||
val slickDriver = slick.driver.H2Driver
|
val slickDriver = BlockingH2Driver
|
||||||
val liquiDriver = new H2Database()
|
val liquiDriver = new H2Database()
|
||||||
}
|
}
|
||||||
|
|
||||||
object MySQL extends DatabaseType {
|
object MySQL extends DatabaseType {
|
||||||
val jdbcDriver = "com.mysql.jdbc.Driver"
|
val jdbcDriver = "com.mysql.jdbc.Driver"
|
||||||
val slickDriver = slick.driver.MySQLDriver
|
val slickDriver = BlockingMySQLDriver
|
||||||
val liquiDriver = new MySQLDatabase()
|
val liquiDriver = new MySQLDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
object PostgreSQL extends DatabaseType {
|
object PostgreSQL extends DatabaseType {
|
||||||
val jdbcDriver = "org.postgresql.Driver2"
|
val jdbcDriver = "org.postgresql.Driver2"
|
||||||
val slickDriver = new slick.driver.PostgresDriver {
|
val slickDriver = BlockingPostgresDriver
|
||||||
|
val liquiDriver = new PostgresDatabase()
|
||||||
|
}
|
||||||
|
|
||||||
|
object BlockingPostgresDriver extends slick.jdbc.PostgresProfile with BlockingJdbcProfile {
|
||||||
override def quoteIdentifier(id: String): String = {
|
override def quoteIdentifier(id: String): String = {
|
||||||
val s = new StringBuilder(id.length + 4) append '"'
|
val s = new StringBuilder(id.length + 4) append '"'
|
||||||
for(c <- id) if(c == '"') s append "\"\"" else s append c.toLower
|
for(c <- id) if(c == '"') s append "\"\"" else s append c.toLower
|
||||||
(s append '"').toString
|
(s append '"').toString
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val liquiDriver = new PostgresDatabase()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package gitbucket.core.util
|
package gitbucket.core.util
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import ControlUtil._
|
|
||||||
import org.apache.commons.io.FileUtils
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides directories used by GitBucket.
|
* Provides directory locations used by GitBucket.
|
||||||
*/
|
*/
|
||||||
object Directory {
|
object Directory {
|
||||||
|
|
||||||
@@ -44,16 +42,29 @@ object Directory {
|
|||||||
def getRepositoryDir(owner: String, repository: String): File =
|
def getRepositoryDir(owner: String, repository: String): File =
|
||||||
new File(s"${RepositoryHome}/${owner}/${repository}.git")
|
new File(s"${RepositoryHome}/${owner}/${repository}.git")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Directory for repository files.
|
||||||
|
*/
|
||||||
|
def getRepositoryFilesDir(owner: String, repository: String): File =
|
||||||
|
new File(s"${RepositoryHome}/${owner}/${repository}")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory for files which are attached to issue.
|
* Directory for files which are attached to issue.
|
||||||
*/
|
*/
|
||||||
def getAttachedDir(owner: String, repository: String): File =
|
def getAttachedDir(owner: String, repository: String): File =
|
||||||
new File(s"${RepositoryHome}/${owner}/${repository}/comments")
|
new File(getRepositoryFilesDir(owner, repository), "comments")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Directory for files which are attached to issue.
|
||||||
|
*/
|
||||||
|
def getLfsDir(owner: String, repository: String): File =
|
||||||
|
new File(getRepositoryFilesDir(owner, repository), "lfs")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory for uploaded files by the specified user.
|
* Directory for uploaded files by the specified user.
|
||||||
*/
|
*/
|
||||||
def getUserUploadDir(userName: String): File = new File(s"${GitBucketHome}/data/${userName}/files")
|
def getUserUploadDir(userName: String): File =
|
||||||
|
new File(s"${GitBucketHome}/data/${userName}/files")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root of temporary directories for the upload file.
|
* Root of temporary directories for the upload file.
|
||||||
@@ -70,13 +81,8 @@ object Directory {
|
|||||||
/**
|
/**
|
||||||
* Root of plugin cache directory. Plugin repositories are cloned into this directory.
|
* Root of plugin cache directory. Plugin repositories are cloned into this directory.
|
||||||
*/
|
*/
|
||||||
def getPluginCacheDir(): File = new File(s"${TemporaryHome}/_plugins")
|
def getPluginCacheDir(): File =
|
||||||
|
new File(s"${TemporaryHome}/_plugins")
|
||||||
/**
|
|
||||||
* Temporary directory which is used to create an archive to download repository contents.
|
|
||||||
*/
|
|
||||||
def getDownloadWorkDir(owner: String, repository: String, sessionId: String): File =
|
|
||||||
new File(getTemporaryDir(owner, repository), s"download/${sessionId}")
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Substance directory of the wiki repository.
|
* Substance directory of the wiki repository.
|
||||||
|
|||||||
@@ -62,4 +62,15 @@ object FileUtil {
|
|||||||
"image/jpeg",
|
"image/jpeg",
|
||||||
"image/png",
|
"image/png",
|
||||||
"text/plain")
|
"text/plain")
|
||||||
|
|
||||||
|
def getLfsFilePath(owner: String, repository: String, oid: String): String =
|
||||||
|
Directory.getLfsDir(owner, repository) + "/" + oid
|
||||||
|
|
||||||
|
def readableSize(size: Long): String = FileUtils.byteCountToDisplaySize(size)
|
||||||
|
|
||||||
|
def deleteDirectoryIfEmpty(dir: File): Unit = {
|
||||||
|
if(dir.isDirectory() && dir.list().isEmpty) {
|
||||||
|
FileUtils.deleteDirectory(dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ object Implicits {
|
|||||||
|
|
||||||
implicit def context2ApiJsonFormatContext(implicit context: Context): JsonFormat.Context = JsonFormat.Context(context.baseUrl)
|
implicit def context2ApiJsonFormatContext(implicit context: Context): JsonFormat.Context = JsonFormat.Context(context.baseUrl)
|
||||||
|
|
||||||
implicit class RichSeq[A](seq: Seq[A]) {
|
implicit class RichSeq[A](private val seq: Seq[A]) extends AnyVal {
|
||||||
|
|
||||||
def splitWith(condition: (A, A) => Boolean): Seq[Seq[A]] = split(seq)(condition)
|
def splitWith(condition: (A, A) => Boolean): Seq[Seq[A]] = split(seq)(condition)
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ object Implicits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
implicit class RichString(value: String){
|
implicit class RichString(private val value: String) extends AnyVal {
|
||||||
def replaceBy(regex: Regex)(replace: Regex.MatchData => Option[String]): String = {
|
def replaceBy(regex: Regex)(replace: Regex.MatchData => Option[String]): String = {
|
||||||
val sb = new StringBuilder()
|
val sb = new StringBuilder()
|
||||||
var i = 0
|
var i = 0
|
||||||
@@ -63,7 +63,7 @@ object Implicits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
implicit class RichRequest(request: HttpServletRequest){
|
implicit class RichRequest(private val request: HttpServletRequest) extends AnyVal {
|
||||||
|
|
||||||
def paths: Array[String] = (request.getRequestURI.substring(request.getContextPath.length + 1) match{
|
def paths: Array[String] = (request.getRequestURI.substring(request.getContextPath.length + 1) match{
|
||||||
case path if path.startsWith("api/v3/repos/") => path.substring(13/* "/api/v3/repos".length */)
|
case path if path.startsWith("api/v3/repos/") => path.substring(13/* "/api/v3/repos".length */)
|
||||||
@@ -84,7 +84,7 @@ object Implicits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
implicit class RichSession(session: HttpSession){
|
implicit class RichSession(private val session: HttpSession) extends AnyVal {
|
||||||
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){
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import scala.collection.mutable.ListBuffer
|
|||||||
*/
|
*/
|
||||||
object JDBCUtil {
|
object JDBCUtil {
|
||||||
|
|
||||||
implicit class RichConnection(conn: Connection){
|
implicit class RichConnection(private val conn: Connection) extends AnyVal {
|
||||||
|
|
||||||
def update(sql: String, params: Any*): Int = {
|
def update(sql: String, params: Any*): Int = {
|
||||||
execute(sql, params: _*){ stmt =>
|
execute(sql, params: _*){ stmt =>
|
||||||
@@ -214,8 +214,6 @@ object JDBCUtil {
|
|||||||
tsort(edges).toSeq
|
tsort(edges).toSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
case class TableDependency(tableName: String, children: Seq[String])
|
|
||||||
|
|
||||||
|
|
||||||
def tsort[A](edges: Traversable[(A, A)]): Iterable[A] = {
|
def tsort[A](edges: Traversable[(A, A)]): Iterable[A] = {
|
||||||
@tailrec
|
@tailrec
|
||||||
@@ -236,4 +234,6 @@ object JDBCUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private case class TableDependency(tableName: String, children: Seq[String])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,10 +120,11 @@ object JGitUtil {
|
|||||||
* The file content data for the file content view of the repository viewer.
|
* The file content data for the file content view of the repository viewer.
|
||||||
*
|
*
|
||||||
* @param viewType "image", "large" or "other"
|
* @param viewType "image", "large" or "other"
|
||||||
|
* @param size total size of object in bytes
|
||||||
* @param content the string content
|
* @param content the string content
|
||||||
* @param charset the character encoding
|
* @param charset the character encoding
|
||||||
*/
|
*/
|
||||||
case class ContentInfo(viewType: String, content: Option[String], charset: Option[String]){
|
case class ContentInfo(viewType: String, size: Option[Long], content: Option[String], charset: Option[String]){
|
||||||
/**
|
/**
|
||||||
* the line separator of this content ("LF" or "CRLF")
|
* the line separator of this content ("LF" or "CRLF")
|
||||||
*/
|
*/
|
||||||
@@ -170,19 +173,53 @@ object JGitUtil {
|
|||||||
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 +232,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)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,7 +248,7 @@ 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 +290,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 +305,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 +330,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 +380,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 +392,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 +740,8 @@ object JGitUtil {
|
|||||||
refUpdate.setNewObjectId(newHeadId)
|
refUpdate.setNewObjectId(newHeadId)
|
||||||
refUpdate.update()
|
refUpdate.update()
|
||||||
|
|
||||||
|
removeCache(git)
|
||||||
|
|
||||||
newHeadId
|
newHeadId
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,6 +793,33 @@ object JGitUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getLfsObjects(text: String): Map[String, String] = {
|
||||||
|
if(text.startsWith("version https://git-lfs.github.com/spec/v1")){
|
||||||
|
// LFS objects
|
||||||
|
text.split("\n").map { line =>
|
||||||
|
val dim = line.split(" ")
|
||||||
|
dim(0) -> dim(1)
|
||||||
|
}.toMap
|
||||||
|
} else {
|
||||||
|
Map.empty
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getContentSize(loader: ObjectLoader): Long = {
|
||||||
|
if(loader.isLarge) {
|
||||||
|
loader.getSize
|
||||||
|
} else {
|
||||||
|
val bytes = loader.getCachedBytes
|
||||||
|
val text = new String(bytes, "UTF-8")
|
||||||
|
|
||||||
|
val attr = getLfsObjects(text)
|
||||||
|
attr.get("size") match {
|
||||||
|
case Some(size) => size.toLong
|
||||||
|
case None => loader.getSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def getContentInfo(git: Git, path: String, objectId: ObjectId): ContentInfo = {
|
def getContentInfo(git: Git, path: String, objectId: ObjectId): ContentInfo = {
|
||||||
// Viewer
|
// Viewer
|
||||||
using(git.getRepository.getObjectDatabase){ db =>
|
using(git.getRepository.getObjectDatabase){ db =>
|
||||||
@@ -763,18 +827,19 @@ object JGitUtil {
|
|||||||
val large = FileUtil.isLarge(loader.getSize)
|
val large = FileUtil.isLarge(loader.getSize)
|
||||||
val viewer = if(FileUtil.isImage(path)) "image" else if(large) "large" else "other"
|
val viewer = if(FileUtil.isImage(path)) "image" else if(large) "large" else "other"
|
||||||
val bytes = if(viewer == "other") JGitUtil.getContentFromId(git, objectId, false) else None
|
val bytes = if(viewer == "other") JGitUtil.getContentFromId(git, objectId, false) else None
|
||||||
|
val size = Some(getContentSize(loader))
|
||||||
|
|
||||||
if(viewer == "other"){
|
if(viewer == "other"){
|
||||||
if(bytes.isDefined && FileUtil.isText(bytes.get)){
|
if(bytes.isDefined && FileUtil.isText(bytes.get)){
|
||||||
// text
|
// text
|
||||||
ContentInfo("text", Some(StringUtil.convertFromByteArray(bytes.get)), Some(StringUtil.detectEncoding(bytes.get)))
|
ContentInfo("text", size, Some(StringUtil.convertFromByteArray(bytes.get)), Some(StringUtil.detectEncoding(bytes.get)))
|
||||||
} else {
|
} else {
|
||||||
// binary
|
// binary
|
||||||
ContentInfo("binary", None, None)
|
ContentInfo("binary", size, None, None)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// image or large
|
// image or large
|
||||||
ContentInfo(viewer, None, None)
|
ContentInfo(viewer, size, None, None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -877,6 +942,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
|
||||||
@@ -959,6 +1025,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
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
package gitbucket.core.util
|
package gitbucket.core.util
|
||||||
|
|
||||||
import gitbucket.core.model.{Session, Issue}
|
import gitbucket.core.model.{Session, Issue, Account}
|
||||||
|
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||||
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, SystemSettingsService}
|
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, SystemSettingsService}
|
||||||
import gitbucket.core.servlet.Database
|
import gitbucket.core.servlet.Database
|
||||||
import gitbucket.core.view.Markdown
|
import gitbucket.core.view.Markdown
|
||||||
|
|
||||||
import scala.concurrent._
|
import scala.concurrent._
|
||||||
|
import scala.util.{Success, Failure}
|
||||||
import ExecutionContext.Implicits.global
|
import ExecutionContext.Implicits.global
|
||||||
import org.apache.commons.mail.{DefaultAuthenticator, HtmlEmail}
|
import org.apache.commons.mail.{DefaultAuthenticator, HtmlEmail}
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
import gitbucket.core.controller.Context
|
import gitbucket.core.controller.Context
|
||||||
import SystemSettingsService.Smtp
|
import SystemSettingsService.Smtp
|
||||||
import ControlUtil.defining
|
import ControlUtil.defining
|
||||||
|
|
||||||
trait Notifier extends RepositoryService with AccountService with IssuesService {
|
trait Notifier extends RepositoryService with AccountService with IssuesService {
|
||||||
|
|
||||||
def toNotify(r: RepositoryService.RepositoryInfo, issue: Issue, content: String)
|
def toNotify(r: RepositoryService.RepositoryInfo, issue: Issue, content: String)
|
||||||
(msg: String => String)(implicit context: Context): Unit
|
(msg: String => String)(implicit context: Context): Unit
|
||||||
|
|
||||||
protected def recipients(issue: Issue)(notify: String => Unit)(implicit session: Session, context: Context) =
|
protected def recipients(issue: Issue, loginAccount: Account)(notify: String => Unit)(implicit session: Session) =
|
||||||
(
|
(
|
||||||
// individual repository's owner
|
// individual repository's owner
|
||||||
issue.userName ::
|
issue.userName ::
|
||||||
@@ -31,9 +33,13 @@ trait Notifier extends RepositoryService with AccountService with IssuesService
|
|||||||
getComments(issue.userName, issue.repositoryName, issue.issueId).map(_.commentedUserName)
|
getComments(issue.userName, issue.repositoryName, issue.issueId).map(_.commentedUserName)
|
||||||
)
|
)
|
||||||
.distinct
|
.distinct
|
||||||
.withFilter ( _ != context.loginAccount.get.userName ) // the operation in person is excluded
|
.withFilter ( _ != loginAccount.userName ) // the operation in person is excluded
|
||||||
.foreach ( getAccountByUserName(_) filterNot (_.isGroupAccount) filterNot (LDAPUtil.isDummyMailAddress(_)) foreach (x => notify(x.mailAddress)) )
|
.foreach (
|
||||||
|
getAccountByUserName(_)
|
||||||
|
.filterNot (_.isGroupAccount)
|
||||||
|
.filterNot (LDAPUtil.isDummyMailAddress(_))
|
||||||
|
.foreach (x => notify(x.mailAddress))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
object Notifier {
|
object Notifier {
|
||||||
@@ -70,13 +76,14 @@ class Mailer(private val smtp: Smtp) extends Notifier {
|
|||||||
private val logger = LoggerFactory.getLogger(classOf[Mailer])
|
private val logger = LoggerFactory.getLogger(classOf[Mailer])
|
||||||
|
|
||||||
def toNotify(r: RepositoryService.RepositoryInfo, issue: Issue, content: String)
|
def toNotify(r: RepositoryService.RepositoryInfo, issue: Issue, content: String)
|
||||||
(msg: String => String)(implicit context: Context) = {
|
(msg: String => String)(implicit context: Context): Unit = {
|
||||||
|
context.loginAccount.foreach { loginAccount =>
|
||||||
val database = Database()
|
val database = Database()
|
||||||
|
|
||||||
val f = Future {
|
val f = Future {
|
||||||
database withSession { implicit session =>
|
database withSession { implicit session =>
|
||||||
defining(
|
defining(
|
||||||
s"[${r.name}] ${issue.title} (#${issue.issueId})" ->
|
s"[${r.owner}/${r.name}] ${issue.title} (#${issue.issueId})" ->
|
||||||
msg(Markdown.toHtml(
|
msg(Markdown.toHtml(
|
||||||
markdown = content,
|
markdown = content,
|
||||||
repository = r,
|
repository = r,
|
||||||
@@ -84,23 +91,21 @@ class Mailer(private val smtp: Smtp) extends Notifier {
|
|||||||
enableRefsLink = true,
|
enableRefsLink = true,
|
||||||
enableAnchor = false,
|
enableAnchor = false,
|
||||||
enableLineBreaks = false
|
enableLineBreaks = false
|
||||||
))) { case (subject, msg) =>
|
))
|
||||||
recipients(issue) { to =>
|
) { case (subject, msg) =>
|
||||||
send(to, subject, msg)
|
recipients(issue, loginAccount) { to => send(to, subject, msg, loginAccount) }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"Notifications Successful."
|
"Notifications Successful."
|
||||||
}
|
}
|
||||||
f onSuccess {
|
f.onComplete {
|
||||||
case s => logger.debug(s)
|
case Success(s) => logger.debug(s)
|
||||||
|
case Failure(t) => logger.error("Notifications Failed.", t)
|
||||||
}
|
}
|
||||||
f onFailure {
|
|
||||||
case t => logger.error("Notifications Failed.", t)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def send(to: String, subject: String, msg: String)(implicit context: Context): Unit = {
|
def send(to: String, subject: String, msg: String, loginAccount: Account): Unit = {
|
||||||
val email = new HtmlEmail
|
val email = new HtmlEmail
|
||||||
email.setHostName(smtp.host)
|
email.setHostName(smtp.host)
|
||||||
email.setSmtpPort(smtp.port.get)
|
email.setSmtpPort(smtp.port.get)
|
||||||
@@ -109,10 +114,17 @@ 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.starttls.foreach { starttls =>
|
||||||
|
email.setStartTLSEnabled(starttls)
|
||||||
|
email.setStartTLSRequired(starttls)
|
||||||
}
|
}
|
||||||
smtp.fromAddress
|
smtp.fromAddress
|
||||||
.map (_ -> smtp.fromName.getOrElse(context.loginAccount.get.userName))
|
.map (_ -> smtp.fromName.getOrElse(loginAccount.userName))
|
||||||
.orElse (Some("notifications@gitbucket.com" -> context.loginAccount.get.userName))
|
.orElse (Some("notifications@gitbucket.com" -> loginAccount.userName))
|
||||||
.foreach { case (address, name) =>
|
.foreach { case (address, name) =>
|
||||||
email.setFrom(address, name)
|
email.setFrom(address, name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
package gitbucket.core.util
|
package gitbucket.core.util
|
||||||
|
|
||||||
import java.net.{URLDecoder, URLEncoder}
|
import java.net.{URLDecoder, URLEncoder}
|
||||||
|
|
||||||
import org.mozilla.universalchardet.UniversalDetector
|
import org.mozilla.universalchardet.UniversalDetector
|
||||||
import ControlUtil._
|
import ControlUtil._
|
||||||
import org.apache.commons.io.input.BOMInputStream
|
import org.apache.commons.io.input.BOMInputStream
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
|
import org.apache.commons.codec.binary.Base64
|
||||||
|
|
||||||
import scala.util.control.Exception._
|
import scala.util.control.Exception._
|
||||||
|
|
||||||
object StringUtil {
|
object StringUtil {
|
||||||
|
|
||||||
|
private lazy val BlowfishKey = {
|
||||||
|
// last 4 numbers in current timestamp
|
||||||
|
val time = System.currentTimeMillis.toString
|
||||||
|
time.substring(time.length - 4)
|
||||||
|
}
|
||||||
|
|
||||||
def sha1(value: String): String =
|
def sha1(value: String): String =
|
||||||
defining(java.security.MessageDigest.getInstance("SHA-1")){ md =>
|
defining(java.security.MessageDigest.getInstance("SHA-1")){ md =>
|
||||||
md.update(value.getBytes)
|
md.update(value.getBytes)
|
||||||
@@ -21,6 +30,20 @@ object StringUtil {
|
|||||||
md.digest.map(b => "%02x".format(b)).mkString
|
md.digest.map(b => "%02x".format(b)).mkString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def encodeBlowfish(value: String): String = {
|
||||||
|
val spec = new javax.crypto.spec.SecretKeySpec(BlowfishKey.getBytes(), "Blowfish")
|
||||||
|
val cipher = javax.crypto.Cipher.getInstance("Blowfish")
|
||||||
|
cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, spec)
|
||||||
|
new String(Base64.encodeBase64(cipher.doFinal(value.getBytes("UTF-8"))), "UTF-8")
|
||||||
|
}
|
||||||
|
|
||||||
|
def decodeBlowfish(value: String): String = {
|
||||||
|
val spec = new javax.crypto.spec.SecretKeySpec(BlowfishKey.getBytes(), "Blowfish")
|
||||||
|
val cipher = javax.crypto.Cipher.getInstance("Blowfish")
|
||||||
|
cipher.init(javax.crypto.Cipher.DECRYPT_MODE, spec)
|
||||||
|
new String(cipher.doFinal(Base64.decodeBase64(value)), "UTF-8")
|
||||||
|
}
|
||||||
|
|
||||||
def urlEncode(value: String): String = URLEncoder.encode(value, "UTF-8").replace("+", "%20")
|
def urlEncode(value: String): String = URLEncoder.encode(value, "UTF-8").replace("+", "%20")
|
||||||
|
|
||||||
def urlDecode(value: String): String = URLDecoder.decode(value, "UTF-8")
|
def urlDecode(value: String): String = URLDecoder.decode(value, "UTF-8")
|
||||||
@@ -100,4 +123,19 @@ object StringUtil {
|
|||||||
"(?i)(?<!\\w)(?:fix(?:e[sd])?|resolve[sd]?|close[sd]?)\\s+#(\\d+)(?!\\w)".r
|
"(?i)(?<!\\w)(?:fix(?:e[sd])?|resolve[sd]?|close[sd]?)\\s+#(\\d+)(?!\\w)".r
|
||||||
.findAllIn(message).matchData.map(_.group(1)).toSeq.distinct
|
.findAllIn(message).matchData.map(_.group(1)).toSeq.distinct
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Encode search string for LIKE condition.
|
||||||
|
// * This method has been copied from Slick's SqlUtilsComponent.
|
||||||
|
// */
|
||||||
|
// def likeEncode(s: String) = {
|
||||||
|
// val b = new StringBuilder
|
||||||
|
// for(c <- s) c match {
|
||||||
|
// case '%' | '_' | '^' => b append '^' append c
|
||||||
|
// case _ => b append c
|
||||||
|
// }
|
||||||
|
// b.toString
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) =>
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ 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)
|
//helpers.decorateHtml(Marked.marked(source, options, renderer), repository)
|
||||||
|
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 = {
|
||||||
@@ -149,7 +149,7 @@ 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 "")
|
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("mailto:") || url.startsWith("/")){
|
||||||
url
|
url
|
||||||
} else if(url.startsWith("#")){
|
} else if(url.startsWith("#")){
|
||||||
("#" + generateAnchorName(url.substring(1)))
|
("#" + generateAnchorName(url.substring(1)))
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
import scala.util.matching.Regex._
|
import scala.util.matching.Regex._
|
||||||
implicit class RegexReplaceString(s: String) {
|
implicit class RegexReplaceString(private val s: String) extends AnyVal {
|
||||||
def replaceAll(pattern: String, replacer: (Match) => String): String = {
|
def replaceAll(pattern: String, replacer: (Match) => String): String = {
|
||||||
pattern.r.replaceAllIn(s, (m: Match) => replacer(m).replace("$", "\\$"))
|
pattern.r.replaceAllIn(s, (m: Match) => replacer(m).replace("$", "\\$"))
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
|||||||
/**
|
/**
|
||||||
* Implicit conversion to add mkHtml() to Seq[Html].
|
* Implicit conversion to add mkHtml() to Seq[Html].
|
||||||
*/
|
*/
|
||||||
implicit class RichHtmlSeq(seq: Seq[Html]) {
|
implicit class RichHtmlSeq(private val seq: Seq[Html]) extends AnyVal {
|
||||||
def mkHtml(separator: String) = Html(seq.mkString(separator))
|
def mkHtml(separator: String) = Html(seq.mkString(separator))
|
||||||
def mkHtml(separator: scala.xml.Elem) = Html(seq.mkString(separator.toString))
|
def mkHtml(separator: scala.xml.Elem) = Html(seq.mkString(separator.toString))
|
||||||
}
|
}
|
||||||
@@ -380,4 +380,11 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a human-readable display value (includes units - EB, PB, TB, GB, MB, KB or bytes)
|
||||||
|
*
|
||||||
|
* @param size total size of object in bytes
|
||||||
|
*/
|
||||||
|
def readableSize(size: Option[Long]): String = FileUtil.readableSize(size.getOrElse(0))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
@if(personalTokens.isEmpty && gneratedToken.isEmpty){
|
@if(personalTokens.isEmpty && gneratedToken.isEmpty){
|
||||||
No tokens.
|
No tokens.
|
||||||
} else {
|
} else {
|
||||||
Tokens you have generated that can be used to access the GitBucket API.
|
Tokens you have generated which 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) =>
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<a href="@context.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%;">
|
||||||
@gitbucket.core.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;">
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
<label for="note" class="strong">Token description</label>
|
<label for="note" class="strong">Token description</label>
|
||||||
<div><span id="error-note" class="error"></span></div>
|
<div><span id="error-note" class="error"></span></div>
|
||||||
<input type="text" name="note" id="note" class="form-control"/>
|
<input type="text" name="note" id="note" class="form-control"/>
|
||||||
<p class="muted">What's this token for?</p>
|
<p class="muted">What is this token for?</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<input type="submit" class="btn btn-success" value="Generate token"/>
|
<input type="submit" class="btn btn-success" value="Generate token"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -37,6 +37,11 @@
|
|||||||
<input type="text" name="url" id="url" class="form-control" value="@account.url"/>
|
<input type="text" name="url" id="url" class="form-control" value="@account.url"/>
|
||||||
<span id="error-url" class="error"></span>
|
<span id="error-url" class="error"></span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="form-group">
|
||||||
|
<label for="description" class="strong">Bio (optional):</label>
|
||||||
|
<textarea name="description" id="description" class="form-control">@account.description</textarea>
|
||||||
|
<span id="error-description" class="error"></span>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
|
|||||||
@@ -21,6 +21,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="form-group">
|
||||||
|
<label for="groupDescription" class="strong">Description (Optional)</label>
|
||||||
|
<div>
|
||||||
|
<textarea name="description" id="description" class="form-control">@account.map(_.description)</textarea>
|
||||||
|
</div>
|
||||||
|
</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>
|
||||||
@gitbucket.core.helper.html.uploadavatar(account)
|
@gitbucket.core.helper.html.uploadavatar(account)
|
||||||
@@ -43,10 +49,10 @@
|
|||||||
<fieldset class="border-top">
|
<fieldset class="border-top">
|
||||||
@if(account.isDefined){
|
@if(account.isDefined){
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a href="@helpers.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="@helpers.url(account.get.userName)" class="btn btn-default">Cancel</a>
|
<a href="@helpers.url(account.get.userName)" class="btn btn-default">Cancel</a>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="padding-left: 10px; padding-right: 10px;">
|
<div style="padding-left: 10px; padding-right: 10px;">
|
||||||
|
@account.description.map{ description =>
|
||||||
|
<p style="color: white;">@description</p>
|
||||||
|
}
|
||||||
@if(account.url.isDefined){
|
@if(account.url.isDefined){
|
||||||
<p style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
<p style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
||||||
<i class="octicon octicon-home"></i> <a href="@account.url">@account.url</a>
|
<i class="octicon octicon-home"></i> <a href="@account.url">@account.url</a>
|
||||||
@@ -38,7 +41,7 @@
|
|||||||
@if(account.isGroupAccount){
|
@if(account.isGroupAccount){
|
||||||
<li@if(active == "members"){ class="active"}><a href="@helpers.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="@helpers.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 =>
|
||||||
@@ -48,14 +51,14 @@
|
|||||||
@if(context.loginAccount.isDefined && context.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="@helpers.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(context.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="@helpers.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>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ isCreateRepoOptionPublic: Boolean)(implicit context: gitbucket.core.controller.C
|
|||||||
<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="@context.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">
|
||||||
|
|||||||
@@ -33,6 +33,11 @@
|
|||||||
<input type="text" name="url" id="url" class="form-control" value=""/>
|
<input type="text" name="url" id="url" class="form-control" value=""/>
|
||||||
<span id="error-url" class="error"></span>
|
<span id="error-url" class="error"></span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<label for="description" class="strong">Bio (optional):</label>
|
||||||
|
<textarea name="description" id="description" class="form-control"></textarea>
|
||||||
|
<span id="error-description" class="error"></span>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
<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="@context.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="@context.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="@context.path/admin/plugins">Plugins</a>
|
<a href="@context.path/admin/plugins">Plugins</a>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<a href="@context.path/admin/data">Data export / import</a>
|
<a href="@context.path/admin/data">Data export / import</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="@context.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 =>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
@(info: Option[Any])(implicit context: gitbucket.core.controller.Context)
|
@(info: Option[Any])(implicit context: gitbucket.core.controller.Context)
|
||||||
@gitbucket.core.html.main("System Settings"){
|
@gitbucket.core.html.main("System settings"){
|
||||||
@gitbucket.core.admin.html.menu("system"){
|
@gitbucket.core.admin.html.menu("system"){
|
||||||
@gitbucket.core.helper.html.information(info)
|
@gitbucket.core.helper.html.information(info)
|
||||||
<form action="@context.path/admin/system" method="POST" validate="true" class="form-horizontal">
|
<form action="@context.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 -->
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<p class="muted">
|
<p class="muted">
|
||||||
The base URL is used for redirect, notification email, git repository URL box and more.
|
The base URL is used for redirect, notification email, git repository URL box and more.
|
||||||
If the base URL is empty, GitBucket generates URL from request information.
|
If the base URL is empty, GitBucket generates URL from the request information.
|
||||||
You can use this property to adjust URL difference between the reverse proxy and GitBucket.
|
You can use this property to adjust to URL differences between the reverse proxy and GitBucket.
|
||||||
</p>
|
</p>
|
||||||
<!--====================================================================-->
|
<!--====================================================================-->
|
||||||
<!-- Information -->
|
<!-- Information -->
|
||||||
@@ -59,19 +59,19 @@
|
|||||||
</label>
|
</label>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="allowAccountRegistration" value="false"@if(!context.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>
|
||||||
<hr>
|
<hr>
|
||||||
<label class="strong">Default option to create a new repository</label>
|
<label class="strong">Default permissions when creating a new repository</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="isCreateRepoOptionPublic" value="true"@if(context.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 the repository.</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="isCreateRepoOptionPublic" value="false"@if(!context.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 the repository.</span>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<!--====================================================================-->
|
<!--====================================================================-->
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="allowAnonymousAccess" value="true"@if(context.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 and user/group profiles.</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="radio">
|
<label class="radio">
|
||||||
<input type="radio" name="allowAnonymousAccess" value="false"@if(!context.settings.allowAnonymousAccess){ checked}>
|
<input type="radio" name="allowAnonymousAccess" value="false"@if(!context.settings.allowAnonymousAccess){ checked}>
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
<!-- Activity -->
|
<!-- Activity -->
|
||||||
<!--====================================================================-->
|
<!--====================================================================-->
|
||||||
<hr>
|
<hr>
|
||||||
<label><span class="strong">Limit of activity logs</span> (Unlimited if it's not specified or zero)</label>
|
<label><span class="strong">Limit of activity logs</span> (Unlimited if it is not specified or zero)</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<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>
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" name="gravatar"@if(context.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>
|
||||||
<!--====================================================================-->
|
<!--====================================================================-->
|
||||||
@@ -123,27 +123,25 @@
|
|||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" id="ssh" name="ssh"@if(context.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
|
||||||
|
<span class="muted normal">(Both SSH host and Base URL are required if SSH access is enabled)</span>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="ssh">
|
<div class="ssh">
|
||||||
<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="@context.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="@context.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>
|
||||||
</div>
|
</div>
|
||||||
<p class="muted">
|
|
||||||
Both of SSH host and Base URL are required if SSH access is enabled.
|
|
||||||
</p>
|
|
||||||
<!--====================================================================-->
|
<!--====================================================================-->
|
||||||
<!-- Authentication -->
|
<!-- Authentication -->
|
||||||
<!--====================================================================-->
|
<!--====================================================================-->
|
||||||
@@ -157,14 +155,14 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="ldap">
|
<div class="ldap">
|
||||||
<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="@context.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="@context.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>
|
||||||
@@ -178,7 +176,7 @@
|
|||||||
</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="@context.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>
|
||||||
@@ -259,49 +257,56 @@
|
|||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" id="useSMTP" name="useSMTP" @if(context.settings.useSMTP){ checked}/>
|
<input type="checkbox" id="useSMTP" name="useSMTP" @if(context.settings.useSMTP){ checked}/>
|
||||||
SMTP
|
SMTP
|
||||||
|
<span class="muted normal">(Enable notification as well as SMTP configuration if you want to send notification email too)</span>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="useSMTP">
|
<div class="useSMTP">
|
||||||
<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="@context.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="@context.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="@context.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="@context.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="smtpSsl">Enable SSL</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="checkbox" id="smtpSsl" name="smtp.ssl"@if(context.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="smtpStarttls">Enable STARTTLS</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<input type="checkbox" id="smtpStarttls" name="smtp.starttls"@if(context.settings.smtp.flatMap(_.starttls).getOrElse(false)){ checked}/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<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="@context.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="@context.settings.smtp.map(_.fromName)"/>
|
<input type="text" id="fromName" name="smtp.fromName" class="form-control" value="@context.settings.smtp.map(_.fromName)"/>
|
||||||
</div>
|
</div>
|
||||||
@@ -311,11 +316,23 @@
|
|||||||
<input type="text" id="testAddress" size="30"/>
|
<input type="text" id="testAddress" size="30"/>
|
||||||
<input type="button" id="sendTestMail" value="Send"/>
|
<input type="button" id="sendTestMail" value="Send"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="muted">
|
|
||||||
Enable notification not only SMTP configuration if you want to send notification email.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
<!--====================================================================-->
|
||||||
|
<!-- GitLFS -->
|
||||||
|
<!--====================================================================-->
|
||||||
|
@*
|
||||||
|
<hr>
|
||||||
|
<label class="strong">
|
||||||
|
GitLFS <span class="muted normal">(Enter the LFS server url to enable GitLFS support)</span>
|
||||||
|
</label>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-md-3" for="smtpHost">LFS server url</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<input type="text" id="lfsServerUrl" name="lfs.serverUrl" class="form-control" value="@context.settings.lfs.serverUrl"/>
|
||||||
|
<span id="error-lfs_serverUrl" class="error"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
*@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="align-right" style="margin-top: 20px;">
|
<div class="align-right" style="margin-top: 20px;">
|
||||||
@@ -332,6 +349,7 @@ $(function(){
|
|||||||
var user = $('#smtpUser' ).val();
|
var user = $('#smtpUser' ).val();
|
||||||
var password = $('#smtpPassword').val();
|
var password = $('#smtpPassword').val();
|
||||||
var ssl = $('#smtpSsl' ).prop('checked');
|
var ssl = $('#smtpSsl' ).prop('checked');
|
||||||
|
var starttls = $('#smtpStarttls').prop('checked');
|
||||||
var fromAddress = $('#fromAddress' ).val();
|
var fromAddress = $('#fromAddress' ).val();
|
||||||
var fromName = $('#fromName' ).val();
|
var fromName = $('#fromName' ).val();
|
||||||
var testAddress = $('#testAddress' ).val();
|
var testAddress = $('#testAddress' ).val();
|
||||||
@@ -349,6 +367,7 @@ $(function(){
|
|||||||
'smtp.user': user,
|
'smtp.user': user,
|
||||||
'smtp.password': password,
|
'smtp.password': password,
|
||||||
'smtp.ssl': ssl,
|
'smtp.ssl': ssl,
|
||||||
|
'smtp.starttls': starttls,
|
||||||
'smtp.fromAddress': fromAddress,
|
'smtp.fromAddress': fromAddress,
|
||||||
'smtp.fromName': fromName,
|
'smtp.fromName': fromName,
|
||||||
'testAddress': testAddress
|
'testAddress': testAddress
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
@(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)
|
||||||
@gitbucket.core.html.main(if(account.isEmpty) "New User" else "Update User"){
|
@gitbucket.core.html.main(if(account.isEmpty) "New user" else "Update user"){
|
||||||
@gitbucket.core.admin.html.menu("users"){
|
@gitbucket.core.admin.html.menu("users"){
|
||||||
@gitbucket.core.helper.html.error(error)
|
@gitbucket.core.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){@context.path/admin/users/_newuser} else {@context.path/admin/users/@account.get.userName/_edituser}" validate="true">
|
||||||
@@ -66,6 +66,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="form-group">
|
||||||
|
<label class="strong">Bio (Optional):</label>
|
||||||
|
<div>
|
||||||
|
<span id="error-description" class="error"></span>
|
||||||
|
</div>
|
||||||
|
<textarea name="description" id="description" class="form-control">@account.map(_.description)</textarea>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
@@ -75,7 +82,7 @@
|
|||||||
</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="@context.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,5 +1,5 @@
|
|||||||
@(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)
|
||||||
@gitbucket.core.html.main(if(account.isEmpty) "New Group" else "Update Group"){
|
@gitbucket.core.html.main(if(account.isEmpty) "New group" else "Update group"){
|
||||||
@gitbucket.core.admin.html.menu("users"){
|
@gitbucket.core.admin.html.menu("users"){
|
||||||
<form method="POST" action="@if(account.isEmpty){@context.path/admin/users/_newgroup} else {@context.path/admin/users/@account.get.userName/_editgroup}" validate="true">
|
<form method="POST" action="@if(account.isEmpty){@context.path/admin/users/_newgroup} else {@context.path/admin/users/@account.get.userName/_editgroup}" validate="true">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -24,6 +24,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="form-group">
|
||||||
|
<label class="strong">Description (Optional)</label>
|
||||||
|
<textarea name="description" id="description" class="form-control">@account.map(_.description)</textarea>
|
||||||
|
</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>
|
||||||
@gitbucket.core.helper.html.uploadavatar(account)
|
@gitbucket.core.helper.html.uploadavatar(account)
|
||||||
@@ -44,7 +48,7 @@
|
|||||||
</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="@context.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>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
@gitbucket.core.html.main("Manage Users"){
|
@gitbucket.core.html.main("Manage Users"){
|
||||||
@gitbucket.core.admin.html.menu("users"){
|
@gitbucket.core.admin.html.menu("users"){
|
||||||
<div class="pull-right" style="margin-bottom: 4px;">
|
<div class="pull-right" style="margin-bottom: 4px;">
|
||||||
<a href="@context.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="@context.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}/>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
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)
|
||||||
@gitbucket.core.html.main("Pull Requests"){
|
@gitbucket.core.html.main("Pull requests"){
|
||||||
@gitbucket.core.dashboard.html.sidebar(recentRepositories, userRepositories){
|
@gitbucket.core.dashboard.html.sidebar(recentRepositories, userRepositories){
|
||||||
@gitbucket.core.dashboard.html.tab("pulls")
|
@gitbucket.core.dashboard.html.tab("pulls")
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user