Skip to content

Commit 2b63bac

Browse files
committed
Only ever catch InteractionStopped at the highest level
1 parent 69e0ab6 commit 2b63bac

File tree

3 files changed

+40
-42
lines changed

3 files changed

+40
-42
lines changed

docs/man/git-machete.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
2727
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
2828
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
2929
..
30-
.TH "GIT-MACHETE" "1" "Oct 10, 2025" "" "git-machete"
30+
.TH "GIT-MACHETE" "1" "Nov 11, 2025" "" "git-machete"
3131
.SH NAME
3232
git-machete \- git-machete 3.37.1
3333
.sp

git_machete/cli.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,13 @@ def set_utils_global_variables(parsed_args: argparse.Namespace) -> None:
502502

503503

504504
def launch(orig_args: List[str]) -> None:
505+
try:
506+
launch_interruptible(orig_args)
507+
except InteractionStopped:
508+
pass
509+
510+
511+
def launch_interruptible(orig_args: List[str]) -> None:
505512
initial_current_directory: Optional[str] = utils.get_current_directory_or_none()
506513

507514
try:
@@ -744,10 +751,7 @@ def warn_on_deprecation(*, flag: str, revision: AnyRevision, revision_str: str)
744751
fail_on_missing_current_user_for_my_open_prs=True)
745752
elif subcommand == f"create-{pr_or_mr}":
746753
current_branch = git.get_current_branch()
747-
try:
748-
github_or_gitlab_client.sync_before_creating_pull_request(opt_yes=cli_opts.opt_yes)
749-
except InteractionStopped:
750-
return
754+
github_or_gitlab_client.sync_before_creating_pull_request(opt_yes=cli_opts.opt_yes)
751755
github_or_gitlab_client.create_pull_request(
752756
head=current_branch,
753757
opt_base=cli_opts.opt_base,
@@ -952,8 +956,6 @@ def main() -> None:
952956
except (MacheteException, UnderlyingGitException) as e:
953957
print(e, file=sys.stderr)
954958
sys.exit(ExitCode.MACHETE_EXCEPTION)
955-
except InteractionStopped: # pragma: no cover
956-
pass
957959

958960

959961
if __name__ == "__main__":

git_machete/client/traverse.py

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
SquashMergeDetection)
88
from git_machete.client.with_code_hosting import MacheteClientWithCodeHosting
99
from git_machete.code_hosting import PullRequest
10-
from git_machete.exceptions import (InteractionStopped, MacheteException,
11-
UnexpectedMacheteException)
10+
from git_machete.exceptions import MacheteException, UnexpectedMacheteException
1211
from git_machete.git_operations import (GitContext, LocalBranchShortName,
1312
SyncToRemoteStatus)
1413
from git_machete.utils import (bold, flat_map, fmt, get_pretty_choices,
@@ -350,39 +349,36 @@ def traverse(
350349

351350
if needs_remote_sync:
352351
any_action_suggested = True
353-
try:
354-
if s == SyncToRemoteStatus.BEHIND_REMOTE:
355-
assert remote is not None
356-
self._handle_behind_state(branch=current_branch, remote=remote, opt_yes=opt_yes)
357-
elif s == SyncToRemoteStatus.AHEAD_OF_REMOTE:
358-
assert remote is not None
359-
self._handle_ahead_state(
360-
current_branch=current_branch,
361-
remote=remote,
362-
is_called_from_traverse=True,
363-
opt_push_tracked=opt_push_tracked,
364-
opt_yes=opt_yes)
365-
elif s == SyncToRemoteStatus.DIVERGED_FROM_AND_OLDER_THAN_REMOTE:
366-
self._handle_diverged_and_older_state(current_branch, opt_yes=opt_yes)
367-
elif s == SyncToRemoteStatus.DIVERGED_FROM_AND_NEWER_THAN_REMOTE:
368-
assert remote is not None
369-
self._handle_diverged_and_newer_state(
370-
current_branch=current_branch,
371-
remote=remote,
372-
opt_push_tracked=opt_push_tracked,
373-
opt_yes=opt_yes)
374-
elif s == SyncToRemoteStatus.UNTRACKED:
375-
self._handle_untracked_state(
376-
branch=current_branch,
377-
is_called_from_traverse=True,
378-
is_called_from_code_hosting=False,
379-
opt_push_untracked=opt_push_untracked,
380-
opt_push_tracked=opt_push_tracked,
381-
opt_yes=opt_yes)
382-
else:
383-
raise UnexpectedMacheteException(f"Unexpected SyncToRemoteStatus: {s}.")
384-
except InteractionStopped:
385-
return
352+
if s == SyncToRemoteStatus.BEHIND_REMOTE:
353+
assert remote is not None
354+
self._handle_behind_state(branch=current_branch, remote=remote, opt_yes=opt_yes)
355+
elif s == SyncToRemoteStatus.AHEAD_OF_REMOTE:
356+
assert remote is not None
357+
self._handle_ahead_state(
358+
current_branch=current_branch,
359+
remote=remote,
360+
is_called_from_traverse=True,
361+
opt_push_tracked=opt_push_tracked,
362+
opt_yes=opt_yes)
363+
elif s == SyncToRemoteStatus.DIVERGED_FROM_AND_OLDER_THAN_REMOTE:
364+
self._handle_diverged_and_older_state(current_branch, opt_yes=opt_yes)
365+
elif s == SyncToRemoteStatus.DIVERGED_FROM_AND_NEWER_THAN_REMOTE:
366+
assert remote is not None
367+
self._handle_diverged_and_newer_state(
368+
current_branch=current_branch,
369+
remote=remote,
370+
opt_push_tracked=opt_push_tracked,
371+
opt_yes=opt_yes)
372+
elif s == SyncToRemoteStatus.UNTRACKED:
373+
self._handle_untracked_state(
374+
branch=current_branch,
375+
is_called_from_traverse=True,
376+
is_called_from_code_hosting=False,
377+
opt_push_untracked=opt_push_untracked,
378+
opt_push_tracked=opt_push_tracked,
379+
opt_yes=opt_yes)
380+
else:
381+
raise UnexpectedMacheteException(f"Unexpected SyncToRemoteStatus: {s}.")
386382

387383
if needs_create_pr:
388384
any_action_suggested = True

0 commit comments

Comments
 (0)