Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: able to abort git: push or any other git operations #1184

Open
randy3k opened this issue Oct 24, 2019 · 3 comments
Open

Feature request: able to abort git: push or any other git operations #1184

randy3k opened this issue Oct 24, 2019 · 3 comments

Comments

@randy3k
Copy link
Collaborator

randy3k commented Oct 24, 2019

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.

@kaste
Copy link
Collaborator

kaste commented Oct 24, 2019

Shouldn't a failing hook abort the command by itself?

@randy3k
Copy link
Collaborator Author

randy3k commented Oct 24, 2019

Yes, at the very end after all the test suites are executed. I want to abort the tests as early as possible.

@kaste
Copy link
Collaborator

kaste commented Oct 24, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants