diff --git a/src/main/scala/servlet/GitRepositoryServlet.scala b/src/main/scala/servlet/GitRepositoryServlet.scala index 742fbb8..a25fb0f 100644 --- a/src/main/scala/servlet/GitRepositoryServlet.scala +++ b/src/main/scala/servlet/GitRepositoryServlet.scala @@ -75,7 +75,7 @@ commands.asScala.foreach { command => JGitUtil.getCommitLog(git, command.getOldId.name, command.getNewId.name).foreach { commit => // TODO extract issue id and add comment to issue - logger.debug(commit.id + ":" + commit.message) + logger.debug(commit.id + ":" + commit.shortMessage) } } } diff --git a/src/main/scala/util/JGitUtil.scala b/src/main/scala/util/JGitUtil.scala index e67de0e..e423949 100644 --- a/src/main/scala/util/JGitUtil.scala +++ b/src/main/scala/util/JGitUtil.scala @@ -50,11 +50,22 @@ * @param id the commit id * @param time the commit time * @param committer the commiter name - * @param message the commit message + * @param shortMessage the short message + * @param fullMessage the full message */ - case class CommitInfo(id: String, time: Date, committer: String, message: String){ + case class CommitInfo(id: String, time: Date, committer: String, shortMessage: String, fullMessage: String){ def this(rev: org.eclipse.jgit.revwalk.RevCommit) = - this(rev.getName, rev.getCommitterIdent.getWhen, rev.getCommitterIdent.getName, rev.getFullMessage) + this(rev.getName, rev.getCommitterIdent.getWhen, rev.getCommitterIdent.getName, rev.getShortMessage, rev.getFullMessage) + + val description = { + val i = fullMessage.trim.indexOf("\n") + if(i >= 0){ + Some(fullMessage.trim.substring(i).trim) + } else { + None + } + } + } case class DiffInfo(changeType: ChangeType, oldPath: String, newPath: String, oldContent: Option[String], newContent: Option[String]) diff --git a/src/main/scala/view/helpers.scala b/src/main/scala/view/helpers.scala index 8ecead7..5912a94 100644 --- a/src/main/scala/view/helpers.scala +++ b/src/main/scala/view/helpers.scala @@ -14,11 +14,28 @@ * Format java.util.Date to "yyyy/MM/dd". */ def date(date: Date): String = new SimpleDateFormat("yyyy/MM/dd").format(date) - + + def format(value: String): Html = + Html(value.replaceAll(" ", " ").replaceAll("\t", "    ").replaceAll("\n", "
")) + // TODO escape html tags using HtmlEscapeUtils (Commons Lang) - def format(value: String): Html = Html( - value.replaceAll(" ", " ").replaceAll("\t", "    ").replaceAll("\n", "
")) - + def formatCommitLog(message: String): Html = { + val i = message.trim.indexOf("\n") + val (firstLine, description) = if(i >= 0){ + (message.trim.substring(0, i).trim, Some(message.trim.substring(i).trim)) + } else { + (message.trim, None) + } + + val sb = new StringBuilder() + sb.append("
").append(format(firstLine).text).append("
") + if(description.isDefined){ + sb.append("
").append(format(description.get).text).append("
") + } + + Html(sb.toString) + } + /** * Converts Markdown of Wiki pages to HTML. */ @@ -27,15 +44,15 @@ Html(Markdown.toHtml(value, repository, enableWikiLink, enableCommitLink, enableIssueLink)) } - /** - * Cut the given string by specified length. - */ - def cut(message: String, length: Int): String = { - if(message.length > length){ - message.substring(0, length) + "..." - } else { - message - } - } +// /** +// * Cut the given string by specified length. +// */ +// def cut(message: String, length: Int): String = { +// if(message.length > length){ +// message.substring(0, length) + "..." +// } else { +// message +// } +// } } \ No newline at end of file diff --git a/src/main/twirl/repo/blob.scala.html b/src/main/twirl/repo/blob.scala.html index 5e33563..e463594 100644 --- a/src/main/twirl/repo/blob.scala.html +++ b/src/main/twirl/repo/blob.scala.html @@ -21,7 +21,7 @@
@latestCommit.committer @helpers.datetime(latestCommit.time) - @helpers.cut(latestCommit.message, 100) + @latestCommit.shortMessage
Raw diff --git a/src/main/twirl/repo/commit.scala.html b/src/main/twirl/repo/commit.scala.html index a217b39..bfa2fe5 100644 --- a/src/main/twirl/repo/commit.scala.html +++ b/src/main/twirl/repo/commit.scala.html @@ -2,13 +2,13 @@ @import context._ @import view.helpers @import org.eclipse.jgit.diff.DiffEntry.ChangeType -@html.main(helpers.cut(commit.message, 20)){ +@html.main(commit.shortMessage){ @html.header("code", repository) @navtab(branch, repository, "commits") diff --git a/src/main/twirl/repo/commits.scala.html b/src/main/twirl/repo/commits.scala.html index a53a9bb..caddbd4 100644 --- a/src/main/twirl/repo/commits.scala.html +++ b/src/main/twirl/repo/commits.scala.html @@ -30,7 +30,16 @@ - + }
-
@helpers.format(commit.message)
+
@helpers.formatCommitLog(commit.fullMessage)
@branch
- @helpers.cut(commit.message, 100)
+ @commit.shortMessage + @if(commit.description.isDefined){ + ... + } +
+ @if(commit.description.isDefined){ + + }
@commit.committer @helpers.datetime(commit.time) diff --git a/src/main/twirl/repo/files.scala.html b/src/main/twirl/repo/files.scala.html index 8551d1a..dac06a3 100644 --- a/src/main/twirl/repo/files.scala.html +++ b/src/main/twirl/repo/files.scala.html @@ -16,7 +16,7 @@
@helpers.datetime(file.time)@helpers.cut(file.message, 60) [@file.committer]@file.message [@file.committer]
diff --git a/src/main/twirl/wiki/wikihistory.scala.html b/src/main/twirl/wiki/wikihistory.scala.html index 284b08b..e38f42f 100644 --- a/src/main/twirl/wiki/wikihistory.scala.html +++ b/src/main/twirl/wiki/wikihistory.scala.html @@ -36,7 +36,7 @@ @commit.committer @helpers.datetime(commit.time): - @commit.message + @commit.shortMessage } diff --git a/src/main/webapp/assets/common/css/gitbucket.css b/src/main/webapp/assets/common/css/gitbucket.css index 045a23d..c695c12 100644 --- a/src/main/webapp/assets/common/css/gitbucket.css +++ b/src/main/webapp/assets/common/css/gitbucket.css @@ -97,6 +97,10 @@ border-bottom: 1px solid silver; } +div.commit-log div.description { + font-weight: normal; +} + h1.wiki-title { margin-top: 0px; }