1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-05 18:31:10 +01:00

#N/A: Replace only exact words when expanding a Git alias

This commit is contained in:
Pablo Santiago Blum de Aguiar 2021-07-13 22:33:00 +02:00 committed by Pablo Aguiar
parent a2a6cbdc70
commit eb05b28c5b
2 changed files with 6 additions and 2 deletions

View File

@ -6,7 +6,11 @@ from thefuck.types import Command
@pytest.mark.parametrize('called, command, output', [
('git co', 'git checkout', "19:22:36.299340 git.c:282 trace: alias expansion: co => 'checkout'"),
('git com file', 'git commit --verbose file',
"19:23:25.470911 git.c:282 trace: alias expansion: com => 'commit' '--verbose'")])
"19:23:25.470911 git.c:282 trace: alias expansion: com => 'commit' '--verbose'"),
('git com -m "Initial commit"', 'git commit -m "Initial commit"',
"19:22:36.299340 git.c:282 trace: alias expansion: com => 'commit'"),
('git br -d some_branch', 'git branch -d some_branch',
"19:22:36.299340 git.c:282 trace: alias expansion: br => 'branch'")])
def test_git_support(called, command, output):
@git_support
def fn(command):

View File

@ -25,7 +25,7 @@ def git_support(fn, command):
# eg. 'git commit'
expansion = ' '.join(shell.quote(part)
for part in shell.split_command(search.group(2)))
new_script = command.script.replace(alias, expansion)
new_script = re.sub(r"\b{}\b".format(alias), expansion, command.script)
command = command.update(script=new_script)