mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 05:55:51 +01:00
Change java.sql.Date to java.sql.Timestamp.
This commit is contained in:
@@ -8,11 +8,10 @@ object Repositories extends Table[Repository]("REPOSITORY") {
|
|||||||
def isPrivate = column[Boolean]("PRIVATE")
|
def isPrivate = column[Boolean]("PRIVATE")
|
||||||
def description = column[String]("DESCRIPTION")
|
def description = column[String]("DESCRIPTION")
|
||||||
def defaultBranch = column[String]("DEFAULT_BRANCH")
|
def defaultBranch = column[String]("DEFAULT_BRANCH")
|
||||||
def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later
|
def registeredDate = column[java.sql.Timestamp]("REGISTERED_DATE") // TODO convert java.util.Date later
|
||||||
def updatedDate = column[java.sql.Date]("UPDATED_DATE")
|
def updatedDate = column[java.sql.Timestamp]("UPDATED_DATE")
|
||||||
def lastActivityDate = column[java.sql.Date]("LAST_ACTIVITY_DATE")
|
def lastActivityDate = column[java.sql.Timestamp]("LAST_ACTIVITY_DATE")
|
||||||
def * = repositoryName ~ userName ~ isPrivate ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Repository, Repository.unapply _)
|
def * = repositoryName ~ userName ~ isPrivate ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Repository, Repository.unapply _)
|
||||||
// def ins = repositoryName ~ userName ~ repositoryType ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> ({ t => Project(None, t._1, t._2, t._3, t._4, t._5, t._6, t._7, t._8)}, { (o: Project) => Some((o.projectName, o.userId, o.projectType, o.description, o.defaultBranch, o.registeredDate, o.updatedDate, o.lastActivityDate))})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Repository(
|
case class Repository(
|
||||||
@@ -21,7 +20,7 @@ case class Repository(
|
|||||||
isPrivate: Boolean,
|
isPrivate: Boolean,
|
||||||
description: Option[String],
|
description: Option[String],
|
||||||
defaultBranch: String,
|
defaultBranch: String,
|
||||||
registeredDate: java.sql.Date,
|
registeredDate: java.sql.Timestamp,
|
||||||
updatedDate: java.sql.Date,
|
updatedDate: java.sql.Timestamp,
|
||||||
lastActivityDate: java.sql.Date
|
lastActivityDate: java.sql.Timestamp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ trait RepositoryService { self: AccountService =>
|
|||||||
|
|
||||||
// TODO insert default labels.
|
// TODO insert default labels.
|
||||||
|
|
||||||
val currentDate = new java.sql.Date(System.currentTimeMillis)
|
val currentDate = new java.sql.Timestamp(System.currentTimeMillis)
|
||||||
|
|
||||||
Repositories insert
|
Repositories insert
|
||||||
Repository(
|
Repository(
|
||||||
@@ -98,7 +98,7 @@ trait RepositoryService { self: AccountService =>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
q1.union(q2).filter(visibleFor(_, loginUserName)).sortBy(_.lastActivityDate).list map { repository =>
|
q1.union(q2).filter(visibleFor(_, loginUserName)).sortBy(_.lastActivityDate desc).list map { repository =>
|
||||||
val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl)
|
val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl)
|
||||||
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, repository, repositoryInfo.branchList, repositoryInfo.tags)
|
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, repository, repositoryInfo.branchList, repositoryInfo.tags)
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ trait RepositoryService { self: AccountService =>
|
|||||||
Query(Repositories)
|
Query(Repositories)
|
||||||
.filter { r => (r.userName is userName.bind) && (r.repositoryName is repositoryName.bind) }
|
.filter { r => (r.userName is userName.bind) && (r.repositoryName is repositoryName.bind) }
|
||||||
.map { _.lastActivityDate }
|
.map { _.lastActivityDate }
|
||||||
.update (new java.sql.Date(System.currentTimeMillis))
|
.update (new java.sql.Timestamp(System.currentTimeMillis))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save repository options.
|
* Save repository options.
|
||||||
@@ -172,7 +172,7 @@ trait RepositoryService { self: AccountService =>
|
|||||||
Query(Repositories)
|
Query(Repositories)
|
||||||
.filter { r => (r.userName is userName.bind) && (r.repositoryName is repositoryName.bind) }
|
.filter { r => (r.userName is userName.bind) && (r.repositoryName is repositoryName.bind) }
|
||||||
.map { r => r.description.? ~ r.defaultBranch ~ r.isPrivate ~ r.updatedDate }
|
.map { r => r.description.? ~ r.defaultBranch ~ r.isPrivate ~ r.updatedDate }
|
||||||
.update (description, defaultBranch, isPrivate, new java.sql.Date(System.currentTimeMillis))
|
.update (description, defaultBranch, isPrivate, new java.sql.Timestamp(System.currentTimeMillis))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add collaborator to the repository.
|
* Add collaborator to the repository.
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javax.servlet.ServletConfig
|
|||||||
import javax.servlet.ServletContext
|
import javax.servlet.ServletContext
|
||||||
import javax.servlet.http.HttpServletRequest
|
import javax.servlet.http.HttpServletRequest
|
||||||
import util.{JGitUtil, Directory}
|
import util.{JGitUtil, Directory}
|
||||||
|
import service._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Git repository via HTTP.
|
* Provides Git repository via HTTP.
|
||||||
@@ -66,21 +67,25 @@ class GitBucketReceivePackFactory extends ReceivePackFactory[HttpServletRequest]
|
|||||||
|
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
class CommitLogHook(owner: String, repository: String) extends PostReceiveHook {
|
class CommitLogHook(owner: String, repository: String) extends PostReceiveHook with RepositoryService with AccountService {
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(classOf[CommitLogHook])
|
private val logger = LoggerFactory.getLogger(classOf[CommitLogHook])
|
||||||
|
|
||||||
def onPostReceive(receivePack: ReceivePack, commands: java.util.Collection[ReceiveCommand]): Unit = {
|
def onPostReceive(receivePack: ReceivePack, commands: java.util.Collection[ReceiveCommand]): Unit = {
|
||||||
|
|
||||||
JGitUtil.withGit(Directory.getRepositoryDir(owner, repository)) { git =>
|
JGitUtil.withGit(Directory.getRepositoryDir(owner, repository)) { git =>
|
||||||
commands.asScala.foreach { command =>
|
commands.asScala.foreach { command =>
|
||||||
JGitUtil.getCommitLog(git, command.getOldId.name, command.getNewId.name).foreach { commit =>
|
JGitUtil.getCommitLog(git, command.getOldId.name, command.getNewId.name).foreach { commit =>
|
||||||
// TODO extract issue id and add comment to issue
|
// TODO extract issue id and add comment to issue
|
||||||
logger.debug(commit.id + ":" + commit.shortMessage)
|
logger.debug(commit.id + ":" + commit.shortMessage)
|
||||||
|
|
||||||
|
println(owner + "/" + repository + " " + commit.id)
|
||||||
|
println(commit.fullMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO update repository last modified time.
|
// update repository last modified time.
|
||||||
|
updateLastActivityDate(owner, repository)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
@if(repository.repository.description.isDefined){
|
@if(repository.repository.description.isDefined){
|
||||||
<div>@repository.repository.description</div>
|
<div>@repository.repository.description</div>
|
||||||
}
|
}
|
||||||
<div><span class="description small">Last updated: @helpers.date(repository.repository.lastActivityDate)</span></div>
|
<div><span class="description small">Last updated: @helpers.datetime(repository.repository.lastActivityDate)</span></div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
@if(repository.repository.description.isDefined){
|
@if(repository.repository.description.isDefined){
|
||||||
<div>@repository.repository.description</div>
|
<div>@repository.repository.description</div>
|
||||||
}
|
}
|
||||||
<div><span class="description small">Last updated: @helpers.date(repository.repository.lastActivityDate)</span></div>
|
<div><span class="description small">Last updated: @helpers.datetime(repository.repository.lastActivityDate)</span></div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user