Support hub as well as git in @git_support
This commit is contained in:
+11
-3
@@ -75,12 +75,19 @@ def sudo_support(fn):
|
||||
|
||||
|
||||
def git_support(fn):
|
||||
"""Resolve git aliases."""
|
||||
"""Resolves git aliases and supports testing for both git and hub."""
|
||||
@wraps(fn)
|
||||
def wrapper(command, settings):
|
||||
if (command.script.startswith('git') and
|
||||
'trace: alias expansion:' in command.stderr):
|
||||
# supports GitHub's `hub` command
|
||||
# which is recommended to be used with `alias git=hub`
|
||||
# but at this point, shell aliases have already been resolved
|
||||
is_git_cmd = command.script.startswith(('git', 'hub'))
|
||||
|
||||
if not is_git_cmd:
|
||||
return False
|
||||
|
||||
# perform git aliases expansion
|
||||
if 'trace: alias expansion:' in command.stderr:
|
||||
search = re.search("trace: alias expansion: ([^ ]*) => ([^\n]*)",
|
||||
command.stderr)
|
||||
alias = search.group(1)
|
||||
@@ -93,6 +100,7 @@ def git_support(fn):
|
||||
new_script = command.script.replace(alias, expansion)
|
||||
|
||||
command = Command._replace(command, script=new_script)
|
||||
|
||||
return fn(command, settings)
|
||||
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user