mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
(refs #341)Fix compilation error other than date mapping and delete statement
This commit is contained in:
@@ -2,6 +2,7 @@ package app
|
|||||||
|
|
||||||
import util._
|
import util._
|
||||||
import ControlUtil._
|
import ControlUtil._
|
||||||
|
import Implicits._
|
||||||
import service._
|
import service._
|
||||||
import jp.sf.amateras.scalatra.forms._
|
import jp.sf.amateras.scalatra.forms._
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ trait ActivityService {
|
|||||||
.take(30)
|
.take(30)
|
||||||
.list
|
.list
|
||||||
|
|
||||||
def getRecentActivities(implicit s: Session): List[Activity] =
|
def getRecentActivities()(implicit s: Session): List[Activity] =
|
||||||
Activities
|
Activities
|
||||||
.innerJoin(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
|
.innerJoin(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
|
||||||
.filter { case (t1, t2) => t2.isPrivate is false.bind }
|
.filter { case (t1, t2) => t2.isPrivate is false.bind }
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ trait IssuesService {
|
|||||||
t.userName -> t.repositoryName
|
t.userName -> t.repositoryName
|
||||||
}
|
}
|
||||||
.map { case (repo, t) =>
|
.map { case (repo, t) =>
|
||||||
repo -> t.length
|
(repo._1, repo._2, t.length)
|
||||||
}
|
}
|
||||||
.sortBy(_._3 desc)
|
.sortBy(_._3 desc)
|
||||||
.list
|
.list
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ import org.eclipse.jgit.revwalk.RevWalk
|
|||||||
import org.eclipse.jgit.treewalk.TreeWalk
|
import org.eclipse.jgit.treewalk.TreeWalk
|
||||||
import org.eclipse.jgit.lib.FileMode
|
import org.eclipse.jgit.lib.FileMode
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
|
import model.profile.simple.Session
|
||||||
|
|
||||||
trait
|
trait RepositorySearchService { self: IssuesService =>
|
||||||
RepositorySearchService { self: IssuesService =>
|
|
||||||
import RepositorySearchService._
|
import RepositorySearchService._
|
||||||
|
|
||||||
def countIssues(owner: String, repository: String, query: String): Int =
|
def countIssues(owner: String, repository: String, query: String)(implicit session: Session): Int =
|
||||||
searchIssuesByKeyword(owner, repository, query).length
|
searchIssuesByKeyword(owner, repository, query).length
|
||||||
|
|
||||||
def searchIssues(owner: String, repository: String, query: String): List[IssueSearchResult] =
|
def searchIssues(owner: String, repository: String, query: String)(implicit session: Session): List[IssueSearchResult] =
|
||||||
searchIssuesByKeyword(owner, repository, query).map { case (issue, commentCount, content) =>
|
searchIssuesByKeyword(owner, repository, query).map { case (issue, commentCount, content) =>
|
||||||
IssueSearchResult(
|
IssueSearchResult(
|
||||||
issue.issueId,
|
issue.issueId,
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ trait RepositoryService { self: AccountService =>
|
|||||||
// for Guests
|
// for Guests
|
||||||
case None => Repositories filter(_.isPrivate is false.bind)
|
case None => Repositories filter(_.isPrivate is false.bind)
|
||||||
}).filter { t =>
|
}).filter { t =>
|
||||||
repositoryUserName.map { userName => t.userName is userName.bind } getOrElse ConstColumn.TRUE
|
repositoryUserName.map { userName => t.userName is userName.bind } getOrElse LiteralColumn(true)
|
||||||
}.sortBy(_.lastActivityDate desc).list.map{ repository =>
|
}.sortBy(_.lastActivityDate desc).list.map{ repository =>
|
||||||
new RepositoryInfo(
|
new RepositoryInfo(
|
||||||
JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl),
|
JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl),
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import servlet.{Database, CommitLogHook}
|
|||||||
import service.{AccountService, RepositoryService, SystemSettingsService}
|
import service.{AccountService, RepositoryService, SystemSettingsService}
|
||||||
import org.eclipse.jgit.errors.RepositoryNotFoundException
|
import org.eclipse.jgit.errors.RepositoryNotFoundException
|
||||||
import javax.servlet.ServletContext
|
import javax.servlet.ServletContext
|
||||||
|
import model.profile.simple.Session
|
||||||
|
|
||||||
object GitCommand {
|
object GitCommand {
|
||||||
val CommandRegex = """\Agit-(upload|receive)-pack '/([a-zA-Z0-9\-_.]+)/([a-zA-Z0-9\-_.]+).git'\Z""".r
|
val CommandRegex = """\Agit-(upload|receive)-pack '/([a-zA-Z0-9\-_.]+)/([a-zA-Z0-9\-_.]+).git'\Z""".r
|
||||||
@@ -27,11 +27,11 @@ abstract class GitCommand(val context: ServletContext, val owner: String, val re
|
|||||||
protected var out: OutputStream = null
|
protected var out: OutputStream = null
|
||||||
protected var callback: ExitCallback = null
|
protected var callback: ExitCallback = null
|
||||||
|
|
||||||
protected def runTask(user: String): Unit
|
protected def runTask(user: String)(implicit session: Session): Unit
|
||||||
|
|
||||||
private def newTask(user: String): Runnable = new Runnable {
|
private def newTask(user: String): Runnable = new Runnable {
|
||||||
override def run(): Unit = {
|
override def run(): Unit = {
|
||||||
Database(context) withTransaction {
|
Database(context) withTransaction { implicit session =>
|
||||||
try {
|
try {
|
||||||
runTask(user)
|
runTask(user)
|
||||||
callback.onExit(0)
|
callback.onExit(0)
|
||||||
@@ -71,7 +71,8 @@ abstract class GitCommand(val context: ServletContext, val owner: String, val re
|
|||||||
this.in = in
|
this.in = in
|
||||||
}
|
}
|
||||||
|
|
||||||
protected def isWritableUser(username: String, repositoryInfo: RepositoryService.RepositoryInfo): Boolean =
|
protected def isWritableUser(username: String, repositoryInfo: RepositoryService.RepositoryInfo)
|
||||||
|
(implicit session: Session): Boolean =
|
||||||
getAccountByUserName(username) match {
|
getAccountByUserName(username) match {
|
||||||
case Some(account) => hasWritePermission(repositoryInfo.owner, repositoryInfo.name, Some(account))
|
case Some(account) => hasWritePermission(repositoryInfo.owner, repositoryInfo.name, Some(account))
|
||||||
case None => false
|
case None => false
|
||||||
@@ -82,7 +83,7 @@ abstract class GitCommand(val context: ServletContext, val owner: String, val re
|
|||||||
class GitUploadPack(context: ServletContext, owner: String, repoName: String, baseUrl: String) extends GitCommand(context, owner, repoName)
|
class GitUploadPack(context: ServletContext, owner: String, repoName: String, baseUrl: String) extends GitCommand(context, owner, repoName)
|
||||||
with RepositoryService with AccountService {
|
with RepositoryService with AccountService {
|
||||||
|
|
||||||
override protected def runTask(user: String): Unit = {
|
override protected def runTask(user: String)(implicit session: Session): Unit = {
|
||||||
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", ""), baseUrl).foreach { repositoryInfo =>
|
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", ""), baseUrl).foreach { repositoryInfo =>
|
||||||
if(!repositoryInfo.repository.isPrivate || isWritableUser(user, repositoryInfo)){
|
if(!repositoryInfo.repository.isPrivate || isWritableUser(user, repositoryInfo)){
|
||||||
using(Git.open(getRepositoryDir(owner, repoName))) { git =>
|
using(Git.open(getRepositoryDir(owner, repoName))) { git =>
|
||||||
@@ -99,7 +100,7 @@ class GitUploadPack(context: ServletContext, owner: String, repoName: String, ba
|
|||||||
class GitReceivePack(context: ServletContext, owner: String, repoName: String, baseUrl: String) extends GitCommand(context, owner, repoName)
|
class GitReceivePack(context: ServletContext, owner: String, repoName: String, baseUrl: String) extends GitCommand(context, owner, repoName)
|
||||||
with SystemSettingsService with RepositoryService with AccountService {
|
with SystemSettingsService with RepositoryService with AccountService {
|
||||||
|
|
||||||
override protected def runTask(user: String): Unit = {
|
override protected def runTask(user: String)(implicit session: Session): Unit = {
|
||||||
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", ""), baseUrl).foreach { repositoryInfo =>
|
getRepository(owner, repoName.replaceFirst("\\.wiki\\Z", ""), baseUrl).foreach { repositoryInfo =>
|
||||||
if(isWritableUser(user, repositoryInfo)){
|
if(isWritableUser(user, repositoryInfo)){
|
||||||
using(Git.open(getRepositoryDir(owner, repoName))) { git =>
|
using(Git.open(getRepositoryDir(owner, repoName))) { git =>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import javax.servlet.ServletContext
|
|||||||
class PublicKeyAuthenticator(context: ServletContext) extends PublickeyAuthenticator with SshKeyService {
|
class PublicKeyAuthenticator(context: ServletContext) extends PublickeyAuthenticator with SshKeyService {
|
||||||
|
|
||||||
override def authenticate(username: String, key: PublicKey, session: ServerSession): Boolean = {
|
override def authenticate(username: String, key: PublicKey, session: ServerSession): Boolean = {
|
||||||
Database(context) withTransaction {
|
Database(context) withTransaction { implicit session =>
|
||||||
getPublicKeys(username).exists { sshKey =>
|
getPublicKeys(username).exists { sshKey =>
|
||||||
SshUtil.str2PublicKey(sshKey.publicKey) match {
|
SshUtil.str2PublicKey(sshKey.publicKey) match {
|
||||||
case Some(publicKey) => key.equals(publicKey)
|
case Some(publicKey) => key.equals(publicKey)
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ import service.{AccountService, RepositoryService, IssuesService, SystemSettings
|
|||||||
import servlet.Database
|
import servlet.Database
|
||||||
import SystemSettingsService.Smtp
|
import SystemSettingsService.Smtp
|
||||||
import _root_.util.ControlUtil.defining
|
import _root_.util.ControlUtil.defining
|
||||||
|
import model.profile.simple.Session
|
||||||
|
|
||||||
trait Notifier extends RepositoryService with AccountService with IssuesService {
|
trait Notifier extends RepositoryService with AccountService with IssuesService {
|
||||||
def toNotify(r: RepositoryService.RepositoryInfo, issueId: Int, content: String)
|
def toNotify(r: RepositoryService.RepositoryInfo, issueId: Int, content: String)
|
||||||
(msg: String => String)(implicit context: Context): Unit
|
(msg: String => String)(implicit context: Context): Unit
|
||||||
|
|
||||||
protected def recipients(issue: model.Issue)(notify: String => Unit)(implicit context: Context) =
|
protected def recipients(issue: model.Issue)(notify: String => Unit)(implicit session: Session, context: Context) =
|
||||||
(
|
(
|
||||||
// individual repository's owner
|
// individual repository's owner
|
||||||
issue.userName ::
|
issue.userName ::
|
||||||
@@ -70,7 +71,7 @@ class Mailer(private val smtp: Smtp) extends Notifier {
|
|||||||
|
|
||||||
val f = future {
|
val f = future {
|
||||||
// TODO Can we use the Database Session in other than Transaction Filter?
|
// TODO Can we use the Database Session in other than Transaction Filter?
|
||||||
database withSession {
|
database withSession { implicit session =>
|
||||||
getIssue(r.owner, r.name, issueId.toString) foreach { issue =>
|
getIssue(r.owner, r.name, issueId.toString) foreach { issue =>
|
||||||
defining(
|
defining(
|
||||||
s"[${r.name}] ${issue.title} (#${issueId})" ->
|
s"[${r.name}] ${issue.title} (#${issueId})" ->
|
||||||
|
|||||||
Reference in New Issue
Block a user