1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-19 17:18:42 +00:00

Suggest git chekcout -b

This commit is contained in:
David 2018-01-01 15:54:43 +00:00
parent f966ecd4f5
commit 5bef2c60c5
2 changed files with 3 additions and 1 deletions

View File

@ -52,7 +52,7 @@ def test_get_branches(branches, branch_list, git_branch):
@pytest.mark.parametrize('branches, command, new_command', [ @pytest.mark.parametrize('branches, command, new_command', [
(b'', (b'',
Command('git checkout unknown', did_not_match('unknown')), Command('git checkout unknown', did_not_match('unknown')),
'git branch unknown && git checkout unknown'), 'git checkout -b unknown'),
(b'', (b'',
Command('git commit unknown', did_not_match('unknown')), Command('git commit unknown', did_not_match('unknown')),
'git branch unknown && git commit unknown'), 'git branch unknown && git commit unknown'),

View File

@ -34,6 +34,8 @@ def get_new_command(command):
fallback_to_first=False) fallback_to_first=False)
if closest_branch: if closest_branch:
return replace_argument(command.script, missing_file, closest_branch) return replace_argument(command.script, missing_file, closest_branch)
elif command.script.startswith('git checkout'):
return replace_argument(command.script, 'checkout', 'checkout -b')
else: else:
return shell.and_('git branch {}', '{}').format( return shell.and_('git branch {}', '{}').format(
missing_file, command.script) missing_file, command.script)