mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
Merge branch 'master' into add-features-to-ldapauth
This commit is contained in:
@@ -58,6 +58,9 @@ Run the following commands in `Terminal` to
|
|||||||
|
|
||||||
Release Notes
|
Release Notes
|
||||||
--------
|
--------
|
||||||
|
### 1.11.1 - 06 Mar 2014
|
||||||
|
- Bug fix
|
||||||
|
|
||||||
### 1.11 - 01 Mar 2014
|
### 1.11 - 01 Mar 2014
|
||||||
- Base URL for redirection, notification and repository URL box is configurable
|
- Base URL for redirection, notification and repository URL box is configurable
|
||||||
- Remove ```--https``` option because it's possible to substitute in the base url
|
- Remove ```--https``` option because it's possible to substitute in the base url
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
// Don't set content type via Accept header.
|
// Don't set content type via Accept header.
|
||||||
override def format(implicit request: HttpServletRequest) = ""
|
override def format(implicit request: HttpServletRequest) = ""
|
||||||
|
|
||||||
override def doFilter(request: ServletRequest, response: ServletResponse, chain: FilterChain) {
|
override def doFilter(request: ServletRequest, response: ServletResponse, chain: FilterChain): Unit = try {
|
||||||
val httpRequest = request.asInstanceOf[HttpServletRequest]
|
val httpRequest = request.asInstanceOf[HttpServletRequest]
|
||||||
val httpResponse = response.asInstanceOf[HttpServletResponse]
|
val httpResponse = response.asInstanceOf[HttpServletResponse]
|
||||||
val context = request.getServletContext.getContextPath
|
val context = request.getServletContext.getContextPath
|
||||||
@@ -56,12 +56,25 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
// Scalatra actions
|
// Scalatra actions
|
||||||
super.doFilter(request, response, chain)
|
super.doFilter(request, response, chain)
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
contextCache.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val contextCache = new java.lang.ThreadLocal[Context]()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the context object for the request.
|
* Returns the context object for the request.
|
||||||
*/
|
*/
|
||||||
implicit def context: Context = Context(servletContext.getContextPath, LoginAccount, request)
|
implicit def context: Context = {
|
||||||
|
contextCache.get match {
|
||||||
|
case null => {
|
||||||
|
val context = Context(loadSystemSettings().baseUrl.getOrElse(servletContext.getContextPath), LoginAccount, request)
|
||||||
|
contextCache.set(context)
|
||||||
|
context
|
||||||
|
}
|
||||||
|
case context => context
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private def LoginAccount: Option[Account] = session.getAs[Account](Keys.Session.LoginAccount)
|
private def LoginAccount: Option[Account] = session.getAs[Account](Keys.Session.LoginAccount)
|
||||||
|
|
||||||
@@ -130,7 +143,7 @@ abstract class ControllerBase extends ScalatraFilter
|
|||||||
*/
|
*/
|
||||||
case class Context(path: String, loginAccount: Option[Account], request: HttpServletRequest){
|
case class Context(path: String, loginAccount: Option[Account], request: HttpServletRequest){
|
||||||
|
|
||||||
lazy val currentPath = request.getRequestURI.substring(path.length)
|
lazy val currentPath = request.getRequestURI.substring(request.getContextPath.length)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get object from cache.
|
* Get object from cache.
|
||||||
|
|||||||
@@ -228,16 +228,16 @@ trait PullRequestsControllerBase extends ControllerBase {
|
|||||||
val oldBranch = JGitUtil.getDefaultBranch(oldGit, originRepository).get._2
|
val oldBranch = JGitUtil.getDefaultBranch(oldGit, originRepository).get._2
|
||||||
val newBranch = JGitUtil.getDefaultBranch(newGit, forkedRepository).get._2
|
val newBranch = JGitUtil.getDefaultBranch(newGit, forkedRepository).get._2
|
||||||
|
|
||||||
redirect(s"${context.path}/${forkedRepository.owner}/${forkedRepository.name}/compare/${originUserName}:${oldBranch}...${newBranch}")
|
redirect(s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${originUserName}:${oldBranch}...${newBranch}")
|
||||||
}
|
}
|
||||||
} getOrElse NotFound
|
} getOrElse NotFound
|
||||||
}
|
}
|
||||||
case _ => {
|
case _ => {
|
||||||
using(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))){ git =>
|
using(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))){ git =>
|
||||||
JGitUtil.getDefaultBranch(git, forkedRepository).map { case (_, defaultBranch) =>
|
JGitUtil.getDefaultBranch(git, forkedRepository).map { case (_, defaultBranch) =>
|
||||||
redirect(s"${context.path}/${forkedRepository.owner}/${forkedRepository.name}/compare/${defaultBranch}...${defaultBranch}")
|
redirect(s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${defaultBranch}...${defaultBranch}")
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
redirect(s"${context.path}/${forkedRepository.owner}/${forkedRepository.name}")
|
redirect(s"/${forkedRepository.owner}/${forkedRepository.name}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,44 +82,45 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve(id))
|
||||||
|
|
||||||
@scala.annotation.tailrec
|
@scala.annotation.tailrec
|
||||||
def getPathObjectId(path: String, walk: TreeWalk): ObjectId = walk.next match {
|
def getPathObjectId(path: String, walk: TreeWalk): Option[ObjectId] = walk.next match {
|
||||||
case true if(walk.getPathString == path) => walk.getObjectId(0)
|
case true if(walk.getPathString == path) => Some(walk.getObjectId(0))
|
||||||
case true => getPathObjectId(path, walk)
|
case true => getPathObjectId(path, walk)
|
||||||
|
case false => None
|
||||||
}
|
}
|
||||||
|
|
||||||
val objectId = using(new TreeWalk(git.getRepository)){ treeWalk =>
|
using(new TreeWalk(git.getRepository)){ treeWalk =>
|
||||||
treeWalk.addTree(revCommit.getTree)
|
treeWalk.addTree(revCommit.getTree)
|
||||||
treeWalk.setRecursive(true)
|
treeWalk.setRecursive(true)
|
||||||
getPathObjectId(path, treeWalk)
|
getPathObjectId(path, treeWalk)
|
||||||
}
|
} map { objectId =>
|
||||||
|
if(raw){
|
||||||
if(raw){
|
// Download
|
||||||
// Download
|
defining(JGitUtil.getContent(git, objectId, false).get){ bytes =>
|
||||||
defining(JGitUtil.getContent(git, objectId, false).get){ bytes =>
|
contentType = FileUtil.getContentType(path, bytes)
|
||||||
contentType = FileUtil.getContentType(path, bytes)
|
bytes
|
||||||
bytes
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Viewer
|
|
||||||
val large = FileUtil.isLarge(git.getRepository.getObjectDatabase.open(objectId).getSize)
|
|
||||||
val viewer = if(FileUtil.isImage(path)) "image" else if(large) "large" else "other"
|
|
||||||
val bytes = if(viewer == "other") JGitUtil.getContent(git, objectId, false) else None
|
|
||||||
|
|
||||||
val content = if(viewer == "other"){
|
|
||||||
if(bytes.isDefined && FileUtil.isText(bytes.get)){
|
|
||||||
// text
|
|
||||||
JGitUtil.ContentInfo("text", bytes.map(StringUtil.convertFromByteArray))
|
|
||||||
} else {
|
|
||||||
// binary
|
|
||||||
JGitUtil.ContentInfo("binary", None)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// image or large
|
// Viewer
|
||||||
JGitUtil.ContentInfo(viewer, None)
|
val large = FileUtil.isLarge(git.getRepository.getObjectDatabase.open(objectId).getSize)
|
||||||
}
|
val viewer = if(FileUtil.isImage(path)) "image" else if(large) "large" else "other"
|
||||||
|
val bytes = if(viewer == "other") JGitUtil.getContent(git, objectId, false) else None
|
||||||
|
|
||||||
repo.html.blob(id, repository, path.split("/").toList, content, new JGitUtil.CommitInfo(revCommit))
|
val content = if(viewer == "other"){
|
||||||
}
|
if(bytes.isDefined && FileUtil.isText(bytes.get)){
|
||||||
|
// text
|
||||||
|
JGitUtil.ContentInfo("text", bytes.map(StringUtil.convertFromByteArray))
|
||||||
|
} else {
|
||||||
|
// binary
|
||||||
|
JGitUtil.ContentInfo("binary", None)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// image or large
|
||||||
|
JGitUtil.ContentInfo(viewer, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
repo.html.blob(id, repository, path.split("/").toList, content, new JGitUtil.CommitInfo(revCommit))
|
||||||
|
}
|
||||||
|
} getOrElse NotFound
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -266,7 +267,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
repo.html.guide(repository)
|
repo.html.guide(repository)
|
||||||
} else {
|
} else {
|
||||||
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git =>
|
||||||
val revisions = Seq(if(revstr.isEmpty) repository.repository.defaultBranch else revstr, repository.branchList.head)
|
//val revisions = Seq(if(revstr.isEmpty) repository.repository.defaultBranch else revstr, repository.branchList.head)
|
||||||
// get specified commit
|
// get specified commit
|
||||||
JGitUtil.getDefaultBranch(git, repository, revstr).map { case (objectId, revision) =>
|
JGitUtil.getDefaultBranch(git, repository, revstr).map { case (objectId, revision) =>
|
||||||
defining(JGitUtil.getRevCommitFromId(git, objectId)){ revCommit =>
|
defining(JGitUtil.getRevCommitFromId(git, objectId)){ revCommit =>
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import Q.interpolation
|
|||||||
import model._
|
import model._
|
||||||
import util.Implicits._
|
import util.Implicits._
|
||||||
import util.StringUtil._
|
import util.StringUtil._
|
||||||
import util.StringUtil
|
|
||||||
|
|
||||||
trait IssuesService {
|
trait IssuesService {
|
||||||
import IssuesService._
|
import IssuesService._
|
||||||
@@ -120,16 +119,10 @@ trait IssuesService {
|
|||||||
// get issues and comment count and labels
|
// get issues and comment count and labels
|
||||||
searchIssueQuery(repos, condition, filterUser, onlyPullRequest)
|
searchIssueQuery(repos, condition, filterUser, onlyPullRequest)
|
||||||
.innerJoin(IssueOutline).on { (t1, t2) => t1.byIssue(t2.userName, t2.repositoryName, t2.issueId) }
|
.innerJoin(IssueOutline).on { (t1, t2) => t1.byIssue(t2.userName, t2.repositoryName, t2.issueId) }
|
||||||
.leftJoin (IssueLabels) .on { case ((t1, t2), t3) => t1.byIssue(t3.userName, t3.repositoryName, t3.issueId) }
|
.sortBy { case (t1, t2) =>
|
||||||
.leftJoin (Labels) .on { case (((t1, t2), t3), t4) => t3.byLabel(t4.userName, t4.repositoryName, t4.labelId) }
|
|
||||||
.map { case (((t1, t2), t3), t4) =>
|
|
||||||
(t1, t2.commentCount, t4.labelId.?, t4.labelName.?, t4.color.?)
|
|
||||||
}
|
|
||||||
.sortBy(_._4) // labelName
|
|
||||||
.sortBy { case (t1, commentCount, _,_,_) =>
|
|
||||||
(condition.sort match {
|
(condition.sort match {
|
||||||
case "created" => t1.registeredDate
|
case "created" => t1.registeredDate
|
||||||
case "comments" => commentCount
|
case "comments" => t2.commentCount
|
||||||
case "updated" => t1.updatedDate
|
case "updated" => t1.updatedDate
|
||||||
}) match {
|
}) match {
|
||||||
case sort => condition.direction match {
|
case sort => condition.direction match {
|
||||||
@@ -139,6 +132,11 @@ trait IssuesService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.drop(offset).take(limit)
|
.drop(offset).take(limit)
|
||||||
|
.leftJoin (IssueLabels) .on { case ((t1, t2), t3) => t1.byIssue(t3.userName, t3.repositoryName, t3.issueId) }
|
||||||
|
.leftJoin (Labels) .on { case (((t1, t2), t3), t4) => t3.byLabel(t4.userName, t4.repositoryName, t4.labelId) }
|
||||||
|
.map { case (((t1, t2), t3), t4) =>
|
||||||
|
(t1, t2.commentCount, t4.labelId.?, t4.labelName.?, t4.color.?)
|
||||||
|
}
|
||||||
.list
|
.list
|
||||||
.splitWith { (c1, c2) =>
|
.splitWith { (c1, c2) =>
|
||||||
c1._1.userName == c2._1.userName &&
|
c1._1.userName == c2._1.userName &&
|
||||||
@@ -316,7 +314,7 @@ trait IssuesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def closeIssuesFromMessage(message: String, userName: String, owner: String, repository: String) = {
|
def closeIssuesFromMessage(message: String, userName: String, owner: String, repository: String) = {
|
||||||
StringUtil.extractCloseId(message).foreach { issueId =>
|
extractCloseId(message).foreach { issueId =>
|
||||||
for(issue <- getIssue(owner, repository, issueId) if !issue.closed){
|
for(issue <- getIssue(owner, repository, issueId) if !issue.closed){
|
||||||
createComment(owner, repository, userName, issue.issueId, "Close", "close")
|
createComment(owner, repository, userName, issue.issueId, "Close", "close")
|
||||||
updateClosed(owner, repository, issue.issueId, true)
|
updateClosed(owner, repository, issue.issueId, true)
|
||||||
|
|||||||
Reference in New Issue
Block a user