Bump to sbt 1.4.6, Scala 2.13.3, and Scalatra 2.7.1 (#2609)

* Bump to sbt 1.4.6, Scala 2.13.3, and Scalatra 2.7.1
* Fix warnings in Scala 2.13
This commit is contained in:
Naoki Takezoe
2020-12-27 13:35:57 +09:00
committed by GitHub
parent 66be84289d
commit e7ddfc7ebb
42 changed files with 178 additions and 152 deletions

View File

@@ -4,7 +4,7 @@ import com.typesafe.sbt.pgp.PgpKeys._
val Organization = "io.github.gitbucket" val Organization = "io.github.gitbucket"
val Name = "gitbucket" val Name = "gitbucket"
val GitBucketVersion = "4.35.0" val GitBucketVersion = "4.35.0"
val ScalatraVersion = "2.7.0" val ScalatraVersion = "2.7.1"
val JettyVersion = "9.4.32.v20200930" val JettyVersion = "9.4.32.v20200930"
val JgitVersion = "5.9.0.202009080501-r" val JgitVersion = "5.9.0.202009080501-r"
@@ -17,7 +17,7 @@ sourcesInBase := false
organization := Organization organization := Organization
name := Name name := Name
version := GitBucketVersion version := GitBucketVersion
scalaVersion := "2.13.1" scalaVersion := "2.13.3"
scalafmtOnCompile := true scalafmtOnCompile := true
@@ -75,7 +75,7 @@ libraryDependencies ++= Seq(
) )
// Compiler settings // Compiler settings
scalacOptions := Seq("-deprecation", "-language:postfixOps", "-opt:l:method") scalacOptions := Seq("-deprecation", "-language:postfixOps", "-opt:l:method", "-feature")
javacOptions in compile ++= Seq("-target", "8", "-source", "8") javacOptions in compile ++= Seq("-target", "8", "-source", "8")
javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml" javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml"

View File

@@ -1 +1 @@
sbt.version=1.4.4 sbt.version=1.4.6

View File

@@ -421,7 +421,7 @@ trait AccountManagementControllerBase extends ControllerBase {
"new" "new"
) )
protected def reservedNames(): Constraint = new Constraint() { protected def reservedNames: Constraint = new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] = override def validate(name: String, value: String, messages: Messages): Option[String] =
if (allReservedNames.contains(value.toLowerCase)) { if (allReservedNames.contains(value.toLowerCase)) {
Some(s"${value} is reserved") Some(s"${value} is reserved")

View File

@@ -37,7 +37,7 @@ class FileUploadController
execute( execute(
{ (file, fileId) => { (file, fileId) =>
FileUtils FileUtils
.writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get) .writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get())
session += Keys.Session.Upload(fileId) -> file.name session += Keys.Session.Upload(fileId) -> file.name
}, },
FileUtil.isImage FileUtil.isImage
@@ -49,7 +49,7 @@ class FileUploadController
execute( execute(
{ (file, fileId) => { (file, fileId) =>
FileUtils FileUtils
.writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get) .writeByteArrayToFile(new File(getTemporaryDir(session.getId), FileUtil.checkFilename(fileId)), file.get())
session += Keys.Session.Upload(fileId) -> file.name session += Keys.Session.Upload(fileId) -> file.name
}, },
_ => true _ => true
@@ -65,7 +65,7 @@ class FileUploadController
getAttachedDir(params("owner"), params("repository")), getAttachedDir(params("owner"), params("repository")),
FileUtil.checkFilename(fileId + "." + FileUtil.getExtension(file.getName)) FileUtil.checkFilename(fileId + "." + FileUtil.getExtension(file.getName))
), ),
file.get file.get()
) )
}, },
_ => true _ => true
@@ -144,7 +144,7 @@ class FileUploadController
{ (file, fileId) => { (file, fileId) =>
FileUtils.writeByteArrayToFile( FileUtils.writeByteArrayToFile(
new File(getReleaseFilesDir(owner, repository), FileUtil.checkFilename(tag + "/" + fileId)), new File(getReleaseFilesDir(owner, repository), FileUtil.checkFilename(tag + "/" + fileId)),
file.get file.get()
) )
}, },
_ => true _ => true

View File

@@ -230,9 +230,9 @@ trait ApiPullRequestControllerBase extends ControllerBase {
if (checkConflict(repository.owner, repository.name, pullReq.branch, issueId).isDefined) { if (checkConflict(repository.owner, repository.name, pullReq.branch, issueId).isDefined) {
NoContent NoContent
} else { } else {
NotFound NotFound()
} }
}).getOrElse(NotFound) }).getOrElse(NotFound())
}) })
/* /*

View File

@@ -10,7 +10,7 @@ trait AccessTokenComponent { self: Profile =>
val userName = column[String]("USER_NAME") val userName = column[String]("USER_NAME")
val tokenHash = column[String]("TOKEN_HASH") val tokenHash = column[String]("TOKEN_HASH")
val note = column[String]("NOTE") val note = column[String]("NOTE")
def * = (accessTokenId, userName, tokenHash, note) <> (AccessToken.tupled, AccessToken.unapply) def * = (accessTokenId, userName, tokenHash, note).<>(AccessToken.tupled, AccessToken.unapply)
} }
} }
case class AccessToken( case class AccessToken(

View File

@@ -35,7 +35,7 @@ trait AccountComponent { self: Profile =>
groupAccount, groupAccount,
removed, removed,
description.? description.?
) <> (Account.tupled, Account.unapply) ).<>(Account.tupled, Account.unapply)
} }
} }

View File

@@ -9,7 +9,7 @@ trait AccountExtraMailAddressComponent { self: Profile =>
val userName = column[String]("USER_NAME", O PrimaryKey) val userName = column[String]("USER_NAME", O PrimaryKey)
val extraMailAddress = column[String]("EXTRA_MAIL_ADDRESS", O PrimaryKey) val extraMailAddress = column[String]("EXTRA_MAIL_ADDRESS", O PrimaryKey)
def * = def * =
(userName, extraMailAddress) <> (AccountExtraMailAddress.tupled, AccountExtraMailAddress.unapply) (userName, extraMailAddress).<>(AccountExtraMailAddress.tupled, AccountExtraMailAddress.unapply)
} }
} }

View File

@@ -9,7 +9,7 @@ trait AccountFederationComponent { self: Profile =>
val issuer = column[String]("ISSUER") val issuer = column[String]("ISSUER")
val subject = column[String]("SUBJECT") val subject = column[String]("SUBJECT")
val userName = column[String]("USER_NAME") val userName = column[String]("USER_NAME")
def * = (issuer, subject, userName) <> (AccountFederation.tupled, AccountFederation.unapply) def * = (issuer, subject, userName).<>(AccountFederation.tupled, AccountFederation.unapply)
def byPrimaryKey(issuer: String, subject: String): Rep[Boolean] = def byPrimaryKey(issuer: String, subject: String): Rep[Boolean] =
(this.issuer === issuer.bind) && (this.subject === subject.bind) (this.issuer === issuer.bind) && (this.subject === subject.bind)

View File

@@ -9,7 +9,7 @@ trait AccountPreferenceComponent { self: Profile =>
val userName = column[String]("USER_NAME", O PrimaryKey) val userName = column[String]("USER_NAME", O PrimaryKey)
val highlighterTheme = column[String]("HIGHLIGHTER_THEME") val highlighterTheme = column[String]("HIGHLIGHTER_THEME")
def * = def * =
(userName, highlighterTheme) <> (AccountPreference.tupled, AccountPreference.unapply) (userName, highlighterTheme).<>(AccountPreference.tupled, AccountPreference.unapply)
def byPrimaryKey(userName: String): Rep[Boolean] = this.userName === userName.bind def byPrimaryKey(userName: String): Rep[Boolean] = this.userName === userName.bind
} }

View File

@@ -12,7 +12,7 @@ trait AccountWebHookComponent extends TemplateComponent { self: Profile =>
val url = column[String]("URL") val url = column[String]("URL")
val token = column[Option[String]]("TOKEN") val token = column[Option[String]]("TOKEN")
val ctype = column[WebHookContentType]("CTYPE") val ctype = column[WebHookContentType]("CTYPE")
def * = (userName, url, ctype, token) <> ((AccountWebHook.apply _).tupled, AccountWebHook.unapply) def * = (userName, url, ctype, token).<>((AccountWebHook.apply _).tupled, AccountWebHook.unapply)
def byPrimaryKey(userName: String, url: String) = (this.userName === userName.bind) && (this.url === url.bind) def byPrimaryKey(userName: String, url: String) = (this.userName === userName.bind) && (this.url === url.bind)
} }

View File

@@ -14,7 +14,7 @@ trait AccountWebHookEventComponent extends TemplateComponent {
val url = column[String]("URL") val url = column[String]("URL")
val event = column[WebHook.Event]("EVENT") val event = column[WebHook.Event]("EVENT")
def * = (userName, url, event) <> ((AccountWebHookEvent.apply _).tupled, AccountWebHookEvent.unapply) def * = (userName, url, event).<>((AccountWebHookEvent.apply _).tupled, AccountWebHookEvent.unapply)
def byAccountWebHook(userName: String, url: String) = (this.userName === userName.bind) && (this.url === url.bind) def byAccountWebHook(userName: String, url: String) = (this.userName === userName.bind) && (this.url === url.bind)

View File

@@ -1,19 +1,19 @@
package gitbucket.core.model package gitbucket.core.model
/** // /**
* ActivityComponent has been deprecated, but keep it for binary compatibility. // * ActivityComponent has been deprecated, but keep it for binary compatibility.
*/ // */
@deprecated("ActivityComponent has been deprecated, but keep it for binary compatibility.", "4.34.0") // @deprecated("ActivityComponent has been deprecated, but keep it for binary compatibility.", "4.34.0")
trait ActivityComponent extends TemplateComponent { self: Profile => // trait ActivityComponent extends TemplateComponent { self: Profile =>
import profile.api._ // import profile.api._
import self._ // import self._
lazy val Activities = TableQuery[Activities] // lazy val Activities = TableQuery[Activities]
class Activities(tag: Tag) extends Table[Activity](tag, "ACTIVITY") with BasicTemplate { // class Activities(tag: Tag) extends Table[Activity](tag, "ACTIVITY") with BasicTemplate {
def * = ??? // def * = ???
} // }
} // }
case class Activity( case class Activity(
userName: String, userName: String,

View File

@@ -8,7 +8,7 @@ trait CollaboratorComponent extends TemplateComponent { self: Profile =>
class Collaborators(tag: Tag) extends Table[Collaborator](tag, "COLLABORATOR") with BasicTemplate { class Collaborators(tag: Tag) extends Table[Collaborator](tag, "COLLABORATOR") with BasicTemplate {
val collaboratorName = column[String]("COLLABORATOR_NAME") val collaboratorName = column[String]("COLLABORATOR_NAME")
val role = column[String]("ROLE") val role = column[String]("ROLE")
def * = (userName, repositoryName, collaboratorName, role) <> (Collaborator.tupled, Collaborator.unapply) def * = (userName, repositoryName, collaboratorName, role).<>(Collaborator.tupled, Collaborator.unapply)
def byPrimaryKey(owner: String, repository: String, collaborator: String) = def byPrimaryKey(owner: String, repository: String, collaborator: String) =
byRepository(owner, repository) && (collaboratorName === collaborator.bind) byRepository(owner, repository) && (collaboratorName === collaborator.bind)

View File

@@ -20,7 +20,8 @@ trait IssueCommentComponent extends TemplateComponent { self: Profile =>
val registeredDate = column[java.util.Date]("REGISTERED_DATE") val registeredDate = column[java.util.Date]("REGISTERED_DATE")
val updatedDate = column[java.util.Date]("UPDATED_DATE") val updatedDate = column[java.util.Date]("UPDATED_DATE")
def * = def * =
(userName, repositoryName, issueId, commentId, action, commentedUserName, content, registeredDate, updatedDate) <> (IssueComment.tupled, IssueComment.unapply) (userName, repositoryName, issueId, commentId, action, commentedUserName, content, registeredDate, updatedDate)
.<>(IssueComment.tupled, IssueComment.unapply)
def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind
} }
@@ -74,7 +75,7 @@ trait CommitCommentComponent extends TemplateComponent { self: Profile =>
originalCommitId, originalCommitId,
originalOldLine, originalOldLine,
originalNewLine originalNewLine
) <> (CommitComment.tupled, CommitComment.unapply) ).<>(CommitComment.tupled, CommitComment.unapply)
def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind
} }

View File

@@ -29,7 +29,7 @@ trait CommitStatusComponent extends TemplateComponent { self: Profile =>
creator, creator,
registeredDate, registeredDate,
updatedDate updatedDate
) <> ((CommitStatus.apply _).tupled, CommitStatus.unapply) ).<>((CommitStatus.apply _).tupled, CommitStatus.unapply)
def byPrimaryKey(id: Int) = commitStatusId === id.bind def byPrimaryKey(id: Int) = commitStatusId === id.bind
} }
} }

View File

@@ -11,7 +11,7 @@ trait DeployKeyComponent extends TemplateComponent { self: Profile =>
val publicKey = column[String]("PUBLIC_KEY") val publicKey = column[String]("PUBLIC_KEY")
val allowWrite = column[Boolean]("ALLOW_WRITE") val allowWrite = column[Boolean]("ALLOW_WRITE")
def * = def * =
(userName, repositoryName, deployKeyId, title, publicKey, allowWrite) <> (DeployKey.tupled, DeployKey.unapply) (userName, repositoryName, deployKeyId, title, publicKey, allowWrite).<>(DeployKey.tupled, DeployKey.unapply)
def byPrimaryKey(userName: String, repositoryName: String, deployKeyId: Int) = def byPrimaryKey(userName: String, repositoryName: String, deployKeyId: Int) =
(this.userName === userName.bind) && (this.repositoryName === repositoryName.bind) && (this.deployKeyId === deployKeyId.bind) (this.userName === userName.bind) && (this.repositoryName === repositoryName.bind) && (this.deployKeyId === deployKeyId.bind)

View File

@@ -11,7 +11,7 @@ trait GpgKeyComponent { self: Profile =>
val gpgKeyId = column[Long]("GPG_KEY_ID") val gpgKeyId = column[Long]("GPG_KEY_ID")
val title = column[String]("TITLE") val title = column[String]("TITLE")
val publicKey = column[String]("PUBLIC_KEY") val publicKey = column[String]("PUBLIC_KEY")
def * = (userName, keyId, gpgKeyId, title, publicKey) <> (GpgKey.tupled, GpgKey.unapply) def * = (userName, keyId, gpgKeyId, title, publicKey).<>(GpgKey.tupled, GpgKey.unapply)
def byPrimaryKey(userName: String, keyId: Int) = def byPrimaryKey(userName: String, keyId: Int) =
(this.userName === userName.bind) && (this.keyId === keyId.bind) (this.userName === userName.bind) && (this.keyId === keyId.bind)

View File

@@ -9,7 +9,7 @@ trait GroupMemberComponent { self: Profile =>
val groupName = column[String]("GROUP_NAME", O PrimaryKey) val groupName = column[String]("GROUP_NAME", O PrimaryKey)
val userName = column[String]("USER_NAME", O PrimaryKey) val userName = column[String]("USER_NAME", O PrimaryKey)
val isManager = column[Boolean]("MANAGER") val isManager = column[Boolean]("MANAGER")
def * = (groupName, userName, isManager) <> (GroupMember.tupled, GroupMember.unapply) def * = (groupName, userName, isManager).<>(GroupMember.tupled, GroupMember.unapply)
} }
} }

View File

@@ -49,7 +49,7 @@ trait IssueComponent extends TemplateComponent { self: Profile =>
registeredDate, registeredDate,
updatedDate, updatedDate,
pullRequest pullRequest
) <> (Issue.tupled, Issue.unapply) ).<>(Issue.tupled, Issue.unapply)
def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId) def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId)
} }

View File

@@ -6,7 +6,7 @@ trait IssueLabelComponent extends TemplateComponent { self: Profile =>
lazy val IssueLabels = TableQuery[IssueLabels] lazy val IssueLabels = TableQuery[IssueLabels]
class IssueLabels(tag: Tag) extends Table[IssueLabel](tag, "ISSUE_LABEL") with IssueTemplate with LabelTemplate { class IssueLabels(tag: Tag) extends Table[IssueLabel](tag, "ISSUE_LABEL") with IssueTemplate with LabelTemplate {
def * = (userName, repositoryName, issueId, labelId) <> (IssueLabel.tupled, IssueLabel.unapply) def * = (userName, repositoryName, issueId, labelId).<>(IssueLabel.tupled, IssueLabel.unapply)
def byPrimaryKey(owner: String, repository: String, issueId: Int, labelId: Int) = def byPrimaryKey(owner: String, repository: String, issueId: Int, labelId: Int) =
byIssue(owner, repository, issueId) && (this.labelId === labelId.bind) byIssue(owner, repository, issueId) && (this.labelId === labelId.bind)
} }

View File

@@ -9,7 +9,7 @@ trait LabelComponent extends TemplateComponent { self: Profile =>
override val labelId = column[Int]("LABEL_ID", O AutoInc) override val labelId = column[Int]("LABEL_ID", O AutoInc)
override val labelName = column[String]("LABEL_NAME") override val labelName = column[String]("LABEL_NAME")
val color = column[String]("COLOR") val color = column[String]("COLOR")
def * = (userName, repositoryName, labelId, labelName, color) <> (Label.tupled, Label.unapply) def * = (userName, repositoryName, labelId, labelName, color).<>(Label.tupled, Label.unapply)
def byPrimaryKey(owner: String, repository: String, labelId: Int) = byLabel(owner, repository, labelId) def byPrimaryKey(owner: String, repository: String, labelId: Int) = byLabel(owner, repository, labelId)
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], labelId: Rep[Int]) = def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], labelId: Rep[Int]) =

View File

@@ -13,7 +13,8 @@ trait MilestoneComponent extends TemplateComponent { self: Profile =>
val dueDate = column[Option[java.util.Date]]("DUE_DATE") val dueDate = column[Option[java.util.Date]]("DUE_DATE")
val closedDate = column[Option[java.util.Date]]("CLOSED_DATE") val closedDate = column[Option[java.util.Date]]("CLOSED_DATE")
def * = def * =
(userName, repositoryName, milestoneId, title, description, dueDate, closedDate) <> (Milestone.tupled, Milestone.unapply) (userName, repositoryName, milestoneId, title, description, dueDate, closedDate)
.<>(Milestone.tupled, Milestone.unapply)
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) = byMilestone(owner, repository, milestoneId) def byPrimaryKey(owner: String, repository: String, milestoneId: Int) = byMilestone(owner, repository, milestoneId)
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], milestoneId: Rep[Int]) = def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], milestoneId: Rep[Int]) =

View File

@@ -13,7 +13,8 @@ trait PriorityComponent extends TemplateComponent { self: Profile =>
val isDefault = column[Boolean]("IS_DEFAULT") val isDefault = column[Boolean]("IS_DEFAULT")
val color = column[String]("COLOR") val color = column[String]("COLOR")
def * = def * =
(userName, repositoryName, priorityId, priorityName, description.?, isDefault, ordering, color) <> (Priority.tupled, Priority.unapply) (userName, repositoryName, priorityId, priorityName, description.?, isDefault, ordering, color)
.<>(Priority.tupled, Priority.unapply)
def byPrimaryKey(owner: String, repository: String, priorityId: Int) = byPriority(owner, repository, priorityId) def byPrimaryKey(owner: String, repository: String, priorityId: Int) = byPriority(owner, repository, priorityId)
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], priorityId: Rep[Int]) = def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], priorityId: Rep[Int]) =

View File

@@ -45,7 +45,6 @@ trait CoreProfile
with Profile with Profile
with AccessTokenComponent with AccessTokenComponent
with AccountComponent with AccountComponent
with ActivityComponent // ActivityComponent has been deprecated, but keep it for binary compatibility
with CollaboratorComponent with CollaboratorComponent
with CommitCommentComponent with CommitCommentComponent
with CommitStatusComponent with CommitStatusComponent

View File

@@ -7,7 +7,7 @@ trait ProtectedBranchComponent extends TemplateComponent { self: Profile =>
lazy val ProtectedBranches = TableQuery[ProtectedBranches] lazy val ProtectedBranches = TableQuery[ProtectedBranches]
class ProtectedBranches(tag: Tag) extends Table[ProtectedBranch](tag, "PROTECTED_BRANCH") with BranchTemplate { class ProtectedBranches(tag: Tag) extends Table[ProtectedBranch](tag, "PROTECTED_BRANCH") with BranchTemplate {
val statusCheckAdmin = column[Boolean]("STATUS_CHECK_ADMIN") val statusCheckAdmin = column[Boolean]("STATUS_CHECK_ADMIN")
def * = (userName, repositoryName, branch, statusCheckAdmin) <> (ProtectedBranch.tupled, ProtectedBranch.unapply) def * = (userName, repositoryName, branch, statusCheckAdmin).<>(ProtectedBranch.tupled, ProtectedBranch.unapply)
def byPrimaryKey(userName: String, repositoryName: String, branch: String) = def byPrimaryKey(userName: String, repositoryName: String, branch: String) =
byBranch(userName, repositoryName, branch) byBranch(userName, repositoryName, branch)
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], branch: Rep[String]) = def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], branch: Rep[String]) =
@@ -20,7 +20,7 @@ trait ProtectedBranchComponent extends TemplateComponent { self: Profile =>
with BranchTemplate { with BranchTemplate {
val context = column[String]("CONTEXT") val context = column[String]("CONTEXT")
def * = def * =
(userName, repositoryName, branch, context) <> (ProtectedBranchContext.tupled, ProtectedBranchContext.unapply) (userName, repositoryName, branch, context).<>(ProtectedBranchContext.tupled, ProtectedBranchContext.unapply)
} }
} }

View File

@@ -25,7 +25,7 @@ trait PullRequestComponent extends TemplateComponent { self: Profile =>
commitIdFrom, commitIdFrom,
commitIdTo, commitIdTo,
isDraft isDraft
) <> (PullRequest.tupled, PullRequest.unapply) ).<>(PullRequest.tupled, PullRequest.unapply)
def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) = def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) =
byIssue(userName, repositoryName, issueId) byIssue(userName, repositoryName, issueId)

View File

@@ -21,7 +21,8 @@ trait ReleaseAssetComponent extends TemplateComponent {
val updatedDate = column[Date]("UPDATED_DATE") val updatedDate = column[Date]("UPDATED_DATE")
def * = def * =
(userName, repositoryName, tag, releaseAssetId, fileName, label, size, uploader, registeredDate, updatedDate) <> (ReleaseAsset.tupled, ReleaseAsset.unapply) (userName, repositoryName, tag, releaseAssetId, fileName, label, size, uploader, registeredDate, updatedDate)
.<>(ReleaseAsset.tupled, ReleaseAsset.unapply)
def byPrimaryKey(owner: String, repository: String, tag: String, fileName: String) = def byPrimaryKey(owner: String, repository: String, tag: String, fileName: String) =
byTag(owner, repository, tag) && (this.fileName === fileName.bind) byTag(owner, repository, tag) && (this.fileName === fileName.bind)
def byTag(owner: String, repository: String, tag: String) = def byTag(owner: String, repository: String, tag: String) =

View File

@@ -17,7 +17,8 @@ trait ReleaseTagComponent extends TemplateComponent {
val updatedDate = column[java.util.Date]("UPDATED_DATE") val updatedDate = column[java.util.Date]("UPDATED_DATE")
def * = def * =
(userName, repositoryName, name, tag, author, content, registeredDate, updatedDate) <> (ReleaseTag.tupled, ReleaseTag.unapply) (userName, repositoryName, name, tag, author, content, registeredDate, updatedDate)
.<>(ReleaseTag.tupled, ReleaseTag.unapply)
def byPrimaryKey(owner: String, repository: String, tag: String) = byTag(owner, repository, tag) def byPrimaryKey(owner: String, repository: String, tag: String) = byTag(owner, repository, tag)
def byTag(owner: String, repository: String, tag: String) = def byTag(owner: String, repository: String, tag: String) =
byRepository(owner, repository) && (this.tag === tag.bind) byRepository(owner, repository) && (this.tag === tag.bind)

View File

@@ -42,46 +42,48 @@ trait RepositoryComponent extends TemplateComponent { self: Profile =>
parentRepositoryName.? parentRepositoryName.?
), ),
(issuesOption, externalIssuesUrl.?, wikiOption, externalWikiUrl.?, allowFork, mergeOptions, defaultMergeOption) (issuesOption, externalIssuesUrl.?, wikiOption, externalWikiUrl.?, allowFork, mergeOptions, defaultMergeOption)
).shaped <> ({ ).shaped.<>(
case (repository, options) => {
Repository( case (repository, options) =>
repository._1, Repository(
repository._2, repository._1,
repository._3, repository._2,
repository._4, repository._3,
repository._5, repository._4,
repository._6, repository._5,
repository._7, repository._6,
repository._8, repository._7,
repository._9, repository._8,
repository._10, repository._9,
repository._11, repository._10,
repository._12, repository._11,
RepositoryOptions.tupled.apply(options) repository._12,
) RepositoryOptions.tupled.apply(options)
}, { (r: Repository) => )
Some( }, { (r: Repository) =>
( Some(
( (
r.userName, (
r.repositoryName, r.userName,
r.isPrivate, r.repositoryName,
r.description, r.isPrivate,
r.defaultBranch, r.description,
r.registeredDate, r.defaultBranch,
r.updatedDate, r.registeredDate,
r.lastActivityDate, r.updatedDate,
r.originUserName, r.lastActivityDate,
r.originRepositoryName, r.originUserName,
r.parentUserName, r.originRepositoryName,
r.parentRepositoryName r.parentUserName,
), r.parentRepositoryName
( ),
RepositoryOptions.unapply(r.options).get (
RepositoryOptions.unapply(r.options).get
)
) )
) )
) }
}) )
def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository) def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository)
} }

View File

@@ -14,7 +14,8 @@ trait RepositoryWebHookComponent extends TemplateComponent { self: Profile =>
val token = column[Option[String]]("TOKEN") val token = column[Option[String]]("TOKEN")
val ctype = column[WebHookContentType]("CTYPE") val ctype = column[WebHookContentType]("CTYPE")
def * = def * =
(userName, repositoryName, hookId, url, ctype, token) <> ((RepositoryWebHook.apply _).tupled, RepositoryWebHook.unapply) (userName, repositoryName, hookId, url, ctype, token)
.<>((RepositoryWebHook.apply _).tupled, RepositoryWebHook.unapply)
def byRepositoryUrl(owner: String, repository: String, url: String) = def byRepositoryUrl(owner: String, repository: String, url: String) =
byRepository(owner, repository) && (this.url === url.bind) byRepository(owner, repository) && (this.url === url.bind)

View File

@@ -12,7 +12,7 @@ trait RepositoryWebHookEventComponent extends TemplateComponent { self: Profile
val url = column[String]("URL") val url = column[String]("URL")
val event = column[WebHook.Event]("EVENT") val event = column[WebHook.Event]("EVENT")
def * = def * =
(userName, repositoryName, url, event) <> ((RepositoryWebHookEvent.apply _).tupled, RepositoryWebHookEvent.unapply) (userName, repositoryName, url, event).<>((RepositoryWebHookEvent.apply _).tupled, RepositoryWebHookEvent.unapply)
def byRepositoryWebHook(owner: String, repository: String, url: String) = def byRepositoryWebHook(owner: String, repository: String, url: String) =
byRepository(owner, repository) && (this.url === url.bind) byRepository(owner, repository) && (this.url === url.bind)

View File

@@ -10,7 +10,7 @@ trait SshKeyComponent { self: Profile =>
val sshKeyId = column[Int]("SSH_KEY_ID", O AutoInc) val sshKeyId = column[Int]("SSH_KEY_ID", O AutoInc)
val title = column[String]("TITLE") val title = column[String]("TITLE")
val publicKey = column[String]("PUBLIC_KEY") val publicKey = column[String]("PUBLIC_KEY")
def * = (userName, sshKeyId, title, publicKey) <> (SshKey.tupled, SshKey.unapply) def * = (userName, sshKeyId, title, publicKey).<>(SshKey.tupled, SshKey.unapply)
def byPrimaryKey(userName: String, sshKeyId: Int) = def byPrimaryKey(userName: String, sshKeyId: Int) =
(this.userName === userName.bind) && (this.sshKeyId === sshKeyId.bind) (this.userName === userName.bind) && (this.sshKeyId === sshKeyId.bind)

View File

@@ -105,13 +105,13 @@ trait AccountService {
} }
def getAccountByUserName(userName: String, includeRemoved: Boolean = false)(implicit s: Session): Option[Account] = def getAccountByUserName(userName: String, includeRemoved: Boolean = false)(implicit s: Session): Option[Account] =
Accounts filter (t => (t.userName === userName.bind) && (t.removed === false.bind, !includeRemoved)) firstOption Accounts filter (t => (t.userName === userName.bind).&&(t.removed === false.bind, !includeRemoved)) firstOption
def getAccountByUserNameIgnoreCase(userName: String, includeRemoved: Boolean = false)( def getAccountByUserNameIgnoreCase(userName: String, includeRemoved: Boolean = false)(
implicit s: Session implicit s: Session
): Option[Account] = ): Option[Account] =
Accounts filter ( Accounts filter (
t => (t.userName.toLowerCase === userName.toLowerCase.bind) && (t.removed === false.bind, !includeRemoved) t => (t.userName.toLowerCase === userName.toLowerCase.bind).&&(t.removed === false.bind, !includeRemoved)
) firstOption ) firstOption
def getAccountsByUserNames(userNames: Set[String], knowns: Set[Account], includeRemoved: Boolean = false)( def getAccountsByUserNames(userNames: Set[String], knowns: Set[Account], includeRemoved: Boolean = false)(
@@ -123,7 +123,7 @@ trait AccountService {
map map
} else { } else {
map ++ Accounts map ++ Accounts
.filter(t => (t.userName inSetBind needs) && (t.removed === false.bind, !includeRemoved)) .filter(t => (t.userName inSetBind needs).&&(t.removed === false.bind, !includeRemoved))
.list .list
.map(a => a.userName -> a) .map(a => a.userName -> a)
.toMap .toMap
@@ -140,15 +140,15 @@ trait AccountService {
(x.map { e => (x.map { e =>
e.extraMailAddress.toLowerCase === mailAddress.toLowerCase.bind e.extraMailAddress.toLowerCase === mailAddress.toLowerCase.bind
} }
.getOrElse(false.bind))) && (a.removed === false.bind, !includeRemoved) .getOrElse(false.bind))).&&(a.removed === false.bind, !includeRemoved)
} }
.map { case (a, e) => a } firstOption .map { case (a, e) => a } firstOption
def getAllUsers(includeRemoved: Boolean = true, includeGroups: Boolean = true)(implicit s: Session): List[Account] = { def getAllUsers(includeRemoved: Boolean = true, includeGroups: Boolean = true)(implicit s: Session): List[Account] = {
Accounts filter { t => Accounts filter { t =>
(1.bind === 1.bind) && (1.bind === 1.bind)
(t.groupAccount === false.bind, !includeGroups) && .&&(t.groupAccount === false.bind, !includeGroups)
(t.removed === false.bind, !includeRemoved) .&&(t.removed === false.bind, !includeRemoved)
} sortBy (_.userName) list } sortBy (_.userName) list
} }

View File

@@ -98,6 +98,8 @@ trait ActivityService {
} }
} }
def recordActivity[T <: { def toActivity: Activity }](info: T): Unit = def recordActivity[T <: { def toActivity: Activity }](info: T): Unit = {
import scala.language.reflectiveCalls
writeLog(info.toActivity) writeLog(info.toActivity)
}
} }

View File

@@ -351,49 +351,64 @@ trait IssuesService {
} else { } else {
((t1.userName ++ "/" ++ t1.repositoryName) inSetBind (repos.map { case (owner, repo) => s"$owner/$repo" })) ((t1.userName ++ "/" ++ t1.repositoryName) inSetBind (repos.map { case (owner, repo) => s"$owner/$repo" }))
}) && }) &&
(t1.closed === (condition.state == "closed").bind) && (t1.closed === (condition.state == "closed").bind)
(t1.milestoneId.? isEmpty, condition.milestone == Some(None)) && .&&(t1.milestoneId.? isEmpty, condition.milestone == Some(None))
(t1.priorityId.? isEmpty, condition.priority == Some(None)) && .&&(t1.priorityId.? isEmpty, condition.priority == Some(None))
(t1.assignedUserName.? isEmpty, condition.assigned == Some(None)) && .&&(t1.assignedUserName.? isEmpty, condition.assigned == Some(None))
(t1.openedUserName === condition.author.get.bind, condition.author.isDefined) && .&&(t1.openedUserName === condition.author.get.bind, condition.author.isDefined) &&
(searchOption match { (searchOption match {
case IssueSearchOption.Issues => t1.pullRequest === false case IssueSearchOption.Issues => t1.pullRequest === false
case IssueSearchOption.PullRequests => t1.pullRequest === true case IssueSearchOption.PullRequests => t1.pullRequest === true
case IssueSearchOption.Both => t1.pullRequest === false || t1.pullRequest === true case IssueSearchOption.Both => t1.pullRequest === false || t1.pullRequest === true
}) && })
// Milestone filter // Milestone filter
(Milestones filter { t2 => .&&(
(t2.byPrimaryKey(t1.userName, t1.repositoryName, t1.milestoneId)) && Milestones filter { t2 =>
(t2.title === condition.milestone.get.get.bind) (t2.byPrimaryKey(t1.userName, t1.repositoryName, t1.milestoneId)) &&
} exists, condition.milestone.flatten.isDefined) && (t2.title === condition.milestone.get.get.bind)
// Priority filter } exists,
(Priorities filter { t2 => condition.milestone.flatten.isDefined
(t2.byPrimaryKey(t1.userName, t1.repositoryName, t1.priorityId)) && )
(t2.priorityName === condition.priority.get.get.bind) // Priority filter
} exists, condition.priority.flatten.isDefined) && .&&(
// Assignee filter Priorities filter { t2 =>
(t1.assignedUserName === condition.assigned.get.get.bind, condition.assigned.flatten.isDefined) && (t2.byPrimaryKey(t1.userName, t1.repositoryName, t1.priorityId)) &&
// Label filter (t2.priorityName === condition.priority.get.get.bind)
(IssueLabels filter { t2 => } exists,
(t2.byIssue(t1.userName, t1.repositoryName, t1.issueId)) && condition.priority.flatten.isDefined
(t2.labelId in )
(Labels filter { t3 => // Assignee filter
(t3.byRepository(t1.userName, t1.repositoryName)) && .&&(t1.assignedUserName === condition.assigned.get.get.bind, condition.assigned.flatten.isDefined)
(t3.labelName inSetBind condition.labels) // Label filter
} map (_.labelId))) .&&(
} exists, condition.labels.nonEmpty) && IssueLabels filter { t2 =>
// Visibility filter (t2.byIssue(t1.userName, t1.repositoryName, t1.issueId)) &&
(Repositories filter { t2 => (t2.labelId in
(t2.byRepository(t1.userName, t1.repositoryName)) && (Labels filter { t3 =>
(t2.isPrivate === (condition.visibility == Some("private")).bind) (t3.byRepository(t1.userName, t1.repositoryName)) &&
} exists, condition.visibility.nonEmpty) && (t3.labelName inSetBind condition.labels)
// Organization (group) filter } map (_.labelId)))
(t1.userName inSetBind condition.groups, condition.groups.nonEmpty) && } exists,
// Mentioned filter condition.labels.nonEmpty
((t1.openedUserName === condition.mentioned.get.bind) || t1.assignedUserName === condition.mentioned.get.bind || )
(IssueComments filter { t2 => // Visibility filter
(t2.byIssue(t1.userName, t1.repositoryName, t1.issueId)) && (t2.commentedUserName === condition.mentioned.get.bind) .&&(
} exists), condition.mentioned.isDefined) Repositories filter { t2 =>
(t2.byRepository(t1.userName, t1.repositoryName)) &&
(t2.isPrivate === (condition.visibility == Some("private")).bind)
} exists,
condition.visibility.nonEmpty
)
// Organization (group) filter
.&&(t1.userName inSetBind condition.groups, condition.groups.nonEmpty)
// Mentioned filter
.&&(
(t1.openedUserName === condition.mentioned.get.bind) || t1.assignedUserName === condition.mentioned.get.bind ||
(IssueComments filter { t2 =>
(t2.byIssue(t1.userName, t1.repositoryName, t1.issueId)) && (t2.commentedUserName === condition.mentioned.get.bind)
} exists),
condition.mentioned.isDefined
)
} }
def insertIssue( def insertIssue(
@@ -692,8 +707,8 @@ trait IssuesService {
case (t1, t2) => case (t1, t2) =>
keywords keywords
.map { keyword => .map { keyword =>
(t1.title.toLowerCase like (s"%${likeEncode(keyword)}%", '^')) || (t1.title.toLowerCase.like(s"%${likeEncode(keyword)}%", '^')) ||
(t1.content.toLowerCase like (s"%${likeEncode(keyword)}%", '^')) (t1.content.toLowerCase.like(s"%${likeEncode(keyword)}%", '^'))
} }
.reduceLeft(_ && _) .reduceLeft(_ && _)
} }
@@ -720,7 +735,7 @@ trait IssuesService {
t2.pullRequest === pullRequest.bind && t2.pullRequest === pullRequest.bind &&
keywords keywords
.map { query => .map { query =>
t1.content.toLowerCase like (s"%${likeEncode(query)}%", '^') t1.content.toLowerCase.like(s"%${likeEncode(query)}%", '^')
} }
.reduceLeft(_ && _) .reduceLeft(_ && _)
} }

View File

@@ -561,7 +561,7 @@ object MergeService {
} }
def checkConflict(): Option[String] = { def checkConflict(): Option[String] = {
checkConflictCache.getOrElse(checkConflictForce) checkConflictCache().getOrElse(checkConflictForce())
} }
def checkConflictForce(): Option[String] = { def checkConflictForce(): Option[String] = {

View File

@@ -77,9 +77,9 @@ trait PullRequestService {
} }
.filter { .filter {
case (t1, t2) => case (t1, t2) =>
(t2.closed === closed.bind) && (t2.closed === closed.bind)
(t1.userName === owner.get.bind, owner.isDefined) && .&&(t1.userName === owner.get.bind, owner.isDefined)
(t1.repositoryName === repository.get.bind, repository.isDefined) .&&(t1.repositoryName === repository.get.bind, repository.isDefined)
} }
.groupBy { case (t1, t2) => t2.openedUserName } .groupBy { case (t1, t2) => t2.openedUserName }
.map { case (userName, t) => userName -> t.length } .map { case (userName, t) => userName -> t.length }
@@ -183,10 +183,10 @@ trait PullRequestService {
} }
.filter { .filter {
case (t1, t2) => case (t1, t2) =>
(t1.requestUserName === userName.bind) && (t1.requestUserName === userName.bind)
(t1.requestRepositoryName === repositoryName.bind) && .&&(t1.requestRepositoryName === repositoryName.bind)
(t1.requestBranch === branch.bind) && .&&(t1.requestBranch === branch.bind)
(t2.closed === closed.get.bind, closed.isDefined) .&&(t2.closed === closed.get.bind, closed.isDefined)
} }
.map { case (t1, t2) => t1 } .map { case (t1, t2) => t1 }
.list .list
@@ -201,10 +201,10 @@ trait PullRequestService {
} }
.filter { .filter {
case (t1, t2) => case (t1, t2) =>
(t1.requestUserName === userName.bind) && (t1.requestUserName === userName.bind)
(t1.requestRepositoryName === repositoryName.bind) && .&&(t1.requestRepositoryName === repositoryName.bind)
(t1.branch === branch.bind) && .&&(t1.branch === branch.bind)
(t2.closed === closed.get.bind, closed.isDefined) .&&(t2.closed === closed.get.bind, closed.isDefined)
} }
.map { case (t1, t2) => t1 } .map { case (t1, t2) => t1 }
.list .list

View File

@@ -283,7 +283,7 @@ trait WebHookService {
val json = JsonFormat(payload) val json = JsonFormat(payload)
webHooks.map { webHook => webHooks.map { webHook =>
val reqPromise = Promise[HttpRequest] val reqPromise = Promise[HttpRequest]()
val f = Future { val f = Future {
val itcp = new org.apache.http.HttpRequestInterceptor { val itcp = new org.apache.http.HttpRequestInterceptor {
def process(res: HttpRequest, ctx: HttpContext): Unit = { def process(res: HttpRequest, ctx: HttpContext): Unit = {

View File

@@ -202,7 +202,7 @@ object JDBCUtil {
} }
private def allTablesOrderByDependencies(meta: DatabaseMetaData): Seq[String] = { private def allTablesOrderByDependencies(meta: DatabaseMetaData): Seq[String] = {
val tables = allTableNames.map { tableName => val tables = allTableNames().map { tableName =>
TableDependency(tableName, childTables(meta, tableName)) TableDependency(tableName, childTables(meta, tableName))
} }

View File

@@ -125,6 +125,8 @@ object LDAPUtil {
} }
private def getSslProvider(): Provider = { private def getSslProvider(): Provider = {
import scala.language.existentials
val cachedInstance = provider.get() val cachedInstance = provider.get()
if (cachedInstance == null) { if (cachedInstance == null) {
val cls = try { val cls = try {

View File

@@ -71,7 +71,7 @@ class AccessTokenServiceSpec extends AnyFunSuite with ServiceSpecBase {
withTestDB { implicit session => withTestDB { implicit session =>
val tokenIt = List("token1", "token1", "token1", "token2").iterator val tokenIt = List("token1", "token1", "token1", "token2").iterator
val service = new AccessTokenService { val service = new AccessTokenService {
override def makeAccessTokenString: String = tokenIt.next override def makeAccessTokenString: String = tokenIt.next()
} }
assert(service.generateAccessToken("root", "note1")._2 == "token1") assert(service.generateAccessToken("root", "note1")._2 == "token1")