pygitgo 1.2.1__tar.gz → 1.3.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.2.1/src/pygitgo.egg-info → pygitgo-1.3.0}/PKG-INFO +22 -3
- {pygitgo-1.2.1 → pygitgo-1.3.0}/README.md +21 -2
- {pygitgo-1.2.1 → pygitgo-1.3.0}/pyproject.toml +1 -1
- pygitgo-1.3.0/src/pygitgo/commands/undo.py +53 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/main.py +20 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0/src/pygitgo.egg-info}/PKG-INFO +22 -3
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo.egg-info/SOURCES.txt +2 -0
- pygitgo-1.3.0/tests/test_undo.py +94 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/LICENSE +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/setup.cfg +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/__init__.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/auth/__init__.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/auth/account.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/auth/manager.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/auth/ssh_utils.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/commands/__init__.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/commands/git_operations.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/commands/jump.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/commands/state.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/exceptions.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/utils/__init__.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/utils/colors.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/utils/config.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/utils/executor.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/utils/platform_utils.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo/utils/setup.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo.egg-info/dependency_links.txt +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo.egg-info/entry_points.txt +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo.egg-info/requires.txt +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/src/pygitgo.egg-info/top_level.txt +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/tests/test_config.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/tests/test_git_operations.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/tests/test_jump.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/tests/test_main.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/tests/test_platform.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/tests/test_setup.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.0}/tests/test_state.py +0 -0
- {pygitgo-1.2.1 → pygitgo-1.3.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.3.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
|
|
@@ -40,7 +40,7 @@ Dynamic: license-file
|
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
43
|
-
GitGo wraps your most repetitive
|
|
43
|
+
GitGo wraps your most repetitive git commands into short ones you can actually remember. It covers init, add, commit, push, branch, and stash. It also handles the things most tools skip like automatic SSH setup, HTTPS to SSH conversion, and a simple stash interface called state management.
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
46
|
# Instead of this:
|
|
@@ -76,6 +76,7 @@ gitgo link https://github.com/username/repo.git "init"
|
|
|
76
76
|
GitGo provides a CLI environment designed for faster and simpler Git workflows. Built to be intuitive, fast, and frictionless.
|
|
77
77
|
|
|
78
78
|
- **Simplified Git Operations:** Replaces chained commands with single intuitive commands for linking, pushing, and stashing.
|
|
79
|
+
- **Easy Undo Operations:** Safely undo commits, un-queue files, or wipe local changes without any complex Git jargon.
|
|
79
80
|
- **Smart Branch Hopping:** Safely traverse branches with `jump`. Auto-stashes messy code and prevents merge conflict disasters with a Try-And-Revert safety engine.
|
|
80
81
|
- **State Management:** A human-readable interface over `git stash`. States are named and listed by index so you never have to remember cryptic stash references.
|
|
81
82
|
- **Custom Defaults:** Save your preferred branch name and commit message locally so you never have to type them again.
|
|
@@ -147,7 +148,15 @@ Jump to a different branch without worrying about your uncommitted changes. GitG
|
|
|
147
148
|
gitgo jump feature/new-login
|
|
148
149
|
```
|
|
149
150
|
|
|
150
|
-
### 5.
|
|
151
|
+
### 5. Safely Undo Mistakes
|
|
152
|
+
Easily fix common mistakes without losing work or needing to search for Git commands.
|
|
153
|
+
```bash
|
|
154
|
+
gitgo undo commit # Undo the last commit (files stay safe)
|
|
155
|
+
gitgo undo add # Un-queue files (undo git add)
|
|
156
|
+
gitgo undo changes # DANGER: permanently wipe all unsaved edits
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 6. Save Your Work-in-Progress
|
|
151
160
|
```bash
|
|
152
161
|
gitgo state save "halfway through refactor"
|
|
153
162
|
gitgo state list
|
|
@@ -200,6 +209,16 @@ Safely switches branches without losing uncommitted progress. Auto-stashes, jump
|
|
|
200
209
|
gitgo jump <branch>
|
|
201
210
|
```
|
|
202
211
|
|
|
212
|
+
### `gitgo undo`
|
|
213
|
+
|
|
214
|
+
Safely undo recent actions and mistakes using simple, human-readable commands.
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
gitgo undo commit # Undo your last commit without losing files
|
|
218
|
+
gitgo undo add # Un-queue files (remove them from being ready to commit)
|
|
219
|
+
gitgo undo changes # Permanently wipe all new files and local edits
|
|
220
|
+
```
|
|
221
|
+
|
|
203
222
|
### `gitgo state`
|
|
204
223
|
|
|
205
224
|
A human-readable interface over `git stash`.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
GitGo wraps your most repetitive
|
|
20
|
+
GitGo wraps your most repetitive git commands into short ones you can actually remember. It covers init, add, commit, push, branch, and stash. It also handles the things most tools skip like automatic SSH setup, HTTPS to SSH conversion, and a simple stash interface called state management.
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
23
|
# Instead of this:
|
|
@@ -53,6 +53,7 @@ gitgo link https://github.com/username/repo.git "init"
|
|
|
53
53
|
GitGo provides a CLI environment designed for faster and simpler Git workflows. Built to be intuitive, fast, and frictionless.
|
|
54
54
|
|
|
55
55
|
- **Simplified Git Operations:** Replaces chained commands with single intuitive commands for linking, pushing, and stashing.
|
|
56
|
+
- **Easy Undo Operations:** Safely undo commits, un-queue files, or wipe local changes without any complex Git jargon.
|
|
56
57
|
- **Smart Branch Hopping:** Safely traverse branches with `jump`. Auto-stashes messy code and prevents merge conflict disasters with a Try-And-Revert safety engine.
|
|
57
58
|
- **State Management:** A human-readable interface over `git stash`. States are named and listed by index so you never have to remember cryptic stash references.
|
|
58
59
|
- **Custom Defaults:** Save your preferred branch name and commit message locally so you never have to type them again.
|
|
@@ -124,7 +125,15 @@ Jump to a different branch without worrying about your uncommitted changes. GitG
|
|
|
124
125
|
gitgo jump feature/new-login
|
|
125
126
|
```
|
|
126
127
|
|
|
127
|
-
### 5.
|
|
128
|
+
### 5. Safely Undo Mistakes
|
|
129
|
+
Easily fix common mistakes without losing work or needing to search for Git commands.
|
|
130
|
+
```bash
|
|
131
|
+
gitgo undo commit # Undo the last commit (files stay safe)
|
|
132
|
+
gitgo undo add # Un-queue files (undo git add)
|
|
133
|
+
gitgo undo changes # DANGER: permanently wipe all unsaved edits
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 6. Save Your Work-in-Progress
|
|
128
137
|
```bash
|
|
129
138
|
gitgo state save "halfway through refactor"
|
|
130
139
|
gitgo state list
|
|
@@ -177,6 +186,16 @@ Safely switches branches without losing uncommitted progress. Auto-stashes, jump
|
|
|
177
186
|
gitgo jump <branch>
|
|
178
187
|
```
|
|
179
188
|
|
|
189
|
+
### `gitgo undo`
|
|
190
|
+
|
|
191
|
+
Safely undo recent actions and mistakes using simple, human-readable commands.
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
gitgo undo commit # Undo your last commit without losing files
|
|
195
|
+
gitgo undo add # Un-queue files (remove them from being ready to commit)
|
|
196
|
+
gitgo undo changes # Permanently wipe all new files and local edits
|
|
197
|
+
```
|
|
198
|
+
|
|
180
199
|
### `gitgo state`
|
|
181
200
|
|
|
182
201
|
A human-readable interface over `git stash`.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pygitgo"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.3.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,53 @@
|
|
|
1
|
+
from pygitgo.utils.colors import success, warning, error, info
|
|
2
|
+
from pygitgo.exceptions import GitCommandError
|
|
3
|
+
from pygitgo.utils.executor import run_command
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def undo_commit():
|
|
8
|
+
try:
|
|
9
|
+
run_command(["git", "reset", "--soft", "HEAD~"])
|
|
10
|
+
success("\nSuccess! Your last commit is undone. Your files are safe.\n")
|
|
11
|
+
except GitCommandError as e:
|
|
12
|
+
error("\nFailed! You might not have any previous commits to undo yet.")
|
|
13
|
+
error(f"Details: {e}\n")
|
|
14
|
+
sys.exit(1)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def undo_add():
|
|
18
|
+
try:
|
|
19
|
+
run_command(["git", "reset", "HEAD"])
|
|
20
|
+
success("\nSuccess! Files are no longer ready to commit.\n")
|
|
21
|
+
except GitCommandError as e:
|
|
22
|
+
error(f"\n{e}\n")
|
|
23
|
+
sys.exit(1)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def undo_changes():
|
|
27
|
+
warning("\nDANGER: This will permanently delete all your new edits and new files!")
|
|
28
|
+
confirm = input("Are you sure you want to throw away all changes? (y/n): ")
|
|
29
|
+
if confirm.lower() != "y":
|
|
30
|
+
info("\nCanceled. Your files are safe.\n")
|
|
31
|
+
return
|
|
32
|
+
try:
|
|
33
|
+
run_command(["git", "reset", "--hard", "HEAD"], loading_msg="Throwing away edits...")
|
|
34
|
+
run_command(["git", "clean", "-fd"], loading_msg="Removing new files...")
|
|
35
|
+
|
|
36
|
+
success("\nSuccess! All changes are completely gone. You have a clean start.\n")
|
|
37
|
+
except GitCommandError as e:
|
|
38
|
+
error(f"\n{e}\n")
|
|
39
|
+
sys.exit(1)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def undo_operations(args):
|
|
43
|
+
action = args.action
|
|
44
|
+
|
|
45
|
+
if action == "commit":
|
|
46
|
+
undo_commit()
|
|
47
|
+
elif action == "add":
|
|
48
|
+
undo_add()
|
|
49
|
+
elif action == "changes":
|
|
50
|
+
undo_changes()
|
|
51
|
+
else:
|
|
52
|
+
error(f"\nUnknown undo operation: {action}\n")
|
|
53
|
+
sys.exit(1)
|
|
@@ -7,6 +7,7 @@ from pygitgo.utils.config import get_config, config_operation
|
|
|
7
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
|
+
from pygitgo.commands.undo import undo_operations
|
|
10
11
|
from pygitgo.commands.jump import jump_operation
|
|
11
12
|
from pygitgo.utils.executor import run_command
|
|
12
13
|
from pygitgo.auth.manager import login, logout
|
|
@@ -185,6 +186,7 @@ def get_version():
|
|
|
185
186
|
except Exception:
|
|
186
187
|
return "dev"
|
|
187
188
|
|
|
189
|
+
|
|
188
190
|
def main():
|
|
189
191
|
parser = argparse.ArgumentParser(
|
|
190
192
|
prog='gitgo',
|
|
@@ -264,6 +266,22 @@ def main():
|
|
|
264
266
|
config_parser.add_argument("key", choices=["default-branch", "default-message"], help="The setting to change")
|
|
265
267
|
config_parser.add_argument("value", nargs="?", help="The new value (required for 'set')")
|
|
266
268
|
|
|
269
|
+
undo_parser = subparsers.add_parser("undo",
|
|
270
|
+
help="Safely undo mistakes",
|
|
271
|
+
epilog=(
|
|
272
|
+
"Examples:\n"
|
|
273
|
+
" gitgo undo commit Undo your last commit (your files are safe)\n"
|
|
274
|
+
" gitgo undo add Undo 'git add' (files are no longer ready to commit)\n"
|
|
275
|
+
" gitgo undo changes DANGER: Throw away all new changes and start fresh"
|
|
276
|
+
),
|
|
277
|
+
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
278
|
+
)
|
|
279
|
+
undo_parser.add_argument(
|
|
280
|
+
"action",
|
|
281
|
+
choices=["commit", "add", "changes"],
|
|
282
|
+
help="What to undo: 'commit', 'add', or 'changes'"
|
|
283
|
+
)
|
|
284
|
+
|
|
267
285
|
args = parser.parse_args()
|
|
268
286
|
|
|
269
287
|
if args.ready:
|
|
@@ -289,6 +307,8 @@ def main():
|
|
|
289
307
|
user_management(args)
|
|
290
308
|
elif args.command == "config":
|
|
291
309
|
config_operation(args)
|
|
310
|
+
elif args.command == "undo":
|
|
311
|
+
undo_operations(args)
|
|
292
312
|
except GitGoError as e:
|
|
293
313
|
error(f"\n{e}\n")
|
|
294
314
|
sys.exit(1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pygitgo
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.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
|
|
@@ -40,7 +40,7 @@ Dynamic: license-file
|
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
43
|
-
GitGo wraps your most repetitive
|
|
43
|
+
GitGo wraps your most repetitive git commands into short ones you can actually remember. It covers init, add, commit, push, branch, and stash. It also handles the things most tools skip like automatic SSH setup, HTTPS to SSH conversion, and a simple stash interface called state management.
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
46
|
# Instead of this:
|
|
@@ -76,6 +76,7 @@ gitgo link https://github.com/username/repo.git "init"
|
|
|
76
76
|
GitGo provides a CLI environment designed for faster and simpler Git workflows. Built to be intuitive, fast, and frictionless.
|
|
77
77
|
|
|
78
78
|
- **Simplified Git Operations:** Replaces chained commands with single intuitive commands for linking, pushing, and stashing.
|
|
79
|
+
- **Easy Undo Operations:** Safely undo commits, un-queue files, or wipe local changes without any complex Git jargon.
|
|
79
80
|
- **Smart Branch Hopping:** Safely traverse branches with `jump`. Auto-stashes messy code and prevents merge conflict disasters with a Try-And-Revert safety engine.
|
|
80
81
|
- **State Management:** A human-readable interface over `git stash`. States are named and listed by index so you never have to remember cryptic stash references.
|
|
81
82
|
- **Custom Defaults:** Save your preferred branch name and commit message locally so you never have to type them again.
|
|
@@ -147,7 +148,15 @@ Jump to a different branch without worrying about your uncommitted changes. GitG
|
|
|
147
148
|
gitgo jump feature/new-login
|
|
148
149
|
```
|
|
149
150
|
|
|
150
|
-
### 5.
|
|
151
|
+
### 5. Safely Undo Mistakes
|
|
152
|
+
Easily fix common mistakes without losing work or needing to search for Git commands.
|
|
153
|
+
```bash
|
|
154
|
+
gitgo undo commit # Undo the last commit (files stay safe)
|
|
155
|
+
gitgo undo add # Un-queue files (undo git add)
|
|
156
|
+
gitgo undo changes # DANGER: permanently wipe all unsaved edits
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 6. Save Your Work-in-Progress
|
|
151
160
|
```bash
|
|
152
161
|
gitgo state save "halfway through refactor"
|
|
153
162
|
gitgo state list
|
|
@@ -200,6 +209,16 @@ Safely switches branches without losing uncommitted progress. Auto-stashes, jump
|
|
|
200
209
|
gitgo jump <branch>
|
|
201
210
|
```
|
|
202
211
|
|
|
212
|
+
### `gitgo undo`
|
|
213
|
+
|
|
214
|
+
Safely undo recent actions and mistakes using simple, human-readable commands.
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
gitgo undo commit # Undo your last commit without losing files
|
|
218
|
+
gitgo undo add # Un-queue files (remove them from being ready to commit)
|
|
219
|
+
gitgo undo changes # Permanently wipe all new files and local edits
|
|
220
|
+
```
|
|
221
|
+
|
|
203
222
|
### `gitgo state`
|
|
204
223
|
|
|
205
224
|
A human-readable interface over `git stash`.
|
|
@@ -18,6 +18,7 @@ src/pygitgo/commands/__init__.py
|
|
|
18
18
|
src/pygitgo/commands/git_operations.py
|
|
19
19
|
src/pygitgo/commands/jump.py
|
|
20
20
|
src/pygitgo/commands/state.py
|
|
21
|
+
src/pygitgo/commands/undo.py
|
|
21
22
|
src/pygitgo/utils/__init__.py
|
|
22
23
|
src/pygitgo/utils/colors.py
|
|
23
24
|
src/pygitgo/utils/config.py
|
|
@@ -31,4 +32,5 @@ tests/test_main.py
|
|
|
31
32
|
tests/test_platform.py
|
|
32
33
|
tests/test_setup.py
|
|
33
34
|
tests/test_state.py
|
|
35
|
+
tests/test_undo.py
|
|
34
36
|
tests/test_url_validator.py
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from unittest.mock import patch, MagicMock
|
|
3
|
+
from pygitgo.commands.undo import undo_commit, undo_add, undo_changes, undo_operations
|
|
4
|
+
from pygitgo.exceptions import GitCommandError
|
|
5
|
+
from argparse import Namespace
|
|
6
|
+
|
|
7
|
+
@patch("pygitgo.commands.undo.run_command")
|
|
8
|
+
@patch("pygitgo.commands.undo.success")
|
|
9
|
+
def test_undo_commit_success(mock_success, mock_run_command):
|
|
10
|
+
undo_commit()
|
|
11
|
+
mock_run_command.assert_called_once_with(["git", "reset", "--soft", "HEAD~"])
|
|
12
|
+
mock_success.assert_called_once()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@patch("pygitgo.commands.undo.sys.exit")
|
|
16
|
+
@patch("pygitgo.commands.undo.error")
|
|
17
|
+
@patch("pygitgo.commands.undo.run_command")
|
|
18
|
+
def test_undo_commit_failure(mock_run_command, mock_error, mock_exit):
|
|
19
|
+
mock_run_command.side_effect = GitCommandError(["git", "reset", "--soft", "HEAD~"])
|
|
20
|
+
undo_commit()
|
|
21
|
+
mock_run_command.assert_called_once()
|
|
22
|
+
assert mock_error.call_count == 2
|
|
23
|
+
mock_exit.assert_called_once_with(1)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@patch("pygitgo.commands.undo.run_command")
|
|
27
|
+
@patch("pygitgo.commands.undo.success")
|
|
28
|
+
def test_undo_add_success(mock_success, mock_run_command):
|
|
29
|
+
undo_add()
|
|
30
|
+
mock_run_command.assert_called_once_with(["git", "reset", "HEAD"])
|
|
31
|
+
mock_success.assert_called_once()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@patch("pygitgo.commands.undo.sys.exit")
|
|
35
|
+
@patch("pygitgo.commands.undo.error")
|
|
36
|
+
@patch("pygitgo.commands.undo.run_command")
|
|
37
|
+
def test_undo_add_failure(mock_run_command, mock_error, mock_exit):
|
|
38
|
+
mock_run_command.side_effect = GitCommandError(["git", "reset", "HEAD"])
|
|
39
|
+
undo_add()
|
|
40
|
+
mock_run_command.assert_called_once()
|
|
41
|
+
mock_error.assert_called_once()
|
|
42
|
+
mock_exit.assert_called_once_with(1)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@patch("pygitgo.commands.undo.run_command")
|
|
46
|
+
@patch("pygitgo.commands.undo.success")
|
|
47
|
+
@patch("pygitgo.commands.undo.input", return_value="y")
|
|
48
|
+
def test_undo_changes_success(mock_input, mock_success, mock_run_command):
|
|
49
|
+
undo_changes()
|
|
50
|
+
mock_input.assert_called_once()
|
|
51
|
+
assert mock_run_command.call_count == 2
|
|
52
|
+
mock_run_command.assert_any_call(["git", "reset", "--hard", "HEAD"], loading_msg="Throwing away edits...")
|
|
53
|
+
mock_run_command.assert_any_call(["git", "clean", "-fd"], loading_msg="Removing new files...")
|
|
54
|
+
mock_success.assert_called_once()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@patch("pygitgo.commands.undo.run_command")
|
|
58
|
+
@patch("pygitgo.commands.undo.info")
|
|
59
|
+
@patch("pygitgo.commands.undo.input", return_value="n")
|
|
60
|
+
def test_undo_changes_abort(mock_input, mock_info, mock_run_command):
|
|
61
|
+
undo_changes()
|
|
62
|
+
mock_input.assert_called_once()
|
|
63
|
+
mock_info.assert_called_once()
|
|
64
|
+
mock_run_command.assert_not_called()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@patch("pygitgo.commands.undo.undo_commit")
|
|
68
|
+
def test_undo_operations_commit(mock_undo_commit):
|
|
69
|
+
args = Namespace(action="commit")
|
|
70
|
+
undo_operations(args)
|
|
71
|
+
mock_undo_commit.assert_called_once()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@patch("pygitgo.commands.undo.undo_add")
|
|
75
|
+
def test_undo_operations_add(mock_undo_add):
|
|
76
|
+
args = Namespace(action="add")
|
|
77
|
+
undo_operations(args)
|
|
78
|
+
mock_undo_add.assert_called_once()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@patch("pygitgo.commands.undo.undo_changes")
|
|
82
|
+
def test_undo_operations_changes(mock_undo_changes):
|
|
83
|
+
args = Namespace(action="changes")
|
|
84
|
+
undo_operations(args)
|
|
85
|
+
mock_undo_changes.assert_called_once()
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@patch("pygitgo.commands.undo.sys.exit")
|
|
89
|
+
@patch("pygitgo.commands.undo.error")
|
|
90
|
+
def test_undo_operations_invalid(mock_error, mock_exit):
|
|
91
|
+
args = Namespace(action="invalid")
|
|
92
|
+
undo_operations(args)
|
|
93
|
+
mock_error.assert_called_once()
|
|
94
|
+
mock_exit.assert_called_once_with(1)
|
|
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
|