diff --git a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala index 6fc90d7..eea1578 100644 --- a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala @@ -13,7 +13,7 @@ import gitbucket.core.util.SyntaxSugars._ import gitbucket.core.util.Implicits._ import gitbucket.core.util.Directory._ -import gitbucket.core.model.{Account, WebHook} +import gitbucket.core.model.{Account, CommitState, CommitStatus, WebHook} import gitbucket.core.service.WebHookService._ import gitbucket.core.view import gitbucket.core.view.helpers @@ -157,13 +157,24 @@ val (branchName, path) = repository.splitPath(multiParams("splat").head) val page = params.get("page").flatMap(_.toIntOpt).getOrElse(1) + def getStatuses(sha: String): List[CommitStatus] = { + getCommitStatues(repository.owner, repository.name, sha) + } + + def getSummary(statuses: List[CommitStatus]): (CommitState, String) = { + val stateMap = statuses.groupBy(_.state) + val state = CommitState.combine(stateMap.keySet) + val summary = stateMap.map{ case (keyState, states) => states.size+" "+keyState.name }.mkString(", ") + state -> summary + } + using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git => JGitUtil.getCommitLog(git, branchName, page, 30, path) match { case Right((logs, hasNext)) => html.commits(if(path.isEmpty) Nil else path.split("/").toList, branchName, repository, logs.splitWith{ (commit1, commit2) => view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime) - }, page, hasNext, hasDeveloperRole(repository.owner, repository.name, context.loginAccount)) + }, page, hasNext, hasDeveloperRole(repository.owner, repository.name, context.loginAccount), getStatuses, getSummary) case Left(_) => NotFound() } } @@ -670,11 +681,11 @@ private def archiveRepository(name: String, suffix: String, repository: RepositoryService.RepositoryInfo): Unit = { val revision = name.stripSuffix(suffix) - + using(Git.open(getRepositoryDir(repository.owner, repository.name))){ git => val oid = git.getRepository.resolve(revision) val revCommit = JGitUtil.getRevCommitFromId(git, oid) - val sha1 = oid.getName() + val sha1 = oid.getName() val repositorySuffix = (if(sha1.startsWith(revision)) sha1 else revision).replace('/','-') val filename = repository.name + "-" + repositorySuffix + suffix diff --git a/src/main/twirl/gitbucket/core/repo/commits.scala.html b/src/main/twirl/gitbucket/core/repo/commits.scala.html index 0eca2c9..69d72a0 100644 --- a/src/main/twirl/gitbucket/core/repo/commits.scala.html +++ b/src/main/twirl/gitbucket/core/repo/commits.scala.html @@ -4,7 +4,9 @@ commits: Seq[Seq[gitbucket.core.util.JGitUtil.CommitInfo]], page: Int, hasNext: Boolean, - hasWritePermission: Boolean)(implicit context: gitbucket.core.controller.Context) + hasWritePermission: Boolean, + getStatuses: String => List[gitbucket.core.model.CommitStatus], + getSummary: List[gitbucket.core.model.CommitStatus] => (gitbucket.core.model.CommitState, String))(implicit context: gitbucket.core.controller.Context) @import gitbucket.core.view.helpers @gitbucket.core.html.main(s"${repository.owner}/${repository.name}", Some(repository)) { @gitbucket.core.html.menu("files", repository){ @@ -63,6 +65,30 @@ } @helpers.user(commit.committerName, commit.committerEmailAddress, "username") committed @gitbucket.core.helper.html.datetimeago(commit.commitTime) + @defining({ + val statuses = getStatuses(commit.id) + val (summary, summaryText) = getSummary(statuses) + (statuses, summary, summaryText) + }){ case (statuses, summaryState, summaryText) => + @if(!statuses.isEmpty){ + @helpers.commitStateIcon(summaryState) + @helpers.commitStateText(summaryState, commit.id) + — @summaryText checks + Show all checks +
+ @statuses.map{ status => +
+ @helpers.commitStateIcon(status.state) + @status.context + @status.description.map { desc => — @desc } + + @status.targetUrl.map { url => — Details } + +
+ } +
+ } + } @@ -86,5 +112,20 @@ } + } }