File tree Expand file tree Collapse file tree 4 files changed +7
-6
lines changed
222/main/kotlin/cc/unitmesh/devti/vcs
main/kotlin/cc/unitmesh/devti Expand file tree Collapse file tree 4 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 1
1
package cc.unitmesh.devti.vcs
2
2
3
3
import com.intellij.openapi.actionSystem.AnActionEvent
4
- import com.intellij.openapi.vcs.VcsDataKeys
4
+ import com.intellij.openapi.components.service
5
5
import com.intellij.openapi.vcs.changes.Change
6
6
7
7
object VcsUtil {
8
8
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 }
11
12
}
12
13
}
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ class CommitMessageSuggestionAction : ChatBaseAction() {
44
44
}
45
45
46
46
val prompting = e.project?.service<VcsPrompting >()
47
- val changes: List <Change > = prompting?.hasChanges () ? : listOf ()
47
+ val changes: List <Change > = prompting?.getChanges () ? : listOf ()
48
48
49
49
e.presentation.icon = AutoDevStatus .Ready .icon
50
50
e.presentation.isEnabled = changes.isNotEmpty()
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class PrepushReviewAction : CodeReviewAction() {
16
16
}
17
17
18
18
val prompting = e.project?.service<VcsPrompting >()
19
- val changes: List <Change > = prompting?.hasChanges () ? : listOf ()
19
+ val changes: List <Change > = prompting?.getChanges () ? : listOf ()
20
20
21
21
e.presentation.isEnabled = changes.isNotEmpty()
22
22
}
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ class VcsPrompting(private val project: Project) {
82
82
}
83
83
84
84
85
- fun hasChanges (): List <Change > {
85
+ fun getChanges (): List <Change > {
86
86
val changeListManager = ChangeListManager .getInstance(project)
87
87
return changeListManager.changeLists.flatMap { it.changes }
88
88
}
You can’t perform that action at this time.
0 commit comments