Repository: VirtusLab/git-machete
Pull request #1072 (2023-10-15 21:35:29)

Rename `is_called_from_create_pr` param to `is_called_from_github`
# Based on PR #1060




Patch:
diff --git a/git_machete/client.py b/git_machete/client.py
index 300287f..7de2097 100644
--- a/git_machete/client.py
+++ b/git_machete/client.py
@@ -892,7 +892,7 @@ class MacheteClient:
                         self.__handle_untracked_state(
                             branch=current_branch,
                             is_called_from_traverse=True,
-                            is_called_from_create_pr=False,
+                            is_called_from_github=False,
                             opt_push_untracked=opt_push_untracked,
                             opt_push_tracked=opt_push_tracked,
                             opt_yes=opt_yes)
@@ -1803,7 +1803,7 @@ class MacheteClient:
             *,
             branch: LocalBranchShortName,
             is_called_from_traverse: bool,
-            is_called_from_create_pr: bool,
+            is_called_from_github: bool,
             opt_push_untracked: bool,
             opt_push_tracked: bool,
             opt_yes: bool
@@ -1814,7 +1814,7 @@ class MacheteClient:
               "repository, or 'n' to skip this branch, or " \
               "'q' to quit the traverse: " if is_called_from_traverse \
             else f"Select number 1..{len(rems)} to specify the destination remote " \
-                 "repository, or 'q' to quit creating pull request: "
+                 "repository, or 'q' to quit the operation: "
 
         ans = input(msg).lower()
         if ans in ('q', 'quit'):
@@ -1827,13 +1827,13 @@ class MacheteClient:
                 new_remote=rems[index],
                 branch=branch,
                 is_called_from_traverse=is_called_from_traverse,
-                is_called_from_create_pr=is_called_from_create_pr,
+                is_called_from_github=is_called_from_github,
                 opt_push_untracked=opt_push_untracked,
                 opt_push_tracked=opt_push_tracked,
                 opt_yes=opt_yes)
         except ValueError:
-            if is_called_from_create_pr:
-                raise MacheteException('Could not establish remote repository, pull request creation interrupted.')
+            if is_called_from_github:
+                raise MacheteException('Could not establish remote repository, operation interrupted.')
 
     def __handle_untracked_branch(
             self,
@@ -1841,7 +1841,7 @@ class MacheteClient:
             new_remote: str,
             branch: LocalBranchShortName,
             is_called_from_traverse: bool,
-            is_called_from_create_pr: bool,
+            is_called_from_github: bool,
             opt_push_untracked: bool,
             opt_push_tracked: bool,
             opt_yes: bool
@@ -1869,7 +1869,7 @@ class MacheteClient:
                     self.__pick_remote(
                         branch=branch,
                         is_called_from_traverse=is_called_from_traverse,
-                        is_called_from_create_pr=is_called_from_create_pr,
+                        is_called_from_github=is_called_from_github,
                         opt_push_untracked=opt_push_untracked,
                         opt_push_tracked=opt_push_tracked,
                         opt_yes=opt_yes)
@@ -2357,7 +2357,7 @@ class MacheteClient:
                 branch=base,
                 new_remote=org_repo_remote.remote,
                 is_called_from_traverse=False,
-                is_called_from_create_pr=True,
+                is_called_from_github=True,
                 opt_push_tracked=False,
                 opt_push_untracked=True,
                 opt_yes=False)
@@ -2467,7 +2467,7 @@ class MacheteClient:
             *,
             branch: LocalBranchShortName,
             is_called_from_traverse: bool,
-            is_called_from_create_pr: bool,
+            is_called_from_github: bool,
             opt_push_tracked: bool,
             opt_push_untracked: bool,
             opt_yes: bool
@@ -2479,7 +2479,7 @@ class MacheteClient:
                 new_remote=remotes[0],
                 branch=branch,
                 is_called_from_traverse=is_called_from_traverse,
-                is_called_from_create_pr=is_called_from_create_pr,
+                is_called_from_github=is_called_from_github,
                 opt_push_untracked=opt_push_untracked,
                 opt_push_tracked=opt_push_tracked,
                 opt_yes=opt_yes)
@@ -2488,7 +2488,7 @@ class MacheteClient:
                 new_remote="origin",
                 branch=branch,
                 is_called_from_traverse=is_called_from_traverse,
-                is_called_from_create_pr=is_called_from_create_pr,
+                is_called_from_github=is_called_from_github,
                 opt_push_untracked=opt_push_untracked,
                 opt_push_tracked=opt_push_tracked,
                 opt_yes=opt_yes)
@@ -2498,7 +2498,7 @@ class MacheteClient:
             self.__pick_remote(
                 branch=branch,
                 is_called_from_traverse=is_called_from_traverse,
-                is_called_from_create_pr=is_called_from_create_pr,
+                is_called_from_github=is_called_from_github,
                 opt_push_untracked=opt_push_untracked,
                 opt_push_tracked=opt_push_tracked,
                 opt_yes=opt_yes)
@@ -2613,7 +2613,7 @@ class MacheteClient:
                     self.__handle_untracked_state(
                         branch=current_branch,
                         is_called_from_traverse=False,
-                        is_called_from_create_pr=True,
+                        is_called_from_github=True,
                         opt_push_tracked=True,
                         opt_push_untracked=True,
                         opt_yes=opt_yes)


Test patch:
diff --git a/tests/test_github_create_pr.py b/tests/test_github_create_pr.py
index c08c1db..4db80f8 100644
--- a/tests/test_github_create_pr.py
+++ b/tests/test_github_create_pr.py
@@ -406,7 +406,7 @@ class TestGitHubCreatePR(BaseTest):
         Branch feature is untracked and there's no origin repository.
         [1] origin_1
         [2] origin_2
-        Select number 1..2 to specify the destination remote repository, or 'q' to quit creating pull request:
+        Select number 1..2 to specify the destination remote repository, or 'q' to quit the operation:
         """
         assert_success(
             ['github', 'create-pr'],
@@ -422,7 +422,7 @@ class TestGitHubCreatePR(BaseTest):
         self.patch_symbol(mocker, 'builtins.input', mock_input_returning('xd'))
         assert_failure(
             ['github', 'create-pr'],
-            "Could not establish remote repository, pull request creation interrupted."
+            "Could not establish remote repository, operation interrupted."
         )
 
         self.patch_symbol(mocker, 'builtins.input', mock_input_returning('1', 'n'))
@@ -437,7 +437,7 @@ class TestGitHubCreatePR(BaseTest):
         Branch feature is untracked and there's no origin repository.
         [1] origin_1
         [2] origin_2
-        Select number 1..2 to specify the destination remote repository, or 'q' to quit creating pull request:
+        Select number 1..2 to specify the destination remote repository, or 'q' to quit the operation:
         Branch feature is untracked, but its remote counterpart candidate origin_1/feature already exists and both branches point to the same commit.
         Set the remote of feature to origin_1 without pushing or pulling? (y, N, q, yq)
         """  # noqa: E501
@@ -461,7 +461,7 @@ class TestGitHubCreatePR(BaseTest):
         Branch feature is untracked and there's no origin repository.
         [1] origin_1
         [2] origin_2
-        Select number 1..2 to specify the destination remote repository, or 'q' to quit creating pull request:
+        Select number 1..2 to specify the destination remote repository, or 'q' to quit the operation:
         Branch feature is untracked, but its remote counterpart candidate origin_1/feature already exists and both branches point to the same commit.
         Set the remote of feature to origin_1 without pushing or pulling? (y, N, q, yq)
 
@@ -525,7 +525,7 @@ class TestGitHubCreatePR(BaseTest):
         Branch feature_2 is untracked and there's no origin repository.
         [1] origin_1
         [2] origin_2
-        Select number 1..2 to specify the destination remote repository, or 'q' to quit creating pull request:
+        Select number 1..2 to specify the destination remote repository, or 'q' to quit the operation:
         Push untracked branch feature_2 to origin_1? (y, Q)
 
           root