mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 10:11:14 +00:00
Merge pull request #582 from josephfrazier/git_stash_pop
Fix `git stash pop` with local changes
This commit is contained in:
commit
e313ff73a9
@ -187,6 +187,7 @@ using the matched rule and runs it. Rules enabled by default are as follows:
|
|||||||
* `git_rebase_merge_dir` – offers `git rebase (--continue | --abort | --skip)` or removing the `.git/rebase-merge` dir when a rebase is in progress;
|
* `git_rebase_merge_dir` – offers `git rebase (--continue | --abort | --skip)` or removing the `.git/rebase-merge` dir when a rebase is in progress;
|
||||||
* `git_remote_seturl_add` – runs `git remote add` when `git remote set_url` on nonexistant remote;
|
* `git_remote_seturl_add` – runs `git remote add` when `git remote set_url` on nonexistant remote;
|
||||||
* `git_stash` – stashes you local modifications before rebasing or switching branch;
|
* `git_stash` – stashes you local modifications before rebasing or switching branch;
|
||||||
|
* `git_stash_pop` – adds your local modifications before popping stash, then resets;
|
||||||
* `git_two_dashes` – adds a missing dash to commands like `git commit -amend` or `git rebase -continue`;
|
* `git_two_dashes` – adds a missing dash to commands like `git commit -amend` or `git rebase -continue`;
|
||||||
* `go_run` – appends `.go` extension when compiling/running Go programs;
|
* `go_run` – appends `.go` extension when compiling/running Go programs;
|
||||||
* `gradle_no_task` – fixes not found or ambiguous `gradle` task;
|
* `gradle_no_task` – fixes not found or ambiguous `gradle` task;
|
||||||
|
18
tests/rules/test_git_stash_pop.py
Normal file
18
tests/rules/test_git_stash_pop.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import pytest
|
||||||
|
from thefuck.rules.git_stash_pop import match, get_new_command
|
||||||
|
from tests.utils import Command
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def stderr():
|
||||||
|
return '''error: Your local changes to the following files would be overwritten by merge:'''
|
||||||
|
|
||||||
|
|
||||||
|
def test_match(stderr):
|
||||||
|
assert match(Command('git stash pop', stderr=stderr))
|
||||||
|
assert not match(Command('git stash'))
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_new_command(stderr):
|
||||||
|
assert get_new_command(Command('git stash pop', stderr=stderr)) \
|
||||||
|
== "git add . && git stash pop && git reset ."
|
18
thefuck/rules/git_stash_pop.py
Normal file
18
thefuck/rules/git_stash_pop.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from thefuck.shells import shell
|
||||||
|
from thefuck.specific.git import git_support
|
||||||
|
|
||||||
|
|
||||||
|
@git_support
|
||||||
|
def match(command):
|
||||||
|
return ('stash' in command.script
|
||||||
|
and 'pop' in command.script
|
||||||
|
and 'Your local changes to the following files would be overwritten by merge' in command.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
@git_support
|
||||||
|
def get_new_command(command):
|
||||||
|
return shell.and_('git add .', 'git stash pop', 'git reset .')
|
||||||
|
|
||||||
|
|
||||||
|
# make it come before the other applicable rules
|
||||||
|
priority = 900
|
Loading…
x
Reference in New Issue
Block a user