commit a0933fcf1efe249f441a565134b07c98252f2716 from: ale date: Thu Jul 23 22:07:45 2026 UTC Agrega 'Send (got send)' al menú VCS Se evaluó implementar el diálogo nativo de Push (Ctrl+Shift+K) vía PushSupport, pero requiere Repository/RepositoryManager completos (GotRepository, GotPushSource/Target/Pusher/OutgoingCommitsProvider, etc.) -- tamaño comparable a todo el resto del plugin junto, con APIs sin documentar que habría que descubrir a los tumbos. Se optó por un AnAction simple: 'got send' (sin argumentos, usa 'origin' y la rama actual por defecto) corrido en background sobre las raíces got del proyecto, con el resultado reportado vía notificación. Cubre el caso de uso real sin esa complejidad. Registrado en el grupo Vcs.Operations.Popup, junto a las demás acciones de VCS. commit - dc516d22dbdaa1a1fc249bf404a61903d33135eb commit + a0933fcf1efe249f441a565134b07c98252f2716 blob - 8c7b07b8439c7003f455c3e811f58ce6df93e266 blob + a933f224334bbd596ce536b35ffd62d72284b7de --- src/main/kotlin/dev/nezzontli/gotvcs/GotCommandLineWrapper.kt +++ src/main/kotlin/dev/nezzontli/gotvcs/GotCommandLineWrapper.kt @@ -157,6 +157,10 @@ class GotCommandLineWrapper { 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 @@ -0,0 +1,63 @@ +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() + 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 { + 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 @@ -18,5 +18,13 @@ + + + + + + +