@(issue: Option[gitbucket.core.model.Issue],
comments: List[gitbucket.core.model.Comment],
hasWritePermission: Boolean,
repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
pullreq: Option[gitbucket.core.model.PullRequest] = None)(implicit context: gitbucket.core.controller.Context)
@import context._
@import gitbucket.core.view.helpers._
@import gitbucket.core.model.CommitComment
@if(issue.isDefined){
@avatarLink(issue.get.openedUserName, 48)
}
@issueOrPullRequest()={ @if(issue.isDefined && issue.get.isPullRequest)( "pull request" )else( "issue" ) }
@comments.map {
case comment: gitbucket.core.model.IssueComment => {
@if(comment.action != "close" && comment.action != "reopen" && comment.action != "delete_branch"
&& comment.action != "commit" && comment.action != "refer"){
@avatarLink(comment.commentedUserName, 48)
}
@if(comment.action == "commit"){
@defining({
val (content, id) = " ([a-f0-9]{40})$".r.findFirstMatchIn(comment.content)
.map(m => (m.before.toString -> Some(m.group(1))))
.getOrElse(comment.content -> None)
val head = content.take(100).takeWhile(_ != '\n')
(id, head, if(head == content){ None }else{ Some(content.drop(head.length).dropWhile(_ == '\n')) }.filter(_.nonEmpty))
}){ case (commitId, head, rest) =>
@commitId.map{ id =>
@id.substring(0, 7)
}
@link(head, repository)
@rest.map{ content =>
...
@link(content, repository)
}
}
}
@if(comment.action == "refer"){
@defining(comment.content.split(":")){ case Array(issueId, rest @ _*) =>
@issueLink(repository, issueId.toInt): @rest.mkString(":")
}
}
@if(comment.action == "merge"){
}
@if(comment.action == "close" || comment.action == "close_comment"){
}
@if(comment.action == "reopen" || comment.action == "reopen_comment"){
}
@if(comment.action == "delete_branch"){
}
}
case comment: CommitComment => {
@helper.html.commitcomment(comment, hasWritePermission, repository, pullreq.map(_.commitIdTo))
}
}