[github] Process commit message bodies ourselves

Has as a likely side-effect that we'd need to reimplement
linking of commit references...

GitOrigin-RevId: 7d4f9a83f9097a8fc0c35785da81aafdb931acbe
This commit is contained in:
Chris Lemaire
2024-05-16 15:44:31 +02:00
committed by intellij-monorepo-bot
parent 94a9bf70e0
commit 8987b51825
6 changed files with 14 additions and 20 deletions

View File

@@ -3,8 +3,7 @@ fragment commit on Commit {
committer {
...gitActorInfo
}
messageHeadline
messageBodyHTML
messageBody
committedDate
parents(first: 100) {
nodes {

View File

@@ -1,7 +1,7 @@
fragment commitShort on Commit {
...commitHash
url
messageHeadlineHTML
messageHeadline
author {
...gitActorInfo
}

View File

@@ -12,14 +12,13 @@ class GHCommit(id: String,
oid: String,
abbreviatedOid: String,
url: String,
@NlsSafe val messageHeadline: String,
@NlsSafe messageHeadlineHTML: String,
@NlsSafe val messageBodyHTML: String,
@NlsSafe messageHeadline: String,
@NlsSafe val messageBody: String,
author: GHGitActor?,
val committer: GHGitActor?,
val committedDate: Date,
@JsonProperty("parents") parents: GraphQLNodesDTO<GHCommitHash>)
: GHCommitShort(id, oid, abbreviatedOid, url, messageHeadlineHTML, author) {
: GHCommitShort(id, oid, abbreviatedOid, url, messageHeadline, author) {
val parents = parents.nodes
}

View File

@@ -9,7 +9,6 @@ open class GHCommitShort(id: String,
oid: String,
abbreviatedOid: String,
val url: String,
val messageHeadlineHTML: @NlsSafe String,
val messageHeadline: @NlsSafe String,
val author: GHGitActor?)
: GHCommitHash(id, oid, abbreviatedOid) {
}
: GHCommitHash(id, oid, abbreviatedOid)

View File

@@ -45,7 +45,7 @@ internal object GHPRDetailsComponentFactory {
val commitsAndBranches = JPanel(MigLayout(LC().emptyBorders().fill(), AC().gap("push"))).apply {
isOpaque = false
add(CodeReviewDetailsCommitsComponentFactory.create(scope, detailsVm.changesVm) { commit: GHCommit ->
createCommitsPopupPresenter(commit, detailsVm.securityService.ghostUser)
createCommitsPopupPresenter(project, commit, detailsVm.securityService.ghostUser)
})
add(CodeReviewDetailsBranchComponentFactory.create(scope, detailsVm.branchesVm))
}
@@ -71,9 +71,7 @@ internal object GHPRDetailsComponentFactory {
add(CodeReviewDetailsCommitInfoComponentFactory.create(
scope, detailsVm.changesVm.selectedCommit,
commitPresentation = { commit ->
createCommitsPopupPresenter(commit, detailsVm.securityService.ghostUser) {
it.convertToHtml(project)
}
createCommitsPopupPresenter(project, commit, detailsVm.securityService.ghostUser)
},
htmlPaneFactory = {
SimpleHtmlPane(addBrowserListener = false).apply {
@@ -95,12 +93,12 @@ internal object GHPRDetailsComponentFactory {
}
private fun createCommitsPopupPresenter(
project: Project,
commit: GHCommit,
ghostUser: GHUser,
issueProcessor: ((String) -> String)? = null
ghostUser: GHUser
) = CommitPresentation(
titleHtml = if (issueProcessor != null) issueProcessor(commit.messageHeadlineHTML) else commit.messageHeadlineHTML,
descriptionHtml = if (issueProcessor != null) issueProcessor(commit.messageBodyHTML) else commit.messageBodyHTML,
titleHtml = commit.messageHeadline.convertToHtml(project),
descriptionHtml = commit.messageBody.convertToHtml(project),
author = (commit.author?.user ?: ghostUser).getPresentableName(),
committedDate = commit.committedDate
)

View File

@@ -116,8 +116,7 @@ private fun createMockCommits(headRef: String): List<GHCommit> {
abbreviatedOid = "abbreviated_oid_$i",
url = "mockUrl$i",
messageHeadline = "Mock Commit Headline $i",
messageHeadlineHTML = "Mock Commit Headline HTML $i",
messageBodyHTML = "Mock Commit Body HTML $i",
messageBody = "Mock Commit Body $i",
author = mock(),
committer = mock(),
committedDate = Date(),