8000 branch: do not show remote messages for async git actions · ag-python-qt/git-cola@e1b594e · GitHub
[go: up one dir, main page]

Skip to content

Commit e1b594e

Browse files
committed
branch: do not show remote messages for async git actions
We inadvertently wired-up the remote messages dialog for all async git actions in the branch widget. We should only show these for Push and Pull, and only when the checkbox has been enabled in the main Push and Pull dialogs. Closes: git-cola#1363 Reported-by: Zauberin Stardreamer @zauberparacelsus on github Signed-off-by: David Aguilar <davvid@gmail.com>
1 parent caa122c commit e1b594e

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

CHANGES.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
.. _v4.4.1:
2+
3+
v4.4.1
4+
======
5+
6+
Usability, bells and whistles
7+
-----------------------------
8+
* The remote messages dialog is now displayed for the Pull and Push actions in the
9+
Branches widget only. These dialogs are disabled by default and enabled in the
10+
main Push and Pull dialogs.
11+
(`#1363 <https://github.com/git-cola/git-cola/issues/1363>`_)
12+
113
.. _v4.4.0:
214

315
v4.4.0

cola/widgets/branch.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,19 +422,26 @@ def _update_branches_finished(self, task):
422422
if status_str:
423423
item.setText(0, f'{item.text(0)}\t{status_str}')
424424

425-
def git_action_async(self, action, args, kwarg=None, update_refs=False):
425+
def git_action_async(
426+
self, action, args, kwarg=None, update_refs=False, remote_messages=False
427+
):
426428
"""Execute a git action in a background task"""
427429
if kwarg is None:
428430
kwarg = {}
429431
task = AsyncGitActionTask(self.git_helper, action, args, kwarg, update_refs)
430432
progress = standard.progress(
431433
N_('Executing action %s') % action, N_('Updating'), self
432434
)
435+
if remote_messages:
436+
result_handler = remotemessage.from_context(self.context)
437+
else:
438+
result_handler = None
439+
433440
self.runtask.start(
434441
task,
435442
progress=progress,
436443
finish=self.git_action_completed,
437-
result=remotemessage.with_context(self.context),
444+
result=result_handler,
438445
)
439446

440447
def git_action_completed(self, task):
@@ -449,12 +456,20 @@ def push_action(self):
449456
context = self.context
450457
branch = self.selected_refname()
451458
remote_branch = gitcmds.tracked_branch(context, branch)
459+
context.settings.load()
460+
push_settings = context.settings.get_gui_state_by_name('push')
461+
remote_messages = push_settings.get('remote_messages', False)
452462
if remote_branch:
453463
remote, branch_name = gitcmds.parse_remote_branch(remote_branch)
454464
if remote and branch_name:
455465
# we assume that user wants to "Push" the selected local
456466
# branch to a remote with same name
457-
self.git_action_async('push', [remote, branch_name], update_refs=True)
467+
self.git_action_async(
468+
'push',
469+
[remote, branch_name],
470+
update_refs=True,
471+
remote_messages=remote_messages,
472+
)
458473

459474
def rename_action(self):
460475
"""Rename the selected branch"""
@@ -472,10 +487,18 @@ def pull_action(self):
472487
if not branch:
473488
return
474489
remote_branch = gitcmds.tracked_branch(context, branch)
490+
context.settings.load()
491+
pull_settings = context.settings.get_gui_state_by_name('pull')
492+
remote_messages = pull_settings.get('remote_messages', False)
475493
if remote_branch:
476494
remote, branch_name = gitcmds.parse_remote_branch(remote_branch)
477495
if remote and branch_name:
478-
self.git_action_async('pull', [remote, branch_name], update_refs=True)
496+
self.git_action_async(
497+
'pull',
498+
[remote, branch_name],
499+
update_refs=True,
500+
remote_messages=remote_messages,
501+
)
479502

480503
def delete_action(self):
481504
"""Delete the selected branch"""

cola/widgets/remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ def action_callback(self):
644644
# Use a thread to update in the background
645645
task = ActionTask(model_action, remote, kwargs)
646646
if remote_messages:
647-
result = remotemessage.with_context(self.context)
647+
result = remotemessage.from_context(self.context)
648648
else:
649649
result = None
650650
self.runtask.start(

cola/widgets/remotemessage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def show(context, message):
1515
view.exec_()
1616

1717

18-
def with_context(context):
18+
def from_context(context):
1919
"""Return a closure for the `result` callback from RunTask.start()"""
2020

2121
def show_result(result):

0 commit comments

Comments
 (0)
0