mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +00:00
#N/A: Replace only exact words when expanding a Git alias
This commit is contained in:
parent
a2a6cbdc70
commit
eb05b28c5b
@ -6,7 +6,11 @@ from thefuck.types import Command
|
|||||||
@pytest.mark.parametrize('called, command, output', [
|
@pytest.mark.parametrize('called, command, output', [
|
||||||
('git co', 'git checkout', "19:22:36.299340 git.c:282 trace: alias expansion: co => 'checkout'"),
|
('git co', 'git checkout', "19:22:36.299340 git.c:282 trace: alias expansion: co => 'checkout'"),
|
||||||
('git com file', 'git commit --verbose file',
|
('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):
|
def test_git_support(called, command, output):
|
||||||
@git_support
|
@git_support
|
||||||
def fn(command):
|
def fn(command):
|
||||||
|
@ -25,7 +25,7 @@ def git_support(fn, command):
|
|||||||
# eg. 'git commit'
|
# eg. 'git commit'
|
||||||
expansion = ' '.join(shell.quote(part)
|
expansion = ' '.join(shell.quote(part)
|
||||||
for part in shell.split_command(search.group(2)))
|
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)
|
command = command.update(script=new_script)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user