Skip to content

Commit

Permalink
cmds: add a way to launch actions in the background
Browse files Browse the repository at this point in the history
Setting `guitool.<name>.background` will now launch custom commands in
the background, which avoids blocking the UI.

Related-to: #44

Suggested-by: Leho Kraav <leho@kraav.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Jun 25, 2014
1 parent 5ade7fe commit 9ad15ce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cola/cmds.py
Expand Up @@ -982,7 +982,10 @@ def do(self):
Interaction.log(N_('Running command: %s') % title)
cmd = ['sh', '-c', cmd]

if opts.get('noconsole'):
if opts.get('background'):
core.fork(cmd)
status, out, err = (0, '', '')
elif opts.get('noconsole'):
status, out, err = core.run_command(cmd)
else:
status, out, err = Interaction.run_command(title, cmd)
Expand All @@ -991,7 +994,7 @@ def do(self):
out and (N_('Output: %s') % out) or '',
err and (N_('Errors: %s') % err) or '')

if not opts.get('norescan'):
if not opts.get('background') and not opts.get('norescan'):
self.model.update_status()
return status

Expand Down
6 changes: 6 additions & 0 deletions share/doc/git-cola/git-cola.rst
Expand Up @@ -489,6 +489,12 @@ receives the name of the tool as GIT_GUITOOL, the name of the currently
selected file as FILENAME, and the name of the current branch as CUR_BRANCH
(if the head is detached, CUR_BRANCH is empty).

guitool.<name>.background
-------------------------
Run the command in the background (similar to editing and difftool actions).
This avoids blocking the GUI. Setting `background` to `true` implies
`noconsole` and `norescan`.

guitool.<name>.needsfile
------------------------
Run the tool only if a diff is selected in the GUI. It guarantees that
Expand Down
3 changes: 3 additions & 0 deletions share/doc/git-cola/relnotes.rst
Expand Up @@ -50,6 +50,9 @@ Usability, bells and whistles

https://github.com/git-cola/git-cola/issues/292

* Custom `git config`-defined actions can now be run in the
background by setting `guitool.<name>.background` to `true`.

Fixes
-----
* We now use bold fonts instead of SmallCaps to avoid
Expand Down

0 comments on commit 9ad15ce

Please sign in to comment.