diff --git a/build.sbt b/build.sbt index ff2085c..da78163 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ val Organization = "io.github.gitbucket" val Name = "gitbucket" val GitBucketVersion = "4.35.0" -val ScalatraVersion = "2.7.0" +val ScalatraVersion = "2.7.1" val JettyVersion = "9.4.32.v20200930" val JgitVersion = "5.9.0.202009080501-r" @@ -17,7 +17,7 @@ organization := Organization name := Name version := GitBucketVersion -scalaVersion := "2.13.1" +scalaVersion := "2.13.3" scalafmtOnCompile := true @@ -75,7 +75,7 @@ ) // 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") javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml" diff --git a/project/build.properties b/project/build.properties index 7de0a93..d91c272 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.4 +sbt.version=1.4.6 diff --git a/src/main/scala/gitbucket/core/controller/ControllerBase.scala b/src/main/scala/gitbucket/core/controller/ControllerBase.scala index a4bc72c..e5d3d0c 100644 --- a/src/main/scala/gitbucket/core/controller/ControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/ControllerBase.scala @@ -421,7 +421,7 @@ "new" ) - protected def reservedNames(): Constraint = new Constraint() { + protected def reservedNames: Constraint = new Constraint() { override def validate(name: String, value: String, messages: Messages): Option[String] = if (allReservedNames.contains(value.toLowerCase)) { Some(s"${value} is reserved") diff --git a/src/main/scala/gitbucket/core/controller/FileUploadController.scala b/src/main/scala/gitbucket/core/controller/FileUploadController.scala index 61516bb..69cc725 100644 --- a/src/main/scala/gitbucket/core/controller/FileUploadController.scala +++ b/src/main/scala/gitbucket/core/controller/FileUploadController.scala @@ -37,7 +37,7 @@ execute( { (file, fileId) => 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 }, FileUtil.isImage @@ -49,7 +49,7 @@ execute( { (file, fileId) => 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 }, _ => true @@ -65,7 +65,7 @@ getAttachedDir(params("owner"), params("repository")), FileUtil.checkFilename(fileId + "." + FileUtil.getExtension(file.getName)) ), - file.get + file.get() ) }, _ => true @@ -144,7 +144,7 @@ { (file, fileId) => FileUtils.writeByteArrayToFile( new File(getReleaseFilesDir(owner, repository), FileUtil.checkFilename(tag + "/" + fileId)), - file.get + file.get() ) }, _ => true diff --git a/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala b/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala index 1774f82..bc6c6b1 100644 --- a/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/api/ApiPullRequestControllerBase.scala @@ -230,9 +230,9 @@ if (checkConflict(repository.owner, repository.name, pullReq.branch, issueId).isDefined) { NoContent } else { - NotFound + NotFound() } - }).getOrElse(NotFound) + }).getOrElse(NotFound()) }) /* diff --git a/src/main/scala/gitbucket/core/model/AccessToken.scala b/src/main/scala/gitbucket/core/model/AccessToken.scala index c952c03..694fbff 100644 --- a/src/main/scala/gitbucket/core/model/AccessToken.scala +++ b/src/main/scala/gitbucket/core/model/AccessToken.scala @@ -10,7 +10,7 @@ val userName = column[String]("USER_NAME") val tokenHash = column[String]("TOKEN_HASH") 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( diff --git a/src/main/scala/gitbucket/core/model/Account.scala b/src/main/scala/gitbucket/core/model/Account.scala index 2379328..f4c0ab5 100644 --- a/src/main/scala/gitbucket/core/model/Account.scala +++ b/src/main/scala/gitbucket/core/model/Account.scala @@ -35,7 +35,7 @@ groupAccount, removed, description.? - ) <> (Account.tupled, Account.unapply) + ).<>(Account.tupled, Account.unapply) } } diff --git a/src/main/scala/gitbucket/core/model/AccountExtraMailAddress.scala b/src/main/scala/gitbucket/core/model/AccountExtraMailAddress.scala index 88cc2fe..cb66f60 100644 --- a/src/main/scala/gitbucket/core/model/AccountExtraMailAddress.scala +++ b/src/main/scala/gitbucket/core/model/AccountExtraMailAddress.scala @@ -9,7 +9,7 @@ val userName = column[String]("USER_NAME", O PrimaryKey) val extraMailAddress = column[String]("EXTRA_MAIL_ADDRESS", O PrimaryKey) def * = - (userName, extraMailAddress) <> (AccountExtraMailAddress.tupled, AccountExtraMailAddress.unapply) + (userName, extraMailAddress).<>(AccountExtraMailAddress.tupled, AccountExtraMailAddress.unapply) } } diff --git a/src/main/scala/gitbucket/core/model/AccountFederation.scala b/src/main/scala/gitbucket/core/model/AccountFederation.scala index 35a6b4b..ee11f4f 100644 --- a/src/main/scala/gitbucket/core/model/AccountFederation.scala +++ b/src/main/scala/gitbucket/core/model/AccountFederation.scala @@ -9,7 +9,7 @@ val issuer = column[String]("ISSUER") val subject = column[String]("SUBJECT") 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] = (this.issuer === issuer.bind) && (this.subject === subject.bind) diff --git a/src/main/scala/gitbucket/core/model/AccountPreference.scala b/src/main/scala/gitbucket/core/model/AccountPreference.scala index 6704fcf..32f0210 100644 --- a/src/main/scala/gitbucket/core/model/AccountPreference.scala +++ b/src/main/scala/gitbucket/core/model/AccountPreference.scala @@ -9,7 +9,7 @@ val userName = column[String]("USER_NAME", O PrimaryKey) val highlighterTheme = column[String]("HIGHLIGHTER_THEME") def * = - (userName, highlighterTheme) <> (AccountPreference.tupled, AccountPreference.unapply) + (userName, highlighterTheme).<>(AccountPreference.tupled, AccountPreference.unapply) def byPrimaryKey(userName: String): Rep[Boolean] = this.userName === userName.bind } diff --git a/src/main/scala/gitbucket/core/model/AccountWebHook.scala b/src/main/scala/gitbucket/core/model/AccountWebHook.scala index 79f0c4b..7aa8edf 100644 --- a/src/main/scala/gitbucket/core/model/AccountWebHook.scala +++ b/src/main/scala/gitbucket/core/model/AccountWebHook.scala @@ -12,7 +12,7 @@ val url = column[String]("URL") val token = column[Option[String]]("TOKEN") 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) } diff --git a/src/main/scala/gitbucket/core/model/AccountWebHookEvent.scala b/src/main/scala/gitbucket/core/model/AccountWebHookEvent.scala index f169a36..d30eaa8 100644 --- a/src/main/scala/gitbucket/core/model/AccountWebHookEvent.scala +++ b/src/main/scala/gitbucket/core/model/AccountWebHookEvent.scala @@ -14,7 +14,7 @@ val url = column[String]("URL") 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) diff --git a/src/main/scala/gitbucket/core/model/Activity.scala b/src/main/scala/gitbucket/core/model/Activity.scala index a7ca6fb..0466525 100644 --- a/src/main/scala/gitbucket/core/model/Activity.scala +++ b/src/main/scala/gitbucket/core/model/Activity.scala @@ -1,19 +1,19 @@ package gitbucket.core.model -/** - * ActivityComponent has been deprecated, but keep it for binary compatibility. - */ -@deprecated("ActivityComponent has been deprecated, but keep it for binary compatibility.", "4.34.0") -trait ActivityComponent extends TemplateComponent { self: Profile => - import profile.api._ - import self._ +// /** +// * ActivityComponent has been deprecated, but keep it for binary compatibility. +// */ +// @deprecated("ActivityComponent has been deprecated, but keep it for binary compatibility.", "4.34.0") +// trait ActivityComponent extends TemplateComponent { self: Profile => +// import profile.api._ +// import self._ - lazy val Activities = TableQuery[Activities] +// lazy val Activities = TableQuery[Activities] - class Activities(tag: Tag) extends Table[Activity](tag, "ACTIVITY") with BasicTemplate { - def * = ??? - } -} +// class Activities(tag: Tag) extends Table[Activity](tag, "ACTIVITY") with BasicTemplate { +// def * = ??? +// } +// } case class Activity( userName: String, diff --git a/src/main/scala/gitbucket/core/model/Collaborator.scala b/src/main/scala/gitbucket/core/model/Collaborator.scala index 3cee46b..bb2b53b 100644 --- a/src/main/scala/gitbucket/core/model/Collaborator.scala +++ b/src/main/scala/gitbucket/core/model/Collaborator.scala @@ -8,7 +8,7 @@ class Collaborators(tag: Tag) extends Table[Collaborator](tag, "COLLABORATOR") with BasicTemplate { val collaboratorName = column[String]("COLLABORATOR_NAME") 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) = byRepository(owner, repository) && (collaboratorName === collaborator.bind) diff --git a/src/main/scala/gitbucket/core/model/Comment.scala b/src/main/scala/gitbucket/core/model/Comment.scala index 9314b2e..8997b85 100644 --- a/src/main/scala/gitbucket/core/model/Comment.scala +++ b/src/main/scala/gitbucket/core/model/Comment.scala @@ -20,7 +20,8 @@ val registeredDate = column[java.util.Date]("REGISTERED_DATE") val updatedDate = column[java.util.Date]("UPDATED_DATE") 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 } @@ -74,7 +75,7 @@ originalCommitId, originalOldLine, originalNewLine - ) <> (CommitComment.tupled, CommitComment.unapply) + ).<>(CommitComment.tupled, CommitComment.unapply) def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind } diff --git a/src/main/scala/gitbucket/core/model/CommitStatus.scala b/src/main/scala/gitbucket/core/model/CommitStatus.scala index c89f4be..1e605bc 100644 --- a/src/main/scala/gitbucket/core/model/CommitStatus.scala +++ b/src/main/scala/gitbucket/core/model/CommitStatus.scala @@ -29,7 +29,7 @@ creator, registeredDate, updatedDate - ) <> ((CommitStatus.apply _).tupled, CommitStatus.unapply) + ).<>((CommitStatus.apply _).tupled, CommitStatus.unapply) def byPrimaryKey(id: Int) = commitStatusId === id.bind } } diff --git a/src/main/scala/gitbucket/core/model/DeployKey.scala b/src/main/scala/gitbucket/core/model/DeployKey.scala index dd13785..b52e525 100644 --- a/src/main/scala/gitbucket/core/model/DeployKey.scala +++ b/src/main/scala/gitbucket/core/model/DeployKey.scala @@ -11,7 +11,7 @@ val publicKey = column[String]("PUBLIC_KEY") val allowWrite = column[Boolean]("ALLOW_WRITE") 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) = (this.userName === userName.bind) && (this.repositoryName === repositoryName.bind) && (this.deployKeyId === deployKeyId.bind) diff --git a/src/main/scala/gitbucket/core/model/GpgKey.scala b/src/main/scala/gitbucket/core/model/GpgKey.scala index d4859f0..7758b9c 100644 --- a/src/main/scala/gitbucket/core/model/GpgKey.scala +++ b/src/main/scala/gitbucket/core/model/GpgKey.scala @@ -11,7 +11,7 @@ val gpgKeyId = column[Long]("GPG_KEY_ID") val title = column[String]("TITLE") 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) = (this.userName === userName.bind) && (this.keyId === keyId.bind) diff --git a/src/main/scala/gitbucket/core/model/GroupMembers.scala b/src/main/scala/gitbucket/core/model/GroupMembers.scala index 6c4c5b5..de14834 100644 --- a/src/main/scala/gitbucket/core/model/GroupMembers.scala +++ b/src/main/scala/gitbucket/core/model/GroupMembers.scala @@ -9,7 +9,7 @@ val groupName = column[String]("GROUP_NAME", O PrimaryKey) val userName = column[String]("USER_NAME", O PrimaryKey) val isManager = column[Boolean]("MANAGER") - def * = (groupName, userName, isManager) <> (GroupMember.tupled, GroupMember.unapply) + def * = (groupName, userName, isManager).<>(GroupMember.tupled, GroupMember.unapply) } } diff --git a/src/main/scala/gitbucket/core/model/Issue.scala b/src/main/scala/gitbucket/core/model/Issue.scala index 635e94f..ccf2c81 100644 --- a/src/main/scala/gitbucket/core/model/Issue.scala +++ b/src/main/scala/gitbucket/core/model/Issue.scala @@ -49,7 +49,7 @@ registeredDate, updatedDate, pullRequest - ) <> (Issue.tupled, Issue.unapply) + ).<>(Issue.tupled, Issue.unapply) def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId) } diff --git a/src/main/scala/gitbucket/core/model/IssueLabels.scala b/src/main/scala/gitbucket/core/model/IssueLabels.scala index 57d3a65..6ea4691 100644 --- a/src/main/scala/gitbucket/core/model/IssueLabels.scala +++ b/src/main/scala/gitbucket/core/model/IssueLabels.scala @@ -6,7 +6,7 @@ lazy val IssueLabels = TableQuery[IssueLabels] 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) = byIssue(owner, repository, issueId) && (this.labelId === labelId.bind) } diff --git a/src/main/scala/gitbucket/core/model/Labels.scala b/src/main/scala/gitbucket/core/model/Labels.scala index 70f4ae4..b21c0be 100644 --- a/src/main/scala/gitbucket/core/model/Labels.scala +++ b/src/main/scala/gitbucket/core/model/Labels.scala @@ -9,7 +9,7 @@ override val labelId = column[Int]("LABEL_ID", O AutoInc) override val labelName = column[String]("LABEL_NAME") 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(userName: Rep[String], repositoryName: Rep[String], labelId: Rep[Int]) = diff --git a/src/main/scala/gitbucket/core/model/Milestone.scala b/src/main/scala/gitbucket/core/model/Milestone.scala index 0074012..6578791 100644 --- a/src/main/scala/gitbucket/core/model/Milestone.scala +++ b/src/main/scala/gitbucket/core/model/Milestone.scala @@ -13,7 +13,8 @@ val dueDate = column[Option[java.util.Date]]("DUE_DATE") val closedDate = column[Option[java.util.Date]]("CLOSED_DATE") 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(userName: Rep[String], repositoryName: Rep[String], milestoneId: Rep[Int]) = diff --git a/src/main/scala/gitbucket/core/model/Priorities.scala b/src/main/scala/gitbucket/core/model/Priorities.scala index 548b32f..5fbd552 100644 --- a/src/main/scala/gitbucket/core/model/Priorities.scala +++ b/src/main/scala/gitbucket/core/model/Priorities.scala @@ -13,7 +13,8 @@ val isDefault = column[Boolean]("IS_DEFAULT") val color = column[String]("COLOR") 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(userName: Rep[String], repositoryName: Rep[String], priorityId: Rep[Int]) = diff --git a/src/main/scala/gitbucket/core/model/Profile.scala b/src/main/scala/gitbucket/core/model/Profile.scala index 0226e03..2d746fa 100644 --- a/src/main/scala/gitbucket/core/model/Profile.scala +++ b/src/main/scala/gitbucket/core/model/Profile.scala @@ -45,7 +45,6 @@ with Profile with AccessTokenComponent with AccountComponent - with ActivityComponent // ActivityComponent has been deprecated, but keep it for binary compatibility with CollaboratorComponent with CommitCommentComponent with CommitStatusComponent diff --git a/src/main/scala/gitbucket/core/model/ProtectedBranch.scala b/src/main/scala/gitbucket/core/model/ProtectedBranch.scala index b101081..91a0358 100644 --- a/src/main/scala/gitbucket/core/model/ProtectedBranch.scala +++ b/src/main/scala/gitbucket/core/model/ProtectedBranch.scala @@ -7,7 +7,7 @@ lazy val ProtectedBranches = TableQuery[ProtectedBranches] class ProtectedBranches(tag: Tag) extends Table[ProtectedBranch](tag, "PROTECTED_BRANCH") with BranchTemplate { val statusCheckAdmin = column[Boolean]("STATUS_CHECK_ADMIN") - def * = (userName, repositoryName, branch, statusCheckAdmin) <> (ProtectedBranch.tupled, ProtectedBranch.unapply) + def * = (userName, repositoryName, branch, statusCheckAdmin).<>(ProtectedBranch.tupled, ProtectedBranch.unapply) def byPrimaryKey(userName: String, repositoryName: String, branch: String) = byBranch(userName, repositoryName, branch) def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], branch: Rep[String]) = @@ -20,7 +20,7 @@ with BranchTemplate { val context = column[String]("CONTEXT") def * = - (userName, repositoryName, branch, context) <> (ProtectedBranchContext.tupled, ProtectedBranchContext.unapply) + (userName, repositoryName, branch, context).<>(ProtectedBranchContext.tupled, ProtectedBranchContext.unapply) } } diff --git a/src/main/scala/gitbucket/core/model/PullRequest.scala b/src/main/scala/gitbucket/core/model/PullRequest.scala index 1e3adc0..7cf292d 100644 --- a/src/main/scala/gitbucket/core/model/PullRequest.scala +++ b/src/main/scala/gitbucket/core/model/PullRequest.scala @@ -25,7 +25,7 @@ commitIdFrom, commitIdTo, isDraft - ) <> (PullRequest.tupled, PullRequest.unapply) + ).<>(PullRequest.tupled, PullRequest.unapply) def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) = byIssue(userName, repositoryName, issueId) diff --git a/src/main/scala/gitbucket/core/model/ReleaseAsset.scala b/src/main/scala/gitbucket/core/model/ReleaseAsset.scala index 3bab8ce..28ca2ca 100644 --- a/src/main/scala/gitbucket/core/model/ReleaseAsset.scala +++ b/src/main/scala/gitbucket/core/model/ReleaseAsset.scala @@ -21,7 +21,8 @@ val updatedDate = column[Date]("UPDATED_DATE") 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) = byTag(owner, repository, tag) && (this.fileName === fileName.bind) def byTag(owner: String, repository: String, tag: String) = diff --git a/src/main/scala/gitbucket/core/model/ReleaseTag.scala b/src/main/scala/gitbucket/core/model/ReleaseTag.scala index dad2e8b..7101da1 100644 --- a/src/main/scala/gitbucket/core/model/ReleaseTag.scala +++ b/src/main/scala/gitbucket/core/model/ReleaseTag.scala @@ -17,7 +17,8 @@ val updatedDate = column[java.util.Date]("UPDATED_DATE") 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 byTag(owner: String, repository: String, tag: String) = byRepository(owner, repository) && (this.tag === tag.bind) diff --git a/src/main/scala/gitbucket/core/model/Repository.scala b/src/main/scala/gitbucket/core/model/Repository.scala index a62047d..b536c82 100644 --- a/src/main/scala/gitbucket/core/model/Repository.scala +++ b/src/main/scala/gitbucket/core/model/Repository.scala @@ -42,46 +42,48 @@ parentRepositoryName.? ), (issuesOption, externalIssuesUrl.?, wikiOption, externalWikiUrl.?, allowFork, mergeOptions, defaultMergeOption) - ).shaped <> ({ - case (repository, options) => - Repository( - repository._1, - repository._2, - repository._3, - repository._4, - repository._5, - repository._6, - repository._7, - repository._8, - repository._9, - repository._10, - repository._11, - repository._12, - RepositoryOptions.tupled.apply(options) - ) - }, { (r: Repository) => - Some( - ( + ).shaped.<>( + { + case (repository, options) => + Repository( + repository._1, + repository._2, + repository._3, + repository._4, + repository._5, + repository._6, + repository._7, + repository._8, + repository._9, + repository._10, + repository._11, + repository._12, + RepositoryOptions.tupled.apply(options) + ) + }, { (r: Repository) => + Some( ( - r.userName, - r.repositoryName, - r.isPrivate, - r.description, - r.defaultBranch, - r.registeredDate, - r.updatedDate, - r.lastActivityDate, - r.originUserName, - r.originRepositoryName, - r.parentUserName, - r.parentRepositoryName - ), - ( - RepositoryOptions.unapply(r.options).get + ( + r.userName, + r.repositoryName, + r.isPrivate, + r.description, + r.defaultBranch, + r.registeredDate, + r.updatedDate, + r.lastActivityDate, + r.originUserName, + r.originRepositoryName, + r.parentUserName, + r.parentRepositoryName + ), + ( + RepositoryOptions.unapply(r.options).get + ) ) ) - ) - }) + } + ) def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository) } diff --git a/src/main/scala/gitbucket/core/model/RepositoryWebHook.scala b/src/main/scala/gitbucket/core/model/RepositoryWebHook.scala index cbe38f8..5301c18 100644 --- a/src/main/scala/gitbucket/core/model/RepositoryWebHook.scala +++ b/src/main/scala/gitbucket/core/model/RepositoryWebHook.scala @@ -14,7 +14,8 @@ val token = column[Option[String]]("TOKEN") val ctype = column[WebHookContentType]("CTYPE") 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) = byRepository(owner, repository) && (this.url === url.bind) diff --git a/src/main/scala/gitbucket/core/model/RepositoryWebHookEvent.scala b/src/main/scala/gitbucket/core/model/RepositoryWebHookEvent.scala index 79ca9a9..4165c67 100644 --- a/src/main/scala/gitbucket/core/model/RepositoryWebHookEvent.scala +++ b/src/main/scala/gitbucket/core/model/RepositoryWebHookEvent.scala @@ -12,7 +12,7 @@ val url = column[String]("URL") val event = column[WebHook.Event]("EVENT") 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) = byRepository(owner, repository) && (this.url === url.bind) diff --git a/src/main/scala/gitbucket/core/model/SshKey.scala b/src/main/scala/gitbucket/core/model/SshKey.scala index d6379ed..2abd149 100644 --- a/src/main/scala/gitbucket/core/model/SshKey.scala +++ b/src/main/scala/gitbucket/core/model/SshKey.scala @@ -10,7 +10,7 @@ val sshKeyId = column[Int]("SSH_KEY_ID", O AutoInc) val title = column[String]("TITLE") 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) = (this.userName === userName.bind) && (this.sshKeyId === sshKeyId.bind) diff --git a/src/main/scala/gitbucket/core/service/AccountService.scala b/src/main/scala/gitbucket/core/service/AccountService.scala index 3c256c8..b445468 100644 --- a/src/main/scala/gitbucket/core/service/AccountService.scala +++ b/src/main/scala/gitbucket/core/service/AccountService.scala @@ -105,13 +105,13 @@ } 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)( implicit s: Session ): Option[Account] = 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 def getAccountsByUserNames(userNames: Set[String], knowns: Set[Account], includeRemoved: Boolean = false)( @@ -123,7 +123,7 @@ map } else { 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 .map(a => a.userName -> a) .toMap @@ -140,15 +140,15 @@ (x.map { e => 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 def getAllUsers(includeRemoved: Boolean = true, includeGroups: Boolean = true)(implicit s: Session): List[Account] = { Accounts filter { t => - (1.bind === 1.bind) && - (t.groupAccount === false.bind, !includeGroups) && - (t.removed === false.bind, !includeRemoved) + (1.bind === 1.bind) + .&&(t.groupAccount === false.bind, !includeGroups) + .&&(t.removed === false.bind, !includeRemoved) } sortBy (_.userName) list } diff --git a/src/main/scala/gitbucket/core/service/ActivityService.scala b/src/main/scala/gitbucket/core/service/ActivityService.scala index 4c830ba..4246440 100644 --- a/src/main/scala/gitbucket/core/service/ActivityService.scala +++ b/src/main/scala/gitbucket/core/service/ActivityService.scala @@ -98,6 +98,8 @@ } } - 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) + } } diff --git a/src/main/scala/gitbucket/core/service/IssuesService.scala b/src/main/scala/gitbucket/core/service/IssuesService.scala index 98e8f51..6e9463b 100644 --- a/src/main/scala/gitbucket/core/service/IssuesService.scala +++ b/src/main/scala/gitbucket/core/service/IssuesService.scala @@ -351,49 +351,64 @@ } 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)) && - (t1.assignedUserName.? isEmpty, condition.assigned == Some(None)) && - (t1.openedUserName === condition.author.get.bind, condition.author.isDefined) && + (t1.closed === (condition.state == "closed").bind) + .&&(t1.milestoneId.? isEmpty, condition.milestone == Some(None)) + .&&(t1.priorityId.? isEmpty, condition.priority == Some(None)) + .&&(t1.assignedUserName.? isEmpty, condition.assigned == Some(None)) + .&&(t1.openedUserName === condition.author.get.bind, condition.author.isDefined) && (searchOption match { case IssueSearchOption.Issues => t1.pullRequest === false case IssueSearchOption.PullRequests => t1.pullRequest === true case IssueSearchOption.Both => t1.pullRequest === false || t1.pullRequest === true - }) && + }) // Milestone filter - (Milestones filter { t2 => - (t2.byPrimaryKey(t1.userName, t1.repositoryName, t1.milestoneId)) && - (t2.title === condition.milestone.get.get.bind) - } exists, condition.milestone.flatten.isDefined) && - // Priority filter - (Priorities filter { t2 => - (t2.byPrimaryKey(t1.userName, t1.repositoryName, t1.priorityId)) && - (t2.priorityName === condition.priority.get.get.bind) - } exists, condition.priority.flatten.isDefined) && - // Assignee filter - (t1.assignedUserName === condition.assigned.get.get.bind, condition.assigned.flatten.isDefined) && - // Label filter - (IssueLabels filter { t2 => - (t2.byIssue(t1.userName, t1.repositoryName, t1.issueId)) && - (t2.labelId in - (Labels filter { t3 => - (t3.byRepository(t1.userName, t1.repositoryName)) && - (t3.labelName inSetBind condition.labels) - } map (_.labelId))) - } exists, condition.labels.nonEmpty) && - // Visibility filter - (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) + .&&( + Milestones filter { t2 => + (t2.byPrimaryKey(t1.userName, t1.repositoryName, t1.milestoneId)) && + (t2.title === condition.milestone.get.get.bind) + } exists, + condition.milestone.flatten.isDefined + ) + // Priority filter + .&&( + Priorities filter { t2 => + (t2.byPrimaryKey(t1.userName, t1.repositoryName, t1.priorityId)) && + (t2.priorityName === condition.priority.get.get.bind) + } exists, + condition.priority.flatten.isDefined + ) + // Assignee filter + .&&(t1.assignedUserName === condition.assigned.get.get.bind, condition.assigned.flatten.isDefined) + // Label filter + .&&( + IssueLabels filter { t2 => + (t2.byIssue(t1.userName, t1.repositoryName, t1.issueId)) && + (t2.labelId in + (Labels filter { t3 => + (t3.byRepository(t1.userName, t1.repositoryName)) && + (t3.labelName inSetBind condition.labels) + } map (_.labelId))) + } exists, + condition.labels.nonEmpty + ) + // Visibility filter + .&&( + 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( @@ -692,8 +707,8 @@ case (t1, t2) => keywords .map { keyword => - (t1.title.toLowerCase like (s"%${likeEncode(keyword)}%", '^')) || - (t1.content.toLowerCase like (s"%${likeEncode(keyword)}%", '^')) + (t1.title.toLowerCase.like(s"%${likeEncode(keyword)}%", '^')) || + (t1.content.toLowerCase.like(s"%${likeEncode(keyword)}%", '^')) } .reduceLeft(_ && _) } @@ -720,7 +735,7 @@ t2.pullRequest === pullRequest.bind && keywords .map { query => - t1.content.toLowerCase like (s"%${likeEncode(query)}%", '^') + t1.content.toLowerCase.like(s"%${likeEncode(query)}%", '^') } .reduceLeft(_ && _) } diff --git a/src/main/scala/gitbucket/core/service/MergeService.scala b/src/main/scala/gitbucket/core/service/MergeService.scala index 55f1f64..3e0d24d 100644 --- a/src/main/scala/gitbucket/core/service/MergeService.scala +++ b/src/main/scala/gitbucket/core/service/MergeService.scala @@ -561,7 +561,7 @@ } def checkConflict(): Option[String] = { - checkConflictCache.getOrElse(checkConflictForce) + checkConflictCache().getOrElse(checkConflictForce()) } def checkConflictForce(): Option[String] = { diff --git a/src/main/scala/gitbucket/core/service/PullRequestService.scala b/src/main/scala/gitbucket/core/service/PullRequestService.scala index 5344a17..fd68a8a 100644 --- a/src/main/scala/gitbucket/core/service/PullRequestService.scala +++ b/src/main/scala/gitbucket/core/service/PullRequestService.scala @@ -77,9 +77,9 @@ } .filter { case (t1, t2) => - (t2.closed === closed.bind) && - (t1.userName === owner.get.bind, owner.isDefined) && - (t1.repositoryName === repository.get.bind, repository.isDefined) + (t2.closed === closed.bind) + .&&(t1.userName === owner.get.bind, owner.isDefined) + .&&(t1.repositoryName === repository.get.bind, repository.isDefined) } .groupBy { case (t1, t2) => t2.openedUserName } .map { case (userName, t) => userName -> t.length } @@ -183,10 +183,10 @@ } .filter { case (t1, t2) => - (t1.requestUserName === userName.bind) && - (t1.requestRepositoryName === repositoryName.bind) && - (t1.requestBranch === branch.bind) && - (t2.closed === closed.get.bind, closed.isDefined) + (t1.requestUserName === userName.bind) + .&&(t1.requestRepositoryName === repositoryName.bind) + .&&(t1.requestBranch === branch.bind) + .&&(t2.closed === closed.get.bind, closed.isDefined) } .map { case (t1, t2) => t1 } .list @@ -201,10 +201,10 @@ } .filter { case (t1, t2) => - (t1.requestUserName === userName.bind) && - (t1.requestRepositoryName === repositoryName.bind) && - (t1.branch === branch.bind) && - (t2.closed === closed.get.bind, closed.isDefined) + (t1.requestUserName === userName.bind) + .&&(t1.requestRepositoryName === repositoryName.bind) + .&&(t1.branch === branch.bind) + .&&(t2.closed === closed.get.bind, closed.isDefined) } .map { case (t1, t2) => t1 } .list diff --git a/src/main/scala/gitbucket/core/service/WebHookService.scala b/src/main/scala/gitbucket/core/service/WebHookService.scala index 7d12cc3..1d10bb5 100644 --- a/src/main/scala/gitbucket/core/service/WebHookService.scala +++ b/src/main/scala/gitbucket/core/service/WebHookService.scala @@ -283,7 +283,7 @@ val json = JsonFormat(payload) webHooks.map { webHook => - val reqPromise = Promise[HttpRequest] + val reqPromise = Promise[HttpRequest]() val f = Future { val itcp = new org.apache.http.HttpRequestInterceptor { def process(res: HttpRequest, ctx: HttpContext): Unit = { diff --git a/src/main/scala/gitbucket/core/util/JDBCUtil.scala b/src/main/scala/gitbucket/core/util/JDBCUtil.scala index 0b2fa65..fe650bd 100644 --- a/src/main/scala/gitbucket/core/util/JDBCUtil.scala +++ b/src/main/scala/gitbucket/core/util/JDBCUtil.scala @@ -202,7 +202,7 @@ } private def allTablesOrderByDependencies(meta: DatabaseMetaData): Seq[String] = { - val tables = allTableNames.map { tableName => + val tables = allTableNames().map { tableName => TableDependency(tableName, childTables(meta, tableName)) } diff --git a/src/main/scala/gitbucket/core/util/LDAPUtil.scala b/src/main/scala/gitbucket/core/util/LDAPUtil.scala index 623170f..8ab912b 100644 --- a/src/main/scala/gitbucket/core/util/LDAPUtil.scala +++ b/src/main/scala/gitbucket/core/util/LDAPUtil.scala @@ -125,6 +125,8 @@ } private def getSslProvider(): Provider = { + import scala.language.existentials + val cachedInstance = provider.get() if (cachedInstance == null) { val cls = try { diff --git a/src/test/scala/gitbucket/core/service/AccessTokenServiceSpec.scala b/src/test/scala/gitbucket/core/service/AccessTokenServiceSpec.scala index 2403ddc..56c7ce7 100644 --- a/src/test/scala/gitbucket/core/service/AccessTokenServiceSpec.scala +++ b/src/test/scala/gitbucket/core/service/AccessTokenServiceSpec.scala @@ -71,7 +71,7 @@ withTestDB { implicit session => val tokenIt = List("token1", "token1", "token1", "token2").iterator val service = new AccessTokenService { - override def makeAccessTokenString: String = tokenIt.next + override def makeAccessTokenString: String = tokenIt.next() } assert(service.generateAccessToken("root", "note1")._2 == "token1")