diff --git a/src/main/scala/util/JGitUtil.scala b/src/main/scala/util/JGitUtil.scala index ee8043d..669330e 100644 --- a/src/main/scala/util/JGitUtil.scala +++ b/src/main/scala/util/JGitUtil.scala @@ -61,11 +61,15 @@ 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 e7d060a..9af5c36 100644 --- a/src/main/scala/view/helpers.scala +++ b/src/main/scala/view/helpers.scala @@ -26,6 +26,18 @@ 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 3078a52..0d4a8cc 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] | } [
---|