From c67105ae4a2cc8a71d7a339264b41b7fa300ad69 Mon Sep 17 00:00:00 2001 From: DPR Date: Sun, 28 Jan 2024 23:25:03 +0800 Subject: [PATCH 1/5] Bubble up error message --- cherry_picker/cherry_picker.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker.py index 3e59f39..762b4d9 100755 --- a/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker.py @@ -803,8 +803,9 @@ def cherry_pick_cli( config=config, chosen_config_path=chosen_config_path, ) - except InvalidRepoException: - click.echo(f"You're not inside a {config['repo']} repo right now! \U0001F645") + except InvalidRepoException as ire: + click.echo("Error validate sha") + click.echo(ire.args[0]) sys.exit(-1) except ValueError as exc: ctx.fail(exc) From 20d5f69da87a25b13f87b13ac5dc2aa39eea83d9 Mon Sep 17 00:00:00 2001 From: DPR Date: Mon, 5 Feb 2024 22:22:40 +0800 Subject: [PATCH 2/5] Revert "Bubble up error message" This reverts commit c67105ae4a2cc8a71d7a339264b41b7fa300ad69. --- cherry_picker/cherry_picker.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker.py index 762b4d9..3e59f39 100755 --- a/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker.py @@ -803,9 +803,8 @@ def cherry_pick_cli( config=config, chosen_config_path=chosen_config_path, ) - except InvalidRepoException as ire: - click.echo("Error validate sha") - click.echo(ire.args[0]) + except InvalidRepoException: + click.echo(f"You're not inside a {config['repo']} repo right now! \U0001F645") sys.exit(-1) except ValueError as exc: ctx.fail(exc) From 4ce1793da14b8ab25e0c1ad5c253d06ede5eeb6d Mon Sep 17 00:00:00 2001 From: DPR Date: Mon, 5 Feb 2024 22:33:44 +0800 Subject: [PATCH 3/5] Bubble up error message --- cherry_picker/cherry_picker.py | 4 ++-- cherry_picker/test_cherry_picker.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker.py index 3e59f39..aeaa0f1 100755 --- a/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker.py @@ -803,8 +803,8 @@ def cherry_pick_cli( config=config, chosen_config_path=chosen_config_path, ) - except InvalidRepoException: - click.echo(f"You're not inside a {config['repo']} repo right now! \U0001F645") + except InvalidRepoException as ire: + click.echo(ire.args[0]) sys.exit(-1) except ValueError as exc: ctx.fail(exc) diff --git a/cherry_picker/test_cherry_picker.py b/cherry_picker/test_cherry_picker.py index 3a9f670..7a20b17 100644 --- a/cherry_picker/test_cherry_picker.py +++ b/cherry_picker/test_cherry_picker.py @@ -406,7 +406,10 @@ def test_is_cpython_repo(subprocess_check_output): def test_is_not_cpython_repo(): # use default CPython sha to fail on this repo - with pytest.raises(InvalidRepoException): + with pytest.raises( + InvalidRepoException, + match=r"The sha listed in the branch name, \w+, is not present in the repository", + ): CherryPicker("origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", ["3.6"]) @@ -1148,9 +1151,7 @@ def test_backport_pause_and_continue( cherry_picker, "get_updated_commit_message", return_value=commit_message ) as get_updated_commit_message, mock.patch.object( cherry_picker, "checkout_branch" - ), mock.patch.object( - cherry_picker, "fetch_upstream" - ), mock.patch.object( + ), mock.patch.object(cherry_picker, "fetch_upstream"), mock.patch.object( cherry_picker, "cleanup_branch" ): cherry_picker.continue_cherry_pick() From 6b817ca662efe2cf483182c2fb941f0423d94654 Mon Sep 17 00:00:00 2001 From: DPR Date: Mon, 5 Feb 2024 22:50:41 +0800 Subject: [PATCH 4/5] fix E501 --- cherry_picker/test_cherry_picker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cherry_picker/test_cherry_picker.py b/cherry_picker/test_cherry_picker.py index 7a20b17..32ca650 100644 --- a/cherry_picker/test_cherry_picker.py +++ b/cherry_picker/test_cherry_picker.py @@ -408,7 +408,8 @@ def test_is_not_cpython_repo(): # use default CPython sha to fail on this repo with pytest.raises( InvalidRepoException, - match=r"The sha listed in the branch name, \w+, is not present in the repository", + match=r"The sha listed in the branch name, " + r"\w+, is not present in the repository", ): CherryPicker("origin", "22a594a0047d7706537ff2ac676cdc0f1dcb329c", ["3.6"]) From 7298c14935d5004bdc70de33268b27a04cd09896 Mon Sep 17 00:00:00 2001 From: DPR Date: Mon, 5 Feb 2024 22:57:21 +0800 Subject: [PATCH 5/5] reformat --- cherry_picker/test_cherry_picker.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cherry_picker/test_cherry_picker.py b/cherry_picker/test_cherry_picker.py index 32ca650..b5b1b77 100644 --- a/cherry_picker/test_cherry_picker.py +++ b/cherry_picker/test_cherry_picker.py @@ -1152,7 +1152,9 @@ def test_backport_pause_and_continue( cherry_picker, "get_updated_commit_message", return_value=commit_message ) as get_updated_commit_message, mock.patch.object( cherry_picker, "checkout_branch" - ), mock.patch.object(cherry_picker, "fetch_upstream"), mock.patch.object( + ), mock.patch.object( + cherry_picker, "fetch_upstream" + ), mock.patch.object( cherry_picker, "cleanup_branch" ): cherry_picker.continue_cherry_pick()