diff -r ea6181255423 -r 671c1c8fbf1c src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt --- a/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt Sat Jul 22 15:07:23 2023 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt Sat Jul 22 22:32:04 2023 +0200 @@ -99,6 +99,8 @@ } } +data class CommitLink(val url: String, val hash: String, val message: String) + class IssueDetailView( val issue: Issue, val comments: List, @@ -110,10 +112,12 @@ /** * Optional resource key to an error message for the relation editor. */ - val relationError: String? + val relationError: String?, + commitRefs: List ) : View() { val relationTypes = RelationType.values() val linkableIssues = projectIssues.filterNot { it.id == issue.id } + val commitLinks: List private val parser: Parser private val renderer: HtmlRenderer @@ -131,8 +135,24 @@ for (comment in comments) { comment.commentFormatted = formatMarkdown(comment.comment) } + + val commitBaseUrl = project.repoUrl + commitLinks = (if (commitBaseUrl == null || project.vcs == VcsType.None) emptyList() else commitRefs.map { + CommitLink(buildCommitUrl(commitBaseUrl, project.vcs, it.hash), it.hash, it.message) + }) } + private fun buildCommitUrl(baseUrl: String, vcs: VcsType, hash: String): String = + with (StringBuilder(baseUrl)) { + if (!endsWith("/")) append('/') + when (vcs) { + VcsType.Mercurial -> append("rev/") + else -> append("commit/") + } + append(hash) + toString() + } + private fun formatEmojis(text: String) = text .replace("(/)", "✅") .replace("(x)", "❌")