Compare commits

..

54 Commits

Author SHA1 Message Date
Naoki Takezoe
80b50f6fa9 Release note for 4.29.0 2018-09-29 14:34:26 +09:00
Naoki Takezoe
7cd47a714b Bump to 4.29.0 2018-09-29 12:19:36 +09:00
Naoki Takezoe
b1d46ce2e5 Merge pull request #2151 from xuwei-k/jdk11
add jdk11 test
2018-09-28 01:00:12 +09:00
xuwei-k
ecdb2b3eb5 add jdk11 test 2018-09-28 00:10:47 +09:00
xuwei-k
dde3738c45 update latest mockito 2018-09-28 00:10:30 +09:00
Naoki Takezoe
2e69959a1f Bump to Scala 2.12.7 2018-09-28 00:05:06 +09:00
kenji yoshida
28c5f6e434 sbt 1.2.3 2018-09-27 12:52:09 +09:00
xuwei-k
1b165fd230 fix deprecation warning. Class#newInstance deprecated since Java9 2018-09-27 12:29:55 +09:00
Naoki Takezoe
96f8716417 Fix avatar icon size at blob view 2018-09-24 02:19:30 +09:00
Naoki Takezoe
7353da674d Merge pull request #2148 from gitbucket/enhance-file-buttons
Enhance file buttons
2018-09-24 02:09:58 +09:00
Naoki Takezoe
dbb25c95cd Enhance file buttons 2018-09-24 01:49:04 +09:00
Naoki Takezoe
126a3465d6 (ref #2145)Fix patch output 2018-09-22 09:29:37 +09:00
Naoki Takezoe
6061f70e24 Merge pull request #2147 from uli-heller/jgit-5.1.1
Jgit 5.1.1 - updated to the recent version of jgit and fixed deprecation warnings
2018-09-22 08:48:38 +09:00
Naoki Takezoe
ec569839fe Update issue link presentation 2018-09-22 08:47:03 +09:00
Uli Heller
fd0bc80284 Fixed deprecation warning, part 2/2 2018-09-21 20:03:58 +02:00
Uli Heller
318cdafcb1 Fixed deprecation warning, part 1/2 2018-09-21 19:58:50 +02:00
Uli Heller
1e9b60446f Upgraded to jgit-5.1.1, issue #2134 does not exist with this version 2018-09-21 17:38:05 +02:00
Naoki Takezoe
35216d8a47 Merge pull request #2144 from geforce-hisa0904/feature/confirm
Display the confirmation dialog
2018-09-17 15:31:18 +09:00
Hisakazu Nishiyama
4aa90c0501 When executing [Transfer Ownership] and [Garbage collection], display the confirmation dialog like [Delete repository] 2018-09-17 14:46:43 +09:00
Naoki Takezoe
7965408960 (refs #2133) Fix transaction isolation level issue in MariaDB 2018-09-15 17:27:59 +09:00
Naoki Takezoe
10c6660f23 Merge pull request #2140 from watari3/issue/fix_quick_create_pr_issue
Fix wrong encodeURL issue when click "Compare & pull request".
2018-09-09 20:15:37 +09:00
Naoki Takezoe
e391688a45 Fix typo 2018-09-09 18:06:25 +09:00
Naoki Takezoe
8445f210ee Merge pull request #2141 from geforce-hisa0904/feature/proxy-setting
Change the input type of "Proxy Password" from "text" to "password".
2018-09-09 00:05:44 +09:00
Hisakazu Nishiyama
c268ad46ce Change the input type of "Proxy Password" from "text" to "password". 2018-09-08 22:06:17 +09:00
Koji Ishiwatari
1a8f476a81 Fix typo. 2018-09-04 06:20:33 +09:00
Koji Ishiwatari
22d8fdd81a Fix wrong encodeURL issue when click "Compare & pull request". 2018-09-04 05:26:18 +09:00
Naoki Takezoe
ae947cd436 Merge pull request #2138 from gitbucket/gitbucket-4.28.0
GitBucket 4.28.0 release
2018-09-01 09:21:43 +09:00
Naoki Takezoe
b70a46114c GitBucket 4.28.0 release 2018-09-01 09:10:33 +09:00
Naoki Takezoe
126cc16977 (refs #2134) Revert JGit to 5.0.1.201806211838-r 2018-09-01 09:04:00 +09:00
Naoki Takezoe
a72ca0dc53 Url encode branch names in the quick pull request proposal 2018-09-01 08:21:21 +09:00
Naoki Takezoe
a914b32fe7 Merge pull request #2135 from gitbucket/fix-error-in-compare-view
Fix Internal Server Error in the comparing view
2018-08-28 08:52:42 +09:00
Naoki Takezoe
5d344c33cc Remove unnecessary code 2018-08-28 07:35:23 +09:00
Naoki Takezoe
82564cecb0 Choose default branch if repository is changed 2018-08-28 00:26:57 +09:00
Naoki Takezoe
fb5012f851 Change maven central badge to use img.shields.io 2018-08-25 10:02:41 +09:00
Naoki Takezoe
067a4856f4 Merge pull request #2130 from gitbucket/fix-slick-stackoverflow
Fix StackOverflow by deep nested condition in Slick query
2018-08-12 08:29:53 +09:00
Naoki Takezoe
a22afc2fa8 Fix query condition 2018-08-12 02:16:22 +09:00
Naoki Takezoe
0e7ce02e4e Merge branch 'master' into fix-slick-stackoverflow 2018-08-12 01:51:09 +09:00
Naoki Takezoe
b13fc2b4e7 Fix StackOverflow by deep nested condition in Slick query 2018-08-12 01:45:30 +09:00
Naoki Takezoe
b5322186ab Merge pull request #2126 from uli-heller/jgit-5.0.2
Upgraded to jgit-5.0.2
2018-08-05 09:08:36 +09:00
Uli Heller
09f85da1de Upgraded to jgit-5.0.2 2018-08-04 17:55:07 +02:00
kenji yoshida
775f838110 sbt 1.2.0 (#2124) 2018-08-04 15:47:37 +09:00
Naoki Takezoe
123cab6c19 Merge pull request #2105 from gitbucket/http-proxy-setting
Proxy support for plugin installation
2018-07-30 10:47:21 +09:00
Naoki Takezoe
4cb04e9cc3 Change configuration keys 2018-07-30 10:34:38 +09:00
Naoki Takezoe
4aa2727676 Merge pull request #2123 from uli-heller/scalatra-263
Updated: scalatra 2.6.1 -> 2.6.3, jetty 9.4.7 -> 9.4.11
2018-07-29 17:53:10 +09:00
Uli Heller
8dea7302a3 Updated: scalatra 2.6.1 -> 2.6.3, jetty 9.4.7.v20170914 -> 9.4.11.v20180605 2018-07-29 08:51:55 +02:00
Naoki Takezoe
04823666b6 Fixup 2018-07-29 13:15:53 +09:00
Naoki Takezoe
ed9d4443ae Merge branch 'master' into http-proxy-setting 2018-07-29 12:58:41 +09:00
Naoki Takezoe
45a1af2cd7 Use Apache HttpComponents instead of URL.openStream 2018-07-29 12:58:20 +09:00
Naoki Takezoe
cb920feb24 Update changelog of 4.27.0 2018-07-29 11:59:22 +09:00
Naoki Takezoe
16097bff94 Use load pattern to handle InputStream 2018-07-17 00:52:14 +09:00
Naoki Takezoe
c159b704b6 Merge branch 'master' into http-proxy-setting 2018-07-17 00:47:16 +09:00
Naoki Takezoe
3920dfb57e Fix testcase 2018-07-15 13:03:04 +09:00
Naoki Takezoe
31345cc739 Add proxy support for plugin installation 2018-07-15 12:52:22 +09:00
Naoki Takezoe
3ebc4e8e23 Add properties for HTTP proxy setting 2018-07-15 11:36:56 +09:00
28 changed files with 329 additions and 112 deletions

View File

@@ -2,6 +2,7 @@ language: scala
sudo: true
jdk:
- oraclejdk8
- oraclejdk11
script:
- sbt scalafmtSbtCheck scalafmtCheck test:scalafmtCheck test
before_script:

View File

@@ -1,10 +1,22 @@
# Changelog
All changes to the project will be documented in this file.
### 4.29.0 - 29 Sep 2018
- Official Docker image has been available
- Enhance file edit and delete buttons of the repository viewer
- Fix Patch button to generate patches for all files in the commit
- Display confirmation dialog for Transfer Ownership and Garbage collection
- Fix wrong url encoding in "Compare & pull request"
### 4.28.0 - 1 Sep 2018
- Proxy support for plugin installation
- Fix some bugs around pull requests
### 4.27.0 - 29 Jul 2018
- Create new tag on the browser
- EditorConfig support
- Improve issues / pull requests search
- Some improvements and bug fixes for plugin installation via internet and pull request commenting
### 4.26.0 - 30 Jun 2018
- Installing plugins from the central registry

View File

@@ -1,4 +1,4 @@
GitBucket [![Gitter chat](https://badges.gitter.im/gitbucket/gitbucket.svg)](https://gitter.im/gitbucket/gitbucket) [![Build Status](https://travis-ci.org/gitbucket/gitbucket.svg?branch=master)](https://travis-ci.org/gitbucket/gitbucket) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.gitbucket/gitbucket_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.gitbucket/gitbucket_2.12) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/gitbucket/gitbucket/blob/master/LICENSE)
GitBucket [![Gitter chat](https://badges.gitter.im/gitbucket/gitbucket.svg)](https://gitter.im/gitbucket/gitbucket) [![Build Status](https://travis-ci.org/gitbucket/gitbucket.svg?branch=master)](https://travis-ci.org/gitbucket/gitbucket) [![Maven Central](https://img.shields.io/maven-central/v/io.github.gitbucket/gitbucket_2.12.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.gitbucket/gitbucket_2.12) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/gitbucket/gitbucket/blob/master/LICENSE)
=========
GitBucket is a Git web platform powered by Scala offering:
@@ -68,11 +68,13 @@ Support
- If you can't find same question and report, send it to [gitter room](https://gitter.im/gitbucket/gitbucket) before raising an issue.
- The highest priority of GitBucket is the ease of installation and API compatibility with GitHub, so your feature request might be rejected if they go against those principles.
What's New in 4.27.x
What's New in 4.29.x
-------------
### 4.27.0 - 29 Jul 2018
- Create new tag on the browser
- EditorConfig support
- Improve issues / pull requests search
### 4.29.0 - 29 Sep 2018
- Official Docker image has been available
- Enhance file edit and delete buttons of the repository viewer
- Fix Patch button to generate patches for all files in the commit
- Display confirmation dialog for Transfer Ownership and Garbage collection
- Fix wrong url encoding in "Compare & pull request"
See the [change log](CHANGELOG.md) for all of the updates.

View File

@@ -3,9 +3,10 @@ import com.typesafe.sbt.pgp.PgpKeys._
val Organization = "io.github.gitbucket"
val Name = "gitbucket"
val GitBucketVersion = "4.27.0"
val ScalatraVersion = "2.6.1"
val JettyVersion = "9.4.7.v20170914"
val GitBucketVersion = "4.29.0"
val ScalatraVersion = "2.6.3"
val JettyVersion = "9.4.11.v20180605"
val JgitVersion = "5.1.1.201809181055-r"
lazy val root = (project in file("."))
.enablePlugins(SbtTwirl, ScalatraPlugin)
@@ -16,7 +17,7 @@ sourcesInBase := false
organization := Organization
name := Name
version := GitBucketVersion
scalaVersion := "2.12.6"
scalaVersion := "2.12.7"
scalafmtOnCompile := true
@@ -30,8 +31,8 @@ resolvers ++= Seq(
)
libraryDependencies ++= Seq(
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % "5.0.1.201806211838-r",
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % "5.0.1.201806211838-r",
"org.eclipse.jgit" % "org.eclipse.jgit.http.server" % JgitVersion,
"org.eclipse.jgit" % "org.eclipse.jgit.archive" % JgitVersion,
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
"org.scalatra" %% "scalatra-forms" % ScalatraVersion,
@@ -64,7 +65,7 @@ libraryDependencies ++= Seq(
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"junit" % "junit" % "4.12" % "test",
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
"org.mockito" % "mockito-core" % "2.13.0" % "test",
"org.mockito" % "mockito-core" % "2.19.1" % "test",
"com.wix" % "wix-embedded-mysql" % "3.0.0" % "test",
"ru.yandex.qatools.embed" % "postgresql-embedded" % "2.6" % "test",
"net.i2p.crypto" % "eddsa" % "0.2.0",

View File

@@ -1 +1 @@
sbt.version=1.1.6
sbt.version=1.2.3

View File

@@ -56,5 +56,7 @@ object GitBucketCoreModule
new Version("4.24.1"),
new Version("4.25.0", new LiquibaseMigration("update/gitbucket-core_4.25.xml")),
new Version("4.26.0"),
new Version("4.27.0", new LiquibaseMigration("update/gitbucket-core_4.27.xml"))
new Version("4.27.0", new LiquibaseMigration("update/gitbucket-core_4.27.xml")),
new Version("4.28.0"),
new Version("4.29.0")
)

View File

@@ -256,9 +256,9 @@ trait ApiControllerBase extends ControllerBase {
} else {
val refs = git
.getRepository()
.getAllRefs()
.getRefDatabase()
.getRefsByPrefix("refs/")
.asScala
.collect { case (str, ref) if str.startsWith("refs/" + revstr) => ref }
JsonFormat(refs.map { ref =>
val sha = ref.getObjectId().name()
@@ -352,7 +352,9 @@ trait ApiControllerBase extends ControllerBase {
data.auto_init
)
Await.result(f, Duration.Inf)
val repository = getRepository(groupName, data.name).get
val repository = Database() withTransaction { session =>
getRepository(groupName, data.name).get
}
JsonFormat(ApiRepository(repository, ApiUser(getAccountByUserName(groupName).get)))
} else {
ApiError(

View File

@@ -642,7 +642,7 @@ trait PullRequestsControllerBase extends ControllerBase {
case _ =>
forkedRepository.repository :: getForkedRepositories(forkedRepository.owner, forkedRepository.name)
}).map { repository =>
(repository.userName, repository.repositoryName)
(repository.userName, repository.repositoryName, repository.defaultBranch)
},
commits.flatten
.map(commit => getCommitComments(forkedRepository.owner, forkedRepository.name, commit.id, false))

View File

@@ -94,9 +94,16 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
),
"skinName" -> trim(label("AdminLTE skin name", text(required))),
"showMailAddress" -> trim(label("Show mail address", boolean())),
"pluginNetworkInstall" -> new SingleValueType[Boolean] {
override def convert(value: String, messages: Messages): Boolean = context.settings.pluginNetworkInstall
}
"pluginNetworkInstall" -> trim(label("Network plugin installation", boolean())),
"proxy" -> optionalIfNotChecked(
"useProxy",
mapping(
"host" -> trim(label("Proxy host", text(required))),
"port" -> trim(label("Proxy port", number())),
"user" -> trim(label("Keystore", optional(text()))),
"password" -> trim(label("Keystore", optional(text())))
)(Proxy.apply)
)
)(SystemSettings.apply).verifying { settings =>
Vector(
if (settings.ssh.enabled && settings.baseUrl.isEmpty) {
@@ -380,11 +387,6 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
})
post("/admin/plugins/_reload")(adminOnly {
// Update configuration
val pluginNetworkInstall = params.get("pluginNetworkInstall").map(_.toBoolean).getOrElse(false)
saveSystemSettings(context.settings.copy(pluginNetworkInstall = pluginNetworkInstall))
// Reload plugins
PluginRegistry.reload(request.getServletContext(), loadSystemSettings(), request2Session(request).conn)
flash += "info" -> "All plugins were reloaded."
redirect("/admin/plugins")

View File

@@ -6,8 +6,8 @@ import java.nio.file.{Files, Paths, StandardWatchEventKinds}
import java.util.Base64
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.ConcurrentHashMap
import javax.servlet.ServletContext
import javax.servlet.ServletContext
import com.github.zafarkhaja.semver.Version
import gitbucket.core.controller.{Context, ControllerBase}
import gitbucket.core.model.{Account, Issue}
@@ -18,10 +18,12 @@ import gitbucket.core.service.SystemSettingsService.SystemSettings
import gitbucket.core.util.SyntaxSugars._
import gitbucket.core.util.DatabaseConfig
import gitbucket.core.util.Directory._
import gitbucket.core.util.HttpClientUtil._
import io.github.gitbucket.solidbase.Solidbase
import io.github.gitbucket.solidbase.manager.JDBCVersionManager
import io.github.gitbucket.solidbase.model.Module
import org.apache.commons.io.FileUtils
import org.apache.http.client.methods.HttpGet
import org.apache.sshd.server.Command
import org.slf4j.LoggerFactory
import play.twirl.api.Html
@@ -253,8 +255,17 @@ object PluginRegistry {
})
.foreach(_.delete())
val in = url.openStream()
FileUtils.copyToFile(in, new File(PluginHome, new File(url.getFile).getName))
withHttpClient(settings.pluginProxy) { httpClient =>
val httpGet = new HttpGet(url.toString)
try {
val response = httpClient.execute(httpGet)
val in = response.getEntity.getContent
FileUtils.copyToFile(in, new File(PluginHome, new File(url.getFile).getName))
} finally {
httpGet.releaseConnection()
}
}
instance = new PluginRegistry()
initialize(context, settings, conn)
}

View File

@@ -1,7 +1,12 @@
package gitbucket.core.plugin
import gitbucket.core.controller.Context
import gitbucket.core.util.SyntaxSugars.using
import gitbucket.core.util.HttpClientUtil._
import org.json4s._
import org.apache.commons.io.IOUtils
import org.apache.http.client.methods.HttpGet
import org.slf4j.LoggerFactory
object PluginRepository {
@@ -12,18 +17,28 @@ object PluginRepository {
org.json4s.jackson.JsonMethods.parse(json).extract[Seq[PluginMetadata]]
}
def getPlugins(): Seq[PluginMetadata] = {
def getPlugins()(implicit context: Context): Seq[PluginMetadata] = {
try {
val url = new java.net.URL("https://plugins.gitbucket-community.org/releases/plugins.json")
val str = IOUtils.toString(url, "UTF-8")
parsePluginJson(str)
withHttpClient(context.settings.pluginProxy) { httpClient =>
val httpGet = new HttpGet(url.toString)
try {
val response = httpClient.execute(httpGet)
using(response.getEntity.getContent) { in =>
val str = IOUtils.toString(in, "UTF-8")
parsePluginJson(str)
}
} finally {
httpGet.releaseConnection()
}
}
} catch {
case t: Throwable =>
logger.warn("Failed to access to the plugin repository: " + t.toString)
Nil
}
}
}
// Mapped from plugins.json

View File

@@ -351,9 +351,11 @@ trait IssuesService {
implicit s: Session
) =
Issues filter { t1 =>
repos
.map { case (owner, repository) => t1.byRepository(owner, repository) }
.foldLeft[Rep[Boolean]](false)(_ || _) &&
(if (repos.size == 1) {
t1.byRepository(repos.head._1, repos.head._2)
} else {
((t1.userName ++ "/" ++ t1.repositoryName) inSetBind (repos.map { case (owner, repo) => s"$owner/$repo" }))
}) &&
(t1.closed === (condition.state == "closed").bind) &&
(t1.milestoneId.? isEmpty, condition.milestone == Some(None)) &&
(t1.priorityId.? isEmpty, condition.priority == Some(None)) &&

View File

@@ -70,6 +70,16 @@ trait SystemSettingsService {
props.setProperty(SkinName, settings.skinName.toString)
props.setProperty(ShowMailAddress, settings.showMailAddress.toString)
props.setProperty(PluginNetworkInstall, settings.pluginNetworkInstall.toString)
settings.pluginProxy.foreach { proxy =>
props.setProperty(PluginProxyHost, proxy.host)
props.setProperty(PluginProxyPort, proxy.port.toString)
proxy.user.foreach { user =>
props.setProperty(PluginProxyUser, user)
}
proxy.password.foreach { password =>
props.setProperty(PluginProxyPassword, password)
}
}
using(new java.io.FileOutputStream(GitBucketConf)) { out =>
props.store(out, null)
@@ -112,9 +122,7 @@ trait SystemSettingsService {
getOptionValue(props, SmtpFromName, None)
)
)
} else {
None
},
} else None,
getValue(props, LdapAuthentication, false),
if (getValue(props, LdapAuthentication, false)) {
Some(
@@ -133,9 +141,7 @@ trait SystemSettingsService {
getOptionValue(props, LdapKeystore, None)
)
)
} else {
None
},
} else None,
getValue(props, OidcAuthentication, false),
if (getValue(props, OidcAuthentication, false)) {
Some(
@@ -151,7 +157,17 @@ trait SystemSettingsService {
},
getValue(props, SkinName, "skin-blue"),
getValue(props, ShowMailAddress, false),
getValue(props, PluginNetworkInstall, false)
getValue(props, PluginNetworkInstall, false),
if (getValue(props, PluginProxyHost, "").nonEmpty) {
Some(
Proxy(
getValue(props, PluginProxyHost, ""),
getValue(props, PluginProxyPort, 8080),
getOptionValue(props, PluginProxyUser, None),
getOptionValue(props, PluginProxyPassword, None)
)
)
} else None
)
}
}
@@ -181,7 +197,8 @@ object SystemSettingsService {
oidc: Option[OIDC],
skinName: String,
showMailAddress: Boolean,
pluginNetworkInstall: Boolean
pluginNetworkInstall: Boolean,
pluginProxy: Option[Proxy]
) {
def baseUrl(request: HttpServletRequest): String =
@@ -249,6 +266,13 @@ object SystemSettingsService {
fromName: Option[String]
)
case class Proxy(
host: String,
port: Int,
user: Option[String],
password: Option[String],
)
case class SshAddress(host: String, port: Int, genericUser: String)
case class Lfs(serverUrl: Option[String])
@@ -298,6 +322,10 @@ object SystemSettingsService {
private val SkinName = "skinName"
private val ShowMailAddress = "showMailAddress"
private val PluginNetworkInstall = "plugin.networkInstall"
private val PluginProxyHost = "plugin.proxy.host"
private val PluginProxyPort = "plugin.proxy.port"
private val PluginProxyUser = "plugin.proxy.user"
private val PluginProxyPassword = "plugin.proxy.password"
private def getValue[A: ClassTag](props: java.util.Properties, key: String, default: A): A = {
getSystemProperty(key).getOrElse(getEnvironmentVariable(key).getOrElse {

View File

@@ -0,0 +1,35 @@
package gitbucket.core.util
import gitbucket.core.service.SystemSettingsService
import org.apache.http.HttpHost
import org.apache.http.auth.{AuthScope, UsernamePasswordCredentials}
import org.apache.http.impl.client.{BasicCredentialsProvider, CloseableHttpClient, HttpClientBuilder}
object HttpClientUtil {
def withHttpClient[T](proxy: Option[SystemSettingsService.Proxy])(f: CloseableHttpClient => T): T = {
val builder = HttpClientBuilder.create.useSystemProperties
proxy.foreach { proxy =>
builder.setProxy(new HttpHost(proxy.host, proxy.port))
for (user <- proxy.user; password <- proxy.password) {
val credential = new BasicCredentialsProvider()
credential.setCredentials(
new AuthScope(proxy.host, proxy.port),
new UsernamePasswordCredentials(user, password)
)
builder.setDefaultCredentialsProvider(credential)
}
}
val httpClient = builder.build()
try {
f(httpClient)
} finally {
httpClient.close()
}
}
}

View File

@@ -613,8 +613,12 @@ object JGitUtil {
df.setRepository(git.getRepository)
df.setDiffComparator(RawTextComparator.DEFAULT)
df.setDetectRenames(true)
df.format(getDiffEntries(git, from, to).head)
new String(out.toByteArray, "UTF-8")
getDiffEntries(git, from, to)
.map { entry =>
df.format(entry)
new String(out.toByteArray, "UTF-8")
}
.mkString("\n")
}
private def getDiffEntries(git: Git, from: Option[String], to: String): Seq[DiffEntry] = {
@@ -740,15 +744,17 @@ object JGitUtil {
def getBranchesOfCommit(git: Git, commitId: String): List[String] =
using(new RevWalk(git.getRepository)) { revWalk =>
defining(revWalk.parseCommit(git.getRepository.resolve(commitId + "^0"))) { commit =>
git.getRepository.getAllRefs.entrySet.asScala
git.getRepository.getRefDatabase
.getRefsByPrefix(Constants.R_HEADS)
.asScala
.filter { e =>
(e.getKey.startsWith(Constants.R_HEADS) && revWalk.isMergedInto(
(revWalk.isMergedInto(
commit,
revWalk.parseCommit(e.getValue.getObjectId)
revWalk.parseCommit(e.getObjectId)
))
}
.map { e =>
e.getValue.getName.substring(org.eclipse.jgit.lib.Constants.R_HEADS.length)
e.getName.substring(Constants.R_HEADS.length)
}
.toList
.sorted
@@ -781,15 +787,17 @@ object JGitUtil {
def getTagsOfCommit(git: Git, commitId: String): List[String] =
using(new RevWalk(git.getRepository)) { revWalk =>
defining(revWalk.parseCommit(git.getRepository.resolve(commitId + "^0"))) { commit =>
git.getRepository.getAllRefs.entrySet.asScala
git.getRepository.getRefDatabase
.getRefsByPrefix(Constants.R_TAGS)
.asScala
.filter { e =>
(e.getKey.startsWith(Constants.R_TAGS) && revWalk.isMergedInto(
(revWalk.isMergedInto(
commit,
revWalk.parseCommit(e.getValue.getObjectId)
revWalk.parseCommit(e.getObjectId)
))
}
.map { e =>
e.getValue.getName.substring(org.eclipse.jgit.lib.Constants.R_TAGS.length)
e.getName.substring(Constants.R_TAGS.length)
}
.toList
.sorted

View File

@@ -127,7 +127,11 @@ object LDAPUtil {
private def getSslProvider(): Provider = {
val cachedInstance = provider.get()
if (cachedInstance == null) {
val newInstance = Class.forName("com.sun.net.ssl.internal.ssl.Provider").newInstance().asInstanceOf[Provider]
val newInstance = Class
.forName("com.sun.net.ssl.internal.ssl.Provider")
.getDeclaredConstructor()
.newInstance()
.asInstanceOf[Provider]
provider.compareAndSet(null, newInstance)
newInstance
} else {

View File

@@ -3,23 +3,23 @@ package gitbucket.core.view
import gitbucket.core.controller.Context
import gitbucket.core.service.{RepositoryService, RequestCache}
import gitbucket.core.util.Implicits.RichString
import gitbucket.core.util.StringUtil
trait LinkConverter { self: RequestCache =>
/**
* Creates a link to the issue or the pull request from the issue id.
*/
protected def createIssueLink(repository: RepositoryService.RepositoryInfo, issueId: Int)(
protected def createIssueLink(repository: RepositoryService.RepositoryInfo, issueId: Int, title: String)(
implicit context: Context
): String = {
val userName = repository.repository.userName
val repositoryName = repository.repository.repositoryName
getIssue(userName, repositoryName, issueId.toString) match {
case Some(issue) if (issue.isPullRequest) =>
s"""<a href="${context.path}/${userName}/${repositoryName}/pull/${issueId}">Pull #${issueId}</a>"""
case Some(_) =>
s"""<a href="${context.path}/${userName}/${repositoryName}/issues/${issueId}">Issue #${issueId}</a>"""
case Some(issue) =>
s"""<a href="${context.path}/${userName}/${repositoryName}/${if (issue.isPullRequest) "pull" else "issues"}/${issueId}"><strong>${StringUtil
.escapeHtml(title)}</strong> #${issueId}</a>"""
case None =>
s"Unknown #${issueId}"
}

View File

@@ -156,8 +156,10 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
/**
* Creates a link to the issue or the pull request from the issue id.
*/
def issueLink(repository: RepositoryService.RepositoryInfo, issueId: Int)(implicit context: Context): Html = {
Html(createIssueLink(repository, issueId))
def issueLink(repository: RepositoryService.RepositoryInfo, issueId: Int, title: String)(
implicit context: Context
): Html = {
Html(createIssueLink(repository, issueId, title))
}
/**

View File

@@ -3,8 +3,6 @@
@gitbucket.core.admin.html.menu("plugins") {
@gitbucket.core.helper.html.information(info)
<form action="@context.path/admin/plugins/_reload" method="POST" class="pull-right">
<input type="checkbox" name="pluginNetworkInstall" id="pluginNetworkInstall" value="true" @if(context.settings.pluginNetworkInstall){checked}>
<label for="pluginNetworkInstall">Install plugin from <a href="https://plugins.gitbucket-community.org" target="_blank">plugins.gitbucket-community.org</a></label>
<input type="submit" value="Reload plugins" class="btn btn-default">
</form>
<h1 class="system-settings-title">Plugins</h1>

View File

@@ -8,6 +8,7 @@
<ul class="nav nav-tabs fill-width" id="pullreq-tab">
<li><a href="#system">System settings</a></li>
<li><a href="#authentication">Authentication</a></li>
<li><a href="#plugins">Plugins</a></li>
</ul>
<div class="tab-content fill-width" style="padding-top: 20px;">
<div class="tab-pane" id="system">
@@ -16,6 +17,9 @@
<div class="tab-pane" id="authentication">
@settings_authentication(info)
</div>
<div class="tab-pane" id="plugins">
@settings_plugins(info)
</div>
</div>
<hr>
<div class="align-right" style="margin-top: 20px;">
@@ -30,6 +34,9 @@ $(function(){
if(location.hash == '#authentication'){
$('li:has(a[href="#authentication"])').addClass('active');
$('div#authentication').addClass('active');
} else if(location.hash == '#plugins'){
$('li:has(a[href="#plugins"])').addClass('active');
$('div#plugins').addClass('active');
} else {
$('li:has(a[href="#system"])').addClass('active');
$('div#system').addClass('active');

View File

@@ -0,0 +1,52 @@
@(info: Option[Any])(implicit context: gitbucket.core.controller.Context)
<label class="strong">Plugin repositories</label>
<fieldset>
<label class="checkbox">
<input type="checkbox" id="pluginNetworkInstall" name="pluginNetworkInstall"@if(context.settings.pluginNetworkInstall){ checked} />
<a href="https://plugins.gitbucket-community.org" target="_blank">plugins.gitbucket-community.org</a>
</label>
</fieldset>
<hr>
<fieldset>
<label class="checkbox">
<input type="checkbox" id="useProxy" name="useProxy"@if(context.settings.pluginProxy.isDefined){ checked} />
Use proxy
</label>
</fieldset>
<div class="proxy">
<div class="form-group">
<label class="control-label col-md-2" for="proxyHost">Proxy host</label>
<div class="col-md-10">
<input type="text" id="proxyHost" name="proxy.host" class="form-control" value="@context.settings.pluginProxy.map(_.host)"/>
<span id="error-proxy_host" class="error"></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2" for="proxyPort">Proxy port</label>
<div class="col-md-10">
<input type="text" id="proxyPort" name="proxy.port" class="form-control input-mini" value="@context.settings.pluginProxy.map(_.port)"/>
<span id="error-proxy_port" class="error"></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2" for="proxyUser">Proxy user</label>
<div class="col-md-10">
<input type="text" id="proxyUser" name="proxy.user" class="form-control" value="@context.settings.pluginProxy.map(_.user)"/>
<span id="error-proxy_user" class="error"></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2" for="proxyPassword">Proxy password</label>
<div class="col-md-10">
<input type="password" id="proxyPassword" name="proxy.password" class="form-control" value="@context.settings.pluginProxy.map(_.password)"/>
<span id="error-proxy_password" class="error"></span>
</div>
</div>
</div>
<script>
$(function(){
$('#useProxy').change(function(){
$('.proxy input').prop('disabled', !$(this).prop('checked'));
}).change();
});
</script>

View File

@@ -112,7 +112,7 @@
</div>
<div style="discussion-item-content">
@defining(comment.content.split(":")){ case Array(issueId, rest @ _*) =>
<strong>@helpers.issueLink(repository, issueId.toInt): @rest.mkString(":")</strong>
@helpers.issueLink(repository, issueId.toInt, rest.mkString(":"))
}
</div>
</div>

View File

@@ -1,7 +1,7 @@
@(title: String,
commits: Seq[Seq[gitbucket.core.util.JGitUtil.CommitInfo]],
diffs: Seq[gitbucket.core.util.JGitUtil.DiffInfo],
members: List[(String, String)],
members: List[(String, String, String)],
comments: List[gitbucket.core.model.Comment],
originId: String,
forkedId: String,
@@ -22,8 +22,8 @@
<div class="pullreq-info">
<div id="compare-edit">
@gitbucket.core.helper.html.dropdown(originRepository.owner + "/" + originRepository.name, "base fork", filter=("origin_repo", "Find Repository...")) {
@members.map { case (owner, name) =>
<li><a href="#" class="origin-owner" data-owner="@owner" data-name="@name">@gitbucket.core.helper.html.checkicon(owner == originRepository.owner) @owner/@name</a></li>
@members.map { case (owner, name, defaultBranch) =>
<li><a href="#" class="origin-owner" data-owner="@owner" data-name="@name" data-default-branch="@defaultBranch">@gitbucket.core.helper.html.checkicon(owner == originRepository.owner) @owner/@name</a></li>
}
}
@gitbucket.core.helper.html.dropdown(originId, "base", filter=("origin_branch", "Find Branch...")) {
@@ -33,8 +33,8 @@
}
...
@gitbucket.core.helper.html.dropdown(forkedRepository.owner + "/" + forkedRepository.name, "head fork", filter=("forked_repo", "Find Repository...")) {
@members.map { case (owner, name) =>
<li><a href="#" class="forked-owner" data-owner="@owner" data-name="@name">@gitbucket.core.helper.html.checkicon(owner == forkedRepository.owner) @owner/@name</a></li>
@members.map { case (owner, name, defaultBranch) =>
<li><a href="#" class="forked-owner" data-owner="@owner" data-name="@name" data-default-branch="@defaultBranch">@gitbucket.core.helper.html.checkicon(owner == forkedRepository.owner) @owner/@name</a></li>
}
}
@gitbucket.core.helper.html.dropdown(forkedId, "compare", filter=("forked_branch", "Find Branch...")) {
@@ -170,25 +170,46 @@
}
<script>
$(function(){
$('a.origin-owner, a.forked-owner, a.origin-branch, a.forked-branch').click(function(){
var e = $(this);
function updateSelector(e){
e.parents('ul').find('i').attr('class', 'octicon');
e.find('i').addClass('octicon-check');
e.parents('div.btn-group').find('button span.strong').text(e.text());
}
@if(members.isEmpty){
location.href = '@helpers.url(repository)/compare/' +
$.trim($('i.octicon-check').parents('a.origin-branch').data('branch')) + '...' +
$.trim($('i.octicon-check').parents('a.forked-branch').data('branch'));
} else {
location.href = '@context.path/' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('owner')) + '/' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('name')) +'/compare/' +
$.trim($('i.octicon-check').parents('a.origin-owner' ).data('owner')) + ':' +
$.trim($('i.octicon-check').parents('a.origin-branch').data('branch')) + '...' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('owner')) + ':' +
$.trim($('i.octicon-check').parents('a.forked-branch').data('branch'));
}
$('a.origin-owner').click(function(){
updateSelector($(this));
location.href = '@context.path/' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('owner')) + '/' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('name')) +'/compare/' +
$.trim($('i.octicon-check').parents('a.origin-owner' ).data('owner')) + ':' +
$.trim($('i.octicon-check').parents('a.origin-owner' ).data('default-branch')) + '...' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('owner')) + ':' +
$.trim($('i.octicon-check').parents('a.forked-branch').data('branch'));
});
$('a.forked-owner').click(function(){
updateSelector($(this));
location.href = '@context.path/' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('owner')) + '/' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('name')) +'/compare/' +
$.trim($('i.octicon-check').parents('a.origin-owner' ).data('owner')) + ':' +
$.trim($('i.octicon-check').parents('a.origin-branch').data('branch')) + '...' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('owner')) + ':' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('default-branch'));
});
$('a.origin-branch, a.forked-branch').click(function(){
updateSelector($(this));
location.href = '@context.path/' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('owner')) + '/' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('name')) +'/compare/' +
$.trim($('i.octicon-check').parents('a.origin-owner' ).data('owner')) + ':' +
$.trim($('i.octicon-check').parents('a.origin-branch').data('branch')) + '...' +
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('owner')) + ':' +
$.trim($('i.octicon-check').parents('a.forked-branch').data('branch'));
});
$('#show-form').click(function(){
@@ -206,19 +227,12 @@ $(function(){
function(data){ $('.check-conflict').html(data); });
}
@if(members.isEmpty){
checkConflict(
$.trim($('i.octicon-check').parents('a.origin-branch').data('branch')),
$.trim($('i.octicon-check').parents('a.forked-branch').data('branch'))
);
} else {
checkConflict(
$.trim($('i.octicon-check').parents('a.origin-owner' ).data('owner')) + ":" +
$.trim($('i.octicon-check').parents('a.origin-branch').data('branch')),
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('owner')) + ":" +
$.trim($('i.octicon-check').parents('a.forked-branch').data('branch'))
);
}
checkConflict(
$.trim($('i.octicon-check').parents('a.origin-owner' ).data('owner')) + ":" +
$.trim($('i.octicon-check').parents('a.origin-branch').data('branch')),
$.trim($('i.octicon-check').parents('a.forked-owner' ).data('owner')) + ":" +
$.trim($('i.octicon-check').parents('a.forked-branch').data('branch'))
);
}
});
</script>

View File

@@ -7,7 +7,7 @@
<div class="box-content" style="line-height: 20pt; margin-bottom: 6px; padding: 10px 6px 10px 10px; background-color: #fff9ea">
<strong><i class="menu-icon octicon octicon-git-branch"></i><span class="muted">@branch</span></strong>
<a class="pull-right btn btn-success" style="position: relative; top: -4px;"
href="@helpers.url(repository)/compare/@{parent.owner}:@{parent.repository.defaultBranch}...@{repository.owner}:@{branch}">Compare & pull request</a>
href="@helpers.url(repository)/compare/@{parent.owner}:@{helpers.encodeRefName(parent.repository.defaultBranch)}...@{repository.owner}:@{helpers.encodeRefName(branch)}">Compare & pull request</a>
</div>
}
}
}

View File

@@ -55,24 +55,24 @@
<span class="label label-info">LFS</span>
}
</div>
<div class="box-header">
@helpers.avatarLink(latestCommit, 28)
<div class="box-header" style="line-height: 28px;">
@helpers.avatarLink(latestCommit, 20)
@helpers.user(latestCommit.authorName, latestCommit.authorEmailAddress, "username strong")
<span class="muted">@gitbucket.core.helper.html.datetimeago(latestCommit.commitTime)</span>
<span class="label label-default">@helpers.readableSize(content.size)</span>
<a href="@helpers.url(repository)/commit/@latestCommit.id" class="commit-message">@helpers.link(latestCommit.summary, repository)</a>
<div class="btn-group pull-right">
@if(hasWritePermission && content.viewType == "text" && repository.branchList.contains(branch)){
<a class="btn btn-sm btn-default" href="@helpers.url(repository)/edit/@helpers.encodeRefName((branch :: pathList).mkString("/"))">Edit</a>
}
<a class="btn btn-sm btn-default" href="@helpers.url(repository)/raw/@latestCommit.id/@helpers.encodeRefName(pathList.mkString("/"))">Raw</a>
@if(content.viewType == "text"){
<a class="btn btn-sm btn-default blame-action" href="@helpers.url(repository)/blame/@latestCommit.id/@helpers.encodeRefName(pathList.mkString("/"))"
data-url="@helpers.url(repository)/get-blame/@helpers.encodeRefName((latestCommit.id :: pathList).mkString("/"))" data-repository="@helpers.url(repository)">Blame</a>
}
<a class="btn btn-sm btn-default" href="@helpers.url(repository)/commits/@helpers.encodeRefName((branch :: pathList).mkString("/"))">History</a>
@if(hasWritePermission && content.viewType == "text" && repository.branchList.contains(branch)){
<a class="btn btn-sm" style="padding-right: 4px;" href="@helpers.url(repository)/edit/@helpers.encodeRefName((branch :: pathList).mkString("/"))"><i class="octicon octicon-pencil"></i></a>
}
@if(hasWritePermission && repository.branchList.contains(branch)){
<a class="btn btn-sm btn-danger" href="@helpers.url(repository)/remove/@helpers.encodeRefName((branch :: pathList).mkString("/"))">Delete</a>
<a class="btn btn-sm" style="padding-right: 4px;" href="@helpers.url(repository)/remove/@helpers.encodeRefName((branch :: pathList).mkString("/"))"><i class="octicon octicon-trashcan"></i></a>
}
</div>
</div>

View File

@@ -196,11 +196,19 @@
</tr>
}
</table>
@readme.map { case(filePath, content) =>
<div id="readme" class="panel panel-default">
<div class="panel-heading strong">@filePath.last</div>
<div class="panel-body markdown-body" style="padding-left: 20px; padding-right: 20px;">@helpers.renderMarkup(filePath, content, branch, repository, false, false, true)</div>
@readme.map { case (filePath, content) =>
<div id="readme" class="box-header">
<div class="strong" style="line-height: 28px;">
<i class="octicon octicon-file"></i>
@filePath.last
@if(hasWritePermission){
<div class="btn-group pull-right">
<a class="btn btn-sm" style="padding-right: 4px;" href="@helpers.url(repository)/edit/@helpers.encodeRefName((branch :: filePath).mkString("/"))"><i class="octicon octicon-pencil"></i></a>
</div>
}
</div>
</div>
<div class="box-content-bottom markdown-body" style="padding-left: 20px; padding-right: 20px;">@helpers.renderMarkup(filePath, content, branch, repository, false, false, true)</div>
}
}
}

View File

@@ -50,5 +50,15 @@ $(function(){
$('#delete-form').submit(function(){
return confirm('Once you delete a repository, there is no going back.\nAre you sure?');
});
$('#transfer-form').submit(function(){
if($('#transfer-form').data('validated') === true){
return confirm('Transfer to the repository owner you entered.\nAre you sure?');
} else {
return true;
}
});
$('#gc-form').submit(function(){
return confirm('The garbage collection may take a long time.\nDo you want to execute it?');
});
});
</script>

View File

@@ -138,7 +138,8 @@ class AvatarImageProviderSpec extends FunSpec with MockitoSugar {
oidc = None,
skinName = "skin-blue",
showMailAddress = false,
pluginNetworkInstall = false
pluginNetworkInstall = false,
pluginProxy = None
)
/**