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

Added "contains work" error for git push

This commit is contained in:
Julian Zimmermann 2016-07-07 11:47:51 +02:00
parent a3b2e6872b
commit 837ca73f50
2 changed files with 30 additions and 1 deletions

View File

@ -13,6 +13,17 @@ To /tmp/foo
hint: See the 'Note about fast-forwards' in 'git push --help' for details. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
''' '''
git_err2 = '''
To /tmp/foo
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '/tmp/bar'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
'''
git_uptodate = 'Everything up-to-date' git_uptodate = 'Everything up-to-date'
git_ok = ''' git_ok = '''
Counting objects: 3, done. Counting objects: 3, done.
@ -33,6 +44,14 @@ def test_match(command):
assert match(command) assert match(command)
@pytest.mark.parametrize('command', [
Command(script='git push', stderr=git_err2),
Command(script='git push nvbn', stderr=git_err2),
Command(script='git push nvbn master', stderr=git_err2)])
def test_match(command):
assert match(command)
@pytest.mark.parametrize('command', [ @pytest.mark.parametrize('command', [
Command(script='git push', stderr=git_ok), Command(script='git push', stderr=git_ok),
Command(script='git push', stderr=git_uptodate), Command(script='git push', stderr=git_uptodate),
@ -52,3 +71,13 @@ def test_not_match(command):
'git pull nvbn master && git push nvbn master')]) 'git pull nvbn master && git push nvbn master')])
def test_get_new_command(command, output): def test_get_new_command(command, output):
assert get_new_command(command) == output assert get_new_command(command) == output
@pytest.mark.parametrize('command, output', [
(Command(script='git push', stderr=git_err2), 'git pull && git push'),
(Command(script='git push nvbn', stderr=git_err2),
'git pull nvbn && git push nvbn'),
(Command(script='git push nvbn master', stderr=git_err2),
'git pull nvbn master && git push nvbn master')])
def test_get_new_command(command, output):
assert get_new_command(command) == output

View File

@ -8,7 +8,7 @@ def match(command):
return ('push' in command.script return ('push' in command.script
and '! [rejected]' in command.stderr and '! [rejected]' in command.stderr
and 'failed to push some refs to' in command.stderr and 'failed to push some refs to' in command.stderr
and 'Updates were rejected because the tip of your current branch is behind' in command.stderr) and (('Updates were rejected because the tip of your current branch is behind' in command.stderr) or 'Updates were rejected because the remote contains work that you do' in command.stderr))
@git_support @git_support