pygitgo 1.3.0__tar.gz → 1.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pygitgo-1.3.0/src/pygitgo.egg-info → pygitgo-1.4.0}/PKG-INFO +10 -1
- {pygitgo-1.3.0 → pygitgo-1.4.0}/README.md +9 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/pyproject.toml +1 -1
- pygitgo-1.4.0/src/pygitgo/commands/pull.py +43 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/main.py +14 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0/src/pygitgo.egg-info}/PKG-INFO +10 -1
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo.egg-info/SOURCES.txt +2 -0
- pygitgo-1.4.0/tests/test_pull.py +77 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/LICENSE +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/setup.cfg +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/__init__.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/auth/__init__.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/auth/account.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/auth/manager.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/auth/ssh_utils.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/commands/__init__.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/commands/git_operations.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/commands/jump.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/commands/state.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/commands/undo.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/exceptions.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/utils/__init__.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/utils/colors.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/utils/config.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/utils/executor.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/utils/platform_utils.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo/utils/setup.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo.egg-info/dependency_links.txt +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo.egg-info/entry_points.txt +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo.egg-info/requires.txt +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/src/pygitgo.egg-info/top_level.txt +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/tests/test_config.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/tests/test_git_operations.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/tests/test_jump.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/tests/test_main.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/tests/test_platform.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/tests/test_setup.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/tests/test_state.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/tests/test_undo.py +0 -0
- {pygitgo-1.3.0 → pygitgo-1.4.0}/tests/test_url_validator.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pygitgo
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: GitGo CLI - Your Fast Git Companion. Simplifies git push, link, stash, and user management.
|
|
5
5
|
Author: Huerte
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -193,6 +193,15 @@ gitgo push -n [branch] [message] # create new branch first
|
|
|
193
193
|
|
|
194
194
|
If there are no new changes but unpushed commits exist, GitGo detects this and pushes without creating an empty commit.
|
|
195
195
|
|
|
196
|
+
### `gitgo pull`
|
|
197
|
+
|
|
198
|
+
Safely downloads updates from the remote server. It automatically stashes your messy code, pulls the updates cleanly underneath using a rebase, and then instantly puts your code back exactly how it was.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
gitgo pull # Safely pull updates for your current branch
|
|
202
|
+
gitgo pull <branch> # Safely pull updates from a specific branch
|
|
203
|
+
```
|
|
204
|
+
|
|
196
205
|
### `gitgo link`
|
|
197
206
|
|
|
198
207
|
Initializes a Git repository in the current directory, connects it to a remote, and pushes. Handles already-initialized repos gracefully and pulls unrelated histories.
|
|
@@ -170,6 +170,15 @@ gitgo push -n [branch] [message] # create new branch first
|
|
|
170
170
|
|
|
171
171
|
If there are no new changes but unpushed commits exist, GitGo detects this and pushes without creating an empty commit.
|
|
172
172
|
|
|
173
|
+
### `gitgo pull`
|
|
174
|
+
|
|
175
|
+
Safely downloads updates from the remote server. It automatically stashes your messy code, pulls the updates cleanly underneath using a rebase, and then instantly puts your code back exactly how it was.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
gitgo pull # Safely pull updates for your current branch
|
|
179
|
+
gitgo pull <branch> # Safely pull updates from a specific branch
|
|
180
|
+
```
|
|
181
|
+
|
|
173
182
|
### `gitgo link`
|
|
174
183
|
|
|
175
184
|
Initializes a Git repository in the current directory, connects it to a remote, and pushes. Handles already-initialized repos gracefully and pulls unrelated histories.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pygitgo"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.4.0"
|
|
8
8
|
description = "GitGo CLI - Your Fast Git Companion. Simplifies git push, link, stash, and user management."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "GPL-3.0-or-later"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from pygitgo.utils.colors import success, warning, error, info
|
|
2
|
+
from pygitgo.utils.executor import run_command
|
|
3
|
+
from pygitgo.exceptions import GitCommandError
|
|
4
|
+
from pygitgo.commands.git_operations import get_current_branch
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
def pull_operation(args):
|
|
9
|
+
branch = args.branch
|
|
10
|
+
|
|
11
|
+
if not branch:
|
|
12
|
+
branch = get_current_branch()
|
|
13
|
+
info(f"No branch provided. Pulling latest updates for '{branch}'...\n")
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
remote_refs = run_command(["git", "ls-remote", "--heads", "origin", branch], allow_fail=True)
|
|
17
|
+
if isinstance(remote_refs, subprocess.CalledProcessError) or not remote_refs.strip():
|
|
18
|
+
error(f"\nFailed! The branch '{branch}' does not exist on the remote server.")
|
|
19
|
+
warning("You might need to push your local branch first.\n")
|
|
20
|
+
sys.exit(1)
|
|
21
|
+
|
|
22
|
+
run_command(
|
|
23
|
+
["git", "pull", "--rebase", "--autostash", "origin", branch],
|
|
24
|
+
loading_msg=f"Downloading latest updates for '{branch}' (auto-saving your code)..."
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
success(f"\nSuccess! Your project is now up to date with '{branch}'.\n")
|
|
28
|
+
|
|
29
|
+
except GitCommandError as e:
|
|
30
|
+
error_msg = str(e).lower()
|
|
31
|
+
if "conflict" in error_msg or "rebase in progress" in error_msg:
|
|
32
|
+
error("\nMERGE CONFLICT DETECTED!")
|
|
33
|
+
warning("Your local code clashes with the new code downloaded from the server.\n")
|
|
34
|
+
info("1. Open your code editor down below.")
|
|
35
|
+
info("2. Fix the red conflict lines in your files.")
|
|
36
|
+
info("3. Save the files.")
|
|
37
|
+
info("4. Run this command to finish: git rebase --continue\n")
|
|
38
|
+
sys.exit(1)
|
|
39
|
+
else:
|
|
40
|
+
error("\nFailed to pull updates from the server!")
|
|
41
|
+
error("Please check your internet connection and try again.")
|
|
42
|
+
error(f"Details: {e}\n")
|
|
43
|
+
sys.exit(1)
|
|
@@ -8,6 +8,7 @@ from pygitgo.exceptions import GitCommandError, GitGoError
|
|
|
8
8
|
from pygitgo.utils.setup import ensure_first_run_setup
|
|
9
9
|
from pygitgo.commands.state import state_operations
|
|
10
10
|
from pygitgo.commands.undo import undo_operations
|
|
11
|
+
from pygitgo.commands.pull import pull_operation
|
|
11
12
|
from pygitgo.commands.jump import jump_operation
|
|
12
13
|
from pygitgo.utils.executor import run_command
|
|
13
14
|
from pygitgo.auth.manager import login, logout
|
|
@@ -282,6 +283,17 @@ def main():
|
|
|
282
283
|
help="What to undo: 'commit', 'add', or 'changes'"
|
|
283
284
|
)
|
|
284
285
|
|
|
286
|
+
pull_parser = subparsers.add_parser("pull",
|
|
287
|
+
help="Safely pull the latest code without losing your changes",
|
|
288
|
+
epilog=(
|
|
289
|
+
"Examples:\n"
|
|
290
|
+
" gitgo pull Safely pull updates for your current branch\n"
|
|
291
|
+
" gitgo pull main Safely pull updates from the 'main' branch\n"
|
|
292
|
+
),
|
|
293
|
+
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
294
|
+
)
|
|
295
|
+
pull_parser.add_argument("branch", nargs="?", default=None, help="The branch to pull from (default is your current branch)")
|
|
296
|
+
|
|
285
297
|
args = parser.parse_args()
|
|
286
298
|
|
|
287
299
|
if args.ready:
|
|
@@ -309,6 +321,8 @@ def main():
|
|
|
309
321
|
config_operation(args)
|
|
310
322
|
elif args.command == "undo":
|
|
311
323
|
undo_operations(args)
|
|
324
|
+
elif args.command == "pull":
|
|
325
|
+
pull_operation(args)
|
|
312
326
|
except GitGoError as e:
|
|
313
327
|
error(f"\n{e}\n")
|
|
314
328
|
sys.exit(1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pygitgo
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: GitGo CLI - Your Fast Git Companion. Simplifies git push, link, stash, and user management.
|
|
5
5
|
Author: Huerte
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -193,6 +193,15 @@ gitgo push -n [branch] [message] # create new branch first
|
|
|
193
193
|
|
|
194
194
|
If there are no new changes but unpushed commits exist, GitGo detects this and pushes without creating an empty commit.
|
|
195
195
|
|
|
196
|
+
### `gitgo pull`
|
|
197
|
+
|
|
198
|
+
Safely downloads updates from the remote server. It automatically stashes your messy code, pulls the updates cleanly underneath using a rebase, and then instantly puts your code back exactly how it was.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
gitgo pull # Safely pull updates for your current branch
|
|
202
|
+
gitgo pull <branch> # Safely pull updates from a specific branch
|
|
203
|
+
```
|
|
204
|
+
|
|
196
205
|
### `gitgo link`
|
|
197
206
|
|
|
198
207
|
Initializes a Git repository in the current directory, connects it to a remote, and pushes. Handles already-initialized repos gracefully and pulls unrelated histories.
|
|
@@ -17,6 +17,7 @@ src/pygitgo/auth/ssh_utils.py
|
|
|
17
17
|
src/pygitgo/commands/__init__.py
|
|
18
18
|
src/pygitgo/commands/git_operations.py
|
|
19
19
|
src/pygitgo/commands/jump.py
|
|
20
|
+
src/pygitgo/commands/pull.py
|
|
20
21
|
src/pygitgo/commands/state.py
|
|
21
22
|
src/pygitgo/commands/undo.py
|
|
22
23
|
src/pygitgo/utils/__init__.py
|
|
@@ -30,6 +31,7 @@ tests/test_git_operations.py
|
|
|
30
31
|
tests/test_jump.py
|
|
31
32
|
tests/test_main.py
|
|
32
33
|
tests/test_platform.py
|
|
34
|
+
tests/test_pull.py
|
|
33
35
|
tests/test_setup.py
|
|
34
36
|
tests/test_state.py
|
|
35
37
|
tests/test_undo.py
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from unittest.mock import patch, MagicMock
|
|
3
|
+
from pygitgo.commands.pull import pull_operation
|
|
4
|
+
from pygitgo.exceptions import GitCommandError
|
|
5
|
+
from argparse import Namespace
|
|
6
|
+
import subprocess
|
|
7
|
+
|
|
8
|
+
@patch("pygitgo.commands.pull.run_command")
|
|
9
|
+
@patch("pygitgo.commands.pull.success")
|
|
10
|
+
@patch("pygitgo.commands.pull.get_current_branch", return_value="main")
|
|
11
|
+
def test_pull_operation_success_no_branch(mock_get_branch, mock_success, mock_run_command):
|
|
12
|
+
mock_run_command.side_effect = [
|
|
13
|
+
"1234567890abcdef",
|
|
14
|
+
None
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
args = Namespace(branch=None)
|
|
18
|
+
pull_operation(args)
|
|
19
|
+
|
|
20
|
+
assert mock_run_command.call_count == 2
|
|
21
|
+
mock_run_command.assert_any_call(["git", "ls-remote", "--heads", "origin", "main"], allow_fail=True)
|
|
22
|
+
mock_run_command.assert_any_call(
|
|
23
|
+
["git", "pull", "--rebase", "--autostash", "origin", "main"],
|
|
24
|
+
loading_msg="Downloading latest updates for 'main' (auto-saving your code)..."
|
|
25
|
+
)
|
|
26
|
+
mock_success.assert_called_once()
|
|
27
|
+
|
|
28
|
+
@patch("pygitgo.commands.pull.run_command")
|
|
29
|
+
@patch("pygitgo.commands.pull.success")
|
|
30
|
+
def test_pull_operation_success_with_branch(mock_success, mock_run_command):
|
|
31
|
+
mock_run_command.side_effect = [
|
|
32
|
+
"1234567890abcdef",
|
|
33
|
+
None
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
args = Namespace(branch="feature/test")
|
|
37
|
+
pull_operation(args)
|
|
38
|
+
|
|
39
|
+
assert mock_run_command.call_count == 2
|
|
40
|
+
mock_run_command.assert_any_call(["git", "ls-remote", "--heads", "origin", "feature/test"], allow_fail=True)
|
|
41
|
+
mock_run_command.assert_any_call(
|
|
42
|
+
["git", "pull", "--rebase", "--autostash", "origin", "feature/test"],
|
|
43
|
+
loading_msg="Downloading latest updates for 'feature/test' (auto-saving your code)..."
|
|
44
|
+
)
|
|
45
|
+
mock_success.assert_called_once()
|
|
46
|
+
|
|
47
|
+
@patch("pygitgo.commands.pull.sys.exit")
|
|
48
|
+
@patch("pygitgo.commands.pull.error")
|
|
49
|
+
@patch("pygitgo.commands.pull.run_command")
|
|
50
|
+
def test_pull_operation_branch_not_found(mock_run_command, mock_error, mock_exit):
|
|
51
|
+
mock_run_command.return_value = subprocess.CalledProcessError(128, ["git", "ls-remote"])
|
|
52
|
+
|
|
53
|
+
args = Namespace(branch="does-not-exist")
|
|
54
|
+
pull_operation(args)
|
|
55
|
+
|
|
56
|
+
mock_exit.assert_called_once_with(1)
|
|
57
|
+
mock_error.assert_called()
|
|
58
|
+
|
|
59
|
+
@patch("pygitgo.commands.pull.sys.exit")
|
|
60
|
+
@patch("pygitgo.commands.pull.error")
|
|
61
|
+
@patch("pygitgo.commands.pull.run_command")
|
|
62
|
+
def test_pull_operation_merge_conflict(mock_run_command, mock_error, mock_exit):
|
|
63
|
+
conflict_err = GitCommandError(["git", "pull"], stderr="merge conflict in file.py")
|
|
64
|
+
|
|
65
|
+
def side_effect_fn(*args, **kwargs):
|
|
66
|
+
cmd = args[0]
|
|
67
|
+
if cmd[1] == "ls-remote":
|
|
68
|
+
return "1234567890abcdef"
|
|
69
|
+
raise conflict_err
|
|
70
|
+
|
|
71
|
+
mock_run_command.side_effect = side_effect_fn
|
|
72
|
+
|
|
73
|
+
args = Namespace(branch="main")
|
|
74
|
+
pull_operation(args)
|
|
75
|
+
|
|
76
|
+
mock_exit.assert_called_once_with(1)
|
|
77
|
+
mock_error.assert_any_call("\nMERGE CONFLICT DETECTED!")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|