mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
Merge branch 'juzim-git-pull-uncommitted-changes'
This commit is contained in:
commit
9660ec7813
@ -103,7 +103,6 @@ brew install thefuck
|
|||||||
```
|
```
|
||||||
|
|
||||||
On Ubuntu you can install `The Fuck` with:
|
On Ubuntu you can install `The Fuck` with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install python3-dev python3-pip
|
sudo apt install python3-dev python3-pip
|
||||||
@ -135,7 +134,7 @@ To make them available immediately, run `source ~/.bashrc` (or your shell config
|
|||||||
## Update
|
## Update
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo pip install thefuck --upgrade
|
sudo -H pip install thefuck --upgrade
|
||||||
```
|
```
|
||||||
|
|
||||||
**Aliases changed in 1.34.**
|
**Aliases changed in 1.34.**
|
||||||
@ -174,6 +173,7 @@ using the matched rule and runs it. Rules enabled by default are as follows:
|
|||||||
* `git_not_command` – fixes wrong git commands like `git brnch`;
|
* `git_not_command` – fixes wrong git commands like `git brnch`;
|
||||||
* `git_pull` – sets upstream before executing previous `git pull`;
|
* `git_pull` – sets upstream before executing previous `git pull`;
|
||||||
* `git_pull_clone` – clones instead of pulling when the repo does not exist;
|
* `git_pull_clone` – clones instead of pulling when the repo does not exist;
|
||||||
|
* `git_pull_uncommitted_changes` – stashes changes before pulling and pops them afterwards;
|
||||||
* `git_push` – adds `--set-upstream origin $branch` to previous failed `git push`;
|
* `git_push` – adds `--set-upstream origin $branch` to previous failed `git push`;
|
||||||
* `git_push_pull` – runs `git pull` when `push` was rejected;
|
* `git_push_pull` – runs `git pull` when `push` was rejected;
|
||||||
* `git_rebase_no_changes` – runs `git rebase --skip` instead of `git rebase --continue` when there are no changes;
|
* `git_rebase_no_changes` – runs `git rebase --skip` instead of `git rebase --continue` when there are no changes;
|
||||||
|
19
tests/rules/test_git_pull_uncommitted_changes.py
Normal file
19
tests/rules/test_git_pull_uncommitted_changes.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import pytest
|
||||||
|
from thefuck.rules.git_pull_uncommitted_changes import match, get_new_command
|
||||||
|
from tests.utils import Command
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def stderr():
|
||||||
|
return '''error: Cannot pull with rebase: You have unstaged changes.'''
|
||||||
|
|
||||||
|
|
||||||
|
def test_match(stderr):
|
||||||
|
assert match(Command('git pull', stderr=stderr))
|
||||||
|
assert not match(Command('git pull'))
|
||||||
|
assert not match(Command('ls', stderr=stderr))
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_new_command(stderr):
|
||||||
|
assert get_new_command(Command('git pull', stderr=stderr)) \
|
||||||
|
== "git stash && git pull && git stash pop"
|
19
tests/rules/test_git_pull_unstaged_changes.py
Normal file
19
tests/rules/test_git_pull_unstaged_changes.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import pytest
|
||||||
|
from thefuck.rules.git_pull_uncommitted_changes import match, get_new_command
|
||||||
|
from tests.utils import Command
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def stderr():
|
||||||
|
return '''error: Cannot pull with rebase: Your index contains uncommitted changes.'''
|
||||||
|
|
||||||
|
|
||||||
|
def test_match(stderr):
|
||||||
|
assert match(Command('git pull', stderr=stderr))
|
||||||
|
assert not match(Command('git pull'))
|
||||||
|
assert not match(Command('ls', stderr=stderr))
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_new_command(stderr):
|
||||||
|
assert get_new_command(Command('git pull', stderr=stderr)) \
|
||||||
|
== "git stash && git pull && git stash pop"
|
14
thefuck/rules/git_pull_uncommitted_changes.py
Normal file
14
thefuck/rules/git_pull_uncommitted_changes.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from thefuck.shells import shell
|
||||||
|
from thefuck.specific.git import git_support
|
||||||
|
|
||||||
|
|
||||||
|
@git_support
|
||||||
|
def match(command):
|
||||||
|
return ('pull' in command.script
|
||||||
|
and ('You have unstaged changes' in command.stderr
|
||||||
|
or 'contains uncommitted changes' in command.stderr))
|
||||||
|
|
||||||
|
|
||||||
|
@git_support
|
||||||
|
def get_new_command(command):
|
||||||
|
return shell.and_('git stash', 'git pull', 'git stash pop')
|
Loading…
x
Reference in New Issue
Block a user