mirror of
https://github.com/nvbn/thefuck.git
synced 2025-10-08 04:44:00 +01:00
#652: Add new git_push_different_branch_names rule
Fix #652 * Basic fix for #652 * Finishing work * Added readme line * Added test * My test was stupid... * Removed redundant lines * That space...
This commit is contained in:
committed by
Pablo Aguiar
parent
2233e3679c
commit
64d6835e15
39
tests/rules/test_git_push_different_branch_names.py
Normal file
39
tests/rules/test_git_push_different_branch_names.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import pytest
|
||||
from thefuck.rules.git_push_different_branch_names import get_new_command, match
|
||||
from thefuck.types import Command
|
||||
|
||||
|
||||
output = """fatal: The upstream branch of your current branch does not match
|
||||
the name of your current branch. To push to the upstream branch
|
||||
on the remote, use
|
||||
|
||||
git push origin HEAD:%s
|
||||
|
||||
To push to the branch of the same name on the remote, use
|
||||
|
||||
git push origin %s
|
||||
|
||||
To choose either option permanently, see push.default in 'git help config'.
|
||||
"""
|
||||
|
||||
|
||||
def error_msg(localbranch, remotebranch):
|
||||
return output % (remotebranch, localbranch)
|
||||
|
||||
|
||||
def test_match():
|
||||
assert match(Command('git push', error_msg('foo', 'bar')))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command('vim', ''),
|
||||
Command('git status', error_msg('foo', 'bar')),
|
||||
Command('git push', '')
|
||||
])
|
||||
def test_not_match(command):
|
||||
assert not match(command)
|
||||
|
||||
|
||||
def test_get_new_command():
|
||||
new_command = get_new_command(Command('git push', error_msg('foo', 'bar')))
|
||||
assert new_command == 'git push origin HEAD:bar'
|
Reference in New Issue
Block a user