fix: commit message placeholders

This commit is contained in:
Carl-Robert Linnupuu 2024-06-17 16:54:06 +03:00
parent f2e89b429c
commit 9fc685a93a
6 changed files with 17 additions and 6 deletions

View file

@ -12,7 +12,7 @@ pluginUntilBuild =
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IC
platformVersion = LATEST-EAP-SNAPSHOT
platformVersion = 2024.1.2
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22

View file

@ -101,7 +101,9 @@ public class GenerateGitCommitMessageAction extends AnAction {
return ActionUpdateThread.EDT;
}
private CompletionEventListener<String> getEventListener(Project project, CommitWorkflowUi commitWorkflowUi) {
private CompletionEventListener<String> getEventListener(
Project project,
CommitWorkflowUi commitWorkflowUi) {
return new CompletionEventListener<>() {
private final StringBuilder messageBuilder = new StringBuilder();

View file

@ -26,7 +26,12 @@ class DatePlaceholderStrategy : PlaceholderStrategy {
class BranchNamePlaceholderStrategy(val project: Project) : PlaceholderStrategy {
override fun getReplacementValue(): String {
return try {
"BRANCH-UNKNOWN"
val repositories = GitUtil.getRepositoryManager(project).repositories
if (repositories.isEmpty() || repositories.size != 1) {
return "BRANCH-UNKNOWN"
}
GitBranchUtil.getBranchNameOrRev(repositories[0])
} catch (ignore: Exception) {
"BRANCH-UNKNOWN"
}

View file

@ -1,3 +1,6 @@
Branch: {BRANCH_NAME}
Date: {DATE_ISO_8601}
Write a short and descriptive git commit message for the following git diff.
Use imperative mood, present tense, active voice and verbs.
Your entire response will be passed directly into git commit.

View file

@ -4,6 +4,7 @@ import com.intellij.codeInsight.inline.completion.session.InlineCompletionSessio
import com.intellij.openapi.editor.VisualPosition
import com.intellij.openapi.util.TextRange
import com.intellij.testFramework.PlatformTestUtil
import ee.carlrobert.codegpt.settings.service.llama.LlamaSettings
import ee.carlrobert.codegpt.settings.service.openai.OpenAISettings
import ee.carlrobert.codegpt.util.file.FileUtil
import ee.carlrobert.llm.client.http.RequestEntity
@ -16,8 +17,7 @@ import testsupport.IntegrationTest
class CodeCompletionServiceTest : IntegrationTest() {
fun testApplyCompletionNextWordInlay() {
useLlamaService()
OpenAISettings.getCurrentState().isCodeCompletionsEnabled = true
useLlamaService(true)
myFixture.configureByText(
"CompletionTest.java",
FileUtil.getResourceContent("/codecompletions/code-completion-file.txt")

View file

@ -45,9 +45,10 @@ interface ShortcutsTestMixin {
GeneralSettings.getCurrentState().selectedService = ServiceType.YOU
}
fun useLlamaService() {
fun useLlamaService(codeCompletionsEnabled: Boolean = false) {
GeneralSettings.getCurrentState().selectedService = ServiceType.LLAMA_CPP
LlamaSettings.getCurrentState().serverPort = null
LlamaSettings.getCurrentState().isCodeCompletionsEnabled = codeCompletionsEnabled
}
fun useGoogleService() {