mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-06 18:37:13 +02:00
Introduce syntax suger to tuple extraction
This commit is contained in:
@@ -6,7 +6,7 @@ import gitbucket.core.model.{GroupMember, Role}
|
||||
import gitbucket.core.plugin.PluginRegistry
|
||||
import gitbucket.core.service._
|
||||
import gitbucket.core.ssh.SshUtil
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.StringUtil._
|
||||
|
||||
@@ -5,7 +5,7 @@ import gitbucket.core.model._
|
||||
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
||||
import gitbucket.core.service.PullRequestService._
|
||||
import gitbucket.core.service._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.JGitUtil._
|
||||
import gitbucket.core.util._
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.io.FileInputStream
|
||||
import gitbucket.core.api.ApiError
|
||||
import gitbucket.core.model.Account
|
||||
import gitbucket.core.service.{AccountService, SystemSettingsService,RepositoryService}
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util._
|
||||
|
||||
@@ -5,7 +5,7 @@ import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||
import gitbucket.core.service.{AccountService, RepositoryService}
|
||||
import gitbucket.core.servlet.Database
|
||||
import gitbucket.core.util._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import org.eclipse.jgit.api.Git
|
||||
|
||||
@@ -4,13 +4,13 @@ import gitbucket.core.helper.xml
|
||||
import gitbucket.core.model.Account
|
||||
import gitbucket.core.service._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.{Keys, LDAPUtil, ReferrerAuthenticator, UsersAuthenticator}
|
||||
import io.github.gitbucket.scalatra.forms._
|
||||
import org.scalatra.Ok
|
||||
|
||||
|
||||
class IndexController extends IndexControllerBase
|
||||
class IndexController extends IndexControllerBase
|
||||
with RepositoryService with ActivityService with AccountService with RepositorySearchService with IssuesService
|
||||
with UsersAuthenticator with ReferrerAuthenticator
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package gitbucket.core.controller
|
||||
import gitbucket.core.issues.html
|
||||
import gitbucket.core.service.IssuesService._
|
||||
import gitbucket.core.service._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util._
|
||||
import gitbucket.core.view
|
||||
|
||||
@@ -8,7 +8,7 @@ import gitbucket.core.service.IssuesService._
|
||||
import gitbucket.core.service.PullRequestService._
|
||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||
import gitbucket.core.service._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util._
|
||||
|
||||
@@ -6,7 +6,7 @@ import gitbucket.core.service._
|
||||
import gitbucket.core.service.WebHookService._
|
||||
import gitbucket.core.util._
|
||||
import gitbucket.core.util.JGitUtil._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.Directory._
|
||||
import io.github.gitbucket.scalatra.forms._
|
||||
@@ -92,14 +92,14 @@ trait RepositorySettingsControllerBase extends ControllerBase {
|
||||
get("/:owner/:repository/settings")(ownerOnly { repository =>
|
||||
redirect(s"/${repository.owner}/${repository.name}/settings/options")
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* Display the Options page.
|
||||
*/
|
||||
get("/:owner/:repository/settings/options")(ownerOnly {
|
||||
html.options(_, flash.get("info"))
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* Save the repository options.
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@ import gitbucket.core.service._
|
||||
import gitbucket.core.util._
|
||||
import gitbucket.core.util.JGitUtil._
|
||||
import gitbucket.core.util.StringUtil._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.model.{Account, WebHook}
|
||||
|
||||
@@ -9,7 +9,7 @@ import gitbucket.core.ssh.SshServer
|
||||
import gitbucket.core.plugin.PluginRegistry
|
||||
import SystemSettingsService._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.StringUtil._
|
||||
import io.github.gitbucket.scalatra.forms._
|
||||
|
||||
@@ -5,14 +5,14 @@ import gitbucket.core.wiki.html
|
||||
import gitbucket.core.service.{AccountService, ActivityService, RepositoryService, WikiService}
|
||||
import gitbucket.core.util._
|
||||
import gitbucket.core.util.StringUtil._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.Directory._
|
||||
import io.github.gitbucket.scalatra.forms._
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.scalatra.i18n.Messages
|
||||
|
||||
class WikiController extends WikiControllerBase
|
||||
class WikiController extends WikiControllerBase
|
||||
with WikiService with RepositoryService with AccountService with ActivityService
|
||||
with ReadableUsersAuthenticator with ReferrerAuthenticator
|
||||
|
||||
@@ -20,7 +20,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
self: WikiService with RepositoryService with ActivityService with ReadableUsersAuthenticator with ReferrerAuthenticator =>
|
||||
|
||||
case class WikiPageEditForm(pageName: String, content: String, message: Option[String], currentPageName: String, id: String)
|
||||
|
||||
|
||||
val newForm = mapping(
|
||||
"pageName" -> trim(label("Page name" , text(required, maxlength(40), pagename, unique))),
|
||||
"content" -> trim(label("Content" , text(required, conflictForNew))),
|
||||
@@ -28,7 +28,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
"currentPageName" -> trim(label("Current page name" , text())),
|
||||
"id" -> trim(label("Latest commit id" , text()))
|
||||
)(WikiPageEditForm.apply)
|
||||
|
||||
|
||||
val editForm = mapping(
|
||||
"pageName" -> trim(label("Page name" , text(required, maxlength(40), pagename))),
|
||||
"content" -> trim(label("Content" , text(required, conflictForEdit))),
|
||||
@@ -36,7 +36,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
"currentPageName" -> trim(label("Current page name" , text(required))),
|
||||
"id" -> trim(label("Latest commit id" , text(required)))
|
||||
)(WikiPageEditForm.apply)
|
||||
|
||||
|
||||
get("/:owner/:repository/wiki")(referrersOnly { repository =>
|
||||
getWikiPage(repository.owner, repository.name, "Home").map { page =>
|
||||
html.page("Home", page, getWikiPageList(repository.owner, repository.name),
|
||||
@@ -45,7 +45,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
getWikiPage(repository.owner, repository.name, "_Footer"))
|
||||
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/Home/_edit")
|
||||
})
|
||||
|
||||
|
||||
get("/:owner/:repository/wiki/:page")(referrersOnly { repository =>
|
||||
val pageName = StringUtil.urlDecode(params("page"))
|
||||
|
||||
@@ -56,7 +56,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
getWikiPage(repository.owner, repository.name, "_Footer"))
|
||||
} getOrElse redirect(s"/${repository.owner}/${repository.name}/wiki/${StringUtil.urlEncode(pageName)}/_edit")
|
||||
})
|
||||
|
||||
|
||||
get("/:owner/:repository/wiki/:page/_history")(referrersOnly { repository =>
|
||||
val pageName = StringUtil.urlDecode(params("page"))
|
||||
|
||||
@@ -67,7 +67,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
get("/:owner/:repository/wiki/:page/_compare/:commitId")(referrersOnly { repository =>
|
||||
val pageName = StringUtil.urlDecode(params("page"))
|
||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||
@@ -77,7 +77,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
isEditable(repository), flash.get("info"))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
get("/:owner/:repository/wiki/_compare/:commitId")(referrersOnly { repository =>
|
||||
val Array(from, to) = params("commitId").split("\\.\\.\\.")
|
||||
|
||||
@@ -120,7 +120,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
html.edit(pageName, getWikiPage(repository.owner, repository.name, pageName), repository)
|
||||
} else Unauthorized()
|
||||
})
|
||||
|
||||
|
||||
post("/:owner/:repository/wiki/_edit", editForm)(readableUsersOnly { (form, repository) =>
|
||||
if(isEditable(repository)){
|
||||
defining(context.loginAccount.get){ loginAccount =>
|
||||
@@ -145,13 +145,13 @@ trait WikiControllerBase extends ControllerBase {
|
||||
}
|
||||
} else Unauthorized()
|
||||
})
|
||||
|
||||
|
||||
get("/:owner/:repository/wiki/_new")(readableUsersOnly { repository =>
|
||||
if(isEditable(repository)){
|
||||
html.edit("", None, repository)
|
||||
} else Unauthorized()
|
||||
})
|
||||
|
||||
|
||||
post("/:owner/:repository/wiki/_new", newForm)(readableUsersOnly { (form, repository) =>
|
||||
if(isEditable(repository)){
|
||||
defining(context.loginAccount.get){ loginAccount =>
|
||||
@@ -169,7 +169,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
}
|
||||
} else Unauthorized()
|
||||
})
|
||||
|
||||
|
||||
get("/:owner/:repository/wiki/:page/_delete")(readableUsersOnly { repository =>
|
||||
if(isEditable(repository)){
|
||||
val pageName = StringUtil.urlDecode(params("page"))
|
||||
@@ -186,7 +186,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
get("/:owner/:repository/wiki/_pages")(referrersOnly { repository =>
|
||||
html.pages(getWikiPageList(repository.owner, repository.name), repository, isEditable(repository))
|
||||
})
|
||||
|
||||
|
||||
get("/:owner/:repository/wiki/_history")(referrersOnly { repository =>
|
||||
using(Git.open(getWikiRepositoryDir(repository.owner, repository.name))){ git =>
|
||||
JGitUtil.getCommitLog(git, "master") match {
|
||||
|
||||
@@ -5,7 +5,7 @@ import gitbucket.core.controller.{Context, ControllerBase}
|
||||
import gitbucket.core.model.Account
|
||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||
import gitbucket.core.service.SystemSettingsService.SystemSettings
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import io.github.gitbucket.solidbase.model.Version
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ import gitbucket.core.model.Account
|
||||
import gitbucket.core.service.ProtectedBranchService.ProtectedBranchReceiveHook
|
||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||
import gitbucket.core.service.SystemSettingsService.SystemSettings
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.DatabaseConfig
|
||||
import gitbucket.core.util.Directory._
|
||||
import io.github.gitbucket.solidbase.Solidbase
|
||||
|
||||
@@ -42,7 +42,7 @@ trait AccessTokenService {
|
||||
Accounts
|
||||
.join(AccessTokens)
|
||||
.filter { case (ac, t) => (ac.userName === t.userName) && (t.tokenHash === tokenToHash(token).bind) && (ac.removed === false.bind) }
|
||||
.map { case (ac, t) => ac }
|
||||
.map { case (ac, t) => ac }
|
||||
.firstOption
|
||||
|
||||
def getAccessTokens(userName: String)(implicit s: Session): List[AccessToken] =
|
||||
|
||||
@@ -4,7 +4,7 @@ import gitbucket.core.controller.Context
|
||||
import gitbucket.core.model.Issue
|
||||
import gitbucket.core.model.Profile._
|
||||
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.Notifier
|
||||
|
||||
|
||||
@@ -3,14 +3,13 @@ package gitbucket.core.service
|
||||
import gitbucket.core.util.JGitUtil.CommitInfo
|
||||
import gitbucket.core.util.StringUtil._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.model.{Issue, PullRequest, IssueComment, IssueLabel, Label, Account, Repository, CommitState, Role}
|
||||
import gitbucket.core.model.Profile._
|
||||
import gitbucket.core.model.Profile.profile._
|
||||
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||
import gitbucket.core.model.Profile.dateColumnType
|
||||
|
||||
|
||||
|
||||
trait IssuesService {
|
||||
self: AccountService with RepositoryService =>
|
||||
import IssuesService._
|
||||
@@ -27,33 +26,37 @@ trait IssuesService {
|
||||
def getCommentsForApi(owner: String, repository: String, issueId: Int)(implicit s: Session): List[(IssueComment, Account, Issue)] =
|
||||
IssueComments.filter(_.byIssue(owner, repository, issueId))
|
||||
.filter(_.action inSetBind Set("comment" , "close_comment", "reopen_comment"))
|
||||
.join(Accounts).on( (t1, t2) => t1.commentedUserName === t2.userName )
|
||||
.join(Issues).on{ case ((t1, t2), t3) => t3.byIssue(t1.userName, t1.repositoryName, t1.issueId) }
|
||||
.map{ case ((t1, t2), t3) => (t1, t2, t3) }
|
||||
.join(Accounts).on { case t1 ~ t2 => t1.commentedUserName === t2.userName }
|
||||
.join(Issues).on { case t1 ~ t2 ~ t3 => t3.byIssue(t1.userName, t1.repositoryName, t1.issueId) }
|
||||
.map { case t1 ~ t2 ~ t3 => (t1, t2, t3) }
|
||||
.list
|
||||
|
||||
def getMergedComment(owner: String, repository: String, issueId: Int)(implicit s: Session): Option[(IssueComment, Account)] = {
|
||||
getCommentsForApi(owner, repository, issueId).collectFirst { case (comment, account, _) if comment.action == "merged" => (comment, account) }
|
||||
getCommentsForApi(owner, repository, issueId)
|
||||
.collectFirst { case (comment, account, _) if comment.action == "merged" => (comment, account) }
|
||||
}
|
||||
|
||||
def getComment(owner: String, repository: String, commentId: String)(implicit s: Session) =
|
||||
def getComment(owner: String, repository: String, commentId: String)(implicit s: Session): Option[IssueComment] = {
|
||||
if (commentId forall (_.isDigit))
|
||||
IssueComments filter { t =>
|
||||
t.byPrimaryKey(commentId.toInt) && t.byRepository(owner, repository)
|
||||
} firstOption
|
||||
else None
|
||||
}
|
||||
|
||||
def getIssueLabels(owner: String, repository: String, issueId: Int)(implicit s: Session) =
|
||||
def getIssueLabels(owner: String, repository: String, issueId: Int)(implicit s: Session): List[Label] = {
|
||||
IssueLabels
|
||||
.join(Labels).on { (t1, t2) =>
|
||||
.join(Labels).on { case t1 ~ t2 =>
|
||||
t1.byLabel(t2.userName, t2.repositoryName, t2.labelId)
|
||||
}
|
||||
.filter ( _._1.byIssue(owner, repository, issueId) )
|
||||
.map ( _._2 )
|
||||
.filter { case t1 ~ t2 => t1.byIssue(owner, repository, issueId) }
|
||||
.map { case t1 ~ t2 => t2 }
|
||||
.list
|
||||
}
|
||||
|
||||
def getIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int)(implicit s: Session) =
|
||||
def getIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int)(implicit s: Session): Option[IssueLabel] = {
|
||||
IssueLabels filter (_.byPrimaryKey(owner, repository, issueId, labelId)) firstOption
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the count of the search result against issues.
|
||||
@@ -63,9 +66,9 @@ trait IssuesService {
|
||||
* @param repos Tuple of the repository owner and the repository name
|
||||
* @return the count of the search result
|
||||
*/
|
||||
def countIssue(condition: IssueSearchCondition, onlyPullRequest: Boolean,
|
||||
repos: (String, String)*)(implicit s: Session): Int =
|
||||
def countIssue(condition: IssueSearchCondition, onlyPullRequest: Boolean, repos: (String, String)*)(implicit s: Session): Int = {
|
||||
Query(searchIssueQuery(repos, condition, onlyPullRequest).length).first
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Map which contains issue count for each labels.
|
||||
@@ -79,16 +82,16 @@ trait IssuesService {
|
||||
filterUser: Map[String, String])(implicit s: Session): Map[String, Int] = {
|
||||
|
||||
searchIssueQuery(Seq(owner -> repository), condition.copy(labels = Set.empty), false)
|
||||
.join(IssueLabels).on { (t1, t2) =>
|
||||
.join(IssueLabels).on { case t1 ~ t2 =>
|
||||
t1.byIssue(t2.userName, t2.repositoryName, t2.issueId)
|
||||
}
|
||||
.join(Labels).on { case ((t1, t2), t3) =>
|
||||
.join(Labels).on { case t1 ~ t2 ~ t3 =>
|
||||
t2.byLabel(t3.userName, t3.repositoryName, t3.labelId)
|
||||
}
|
||||
.groupBy { case ((t1, t2), t3) =>
|
||||
.groupBy { case t1 ~ t2 ~ t3 =>
|
||||
t3.labelName
|
||||
}
|
||||
.map { case (labelName, t) =>
|
||||
.map { case labelName ~ t =>
|
||||
labelName -> t.length
|
||||
}
|
||||
.list.toMap
|
||||
@@ -96,8 +99,12 @@ trait IssuesService {
|
||||
|
||||
def getCommitStatues(userName: String, repositoryName: String, issueId: Int)(implicit s: Session): Option[CommitStatusInfo] = {
|
||||
val status = PullRequests
|
||||
.filter { pr => (pr.userName === userName.bind) && (pr.repositoryName === repositoryName.bind) && (pr.issueId === issueId.bind) }
|
||||
.join(CommitStatuses).on((pr, cs) => pr.userName === cs.userName && pr.repositoryName === cs.repositoryName && pr.commitIdTo === cs.commitId)
|
||||
.filter { pr =>
|
||||
pr.userName === userName.bind && pr.repositoryName === repositoryName.bind && pr.issueId === issueId.bind
|
||||
}
|
||||
.join(CommitStatuses).on { case pr ~ cs =>
|
||||
pr.userName === cs.userName && pr.repositoryName === cs.repositoryName && pr.commitIdTo === cs.commitId
|
||||
}
|
||||
.list
|
||||
|
||||
if(status.nonEmpty){
|
||||
@@ -129,11 +136,11 @@ trait IssuesService {
|
||||
(implicit s: Session): List[IssueInfo] = {
|
||||
// get issues and comment count and labels
|
||||
val result = searchIssueQueryBase(condition, pullRequest, offset, limit, repos)
|
||||
.joinLeft (IssueLabels) .on { case (((t1, t2), i), t3) => t1.byIssue(t3.userName, t3.repositoryName, t3.issueId) }
|
||||
.joinLeft (Labels) .on { case ((((t1, t2), i), t3), t4) => t3.map(_.byLabel(t4.userName, t4.repositoryName, t4.labelId)) }
|
||||
.joinLeft (Milestones) .on { case (((((t1, t2), i), t3), t4), t5) => t1.byMilestone(t5.userName, t5.repositoryName, t5.milestoneId) }
|
||||
.sortBy { case (((((t1, t2), i), t3), t4), t5) => i asc }
|
||||
.map { case (((((t1, t2), i), t3), t4), t5) =>
|
||||
.joinLeft (IssueLabels) .on { case t1 ~ t2 ~ i ~ t3 => t1.byIssue(t3.userName, t3.repositoryName, t3.issueId) }
|
||||
.joinLeft (Labels) .on { case t1 ~ t2 ~ i ~ t3 ~ t4 => t3.map(_.byLabel(t4.userName, t4.repositoryName, t4.labelId)) }
|
||||
.joinLeft (Milestones) .on { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 => t1.byMilestone(t5.userName, t5.repositoryName, t5.milestoneId) }
|
||||
.sortBy { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 => i asc }
|
||||
.map { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 =>
|
||||
(t1, t2.commentCount, t4.map(_.labelId), t4.map(_.labelName), t4.map(_.color), t5.map(_.title))
|
||||
}
|
||||
.list
|
||||
@@ -156,9 +163,9 @@ trait IssuesService {
|
||||
(implicit s: Session): List[(Issue, Account)] = {
|
||||
// get issues and comment count and labels
|
||||
searchIssueQueryBase(condition, false, offset, limit, repos)
|
||||
.join(Accounts).on { case (((t1, t2), i), t3) => t3.userName === t1.openedUserName }
|
||||
.sortBy { case (((t1, t2), i), t3) => i asc }
|
||||
.map { case (((t1, t2), i), t3) => (t1, t3) }
|
||||
.join(Accounts).on { case t1 ~ t2 ~ i ~ t3 => t3.userName === t1.openedUserName }
|
||||
.sortBy { case t1 ~ t2 ~ i ~ t3 => i asc }
|
||||
.map { case t1 ~ t2 ~ i ~ t3 => (t1, t3) }
|
||||
.list
|
||||
}
|
||||
|
||||
@@ -169,12 +176,12 @@ trait IssuesService {
|
||||
(implicit s: Session): List[(Issue, Account, Int, PullRequest, Repository, Account)] = {
|
||||
// get issues and comment count and labels
|
||||
searchIssueQueryBase(condition, true, offset, limit, repos)
|
||||
.join(PullRequests).on { case (((t1, t2), i), t3) => t3.byPrimaryKey(t1.userName, t1.repositoryName, t1.issueId) }
|
||||
.join(Repositories).on { case ((((t1, t2), i), t3), t4) => t4.byRepository(t1.userName, t1.repositoryName) }
|
||||
.join(Accounts).on { case (((((t1, t2), i), t3), t4), t5) => t5.userName === t1.openedUserName }
|
||||
.join(Accounts).on { case ((((((t1, t2), i), t3), t4), t5), t6) => t6.userName === t4.userName }
|
||||
.sortBy { case ((((((t1, t2), i), t3), t4), t5), t6) => i asc }
|
||||
.map { case ((((((t1, t2), i), t3), t4), t5), t6) => (t1, t5, t2.commentCount, t3, t4, t6) }
|
||||
.join(PullRequests).on { case t1 ~ t2 ~ i ~ t3 => t3.byPrimaryKey(t1.userName, t1.repositoryName, t1.issueId) }
|
||||
.join(Repositories).on { case t1 ~ t2 ~ i ~ t3 ~ t4 => t4.byRepository(t1.userName, t1.repositoryName) }
|
||||
.join(Accounts ).on { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 => t5.userName === t1.openedUserName }
|
||||
.join(Accounts ).on { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 ~ t6 => t6.userName === t4.userName }
|
||||
.sortBy { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 ~ t6 => i asc }
|
||||
.map { case t1 ~ t2 ~ i ~ t3 ~ t4 ~ t5 ~ t6 => (t1, t5, t2.commentCount, t3, t4, t6) }
|
||||
.list
|
||||
}
|
||||
|
||||
@@ -247,36 +254,39 @@ trait IssuesService {
|
||||
|
||||
def insertIssue(owner: String, repository: String, loginUser: String, title: String, content: Option[String],
|
||||
assignedUserName: Option[String], milestoneId: Option[Int],
|
||||
isPullRequest: Boolean = false)(implicit s: Session) =
|
||||
isPullRequest: Boolean = false)(implicit s: Session): Int = {
|
||||
// next id number
|
||||
sql"SELECT ISSUE_ID + 1 FROM ISSUE_ID WHERE USER_NAME = $owner AND REPOSITORY_NAME = $repository FOR UPDATE".as[Int]
|
||||
.firstOption.filter { id =>
|
||||
.firstOption.filter { id =>
|
||||
Issues insert Issue(
|
||||
owner,
|
||||
repository,
|
||||
id,
|
||||
loginUser,
|
||||
milestoneId,
|
||||
assignedUserName,
|
||||
title,
|
||||
content,
|
||||
false,
|
||||
currentDate,
|
||||
currentDate,
|
||||
isPullRequest)
|
||||
owner,
|
||||
repository,
|
||||
id,
|
||||
loginUser,
|
||||
milestoneId,
|
||||
assignedUserName,
|
||||
title,
|
||||
content,
|
||||
false,
|
||||
currentDate,
|
||||
currentDate,
|
||||
isPullRequest)
|
||||
|
||||
// increment issue id
|
||||
IssueId
|
||||
.filter (_.byPrimaryKey(owner, repository))
|
||||
.map (_.issueId)
|
||||
.update (id) > 0
|
||||
.filter(_.byPrimaryKey(owner, repository))
|
||||
.map(_.issueId)
|
||||
.update(id) > 0
|
||||
} get
|
||||
}
|
||||
|
||||
def registerIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int)(implicit s: Session) =
|
||||
def registerIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int)(implicit s: Session): Int = {
|
||||
IssueLabels insert IssueLabel(owner, repository, issueId, labelId)
|
||||
}
|
||||
|
||||
def deleteIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int)(implicit s: Session) =
|
||||
def deleteIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int)(implicit s: Session): Int = {
|
||||
IssueLabels filter(_.byPrimaryKey(owner, repository, issueId, labelId)) delete
|
||||
}
|
||||
|
||||
def createComment(owner: String, repository: String, loginUser: String,
|
||||
issueId: Int, content: String, action: String)(implicit s: Session): Int = {
|
||||
@@ -291,29 +301,30 @@ trait IssuesService {
|
||||
updatedDate = currentDate)
|
||||
}
|
||||
|
||||
def updateIssue(owner: String, repository: String, issueId: Int, title: String, content: Option[String])(implicit s: Session) = {
|
||||
def updateIssue(owner: String, repository: String, issueId: Int, title: String, content: Option[String])(implicit s: Session): Int = {
|
||||
Issues
|
||||
.filter (_.byPrimaryKey(owner, repository, issueId))
|
||||
.map { t => (t.title, t.content.?, t.updatedDate) }
|
||||
.update (title, content, currentDate)
|
||||
}
|
||||
|
||||
def updateAssignedUserName(owner: String, repository: String, issueId: Int,
|
||||
assignedUserName: Option[String])(implicit s: Session) =
|
||||
def updateAssignedUserName(owner: String, repository: String, issueId: Int, assignedUserName: Option[String])(implicit s: Session): Int = {
|
||||
Issues.filter (_.byPrimaryKey(owner, repository, issueId)).map(_.assignedUserName?).update (assignedUserName)
|
||||
}
|
||||
|
||||
def updateMilestoneId(owner: String, repository: String, issueId: Int,
|
||||
milestoneId: Option[Int])(implicit s: Session) =
|
||||
def updateMilestoneId(owner: String, repository: String, issueId: Int, milestoneId: Option[Int])(implicit s: Session): Int = {
|
||||
Issues.filter (_.byPrimaryKey(owner, repository, issueId)).map(_.milestoneId?).update (milestoneId)
|
||||
}
|
||||
|
||||
def updateComment(commentId: Int, content: String)(implicit s: Session) = {
|
||||
def updateComment(commentId: Int, content: String)(implicit s: Session): Int = {
|
||||
IssueComments.filter (_.byPrimaryKey(commentId)).map(t => (t.content, t.updatedDate)).update(content, currentDate)
|
||||
}
|
||||
|
||||
def deleteComment(commentId: Int)(implicit s: Session) =
|
||||
def deleteComment(commentId: Int)(implicit s: Session): Int = {
|
||||
IssueComments filter (_.byPrimaryKey(commentId)) delete
|
||||
}
|
||||
|
||||
def updateClosed(owner: String, repository: String, issueId: Int, closed: Boolean)(implicit s: Session) = {
|
||||
def updateClosed(owner: String, repository: String, issueId: Int, closed: Boolean)(implicit s: Session): Int = {
|
||||
(Issues filter (_.byPrimaryKey(owner, repository, issueId)) map(t => (t.closed, t.updatedDate))).update((closed, currentDate))
|
||||
}
|
||||
|
||||
@@ -325,8 +336,7 @@ trait IssuesService {
|
||||
* @param query the keywords separated by whitespace.
|
||||
* @return issues with comment count and matched content of issue or comment
|
||||
*/
|
||||
def searchIssuesByKeyword(owner: String, repository: String, query: String)
|
||||
(implicit s: Session): List[(Issue, Int, String)] = {
|
||||
def searchIssuesByKeyword(owner: String, repository: String, query: String)(implicit s: Session): List[(Issue, Int, String)] = {
|
||||
//import slick.driver.JdbcDriver.likeEncode
|
||||
val keywords = splitWords(query.toLowerCase)
|
||||
|
||||
@@ -374,7 +384,7 @@ trait IssuesService {
|
||||
}.toList
|
||||
}
|
||||
|
||||
def closeIssuesFromMessage(message: String, userName: String, owner: String, repository: String)(implicit s: Session) = {
|
||||
def closeIssuesFromMessage(message: String, userName: String, owner: String, repository: String)(implicit s: Session): Unit = {
|
||||
extractCloseId(message).foreach { issueId =>
|
||||
for(issue <- getIssue(owner, repository, issueId) if !issue.closed){
|
||||
createComment(owner, repository, userName, issue.issueId, "Close", "close")
|
||||
@@ -383,7 +393,7 @@ trait IssuesService {
|
||||
}
|
||||
}
|
||||
|
||||
def createReferComment(owner: String, repository: String, fromIssue: Issue, message: String, loginAccount: Account)(implicit s: Session) = {
|
||||
def createReferComment(owner: String, repository: String, fromIssue: Issue, message: String, loginAccount: Account)(implicit s: Session): Unit = {
|
||||
extractIssueId(message).foreach { issueId =>
|
||||
val content = fromIssue.issueId + ":" + fromIssue.title
|
||||
if(getIssue(owner, repository, issueId).isDefined){
|
||||
@@ -395,7 +405,7 @@ trait IssuesService {
|
||||
}
|
||||
}
|
||||
|
||||
def createIssueComment(owner: String, repository: String, commit: CommitInfo)(implicit s: Session) = {
|
||||
def createIssueComment(owner: String, repository: String, commit: CommitInfo)(implicit s: Session): Unit = {
|
||||
extractIssueId(commit.fullMessage).foreach { issueId =>
|
||||
if(getIssue(owner, repository, issueId).isDefined){
|
||||
getAccountByMailAddress(commit.committerEmailAddress).foreach { account =>
|
||||
|
||||
@@ -2,7 +2,7 @@ package gitbucket.core.service
|
||||
|
||||
import gitbucket.core.model.Account
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
|
||||
import org.eclipse.jgit.merge.MergeStrategy
|
||||
import org.eclipse.jgit.api.Git
|
||||
|
||||
@@ -4,7 +4,7 @@ import gitbucket.core.model.{Issue, PullRequest, CommitStatus, CommitState, Comm
|
||||
import gitbucket.core.model.Profile._
|
||||
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||
import difflib.{Delta, DiffUtils}
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util.JGitUtil
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package gitbucket.core.service
|
||||
|
||||
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.JGitUtil
|
||||
import gitbucket.core.model.Account
|
||||
|
||||
@@ -4,7 +4,7 @@ import gitbucket.core.model.Issue
|
||||
import gitbucket.core.util._
|
||||
import gitbucket.core.util.StringUtil
|
||||
import Directory._
|
||||
import ControlUtil._
|
||||
import SyntaxSugars._
|
||||
import org.eclipse.jgit.revwalk.RevWalk
|
||||
import org.eclipse.jgit.treewalk.TreeWalk
|
||||
import org.eclipse.jgit.lib.FileMode
|
||||
|
||||
@@ -2,7 +2,7 @@ package gitbucket.core.service
|
||||
|
||||
import gitbucket.core.controller.Context
|
||||
import gitbucket.core.util._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.model.{Account, Collaborator, Repository, RepositoryOptions, Role}
|
||||
import gitbucket.core.model.Profile._
|
||||
import gitbucket.core.model.Profile.profile.blockingApi._
|
||||
@@ -206,7 +206,7 @@ trait RepositoryService { self: AccountService =>
|
||||
|
||||
/**
|
||||
* Returns the specified repository information.
|
||||
*
|
||||
*
|
||||
* @param userName the user name of the repository owner
|
||||
* @param repositoryName the repository name
|
||||
* @return the repository information
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package gitbucket.core.service
|
||||
|
||||
import gitbucket.core.util.{Directory, ControlUtil}
|
||||
import gitbucket.core.util.{Directory, SyntaxSugars}
|
||||
import gitbucket.core.util.Implicits._
|
||||
import Directory._
|
||||
import ControlUtil._
|
||||
import SyntaxSugars._
|
||||
import SystemSettingsService._
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import gitbucket.core.controller.Context
|
||||
import gitbucket.core.model.Account
|
||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||
import gitbucket.core.util._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.treewalk.CanonicalTreeParser
|
||||
import org.eclipse.jgit.lib._
|
||||
@@ -17,10 +17,10 @@ import org.eclipse.jgit.api.errors.PatchFormatException
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
object WikiService {
|
||||
|
||||
|
||||
/**
|
||||
* The model for wiki page.
|
||||
*
|
||||
*
|
||||
* @param name the page name
|
||||
* @param content the page content
|
||||
* @param committer the last committer
|
||||
@@ -28,10 +28,10 @@ object WikiService {
|
||||
* @param id the latest commit id
|
||||
*/
|
||||
case class WikiPageInfo(name: String, content: String, committer: String, time: Date, id: String)
|
||||
|
||||
|
||||
/**
|
||||
* The model for wiki page history.
|
||||
*
|
||||
*
|
||||
* @param name the page name
|
||||
* @param committer the committer the committer
|
||||
* @param message the commit message
|
||||
|
||||
@@ -8,7 +8,7 @@ import gitbucket.core.util.{FileUtil, StringUtil}
|
||||
import org.apache.commons.io.{FileUtils, IOUtils}
|
||||
import org.json4s.jackson.Serialization._
|
||||
import org.apache.http.HttpStatus
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
|
||||
/**
|
||||
* Provides GitLFS Transfer API
|
||||
|
||||
@@ -10,7 +10,7 @@ import gitbucket.core.plugin.{GitRepositoryRouting, PluginRegistry}
|
||||
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
||||
import gitbucket.core.service.WebHookService._
|
||||
import gitbucket.core.service._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.Implicits._
|
||||
import gitbucket.core.util._
|
||||
import org.eclipse.jgit.api.Git
|
||||
@@ -27,7 +27,7 @@ import org.json4s.jackson.Serialization._
|
||||
|
||||
/**
|
||||
* Provides Git repository via HTTP.
|
||||
*
|
||||
*
|
||||
* This servlet provides only Git repository functionality.
|
||||
* Authentication is provided by [[GitAuthenticationFilter]].
|
||||
*/
|
||||
@@ -174,7 +174,7 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
||||
extends PostReceiveHook with PreReceiveHook
|
||||
with RepositoryService with AccountService with IssuesService with ActivityService with PullRequestService with WebHookService
|
||||
with WebHookPullRequestService with CommitsService {
|
||||
|
||||
|
||||
private val logger = LoggerFactory.getLogger(classOf[CommitLogHook])
|
||||
private var existIds: Seq[String] = Nil
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ import gitbucket.core.model.Profile.profile.blockingApi._
|
||||
import gitbucket.core.plugin.{GitRepositoryRouting, PluginRegistry}
|
||||
import gitbucket.core.service.{AccountService, DeployKeyService, RepositoryService, SystemSettingsService}
|
||||
import gitbucket.core.servlet.{CommitLogHook, Database}
|
||||
import gitbucket.core.util.{ControlUtil, Directory}
|
||||
import gitbucket.core.util.{SyntaxSugars, Directory}
|
||||
import org.apache.sshd.server.{Command, CommandFactory, Environment, ExitCallback, SessionAware}
|
||||
import org.apache.sshd.server.session.ServerSession
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.{File, InputStream, OutputStream}
|
||||
|
||||
import ControlUtil._
|
||||
import SyntaxSugars._
|
||||
import org.eclipse.jgit.api.Git
|
||||
import Directory._
|
||||
import gitbucket.core.ssh.PublicKeyAuthenticator.AuthType
|
||||
|
||||
@@ -5,7 +5,7 @@ import gitbucket.core.service.{AccountService, RepositoryService}
|
||||
import gitbucket.core.model.Role
|
||||
import RepositoryService.RepositoryInfo
|
||||
import Implicits._
|
||||
import ControlUtil._
|
||||
import SyntaxSugars._
|
||||
|
||||
/**
|
||||
* Allows only oneself and administrators.
|
||||
|
||||
@@ -3,7 +3,7 @@ package gitbucket.core.util
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.apache.tika.Tika
|
||||
import java.io.File
|
||||
import ControlUtil._
|
||||
import SyntaxSugars._
|
||||
import scala.util.Random
|
||||
|
||||
object FileUtil {
|
||||
|
||||
@@ -3,7 +3,7 @@ package gitbucket.core.util
|
||||
import java.io._
|
||||
import java.sql._
|
||||
import java.text.SimpleDateFormat
|
||||
import ControlUtil._
|
||||
import SyntaxSugars._
|
||||
import scala.annotation.tailrec
|
||||
import scala.collection.mutable.ListBuffer
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import gitbucket.core.service.RepositoryService
|
||||
import org.eclipse.jgit.api.Git
|
||||
import Directory._
|
||||
import StringUtil._
|
||||
import ControlUtil._
|
||||
import SyntaxSugars._
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import scala.collection.JavaConverters._
|
||||
@@ -78,7 +78,7 @@ object JGitUtil {
|
||||
case class CommitInfo(id: String, shortMessage: String, fullMessage: String, parents: List[String],
|
||||
authorTime: Date, authorName: String, authorEmailAddress: String,
|
||||
commitTime: Date, committerName: String, committerEmailAddress: String){
|
||||
|
||||
|
||||
def this(rev: org.eclipse.jgit.revwalk.RevCommit) = this(
|
||||
rev.getName,
|
||||
rev.getShortMessage,
|
||||
@@ -159,7 +159,7 @@ object JGitUtil {
|
||||
|
||||
/**
|
||||
* Returns RevCommit from the commit or tag id.
|
||||
*
|
||||
*
|
||||
* @param git the Git object
|
||||
* @param objectId the ObjectId of the commit or tag
|
||||
* @return the RevCommit for the specified commit or tag
|
||||
@@ -240,7 +240,7 @@ object JGitUtil {
|
||||
|
||||
/**
|
||||
* Returns the file list of the specified path.
|
||||
*
|
||||
*
|
||||
* @param git the Git object
|
||||
* @param revision the branch name or commit id
|
||||
* @param path the directory path (optional)
|
||||
@@ -411,7 +411,7 @@ object JGitUtil {
|
||||
|
||||
/**
|
||||
* Returns the commit list of the specified branch.
|
||||
*
|
||||
*
|
||||
* @param git the Git object
|
||||
* @param revision the branch name or commit id
|
||||
* @param page the page number (1-)
|
||||
@@ -421,7 +421,7 @@ object JGitUtil {
|
||||
*/
|
||||
def getCommitLog(git: Git, revision: String, page: Int = 1, limit: Int = 0, path: String = ""): Either[String, (List[CommitInfo], Boolean)] = {
|
||||
val fixedPage = if(page <= 0) 1 else page
|
||||
|
||||
|
||||
@scala.annotation.tailrec
|
||||
def getCommitLog(i: java.util.Iterator[RevCommit], count: Int, logs: List[CommitInfo]): (List[CommitInfo], Boolean) =
|
||||
i.hasNext match {
|
||||
@@ -431,7 +431,7 @@ object JGitUtil {
|
||||
}
|
||||
case _ => (logs, i.hasNext)
|
||||
}
|
||||
|
||||
|
||||
using(new RevWalk(git.getRepository)){ revWalk =>
|
||||
defining(git.getRepository.resolve(revision)){ objectId =>
|
||||
if(objectId == null){
|
||||
@@ -469,10 +469,10 @@ object JGitUtil {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the commit list between two revisions.
|
||||
*
|
||||
*
|
||||
* @param git the Git object
|
||||
* @param from the from revision
|
||||
* @param to the to revision
|
||||
@@ -481,10 +481,10 @@ object JGitUtil {
|
||||
// TODO swap parameters 'from' and 'to'!?
|
||||
def getCommitLog(git: Git, from: String, to: String): List[CommitInfo] =
|
||||
getCommitLogs(git, to)(_.getName == from)
|
||||
|
||||
|
||||
/**
|
||||
* Returns the latest RevCommit of the specified path.
|
||||
*
|
||||
*
|
||||
* @param git the Git object
|
||||
* @param path the path
|
||||
* @param revision the branch name or commit id
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package gitbucket.core.util
|
||||
|
||||
import gitbucket.core.model.Account
|
||||
import ControlUtil._
|
||||
import SyntaxSugars._
|
||||
import gitbucket.core.service.SystemSettingsService
|
||||
import gitbucket.core.service.SystemSettingsService.Ldap
|
||||
import com.novell.ldap._
|
||||
@@ -111,9 +111,9 @@ object LDAPUtil {
|
||||
}
|
||||
}
|
||||
|
||||
val conn: LDAPConnection =
|
||||
val conn: LDAPConnection =
|
||||
if(ssl) {
|
||||
new LDAPConnection(new LDAPJSSESecureSocketFactory())
|
||||
new LDAPConnection(new LDAPJSSESecureSocketFactory())
|
||||
}else {
|
||||
new LDAPConnection(new LDAPJSSEStartTLSFactory())
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package gitbucket.core.util
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.locks.{ReentrantLock, Lock}
|
||||
import ControlUtil._
|
||||
import SyntaxSugars._
|
||||
|
||||
object LockUtil {
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.apache.commons.mail.{DefaultAuthenticator, HtmlEmail}
|
||||
import org.slf4j.LoggerFactory
|
||||
import gitbucket.core.controller.Context
|
||||
import SystemSettingsService.Smtp
|
||||
import ControlUtil.defining
|
||||
import SyntaxSugars.defining
|
||||
|
||||
trait Notifier extends RepositoryService with AccountService with IssuesService {
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package gitbucket.core.util
|
||||
import java.net.{URLDecoder, URLEncoder}
|
||||
|
||||
import org.mozilla.universalchardet.UniversalDetector
|
||||
import ControlUtil._
|
||||
import SyntaxSugars._
|
||||
import org.apache.commons.io.input.BOMInputStream
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.apache.commons.codec.binary.Base64
|
||||
|
||||
@@ -7,7 +7,7 @@ import scala.language.reflectiveCalls
|
||||
/**
|
||||
* Provides control facilities.
|
||||
*/
|
||||
object ControlUtil {
|
||||
object SyntaxSugars {
|
||||
|
||||
def defining[A, B](value: A)(f: A => B): B = f(value)
|
||||
|
||||
@@ -46,7 +46,11 @@ object ControlUtil {
|
||||
def ignore[T](f: => Unit): Unit = try {
|
||||
f
|
||||
} catch {
|
||||
case e: Exception => ()
|
||||
case _: Exception => ()
|
||||
}
|
||||
|
||||
object ~ {
|
||||
def unapply[A, B](t: (A, B)): Option[(A, B)] = Some(t)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package gitbucket.core.service
|
||||
|
||||
import gitbucket.core.util.Directory._
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import gitbucket.core.util.GitSpecUtil._
|
||||
|
||||
import org.eclipse.jgit.api.Git
|
||||
@@ -119,4 +119,4 @@ class MergeServiceSpec extends FunSpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package gitbucket.core.service
|
||||
|
||||
import gitbucket.core.GitBucketCoreModule
|
||||
import gitbucket.core.util.{DatabaseConfig, FileUtil}
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
import io.github.gitbucket.solidbase.Solidbase
|
||||
import liquibase.database.core.H2Database
|
||||
import liquibase.database.jvm.JdbcConnection
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package gitbucket.core.util
|
||||
|
||||
import gitbucket.core.util.ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars._
|
||||
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.eclipse.jgit.api.Git
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package gitbucket.core.view
|
||||
|
||||
import gitbucket.core.util.ControlUtil
|
||||
import ControlUtil._
|
||||
import gitbucket.core.util.SyntaxSugars
|
||||
import SyntaxSugars._
|
||||
import org.scalatest.FunSpec
|
||||
|
||||
class PaginationSpec extends FunSpec {
|
||||
|
||||
Reference in New Issue
Block a user