Skip to content

Instantly share code, notes, and snippets.

@dkandalov
Created October 9, 2012 09:24
Show Gist options
  • Save dkandalov/3857613 to your computer and use it in GitHub Desktop.
Save dkandalov/3857613 to your computer and use it in GitHub Desktop.
Intellij eval process files from your change list
import com.intellij.notification.*
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.vcs.changes.*
import javax.swing.SwingUtilities
static show(String htmlBody, String title = "", NotificationType notificationType = NotificationType.INFORMATION) {
SwingUtilities.invokeLater({
def notification = new Notification("", title, htmlBody, notificationType)
ApplicationManager.application.messageBus.syncPublisher(Notifications.TOPIC).notify(notification)
} as Runnable)
}
Collection<Change> changes = ChangeListManager.getInstance(project).getDefaultChangeList().getChanges()
def files = changes.collect { it.virtualFile.path }
show(files.join(" "))
new Thread({
files.each { file ->
try {
def builder = new ProcessBuilder("cmd", "/c", "c:/work/cc_checkout.cmd ${file}")
def proc = builder.start()
def sout = new StringBuffer()
def serr = new StringBuffer()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(5000)
if (proc.exitValue() != 0)
show(serr != null ? serr.toString() : "null serr")
else
show(sout != null ? sout.toString(): "null sout")
} catch (Exception e) {
show(e.toString())
}
}
}).start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment