Start support for git aliases
This commit is contained in:
@@ -2,6 +2,7 @@ from difflib import get_close_matches
|
||||
from functools import wraps
|
||||
import os
|
||||
import pickle
|
||||
import re
|
||||
import six
|
||||
from .types import Command
|
||||
|
||||
@@ -73,6 +74,25 @@ def sudo_support(fn):
|
||||
return wrapper
|
||||
|
||||
|
||||
def git_support(fn):
|
||||
"""Resolve git aliases."""
|
||||
@wraps(fn)
|
||||
def wrapper(command, settings):
|
||||
if (command.script.startswith('git') and
|
||||
'trace: alias expansion:' in command.stderr):
|
||||
|
||||
search = re.search("trace: alias expansion: ([^ ]*) => ([^\n]*)",
|
||||
command.stderr)
|
||||
alias = search.group(1)
|
||||
expansion = search.group(2)
|
||||
new_script = command.script.replace(alias, expansion)
|
||||
|
||||
command = Command._replace(command, script=new_script)
|
||||
return fn(command, settings)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def memoize(fn):
|
||||
"""Caches previous calls to the function."""
|
||||
memo = {}
|
||||
|
||||
Reference in New Issue
Block a user