From 7bf02a75ca71aa80c02b6a9d710c0b11379ac189 Mon Sep 17 00:00:00 2001 From: Ivan Semenov Date: Mon, 15 Jun 2020 19:04:22 +0300 Subject: [PATCH] [github] Load less commit details for timeline GitOrigin-RevId: 3528e7a11395a17668d1271e8c43f519f2cf999a --- .../resources/graphql/fragment/commit.graphql | 13 +------------ .../resources/graphql/fragment/commitShort.graphql | 13 +++++++++++++ .../graphql/query/pullRequestCommits.graphql | 1 + .../graphql/query/pullRequestTimeline.graphql | 2 +- .../jetbrains/plugins/github/api/GHGQLRequests.kt | 6 +++--- .../jetbrains/plugins/github/api/data/GHCommit.kt | 7 +++---- .../plugins/github/api/data/GHCommitShort.kt | 9 +++++++++ .../api/data/pullrequest/GHPullRequestCommit.kt | 5 ++--- .../data/pullrequest/GHPullRequestCommitShort.kt | 7 ++++--- .../data/pullrequest/timeline/GHPRTimelineItem.kt | 4 ++-- .../ui/timeline/GHPRTimelineItemComponentFactory.kt | 8 ++++---- 11 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 plugins/github/resources/graphql/fragment/commitShort.graphql create mode 100644 plugins/github/src/org/jetbrains/plugins/github/api/data/GHCommitShort.kt diff --git a/plugins/github/resources/graphql/fragment/commit.graphql b/plugins/github/resources/graphql/fragment/commit.graphql index 972c52b15224..0441ab27361d 100644 --- a/plugins/github/resources/graphql/fragment/commit.graphql +++ b/plugins/github/resources/graphql/fragment/commit.graphql @@ -1,15 +1,5 @@ fragment commit on Commit { - ...commitHash - url - author { - name - email - avatarUrl - date - user { - url - } - } + ...commitShort committer { name email @@ -20,7 +10,6 @@ fragment commit on Commit { } } messageHeadline - messageHeadlineHTML messageBodyHTML parents(first: 100) { nodes { diff --git a/plugins/github/resources/graphql/fragment/commitShort.graphql b/plugins/github/resources/graphql/fragment/commitShort.graphql new file mode 100644 index 000000000000..ce0e3fa49ed0 --- /dev/null +++ b/plugins/github/resources/graphql/fragment/commitShort.graphql @@ -0,0 +1,13 @@ +fragment commitShort on Commit { + ...commitHash + messageHeadlineHTML + author { + name + email + avatarUrl + date + user { + url + } + } +} \ No newline at end of file diff --git a/plugins/github/resources/graphql/query/pullRequestCommits.graphql b/plugins/github/resources/graphql/query/pullRequestCommits.graphql index ac5ecaf9fa6a..a460a2af9f25 100644 --- a/plugins/github/resources/graphql/query/pullRequestCommits.graphql +++ b/plugins/github/resources/graphql/query/pullRequestCommits.graphql @@ -10,6 +10,7 @@ query($repoOwner: String!, $repoName: String!, $number: Int!, $pageSize: Int = 1 commit { ...commit } + url } } } diff --git a/plugins/github/resources/graphql/query/pullRequestTimeline.graphql b/plugins/github/resources/graphql/query/pullRequestTimeline.graphql index 9cd9526a69cb..64db96d0d634 100644 --- a/plugins/github/resources/graphql/query/pullRequestTimeline.graphql +++ b/plugins/github/resources/graphql/query/pullRequestTimeline.graphql @@ -6,7 +6,7 @@ fragment issueCommentInfo on IssueComment { fragment prCommitInfo on PullRequestCommit { ...nodeInfo commit { - ...commit + ...commitShort } url } diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/GHGQLRequests.kt b/plugins/github/src/org/jetbrains/plugins/github/api/GHGQLRequests.kt index d53f49d95f4b..f27b99b0530c 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/GHGQLRequests.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/api/GHGQLRequests.kt @@ -103,7 +103,7 @@ object GHGQLRequests { : GHConnection(pageInfo, nodes) fun commits(repository: GHRepositoryCoordinates, number: Long, - pagination: GHGQLRequestPagination? = null): GQLQuery> { + pagination: GHGQLRequestPagination? = null): GQLQuery> { return GQLQuery.TraversedParsed(repository.serverPath.toGraphQLUrl(), GHGQLQueries.pullRequestCommits, mapOf("repoOwner" to repository.repositoryPath.owner, "repoName" to repository.repositoryPath.repository, @@ -114,8 +114,8 @@ object GHGQLRequests { "repository", "pullRequest", "commits") } - private class CommitsConnection(pageInfo: GHGQLPageInfo, nodes: List) - : GHConnection(pageInfo, nodes) + private class CommitsConnection(pageInfo: GHGQLPageInfo, nodes: List) + : GHConnection(pageInfo, nodes) object Timeline { fun items(server: GithubServerPath, repoOwner: String, repoName: String, number: Long, diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/data/GHCommit.kt b/plugins/github/src/org/jetbrains/plugins/github/api/data/GHCommit.kt index bd09b221ef34..ff60a678d9ee 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/data/GHCommit.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/api/data/GHCommit.kt @@ -6,14 +6,13 @@ import com.fasterxml.jackson.annotation.JsonProperty class GHCommit(id: String, oid: String, abbreviatedOid: String, - val url: String, val messageHeadline: String, - val messageHeadlineHTML: String, + messageHeadlineHTML: String, val messageBodyHTML: String, - val author: GHGitActor?, + author: GHGitActor?, val committer: GHGitActor?, @JsonProperty("parents") parents: GHNodes) - : GHCommitHash(id, oid, abbreviatedOid) { + : GHCommitShort(id, oid, abbreviatedOid, messageHeadlineHTML, author) { val parents = parents.nodes } \ No newline at end of file diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/data/GHCommitShort.kt b/plugins/github/src/org/jetbrains/plugins/github/api/data/GHCommitShort.kt new file mode 100644 index 000000000000..51a134e42435 --- /dev/null +++ b/plugins/github/src/org/jetbrains/plugins/github/api/data/GHCommitShort.kt @@ -0,0 +1,9 @@ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package org.jetbrains.plugins.github.api.data + +open class GHCommitShort(id: String, + oid: String, + abbreviatedOid: String, + val messageHeadlineHTML: String, + val author: GHGitActor?) + : GHCommitHash(id, oid, abbreviatedOid) diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/GHPullRequestCommit.kt b/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/GHPullRequestCommit.kt index 1e858f28b4ca..3391d0024a27 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/GHPullRequestCommit.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/GHPullRequestCommit.kt @@ -1,11 +1,10 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.github.api.data.pullrequest import org.jetbrains.plugins.github.api.data.GHCommit import org.jetbrains.plugins.github.api.data.GHNode -import org.jetbrains.plugins.github.api.data.pullrequest.timeline.GHPRTimelineItem class GHPullRequestCommit(id: String, val commit: GHCommit, val url: String) - : GHNode(id), GHPRTimelineItem \ No newline at end of file + : GHNode(id) \ No newline at end of file diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/GHPullRequestCommitShort.kt b/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/GHPullRequestCommitShort.kt index f8661dfc8d7f..27382e79c9a5 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/GHPullRequestCommitShort.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/GHPullRequestCommitShort.kt @@ -1,7 +1,8 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.github.api.data.pullrequest -import org.jetbrains.plugins.github.api.data.GHCommit +import org.jetbrains.plugins.github.api.data.GHCommitShort import org.jetbrains.plugins.github.api.data.GHNode +import org.jetbrains.plugins.github.api.data.pullrequest.timeline.GHPRTimelineItem -class GHPullRequestCommitShort(id: String, val commit: GHCommit) : GHNode(id) \ No newline at end of file +class GHPullRequestCommitShort(id: String, val commit: GHCommitShort, val url: String) : GHNode(id), GHPRTimelineItem \ No newline at end of file diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/timeline/GHPRTimelineItem.kt b/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/timeline/GHPRTimelineItem.kt index 26b634e0b897..a7bfea13dd07 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/timeline/GHPRTimelineItem.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/api/data/pullrequest/timeline/GHPRTimelineItem.kt @@ -4,7 +4,7 @@ package org.jetbrains.plugins.github.api.data.pullrequest.timeline import com.fasterxml.jackson.annotation.JsonSubTypes import com.fasterxml.jackson.annotation.JsonTypeInfo import org.jetbrains.plugins.github.api.data.GHIssueComment -import org.jetbrains.plugins.github.api.data.pullrequest.GHPullRequestCommit +import org.jetbrains.plugins.github.api.data.pullrequest.GHPullRequestCommitShort import org.jetbrains.plugins.github.api.data.pullrequest.GHPullRequestReview import org.jetbrains.plugins.github.api.data.pullrequest.timeline.GHPRTimelineItem.Unknown @@ -60,7 +60,7 @@ AutomaticBaseChangeSucceededEvent | AutomaticBaseChangeFailedEvent defaultImpl = Unknown::class) @JsonSubTypes( JsonSubTypes.Type(name = "IssueComment", value = GHIssueComment::class), - JsonSubTypes.Type(name = "PullRequestCommit", value = GHPullRequestCommit::class), + JsonSubTypes.Type(name = "PullRequestCommit", value = GHPullRequestCommitShort::class), JsonSubTypes.Type(name = "PullRequestReview", value = GHPullRequestReview::class), JsonSubTypes.Type(name = "ReviewDismissedEvent", value = GHPRReviewDismissedEvent::class), diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineItemComponentFactory.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineItemComponentFactory.kt index 80171ad8e041..ca2ed33c4c96 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineItemComponentFactory.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineItemComponentFactory.kt @@ -17,7 +17,7 @@ import net.miginfocom.layout.LC import net.miginfocom.swing.MigLayout import org.intellij.lang.annotations.Language import org.jetbrains.plugins.github.api.data.* -import org.jetbrains.plugins.github.api.data.pullrequest.GHPullRequestCommit +import org.jetbrains.plugins.github.api.data.pullrequest.GHPullRequestCommitShort import org.jetbrains.plugins.github.api.data.pullrequest.GHPullRequestReview import org.jetbrains.plugins.github.api.data.pullrequest.GHPullRequestReviewState.* import org.jetbrains.plugins.github.api.data.pullrequest.timeline.GHPRTimelineEvent @@ -43,7 +43,7 @@ class GHPRTimelineItemComponentFactory(private val reviewDataProvider: GHPRRevie fun createComponent(item: GHPRTimelineItem): Item { try { return when (item) { - is GHPullRequestCommit -> Item(AllIcons.Vcs.CommitNode, commitTitle(item.commit)) + is GHPullRequestCommitShort -> Item(AllIcons.Vcs.CommitNode, commitTitle(item.commit, item.url)) is GHIssueComment -> createComponent(item) is GHPullRequestReview -> createComponent(item) @@ -105,9 +105,9 @@ class GHPRTimelineItemComponentFactory(private val reviewDataProvider: GHPRRevie }) } - private fun commitTitle(commit: GHCommit): JComponent { + private fun commitTitle(commit: GHCommitShort, commitUrl: String): JComponent { //language=HTML - val text = """${commit.messageHeadlineHTML} ${commit.abbreviatedOid}""" + val text = """${commit.messageHeadlineHTML} ${commit.abbreviatedOid}""" return HorizontalBox().apply { add(userAvatar(commit.author))