GitSavvy
GitSavvy copied to clipboard
Feature request: able to abort `git: push` or any other git operations
In a project that I am working with, I have a pre-push hook that runs tests before pushing to upstream. The setting live_panel_output
is True
so the test results are displayed on live. When something is wrong, I do wish to abort the hook and the test.
It is not obvious to me how it could be implemented. Basically, we need to be able to run p.kill()
for the git command subprocess. Though I am worried about thread safeness.
Shouldn't a failing hook abort the command by itself?
Yes, at the very end after all the test suites are executed. I want to abort the tests as early as possible.
Okay, I think that's straight forward to implement. If you have a proc = Popen(...)
, you can friendly use proc.terminate()
to stop it. terminate
is afaik totally permissive t.i. you can call it multiple times or even when the proc
already is done.
What I would do: associate the current proc
with the active panel.id()
(which should be a ViewId
) in a simple global map. Like
panel_to_proc = {} # type: Dict[sublime.ViewId, Popen]
panel_to_proc[panel.id()] = proc
Then for the panels, mark them as usual with a type e.g. git_savvy.live_output_view
, and attach a handler e.g. ctrl+z
to them. (I just assume that panels receive key bindings as all other views.) In the TextCommand
get the proc for self.view.id()
and try to terminate()
it.
It could be that after that communicate
throws. Or GitSavvy because of the exitcode.