Skip to content

Commit faaa7c9

Browse files
committed
fix: fix IDEA 222 error in get changes data
1 parent 73d08e6 commit faaa7c9

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package cc.unitmesh.devti.vcs
22

33
import com.intellij.openapi.actionSystem.AnActionEvent
4-
import com.intellij.openapi.vcs.VcsDataKeys
4+
import com.intellij.openapi.components.service
55
import com.intellij.openapi.vcs.changes.Change
66

77
object VcsUtil {
88
fun getChanges(e: AnActionEvent): List<Change>? {
9-
val commitWorkflowUi = e.getData(VcsDataKeys.CHANGES) ?: return null
10-
return commitWorkflowUi.toList()
9+
val prompting = e.project?.service<VcsPrompting>() ?: return null
10+
val changes = prompting.getChanges()
11+
return changes.ifEmpty { null }
1112
}
1213
}

src/main/kotlin/cc/unitmesh/devti/actions/vcs/CommitMessageSuggestionAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CommitMessageSuggestionAction : ChatBaseAction() {
4444
}
4545

4646
val prompting = e.project?.service<VcsPrompting>()
47-
val changes: List<Change> = prompting?.hasChanges() ?: listOf()
47+
val changes: List<Change> = prompting?.getChanges() ?: listOf()
4848

4949
e.presentation.icon = AutoDevStatus.Ready.icon
5050
e.presentation.isEnabled = changes.isNotEmpty()

src/main/kotlin/cc/unitmesh/devti/actions/vcs/PrepushReviewAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class PrepushReviewAction : CodeReviewAction() {
1616
}
1717

1818
val prompting = e.project?.service<VcsPrompting>()
19-
val changes: List<Change> = prompting?.hasChanges() ?: listOf()
19+
val changes: List<Change> = prompting?.getChanges() ?: listOf()
2020

2121
e.presentation.isEnabled = changes.isNotEmpty()
2222
}

src/main/kotlin/cc/unitmesh/devti/vcs/VcsPrompting.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class VcsPrompting(private val project: Project) {
8282
}
8383

8484

85-
fun hasChanges(): List<Change> {
85+
fun getChanges(): List<Change> {
8686
val changeListManager = ChangeListManager.getInstance(project)
8787
return changeListManager.changeLists.flatMap { it.changes }
8888
}

0 commit comments

Comments
 (0)