Allow multiple returns from git_checkout (#1022)

* Allow multiple returns from git_checkout

* Remove multiple returns
This commit is contained in:
David Hart
2020-01-13 22:28:20 +00:00
committed by Vladimir Iakovlev
parent b28ece0f34
commit 2ced7a7f33
2 changed files with 16 additions and 10 deletions
+12 -6
View File
@@ -34,10 +34,16 @@ def get_new_command(command):
r"did not match any file\(s\) known to git", command.output)[0]
closest_branch = utils.get_closest(missing_file, get_branches(),
fallback_to_first=False)
new_commands = []
if closest_branch:
return replace_argument(command.script, missing_file, closest_branch)
elif command.script_parts[1] == 'checkout':
return replace_argument(command.script, 'checkout', 'checkout -b')
else:
return shell.and_('git branch {}', '{}').format(
missing_file, command.script)
new_commands.append(replace_argument(command.script, missing_file, closest_branch))
if command.script_parts[1] == 'checkout':
new_commands.append(replace_argument(command.script, 'checkout', 'checkout -b'))
if not new_commands:
new_commands.append(shell.and_('git branch {}', '{}').format(
missing_file, command.script))
return new_commands