File tree Expand file tree Collapse file tree 2 files changed +25
-14
lines changed
goland/src/main/kotlin/cc/unitmesh/go/provider/testing
src/main/kotlin/cc/unitmesh/devti/actions/vcs Expand file tree Collapse file tree 2 files changed +25
-14
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import com.goide.GoLanguage
10
10
import com.goide.execution.testing.GoTestRunConfiguration
11
11
import com.goide.psi.*
12
12
import com.intellij.execution.configurations.RunProfile
13
+ import com.intellij.openapi.application.ReadAction
13
14
import com.intellij.openapi.application.runReadAction
14
15
import com.intellij.openapi.project.Project
15
16
import com.intellij.openapi.roots.TestSourcesFilter
@@ -40,20 +41,22 @@ class GoWriteTestService : WriteTestService() {
40
41
importList.map { it.text }
41
42
}
42
43
43
- val currentObject = when (underTestElement) {
44
- is GoTypeDeclaration ,
45
- is GoTypeSpec -> {
46
- GoStructContextBuilder ().getClassContext(underTestElement, false )?.format()
44
+ val currentObject = ReadAction .compute<String , Throwable > {
45
+ return @compute when (underTestElement) {
46
+ is GoTypeDeclaration ,
47
+ is GoTypeSpec -> {
48
+ GoStructContextBuilder ().getClassContext(underTestElement, false )?.format()
49
+ }
50
+
51
+ is GoFunctionOrMethodDeclaration -> GoMethodContextBuilder ().getMethodContext(
52
+ underTestElement,
53
+ false ,
54
+ false
55
+ )
56
+ ?.format()
57
+
58
+ else -> null
47
59
}
48
-
49
- is GoFunctionOrMethodDeclaration -> GoMethodContextBuilder ().getMethodContext(
50
- underTestElement,
51
- false ,
52
- false
53
- )
54
- ?.format()
55
-
56
- else -> null
57
60
}
58
61
59
62
return TestFileContext (
Original file line number Diff line number Diff line change @@ -87,6 +87,13 @@ class CommitMessageSuggestionAction : ChatBaseAction() {
87
87
}
88
88
}
89
89
90
+ /* *
91
+ * Finds example commit messages based on the project's VCS log, takes the first three commits.
92
+ * If the no user or user has not committed anything yet, the current branch name is used instead.
93
+ *
94
+ * @param project The project for which to find example commit messages.
95
+ * @return A string containing example commit messages, or null if no example messages are found.
96
+ */
90
97
private fun findExampleCommitMessages (project : Project ): String? {
91
98
val logProviders = VcsProjectLog .getLogProviders(project)
92
99
val entry = logProviders.entries.firstOrNull() ? : return null
@@ -125,7 +132,8 @@ class CommitMessageSuggestionAction : ChatBaseAction() {
125
132
val commitIds = commits.map { it.id.asString() }
126
133
127
134
logProvider.readMetadata(root, commitIds) {
128
- builder.append(it.fullMessage).append(" \n " )
135
+ val shortMsg = it.fullMessage.split(" \n " ).firstOrNull() ? : it.fullMessage
136
+ builder.append(shortMsg).append(" \n " )
129
137
}
130
138
131
139
return builder.toString()
You can’t perform that action at this time.
0 commit comments