mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
Added rule that stashes changed files before pulling and pops them afterwards.
This commit is contained in:
parent
bcc11219e6
commit
af9d34c299
@ -174,6 +174,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;
|
||||
|
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 'git stash && git pull && git stash pop'
|
Loading…
x
Reference in New Issue
Block a user