@(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)
@user(issue.get.openedUserName, styleClass="username strong") commented @helper.html.datetimeago(issue.get.registeredDate) @if(hasWritePermission || loginAccount.map(_.userName == issue.get.openedUserName).getOrElse(false)){ }
@markdown( markdown = issue.get.content getOrElse "No description provided.", repository = repository, enableWikiLink = false, enableRefsLink = true, enableLineBreaks = true, enableTaskList = true, hasWritePermission = hasWritePermission )
} @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)
@user(comment.commentedUserName, styleClass="username strong") @if(comment.action == "comment"){ commented } else { referenced the @issueOrPullRequest() } @helper.html.datetimeago(comment.registeredDate) @if(comment.action != "commit" && comment.action != "merge" && comment.action != "refer" && (hasWritePermission || loginAccount.map(_.userName == comment.commentedUserName).getOrElse(false))){   }
@markdown( markdown = comment.content, repository = repository, enableWikiLink = false, enableRefsLink = true, enableLineBreaks = true, enableTaskList = true, hasWritePermission = hasWritePermission )
} @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) =>
@avatar(comment.commentedUserName, 16) @user(comment.commentedUserName, styleClass="username strong") added a commit that referenced this @issueOrPullRequest() @helper.html.datetimeago(comment.registeredDate)
@commitId.map{ id => @id.substring(0, 7) } @link(head, repository) @rest.map{ content => ... }
} } @if(comment.action == "refer"){
@avatar(comment.commentedUserName, 16) @user(comment.commentedUserName, styleClass="username strong") referenced the @issueOrPullRequest() @helper.html.datetimeago(comment.registeredDate)
@defining(comment.content.split(":")){ case Array(issueId, rest @ _*) => @issueLink(repository, issueId.toInt): @rest.mkString(":") }
} @if(comment.action == "merge"){
@avatar(comment.commentedUserName, 16) @user(comment.commentedUserName, styleClass="username strong") merged commit @pullreq.map(_.commitIdTo.substring(0, 7)) into @if(pullreq.get.requestUserName == repository.owner){ @pullreq.map(_.branch) from @pullreq.map(_.requestBranch) } else { @pullreq.map(_.userName):@pullreq.map(_.branch) from @pullreq.map(_.requestUserName):@pullreq.map(_.requestBranch) } @helper.html.datetimeago(comment.registeredDate)
} @if(comment.action == "close" || comment.action == "close_comment"){
@avatar(comment.commentedUserName, 16) @user(comment.commentedUserName, styleClass="username strong") closed this @issueOrPullRequest() @helper.html.datetimeago(comment.registeredDate)
} @if(comment.action == "reopen" || comment.action == "reopen_comment"){
@avatar(comment.commentedUserName, 16) @user(comment.commentedUserName, styleClass="username strong") reopened the @issueOrPullRequest() @helper.html.datetimeago(comment.registeredDate)
} @if(comment.action == "delete_branch"){
@avatar(comment.commentedUserName, 16) @user(comment.commentedUserName, styleClass="username strong") deleted the @pullreq.map(_.requestBranch) branch @helper.html.datetimeago(comment.registeredDate)
} } case comment: CommitComment => { @helper.html.commitcomment(comment, hasWritePermission, repository, pullreq.map(_.commitIdTo)) } }