generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(git): fix 222 & 233 version GitUtil class for committing local ch…
…anges #101 This commit adds a new class `GitUtil` in the `cc.unitmesh.devti.language.git` package, which provides a `doCommit` function. This function takes a project, a local change list, and a commit message as parameters, and commits the changes using the IntelliJ VCS API. This new class will be used to commit local changes in the `CommitInsCommand` class. Additionally, the `CommitInsCommand` class is modified to use the `GitUtil` class for performing commits. The commit also includes minor changes to the `README.md` file. Refs #233
- Loading branch information
Showing
4 changed files
with
34 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
exts/devins-lang/src/222/main/kotlin/cc/unitmesh/devti/language/git/GitUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cc.unitmesh.devti.language.git | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vcs.changes.CommitContext | ||
import com.intellij.openapi.vcs.changes.LocalChangeList | ||
import com.intellij.vcs.commit.ChangeListCommitState | ||
import com.intellij.vcs.commit.SingleChangeListCommitter | ||
|
||
object GitUtil { | ||
fun doCommit(myProject: Project, list: LocalChangeList, commitMsg: String) { | ||
val commitState = ChangeListCommitState(list, list.changes.toList(), commitMsg) | ||
val committer = SingleChangeListCommitter(myProject, commitState, CommitContext(), commitMsg, false) | ||
committer.runCommit("Commit", false) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
exts/devins-lang/src/233/main/kotlin/cc/unitmesh/devti/language/git/GitUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cc.unitmesh.devti.language.git | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vcs.changes.CommitContext | ||
import com.intellij.openapi.vcs.changes.LocalChangeList | ||
import com.intellij.vcs.commit.ChangeListCommitState | ||
import com.intellij.vcs.commit.LocalChangesCommitter | ||
|
||
object GitUtil { | ||
fun doCommit(myProject: Project, list: LocalChangeList, commitMsg: String) { | ||
val commitState = ChangeListCommitState(list, list.changes.toList(), commitMsg) | ||
val committer = LocalChangesCommitter(myProject, commitState, CommitContext()) | ||
committer.runCommit("Commit", false) | ||
} | ||
} |
10 changes: 3 additions & 7 deletions
10
.../devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/CommitInsCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
package cc.unitmesh.devti.language.compiler.exec | ||
|
||
import cc.unitmesh.devti.language.git.GitUtil | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vcs.changes.ChangeListManager | ||
import com.intellij.openapi.vcs.changes.CommitContext | ||
import com.intellij.openapi.vcs.changes.LocalChangeList | ||
import com.intellij.vcs.commit.ChangeListCommitState | ||
import com.intellij.vcs.commit.LocalChangesCommitter | ||
|
||
class CommitInsCommand(val myProject: Project, val commitMsg: String) : InsCommand { | ||
override fun execute(): String { | ||
val changeListManager = ChangeListManager.getInstance(myProject) | ||
changeListManager.changeLists.forEach { | ||
val list: LocalChangeList = changeListManager.getChangeList(it.id) ?: return@forEach | ||
val commitState = ChangeListCommitState(it, list.changes.toList(), commitMsg) | ||
val committer = LocalChangesCommitter(myProject, commitState, CommitContext()) | ||
committer.runCommit("Commit", false) | ||
GitUtil.doCommit(myProject, list, commitMsg) | ||
} | ||
|
||
return "Committing..." | ||
} | ||
} | ||
} |