Fix commit message presentation.

This commit is contained in:
takezoe
2013-06-22 14:19:08 +09:00
parent 0ee827eaf5
commit cc1be57d5f
6 changed files with 26 additions and 16 deletions

View File

@@ -49,10 +49,10 @@ object JGitUtil {
* *
* @param id the commit id * @param id the commit id
* @param time the commit time * @param time the commit time
* @param committer the commiter name * @param committer the committer name
* @param shortMessage the short message * @param shortMessage the short message
* @param fullMessage the full message * @param fullMessage the full message
* @param parents the list of parent commid id * @param parents the list of parent commit id
*/ */
case class CommitInfo(id: String, time: Date, committer: String, shortMessage: String, fullMessage: String, parents: List[String]){ case class CommitInfo(id: String, time: Date, committer: String, shortMessage: String, fullMessage: String, parents: List[String]){
@@ -60,10 +60,21 @@ object JGitUtil {
rev.getName, rev.getCommitterIdent.getWhen, rev.getCommitterIdent.getName, rev.getShortMessage, rev.getFullMessage, rev.getName, rev.getCommitterIdent.getWhen, rev.getCommitterIdent.getName, rev.getShortMessage, rev.getFullMessage,
rev.getParents().map(_.name).toList) rev.getParents().map(_.name).toList)
val description = { val summary = {
if(shortMessage == fullMessage){ val i = fullMessage.trim.indexOf("\n")
None val firstLine = if(i >= 0){
fullMessage.trim.substring(0, i).trim
} else { } else {
fullMessage
}
if(firstLine.length > shortMessage.length){
shortMessage
} else {
firstLine
}
}
val description = {
val i = fullMessage.trim.indexOf("\n") val i = fullMessage.trim.indexOf("\n")
if(i >= 0){ if(i >= 0){
Some(fullMessage.trim.substring(i).trim) Some(fullMessage.trim.substring(i).trim)
@@ -71,7 +82,6 @@ object JGitUtil {
None None
} }
} }
}
} }

View File

@@ -36,7 +36,7 @@ object helpers {
// convert issue id to link // convert issue id to link
.replaceAll("(^|\\W)#([0-9]+)(\\W|$)", "$1<a href=\"%s/%s/%s/issues/$2\">#$2</a>$3".format(context.path, repository.owner, repository.name)) .replaceAll("(^|\\W)#([0-9]+)(\\W|$)", "$1<a href=\"%s/%s/%s/issues/$2\">#$2</a>$3".format(context.path, repository.owner, repository.name))
// convert commit id to link // convert commit id to link
.replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", "$1<a href=\"%s/%s/%s/commit/$0\">$2</a>$3").format(context.path, repository.owner, repository.name)) .replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", "$1<a href=\"%s/%s/%s/commit/$2\">$2</a>$3").format(context.path, repository.owner, repository.name))
} }

View File

@@ -21,7 +21,7 @@
<div class="pull-left"> <div class="pull-left">
<a href="@path/@latestCommit.committer" class="username">@latestCommit.committer</a> <a href="@path/@latestCommit.committer" class="username">@latestCommit.committer</a>
<span class="description">@helpers.datetime(latestCommit.time)</span> <span class="description">@helpers.datetime(latestCommit.time)</span>
<a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@helpers.link(latestCommit.shortMessage, repository)</a> <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@helpers.link(latestCommit.summary, repository)</a>
</div> </div>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<a class="btn btn-mini" href="?raw=true">Raw</a> <a class="btn btn-mini" href="?raw=true">Raw</a>

View File

@@ -12,7 +12,7 @@
<div class="pull-right align-right"> <div class="pull-right align-right">
<a href="@path/@repository.owner/@repository.name/tree/@commit.id" class="btn btn-small">Browse code</a> <a href="@path/@repository.owner/@repository.name/tree/@commit.id" class="btn btn-small">Browse code</a>
</div> </div>
<div class="commit-log">@helpers.link(commit.shortMessage, repository)</div> <div class="commit-log">@helpers.link(commit.summary, repository)</div>
@if(commit.description.isDefined){ @if(commit.description.isDefined){
<pre class="commit-description">@helpers.link(commit.description.get, repository)</pre> <pre class="commit-description">@helpers.link(commit.description.get, repository)</pre>
} }

View File

@@ -30,7 +30,7 @@
<tr> <tr>
<td> <td>
<div class="pull-left"> <div class="pull-left">
<a href="@path/@repository.owner/@repository.name/commit/@commit.id" class="commit-message" style="font-weight: bold;">@helpers.link(commit.shortMessage, repository)</a> <a href="@path/@repository.owner/@repository.name/commit/@commit.id" class="commit-message" style="font-weight: bold;">@helpers.link(commit.summary, repository)</a>
@if(commit.description.isDefined){ @if(commit.description.isDefined){
<a href="javascript:void(0)" onclick="$('#description-@commit.id').toggle();" class="omit">...</a> <a href="javascript:void(0)" onclick="$('#description-@commit.id').toggle();" class="omit">...</a>
} }

View File

@@ -14,7 +14,7 @@
<table class="table table-file-list" style="border: 1px solid silver;"> <table class="table table-file-list" style="border: 1px solid silver;">
<tr> <tr>
<th colspan="4" style="font-weight: normal;"> <th colspan="4" style="font-weight: normal;">
<a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@helpers.link(latestCommit.shortMessage, repository)</a> <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@helpers.link(latestCommit.summary, repository)</a>
@if(latestCommit.description.isDefined){ @if(latestCommit.description.isDefined){
<a href="javascript:void(0)" onclick="$('#description-@latestCommit.id').toggle();" class="omit">...</a> <a href="javascript:void(0)" onclick="$('#description-@latestCommit.id').toggle();" class="omit">...</a>
} }