1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-20 20:09:07 +00:00

Merge branch 'juzim-git-pull-uncommitted-changes'

This commit is contained in:
Vladimir Iakovlev 2016-09-20 00:28:51 +02:00
commit 9660ec7813
4 changed files with 54 additions and 2 deletions

View File

@ -103,7 +103,6 @@ brew install thefuck
```
On Ubuntu you can install `The Fuck` with:
```bash
sudo apt update
sudo apt install python3-dev python3-pip
@ -135,7 +134,7 @@ To make them available immediately, run `source ~/.bashrc` (or your shell config
## Update
```bash
sudo pip install thefuck --upgrade
sudo -H pip install thefuck --upgrade
```
**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_pull` – sets upstream before executing previous `git pull`;
* `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_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;

View 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"

View 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"

View 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')