commit - dc516d22dbdaa1a1fc249bf404a61903d33135eb
commit + a0933fcf1efe249f441a565134b07c98252f2716
blob - 8c7b07b8439c7003f455c3e811f58ce6df93e266
blob + a933f224334bbd596ce536b35ffd62d72284b7de
--- src/main/kotlin/dev/nezzontli/gotvcs/GotCommandLineWrapper.kt
+++ src/main/kotlin/dev/nezzontli/gotvcs/GotCommandLineWrapper.kt
run(workDir, "fetch")
}
+ /** `got send`: sin argumentos, usa el remoto "origin" y la rama actual del work tree. */
+ @Throws(VcsException::class)
+ fun send(workDir: File): String = run(workDir, "send")
+
/**
* `got update`, formato de estado similar a `got status` (código + 2
* espacios + path). Cuando no hay nada que traer, got update imprime en
blob - /dev/null
blob + 6e656dc9c116d792c9b8f256e6048c9e83649b96 (mode 644)
--- /dev/null
+++ src/main/kotlin/dev/nezzontli/gotvcs/GotSendAction.kt
+package dev.nezzontli.gotvcs
+
+import com.intellij.notification.NotificationGroupManager
+import com.intellij.notification.NotificationType
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.progress.ProgressIndicator
+import com.intellij.openapi.progress.ProgressManager
+import com.intellij.openapi.progress.Task
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.vcs.ProjectLevelVcsManager
+import com.intellij.openapi.vcs.VcsException
+import com.intellij.openapi.vfs.VirtualFile
+import java.io.File
+
+/**
+ * Acción simple de menú para "got send" (el equivalente a "push"). No usa el
+ * diálogo nativo de Push de IntelliJ (Ctrl+Shift+K): eso requiere un
+ * PushSupport respaldado por Repository/RepositoryManager completos, similar
+ * en tamaño a todo lo demás de este plugin junto. Un botón que corre
+ * `got send` y reporta el resultado cubre el caso de uso real sin esa
+ * complejidad.
+ */
+class GotSendAction : AnAction() {
+
+ override fun update(e: AnActionEvent) {
+ e.presentation.isEnabledAndVisible = e.project?.let { gotRoots(it).isNotEmpty() } ?: false
+ }
+
+ override fun actionPerformed(e: AnActionEvent) {
+ val project = e.project ?: return
+ val roots = gotRoots(project)
+ if (roots.isEmpty()) return
+
+ val commandLine = GotCommandLineWrapper()
+ ProgressManager.getInstance().run(object : Task.Backgroundable(project, "got send", true) {
+ override fun run(indicator: ProgressIndicator) {
+ val errors = mutableListOf<String>()
+ for (root in roots) {
+ try {
+ commandLine.send(File(root.path))
+ } catch (ex: VcsException) {
+ errors.add("${root.path}: ${ex.message}")
+ }
+ }
+ val group = NotificationGroupManager.getInstance().getNotificationGroup("got")
+ if (errors.isEmpty()) {
+ group.createNotification("got send: cambios enviados correctamente", NotificationType.INFORMATION)
+ .notify(project)
+ } else {
+ group.createNotification("got send falló", errors.joinToString("\n"), NotificationType.ERROR)
+ .notify(project)
+ }
+ }
+ })
+ }
+
+ private fun gotRoots(project: Project): List<VirtualFile> {
+ val vcsManager = ProjectLevelVcsManager.getInstance(project)
+ val gotVcs = vcsManager.findVcsByName(GotVcs.NAME) ?: return emptyList()
+ return vcsManager.getRootsUnderVcs(gotVcs).toList()
+ }
+}
blob - 84c20b548b9559bf2dc671d497ac67f55abf9722
blob + 486504af66a48550b72d94b34025cfec46b1e585
--- src/main/resources/META-INF/plugin.xml
+++ src/main/resources/META-INF/plugin.xml
<vcsRootChecker implementation="dev.nezzontli.gotvcs.GotVcsRootChecker"/>
<applicationService serviceImplementation="dev.nezzontli.gotvcs.GotSettingsState"/>
<applicationConfigurable instance="dev.nezzontli.gotvcs.GotConfigurable" displayName="got" parentId="vcs"/>
+ <notificationGroup id="got" displayType="BALLOON"/>
</extensions>
+
+ <actions>
+ <action id="Got.Send" class="dev.nezzontli.gotvcs.GotSendAction" text="Send (got send)"
+ description="Envía los cambios locales al remoto vía got send">
+ <add-to-group group-id="Vcs.Operations.Popup" anchor="last"/>
+ </action>
+ </actions>
</idea-plugin>