diff --git a/build.sbt b/build.sbt index 350e2d0..bea6e6a 100644 --- a/build.sbt +++ b/build.sbt @@ -17,7 +17,7 @@ organization := Organization name := Name version := GitBucketVersion -scalaVersion := "2.12.8" +scalaVersion := "2.13.0" scalafmtOnCompile := true @@ -47,7 +47,7 @@ "org.apache.httpcomponents" % "httpclient" % "4.5.6", "org.apache.sshd" % "apache-sshd" % "2.1.0" exclude ("org.slf4j", "slf4j-jdk14") exclude ("org.apache.sshd", "sshd-mina") exclude ("org.apache.sshd", "sshd-netty"), "org.apache.tika" % "tika-core" % "1.19.1", - "com.github.takezoe" %% "blocking-slick-32" % "0.0.11", + "com.github.takezoe" %% "blocking-slick-32" % "0.0.12", "com.novell.ldap" % "jldap" % "2009-10-07", "com.h2database" % "h2" % "1.4.197", "org.mariadb.jdbc" % "mariadb-java-client" % "2.4.2", @@ -59,7 +59,7 @@ "fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.1.0", "com.github.bkromhout" % "java-diff-utils" % "2.1.1", "org.cache2k" % "cache2k-all" % "1.2.0.Final", - "com.enragedginger" %% "akka-quartz-scheduler" % "1.7.0-akka-2.5.x" exclude ("c3p0", "c3p0") exclude ("com.zaxxer", "HikariCP-java6"), + "com.enragedginger" %% "akka-quartz-scheduler" % "1.8.1-akka-2.5.x" exclude ("com.mchange", "c3p0") exclude ("com.zaxxer", "HikariCP-java6"), "net.coobird" % "thumbnailator" % "0.4.8", "com.github.zafarkhaja" % "java-semver" % "0.9.0", "com.nimbusds" % "oauth2-oidc-sdk" % "5.64.4", @@ -77,7 +77,7 @@ ) // Compiler settings -scalacOptions := Seq("-deprecation", "-language:postfixOps", "-opt:l:method", "-Xfuture") +scalacOptions := Seq("-deprecation", "-language:postfixOps", "-opt:l:method") javacOptions in compile ++= Seq("-target", "8", "-source", "8") javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml" diff --git a/doc/build.md b/doc/build.md index d508b50..0adbfcd 100644 --- a/doc/build.md +++ b/doc/build.md @@ -29,7 +29,7 @@ $ sbt package ``` -`gitbucket_2.12-x.x.x.war` is generated into `target/scala-2.12`. +`gitbucket_2.13-x.x.x.war` is generated into `target/scala-2.13`. To build an executable war file, run @@ -58,4 +58,4 @@ ```shell $ sbt "testOnly * -- -l ExternalDBTest" -``` \ No newline at end of file +``` diff --git a/src/main/scala/gitbucket/core/controller/AccountController.scala b/src/main/scala/gitbucket/core/controller/AccountController.scala index caea806..886d9c4 100644 --- a/src/main/scala/gitbucket/core/controller/AccountController.scala +++ b/src/main/scala/gitbucket/core/controller/AccountController.scala @@ -5,7 +5,6 @@ import gitbucket.core.account.html import gitbucket.core.helper import gitbucket.core.model._ -import gitbucket.core.plugin.PluginRegistry import gitbucket.core.service._ import gitbucket.core.service.WebHookService._ import gitbucket.core.ssh.SshUtil @@ -543,7 +542,7 @@ case e: java.net.UnknownHostException => Map("error" -> ("Unknown host " + e.getMessage)) case e: java.lang.IllegalArgumentException => Map("error" -> ("invalid url")) case e: org.apache.http.client.ClientProtocolException => Map("error" -> ("invalid url")) - case NonFatal(e) => Map("error" -> (e.getClass + " " + e.getMessage)) + case NonFatal(e) => Map("error" -> (s"${e.getClass} ${e.getMessage}")) } contentType = formats("json") diff --git a/src/main/scala/gitbucket/core/controller/ControllerBase.scala b/src/main/scala/gitbucket/core/controller/ControllerBase.scala index fa51b5a..f05770b 100644 --- a/src/main/scala/gitbucket/core/controller/ControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/ControllerBase.scala @@ -365,7 +365,7 @@ params: Map[String, Seq[String]], messages: Messages ): Option[String] = { - val extraMailAddresses = params.filterKeys(k => k.startsWith("extraMailAddresses")) + val extraMailAddresses = params.view.filterKeys(k => k.startsWith("extraMailAddresses")) if (extraMailAddresses.exists { case (k, v) => v.contains(value) @@ -388,7 +388,7 @@ params: Map[String, Seq[String]], messages: Messages ): Option[String] = { - val extraMailAddresses = params.filterKeys(k => k.startsWith("extraMailAddresses")) + val extraMailAddresses = params.view.filterKeys(k => k.startsWith("extraMailAddresses")) if (Some(value) == params.optionValue("mailAddress") || extraMailAddresses.count { case (k, v) => v.contains(value) diff --git a/src/main/scala/gitbucket/core/controller/IssuesController.scala b/src/main/scala/gitbucket/core/controller/IssuesController.scala index efc0acb..f19e7a9 100644 --- a/src/main/scala/gitbucket/core/controller/IssuesController.scala +++ b/src/main/scala/gitbucket/core/controller/IssuesController.scala @@ -145,7 +145,7 @@ form.assignedUserName, form.milestoneId, form.priorityId, - form.labelNames.toArray.flatMap(_.split(",")), + form.labelNames.toSeq.flatMap(_.split(",")), context.loginAccount.get ) diff --git a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala index e98f2c1..c736226 100644 --- a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala @@ -254,9 +254,9 @@ using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git => - import scala.collection.JavaConverters._ import scala.concurrent.duration._ import scala.concurrent._ + import scala.jdk.CollectionConverters._ import scala.util.control.NonFatal import org.apache.http.util.EntityUtils import scala.concurrent.ExecutionContext.Implicits.global @@ -298,7 +298,7 @@ case e: java.net.UnknownHostException => Map("error" -> ("Unknown host " + e.getMessage)) case e: java.lang.IllegalArgumentException => Map("error" -> ("invalid url")) case e: org.apache.http.client.ClientProtocolException => Map("error" -> ("invalid url")) - case NonFatal(e) => Map("error" -> (e.getClass + " " + e.getMessage)) + case NonFatal(e) => Map("error" -> (s"${e.getClass} ${e.getMessage}")) } contentType = formats("json") diff --git a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala index 8e238b2..b13e948 100644 --- a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala @@ -258,7 +258,7 @@ def getSummary(statuses: List[CommitStatus]): (CommitState, String) = { val stateMap = statuses.groupBy(_.state) val state = CommitState.combine(stateMap.keySet) - val summary = stateMap.map { case (keyState, states) => states.size + " " + keyState.name }.mkString(", ") + val summary = stateMap.map { case (keyState, states) => s"${states.size} ${keyState.name}" }.mkString(", ") state -> summary } @@ -351,7 +351,7 @@ repository = repository, branch = form.branch, path = form.path, - files = files, + files = files.toIndexedSeq, message = form.message.getOrElse("Add files via upload"), loginAccount = context.loginAccount.get ) { @@ -980,7 +980,7 @@ val date = commit.getCommitterIdent.getWhen val sha1 = oid.getName() val repositorySuffix = (if (sha1.startsWith(revision)) sha1 else revision).replace('/', '-') - val pathSuffix = if (path.isEmpty) "" else '-' + path.replace('/', '-') + val pathSuffix = if (path.isEmpty) "" else s"-${path.replace('/', '-')}" val baseName = repository.name + "-" + repositorySuffix + pathSuffix using(new TreeWalk(git.getRepository)) { treeWalk => diff --git a/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala b/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala index a71c83f..cff406a 100644 --- a/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala +++ b/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala @@ -245,10 +245,10 @@ } } - tables += Table(tableName.toUpperCase, columns) + tables += Table(tableName.toUpperCase, columns.toSeq) } } - html.dbviewer(tables) + html.dbviewer(tables.toSeq) }) post("/admin/dbviewer/_query")(adminOnly { diff --git a/src/main/scala/gitbucket/core/controller/api/ApiGitReferenceControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiGitReferenceControllerBase.scala index 9069733..198c842 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiGitReferenceControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiGitReferenceControllerBase.scala @@ -6,7 +6,8 @@ import gitbucket.core.util.SyntaxSugars.using import gitbucket.core.util.Implicits._ import org.eclipse.jgit.api.Git -import scala.collection.JavaConverters._ + +import scala.jdk.CollectionConverters._ trait ApiGitReferenceControllerBase extends ControllerBase { self: ReferrerAuthenticator => diff --git a/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala index 9872d07..63996a1 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala @@ -13,7 +13,7 @@ import org.eclipse.jgit.api.Git import org.scalatra.NoContent -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ trait ApiPullRequestControllerBase extends ControllerBase { self: AccountService diff --git a/src/main/scala/gitbucket/core/plugin/PluginRegistry.scala b/src/main/scala/gitbucket/core/plugin/PluginRegistry.scala index 4dcd05e..b633691 100644 --- a/src/main/scala/gitbucket/core/plugin/PluginRegistry.scala +++ b/src/main/scala/gitbucket/core/plugin/PluginRegistry.scala @@ -17,17 +17,15 @@ import gitbucket.core.service.SystemSettingsService.SystemSettings 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.Command import org.slf4j.LoggerFactory import play.twirl.api.Html -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ class PluginRegistry { @@ -415,7 +413,6 @@ class PluginWatchThread(context: ServletContext, dir: String) extends Thread with SystemSettingsService { import gitbucket.core.model.Profile.profile.blockingApi._ - import scala.collection.JavaConverters._ private val logger = LoggerFactory.getLogger(classOf[PluginWatchThread]) @@ -445,7 +442,7 @@ } if (events.nonEmpty) { events.foreach { event => - logger.info(event.kind + ": " + event.context) + logger.info(s"${event.kind}: ${event.context}") } new Thread { override def run(): Unit = { diff --git a/src/main/scala/gitbucket/core/service/GpgKeyService.scala b/src/main/scala/gitbucket/core/service/GpgKeyService.scala index 3e10b93..560af3f 100644 --- a/src/main/scala/gitbucket/core/service/GpgKeyService.scala +++ b/src/main/scala/gitbucket/core/service/GpgKeyService.scala @@ -3,14 +3,14 @@ import java.io.ByteArrayInputStream import gitbucket.core.model.GpgKey - -import collection.JavaConverters._ import gitbucket.core.model.Profile._ import gitbucket.core.model.Profile.profile.blockingApi._ import org.bouncycastle.bcpg.ArmoredInputStream import org.bouncycastle.openpgp.PGPPublicKeyRing import org.bouncycastle.openpgp.bc.BcPGPObjectFactory +import scala.jdk.CollectionConverters._ + trait GpgKeyService { def getGpgPublicKeys(userName: String)(implicit s: Session): List[GpgKey] = GpgKeys.filter(_.userName === userName.bind).sortBy(_.gpgKeyId).list diff --git a/src/main/scala/gitbucket/core/service/IssuesService.scala b/src/main/scala/gitbucket/core/service/IssuesService.scala index 29665bd..9dbc344 100644 --- a/src/main/scala/gitbucket/core/service/IssuesService.scala +++ b/src/main/scala/gitbucket/core/service/IssuesService.scala @@ -752,7 +752,7 @@ implicit s: Session ): Unit = { extractIssueId(message).foreach { issueId => - val content = fromIssue.issueId + ":" + fromIssue.title + val content = s"${fromIssue.issueId}:${fromIssue.title}" if (getIssue(owner, repository, issueId).isDefined) { // Not add if refer comment already exist. if (!getComments(owner, repository, issueId.toInt).exists { x => diff --git a/src/main/scala/gitbucket/core/service/MergeService.scala b/src/main/scala/gitbucket/core/service/MergeService.scala index 6122374..e3762e4 100644 --- a/src/main/scala/gitbucket/core/service/MergeService.scala +++ b/src/main/scala/gitbucket/core/service/MergeService.scala @@ -8,8 +8,6 @@ import gitbucket.core.util.Directory._ import gitbucket.core.util.{JGitUtil, LockUtil} import gitbucket.core.util.SyntaxSugars._ -import gitbucket.core.model.Profile._ -import gitbucket.core.model.Profile.profile._ import gitbucket.core.model.Profile.profile.blockingApi._ import org.eclipse.jgit.merge.{MergeStrategy, Merger, RecursiveMerger} import org.eclipse.jgit.api.Git @@ -18,7 +16,7 @@ import org.eclipse.jgit.lib.{CommitBuilder, ObjectId, PersonIdent, Repository} import org.eclipse.jgit.revwalk.{RevCommit, RevWalk} -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ trait MergeService { self: AccountService diff --git a/src/main/scala/gitbucket/core/service/OpenIDConnectService.scala b/src/main/scala/gitbucket/core/service/OpenIDConnectService.scala index 2b60dce..36ace5d 100644 --- a/src/main/scala/gitbucket/core/service/OpenIDConnectService.scala +++ b/src/main/scala/gitbucket/core/service/OpenIDConnectService.scala @@ -17,7 +17,7 @@ import gitbucket.core.model.Profile.profile.blockingApi._ import org.slf4j.LoggerFactory -import scala.collection.JavaConverters.{asScalaSet, mapAsJavaMap} +import scala.jdk.CollectionConverters._ /** * Service class for the OpenID Connect authentication. @@ -101,7 +101,7 @@ redirectURI: URI ): Option[AuthenticationSuccessResponse] = try { - AuthenticationResponseParser.parse(redirectURI, mapAsJavaMap(params)) match { + AuthenticationResponseParser.parse(redirectURI, params.asJava) match { case response: AuthenticationSuccessResponse => if (response.getState == state) { Some(response) @@ -207,5 +207,5 @@ "RSA" -> Family.RSA, "ECDSA" -> Family.EC, "EdDSA" -> Family.ED - ).toMap.map { case (name, family) => (name, asScalaSet(family).toSet) } + ).toMap.map { case (name, family) => (name, family.asScala.toSet) } } diff --git a/src/main/scala/gitbucket/core/service/PullRequestService.scala b/src/main/scala/gitbucket/core/service/PullRequestService.scala index 05d771f..871b3f9 100644 --- a/src/main/scala/gitbucket/core/service/PullRequestService.scala +++ b/src/main/scala/gitbucket/core/service/PullRequestService.scala @@ -19,7 +19,7 @@ import org.eclipse.jgit.api.Git import org.eclipse.jgit.lib.ObjectId -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ trait PullRequestService { self: IssuesService @@ -544,7 +544,7 @@ lazy val commitStateSummary: (CommitState, String) = { val stateMap = statuses.groupBy(_.state) val state = CommitState.combine(stateMap.keySet) - val summary = stateMap.map { case (keyState, states) => states.size + " " + keyState.name }.mkString(", ") + val summary = stateMap.map { case (keyState, states) => s"${states.size} ${keyState.name}" }.mkString(", ") state -> summary } lazy val statusesAndRequired: List[(CommitStatus, Boolean)] = statuses.map { s => diff --git a/src/main/scala/gitbucket/core/service/WebHookService.scala b/src/main/scala/gitbucket/core/service/WebHookService.scala index d3dff04..4da84b0 100644 --- a/src/main/scala/gitbucket/core/service/WebHookService.scala +++ b/src/main/scala/gitbucket/core/service/WebHookService.scala @@ -55,6 +55,7 @@ .map { case (w, t) => w -> t.event } .list .groupBy(_._1) + .view .mapValues(_.map(_._2).toSet) .toList .sortBy(_._1.url) @@ -87,6 +88,7 @@ .map { case (w, t) => w -> t.event } .list .groupBy(_._1) + .view .mapValues(_.map(_._2).toSet) .headOption @@ -136,6 +138,7 @@ .map { case (w, t) => w -> t.event } .list .groupBy(_._1) + .view .mapValues(_.map(_._2).toSet) .toList .sortBy(_._1.url) @@ -164,6 +167,7 @@ .map { case (w, t) => w -> t.event } .list .groupBy(_._1) + .view .mapValues(_.map(_._2).toSet) .headOption @@ -396,7 +400,7 @@ if wht.event === WebHook.PullRequest.asInstanceOf[WebHook.Event].bind && wht.byRepositoryWebHook(wh) } yield { ((is, iu, pr, bu, ru), wh) - }).list.groupBy(_._1).mapValues(_.map(_._2)) + }).list.groupBy(_._1).map { case (k, v) => (k, v.map(_._2)) } def callPullRequestWebHookByRequestBranch( action: String, diff --git a/src/main/scala/gitbucket/core/service/WikiService.scala b/src/main/scala/gitbucket/core/service/WikiService.scala index 9330fa4..47be225 100644 --- a/src/main/scala/gitbucket/core/service/WikiService.scala +++ b/src/main/scala/gitbucket/core/service/WikiService.scala @@ -14,7 +14,8 @@ import java.io.ByteArrayInputStream import org.eclipse.jgit.patch._ import org.eclipse.jgit.api.errors.PatchFormatException -import scala.collection.JavaConverters._ + +import scala.jdk.CollectionConverters._ object WikiService { diff --git a/src/main/scala/gitbucket/core/servlet/ApiAuthenticationFilter.scala b/src/main/scala/gitbucket/core/servlet/ApiAuthenticationFilter.scala index 04cd7fc..82cd80e 100644 --- a/src/main/scala/gitbucket/core/servlet/ApiAuthenticationFilter.scala +++ b/src/main/scala/gitbucket/core/servlet/ApiAuthenticationFilter.scala @@ -8,6 +8,9 @@ import gitbucket.core.service.{AccessTokenService, AccountService, SystemSettingsService} import gitbucket.core.util.{AuthUtil, Keys} import gitbucket.core.model.Profile.profile.blockingApi._ +// Imported names have higher precedence than names, defined in other files. +// If Database is not bound by explicit import, then "Database" refers to the Database introduced by the wildcard import above. +import gitbucket.core.servlet.Database class ApiAuthenticationFilter extends Filter with AccessTokenService with AccountService with SystemSettingsService { diff --git a/src/main/scala/gitbucket/core/servlet/GitAuthenticationFilter.scala b/src/main/scala/gitbucket/core/servlet/GitAuthenticationFilter.scala index 71d8144..e299d4e 100644 --- a/src/main/scala/gitbucket/core/servlet/GitAuthenticationFilter.scala +++ b/src/main/scala/gitbucket/core/servlet/GitAuthenticationFilter.scala @@ -4,12 +4,16 @@ import javax.servlet.http._ import gitbucket.core.model.Account -import gitbucket.core.model.Profile.profile.blockingApi._ import gitbucket.core.plugin.{GitRepositoryFilter, GitRepositoryRouting, PluginRegistry} import gitbucket.core.service.SystemSettingsService.SystemSettings import gitbucket.core.service.{AccessTokenService, AccountService, RepositoryService, SystemSettingsService} import gitbucket.core.util.Implicits._ -import gitbucket.core.util.{AuthUtil, Implicits, Keys} +import gitbucket.core.util.{AuthUtil, Keys} +import gitbucket.core.model.Profile.profile.blockingApi._ +// Imported names have higher precedence than names, defined in other files. +// If Database is not bound by explicit import, then "Database" refers to the Database introduced by the wildcard import above. +import gitbucket.core.servlet.Database + import org.slf4j.LoggerFactory /** diff --git a/src/main/scala/gitbucket/core/servlet/GitRepositoryServlet.scala b/src/main/scala/gitbucket/core/servlet/GitRepositoryServlet.scala index 2c9e43f..6151e09 100644 --- a/src/main/scala/gitbucket/core/servlet/GitRepositoryServlet.scala +++ b/src/main/scala/gitbucket/core/servlet/GitRepositoryServlet.scala @@ -6,7 +6,6 @@ import gitbucket.core.api import gitbucket.core.model.WebHook -import gitbucket.core.model.Profile.profile.blockingApi._ import gitbucket.core.plugin.{GitRepositoryRouting, PluginRegistry} import gitbucket.core.service.IssuesService.IssueSearchCondition import gitbucket.core.service.WebHookService._ @@ -14,6 +13,11 @@ import gitbucket.core.util.SyntaxSugars._ import gitbucket.core.util.Implicits._ import gitbucket.core.util._ +import gitbucket.core.model.Profile.profile.blockingApi._ +// Imported names have higher precedence than names, defined in other files. +// If Database is not bound by explicit import, then "Database" refers to the Database introduced by the wildcard import above. +import gitbucket.core.servlet.Database + import org.eclipse.jgit.api.Git import org.eclipse.jgit.http.server.GitServlet import org.eclipse.jgit.lib._ @@ -108,7 +112,7 @@ GitLfs.Action( href = baseUrl + "/git-lfs/" + owner + "/" + repository + "/" + requestObject.oid, header = - Map("Authorization" -> StringUtil.encodeBlowfish(timeout + " " + requestObject.oid)), + Map("Authorization" -> StringUtil.encodeBlowfish(s"$timeout ${requestObject.oid}")), expires_at = new Date(timeout) ) ) @@ -129,7 +133,7 @@ GitLfs.Action( href = baseUrl + "/git-lfs/" + owner + "/" + repository + "/" + requestObject.oid, header = - Map("Authorization" -> StringUtil.encodeBlowfish(timeout + " " + requestObject.oid)), + Map("Authorization" -> StringUtil.encodeBlowfish(s"$timeout ${requestObject.oid}")), expires_at = new Date(timeout) ) ) @@ -216,7 +220,7 @@ } } -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl: String, sshUrl: Option[String]) extends PostReceiveHook diff --git a/src/main/scala/gitbucket/core/servlet/InitializeListener.scala b/src/main/scala/gitbucket/core/servlet/InitializeListener.scala index 74c043c..1c03e5a 100644 --- a/src/main/scala/gitbucket/core/servlet/InitializeListener.scala +++ b/src/main/scala/gitbucket/core/servlet/InitializeListener.scala @@ -12,6 +12,10 @@ import gitbucket.core.util.SyntaxSugars._ import gitbucket.core.util.JDBCUtil._ import gitbucket.core.model.Profile.profile.blockingApi._ +// Imported names have higher precedence than names, defined in other files. +// If Database is not bound by explicit import, then "Database" refers to the Database introduced by the wildcard import above. +import gitbucket.core.servlet.Database + import io.github.gitbucket.solidbase.Solidbase import io.github.gitbucket.solidbase.manager.JDBCVersionManager import javax.servlet.{ServletContextEvent, ServletContextListener} @@ -21,7 +25,7 @@ import akka.actor.{Actor, ActorSystem, Props} import com.typesafe.akka.extension.quartz.QuartzSchedulerExtension -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ /** * Initialize GitBucket system. diff --git a/src/main/scala/gitbucket/core/util/FileUtil.scala b/src/main/scala/gitbucket/core/util/FileUtil.scala index ab42edd..5da060d 100644 --- a/src/main/scala/gitbucket/core/util/FileUtil.scala +++ b/src/main/scala/gitbucket/core/util/FileUtil.scala @@ -36,7 +36,7 @@ def isText(content: Array[Byte]): Boolean = !content.contains(0) - def generateFileId: String = System.currentTimeMillis + Random.alphanumeric.take(10).mkString + def generateFileId: String = s"${System.currentTimeMillis}${Random.alphanumeric.take(10).mkString}" def getExtension(name: String): String = name.lastIndexOf('.') match { @@ -56,7 +56,7 @@ } def getLfsFilePath(owner: String, repository: String, oid: String): String = - Directory.getLfsDir(owner, repository) + "/" + checkFilename(oid) + s"${Directory.getLfsDir(owner, repository)}/${checkFilename(oid)}" def readableSize(size: Long): String = FileUtils.byteCountToDisplaySize(size) diff --git a/src/main/scala/gitbucket/core/util/GpgUtil.scala b/src/main/scala/gitbucket/core/util/GpgUtil.scala index 5d5edb4..c5f0a73 100644 --- a/src/main/scala/gitbucket/core/util/GpgUtil.scala +++ b/src/main/scala/gitbucket/core/util/GpgUtil.scala @@ -1,7 +1,8 @@ package gitbucket.core.util import java.io.ByteArrayInputStream -import collection.JavaConverters._ +import scala.jdk.CollectionConverters._ + import gitbucket.core.model.Profile._ import gitbucket.core.model.Profile.profile.blockingApi._ import org.bouncycastle.bcpg.ArmoredInputStream diff --git a/src/main/scala/gitbucket/core/util/JDBCUtil.scala b/src/main/scala/gitbucket/core/util/JDBCUtil.scala index 9d34c84..6e7e043 100644 --- a/src/main/scala/gitbucket/core/util/JDBCUtil.scala +++ b/src/main/scala/gitbucket/core/util/JDBCUtil.scala @@ -218,7 +218,7 @@ ordered ++ orphans } - def tsort[A](edges: Traversable[(A, A)]): Iterable[A] = { + def tsort[A](edges: Iterable[(A, A)]): Iterable[A] = { @tailrec def tsort(toPreds: Map[A, Set[A]], done: Iterable[A]): Iterable[A] = { val (noPreds, hasPreds) = toPreds.partition { _._2.isEmpty } @@ -226,7 +226,7 @@ if (hasPreds.isEmpty) done else sys.error(hasPreds.toString) } else { val found = noPreds.map { _._1 } - tsort(hasPreds.mapValues { _ -- found }, done ++ found) + tsort(hasPreds.map { case (k, v) => (k, v -- found) }, done ++ found) } } diff --git a/src/main/scala/gitbucket/core/util/JGitUtil.scala b/src/main/scala/gitbucket/core/util/JGitUtil.scala index e875a2b..c2ad5e2 100644 --- a/src/main/scala/gitbucket/core/util/JGitUtil.scala +++ b/src/main/scala/gitbucket/core/util/JGitUtil.scala @@ -9,7 +9,7 @@ import SyntaxSugars._ import scala.annotation.tailrec -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import org.eclipse.jgit.lib._ import org.eclipse.jgit.revwalk._ import org.eclipse.jgit.revwalk.filter._ @@ -20,7 +20,6 @@ import org.eclipse.jgit.transport.RefSpec import java.util.Date import java.util.concurrent.TimeUnit -import java.util.function.Consumer import org.cache2k.Cache2kBuilder import org.eclipse.jgit.api.errors._ @@ -684,7 +683,7 @@ df.setRepository(git.getRepository) val toCommit = revWalk.parseCommit(git.getRepository.resolve(to)) - from match { + (from match { case None => { toCommit.getParentCount match { case 0 => @@ -700,7 +699,7 @@ val fromCommit = revWalk.parseCommit(git.getRepository.resolve(from)) df.scan(fromCommit.getTree, toCommit.getTree).asScala } - } + }).toSeq } } @@ -908,10 +907,10 @@ } Right("Tag added.") } catch { - case e: GitAPIException => Left("Sorry, some Git operation error occurs.") - case e: ConcurrentRefUpdateException => Left("Sorry some error occurs.") + case e: ConcurrentRefUpdateException => Left("Sorry, some error occurs.") case e: InvalidTagNameException => Left("Sorry, that name is invalid.") case e: NoHeadException => Left("Sorry, this repo doesn't have HEAD reference") + case e: GitAPIException => Left("Sorry, some Git operation error occurs.") } } @@ -1247,7 +1246,7 @@ } finally { walk.dispose() } - } + }.toSeq } def getBlame(git: Git, id: String, path: String): Iterable[BlameInfo] = { @@ -1277,7 +1276,7 @@ } idLine :+= (c.name, i) } - val limeMap = idLine.groupBy(_._1).mapValues(_.map(_._2).toSet) + val limeMap = idLine.groupBy(_._1).view.mapValues(_.map(_._2).toSet) blameMap.values.map { b => b.copy(lines = limeMap(b.id)) } diff --git a/src/main/twirl/gitbucket/core/issues/labels/edit.scala.html b/src/main/twirl/gitbucket/core/issues/labels/edit.scala.html index 62edc4a..2c40a42 100644 --- a/src/main/twirl/gitbucket/core/issues/labels/edit.scala.html +++ b/src/main/twirl/gitbucket/core/issues/labels/edit.scala.html @@ -22,7 +22,7 @@