diff --git a/src/main/scala/util/JGitUtil.scala b/src/main/scala/util/JGitUtil.scala index ee8043dc1..669330e3c 100644 --- a/src/main/scala/util/JGitUtil.scala +++ b/src/main/scala/util/JGitUtil.scala @@ -61,11 +61,15 @@ object JGitUtil { rev.getParents().map(_.name).toList) val description = { - val i = fullMessage.trim.indexOf("\n") - if(i >= 0){ - Some(fullMessage.trim.substring(i).trim) - } else { + if(shortMessage == fullMessage){ None + } else { + val i = fullMessage.trim.indexOf("\n") + if(i >= 0){ + Some(fullMessage.trim.substring(i).trim) + } else { + None + } } } diff --git a/src/main/scala/view/helpers.scala b/src/main/scala/view/helpers.scala index e7d060ac8..9af5c36f0 100644 --- a/src/main/scala/view/helpers.scala +++ b/src/main/scala/view/helpers.scala @@ -26,6 +26,18 @@ object helpers { Html(Markdown.toHtml(value, repository, enableWikiLink, enableCommitLink, enableIssueLink)) } + /** + * Converts issue id and commit id to link. + */ + def link(value: String, repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context): Html = + Html(value + // escape HTML tags + .replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """) + // convert issue id to link + .replaceAll("(^|\\W)#([0-9]+)(\\W|$)", "$1#$2$3".format(context.path, repository.owner, repository.name)) + // convert commit id to link + .replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", "$1$2$3").format(context.path, repository.owner, repository.name)) + } /** diff --git a/src/main/twirl/repo/blob.scala.html b/src/main/twirl/repo/blob.scala.html index 3078a5252..0d4a8cc74 100644 --- a/src/main/twirl/repo/blob.scala.html +++ b/src/main/twirl/repo/blob.scala.html @@ -21,7 +21,7 @@
@commit.description.get+
@helpers.link(commit.description.get, repository)}
| - + @if(latestCommit.description.isDefined){ ... } @if(latestCommit.description.isDefined){ - + } | @helpers.datetime(file.time) | -[@file.committer] | +[@file.committer] | }
|---|