mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 04:56:02 +01:00
Compare commits
154 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
161c5513df | ||
|
|
538c1d7a9a | ||
|
|
123c17d442 | ||
|
|
6b7fd7fb7b | ||
|
|
0c0fde3077 | ||
|
|
1cf6950e70 | ||
|
|
5eddeba3ef | ||
|
|
75f4903ffb | ||
|
|
9727259d0c | ||
|
|
6bb664e592 | ||
|
|
f106dea3d9 | ||
|
|
982cc15052 | ||
|
|
1ef3299574 | ||
|
|
49f0795b5f | ||
|
|
af697d8155 | ||
|
|
81a779d1d9 | ||
|
|
7c484297d7 | ||
|
|
a91e46f3e9 | ||
|
|
5f18de06f5 | ||
|
|
bef5b5f22e | ||
|
|
092e832d21 | ||
|
|
cd836f331e | ||
|
|
53537eaa09 | ||
|
|
8515ef5b26 | ||
|
|
a2524608c7 | ||
|
|
127ddcef6d | ||
|
|
076bc9e2d6 | ||
|
|
d19b2778fe | ||
|
|
4d947aef7b | ||
|
|
1f3fc62a0e | ||
|
|
8b089837f9 | ||
|
|
4c4327b569 | ||
|
|
d72e9b2692 | ||
|
|
e021868a96 | ||
|
|
0c3cf5b140 | ||
|
|
32bd52d74d | ||
|
|
55f52b7f78 | ||
|
|
4ef45d3987 | ||
|
|
ebc6121526 | ||
|
|
8a36acb673 | ||
|
|
9efe438697 | ||
|
|
4c7540451e | ||
|
|
cdeaede8bf | ||
|
|
ad73e1d529 | ||
|
|
68e858541d | ||
|
|
709e423a6d | ||
|
|
392139c061 | ||
|
|
64db3e7842 | ||
|
|
14e8071713 | ||
|
|
cea09fa766 | ||
|
|
019767e8c3 | ||
|
|
3c34689e7d | ||
|
|
d3cca0685a | ||
|
|
72049c5bdf | ||
|
|
d636413471 | ||
|
|
d1c6cbf55a | ||
|
|
e439a2f5f7 | ||
|
|
ecde6aefbf | ||
|
|
b95d912542 | ||
|
|
eb50b74b4a | ||
|
|
d460185317 | ||
|
|
2297ef0bec | ||
|
|
8d7ec16ed0 | ||
|
|
4dfc9fc456 | ||
|
|
3b99e619db | ||
|
|
9cded1b4de | ||
|
|
bfc88a489a | ||
|
|
f2a213f32a | ||
|
|
9663d21ce8 | ||
|
|
30c8d3c39c | ||
|
|
88e72bee2c | ||
|
|
c67441b6d4 | ||
|
|
e1802978d3 | ||
|
|
1ccdc79051 | ||
|
|
3ca0d35a1b | ||
|
|
7bbeceec97 | ||
|
|
1295e621ce | ||
|
|
5f4580399b | ||
|
|
8d735205aa | ||
|
|
64f15e015f | ||
|
|
a95abf7397 | ||
|
|
3054834b91 | ||
|
|
572ea5bf47 | ||
|
|
9c9876c918 | ||
|
|
8d30d68a4a | ||
|
|
88a8552d4d | ||
|
|
7608a41f9c | ||
|
|
7f7c55aeee | ||
|
|
2ebed8ef94 | ||
|
|
2904bcf4a7 | ||
|
|
6630fa2f37 | ||
|
|
351e63e7b6 | ||
|
|
ea0f35a0a1 | ||
|
|
623c53e169 | ||
|
|
3e6fd2caf8 | ||
|
|
39f1aa4487 | ||
|
|
8ffd905a9f | ||
|
|
668f9ef919 | ||
|
|
ffb9bb10f5 | ||
|
|
2618f54442 | ||
|
|
6b3218dd43 | ||
|
|
56a9b7b0f1 | ||
|
|
4f4afc5686 | ||
|
|
87fb136b85 | ||
|
|
7af271e14a | ||
|
|
f44d44cb4a | ||
|
|
e7fc5f1753 | ||
|
|
f0e2775861 | ||
|
|
2488ab9bd4 | ||
|
|
f0872d410c | ||
|
|
9d69cc9d45 | ||
|
|
1c66052372 | ||
|
|
158f799ca1 | ||
|
|
907532fd13 | ||
|
|
0f6a433623 | ||
|
|
00eab5d584 | ||
|
|
5d928b1a62 | ||
|
|
50d6f0c96f | ||
|
|
a60b43b862 | ||
|
|
4b1235b484 | ||
|
|
f354b9cfd7 | ||
|
|
0c2283ce28 | ||
|
|
840479a022 | ||
|
|
1bceaaab1d | ||
|
|
65ece3292a | ||
|
|
e410623cac | ||
|
|
09f7f036aa | ||
|
|
5249224dec | ||
|
|
00def3a46d | ||
|
|
134c0010b5 | ||
|
|
fe3b40557a | ||
|
|
d3cdc5d5fc | ||
|
|
7ebb28be74 | ||
|
|
707cd3c5c3 | ||
|
|
4c5017d108 | ||
|
|
fdd91b1e0e | ||
|
|
9124777ce7 | ||
|
|
7c575fdc52 | ||
|
|
f9d6f1334f | ||
|
|
65d4900325 | ||
|
|
64248d1fce | ||
|
|
bec75120bc | ||
|
|
3b0eed48d9 | ||
|
|
25c4b1e6a7 | ||
|
|
cccff46715 | ||
|
|
fc0ffd1b4f | ||
|
|
b70a2a2327 | ||
|
|
b5ca7ca0e1 | ||
|
|
c64428e37f | ||
|
|
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.
|
||||
- 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.
|
||||
- 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 tests are passing
|
||||
- [] 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 /etc/init.d/mysql stop
|
||||
- sudo /etc/init.d/postgresql stop
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.ivy2/cache
|
||||
- $HOME/.sbt/boot
|
||||
- $HOME/.sbt/launchers
|
||||
- $HOME/.coursier
|
||||
- $HOME/.embedmysql
|
||||
- $HOME/.embedpostgresql
|
||||
|
||||
90
README.md
90
README.md
@@ -2,69 +2,93 @@ GitBucket [](htt
|
||||
=========
|
||||
|
||||
GitBucket is a Git platform powered by Scala offering:
|
||||
- easy installation
|
||||
- high extensibility by plugins
|
||||
- API compatibility with Github
|
||||
- Easy installation
|
||||
- High extensibility by plugins
|
||||
- API compatibility with GitHub
|
||||
|
||||
Features
|
||||
--------
|
||||
The current version of GitBucket provides a basic features below:
|
||||
|
||||
- Public / Private Git repository (http and ssh access)
|
||||
- Repository viewer and online file editing
|
||||
- Wiki
|
||||
- Issues / Pull request
|
||||
- Repository viewer and online file editor
|
||||
- Issues, Pull request and Wiki for repositories
|
||||
- Email notification
|
||||
- Simple user and group management with LDAP integration
|
||||
- Account and group management with LDAP integration
|
||||
- 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
|
||||
--------
|
||||
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).
|
||||
2. Deploy it to the Servlet 3.0 container such as Tomcat 7.x, Jetty 8.x, GlassFish 3.x or higher.
|
||||
3. Access **http://[hostname]:[port]/gitbucket/** using your web browser and logged-in with **root** / **root**.
|
||||
1. Download the latest **gitbucket.war** from [the releases page](https://github.com/gitbucket/gitbucket/releases) and run it by `java -jar gitbucket.war`.
|
||||
2. Go to `http://[hostname]:8080/` and log in with **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]
|
||||
- --prefix=[CONTEXTPATH]
|
||||
- --host=[HOSTNAME]
|
||||
- --gitbucket.home=[DATA_DIR]
|
||||
- `--port=[NUMBER]`
|
||||
- `--prefix=[CONTEXTPATH]`
|
||||
- `--host=[HOSTNAME]`
|
||||
- `--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-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)
|
||||
|
||||
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
|
||||
--------
|
||||
|
||||
- If you have any question about GitBucket, send it to [gitter room](https://gitter.im/gitbucket/gitbucket) before raise an issue.
|
||||
- Make sure check whether there is a same question or request in the past.
|
||||
- When raise a new issue, write subject in **English** at least.
|
||||
- We can also support in Japaneses other than English at [gitter room for Japanese](https://gitter.im/gitbucket/gitbucket_ja).
|
||||
- First priority of GitBucket is easy installation and API compatibility with GitHub, so we might reject if your request is against it.
|
||||
- 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 the same question or request in the past.
|
||||
- When raise a new issue, write at least the subject in **English**.
|
||||
- We can also provide support in Japanese at [gitter room for Japanese](https://gitter.im/gitbucket/gitbucket_ja).
|
||||
- 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
|
||||
-------------
|
||||
## 4.9 - 29 Jan 2017
|
||||
- GitLFS support
|
||||
- Template for issues and pull requests
|
||||
- Manual label color editing
|
||||
- Account description
|
||||
- `--tmp-dir` option for standalone mode
|
||||
- More APIs for issues
|
||||
- [List issues for a repository](https://developer.github.com/v3/issues/#list-issues-for-a-repository)
|
||||
- [Create an issue](https://developer.github.com/v3/issues/#create-an-issue)
|
||||
|
||||
## 4.8 - 23 Dec 2016
|
||||
- Search for repository names from the global header
|
||||
- Filter repositories on the sidebar of the dashboard
|
||||
- Search issues and wiki
|
||||
- Keep pull request comments after new commits are pushed
|
||||
- New web API to get a single issue
|
||||
- Performance improvement for the repository viewer
|
||||
|
||||
### 4.7.1 - 28 Nov 2016
|
||||
- Bug fix: group repositories are not shown in the your repositories list on the sidebar
|
||||
- Small performance improvement of the dashboard
|
||||
|
||||
### 4.7 - 26 Nov 2016
|
||||
- New permission system
|
||||
- Dropdown filter for issue labels, milestones and assignees
|
||||
|
||||
16
build.sbt
16
build.sbt
@@ -1,6 +1,6 @@
|
||||
val Organization = "io.github.gitbucket"
|
||||
val Name = "gitbucket"
|
||||
val GitBucketVersion = "4.7.0"
|
||||
val GitBucketVersion = "4.9.0"
|
||||
val ScalatraVersion = "2.4.1"
|
||||
val JettyVersion = "9.3.9.v20160517"
|
||||
|
||||
@@ -15,14 +15,15 @@ scalaVersion := "2.11.8"
|
||||
// dependency settings
|
||||
resolvers ++= Seq(
|
||||
Classpaths.typesafeReleases,
|
||||
Resolver.jcenterRepo,
|
||||
"amateras" at "http://amateras.sourceforge.jp/mvn/",
|
||||
"sonatype-snapshot" at "https://oss.sonatype.org/content/repositories/snapshots/",
|
||||
"amateras-snapshot" at "http://amateras.sourceforge.jp/mvn-snapshot/"
|
||||
)
|
||||
libraryDependencies ++= Seq(
|
||||
"org.scala-lang.modules" %% "scala-java8-compat" % "0.7.0",
|
||||
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % "4.1.2.201602141800-r",
|
||||
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % "4.1.2.201602141800-r",
|
||||
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % "4.6.0.201612231935-r",
|
||||
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % "4.6.0.201612231935-r",
|
||||
"org.scalatra" %% "scalatra" % ScalatraVersion,
|
||||
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
|
||||
"org.json4s" %% "json4s-jackson" % "3.3.0",
|
||||
@@ -45,12 +46,15 @@ libraryDependencies ++= Seq(
|
||||
"com.typesafe" % "config" % "1.3.0",
|
||||
"com.typesafe.akka" %% "akka-actor" % "2.3.15",
|
||||
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.0.0",
|
||||
"com.github.bkromhout" % "java-diff-utils" % "2.1.1",
|
||||
"org.cache2k" % "cache2k-all" % "1.0.0.CR1",
|
||||
"com.enragedginger" %% "akka-quartz-scheduler" % "1.4.0-akka-2.3.x" exclude("c3p0","c3p0"),
|
||||
"net.coobird" % "thumbnailator" % "0.4.8",
|
||||
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
|
||||
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
|
||||
"junit" % "junit" % "4.12" % "test",
|
||||
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
|
||||
"com.wix" % "wix-embedded-mysql" % "1.0.3" % "test",
|
||||
"com.wix" % "wix-embedded-mysql" % "2.1.4" % "test",
|
||||
"ru.yandex.qatools.embed" % "postgresql-embedded" % "1.14" % "test"
|
||||
)
|
||||
|
||||
@@ -162,9 +166,9 @@ executableKey := {
|
||||
log info s"built executable webapp ${outputFile}"
|
||||
outputFile
|
||||
}
|
||||
publishTo <<= version { (v: String) =>
|
||||
publishTo := {
|
||||
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")
|
||||
}
|
||||
publishMavenStyle := true
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
RPM spec file and init script for Red Hat Enterprise Linux 6.x.
|
||||
|
||||
To create RPM:
|
||||
|
||||
1. Edit `../../gitbucket.conf` to suit.
|
||||
2. Edit `gitbucket.init` to suit.
|
||||
3. Edit `gitbucket.spec` to suit.
|
||||
|
||||
@@ -5,3 +5,4 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
|
||||
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "2.1.0")
|
||||
addSbtPlugin("fi.gekkio.sbtplugins" % "sbt-jrebel-plugin" % "0.10.0")
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")
|
||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15")
|
||||
|
||||
1
project/project/plugins.sbt
Normal file
1
project/project/plugins.sbt
Normal file
@@ -0,0 +1 @@
|
||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15")
|
||||
@@ -12,6 +12,7 @@ public class JettyLauncher {
|
||||
int port = 8080;
|
||||
InetSocketAddress address = null;
|
||||
String contextPath = "/";
|
||||
String tmpDirPath="";
|
||||
boolean forceHttps = false;
|
||||
|
||||
for(String arg: args) {
|
||||
@@ -24,8 +25,13 @@ public class JettyLauncher {
|
||||
port = Integer.parseInt(dim[1]);
|
||||
} else if(dim[0].equals("--prefix")) {
|
||||
contextPath = dim[1];
|
||||
if(!contextPath.startsWith("/")){
|
||||
contextPath = "/" + contextPath;
|
||||
}
|
||||
} else if(dim[0].equals("--gitbucket.home")){
|
||||
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();
|
||||
|
||||
File tmpDir = new File(getGitBucketHome(), "tmp");
|
||||
File tmpDir;
|
||||
if(tmpDirPath.equals("")){
|
||||
tmpDir = new File(getGitBucketHome(), "tmp");
|
||||
if(!tmpDir.exists()){
|
||||
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);
|
||||
|
||||
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>
|
||||
@@ -22,5 +22,10 @@ object GitBucketCoreModule extends Module("gitbucket-core",
|
||||
new Version("4.7.0",
|
||||
new LiquibaseMigration("update/gitbucket-core_4.7.xml"),
|
||||
new SqlMigration("update/gitbucket-core_4.7.sql")
|
||||
),
|
||||
new Version("4.7.1"),
|
||||
new Version("4.8"),
|
||||
new Version("4.9.0",
|
||||
new LiquibaseMigration("update/gitbucket-core_4.9.xml")
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package gitbucket.core.api
|
||||
|
||||
import gitbucket.core.model.{Issue, PullRequest}
|
||||
|
||||
import gitbucket.core.model.{Account, Issue, IssueComment, PullRequest}
|
||||
import java.util.Date
|
||||
|
||||
|
||||
@@ -15,6 +14,9 @@ case class ApiPullRequest(
|
||||
head: ApiPullRequest.Commit,
|
||||
base: ApiPullRequest.Commit,
|
||||
mergeable: Option[Boolean],
|
||||
merged: Boolean,
|
||||
merged_at: Option[Date],
|
||||
merged_by: Option[ApiUser],
|
||||
title: String,
|
||||
body: String,
|
||||
user: ApiUser) {
|
||||
@@ -31,7 +33,14 @@ case class 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(
|
||||
number = issue.issueId,
|
||||
updated_at = issue.updatedDate,
|
||||
@@ -45,6 +54,9 @@ object ApiPullRequest{
|
||||
ref = pullRequest.branch,
|
||||
repo = baseRepo)(issue.userName),
|
||||
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,
|
||||
body = issue.content.getOrElse(""),
|
||||
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 =>
|
||||
|
||||
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,
|
||||
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)
|
||||
|
||||
@@ -43,6 +43,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
||||
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
||||
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
||||
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress()))),
|
||||
"description" -> trim(label("bio" , optional(text()))),
|
||||
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
||||
"fileId" -> trim(label("File ID" , optional(text())))
|
||||
)(AccountNewForm.apply)
|
||||
@@ -51,6 +52,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
||||
"password" -> trim(label("Password" , optional(text(maxlength(20))))),
|
||||
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
||||
"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))))),
|
||||
"fileId" -> trim(label("File ID" , optional(text()))),
|
||||
"clearImage" -> trim(label("Clear image" , boolean()))
|
||||
@@ -65,11 +67,12 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
||||
"note" -> trim(label("Token", text(required, maxlength(100))))
|
||||
)(PersonalTokenForm.apply)
|
||||
|
||||
case class NewGroupForm(groupName: 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 NewGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String], members: String)
|
||||
case class EditGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String], members: String, clearImage: Boolean)
|
||||
|
||||
val newGroupForm = mapping(
|
||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||
"description" -> trim(label("Group description", optional(text()))),
|
||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||
"members" -> trim(label("Members" ,text(required, members)))
|
||||
@@ -77,6 +80,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
||||
|
||||
val editGroupForm = mapping(
|
||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
||||
"description" -> trim(label("Group description", optional(text()))),
|
||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||
"members" -> trim(label("Members" ,text(required, members))),
|
||||
@@ -167,6 +171,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
||||
password = form.password.map(sha1).getOrElse(account.password),
|
||||
fullName = form.fullName,
|
||||
mailAddress = form.mailAddress,
|
||||
description = form.description,
|
||||
url = form.url))
|
||||
|
||||
updateImage(userName, form.fileId, form.clearImage)
|
||||
@@ -266,7 +271,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
||||
|
||||
post("/register", newForm){ form =>
|
||||
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)
|
||||
redirect("/signin")
|
||||
} else NotFound()
|
||||
@@ -277,7 +282,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
||||
})
|
||||
|
||||
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 {
|
||||
_.split(":") match {
|
||||
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
||||
@@ -315,7 +320,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
||||
}
|
||||
}.toList){ case (groupName, members) =>
|
||||
getAccountByUserName(groupName, true).map { account =>
|
||||
updateGroup(groupName, form.url, false)
|
||||
updateGroup(groupName, form.description, form.url, false)
|
||||
|
||||
// Update GROUP_MEMBER
|
||||
updateGroupMembers(form.groupName, members)
|
||||
|
||||
@@ -21,9 +21,12 @@ class ApiController extends ApiControllerBase
|
||||
with ProtectedBranchService
|
||||
with IssuesService
|
||||
with LabelsService
|
||||
with MilestonesService
|
||||
with PullRequestService
|
||||
with CommitsService
|
||||
with CommitStatusService
|
||||
with RepositoryCreationService
|
||||
with IssueCreationService
|
||||
with HandleCommentService
|
||||
with WebHookService
|
||||
with WebHookPullRequestService
|
||||
@@ -43,9 +46,11 @@ trait ApiControllerBase extends ControllerBase {
|
||||
with ProtectedBranchService
|
||||
with IssuesService
|
||||
with LabelsService
|
||||
with MilestonesService
|
||||
with PullRequestService
|
||||
with CommitStatusService
|
||||
with RepositoryCreationService
|
||||
with IssueCreationService
|
||||
with HandleCommentService
|
||||
with OwnerAuthenticator
|
||||
with UsersAuthenticator
|
||||
@@ -132,9 +137,12 @@ trait ApiControllerBase extends ControllerBase {
|
||||
val largeFile = params.get("large_file").exists(s => s.equals("true"))
|
||||
val content = getContentFromId(git, f.id, largeFile)
|
||||
request.getHeader("Accept") match {
|
||||
case "application/vnd.github.v3.raw" =>
|
||||
case "application/vnd.github.v3.raw" => {
|
||||
contentType = "application/vnd.github.v3.raw"
|
||||
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 =>
|
||||
List(
|
||||
"<div data-path=\"", path, "\" id=\"file\">", "<article>",
|
||||
@@ -142,7 +150,9 @@ trait ApiControllerBase extends ControllerBase {
|
||||
"</article>", "</div>"
|
||||
).mkString
|
||||
)
|
||||
case "application/vnd.github.v3.html" =>
|
||||
}
|
||||
case "application/vnd.github.v3.html" => {
|
||||
contentType = "application/vnd.github.v3.html"
|
||||
content.map(c =>
|
||||
List(
|
||||
"<div data-path=\"", path, "\" id=\"file\">", "<div class=\"plain\">", "<pre>",
|
||||
@@ -150,6 +160,7 @@ trait ApiControllerBase extends ControllerBase {
|
||||
"</pre>", "</div>", "</div>"
|
||||
).mkString
|
||||
)
|
||||
}
|
||||
case _ =>
|
||||
Some(JsonFormat(ApiContents(f, content)))
|
||||
}
|
||||
@@ -168,7 +179,7 @@ trait ApiControllerBase extends ControllerBase {
|
||||
using(Git.open(getRepositoryDir(params("owner"), params("repo")))) { git =>
|
||||
//JsonFormat( (revstr, git.getRepository().resolve(revstr)) )
|
||||
// getRef is deprecated by jgit-4.2. use exactRef() or findRef()
|
||||
val sha = git.getRepository().getRef(revstr).getObjectId().name()
|
||||
val sha = git.getRepository().exactRef(revstr).getObjectId().name()
|
||||
JsonFormat(ApiRef(revstr, ApiObject(sha)))
|
||||
}
|
||||
})
|
||||
@@ -276,6 +287,68 @@ trait ApiControllerBase extends ControllerBase {
|
||||
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
|
||||
*/
|
||||
@@ -363,12 +436,14 @@ trait ApiControllerBase extends ControllerBase {
|
||||
updateLabel(repository.owner, repository.name, label.labelId, data.name, data.color)
|
||||
JsonFormat(ApiLabel(
|
||||
getLabel(repository.owner, repository.name, label.labelId).get,
|
||||
RepositoryName(repository)))
|
||||
RepositoryName(repository)
|
||||
))
|
||||
} else {
|
||||
// TODO ApiError should support errors field to enhance compatibility of GitHub API
|
||||
UnprocessableEntity(ApiError(
|
||||
"Validation Failed",
|
||||
Some("https://developer.github.com/v3/issues/labels/#create-a-label")))
|
||||
Some("https://developer.github.com/v3/issues/labels/#create-a-label")
|
||||
))
|
||||
}
|
||||
} getOrElse NotFound()
|
||||
}
|
||||
@@ -407,11 +482,12 @@ trait ApiControllerBase extends ControllerBase {
|
||||
|
||||
JsonFormat(issues.map { case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner) =>
|
||||
ApiPullRequest(
|
||||
issue,
|
||||
pullRequest,
|
||||
ApiRepository(headRepo, ApiUser(headOwner)),
|
||||
ApiRepository(repository, ApiUser(baseOwner)),
|
||||
ApiUser(issueUser)
|
||||
issue = issue,
|
||||
pullRequest = pullRequest,
|
||||
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
|
||||
baseRepo = ApiRepository(repository, ApiUser(baseOwner)),
|
||||
user = ApiUser(issueUser),
|
||||
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -423,18 +499,20 @@ trait ApiControllerBase extends ControllerBase {
|
||||
(for{
|
||||
issueId <- params("id").toIntOpt
|
||||
(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)
|
||||
headOwner <- users.get(pullRequest.requestUserName)
|
||||
issueUser <- users.get(issue.openedUserName)
|
||||
headRepo <- getRepository(pullRequest.requestUserName, pullRequest.requestRepositoryName)
|
||||
} yield {
|
||||
JsonFormat(ApiPullRequest(
|
||||
issue,
|
||||
pullRequest,
|
||||
ApiRepository(headRepo, ApiUser(headOwner)),
|
||||
ApiRepository(repository, ApiUser(baseOwner)),
|
||||
ApiUser(issueUser)))
|
||||
issue = issue,
|
||||
pullRequest = pullRequest,
|
||||
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
|
||||
baseRepo = ApiRepository(repository, ApiUser(baseOwner)),
|
||||
user = ApiUser(issueUser),
|
||||
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||
))
|
||||
}) getOrElse NotFound()
|
||||
})
|
||||
|
||||
@@ -450,7 +528,7 @@ trait ApiControllerBase extends ControllerBase {
|
||||
val oldId = git.getRepository.resolve(pullreq.commitIdFrom)
|
||||
val newId = git.getRepository.resolve(pullreq.commitIdTo)
|
||||
val repoFullName = RepositoryName(repository)
|
||||
val commits = git.log.addRange(oldId, newId).call.iterator.asScala.map(c => ApiCommitListItem(new CommitInfo(c), repoFullName)).toList
|
||||
val commits = git.log.addRange(oldId, newId).call.iterator.asScala.map { c => ApiCommitListItem(new CommitInfo(c), repoFullName) }.toList
|
||||
JsonFormat(commits)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util._
|
||||
|
||||
import io.github.gitbucket.scalatra.forms._
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.json4s._
|
||||
import org.scalatra._
|
||||
import org.scalatra.i18n._
|
||||
@@ -20,6 +19,8 @@ import javax.servlet.{FilterChain, ServletResponse, ServletRequest}
|
||||
|
||||
import scala.util.Try
|
||||
|
||||
import net.coobird.thumbnailator.Thumbnails
|
||||
|
||||
|
||||
/**
|
||||
* Provides generic features for controller implementations.
|
||||
@@ -57,7 +58,7 @@ abstract class ControllerBase extends ScalatraFilter
|
||||
// Redirect to dashboard
|
||||
httpResponse.sendRedirect(baseUrl + "/")
|
||||
}
|
||||
} else if(path.startsWith("/git/")){
|
||||
} else if(path.startsWith("/git/") || path.startsWith("/git-lfs/")){
|
||||
// Git repository
|
||||
chain.doFilter(request, response)
|
||||
} else {
|
||||
@@ -225,10 +226,13 @@ trait AccountManagementControllerBase extends ControllerBase {
|
||||
} else {
|
||||
fileId.map { fileId =>
|
||||
val filename = "avatar." + FileUtil.getExtension(session.getAndRemove(Keys.Session.Upload(fileId)).get)
|
||||
FileUtils.moveFile(
|
||||
new java.io.File(getTemporaryDir(session.getId), fileId),
|
||||
new java.io.File(getUserUploadDir(userName), filename)
|
||||
)
|
||||
val uploadDir = getUserUploadDir(userName)
|
||||
if(!uploadDir.exists){
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package gitbucket.core.controller
|
||||
|
||||
import gitbucket.core.dashboard.html
|
||||
import gitbucket.core.service.{RepositoryService, PullRequestService, AccountService, IssuesService}
|
||||
import gitbucket.core.util.{StringUtil, Keys, UsersAuthenticator}
|
||||
import gitbucket.core.service._
|
||||
import gitbucket.core.util.{Keys, UsersAuthenticator}
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.service.IssuesService._
|
||||
|
||||
class DashboardController extends DashboardControllerBase
|
||||
with IssuesService with PullRequestService with RepositoryService with AccountService
|
||||
with IssuesService with PullRequestService with RepositoryService with AccountService with CommitsService
|
||||
with UsersAuthenticator
|
||||
|
||||
trait DashboardControllerBase extends ControllerBase {
|
||||
@@ -76,7 +76,7 @@ trait DashboardControllerBase extends ControllerBase {
|
||||
},
|
||||
filter,
|
||||
getGroupNames(userName),
|
||||
getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true),
|
||||
Nil,
|
||||
getUserRepositories(userName, withoutPhysicalInfo = true))
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ trait DashboardControllerBase extends ControllerBase {
|
||||
},
|
||||
filter,
|
||||
getGroupNames(userName),
|
||||
getVisibleRepositories(context.loginAccount, withoutPhysicalInfo = true),
|
||||
Nil,
|
||||
getUserRepositories(userName, withoutPhysicalInfo = true))
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import gitbucket.core.util.Implicits._
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.dircache.DirCache
|
||||
import org.eclipse.jgit.lib.{FileMode, Constants}
|
||||
import org.scalatra
|
||||
import org.scalatra._
|
||||
import org.scalatra.servlet.{MultipartConfig, FileUploadSupport, FileItem}
|
||||
import org.apache.commons.io.{IOUtils, FileUtils}
|
||||
|
||||
@@ -5,7 +5,7 @@ import gitbucket.core.model.Account
|
||||
import gitbucket.core.service._
|
||||
import gitbucket.core.util.Implicits._
|
||||
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 org.scalatra.Ok
|
||||
|
||||
@@ -36,23 +36,11 @@ trait IndexControllerBase extends ControllerBase {
|
||||
|
||||
|
||||
get("/"){
|
||||
val loginAccount = context.loginAccount
|
||||
if(loginAccount.isEmpty) {
|
||||
gitbucket.core.html.index(getRecentActivities(),
|
||||
getVisibleRepositories(loginAccount, withoutPhysicalInfo = true),
|
||||
loginAccount.map{ account => getUserRepositories(account.userName, withoutPhysicalInfo = true) }.getOrElse(Nil)
|
||||
)
|
||||
} else {
|
||||
val loginUserName = loginAccount.get.userName
|
||||
val loginUserGroups = getGroupsByUserName(loginUserName)
|
||||
var visibleOwnerSet : Set[String] = Set(loginUserName)
|
||||
|
||||
visibleOwnerSet ++= loginUserGroups
|
||||
|
||||
gitbucket.core.html.index(getRecentActivitiesByOwners(visibleOwnerSet),
|
||||
getVisibleRepositories(loginAccount, withoutPhysicalInfo = true),
|
||||
loginAccount.map{ account => getUserRepositories(account.userName, withoutPhysicalInfo = true) }.getOrElse(Nil)
|
||||
)
|
||||
context.loginAccount.map { account =>
|
||||
val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName)
|
||||
gitbucket.core.html.index(getRecentActivitiesByOwners(visibleOwnerSet), Nil, getUserRepositories(account.userName, withoutPhysicalInfo = true))
|
||||
}.getOrElse {
|
||||
gitbucket.core.html.index(getRecentActivities(), getVisibleRepositories(None, withoutPhysicalInfo = true), Nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +49,18 @@ trait IndexControllerBase extends ControllerBase {
|
||||
if(redirect.isDefined && redirect.get.startsWith("/")){
|
||||
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 =>
|
||||
authenticate(context.settings, form.userName, form.password) match {
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,14 +135,9 @@ trait IndexControllerBase extends ControllerBase {
|
||||
} 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?
|
||||
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 i = params.getOrElse("page", "1").toInt
|
||||
if(i <= 0) 1 else i
|
||||
@@ -159,23 +147,31 @@ trait IndexControllerBase extends ControllerBase {
|
||||
|
||||
target.toLowerCase match {
|
||||
case "issue" => gitbucket.core.search.html.issues(
|
||||
countFiles(repository.owner, repository.name, query),
|
||||
searchIssues(repository.owner, repository.name, query),
|
||||
countWikiPages(repository.owner, repository.name, query),
|
||||
if(query.nonEmpty) searchIssues(repository.owner, repository.name, query) else Nil,
|
||||
query, page, repository)
|
||||
|
||||
case "wiki" => gitbucket.core.search.html.wiki(
|
||||
countFiles(repository.owner, repository.name, query),
|
||||
countIssues(repository.owner, repository.name, query),
|
||||
searchWikiPages(repository.owner, repository.name, query),
|
||||
if(query.nonEmpty) searchWikiPages(repository.owner, repository.name, query) else Nil,
|
||||
query, page, repository)
|
||||
|
||||
case _ => gitbucket.core.search.html.code(
|
||||
searchFiles(repository.owner, repository.name, query),
|
||||
countIssues(repository.owner, repository.name, query),
|
||||
countWikiPages(repository.owner, repository.name, query),
|
||||
if(query.nonEmpty) searchFiles(repository.owner, repository.name, query) else Nil,
|
||||
query, page, repository)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
get("/search"){
|
||||
val query = params.getOrElse("query", "").trim.toLowerCase
|
||||
val visibleRepositories = getVisibleRepositories(context.loginAccount, None)
|
||||
val repositories = visibleRepositories.filter { repository =>
|
||||
repository.name.toLowerCase.indexOf(query) >= 0 || repository.owner.toLowerCase.indexOf(query) >= 0
|
||||
}
|
||||
context.loginAccount.map { account =>
|
||||
gitbucket.core.search.html.repositories(query, repositories, Nil, getUserRepositories(account.userName, withoutPhysicalInfo = true))
|
||||
}.getOrElse {
|
||||
gitbucket.core.search.html.repositories(query, repositories, visibleRepositories, Nil)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package gitbucket.core.controller
|
||||
|
||||
import gitbucket.core.issues.html
|
||||
import gitbucket.core.service.IssuesService._
|
||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||
import gitbucket.core.service._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.Implicits._
|
||||
@@ -10,16 +9,39 @@ import gitbucket.core.util._
|
||||
import gitbucket.core.view
|
||||
import gitbucket.core.view.Markdown
|
||||
import io.github.gitbucket.scalatra.forms._
|
||||
import org.scalatra.Ok
|
||||
import org.scalatra.{BadRequest, Ok}
|
||||
|
||||
|
||||
class IssuesController extends IssuesControllerBase
|
||||
with IssuesService with RepositoryService with AccountService with LabelsService with MilestonesService with ActivityService with HandleCommentService
|
||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator with PullRequestService with WebHookIssueCommentService
|
||||
with IssuesService
|
||||
with RepositoryService
|
||||
with AccountService
|
||||
with LabelsService
|
||||
with MilestonesService
|
||||
with ActivityService
|
||||
with HandleCommentService
|
||||
with IssueCreationService
|
||||
with ReadableUsersAuthenticator
|
||||
with ReferrerAuthenticator
|
||||
with WritableUsersAuthenticator
|
||||
with PullRequestService
|
||||
with WebHookIssueCommentService
|
||||
with CommitsService
|
||||
|
||||
trait IssuesControllerBase extends ControllerBase {
|
||||
self: IssuesService with RepositoryService with AccountService with LabelsService with MilestonesService with ActivityService with HandleCommentService
|
||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with WritableUsersAuthenticator with PullRequestService with WebHookIssueCommentService =>
|
||||
self: IssuesService
|
||||
with RepositoryService
|
||||
with AccountService
|
||||
with LabelsService
|
||||
with MilestonesService
|
||||
with ActivityService
|
||||
with HandleCommentService
|
||||
with IssueCreationService
|
||||
with ReadableUsersAuthenticator
|
||||
with ReferrerAuthenticator
|
||||
with WritableUsersAuthenticator
|
||||
with PullRequestService
|
||||
with WebHookIssueCommentService =>
|
||||
|
||||
case class IssueCreateForm(title: String, content: Option[String],
|
||||
assignedUserName: Option[String], milestoneId: Option[Int], labelNames: Option[String])
|
||||
@@ -70,67 +92,39 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
getAssignableUserNames(owner, name),
|
||||
getMilestonesWithIssueCount(owner, name),
|
||||
getLabels(owner, name),
|
||||
isEditable(repository),
|
||||
isManageable(repository),
|
||||
isIssueEditable(repository),
|
||||
isIssueManageable(repository),
|
||||
repository)
|
||||
} getOrElse NotFound()
|
||||
}
|
||||
})
|
||||
|
||||
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) =>
|
||||
html.create(
|
||||
getAssignableUserNames(owner, name),
|
||||
getMilestones(owner, name),
|
||||
getLabels(owner, name),
|
||||
isManageable(repository),
|
||||
isIssueManageable(repository),
|
||||
getContentTemplate(repository, "ISSUE_TEMPLATE"),
|
||||
repository)
|
||||
}
|
||||
} else Unauthorized()
|
||||
})
|
||||
|
||||
post("/:owner/:repository/issues/new", issueCreateForm)(readableUsersOnly { (form, repository) =>
|
||||
if(isEditable(repository)){ // TODO Should this check is provided by authenticator?
|
||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||
val manageable = isManageable(repository)
|
||||
val userName = context.loginAccount.get.userName
|
||||
if(isIssueEditable(repository)){ // TODO Should this check is provided by authenticator?
|
||||
val issue = createIssue(
|
||||
repository,
|
||||
form.title,
|
||||
form.content,
|
||||
form.assignedUserName,
|
||||
form.milestoneId,
|
||||
form.labelNames.toArray.flatMap(_.split(",")),
|
||||
context.loginAccount.get)
|
||||
|
||||
// insert issue
|
||||
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}")
|
||||
}
|
||||
redirect(s"/${issue.userName}/${issue.repositoryName}/issues/${issue.issueId}")
|
||||
} else Unauthorized()
|
||||
})
|
||||
|
||||
@@ -306,7 +300,7 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
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),
|
||||
condition,
|
||||
repository,
|
||||
isEditable(repository),
|
||||
isManageable(repository))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether an logged-in user can manage issues.
|
||||
*/
|
||||
private def isManageable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether an logged-in user can post issues.
|
||||
*/
|
||||
private def isEditable(repository: RepositoryInfo)(implicit context: Context): Boolean = {
|
||||
repository.repository.options.issuesOption match {
|
||||
case "ALL" => !repository.repository.isPrivate && context.loginAccount.isDefined
|
||||
case "PUBLIC" => hasGuestRole(repository.owner, repository.name, context.loginAccount)
|
||||
case "PRIVATE" => hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||
case "DISABLE" => false
|
||||
isIssueEditable(repository),
|
||||
isIssueManageable(repository))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,5 +382,4 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
private def isEditableContent(owner: String, repository: String, author: String)(implicit context: Context): Boolean = {
|
||||
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.Directory._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.JGitUtil._
|
||||
import gitbucket.core.util._
|
||||
import gitbucket.core.view
|
||||
import gitbucket.core.view.helpers
|
||||
import io.github.gitbucket.scalatra.forms._
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.lib.PersonIdent
|
||||
@@ -371,6 +368,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
||||
forkedId,
|
||||
oldId.getName,
|
||||
newId.getName,
|
||||
getContentTemplate(originRepository, "PULL_REQUEST_TEMPLATE"),
|
||||
forkedRepository,
|
||||
originRepository,
|
||||
forkedRepository,
|
||||
@@ -427,7 +425,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
||||
if(editable) {
|
||||
val loginUserName = context.loginAccount.get.userName
|
||||
|
||||
val issueId = createIssue(
|
||||
val issueId = insertIssue(
|
||||
owner = repository.owner,
|
||||
repository = repository.name,
|
||||
loginUser = loginUserName,
|
||||
@@ -498,26 +496,6 @@ trait PullRequestsControllerBase extends ControllerBase {
|
||||
(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) =
|
||||
defining(repository.owner, repository.name){ case (owner, repoName) =>
|
||||
val page = IssueSearchCondition.page(request)
|
||||
|
||||
@@ -238,7 +238,7 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
||||
val dummyWebHookInfo = WebHook(repository.owner, repository.name, url, ctype, token)
|
||||
val dummyPayload = {
|
||||
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))
|
||||
.setMaxCount(4)
|
||||
.call.iterator.asScala.map(new CommitInfo(_)).toList
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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.repo.html
|
||||
@@ -16,9 +17,8 @@ import gitbucket.core.model.{Account, WebHook}
|
||||
import gitbucket.core.service.WebHookService._
|
||||
import gitbucket.core.view
|
||||
import gitbucket.core.view.helpers
|
||||
|
||||
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.archive.{TgzFormat, ZipFormat}
|
||||
import org.eclipse.jgit.dircache.DirCache
|
||||
@@ -102,7 +102,18 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
*/
|
||||
post("/:owner/:repository/_preview")(referrersOnly { repository =>
|
||||
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"),
|
||||
repository = repository,
|
||||
enableWikiLink = params("enableWikiLink").toBoolean,
|
||||
@@ -112,6 +123,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
enableAnchor = false,
|
||||
hasWritePermission = hasDeveloperRole(repository.owner, repository.name, context.loginAccount)
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -243,13 +255,9 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
val (id, path) = repository.splitPath(multiParams("splat").head)
|
||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||
getPathObjectId(git, path, revCommit).flatMap { objectId =>
|
||||
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
||||
contentType = FileUtil.getMimeType(path)
|
||||
response.setContentLength(loader.getSize.toInt)
|
||||
loader.copyTo(response.outputStream)
|
||||
()
|
||||
}
|
||||
|
||||
getPathObjectId(git, path, revCommit).map { objectId =>
|
||||
responseRawFile(git, objectId, path, repository)
|
||||
} getOrElse NotFound()
|
||||
}
|
||||
})
|
||||
@@ -265,23 +273,62 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
getPathObjectId(git, path, revCommit).map { objectId =>
|
||||
if(raw){
|
||||
// Download (This route is left for backword compatibility)
|
||||
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
||||
contentType = FileUtil.getMimeType(path)
|
||||
response.setContentLength(loader.getSize.toInt)
|
||||
loader.copyTo(response.outputStream)
|
||||
()
|
||||
} getOrElse NotFound()
|
||||
responseRawFile(git, objectId, path, repository)
|
||||
} else {
|
||||
html.blob(id, repository, path.split("/").toList,
|
||||
JGitUtil.getContentInfo(git, path, objectId),
|
||||
new JGitUtil.CommitInfo(JGitUtil.getLastModifiedCommit(git, revCommit, path)),
|
||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||
request.paths(2) == "blame")
|
||||
request.paths(2) == "blame",
|
||||
isLfsFile(git, objectId))
|
||||
}
|
||||
} getOrElse NotFound()
|
||||
}
|
||||
})
|
||||
|
||||
private def isLfsFile(git: Git, objectId: ObjectId): Boolean = {
|
||||
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
||||
if(loader.isLarge){
|
||||
false
|
||||
} else {
|
||||
new String(loader.getCachedBytes, "UTF-8").startsWith("version https://git-lfs.github.com/spec/v1")
|
||||
}
|
||||
}.getOrElse(false)
|
||||
}
|
||||
|
||||
private def responseRawFile(git: Git, objectId: ObjectId, path: String,
|
||||
repository: RepositoryService.RepositoryInfo): Unit = {
|
||||
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
||||
contentType = FileUtil.getMimeType(path)
|
||||
|
||||
if(loader.isLarge){
|
||||
response.setContentLength(loader.getSize.toInt)
|
||||
loader.copyTo(response.outputStream)
|
||||
} else {
|
||||
val bytes = loader.getCachedBytes
|
||||
val text = new String(bytes, "UTF-8")
|
||||
|
||||
if(text.startsWith("version https://git-lfs.github.com/spec/v1")){
|
||||
// LFS objects
|
||||
val attrs = text.split("\n").map { line =>
|
||||
val dim = line.split(" ")
|
||||
dim(0) -> dim(1)
|
||||
}.toMap
|
||||
|
||||
response.setContentLength(attrs("size").toInt)
|
||||
val oid = attrs("oid").split(":")(1)
|
||||
|
||||
using(new FileInputStream(FileUtil.getLfsFilePath(repository.owner, repository.name, oid))){ in =>
|
||||
IOUtils.copy(in, response.getOutputStream)
|
||||
}
|
||||
} else {
|
||||
response.setContentLength(loader.getSize.toInt)
|
||||
response.getOutputStream.write(bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get("/:owner/:repository/blame/*"){
|
||||
blobRoute.action()
|
||||
}
|
||||
@@ -328,7 +375,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
html.commit(id, new JGitUtil.CommitInfo(revCommit),
|
||||
JGitUtil.getBranchesOfCommit(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))
|
||||
}
|
||||
}
|
||||
@@ -546,10 +593,10 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
* @return HTML of the file list
|
||||
*/
|
||||
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))
|
||||
} else {
|
||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||
// get specified commit
|
||||
JGitUtil.getDefaultBranch(git, repository, revstr).map { case (objectId, revision) =>
|
||||
defining(JGitUtil.getRevCommitFromId(git, objectId)) { revCommit =>
|
||||
@@ -569,9 +616,14 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
html.files(revision, repository,
|
||||
if(path == ".") Nil else path.split("/").toList, // current path
|
||||
new JGitUtil.CommitInfo(lastModifiedCommit), // last modified commit
|
||||
files, readme, hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||
JGitUtil.getCommitCount(repository.owner, repository.name, revision),
|
||||
files,
|
||||
readme,
|
||||
hasDeveloperRole(repository.owner, repository.name, context.loginAccount),
|
||||
getPullRequestFromBranch(repository.owner, repository.name, revstr, repository.repository.defaultBranch),
|
||||
flash.get("info"), flash.get("error"))
|
||||
flash.get("info"),
|
||||
flash.get("error")
|
||||
)
|
||||
}
|
||||
} getOrElse NotFound()
|
||||
}
|
||||
@@ -666,11 +718,6 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
|
||||
private def archiveRepository(name: String, suffix: String, repository: RepositoryService.RepositoryInfo): Unit = {
|
||||
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 + "-" +
|
||||
(if(revision.length == 40) revision.substring(0, 10) else revision).replace('/', '_') + suffix
|
||||
@@ -684,7 +731,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
|
||||
git.archive
|
||||
.setFormat(suffix.tail)
|
||||
.setTree(revCommit.getTree)
|
||||
.setTree(revCommit)
|
||||
.setOutputStream(response.getOutputStream)
|
||||
.call()
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
"user" -> trim(label("SMTP User", optional(text()))),
|
||||
"password" -> trim(label("SMTP Password", optional(text()))),
|
||||
"ssl" -> trim(label("Enable SSL", optional(boolean()))),
|
||||
"starttls" -> trim(label("Enable STARTTLS", optional(boolean()))),
|
||||
"fromAddress" -> trim(label("FROM Address", optional(text()))),
|
||||
"fromName" -> trim(label("FROM Name", optional(text())))
|
||||
)(Smtp.apply)),
|
||||
@@ -77,6 +78,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
"user" -> trim(label("SMTP User", optional(text()))),
|
||||
"password" -> trim(label("SMTP Password", optional(text()))),
|
||||
"ssl" -> trim(label("Enable SSL", optional(boolean()))),
|
||||
"starttls" -> trim(label("Enable STARTTLS", optional(boolean()))),
|
||||
"fromAddress" -> trim(label("FROM Address", optional(text()))),
|
||||
"fromName" -> trim(label("FROM Name", optional(text())))
|
||||
)(Smtp.apply),
|
||||
@@ -89,16 +91,16 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
|
||||
case class NewUserForm(userName: String, password: String, fullName: String,
|
||||
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,
|
||||
mailAddress: String, isAdmin: Boolean, url: Option[String],
|
||||
mailAddress: String, isAdmin: Boolean, description: Option[String], url: Option[String],
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -108,6 +110,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
"fullName" -> trim(label("Full Name" ,text(required, maxlength(100)))),
|
||||
"mailAddress" -> trim(label("Mail Address" ,text(required, maxlength(100), uniqueMailAddress()))),
|
||||
"isAdmin" -> trim(label("User Type" ,boolean())),
|
||||
"description" -> trim(label("bio" ,optional(text()))),
|
||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||
"fileId" -> trim(label("File ID" ,optional(text())))
|
||||
)(NewUserForm.apply)
|
||||
@@ -118,6 +121,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
"fullName" -> trim(label("Full Name" ,text(required, maxlength(100)))),
|
||||
"mailAddress" -> trim(label("Mail Address" ,text(required, maxlength(100), uniqueMailAddress("userName")))),
|
||||
"isAdmin" -> trim(label("User Type" ,boolean())),
|
||||
"description" -> trim(label("bio" ,optional(text()))),
|
||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||
"clearImage" -> trim(label("Clear image" ,boolean())),
|
||||
@@ -126,6 +130,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
|
||||
val newGroupForm = mapping(
|
||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||
"description" -> trim(label("Group description", optional(text()))),
|
||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||
"members" -> trim(label("Members" ,text(required, members)))
|
||||
@@ -133,6 +138,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
|
||||
val editGroupForm = mapping(
|
||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
||||
"description" -> trim(label("Group description", optional(text()))),
|
||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||
"members" -> trim(label("Members" ,text(required, members))),
|
||||
@@ -164,7 +170,8 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
post("/admin/system/sendmail", sendMailForm)(adminOnly { form =>
|
||||
try {
|
||||
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
|
||||
|
||||
@@ -193,7 +200,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
})
|
||||
|
||||
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)
|
||||
redirect("/admin/users")
|
||||
})
|
||||
@@ -227,6 +234,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
fullName = form.fullName,
|
||||
mailAddress = form.mailAddress,
|
||||
isAdmin = form.isAdmin,
|
||||
description = form.description,
|
||||
url = form.url,
|
||||
isRemoved = form.isRemoved))
|
||||
|
||||
@@ -241,7 +249,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
})
|
||||
|
||||
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 {
|
||||
_.split(":") match {
|
||||
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
||||
@@ -264,7 +272,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
}
|
||||
}.toList){ case (groupName, members) =>
|
||||
getAccountByUserName(groupName, true).map { account =>
|
||||
updateGroup(groupName, form.url, form.isRemoved)
|
||||
updateGroup(groupName, form.url, form.description, form.isRemoved)
|
||||
|
||||
if(form.isRemoved){
|
||||
// Remove from GROUP_MEMBER
|
||||
|
||||
@@ -19,7 +19,8 @@ trait AccountComponent { self: Profile =>
|
||||
val image = column[String]("IMAGE")
|
||||
val groupAccount = column[Boolean]("GROUP_ACCOUNT")
|
||||
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],
|
||||
image: Option[String],
|
||||
isGroupAccount: Boolean,
|
||||
isRemoved: Boolean
|
||||
isRemoved: Boolean,
|
||||
description: Option[String]
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package gitbucket.core.model
|
||||
|
||||
import scala.slick.lifted.MappedTo
|
||||
import scala.slick.jdbc._
|
||||
|
||||
trait CommitStatusComponent extends TemplateComponent { self: Profile =>
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package gitbucket.core.model
|
||||
|
||||
import scala.slick.lifted.MappedTo
|
||||
import scala.slick.jdbc._
|
||||
|
||||
trait ProtectedBranchComponent extends TemplateComponent { self: Profile =>
|
||||
import profile.simple._
|
||||
import self._
|
||||
|
||||
@@ -23,5 +23,5 @@ class UserNameSuggestionProvider extends SuggestionProvider {
|
||||
override def values(repository: RepositoryInfo): Seq[String] = Nil
|
||||
override def template(implicit context: Context): String = "'@' + value"
|
||||
override def additionalScript(implicit context: Context): String =
|
||||
s"""$$.get('${context.path}/_user/proposals', { query: '' }, function (data) { user = data.options; });"""
|
||||
s"""$$.get('${context.path}/_user/proposals', { query: '', user: true, group: false }, function (data) { user = data.options; });"""
|
||||
}
|
||||
@@ -20,7 +20,7 @@ trait AccessTokenService {
|
||||
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) = {
|
||||
var token: String = null
|
||||
|
||||
@@ -14,13 +14,20 @@ trait AccountService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(classOf[AccountService])
|
||||
|
||||
def authenticate(settings: SystemSettings, userName: String, password: String)(implicit s: Session): Option[Account] =
|
||||
if(settings.ldapAuthentication){
|
||||
def authenticate(settings: SystemSettings, userName: String, password: String)(implicit s: Session): Option[Account] = {
|
||||
val account = if (settings.ldapAuthentication) {
|
||||
ldapAuthentication(settings, userName, password)
|
||||
} else {
|
||||
defaultAuthentication(userName, password)
|
||||
}
|
||||
|
||||
if(account.isEmpty){
|
||||
logger.info(s"Failed to authenticate: $userName")
|
||||
}
|
||||
|
||||
account
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate by internal database.
|
||||
*/
|
||||
@@ -61,14 +68,14 @@ trait AccountService {
|
||||
defaultAuthentication(userName, password)
|
||||
}
|
||||
case None => {
|
||||
createAccount(ldapUserInfo.userName, "", ldapUserInfo.fullName, ldapUserInfo.mailAddress, false, None)
|
||||
createAccount(ldapUserInfo.userName, "", ldapUserInfo.fullName, ldapUserInfo.mailAddress, false, None, None)
|
||||
getAccountByUserName(ldapUserInfo.userName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case Left(errorMessage) => {
|
||||
logger.info(s"LDAP Authentication Failed: ${errorMessage}")
|
||||
logger.info(s"LDAP error: ${errorMessage}")
|
||||
defaultAuthentication(userName, password)
|
||||
}
|
||||
}
|
||||
@@ -103,7 +110,7 @@ trait AccountService {
|
||||
} 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 =
|
||||
Accounts insert Account(
|
||||
userName = userName,
|
||||
@@ -117,12 +124,13 @@ trait AccountService {
|
||||
lastLoginDate = None,
|
||||
image = None,
|
||||
isGroupAccount = false,
|
||||
isRemoved = false)
|
||||
isRemoved = false,
|
||||
description = description)
|
||||
|
||||
def updateAccount(account: Account)(implicit s: Session): Unit =
|
||||
Accounts
|
||||
.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 (
|
||||
account.password,
|
||||
account.fullName,
|
||||
@@ -132,7 +140,8 @@ trait AccountService {
|
||||
account.registeredDate,
|
||||
currentDate,
|
||||
account.lastLoginDate,
|
||||
account.isRemoved)
|
||||
account.isRemoved,
|
||||
account.description)
|
||||
|
||||
def updateAvatarImage(userName: String, image: Option[String])(implicit s: Session): Unit =
|
||||
Accounts.filter(_.userName === userName.bind).map(_.image.?).update(image)
|
||||
@@ -140,7 +149,7 @@ trait AccountService {
|
||||
def updateLastLoginDate(userName: String)(implicit s: Session): Unit =
|
||||
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(
|
||||
userName = groupName,
|
||||
password = "",
|
||||
@@ -153,10 +162,13 @@ trait AccountService {
|
||||
lastLoginDate = None,
|
||||
image = None,
|
||||
isGroupAccount = true,
|
||||
isRemoved = false)
|
||||
isRemoved = false,
|
||||
description = description)
|
||||
|
||||
def updateGroup(groupName: String, url: Option[String], removed: Boolean)(implicit s: Session): Unit =
|
||||
Accounts.filter(_.userName === groupName.bind).map(t => t.url.? -> t.removed).update(url, removed)
|
||||
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.description.?, t.removed))
|
||||
.update(url, description, removed)
|
||||
|
||||
def updateGroupMembers(groupName: String, members: List[(String, Boolean)])(implicit s: Session): Unit = {
|
||||
GroupMembers.filter(_.groupName === groupName.bind).delete
|
||||
|
||||
@@ -5,9 +5,6 @@ import profile.simple._
|
||||
|
||||
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
|
||||
|
||||
trait CommitStatusService {
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package gitbucket.core.service
|
||||
|
||||
import gitbucket.core.model.CommitComment
|
||||
import gitbucket.core.util.{StringUtil, Implicits}
|
||||
import gitbucket.core.util.Implicits
|
||||
|
||||
import scala.slick.jdbc.{StaticQuery => Q}
|
||||
import Q.interpolation
|
||||
import gitbucket.core.model.Profile._
|
||||
import profile.simple._
|
||||
import Implicits._
|
||||
import StringUtil._
|
||||
|
||||
|
||||
trait CommitsService {
|
||||
@@ -42,6 +39,12 @@ trait CommitsService {
|
||||
updatedDate = currentDate,
|
||||
issueId = issueId)
|
||||
|
||||
def updateCommitCommentPosition(commentId: Int, commitId: String, oldLine: Option[Int], newLine: Option[Int])(implicit s: Session): Unit =
|
||||
CommitComments.filter(_.byPrimaryKey(commentId))
|
||||
.map { t =>
|
||||
(t.commitId, t.oldLine, t.newLine)
|
||||
}.update(commitId, oldLine, newLine)
|
||||
|
||||
def updateCommitComment(commentId: Int, content: String)(implicit s: Session) =
|
||||
CommitComments
|
||||
.filter (_.byPrimaryKey(commentId))
|
||||
|
||||
@@ -17,9 +17,9 @@ trait HandleCommentService {
|
||||
*/
|
||||
def handleComment(issue: Issue, content: Option[String], repository: RepositoryService.RepositoryInfo, actionOpt: Option[String])
|
||||
(implicit context: Context, s: Session) = {
|
||||
|
||||
context.loginAccount.flatMap { loginAccount =>
|
||||
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||
val userName = context.loginAccount.get.userName
|
||||
val userName = loginAccount.userName
|
||||
|
||||
val (action, recordActivity) = actionOpt
|
||||
.collect {
|
||||
@@ -49,12 +49,12 @@ trait HandleCommentService {
|
||||
|
||||
// extract references and create refer comment
|
||||
content.map { content =>
|
||||
createReferComment(owner, name, issue, content, context.loginAccount.get)
|
||||
createReferComment(owner, name, issue, content, loginAccount)
|
||||
}
|
||||
|
||||
// call web hooks
|
||||
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) => {
|
||||
val webHookAction = act match {
|
||||
case "open" => "opened"
|
||||
@@ -63,9 +63,9 @@ trait HandleCommentService {
|
||||
case _ => act
|
||||
}
|
||||
if (issue.isPullRequest) {
|
||||
callPullRequestWebHook(webHookAction, repository, issue.issueId, context.baseUrl, context.loginAccount.get)
|
||||
callPullRequestWebHook(webHookAction, repository, issue.issueId, context.baseUrl, loginAccount)
|
||||
} 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 -> _ )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.simple.Session
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import scala.slick.jdbc.{StaticQuery => Q}
|
||||
import Q.interpolation
|
||||
|
||||
|
||||
|
||||
trait IssuesService {
|
||||
self: AccountService with RepositoryService =>
|
||||
import IssuesService._
|
||||
@@ -23,7 +24,7 @@ trait IssuesService {
|
||||
else None
|
||||
|
||||
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 */
|
||||
def getCommentsForApi(owner: String, repository: String, issueId: Int)(implicit s: Session): List[(IssueComment, Account, Issue)] =
|
||||
@@ -34,6 +35,10 @@ trait IssuesService {
|
||||
.map{ case ((t1, t2), t3) => (t1, t2, t3) }
|
||||
.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) =
|
||||
if (commentId forall (_.isDigit))
|
||||
IssueComments filter { t =>
|
||||
@@ -106,7 +111,6 @@ trait IssuesService {
|
||||
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,
|
||||
@@ -185,6 +189,19 @@ trait IssuesService {
|
||||
}} 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)
|
||||
.innerJoin(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
|
||||
* @return (issue, issueUser, commentCount, pullRequest, headRepo, headOwner)
|
||||
*/
|
||||
@@ -264,7 +281,7 @@ trait IssuesService {
|
||||
} 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],
|
||||
isPullRequest: Boolean = false)(implicit s: Session) =
|
||||
// next id number
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package gitbucket.core.service
|
||||
|
||||
import gitbucket.core.model.Account
|
||||
import gitbucket.core.util.LockUtil
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
|
||||
import org.eclipse.jgit.merge.MergeStrategy
|
||||
|
||||
@@ -86,7 +86,7 @@ object ProtectedBranchService {
|
||||
def getStopReason(isAllowNonFastForwards: Boolean, command: ReceiveCommand, pusher: String)(implicit session: Session): Option[String] = {
|
||||
if(enabled){
|
||||
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")
|
||||
case ReceiveCommand.Type.UPDATE|ReceiveCommand.Type.UPDATE_NONFASTFORWARD if needStatusCheck(pusher) =>
|
||||
unSuccessedContexts(command.getNewId.name) match {
|
||||
@@ -98,7 +98,7 @@ object ProtectedBranchService {
|
||||
Some("Cannot delete a protected branch")
|
||||
case _ => None
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
package gitbucket.core.service
|
||||
|
||||
import gitbucket.core.model.{Account, Issue, PullRequest, WebHook, CommitStatus, CommitState}
|
||||
import difflib.{Delta, DiffUtils}
|
||||
import gitbucket.core.model.{Session => _, _}
|
||||
import gitbucket.core.model.Profile._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.JGitUtil
|
||||
import gitbucket.core.util.JGitUtil.{CommitInfo, DiffInfo}
|
||||
import gitbucket.core.view
|
||||
import gitbucket.core.view.helpers
|
||||
import org.eclipse.jgit.api.Git
|
||||
import profile.simple._
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
trait PullRequestService { self: IssuesService =>
|
||||
|
||||
trait PullRequestService { self: IssuesService with CommitsService =>
|
||||
import PullRequestService._
|
||||
|
||||
def getPullRequest(owner: String, repository: String, issueId: Int)
|
||||
@@ -111,9 +121,26 @@ trait PullRequestService { self: IssuesService =>
|
||||
def updatePullRequests(owner: String, repository: String, branch: String)(implicit s: Session): Unit =
|
||||
getPullRequestsByRequest(owner, repository, branch, false).foreach { pullreq =>
|
||||
if(Repositories.filter(_.byRepository(pullreq.userName, pullreq.repositoryName)).exists.run){
|
||||
// Update the git repository
|
||||
val (commitIdTo, commitIdFrom) = JGitUtil.updatePullRequest(
|
||||
pullreq.userName, pullreq.repositoryName, pullreq.branch, pullreq.issueId,
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -137,6 +164,78 @@ trait PullRequestService { self: IssuesService =>
|
||||
.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 {
|
||||
|
||||
@@ -3,7 +3,14 @@ package gitbucket.core.service
|
||||
import gitbucket.core.controller.Context
|
||||
import gitbucket.core.model.{Collaborator, Repository, RepositoryOptions, Account, Role}
|
||||
import gitbucket.core.model.Profile._
|
||||
import gitbucket.core.plugin.PluginRegistry
|
||||
import gitbucket.core.util.JGitUtil
|
||||
import gitbucket.core.util.JGitUtil.FileInfo
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.Directory
|
||||
import gitbucket.core.util.FileUtil
|
||||
import gitbucket.core.util.StringUtil
|
||||
import org.eclipse.jgit.api.Git
|
||||
import profile.simple._
|
||||
|
||||
trait RepositoryService { self: AccountService =>
|
||||
@@ -223,7 +230,7 @@ trait RepositoryService { self: AccountService =>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the repositories without private repository that user does not have access right.
|
||||
* Returns the repositories except private repository that user does not have access right.
|
||||
* Include public repository, private own repository and private but collaborator repository.
|
||||
*
|
||||
* @param userName the user name of collaborator
|
||||
@@ -232,8 +239,10 @@ trait RepositoryService { self: AccountService =>
|
||||
def getAllRepositories(userName: String)(implicit s: Session): List[(String, String)] = {
|
||||
Repositories.filter { t1 =>
|
||||
(t1.isPrivate === false.bind) ||
|
||||
(t1.userName === userName.bind) ||
|
||||
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && (t2.collaboratorName === userName.bind)} exists)
|
||||
(t1.userName === userName.bind) || (t1.userName in (GroupMembers.filter(_.userName === userName.bind).map(_.groupName))) ||
|
||||
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) &&
|
||||
((t2.collaboratorName === userName.bind) || (t2.collaboratorName in GroupMembers.filter(_.userName === userName.bind).map(_.groupName)))
|
||||
} exists)
|
||||
}.sortBy(_.lastActivityDate desc).map{ t =>
|
||||
(t.userName, t.repositoryName)
|
||||
}.list
|
||||
@@ -242,8 +251,10 @@ trait RepositoryService { self: AccountService =>
|
||||
def getUserRepositories(userName: String, withoutPhysicalInfo: Boolean = false)
|
||||
(implicit s: Session): List[RepositoryInfo] = {
|
||||
Repositories.filter { t1 =>
|
||||
(t1.userName === userName.bind) ||
|
||||
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && (t2.collaboratorName === userName.bind)} exists)
|
||||
(t1.userName === userName.bind) || (t1.userName in (GroupMembers.filter(_.userName === userName.bind).map(_.groupName))) ||
|
||||
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) &&
|
||||
((t2.collaboratorName === userName.bind) || (t2.collaboratorName in GroupMembers.filter(_.userName === userName.bind).map(_.groupName)))
|
||||
} exists)
|
||||
}.sortBy(_.lastActivityDate desc).list.map{ repository =>
|
||||
new RepositoryInfo(
|
||||
if(withoutPhysicalInfo){
|
||||
@@ -278,8 +289,13 @@ trait RepositoryService { self: AccountService =>
|
||||
case Some(x) if(x.isAdmin) => Repositories
|
||||
// for Normal Users
|
||||
case Some(x) if(!x.isAdmin) =>
|
||||
Repositories filter { t => (t.isPrivate === false.bind) || (t.userName === x.userName) ||
|
||||
(Collaborators.filter { t2 => t2.byRepository(t.userName, t.repositoryName) && (t2.collaboratorName === x.userName.bind)} exists)
|
||||
Repositories filter { t =>
|
||||
(t.isPrivate === false.bind) || (t.userName === x.userName) ||
|
||||
(t.userName in GroupMembers.filter(_.userName === x.userName.bind).map(_.groupName)) ||
|
||||
(Collaborators.filter { t2 =>
|
||||
t2.byRepository(t.userName, t.repositoryName) &&
|
||||
((t2.collaboratorName === x.userName.bind) || (t2.collaboratorName in GroupMembers.filter(_.userName === x.userName.bind).map(_.groupName)))
|
||||
} exists)
|
||||
}
|
||||
// for Guests
|
||||
case None => Repositories filter(_.isPrivate === false.bind)
|
||||
@@ -407,31 +423,55 @@ trait RepositoryService { self: AccountService =>
|
||||
}
|
||||
.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 {
|
||||
|
||||
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]) {
|
||||
|
||||
/**
|
||||
* 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]) =
|
||||
this(
|
||||
repo.owner, repo.name, model,
|
||||
issueCount, pullCount, repo.commitCount, forkedCount,
|
||||
repo.branchList, repo.tags, managers)
|
||||
this(repo.owner, repo.name, model, issueCount, pullCount, forkedCount, repo.branchList, repo.tags, managers)
|
||||
|
||||
/**
|
||||
* Creates instance without issue count and pull request count.
|
||||
*/
|
||||
def this(repo: JGitUtil.RepositoryInfo, model: Repository, forkedCount: Int, managers: Seq[String]) =
|
||||
this(
|
||||
repo.owner, repo.name, model,
|
||||
0, 0, repo.commitCount, forkedCount,
|
||||
repo.branchList, repo.tags, managers)
|
||||
this(repo.owner, repo.name, model, 0, 0, forkedCount, repo.branchList, repo.tags, managers)
|
||||
|
||||
def httpUrl(implicit context: Context): String = RepositoryService.httpUrl(owner, name)
|
||||
def sshUrl(implicit context: Context): Option[String] = RepositoryService.sshUrl(owner, name)
|
||||
@@ -445,7 +485,6 @@ object RepositoryService {
|
||||
|
||||
(id, path.substring(id.length).stripPrefix("/"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
def httpUrl(owner: String, name: String)(implicit context: Context): String = s"${context.baseUrl}/git/${owner}/${name}.git"
|
||||
|
||||
@@ -32,6 +32,7 @@ trait SystemSettingsService {
|
||||
smtp.user.foreach(props.setProperty(SmtpUser, _))
|
||||
smtp.password.foreach(props.setProperty(SmtpPassword, _))
|
||||
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.fromName.foreach(props.setProperty(SmtpFromName, _))
|
||||
}
|
||||
@@ -87,6 +88,7 @@ trait SystemSettingsService {
|
||||
getOptionValue(props, SmtpUser, None),
|
||||
getOptionValue(props, SmtpPassword, None),
|
||||
getOptionValue[Boolean](props, SmtpSsl, None),
|
||||
getOptionValue[Boolean](props, SmtpStarttls, None),
|
||||
getOptionValue(props, SmtpFromAddress, None),
|
||||
getOptionValue(props, SmtpFromName, None)))
|
||||
} else {
|
||||
@@ -168,6 +170,7 @@ object SystemSettingsService {
|
||||
user: Option[String],
|
||||
password: Option[String],
|
||||
ssl: Option[Boolean],
|
||||
starttls: Option[Boolean],
|
||||
fromAddress: Option[String],
|
||||
fromName: Option[String])
|
||||
|
||||
@@ -176,6 +179,9 @@ object SystemSettingsService {
|
||||
port:Int,
|
||||
genericUser:String)
|
||||
|
||||
case class Lfs(
|
||||
serverUrl: Option[String])
|
||||
|
||||
val DefaultSshPort = 29418
|
||||
val DefaultSmtpPort = 25
|
||||
val DefaultLdapPort = 389
|
||||
@@ -197,6 +203,7 @@ object SystemSettingsService {
|
||||
private val SmtpUser = "smtp.user"
|
||||
private val SmtpPassword = "smtp.password"
|
||||
private val SmtpSsl = "smtp.ssl"
|
||||
private val SmtpStarttls = "smtp.starttls"
|
||||
private val SmtpFromAddress = "smtp.from_address"
|
||||
private val SmtpFromName = "smtp.from_name"
|
||||
private val LdapAuthentication = "ldap_authentication"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package gitbucket.core.service
|
||||
|
||||
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.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 org.apache.http.client.utils.URLEncodedUtils
|
||||
import profile.simple._
|
||||
@@ -16,6 +16,7 @@ import org.apache.http.message.BasicNameValuePair
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.lib.ObjectId
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
import scala.concurrent._
|
||||
import org.apache.http.HttpRequest
|
||||
import org.apache.http.HttpResponse
|
||||
@@ -33,15 +34,15 @@ trait WebHookService {
|
||||
def getWebHooks(owner: String, repository: String)(implicit s: Session): List[(WebHook, Set[WebHook.Event])] =
|
||||
WebHooks.filter(_.byRepository(owner, repository))
|
||||
.innerJoin(WebHookEvents).on { (w, t) => t.byWebHook(w) }
|
||||
.map{ case (w,t) => w -> t.event }
|
||||
.map { case (w,t) => w -> t.event }
|
||||
.list.groupBy(_._1).mapValues(_.map(_._2).toSet).toList.sortBy(_._1.url)
|
||||
|
||||
/** get All WebHook informations of repository event */
|
||||
def getWebHooksByEvent(owner: String, repository: String, event: WebHook.Event)(implicit s: Session): List[WebHook] =
|
||||
WebHooks.filter(_.byRepository(owner, repository))
|
||||
.innerJoin(WebHookEvents).on { (wh, whe) => whe.byWebHook(wh) }
|
||||
.filter{ case (wh, whe) => whe.event === event.bind}
|
||||
.map{ case (wh, whe) => wh }
|
||||
.filter { case (wh, whe) => whe.event === event.bind}
|
||||
.map { case (wh, whe) => wh }
|
||||
.list.distinct
|
||||
|
||||
/** get All WebHook information from repository to url */
|
||||
@@ -49,12 +50,12 @@ trait WebHookService {
|
||||
WebHooks
|
||||
.filter(_.byPrimaryKey(owner, repository, url))
|
||||
.innerJoin(WebHookEvents).on { (w, t) => t.byWebHook(w) }
|
||||
.map{ case (w,t) => w -> t.event }
|
||||
.map { case (w,t) => w -> t.event }
|
||||
.list.groupBy(_._1).mapValues(_.map(_._2).toSet).headOption
|
||||
|
||||
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)
|
||||
events.toSet.map{ event: WebHook.Event =>
|
||||
events.map { event: WebHook.Event =>
|
||||
WebHookEvents insert WebHookEvent(owner, repository, url, event)
|
||||
}
|
||||
}
|
||||
@@ -62,7 +63,7 @@ trait WebHookService {
|
||||
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))
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -81,7 +82,7 @@ trait WebHookService {
|
||||
def callWebHook(event: WebHook.Event, webHooks: List[WebHook], payload: WebHookPayload)
|
||||
(implicit c: JsonFormat.Context): List[(WebHook, String, Future[HttpRequest], Future[HttpResponse])] = {
|
||||
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.client.methods.HttpPost
|
||||
|
||||
@@ -91,7 +92,7 @@ trait WebHookService {
|
||||
webHooks.map { webHook =>
|
||||
val reqPromise = Promise[HttpRequest]
|
||||
val f = Future {
|
||||
val itcp = new org.apache.http.HttpRequestInterceptor{
|
||||
val itcp = new org.apache.http.HttpRequestInterceptor {
|
||||
def process(res: HttpRequest, ctx: HttpContext): Unit = {
|
||||
reqPromise.success(res)
|
||||
}
|
||||
@@ -129,8 +130,8 @@ trait WebHookService {
|
||||
httpPost.releaseConnection()
|
||||
logger.debug(s"end web hook invocation for ${webHook}")
|
||||
res
|
||||
}catch{
|
||||
case e:Throwable => {
|
||||
} catch {
|
||||
case e: Throwable => {
|
||||
if(!reqPromise.isCompleted){
|
||||
reqPromise.failure(e)
|
||||
}
|
||||
@@ -198,7 +199,9 @@ trait WebHookPullRequestService extends WebHookService {
|
||||
headOwner = headOwner,
|
||||
baseRepository = repository,
|
||||
baseOwner = baseOwner,
|
||||
sender = sender)
|
||||
sender = sender,
|
||||
mergedComment = getMergedComment(repository.owner, repository.name, issueId)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,7 +240,10 @@ trait WebHookPullRequestService extends WebHookService {
|
||||
headOwner = headOwner,
|
||||
baseRepository = baseRepo,
|
||||
baseOwner = baseOwner,
|
||||
sender = sender)
|
||||
sender = sender,
|
||||
mergedComment = getMergedComment(baseRepo.owner, baseRepo.name, issue.issueId)
|
||||
)
|
||||
|
||||
callWebHook(WebHook.PullRequest, webHooks, payload)
|
||||
}
|
||||
}
|
||||
@@ -267,7 +273,9 @@ trait WebHookPullRequestReviewCommentService extends WebHookService {
|
||||
headOwner = headOwner,
|
||||
baseRepository = repository,
|
||||
baseOwner = baseOwner,
|
||||
sender = sender)
|
||||
sender = sender,
|
||||
mergedComment = getMergedComment(repository.owner, repository.name, issue.issueId)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,11 +373,21 @@ object WebHookService {
|
||||
headOwner: Account,
|
||||
baseRepository: RepositoryInfo,
|
||||
baseOwner: Account,
|
||||
sender: Account): WebHookPullRequestPayload = {
|
||||
sender: Account,
|
||||
mergedComment: Option[(IssueComment, Account)]): WebHookPullRequestPayload = {
|
||||
|
||||
val headRepoPayload = ApiRepository(headRepository, headOwner)
|
||||
val baseRepoPayload = ApiRepository(baseRepository, baseOwner)
|
||||
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(
|
||||
action = action,
|
||||
number = issue.issueId,
|
||||
@@ -389,7 +407,7 @@ object WebHookService {
|
||||
sender: ApiUser
|
||||
) extends WebHookPayload
|
||||
|
||||
object WebHookIssueCommentPayload{
|
||||
object WebHookIssueCommentPayload {
|
||||
def apply(
|
||||
issue: Issue,
|
||||
issueUser: Account,
|
||||
@@ -415,7 +433,7 @@ object WebHookService {
|
||||
sender: ApiUser
|
||||
) extends WebHookPayload
|
||||
|
||||
object WebHookPullRequestReviewCommentPayload{
|
||||
object WebHookPullRequestReviewCommentPayload {
|
||||
def apply(
|
||||
action: String,
|
||||
comment: CommitComment,
|
||||
@@ -426,15 +444,29 @@ object WebHookService {
|
||||
headOwner: Account,
|
||||
baseRepository: RepositoryInfo,
|
||||
baseOwner: Account,
|
||||
sender: Account
|
||||
sender: Account,
|
||||
mergedComment: Option[(IssueComment, Account)]
|
||||
) : WebHookPullRequestReviewCommentPayload = {
|
||||
val headRepoPayload = ApiRepository(headRepository, headOwner)
|
||||
val baseRepoPayload = ApiRepository(baseRepository, baseOwner)
|
||||
val senderPayload = ApiUser(sender)
|
||||
|
||||
WebHookPullRequestReviewCommentPayload(
|
||||
action = action,
|
||||
comment = ApiPullRequestReviewComment(comment, senderPayload, RepositoryName(baseRepository), issue.issueId),
|
||||
pull_request = ApiPullRequest(issue, pullRequest, headRepoPayload, baseRepoPayload, ApiUser(issueUser)),
|
||||
comment = ApiPullRequestReviewComment(
|
||||
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,
|
||||
sender = senderPayload)
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import gitbucket.core.model.Account
|
||||
import gitbucket.core.service.SystemSettingsService.SystemSettings
|
||||
import gitbucket.core.service.{AccessTokenService, AccountService, SystemSettingsService}
|
||||
import gitbucket.core.util.{AuthUtil, Keys}
|
||||
import org.scalatra.servlet.ServletApiImplicits._
|
||||
import org.scalatra._
|
||||
|
||||
|
||||
class ApiAuthenticationFilter extends Filter with AccessTokenService with AccountService with SystemSettingsService {
|
||||
|
||||
@@ -70,42 +70,47 @@ class GitAuthenticationFilter extends Filter with RepositoryService with Account
|
||||
|
||||
private def defaultRepository(request: HttpServletRequest, response: HttpServletResponse, chain: FilterChain,
|
||||
settings: SystemSettings, isUpdating: Boolean): Unit = {
|
||||
implicit val r = request
|
||||
|
||||
request.paths match {
|
||||
val action = request.paths match {
|
||||
case Array(_, repositoryOwner, repositoryName, _*) =>
|
||||
Database() withSession { implicit session =>
|
||||
getRepository(repositoryOwner, repositoryName.replaceFirst("\\.wiki\\.git$|\\.git$", "")) match {
|
||||
case Some(repository) => {
|
||||
if(!isUpdating && !repository.repository.isPrivate && settings.allowAnonymousAccess){
|
||||
chain.doFilter(request, response)
|
||||
val execute = if (!isUpdating && !repository.repository.isPrivate && settings.allowAnonymousAccess) {
|
||||
// Authentication is not required
|
||||
true
|
||||
} else {
|
||||
// Authentication is required
|
||||
val passed = for {
|
||||
auth <- Option(request.getHeader("Authorization"))
|
||||
Array(username, password) = AuthUtil.decodeAuthHeader(auth).split(":", 2)
|
||||
account <- authenticate(settings, username, password)
|
||||
} yield if(isUpdating || repository.repository.isPrivate){
|
||||
if(hasDeveloperRole(repository.owner, repository.name, Some(account))){
|
||||
} yield if (isUpdating || repository.repository.isPrivate) {
|
||||
if (hasDeveloperRole(repository.owner, repository.name, Some(account))) {
|
||||
request.setAttribute(Keys.Request.UserName, account.userName)
|
||||
true
|
||||
} else false
|
||||
} else true
|
||||
passed.getOrElse(false)
|
||||
}
|
||||
|
||||
if(passed.getOrElse(false)){
|
||||
chain.doFilter(request, response)
|
||||
if (execute) {
|
||||
() => chain.doFilter(request, response)
|
||||
} else {
|
||||
AuthUtil.requireAuth(response)
|
||||
() => AuthUtil.requireAuth(response)
|
||||
}
|
||||
}
|
||||
}
|
||||
case None => {
|
||||
case None => () => {
|
||||
logger.debug(s"Repository ${repositoryOwner}/${repositoryName} is not found.")
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND)
|
||||
}
|
||||
}
|
||||
case _ => {
|
||||
}
|
||||
case _ => () => {
|
||||
logger.debug(s"Not enough path arguments: ${request.paths}")
|
||||
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("/") match {
|
||||
case Array(_, owner, repository, oid) => 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,10 @@
|
||||
package gitbucket.core.servlet
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
import gitbucket.core.api
|
||||
import gitbucket.core.model.{Session, WebHook}
|
||||
import gitbucket.core.model.WebHook
|
||||
import gitbucket.core.plugin.{GitRepositoryRouting, PluginRegistry}
|
||||
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
||||
import gitbucket.core.service.WebHookService._
|
||||
@@ -11,16 +12,16 @@ import gitbucket.core.service._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util._
|
||||
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.http.server.GitServlet
|
||||
import org.eclipse.jgit.lib._
|
||||
import org.eclipse.jgit.transport._
|
||||
import org.eclipse.jgit.transport.resolver._
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
import javax.servlet.ServletConfig
|
||||
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
|
||||
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
||||
|
||||
import org.json4s.jackson.Serialization._
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,6 +33,7 @@ import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
|
||||
class GitRepositoryServlet extends GitServlet with SystemSettingsService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(classOf[GitRepositoryServlet])
|
||||
private implicit val jsonFormats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||
|
||||
override def init(config: ServletConfig): Unit = {
|
||||
setReceivePackFactory(new GitBucketReceivePackFactory())
|
||||
@@ -45,15 +47,73 @@ class GitRepositoryServlet extends GitServlet with SystemSettingsService {
|
||||
override def service(req: HttpServletRequest, res: HttpServletResponse): Unit = {
|
||||
val agent = req.getHeader("USER-AGENT")
|
||||
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
|
||||
val paths = req.getRequestURI.substring(0, index).split("/")
|
||||
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 {
|
||||
// response for git client
|
||||
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) => {
|
||||
req.getRequestURI.substring(1).replace(".git/", "/").split("/") match {
|
||||
case Array(_, owner, repository, _*) => {
|
||||
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] {
|
||||
@@ -107,15 +167,16 @@ class GitBucketReceivePackFactory extends ReceivePackFactory[HttpServletRequest]
|
||||
|
||||
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
|
||||
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 var existIds: Seq[String] = Nil
|
||||
|
||||
def onPreReceive(receivePack: ReceivePack, commands: java.util.Collection[ReceiveCommand]): Unit = {
|
||||
Database() withTransaction { implicit session =>
|
||||
try {
|
||||
commands.asScala.foreach { command =>
|
||||
// call pre-commit hook
|
||||
@@ -135,10 +196,14 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def onPostReceive(receivePack: ReceivePack, commands: java.util.Collection[ReceiveCommand]): Unit = {
|
||||
Database() withTransaction { implicit session =>
|
||||
try {
|
||||
using(Git.open(Directory.getRepositoryDir(owner, repository))) { git =>
|
||||
JGitUtil.removeCache(git)
|
||||
|
||||
val pushedIds = scala.collection.mutable.Set[String]()
|
||||
commands.asScala.foreach { command =>
|
||||
logger.debug(s"commandType: ${command.getType}, refName: ${command.getRefName}")
|
||||
@@ -169,7 +234,7 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
||||
pushedIds.add(commit.id)
|
||||
createIssueComment(owner, repository, commit)
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
@@ -178,14 +243,14 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
||||
}
|
||||
|
||||
// record activity
|
||||
if(refName(1) == "heads"){
|
||||
if (refName(1) == "heads") {
|
||||
command.getType match {
|
||||
case ReceiveCommand.Type.CREATE => recordCreateBranchActivity(owner, repository, pusher, branchName)
|
||||
case ReceiveCommand.Type.UPDATE => recordPushActivity(owner, repository, pusher, branchName, newCommits)
|
||||
case ReceiveCommand.Type.DELETE => recordDeleteBranchActivity(owner, repository, pusher, branchName)
|
||||
case _ =>
|
||||
}
|
||||
} else if(refName(1) == "tags"){
|
||||
} else if (refName(1) == "tags") {
|
||||
command.getType match {
|
||||
case ReceiveCommand.Type.CREATE => recordCreateTagActivity(owner, repository, pusher, branchName, newCommits)
|
||||
case ReceiveCommand.Type.DELETE => recordDeleteTagActivity(owner, repository, pusher, branchName, newCommits)
|
||||
@@ -193,13 +258,13 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
||||
}
|
||||
}
|
||||
|
||||
if(refName(1) == "heads"){
|
||||
if (refName(1) == "heads") {
|
||||
command.getType match {
|
||||
case ReceiveCommand.Type.CREATE |
|
||||
ReceiveCommand.Type.UPDATE |
|
||||
ReceiveCommand.Type.UPDATE_NONFASTFORWARD =>
|
||||
updatePullRequests(owner, repository, branchName)
|
||||
getAccountByUserName(pusher).map{ pusherAccount =>
|
||||
getAccountByUserName(pusher).map { pusherAccount =>
|
||||
callPullRequestWebHookByRequestBranch("synchronize", repositoryInfo, branchName, baseUrl, pusherAccount)
|
||||
}
|
||||
case _ =>
|
||||
@@ -207,8 +272,8 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
||||
}
|
||||
|
||||
// call web hook
|
||||
callWebHookOf(owner, repository, WebHook.Push){
|
||||
for(pusherAccount <- getAccountByUserName(pusher);
|
||||
callWebHookOf(owner, repository, WebHook.Push) {
|
||||
for (pusherAccount <- getAccountByUserName(pusher);
|
||||
ownerAccount <- getAccountByUserName(owner)) yield {
|
||||
WebHookPushPayload(git, pusherAccount, command.getRefName, repositoryInfo, newCommits, ownerAccount,
|
||||
newId = command.getNewId(), oldId = command.getOldId())
|
||||
@@ -228,5 +293,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
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,9 @@ class TransactionFilter extends Filter {
|
||||
def destroy(): Unit = {}
|
||||
|
||||
def doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain): Unit = {
|
||||
if(req.asInstanceOf[HttpServletRequest].getServletPath().startsWith("/assets/")){
|
||||
// assets don't need transaction
|
||||
val servletPath = req.asInstanceOf[HttpServletRequest].getServletPath()
|
||||
if(servletPath.startsWith("/assets/") || servletPath == "/git" || servletPath == "/git-lfs"){
|
||||
// assets and git-lfs don't need transaction
|
||||
chain.doFilter(req, res)
|
||||
} else {
|
||||
Database() withTransaction { session =>
|
||||
|
||||
@@ -30,13 +30,12 @@ abstract class GitCommand extends Command with SessionAware {
|
||||
@volatile protected var callback: ExitCallback = null
|
||||
@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 {
|
||||
override def run(): Unit = {
|
||||
authUser match {
|
||||
case Some(authUser) =>
|
||||
Database() withTransaction { implicit session =>
|
||||
try {
|
||||
runTask(authUser)
|
||||
callback.onExit(0)
|
||||
@@ -48,7 +47,6 @@ abstract class GitCommand extends Command with SessionAware {
|
||||
logger.error(e.getMessage, e)
|
||||
callback.onExit(1)
|
||||
}
|
||||
}
|
||||
case None =>
|
||||
val message = "User not authenticated"
|
||||
logger.error(message)
|
||||
@@ -102,9 +100,14 @@ abstract class DefaultGitCommand(val owner: String, val repoName: String) extend
|
||||
class DefaultGitUploadPack(owner: String, repoName: String) extends DefaultGitCommand(owner, repoName)
|
||||
with RepositoryService with AccountService {
|
||||
|
||||
override protected def runTask(user: String)(implicit session: Session): Unit = {
|
||||
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", "")).foreach { repositoryInfo =>
|
||||
if(!repositoryInfo.repository.isPrivate || isWritableUser(user, repositoryInfo)){
|
||||
override protected def runTask(user: String): Unit = {
|
||||
val execute = Database() withSession { implicit session =>
|
||||
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 =>
|
||||
val repository = git.getRepository
|
||||
val upload = new UploadPack(repository)
|
||||
@@ -112,19 +115,23 @@ class DefaultGitUploadPack(owner: String, repoName: String) extends DefaultGitCo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DefaultGitReceivePack(owner: String, repoName: String, baseUrl: String) extends DefaultGitCommand(owner, repoName)
|
||||
with RepositoryService with AccountService {
|
||||
|
||||
override protected def runTask(user: String)(implicit session: Session): Unit = {
|
||||
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", "")).foreach { repositoryInfo =>
|
||||
if(isWritableUser(user, repositoryInfo)){
|
||||
override protected def runTask(user: String): Unit = {
|
||||
val execute = Database() withSession { implicit session =>
|
||||
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", "")).map { repositoryInfo =>
|
||||
isWritableUser(user, repositoryInfo)
|
||||
}.getOrElse(false)
|
||||
}
|
||||
|
||||
if(execute) {
|
||||
using(Git.open(getRepositoryDir(owner, repoName))) { git =>
|
||||
val repository = git.getRepository
|
||||
val receive = new ReceivePack(repository)
|
||||
if(!repoName.endsWith(".wiki")){
|
||||
if (!repoName.endsWith(".wiki")) {
|
||||
val hook = new CommitLogHook(owner, repoName, user, baseUrl)
|
||||
receive.setPreReceiveHook(hook)
|
||||
receive.setPostReceiveHook(hook)
|
||||
@@ -133,14 +140,17 @@ class DefaultGitReceivePack(owner: String, repoName: String, baseUrl: String) ex
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PluginGitUploadPack(repoName: String, routing: GitRepositoryRouting) extends GitCommand
|
||||
with SystemSettingsService {
|
||||
|
||||
override protected def runTask(user: String)(implicit session: Session): Unit = {
|
||||
if(routing.filter.filter("/" + repoName, Some(user), loadSystemSettings(), false)){
|
||||
override protected def runTask(user: String): Unit = {
|
||||
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)
|
||||
using(Git.open(new File(Directory.GitBucketHome, path))){ git =>
|
||||
val repository = git.getRepository
|
||||
@@ -154,8 +164,11 @@ class PluginGitUploadPack(repoName: String, routing: GitRepositoryRouting) exten
|
||||
class PluginGitReceivePack(repoName: String, routing: GitRepositoryRouting) extends GitCommand
|
||||
with SystemSettingsService {
|
||||
|
||||
override protected def runTask(user: String)(implicit session: Session): Unit = {
|
||||
if(routing.filter.filter("/" + repoName, Some(user), loadSystemSettings(), true)){
|
||||
override protected def runTask(user: String): Unit = {
|
||||
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)
|
||||
using(Git.open(new File(Directory.GitBucketHome, path))){ git =>
|
||||
val repository = git.getRepository
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package gitbucket.core.ssh
|
||||
|
||||
import gitbucket.core.service.SystemSettingsService
|
||||
import gitbucket.core.service.SystemSettingsService.SshAddress
|
||||
import org.apache.sshd.common.Factory
|
||||
import org.apache.sshd.server.{Environment, ExitCallback, Command}
|
||||
|
||||
@@ -2,7 +2,6 @@ package gitbucket.core.ssh
|
||||
|
||||
import java.security.PublicKey
|
||||
|
||||
import gitbucket.core.model.SshKey
|
||||
import gitbucket.core.service.SshKeyService
|
||||
import gitbucket.core.servlet.Database
|
||||
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator
|
||||
|
||||
@@ -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 =
|
||||
try f(git) finally git.getRepository.close()
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package gitbucket.core.util
|
||||
|
||||
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 {
|
||||
|
||||
@@ -50,6 +48,12 @@ object Directory {
|
||||
def getAttachedDir(owner: String, repository: String): File =
|
||||
new File(s"${RepositoryHome}/${owner}/${repository}/comments")
|
||||
|
||||
/**
|
||||
* Directory for files which are attached to issue.
|
||||
*/
|
||||
def getLfsDir(owner: String, repository: String): File =
|
||||
new File(s"${RepositoryHome}/${owner}/${repository}/lfs")
|
||||
|
||||
/**
|
||||
* Directory for uploaded files by the specified user.
|
||||
*/
|
||||
@@ -72,12 +76,6 @@ object Directory {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -62,4 +62,8 @@ object FileUtil {
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"text/plain")
|
||||
|
||||
def getLfsFilePath(owner: String, repository: String, oid: String): String =
|
||||
Directory.getLfsDir(owner, repository) + "/" + oid
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ object Implicits {
|
||||
|
||||
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)
|
||||
|
||||
@@ -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 = {
|
||||
val sb = new StringBuilder()
|
||||
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{
|
||||
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] = {
|
||||
val value = session.getAttribute(key).asInstanceOf[T]
|
||||
if(value == null){
|
||||
|
||||
@@ -16,7 +16,7 @@ import scala.collection.mutable.ListBuffer
|
||||
*/
|
||||
object JDBCUtil {
|
||||
|
||||
implicit class RichConnection(conn: Connection){
|
||||
implicit class RichConnection(private val conn: Connection) extends AnyVal {
|
||||
|
||||
def update(sql: String, params: Any*): Int = {
|
||||
execute(sql, params: _*){ stmt =>
|
||||
@@ -214,8 +214,6 @@ object JDBCUtil {
|
||||
tsort(edges).toSeq
|
||||
}
|
||||
|
||||
case class TableDependency(tableName: String, children: Seq[String])
|
||||
|
||||
|
||||
def tsort[A](edges: Traversable[(A, A)]): Iterable[A] = {
|
||||
@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 StringUtil._
|
||||
import ControlUtil._
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import scala.collection.JavaConverters._
|
||||
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.transport.RefSpec
|
||||
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.slf4j.LoggerFactory
|
||||
|
||||
@@ -32,14 +37,11 @@ object JGitUtil {
|
||||
*
|
||||
* @param owner the user name of the repository owner
|
||||
* @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 tags the list of tags
|
||||
*/
|
||||
case class RepositoryInfo(owner: String, name: String, commitCount: Int, branchList: List[String], tags: List[TagInfo]){
|
||||
def this(owner: String, name: String) = {
|
||||
this(owner, name, 0, Nil, Nil)
|
||||
}
|
||||
case class RepositoryInfo(owner: String, name: String, branchList: List[String], tags: List[TagInfo]){
|
||||
def this(owner: String, name: String) = this(owner, name, Nil, Nil)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,19 +172,53 @@ object JGitUtil {
|
||||
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.
|
||||
*/
|
||||
def getRepositoryInfo(owner: String, repository: String): RepositoryInfo = {
|
||||
using(Git.open(getRepositoryDir(owner, repository))){ git =>
|
||||
try {
|
||||
// get commit count
|
||||
val commitCount = git.log.all.call.iterator.asScala.map(_ => 1).take(10001).sum
|
||||
|
||||
RepositoryInfo(
|
||||
owner, repository,
|
||||
// commit count
|
||||
commitCount,
|
||||
RepositoryInfo(owner, repository,
|
||||
// branches
|
||||
git.branchList.call.asScala.map { ref =>
|
||||
ref.getName.stripPrefix("refs/heads/")
|
||||
@@ -195,9 +231,7 @@ object JGitUtil {
|
||||
)
|
||||
} catch {
|
||||
// not initialized
|
||||
case e: NoHeadException => RepositoryInfo(
|
||||
owner, repository, 0, Nil, Nil)
|
||||
|
||||
case e: NoHeadException => RepositoryInfo(owner, repository, Nil, Nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +247,7 @@ object JGitUtil {
|
||||
def getFileList(git: Git, revision: String, path: String = "."): List[FileInfo] = {
|
||||
using(new RevWalk(git.getRepository)){ revWalk =>
|
||||
val objectId = git.getRepository.resolve(revision)
|
||||
if(objectId==null) return Nil
|
||||
if(objectId == null) return Nil
|
||||
val revCommit = revWalk.parseCommit(objectId)
|
||||
|
||||
def useTreeWalk(rev:RevCommit)(f:TreeWalk => Any): Unit = if (path == ".") {
|
||||
@@ -255,14 +289,14 @@ object JGitUtil {
|
||||
revIterator:java.util.Iterator[RevCommit]): List[(ObjectId, FileMode, String, Option[String], RevCommit)] ={
|
||||
if(restList.isEmpty){
|
||||
result
|
||||
}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)) }
|
||||
}else{
|
||||
} 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)) }
|
||||
} else {
|
||||
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){
|
||||
findLastCommits(result, restList, revIterator)
|
||||
}else{
|
||||
} else {
|
||||
var nextRest = skips
|
||||
var nextResult = result
|
||||
// Map[(name, oid), (tuple, parentsMap)]
|
||||
@@ -270,20 +304,20 @@ object JGitUtil {
|
||||
lazy val newParentsMap = newCommit.getParents.map(_ -> newCommit).toMap
|
||||
useTreeWalk(newCommit){ walk =>
|
||||
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){
|
||||
nextResult +:= tupleAdd(tuple, newCommit)
|
||||
}else{
|
||||
} else {
|
||||
nextRest +:= tuple -> newParentsMap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rest.values.map{ case (tuple, parentsMap) =>
|
||||
rest.values.map { case (tuple, parentsMap) =>
|
||||
val restParentsMap = parentsMap - newCommit
|
||||
if(restParentsMap.isEmpty){
|
||||
nextResult +:= tupleAdd(tuple, parentsMap(newCommit))
|
||||
}else{
|
||||
} else {
|
||||
nextRest +:= tuple -> restParentsMap
|
||||
}
|
||||
}
|
||||
@@ -295,7 +329,7 @@ object JGitUtil {
|
||||
var fileList: List[(ObjectId, FileMode, String, Option[String])] = Nil
|
||||
useTreeWalk(revCommit){ treeWalk =>
|
||||
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)
|
||||
} else None
|
||||
fileList +:= (treeWalk.getObjectId(0), treeWalk.getFileMode(0), treeWalk.getNameString, linkUrl)
|
||||
@@ -345,7 +379,7 @@ object JGitUtil {
|
||||
def getTreeId(git: Git, revision: String): Option[String] = {
|
||||
using(new RevWalk(git.getRepository)){ revWalk =>
|
||||
val objectId = git.getRepository.resolve(revision)
|
||||
if(objectId==null) return None
|
||||
if(objectId == null) return None
|
||||
val revCommit = revWalk.parseCommit(objectId)
|
||||
Some(revCommit.getTree.name)
|
||||
}
|
||||
@@ -357,7 +391,7 @@ object JGitUtil {
|
||||
def getAllFileListByTreeId(git: Git, treeId: String): List[String] = {
|
||||
using(new RevWalk(git.getRepository)){ revWalk =>
|
||||
val objectId = git.getRepository.resolve(treeId+"^{tree}")
|
||||
if(objectId==null) return Nil
|
||||
if(objectId == null) return Nil
|
||||
using(new TreeWalk(git.getRepository)){ treeWalk =>
|
||||
treeWalk.addTree(objectId)
|
||||
treeWalk.setRecursive(true)
|
||||
@@ -705,6 +739,8 @@ object JGitUtil {
|
||||
refUpdate.setNewObjectId(newHeadId)
|
||||
refUpdate.update()
|
||||
|
||||
removeCache(git)
|
||||
|
||||
newHeadId
|
||||
}
|
||||
|
||||
@@ -877,6 +913,7 @@ object JGitUtil {
|
||||
|
||||
/**
|
||||
* Returns the last modified commit of specified path
|
||||
*
|
||||
* @param git the Git object
|
||||
* @param startCommit the search base commit id
|
||||
* @param path the path of target file or directory
|
||||
@@ -959,6 +996,7 @@ object JGitUtil {
|
||||
|
||||
/**
|
||||
* Returns sha1
|
||||
*
|
||||
* @param owner repository owner
|
||||
* @param name repository name
|
||||
* @param revstr A git object references expression
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package gitbucket.core.util
|
||||
|
||||
import gitbucket.core.model.{Session, Issue}
|
||||
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, SystemSettingsService}
|
||||
import gitbucket.core.model.{Account, Issue, Session}
|
||||
import gitbucket.core.service.{AccountService, IssuesService, RepositoryService, SystemSettingsService}
|
||||
import gitbucket.core.servlet.Database
|
||||
import gitbucket.core.view.Markdown
|
||||
|
||||
@@ -9,16 +9,16 @@ import scala.concurrent._
|
||||
import ExecutionContext.Implicits.global
|
||||
import org.apache.commons.mail.{DefaultAuthenticator, HtmlEmail}
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
import gitbucket.core.controller.Context
|
||||
import SystemSettingsService.Smtp
|
||||
import ControlUtil.defining
|
||||
|
||||
trait Notifier extends RepositoryService with AccountService with IssuesService {
|
||||
|
||||
def toNotify(r: RepositoryService.RepositoryInfo, issue: Issue, content: String)
|
||||
(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
|
||||
issue.userName ::
|
||||
@@ -31,9 +31,13 @@ trait Notifier extends RepositoryService with AccountService with IssuesService
|
||||
getComments(issue.userName, issue.repositoryName, issue.issueId).map(_.commentedUserName)
|
||||
)
|
||||
.distinct
|
||||
.withFilter ( _ != context.loginAccount.get.userName ) // the operation in person is excluded
|
||||
.foreach ( getAccountByUserName(_) filterNot (_.isGroupAccount) filterNot (LDAPUtil.isDummyMailAddress(_)) foreach (x => notify(x.mailAddress)) )
|
||||
|
||||
.withFilter ( _ != loginAccount.userName ) // the operation in person is excluded
|
||||
.foreach (
|
||||
getAccountByUserName(_)
|
||||
.filterNot (_.isGroupAccount)
|
||||
.filterNot (LDAPUtil.isDummyMailAddress(_))
|
||||
.foreach (x => notify(x.mailAddress))
|
||||
)
|
||||
}
|
||||
|
||||
object Notifier {
|
||||
@@ -70,7 +74,8 @@ class Mailer(private val smtp: Smtp) extends Notifier {
|
||||
private val logger = LoggerFactory.getLogger(classOf[Mailer])
|
||||
|
||||
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 f = Future {
|
||||
@@ -84,10 +89,9 @@ class Mailer(private val smtp: Smtp) extends Notifier {
|
||||
enableRefsLink = true,
|
||||
enableAnchor = false,
|
||||
enableLineBreaks = false
|
||||
))) { case (subject, msg) =>
|
||||
recipients(issue) { to =>
|
||||
send(to, subject, msg)
|
||||
}
|
||||
))
|
||||
) { case (subject, msg) =>
|
||||
recipients(issue, loginAccount) { to => send(to, subject, msg, loginAccount) }
|
||||
}
|
||||
}
|
||||
"Notifications Successful."
|
||||
@@ -99,8 +103,9 @@ class Mailer(private val smtp: Smtp) extends Notifier {
|
||||
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
|
||||
email.setHostName(smtp.host)
|
||||
email.setSmtpPort(smtp.port.get)
|
||||
@@ -109,10 +114,17 @@ class Mailer(private val smtp: Smtp) extends Notifier {
|
||||
}
|
||||
smtp.ssl.foreach { 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
|
||||
.map (_ -> smtp.fromName.getOrElse(context.loginAccount.get.userName))
|
||||
.orElse (Some("notifications@gitbucket.com" -> context.loginAccount.get.userName))
|
||||
.map (_ -> smtp.fromName.getOrElse(loginAccount.userName))
|
||||
.orElse (Some("notifications@gitbucket.com" -> loginAccount.userName))
|
||||
.foreach { case (address, name) =>
|
||||
email.setFrom(address, name)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
package gitbucket.core.util
|
||||
|
||||
import java.net.{URLDecoder, URLEncoder}
|
||||
|
||||
import org.mozilla.universalchardet.UniversalDetector
|
||||
import ControlUtil._
|
||||
import org.apache.commons.io.input.BOMInputStream
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.apache.commons.codec.binary.Base64
|
||||
|
||||
import scala.util.control.Exception._
|
||||
|
||||
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 =
|
||||
defining(java.security.MessageDigest.getInstance("SHA-1")){ md =>
|
||||
md.update(value.getBytes)
|
||||
@@ -21,6 +30,20 @@ object StringUtil {
|
||||
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 urlDecode(value: String): String = URLDecoder.decode(value, "UTF-8")
|
||||
|
||||
@@ -73,7 +73,7 @@ trait LinkConverter { self: RequestCache =>
|
||||
}
|
||||
|
||||
// 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)
|
||||
getIssue(repository.owner, repository.name, m.group(3)) match {
|
||||
case Some(issue) if(issue.isPullRequest) =>
|
||||
|
||||
@@ -44,7 +44,8 @@ object Markdown {
|
||||
val renderer = new GitBucketMarkedRenderer(options, repository,
|
||||
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 = {
|
||||
// convert commit id and username to link.
|
||||
val t1 = if(enableRefsLink) convertRefsLinks(text, repository, "#", false) else text
|
||||
|
||||
// convert task list to checkbox.
|
||||
val t2 = if(enableTaskList) convertCheckBox(t1, hasWritePermission) else t1
|
||||
|
||||
t2
|
||||
// decorate by TextDecorator plugins
|
||||
helpers.decorateHtml(t2, repository)
|
||||
}
|
||||
|
||||
override def link(href: String, title: String, text: String): String = {
|
||||
|
||||
@@ -161,7 +161,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
}
|
||||
|
||||
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 = {
|
||||
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 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: scala.xml.Elem) = Html(seq.mkString(separator.toString))
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
@if(personalTokens.isEmpty && gneratedToken.isEmpty){
|
||||
No tokens.
|
||||
} 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;">
|
||||
}
|
||||
@gneratedToken.map { case (token, tokenString) =>
|
||||
@@ -19,8 +19,8 @@
|
||||
</div>
|
||||
<a href="@context.path/@account.userName/_personalToken/delete/@token.accessTokenId" class="btn btn-sm btn-danger pull-right">Delete</a>
|
||||
<div style="width: 50%;">
|
||||
@gitbucket.core.helper.html.copy("generated-token-copy", tokenString){
|
||||
<input type="text" value="@tokenString" class="form-control input-sm" readonly>
|
||||
@gitbucket.core.helper.html.copy("generated-token", "generated-token-copy", tokenString){
|
||||
<input type="text" value="@tokenString" class="form-control input-sm" id="generated-token" readonly>
|
||||
}
|
||||
</div>
|
||||
<hr style="margin-top: 10px;">
|
||||
@@ -42,7 +42,7 @@
|
||||
<label for="note" class="strong">Token description</label>
|
||||
<div><span id="error-note" class="error"></span></div>
|
||||
<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>
|
||||
<input type="submit" class="btn btn-success" value="Generate token"/>
|
||||
</div>
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
<input type="text" name="url" id="url" class="form-control" value="@account.url"/>
|
||||
<span id="error-url" class="error"></span>
|
||||
</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 class="col-md-6">
|
||||
<fieldset class="form-group">
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
</div>
|
||||
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
||||
</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">
|
||||
<label for="avatar" class="strong">Image (Optional)</label>
|
||||
@gitbucket.core.helper.html.uploadavatar(account)
|
||||
@@ -43,10 +49,10 @@
|
||||
<fieldset class="border-top">
|
||||
@if(account.isDefined){
|
||||
<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>
|
||||
}
|
||||
<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){
|
||||
<a href="@helpers.url(account.get.userName)" class="btn btn-default">Cancel</a>
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding-left: 10px; padding-right: 10px;">
|
||||
@account.description.map{ description =>
|
||||
<p style="color: white;">@description</p>
|
||||
}
|
||||
@if(account.url.isDefined){
|
||||
<p style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
||||
<i class="octicon octicon-home"></i> <a href="@account.url">@account.url</a>
|
||||
@@ -38,7 +41,7 @@
|
||||
@if(account.isGroupAccount){
|
||||
<li@if(active == "members"){ class="active"}><a href="@helpers.url(account.userName)?tab=members">Members</a></li>
|
||||
} 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 =>
|
||||
@tab(account, context).map { link =>
|
||||
@@ -48,14 +51,14 @@
|
||||
@if(context.loginAccount.isDefined && context.loginAccount.get.userName == account.userName){
|
||||
<li class="pull-right">
|
||||
<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>
|
||||
</li>
|
||||
}
|
||||
@if(context.loginAccount.isDefined && account.isGroupAccount && isGroupManager){
|
||||
<li class="pull-right">
|
||||
<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>
|
||||
</li>
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ isCreateRepoOptionPublic: Boolean)(implicit context: gitbucket.core.controller.C
|
||||
<div class="content body">
|
||||
<h2>Create a new repository</h2>
|
||||
<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>
|
||||
<form id="form" method="post" action="@context.path/new" validate="true">
|
||||
<fieldset class="border-top form-group">
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
<input type="text" name="url" id="url" class="form-control" value=""/>
|
||||
<span id="error-url" class="error"></span>
|
||||
</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 class="col-md-6">
|
||||
<fieldset>
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
<div class="sidebar">
|
||||
<ul class="sidebar-menu" id="system-admin-menu-container">
|
||||
<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@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@if(active=="plugins"){ class="active"}>
|
||||
<a href="@context.path/admin/plugins">Plugins</a>
|
||||
@@ -15,7 +15,7 @@
|
||||
<a href="@context.path/admin/data">Data export / import</a>
|
||||
</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>
|
||||
@gitbucket.core.plugin.PluginRegistry().getSystemSettingMenus.map { menu =>
|
||||
@menu(context).map { link =>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
@(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.helper.html.information(info)
|
||||
<form action="@context.path/admin/system" method="POST" validate="true" class="form-horizontal">
|
||||
<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">
|
||||
<!--====================================================================-->
|
||||
<!-- System properties -->
|
||||
@@ -36,8 +36,8 @@
|
||||
</fieldset>
|
||||
<p class="muted">
|
||||
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.
|
||||
You can use this property to adjust URL difference between the reverse proxy and GitBucket.
|
||||
If the base URL is empty, GitBucket generates URL from the request information.
|
||||
You can use this property to adjust to URL differences between the reverse proxy and GitBucket.
|
||||
</p>
|
||||
<!--====================================================================-->
|
||||
<!-- Information -->
|
||||
@@ -59,19 +59,19 @@
|
||||
</label>
|
||||
<label class="radio">
|
||||
<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>
|
||||
</fieldset>
|
||||
<hr>
|
||||
<label class="strong">Default option to create a new repository</label>
|
||||
<label class="strong">Default permissions when creating a new repository</label>
|
||||
<fieldset>
|
||||
<label class="radio">
|
||||
<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 class="radio">
|
||||
<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>
|
||||
</fieldset>
|
||||
<!--====================================================================-->
|
||||
@@ -82,7 +82,7 @@
|
||||
<fieldset>
|
||||
<label class="radio">
|
||||
<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 class="radio">
|
||||
<input type="radio" name="allowAnonymousAccess" value="false"@if(!context.settings.allowAnonymousAccess){ checked}>
|
||||
@@ -93,7 +93,7 @@
|
||||
<!-- Activity -->
|
||||
<!--====================================================================-->
|
||||
<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>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3" for="activityLogLimit">Limit</label>
|
||||
@@ -111,7 +111,7 @@
|
||||
<fieldset>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="gravatar"@if(context.settings.gravatar){ checked}/>
|
||||
Use Gravatar for Profile-Images
|
||||
Use Gravatar for profile images
|
||||
</label>
|
||||
</fieldset>
|
||||
<!--====================================================================-->
|
||||
@@ -123,27 +123,25 @@
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="ssh" name="ssh"@if(context.settings.ssh){ checked}/>
|
||||
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>
|
||||
</fieldset>
|
||||
<div class="ssh">
|
||||
<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">
|
||||
<input type="text" id="sshHost" name="sshHost" class="form-control" value="@context.settings.sshHost"/>
|
||||
<span id="error-sshHost" class="error"></span>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<input type="text" id="sshPort" name="sshPort" class="form-control" value="@context.settings.sshPort"/>
|
||||
<span id="error-sshPort" class="error"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="muted">
|
||||
Both of SSH host and Base URL are required if SSH access is enabled.
|
||||
</p>
|
||||
<!--====================================================================-->
|
||||
<!-- Authentication -->
|
||||
<!--====================================================================-->
|
||||
@@ -157,14 +155,14 @@
|
||||
</fieldset>
|
||||
<div class="ldap">
|
||||
<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">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<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>
|
||||
@@ -178,7 +176,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<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>
|
||||
@@ -259,49 +257,56 @@
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="useSMTP" name="useSMTP" @if(context.settings.useSMTP){ checked}/>
|
||||
SMTP
|
||||
<span class="muted normal">(Enable notification as well as SMTP configuration if you want to send notification email too)</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
<div class="useSMTP">
|
||||
<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">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<input type="text" id="smtpUser" name="smtp.user" class="form-control" value="@context.settings.smtp.map(_.user)"/>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<input type="password" id="smtpPassword" name="smtp.password" class="form-control" value="@context.settings.smtp.map(_.password)"/>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<input type="checkbox" id="smtpSsl" name="smtp.ssl"@if(context.settings.smtp.flatMap(_.ssl).getOrElse(false)){ checked}/>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<input type="text" id="fromAddress" name="smtp.fromAddress" class="form-control" value="@context.settings.smtp.map(_.fromAddress)"/>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<input type="text" id="fromName" name="smtp.fromName" class="form-control" value="@context.settings.smtp.map(_.fromName)"/>
|
||||
</div>
|
||||
@@ -311,11 +316,23 @@
|
||||
<input type="text" id="testAddress" size="30"/>
|
||||
<input type="button" id="sendTestMail" value="Send"/>
|
||||
</div>
|
||||
|
||||
<p class="muted">
|
||||
Enable notification not only SMTP configuration if you want to send notification email.
|
||||
</p>
|
||||
</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 class="align-right" style="margin-top: 20px;">
|
||||
@@ -332,6 +349,7 @@ $(function(){
|
||||
var user = $('#smtpUser' ).val();
|
||||
var password = $('#smtpPassword').val();
|
||||
var ssl = $('#smtpSsl' ).prop('checked');
|
||||
var starttls = $('#smtpStarttls').prop('checked');
|
||||
var fromAddress = $('#fromAddress' ).val();
|
||||
var fromName = $('#fromName' ).val();
|
||||
var testAddress = $('#testAddress' ).val();
|
||||
@@ -349,6 +367,7 @@ $(function(){
|
||||
'smtp.user': user,
|
||||
'smtp.password': password,
|
||||
'smtp.ssl': ssl,
|
||||
'smtp.starttls': starttls,
|
||||
'smtp.fromAddress': fromAddress,
|
||||
'smtp.fromName': fromName,
|
||||
'testAddress': testAddress
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@(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.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">
|
||||
@@ -66,6 +66,13 @@
|
||||
</div>
|
||||
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
||||
</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 class="col-md-6">
|
||||
<fieldset class="form-group">
|
||||
@@ -75,7 +82,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@(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"){
|
||||
<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">
|
||||
@@ -24,6 +24,10 @@
|
||||
</div>
|
||||
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
||||
</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">
|
||||
<label for="avatar" class="strong">Image (Optional)</label>
|
||||
@gitbucket.core.helper.html.uploadavatar(account)
|
||||
@@ -44,7 +48,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
@gitbucket.core.html.main("Manage Users"){
|
||||
@gitbucket.core.admin.html.menu("users"){
|
||||
<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/_newgroup" class="btn btn-default">New Group</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>
|
||||
</div>
|
||||
<label for="includeRemoved">
|
||||
<input type="checkbox" id="includeRemoved" name="includeRemoved" @if(includeRemoved){checked}/>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
groups: List[String],
|
||||
recentRepositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo],
|
||||
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.tab("pulls")
|
||||
<div class="container">
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
@if(userRepositories.isEmpty){
|
||||
<li>No repositories</li>
|
||||
} else {
|
||||
@defining(10){ max =>
|
||||
<li><form class="sidebar-form"><input type="text" id="filter-box" class="form-control input-sm" placeholder="Find repository"/></form></li>
|
||||
@userRepositories.zipWithIndex.map { case (repository, i) =>
|
||||
<li class="repo-link" style="@if(i > max - 1){display:none;}">
|
||||
<li class="repo-link">
|
||||
@if(repository.owner == context.loginAccount.get.userName){
|
||||
<a href="@helpers.url(repository)">@gitbucket.core.helper.html.repositoryicon(repository, false) <span class="strong">@repository.name</span></a>
|
||||
} else {
|
||||
@@ -22,30 +22,18 @@
|
||||
}
|
||||
</li>
|
||||
}
|
||||
@if(userRepositories.size > max){
|
||||
<li class="show-more">
|
||||
<a href="javascript:void(0);" id="show-more-repos">Show @{userRepositories.size - max} more repositories...</a>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
<li class="header">Recent updated repositories</li>
|
||||
@if(recentRepositories.isEmpty){
|
||||
<li>No repositories</li>
|
||||
} else {
|
||||
@defining(10){ max =>
|
||||
<li><form class="sidebar-form"><input type="text" id="filter-box" class="form-control input-sm" placeholder="Find repository"/></form></li>
|
||||
@recentRepositories.zipWithIndex.map { case (repository, i) =>
|
||||
<li class="repo-link" style="@if(i > max - 1){display:none;}">
|
||||
<li class="repo-link">
|
||||
<a href="@helpers.url(repository)">@gitbucket.core.helper.html.repositoryicon(repository, false) @repository.owner/<span class="strong">@repository.name</span></a>
|
||||
</li>
|
||||
}
|
||||
@if(recentRepositories.size > max){
|
||||
<li class="show-more">
|
||||
<a href="javascript:void(0);" id="show-more-recent-repos">Show @{recentRepositories.size - max} more repositories...</a>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
@@ -58,9 +46,21 @@
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
$('#show-more-repos, #show-more-recent-repos').click(function(e){
|
||||
$(e.target).parents('ul').find('li.repo-link').show();
|
||||
$(e.target).parents('li.show-more').remove();
|
||||
$('#filter-box').keyup(function(){
|
||||
var inputVal = $('#filter-box').val();
|
||||
$.each($('li.repo-link a'), function(index, elem) {
|
||||
console.log(inputVal);
|
||||
console.log(elem.text.trim());
|
||||
console.log(elem.text.trim().lastIndexOf(inputVal, 0));
|
||||
if (!inputVal || !elem.text.trim() || elem.text.trim().indexOf(inputVal) >= 0) {
|
||||
$(elem).parent().show();
|
||||
} else {
|
||||
$(elem).parent().hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
$('form.sidebar-form').submit(function () {
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
@(active: String = "")(implicit context: gitbucket.core.controller.Context)
|
||||
<ul class="nav nav-tabs" style="margin-bottom: 20px;">
|
||||
<li @if(active == ""){ class="active"}><a href="@context.path/">News Feed</a></li>
|
||||
<li @if(active == ""){ class="active"}><a href="@context.path/">News feed</a></li>
|
||||
@if(context.loginAccount.isDefined){
|
||||
<li @if(active == "pulls" ){ class="active"}><a href="@context.path/dashboard/pulls">Pull Requests</a></li>
|
||||
<li @if(active == "pulls" ){ class="active"}><a href="@context.path/dashboard/pulls">Pull requests</a></li>
|
||||
<li @if(active == "issues"){ class="active"}><a href="@context.path/dashboard/issues">Issues</a></li>
|
||||
@gitbucket.core.plugin.PluginRegistry().getDashboardTabs.map { tab =>
|
||||
@tab(context).map { link =>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
@(title: String)(implicit context: gitbucket.core.controller.Context)
|
||||
@gitbucket.core.html.main("Error"){
|
||||
<div class="content-wrapper main-center">
|
||||
<div class="content body">
|
||||
<h1>@title</h1>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -64,7 +64,7 @@ $(function(){
|
||||
@dropzone(clickable: Boolean, textareaId: Option[String]) = {
|
||||
url: '@context.path/upload/file/@repository.owner/@repository.name',
|
||||
maxFilesize: 10,
|
||||
clickable: false,
|
||||
clickable: @clickable,
|
||||
acceptedFiles: @Html(FileUtil.mimeTypeWhiteList.mkString("'", ",", "'")),
|
||||
dictInvalidFileType: 'Unfortunately, we don\'t support that file type. Try again with a PNG, GIF, JPG, DOCX, PPTX, XLSX, TXT, or PDF.',
|
||||
previewTemplate: "<div class=\"dz-preview\">\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress>Uploading your files...</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>",
|
||||
|
||||
@@ -13,15 +13,14 @@
|
||||
@helpers.avatar(comment.commentedUserName, 20)
|
||||
@helpers.user(comment.commentedUserName, styleClass="username strong")
|
||||
<span class="muted">
|
||||
commented
|
||||
commented on
|
||||
@if(comment.issueId.isDefined){
|
||||
on this Pull Request
|
||||
} else {
|
||||
@if(comment.fileName.isDefined){
|
||||
on @comment.fileName.get
|
||||
<a href="@helpers.url(repository)/pull/@comment.issueId">#@comment.issueId</a>
|
||||
}
|
||||
in <a href="@context.path/@repository.owner/@repository.name/commit/@comment.commitId">@comment.commitId.substring(0, 7)</a>
|
||||
@comment.fileName.map { fileName =>
|
||||
@fileName in
|
||||
}
|
||||
<a href="@context.path/@repository.owner/@repository.name/commit/@comment.commitId">@comment.commitId.substring(0, 7)</a>
|
||||
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
|
||||
</span>
|
||||
<span class="pull-right">
|
||||
|
||||
@@ -1,63 +1,48 @@
|
||||
@(id: String, value: String, style: String = "")(html: Html = Html(""))
|
||||
@(targetTextId: String, copyButtonId: String, value: String, style: String = "")(html: Html = Html(""))
|
||||
@if(html.body.nonEmpty){
|
||||
<div class="input-group" style="margin-bottom: 0px;">
|
||||
@html
|
||||
<span class="input-group-btn">
|
||||
<span id="@id" class="btn btn-default" @if(style.nonEmpty){style="@style"}
|
||||
<span id="@copyButtonId" class="btn btn-default" @if(style.nonEmpty){style="@style"}
|
||||
data-clipboard-text="@value" data-placement="bottom" title="copy to clipboard"><i class="octicon octicon-clippy"></i></span>
|
||||
</span>
|
||||
</div>
|
||||
} else {
|
||||
<span id="@id" class="btn btn-default" @if(style.nonEmpty){style="@style"}
|
||||
<span id="@copyButtonId" class="btn btn-default" @if(style.nonEmpty){style="@style"}
|
||||
data-clipboard-text="@value" data-placement="bottom" title="copy to clipboard"><i class="octicon octicon-clippy"></i></span>
|
||||
}
|
||||
<script>
|
||||
// copy to clipboard
|
||||
(function() {
|
||||
// Check flash availablibity
|
||||
var flashAvailable = false;
|
||||
try {
|
||||
var flashObject = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
|
||||
if(flashObject) flashAvailable = true;
|
||||
} catch (e) {
|
||||
if (navigator.mimeTypes
|
||||
&& navigator.mimeTypes['application/x-shockwave-flash'] != undefined
|
||||
&& navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
|
||||
flashAvailable = true;
|
||||
}
|
||||
}
|
||||
// if flash is not available, remove the copy button.
|
||||
if(!flashAvailable) {
|
||||
$('#@id').remove();
|
||||
return
|
||||
}
|
||||
|
||||
// Find ZeroClipboard.swf file URI from ZeroClipboard JavaScript file path.
|
||||
// NOTE(tanacasino) I think this way is wrong... but i don't know correct way.
|
||||
var moviePath = (function() {
|
||||
var zclipjs = "ZeroClipboard.min.js";
|
||||
var scripts = document.getElementsByTagName("script");
|
||||
var i = scripts.length;
|
||||
while(i--) {
|
||||
var match = scripts[i].src.match(zclipjs + "$");
|
||||
if(match) {
|
||||
return match.input.substr(0, match.input.length - 6) + 'swf';
|
||||
}
|
||||
}
|
||||
})();
|
||||
var clip = new ZeroClipboard($("#@id"), {
|
||||
moviePath: moviePath
|
||||
// if document.execCommand('copy') is available, use it for copy.
|
||||
if (document.queryCommandSupported('copy')) {
|
||||
var title = $('#@copyButtonId').attr('title');
|
||||
$('#@copyButtonId').tooltip({
|
||||
@* if default container is used then 2 lines tooltip text is displayd because tooptip width is narrow. *@
|
||||
container: 'body'
|
||||
});
|
||||
var title = $('#@id').attr('title');
|
||||
$('#@id').removeAttr('title')
|
||||
clip.htmlBridge = "#global-zeroclipboard-html-bridge";
|
||||
clip.on('complete', function(client, args) {
|
||||
$(clip.htmlBridge).attr('title', 'copied!').tooltip('fixTitle').tooltip('show');
|
||||
$(clip.htmlBridge).attr('title', title).tooltip('fixTitle');
|
||||
});
|
||||
$(clip.htmlBridge).tooltip({
|
||||
title: title,
|
||||
placement: $('#@id').attr('data-placement')
|
||||
$('#@copyButtonId').on('click', function() {
|
||||
var target = document.getElementById('@targetTextId');
|
||||
if (!target) { @* target's id is incorrect. Fix argument's value *@
|
||||
$('#@copyButtonId').attr('title', 'failed to copy').tooltip('fixTitle').tooltip('show');
|
||||
return;
|
||||
}
|
||||
if (typeof target.select === 'function') {
|
||||
target.select();
|
||||
} else {
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(target);
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
document.execCommand('copy');
|
||||
$('#@copyButtonId').attr('title', 'copied!').tooltip('fixTitle').tooltip('show');
|
||||
$('#@copyButtonId').attr('title', title).tooltip('fixTitle');
|
||||
});
|
||||
} else {
|
||||
// if copy is not supported, remove the copy button
|
||||
$('#@copyButtonId').remove();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
@@ -146,24 +146,24 @@ $(function(){
|
||||
}
|
||||
|
||||
// Render diffs as unified mode initially
|
||||
if(("&"+location.search.substring(1)).indexOf("&w=1")!=-1){
|
||||
if(("&" + location.search.substring(1)).indexOf("&w=1") != -1){
|
||||
$('.ignore-whitespace').prop('checked',true);
|
||||
}
|
||||
window.viewType=1;
|
||||
if(("&"+location.search.substring(1)).indexOf("&diff=split")!=-1){
|
||||
window.viewType = 1;
|
||||
if(("&" + location.search.substring(1)).indexOf("&diff=split") != -1){
|
||||
$('.container').removeClass('container').addClass('container-wide');
|
||||
window.viewType=0;
|
||||
window.viewType = 0;
|
||||
}
|
||||
renderDiffs();
|
||||
|
||||
$('#btn-unified').click(function(){
|
||||
window.viewType=1;
|
||||
window.viewType = 1;
|
||||
$('.container-wide').removeClass('container-wide').addClass('container');
|
||||
renderDiffs();
|
||||
});
|
||||
|
||||
$('#btn-split').click(function(){
|
||||
window.viewType=0;
|
||||
window.viewType = 0;
|
||||
$('.container').removeClass('container').addClass('container-wide');
|
||||
renderDiffs();
|
||||
});
|
||||
@@ -192,9 +192,10 @@ $(function(){
|
||||
$('#comment-list').children('.inline-comment').hide();
|
||||
}
|
||||
$('.diff-outside').on('click','table.diff .add-comment',function() {
|
||||
var $this = $(this),
|
||||
$tr = $this.closest('tr'),
|
||||
$check = $this.closest('table:not(.diff)').find('.toggle-notes');
|
||||
var $this = $(this);
|
||||
var $tr = $this.closest('tr');
|
||||
var $check = $this.closest('table:not(.diff)').find('.toggle-notes');
|
||||
var url = '';
|
||||
if (!$check.prop('checked')) {
|
||||
$check.prop('checked', true).trigger('change');
|
||||
}
|
||||
@@ -216,12 +217,7 @@ $(function(){
|
||||
if (!isNaN(newLineNumber) && newLineNumber) {
|
||||
url += ('&newLineNumber=' + newLineNumber)
|
||||
}
|
||||
$.get(
|
||||
url,
|
||||
{
|
||||
dataType : 'html'
|
||||
},
|
||||
function(responseContent) {
|
||||
$.get(url, { dataType : 'html' }, function(responseContent) {
|
||||
var tmp;
|
||||
if (!isNaN(oldLineNumber) && oldLineNumber) {
|
||||
if (!isNaN(newLineNumber) && newLineNumber) {
|
||||
@@ -234,17 +230,16 @@ $(function(){
|
||||
}
|
||||
tmp.addClass('inline-comment-form').children('.comment-box-container').html(responseContent);
|
||||
$tr.nextAll(':not(.not-diff):first').before(tmp);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}).on('click', 'table.diff .btn-default', function() {
|
||||
$(this).closest('.inline-comment-form').remove();
|
||||
});
|
||||
function renderOneCommitCommentIntoDiff($v, diff){
|
||||
var filename = $v.attr('filename'),
|
||||
oldline = $v.attr('oldline'), newline = $v.attr('newline');
|
||||
var filename = $v.attr('filename');
|
||||
var oldline = $v.attr('oldline');
|
||||
var newline = $v.attr('newline');
|
||||
var tmp;
|
||||
var diff;
|
||||
if (typeof oldline !== 'undefined') {
|
||||
if (typeof newline !== 'undefined') {
|
||||
tmp = getInlineContainer();
|
||||
@@ -252,38 +247,36 @@ $(function(){
|
||||
tmp = getInlineContainer('old');
|
||||
}
|
||||
tmp.children('td:first').html($v.clone().show());
|
||||
diff.find('table.diff').find('.oldline[line-number=' + oldline + ']')
|
||||
.parent().nextAll(':not(.not-diff):first').before(tmp);
|
||||
diff.find('table.diff').find('.oldline[line-number=' + oldline + ']').parent().nextAll(':not(.not-diff):first').before(tmp);
|
||||
} else {
|
||||
tmp = getInlineContainer('new');
|
||||
tmp.children('td:last').html($v.clone().show());
|
||||
diff.find('table.diff').find('.newline[line-number=' + newline + ']')
|
||||
.parent().nextAll(':not(.not-diff):first').before(tmp);
|
||||
diff.find('table.diff').find('.newline[line-number=' + newline + ']').parent().nextAll(':not(.not-diff):first').before(tmp);
|
||||
}
|
||||
if (!diff.find('.toggle-notes').prop('checked')) {
|
||||
tmp.hide();
|
||||
}
|
||||
}
|
||||
function renderStatBar(add,del){
|
||||
if(add+del>5){
|
||||
function renderStatBar(add, del){
|
||||
if(add + del > 5){
|
||||
if(add){
|
||||
if(add<del){
|
||||
add = Math.floor(1 + (add * 4 / (add+del)));
|
||||
}else{
|
||||
add = Math.ceil(1 + (add * 4 / (add+del)));
|
||||
if(add < del){
|
||||
add = Math.floor(1 + (add * 4 / (add + del)));
|
||||
} else {
|
||||
add = Math.ceil(1 + (add * 4 / (add + del)));
|
||||
}
|
||||
}
|
||||
del = 5-add;
|
||||
del = 5 - add;
|
||||
}
|
||||
var ret = $('<div class="diffstat-bar">');
|
||||
for(var i=0;i<5;i++){
|
||||
for(var i = 0; i < 5; i++){
|
||||
if(add){
|
||||
ret.append('<span class="text-diff-added">■</span>');
|
||||
add --;
|
||||
}else if(del){
|
||||
add--;
|
||||
} else if(del){
|
||||
ret.append('<span class="text-diff-deleted">■</span>');
|
||||
del --;
|
||||
}else{
|
||||
del--;
|
||||
} else {
|
||||
ret.append('■');
|
||||
}
|
||||
}
|
||||
@@ -294,10 +287,12 @@ $(function(){
|
||||
var i = table.data("diff-id");
|
||||
var ignoreWhiteSpace = table.find('.ignore-whitespace').prop('checked');
|
||||
diffUsingJS('oldText-'+i, 'newText-'+i, diffText.attr('id'), viewType, ignoreWhiteSpace);
|
||||
var add = diffText.find("table").attr("add")*1;
|
||||
var del = diffText.find("table").attr("del")*1;
|
||||
var add = diffText.find("table").attr("add") * 1;
|
||||
var del = diffText.find("table").attr("del") * 1;
|
||||
table.find(".diffstat").text(add+del+" ").append(renderStatBar(add,del)).attr("title",add+" additions & "+del+" deletions").tooltip();
|
||||
$('span.diffstat[data-diff-id="'+i+'"]').html('<span class="text-diff-added">+'+add+'</span><span class="text-diff-deleted">-'+del+'</span>').append(renderStatBar(add,del).attr('title',(add+del)+" lines changed").tooltip());
|
||||
$('span.diffstat[data-diff-id="'+i+'"]')
|
||||
.html('<span class="text-diff-added">+' + add + '</span><span class="text-diff-deleted">-' + del + '</span>')
|
||||
.append(renderStatBar(add, del).attr('title', (add + del) + " lines changed").tooltip());
|
||||
|
||||
@if(hasWritePermission) {
|
||||
diffText.find('.body').each(function(){ $('<b class="add-comment">+</b>').prependTo(this); });
|
||||
@@ -305,14 +300,14 @@ $(function(){
|
||||
@if(showLineNotes){
|
||||
var fileName = table.attr('filename');
|
||||
$('.inline-comment').each(function(i, v) {
|
||||
if($(this).attr('filename')==fileName){
|
||||
if($(this).attr('filename') == fileName){
|
||||
renderOneCommitCommentIntoDiff($(this), table);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function renderDiffs(){
|
||||
var i=0, diffs = $('.diffText');
|
||||
var i = 0, diffs = $('.diffText');
|
||||
function render(){
|
||||
if(diffs[i]){
|
||||
renderOneDiff($(diffs[i]), viewType);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
milestones: List[gitbucket.core.model.Milestone],
|
||||
labels: List[gitbucket.core.model.Label],
|
||||
isManageable: Boolean,
|
||||
content: String,
|
||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
||||
@import gitbucket.core.view.helpers
|
||||
@gitbucket.core.html.main(s"New Issue - ${repository.owner}/${repository.name}", Some(repository)){
|
||||
@@ -13,7 +14,7 @@
|
||||
<input type="text" id="issue-title" name="title" class="form-control" value="" placeholder="Title" style="margin-bottom: 6px;" autofocus/>
|
||||
@gitbucket.core.helper.html.preview(
|
||||
repository = repository,
|
||||
content = "",
|
||||
content = content,
|
||||
enableWikiLink = false,
|
||||
enableRefsLink = true,
|
||||
enableLineBreaks = true,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<form class="form-inline">
|
||||
<input type="text" id="labelName-@labelId" style="width: 300px; float: left; margin-right: 4px;" class="form-control" value="@label.map(_.labelName)"@if(labelId == "new"){ placeholder="New label name"}/>
|
||||
<div id="label-color-@labelId" class="input-group color bscp" data-color="#@label.map(_.color).getOrElse("888888")" data-color-format="hex" style="width: 100px; float: left;">
|
||||
<input type="text" class="form-control" id="labelColor-@labelId" value="#@label.map(_.color).getOrElse("888888")" readonly style="width: 100px;">
|
||||
<input type="text" class="form-control" id="labelColor-@labelId" value="#@label.map(_.color).getOrElse("888888")" style="width: 100px;">
|
||||
<span class="input-group-addon"><i style="background-color: #@label.map(_.color).getOrElse("888888");"></i></span>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
@@ -21,7 +21,14 @@
|
||||
<a href="@condition.copy(state = "closed").toURL">Closed <span class="badge">@closedCount</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
<form method="GET" id="search-filter-form" class="form-inline pull-right">
|
||||
<form method="GET" action="@helpers.url(repository)/search" id="search-filter-form" class="form-inline pull-right">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="q" placeholder="Search..."/>
|
||||
<input type="hidden" name="type" value="issue"/>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" id="search-btn" class="btn btn-default"><i class="fa fa-search"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
@if(isEditable){
|
||||
@if(target == "issues"){
|
||||
<a class="btn btn-success" href="@helpers.url(repository)/issues/new">New issue</a>
|
||||
|
||||
@@ -11,25 +11,24 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="@helpers.assets/vendors/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="@helpers.assets/vendors/octicons-4.2.0/octicons.css" rel="stylesheet">
|
||||
<link href="@helpers.assets/vendors/datepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
|
||||
<link href="@helpers.assets/vendors/bootstrap-datetimepicker-4.17.44/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
|
||||
<link href="@helpers.assets/vendors/colorpicker/css/bootstrap-colorpicker.css" rel="stylesheet">
|
||||
<link href="@helpers.assets/vendors/google-code-prettify/prettify.css" type="text/css" rel="stylesheet"/>
|
||||
<link href="@helpers.assets/vendors/facebox/facebox.css" rel="stylesheet"/>
|
||||
<link href="@helpers.assets/vendors/AdminLTE-2.3.6/css/AdminLTE.min.css" rel="stylesheet">
|
||||
<link href="@helpers.assets/vendors/AdminLTE-2.3.6/css/skins/skin-blue.min.css" rel="stylesheet">
|
||||
<link href="@helpers.assets/vendors/AdminLTE-2.3.8/css/AdminLTE.min.css" rel="stylesheet">
|
||||
<link href="@helpers.assets/vendors/AdminLTE-2.3.8/css/skins/skin-blue.min.css" rel="stylesheet">
|
||||
<link href="@helpers.assets/vendors/font-awesome-4.6.3/css/font-awesome.min.css" rel="stylesheet">
|
||||
<link href="@helpers.assets/common/css/gitbucket.css" rel="stylesheet">
|
||||
<script src="@helpers.assets/vendors/jquery/jquery-1.11.1.js"></script>
|
||||
<script src="@helpers.assets/vendors/jquery/jquery-1.12.2.min.js"></script>
|
||||
<script src="@helpers.assets/vendors/dropzone/dropzone.js"></script>
|
||||
<script src="@helpers.assets/common/js/validation.js"></script>
|
||||
<script src="@helpers.assets/common/js/gitbucket.js"></script>
|
||||
<script src="@helpers.assets/vendors/bootstrap-3.3.6/js/bootstrap.js"></script>
|
||||
<script src="@helpers.assets/vendors/bootstrap3-typeahead/bootstrap3-typeahead.js"></script>
|
||||
<script src="@helpers.assets/vendors/datepicker/js/moment.js"></script>
|
||||
<script src="@helpers.assets/vendors/datepicker/js/bootstrap-datetimepicker.min.js"></script>
|
||||
<script src="@helpers.assets/vendors/bootstrap-datetimepicker-4.17.44/js/moment.min.js"></script>
|
||||
<script src="@helpers.assets/vendors/bootstrap-datetimepicker-4.17.44/js/bootstrap-datetimepicker.min.js"></script>
|
||||
<script src="@helpers.assets/vendors/colorpicker/js/bootstrap-colorpicker.js"></script>
|
||||
<script src="@helpers.assets/vendors/google-code-prettify/prettify.js"></script>
|
||||
<script src="@helpers.assets/vendors/zclip/ZeroClipboard.min.js"></script>
|
||||
<script src="@helpers.assets/vendors/elastic/jquery.elastic.source.js"></script>
|
||||
<script src="@helpers.assets/vendors/facebox/facebox.js"></script>
|
||||
<script src="@helpers.assets/vendors/jquery-hotkeys/jquery.hotkeys.js"></script>
|
||||
@@ -37,7 +36,7 @@
|
||||
@repository.map { repository =>
|
||||
<meta name="go-import" content="@context.baseUrl.replaceFirst("^https?://", "")/@repository.owner/@repository.name git @repository.httpUrl" />
|
||||
}
|
||||
<script src="@helpers.assets/vendors/AdminLTE-2.3.6/js/app.js" type="text/javascript"></script>
|
||||
<script src="@helpers.assets/vendors/AdminLTE-2.3.8/js/app.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body class="skin-blue page-load @if(context.sidebarCollapse){sidebar-collapse}">
|
||||
<div class="wrapper">
|
||||
@@ -54,15 +53,11 @@
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</a>
|
||||
}
|
||||
@repository.map { repository =>
|
||||
<form id="search" action="@context.path/search" method="POST" class="pc navbar-form navbar-left" role="search">
|
||||
<form id="search" action="@context.path/search" method="GET" class="pc navbar-form navbar-left" role="search">
|
||||
<div class="form-group">
|
||||
<input type="text" name="query" id="navbar-search-input" class="form-control" placeholder="Search this repository"/>
|
||||
<input type="hidden" name="owner" value="@repository.owner"/>
|
||||
<input type="hidden" name="repository" value="@repository.name"/>
|
||||
<input type="text" name="query" id="navbar-search-input" class="form-control" placeholder="Search repository"/>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
<ul class="pc nav navbar-nav">
|
||||
@if(context.loginAccount.isDefined){
|
||||
<li><a href="@context.path/dashboard/pulls">Pull requests</a></li>
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
<div class="sidebar">
|
||||
<ul class="sidebar-menu">
|
||||
@menuitem("", "files", "Files", "code")
|
||||
@if(repository.commitCount != 0) {
|
||||
@if(repository.branchList.nonEmpty) {
|
||||
@menuitem("/branches", "branches", "Branches", "git-branch", repository.branchList.length)
|
||||
@menuitem("/tags", "tags", "Tags", "tag", repository.tags.length)
|
||||
}
|
||||
@if(repository.repository.options.issuesOption != "DISABLE") {
|
||||
@menuitem("/issues", "issues", "Issues", "issue-opened", repository.issueCount)
|
||||
@menuitem("/pulls", "pulls", "Pull Requests", "git-pull-request", repository.pullCount)
|
||||
@menuitem("/pulls", "pulls", "Pull requests", "git-pull-request", repository.pullCount)
|
||||
@menuitem("/issues/labels", "labels", "Labels", "tag")
|
||||
@menuitem("/issues/milestones", "milestones", "Milestones", "milestone")
|
||||
} else {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
forkedId: String,
|
||||
sourceId: String,
|
||||
commitId: String,
|
||||
content: String,
|
||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
|
||||
originRepository: gitbucket.core.service.RepositoryService.RepositoryInfo,
|
||||
forkedRepository: gitbucket.core.service.RepositoryService.RepositoryInfo,
|
||||
@@ -15,7 +16,7 @@
|
||||
milestones: List[gitbucket.core.model.Milestone],
|
||||
labels: List[gitbucket.core.model.Label])(implicit context: gitbucket.core.controller.Context)
|
||||
@import gitbucket.core.view.helpers
|
||||
@gitbucket.core.html.main(s"Pull Requests - ${repository.owner}/${repository.name}", Some(repository)){
|
||||
@gitbucket.core.html.main(s"Pull requests - ${repository.owner}/${repository.name}", Some(repository)){
|
||||
@gitbucket.core.html.menu("pulls", repository){
|
||||
<div class="pullreq-info">
|
||||
<div id="compare-edit">
|
||||
@@ -59,7 +60,7 @@
|
||||
<input type="text" name="title" value="@title" class="form-control" style="margin-bottom: 6px;" placeholder="Title"/>
|
||||
@gitbucket.core.helper.html.preview(
|
||||
repository = repository,
|
||||
content = "",
|
||||
content = content,
|
||||
enableWikiLink = false,
|
||||
enableRefsLink = true,
|
||||
enableLineBreaks = true,
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<div>
|
||||
<span class="strong">Pull request successfully merged and closed</span>
|
||||
</div>
|
||||
<span class="small muted">You're all set-the <span class="label label-info monospace">@pullreq.requestBranch</span> branch can be safely deleted.</span>
|
||||
<span class="small muted">You're all set. The <span class="label label-info monospace">@pullreq.requestBranch</span> branch can now be safely deleted.</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
you can perform a manual merge on the command line.
|
||||
</p>
|
||||
}
|
||||
@gitbucket.core.helper.html.copy("repository-url-copy", forkedRepository.httpUrl){
|
||||
@gitbucket.core.helper.html.copy("repository-url", "repository-url-copy", forkedRepository.httpUrl){
|
||||
<div class="input-group-btn" data-toggle="buttons">
|
||||
<label class="btn btn-sm btn-default active" id="repository-url-http"><input type="radio" checked>HTTP</label>
|
||||
@if(context.settings.ssh && context.loginAccount.isDefined){
|
||||
@@ -114,7 +114,7 @@
|
||||
</p>
|
||||
@defining(s"git checkout -b ${pullreq.requestUserName}-${pullreq.requestBranch} ${pullreq.branch}\n" +
|
||||
s"git pull ${forkedRepository.httpUrl} ${pullreq.requestBranch}"){ command =>
|
||||
@gitbucket.core.helper.html.copy("merge-command-copy-1", command, "position: absolute; right: 31px;")()
|
||||
@gitbucket.core.helper.html.copy("merge-command", "merge-command-copy-1", command, "position: absolute; right: 31px;")()
|
||||
<pre style="font-size: 12px; border-radius: 3px;" id="merge-command">@Html(command)</pre>
|
||||
}
|
||||
</div>
|
||||
@@ -124,8 +124,8 @@
|
||||
</p>
|
||||
@defining(s"git checkout ${pullreq.branch}\ngit merge --no-ff ${pullreq.requestUserName}-${pullreq.requestBranch}\n" +
|
||||
s"git push origin ${pullreq.branch}"){ command =>
|
||||
@gitbucket.core.helper.html.copy("merge-command-copy-2", command, "position: absolute; right: 31px;")()
|
||||
<pre style="font-size: 12px; border-radius: 3px;">@command</pre>
|
||||
@gitbucket.core.helper.html.copy("merge-command-2", "merge-command-copy-2", command, "position: absolute; right: 31px;")()
|
||||
<pre style="font-size: 12px; border-radius: 3px;" id="merge-command-2">@command</pre>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
@import gitbucket.core.view.helpers
|
||||
@import gitbucket.core.model.IssueComment
|
||||
@import gitbucket.core.model.CommitComment
|
||||
@gitbucket.core.html.main(s"${issue.title} - Pull Request #${issue.issueId} - ${repository.owner}/${repository.name}", Some(repository)){
|
||||
@gitbucket.core.html.main(s"${issue.title} - Pull request #${issue.issueId} - ${repository.owner}/${repository.name}", Some(repository)){
|
||||
@gitbucket.core.html.menu("pulls", repository){
|
||||
@defining(dayByDayCommits.flatten){ commits =>
|
||||
<div>
|
||||
@@ -99,13 +99,13 @@
|
||||
$(function(){
|
||||
// Determine active tab from hash
|
||||
if(location.hash == '#commits'){
|
||||
$('li:has(a[href=#commits])').addClass('active');
|
||||
$('li:has(a[href="#commits"])').addClass('active');
|
||||
$('div#commits').addClass('active');
|
||||
} else if(location.hash == '#files'){
|
||||
$('li:has(a[href=#files])').addClass('active');
|
||||
$('li:has(a[href="#files"])').addClass('active');
|
||||
$('div#files').addClass('active');
|
||||
} else {
|
||||
$('li:has(a[href=#conversation])').addClass('active');
|
||||
$('li:has(a[href="#conversation"])').addClass('active');
|
||||
$('div#conversation').addClass('active');
|
||||
}
|
||||
// Set hash when tab is clicked
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
content: gitbucket.core.util.JGitUtil.ContentInfo,
|
||||
latestCommit: gitbucket.core.util.JGitUtil.CommitInfo,
|
||||
hasWritePermission: Boolean,
|
||||
isBlame: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||
isBlame: Boolean,
|
||||
isLfsFile: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||
@import gitbucket.core.view.helpers
|
||||
@gitbucket.core.html.main(s"${(repository.name :: pathList).mkString("/")} at ${helpers.encodeRefName(branch)} - ${repository.owner}/${repository.name}", Some(repository)) {
|
||||
@gitbucket.core.html.menu("files", repository){
|
||||
@@ -45,6 +46,9 @@
|
||||
<a href="@helpers.url(repository)/tree/@helpers.encodeRefName(branch)/@pathList.take(i + 1).mkString("/")">@section</a> /
|
||||
}
|
||||
}
|
||||
@if(isLfsFile){
|
||||
<span class="label label-info">LFS</span>
|
||||
}
|
||||
</div>
|
||||
<div class="box-header">
|
||||
@helpers.avatar(latestCommit, 28)
|
||||
@@ -92,12 +96,13 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
<script src="@helpers.assets/vendors/jquery/jquery.ba-hashchange.js"></script>
|
||||
<script>
|
||||
$(window).load(function(){
|
||||
$(window).hashchange(function(){
|
||||
updateHighlighting();
|
||||
}).hashchange();
|
||||
|
||||
window.onhashchange = function(){
|
||||
updateHighlighting();
|
||||
}
|
||||
|
||||
var pre = $('pre.prettyprint');
|
||||
function updateSourceLineNum(){
|
||||
@@ -112,7 +117,6 @@ $(window).load(function(){
|
||||
top : pos.top + 'px',
|
||||
left : pos.left + 'px'
|
||||
}).click(function(e){
|
||||
$(window).hashchange(function(){})
|
||||
var pos = $(this).data("pos");
|
||||
if(!pos){
|
||||
pos = $('ol.linenums li').map(function(){ return { id: $(this).attr("id"), top: $(this).position().top} }).toArray();
|
||||
@@ -178,7 +182,7 @@ $(window).load(function(){
|
||||
var h = $(e).height();
|
||||
if(blame == index[i]){
|
||||
lastDiv.css("min-height",(p.top + h + 1) - lastDiv.position().top);
|
||||
}else{
|
||||
} else {
|
||||
$(e).addClass('blame-sep')
|
||||
blame = index[i];
|
||||
var sha = $('<div class="blame-sha">')
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
helpers.urlEncode(parent) + ":" + helpers.encodeRefName(repository.repository.defaultBranch)
|
||||
}.getOrElse {
|
||||
helpers.encodeRefName(repository.repository.defaultBranch)
|
||||
}}...@{helpers.encodeRefName(branch.name)}?expand=1" class="btn btn-default">New Pull Request</a>
|
||||
}}...@{helpers.encodeRefName(branch.name)}?expand=1" class="btn btn-default">New Pull request</a>
|
||||
} else {
|
||||
<a href="@helpers.url(repository)/compare/@{repository.repository.parentUserName.map { parent =>
|
||||
helpers.urlEncode(parent) + ":" + helpers.encodeRefName(repository.repository.defaultBranch)
|
||||
|
||||
@@ -136,6 +136,7 @@ $(function(){
|
||||
$.post('@helpers.url(repository)/_preview', {
|
||||
content : editor.getValue(),
|
||||
enableWikiLink : false,
|
||||
filename : $('#newFileName').val(),
|
||||
enableRefsLink : false,
|
||||
enableLineBreaks : false,
|
||||
enableTaskList : false
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
|
||||
pathList: List[String],
|
||||
latestCommit: gitbucket.core.util.JGitUtil.CommitInfo,
|
||||
commitCount: Int,
|
||||
files: List[gitbucket.core.util.JGitUtil.FileInfo],
|
||||
readme: Option[(List[String], String)],
|
||||
hasWritePermission: Boolean,
|
||||
@@ -25,7 +26,7 @@
|
||||
<div class="pull-right">
|
||||
<div class="btn-group">
|
||||
<a href="@helpers.url(repository)/find/@helpers.encodeRefName(branch)" class="btn btn-sm btn-default" data-hotkey="t"><i class="octicon octicon-search"></i></a>
|
||||
<a href="@helpers.url(repository)/commits/@helpers.encodeRefName(branch)/@pathList.mkString("/")" class="btn btn-sm btn-default"><i class="octicon octicon-history"></i> @if(repository.commitCount > 10000){10000+} else {@repository.commitCount} @helpers.plural(repository.commitCount, "commit")</a>
|
||||
<a href="@helpers.url(repository)/commits/@helpers.encodeRefName(branch)/@pathList.mkString("/")" class="btn btn-sm btn-default"><i class="octicon octicon-history"></i> @if(commitCount > 10000){10000+} else {@commitCount} @helpers.plural(commitCount, "commit")</a>
|
||||
</div>
|
||||
</div>
|
||||
@if(pathList.isEmpty){
|
||||
@@ -39,7 +40,7 @@
|
||||
</div>
|
||||
<div class="pull-right pc">
|
||||
<div style="width: 240px; margin-right: 5px; margin-left: 5px;">
|
||||
@gitbucket.core.helper.html.copy("repository-url-copy", repository.httpUrl){
|
||||
@gitbucket.core.helper.html.copy("repository-url", "repository-url-copy", repository.httpUrl){
|
||||
@if(repository.sshUrl.isDefined){
|
||||
<div class="btn-group input-group-btn">
|
||||
<button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
@@ -85,7 +86,9 @@
|
||||
<a href="@helpers.url(repository)/tree/@helpers.encodeRefName(branch)/@pathList.take(i + 1).mkString("/")">@section</a> /
|
||||
}
|
||||
}
|
||||
<a href="@helpers.url(repository)/new/@helpers.encodeRefName(branch)/@pathList.mkString("/")" class="btn btn-sm btn-default pc" title="Create a new file here" @if(!hasWritePermission){disabled}><i class="octicon octicon-plus"></i></a>
|
||||
@if(hasWritePermission){
|
||||
<a href="@helpers.url(repository)/new/@helpers.encodeRefName(branch)/@pathList.mkString("/")" class="btn btn-sm btn-default pc" title="Create a new file here"><i class="octicon octicon-plus"></i></a>
|
||||
}
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
@*
|
||||
@@ -143,7 +146,8 @@
|
||||
<i class="octicon octicon-file-text"></i>
|
||||
}
|
||||
</td>
|
||||
<td class="content-name">
|
||||
<td class="ellipsis-cell" style="width: 20%; min-width: 160px;">
|
||||
<span>
|
||||
@if(file.isDirectory){
|
||||
@if(file.linkUrl.isDefined){
|
||||
<a href="@file.linkUrl">
|
||||
@@ -163,11 +167,12 @@
|
||||
} else {
|
||||
<a href="@helpers.url(repository)/blob@{(branch :: pathList).map(helpers.encodeRefName).mkString("/", "/", "/")}@{helpers.encodeRefName(file.name)}">@file.name</a>
|
||||
}
|
||||
</span>
|
||||
</td>
|
||||
<td class="mute">
|
||||
<a href="@helpers.url(repository)/commit/@file.commitId" class="commit-message shorten-text" title="@file.message">@helpers.link(file.message, repository)</a>
|
||||
<td class="ellipsis-cell" style="width: 70%;">
|
||||
<a href="@helpers.url(repository)/commit/@file.commitId" class="commit-message" title="@file.message">@helpers.link(file.message, repository)</a>
|
||||
</td>
|
||||
<td style="text-align: right;">@gitbucket.core.helper.html.datetimeago(file.time, false)</td>
|
||||
<td style="width: 10%; min-width: 125px; text-align: right;">@gitbucket.core.helper.html.datetimeago(file.time, false)</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<a href="@sshUrl" class="git-protocol-selector">SSH</a>
|
||||
}
|
||||
</div>
|
||||
<h3 style="margin-top: 30px;">Create a new repository on the command line</h3>
|
||||
<h3 style="margin-top: 30px;">Create a new repository from the command line</h3>
|
||||
@helpers.pre {
|
||||
touch README.md
|
||||
git init
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
@(files: List[gitbucket.core.service.RepositorySearchService.FileSearchResult],
|
||||
issueCount: Int,
|
||||
wikiCount: Int,
|
||||
query: String,
|
||||
page: Int,
|
||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
||||
@import gitbucket.core.view.helpers
|
||||
@import gitbucket.core.service.RepositorySearchService
|
||||
@gitbucket.core.html.main("Search Results", Some(repository)){
|
||||
@gitbucket.core.search.html.menu("code", files.size, issueCount, wikiCount, query, repository){
|
||||
@if(files.isEmpty){
|
||||
@gitbucket.core.search.html.menu("files", query, repository){
|
||||
@if(query.nonEmpty) {
|
||||
@if(files.isEmpty) {
|
||||
<h4>We couldn't find any code matching '@query'</h4>
|
||||
} else {
|
||||
<h4>We've found @files.size code @helpers.plural(files.size, "result")</h4>
|
||||
<h4>We have found @files.size code @helpers.plural(files.size, "result")</h4>
|
||||
}
|
||||
}
|
||||
@files.drop((page - 1) * RepositorySearchService.CodeLimit).take(RepositorySearchService.CodeLimit).map { file =>
|
||||
<div>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
@(fileCount: Int,
|
||||
issues: List[gitbucket.core.service.RepositorySearchService.IssueSearchResult],
|
||||
wikiCount: Int,
|
||||
@(issues: List[gitbucket.core.service.RepositorySearchService.IssueSearchResult],
|
||||
query: String,
|
||||
page: Int,
|
||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
||||
@import gitbucket.core.view.helpers
|
||||
@import gitbucket.core.service.RepositorySearchService
|
||||
@gitbucket.core.html.main("Search Results", Some(repository)){
|
||||
@gitbucket.core.search.html.menu("issue", fileCount, issues.size, wikiCount, query, repository){
|
||||
@if(issues.isEmpty){
|
||||
@gitbucket.core.search.html.menu("issues", query, repository){
|
||||
@if(query.nonEmpty) {
|
||||
@if(issues.isEmpty) {
|
||||
<h4>We couldn't find any code matching '@query'</h4>
|
||||
} else {
|
||||
<h4>We've found @issues.size code @helpers.plural(issues.size, "result")</h4>
|
||||
<h4>We've found @issues.size @helpers.plural(issues.size, "issue")</h4>
|
||||
}
|
||||
}
|
||||
@issues.drop((page - 1) * RepositorySearchService.IssueLimit).take(RepositorySearchService.IssueLimit).map { issue =>
|
||||
<div class="block">
|
||||
|
||||
@@ -1,35 +1,18 @@
|
||||
@(active: String, fileCount: Int, issueCount: Int, wikiCount: Int, query: String,
|
||||
@(active: String, query: String,
|
||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(body: Html)(implicit context: gitbucket.core.controller.Context)
|
||||
@import gitbucket.core.view.helpers
|
||||
@gitbucket.core.html.menu("", repository){
|
||||
<ul class="nav nav-tabs" style="margin-bottom: 20px;">
|
||||
<li@if(active=="code"){ class="active"}>
|
||||
<a href="@helpers.url(repository)/search?q=@helpers.urlEncode(query)&type=code">
|
||||
Files
|
||||
@if(fileCount != 0){
|
||||
<span class="badge">@fileCount</span>
|
||||
}
|
||||
</a>
|
||||
</li>
|
||||
<li@if(active=="issue"){ class="active"}>
|
||||
<a href="@helpers.url(repository)/search?q=@helpers.urlEncode(query)&type=issue">
|
||||
Issues
|
||||
@if(issueCount != 0){
|
||||
<span class="badge">@issueCount</span>
|
||||
}
|
||||
</a>
|
||||
</li>
|
||||
<li@if(active=="wiki"){ class="active"}>
|
||||
<a href="@helpers.url(repository)/search?q=@helpers.urlEncode(query)&type=wiki">
|
||||
Wiki
|
||||
@if(wikiCount != 0){
|
||||
<span class="badge">@wikiCount</span>
|
||||
}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@gitbucket.core.html.menu(active, repository){
|
||||
<form action="@helpers.url(repository)/search" method="GET" class="form-inline">
|
||||
<input type="text" name="q" value="@query" class="form-control" style="width: 400px; margin-bottom: 0px;"/>
|
||||
<select class="form-control" name="type">
|
||||
<option value="code" @if(active == "files"){ selected }>Files</option>
|
||||
@if(repository.repository.options.issuesOption != "DISABLE") {
|
||||
<option value="issue" @if(active == "issues"){ selected }>Issues</option>
|
||||
}
|
||||
@if(repository.repository.options.wikiOption != "DISABLE") {
|
||||
<option value="wiki" @if(active == "wiki"){ selected }>Wiki</option>
|
||||
}
|
||||
</select>
|
||||
<input type="text" name="q" value="@query" class="form-control" style="width: 250px;" placeholder="Search..."/>
|
||||
<input type="submit" value="Search" class="btn btn-default"/>
|
||||
<input type="hidden" name="type" value="@active"/>
|
||||
</form>
|
||||
|
||||
40
src/main/twirl/gitbucket/core/search/repositories.scala.html
Normal file
40
src/main/twirl/gitbucket/core/search/repositories.scala.html
Normal file
@@ -0,0 +1,40 @@
|
||||
@(query: String,
|
||||
repositories: 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)
|
||||
@import gitbucket.core.view.helpers
|
||||
@gitbucket.core.html.main("GitBucket"){
|
||||
@gitbucket.core.dashboard.html.sidebar(recentRepositories, userRepositories){
|
||||
<form action="@context.path/search" method="GET" class="form-inline">
|
||||
<input type="text" name="query" value="@query" class="form-control" style="width: 250px; margin-bottom: 0px;"/>
|
||||
<input type="submit" value="Search" class="btn btn-default"/>
|
||||
</form>
|
||||
@if(repositories.isEmpty) {
|
||||
<h4>We couldn't find any repositories matching '@query'</h4>
|
||||
} else {
|
||||
<h4>We've found @repositories.size @helpers.plural(repositories.size, "repository", "repositories")</h4>
|
||||
}
|
||||
@repositories.map { repository =>
|
||||
<div class="block">
|
||||
<div class="repository-icon">
|
||||
@gitbucket.core.helper.html.repositoryicon(repository, true)
|
||||
</div>
|
||||
<div class="repository-content">
|
||||
<div class="block-header">
|
||||
<a href="@helpers.url(repository)">@repository.owner/@repository.name</a>
|
||||
@if(repository.repository.isPrivate){
|
||||
<i class="octicon octicon-lock"></i>
|
||||
}
|
||||
</div>
|
||||
@if(repository.repository.originUserName.isDefined){
|
||||
<div class="small muted">forked from <a href="@context.path/@repository.repository.parentUserName/@repository.repository.parentRepositoryName">@repository.repository.parentUserName/@repository.repository.parentRepositoryName</a></div>
|
||||
}
|
||||
@if(repository.repository.description.isDefined){
|
||||
<div>@repository.repository.description</div>
|
||||
}
|
||||
<div><span class="muted small">Updated @gitbucket.core.helper.html.datetimeago(repository.repository.lastActivityDate)</span></div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
@(fileCount: Int,
|
||||
issueCount: Int,
|
||||
wikis: List[gitbucket.core.service.RepositorySearchService.FileSearchResult],
|
||||
@(wikis: List[gitbucket.core.service.RepositorySearchService.FileSearchResult],
|
||||
query: String,
|
||||
page: Int,
|
||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
||||
@import gitbucket.core.view.helpers
|
||||
@import gitbucket.core.service.RepositorySearchService
|
||||
@gitbucket.core.html.main("Search Results", Some(repository)){
|
||||
@gitbucket.core.search.html.menu("wiki", fileCount, issueCount, wikis.size, query, repository){
|
||||
@if(wikis.isEmpty){
|
||||
<h4>We couldn't find any code matching '@query'</h4>
|
||||
@gitbucket.core.search.html.menu("wiki", query, repository){
|
||||
@if(query.nonEmpty) {
|
||||
@if(wikis.isEmpty) {
|
||||
<h4>We could not find any code matching '@query'</h4>
|
||||
} else {
|
||||
<h4>We've found @wikis.size code @helpers.plural(wikis.size, "result")</h4>
|
||||
<h4>We've found @wikis.size @helpers.plural(wikis.size, "page")</h4>
|
||||
}
|
||||
}
|
||||
@wikis.drop((page - 1) * RepositorySearchService.CodeLimit).take(RepositorySearchService.CodeLimit).map { file =>
|
||||
<div>
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
-->
|
||||
<label class="checkbox"><input type="checkbox" @check("events",IssueComment) />Issue comment <span class="help-block normal">Issue commented on. </span> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Issues) />Issues <span class="help-block normal">Issue opened, closed<!-- , assigned, or labeled -->. </span> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",PullRequest) />Pull Request <span class="help-block normal">Pull Request opened, closed<!-- , assigned, labeled -->, or synchronized. </span> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",PullRequestReviewComment) />Pull Request review comment <span class="help-block normal">Pull Request diff commented on. </span> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",PullRequest) />Pull request <span class="help-block normal">Pull request opened, closed<!-- , assigned, labeled -->, or synchronized. </span> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",PullRequestReviewComment) />Pull request review comment <span class="help-block normal">Pull request diff commented on. </span> </label>
|
||||
<label class="checkbox"><input type="checkbox" @check("events",Push) />Push <span class="help-block normal">Git push to a repository. </span> </label>
|
||||
<div class="text-right">
|
||||
@if(!create){
|
||||
@@ -176,6 +176,15 @@ $(function(){
|
||||
$("#res-headers").html(headers(e.responce));
|
||||
$("#res-body").text(e.responce && e.responce.body ? e.responce.body : "");
|
||||
},
|
||||
error:function (e) {
|
||||
if(e) {
|
||||
console.log(e.responseText, e);
|
||||
alert("request error ( http status " + e.status + " error on gitbugket or browser to gitbucket. show details on your javascript console )");
|
||||
}else{
|
||||
alert("unknown javascript error (please report to gitbucket team)");
|
||||
}
|
||||
$("#test-report-modal").modal('hide')
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<input type="checkbox" id="allowFork" name="allowFork"@if(repository.repository.options.allowFork){ checked}/>
|
||||
Forks<br>
|
||||
<div class="normal muted">
|
||||
Allow repository forking to users who can access this repository.
|
||||
Allow users who can access this repository to fork it.
|
||||
</div>
|
||||
</label>
|
||||
</fieldset>
|
||||
@@ -56,7 +56,7 @@
|
||||
<fieldset class="form-group">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="issuesOption" value="DISABLE" @if(repository.repository.options.issuesOption == "DISABLE"){ checked}> Disables issues tracking system
|
||||
<input type="radio" name="issuesOption" value="DISABLE" @if(repository.repository.options.issuesOption == "DISABLE"){ checked}> Disable issues tracking system
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
@@ -75,7 +75,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<label for="externalIssuesUrl" class="strong">External URL:
|
||||
<span class="normal muted">(Put if you have the external issue tracking system for this project)</span>
|
||||
<span class="normal muted">(Fill if you use an external issue tracking system for this project)</span>
|
||||
</label>
|
||||
<input type="text" class="form-control" id="externalIssuesUrl" name="externalIssuesUrl" value="@repository.repository.options.externalIssuesUrl"/>
|
||||
</fieldset>
|
||||
@@ -87,7 +87,7 @@
|
||||
<fieldset class="form-group">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="wikiOption" value="DISABLE" @if(repository.repository.options.wikiOption == "DISABLE"){ checked}> Disables wiki
|
||||
<input type="radio" name="wikiOption" value="DISABLE" @if(repository.repository.options.wikiOption == "DISABLE"){ checked}> Disable wiki
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
@@ -97,7 +97,7 @@
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="wikiOption" value="PUBLIC" @if(repository.repository.options.wikiOption == "PUBLIC"){ checked}> Developers ans guests can view, create and edit wiki pages
|
||||
<input type="radio" name="wikiOption" value="PUBLIC" @if(repository.repository.options.wikiOption == "PUBLIC"){ checked}> Developers and guests can view, create and edit wiki pages
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio for-public-repo">
|
||||
@@ -106,7 +106,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<label for="externalWikiUrl" class="strong">External URL:
|
||||
<span class="normal muted">(Put if you have the external Wiki for this project)</span>
|
||||
<span class="normal muted">(Fill if you use an external wiki for this project)</span>
|
||||
</label>
|
||||
<input type="text" class="form-control" id="externalWikiUrl" name="externalWikiUrl" value="@repository.repository.options.externalWikiUrl"/>
|
||||
</fieldset>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user