mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-14 06:38:32 +00:00
Test getting status code
This commit is contained in:
parent
d3a05426de
commit
74291c0e8b
@ -3,7 +3,7 @@ from thefuck.specific.git import git_support
|
||||
|
||||
@git_support
|
||||
def match(command):
|
||||
return ('commit' in command.script_parts)
|
||||
return ('commit' in command.script_parts and 0 == command.status_code)
|
||||
|
||||
|
||||
@git_support
|
||||
|
@ -17,6 +17,7 @@ class Bash(Generic):
|
||||
function {name} () {{
|
||||
TF_PYTHONIOENCODING=$PYTHONIOENCODING;
|
||||
export TF_SHELL=bash;
|
||||
export TF_STATUS=$?;
|
||||
export TF_ALIAS={name};
|
||||
export TF_SHELL_ALIASES=$(alias);
|
||||
export TF_HISTORY=$(fc -ln -10);
|
||||
|
@ -58,7 +58,7 @@ class Fish(Generic):
|
||||
# It is VERY important to have the variables declared WITHIN the alias
|
||||
return ('function {0} -d "Correct your previous console command"\n'
|
||||
' set -l fucked_up_command $history[1]\n'
|
||||
' env TF_SHELL=fish TF_ALIAS={0} PYTHONIOENCODING=utf-8'
|
||||
' env TF_SHELL=fish TF_ALIAS={0} TF_STATUS=$status PYTHONIOENCODING=utf-8'
|
||||
' thefuck $fucked_up_command {2} $argv | read -l unfucked_command\n'
|
||||
' if [ "$unfucked_command" != "" ]\n'
|
||||
' eval $unfucked_command\n{1}'
|
||||
|
@ -23,6 +23,10 @@ class Command(object):
|
||||
self.script = script
|
||||
self.output = output
|
||||
|
||||
@property
|
||||
def status_code(self):
|
||||
return int(os.environ.get('TF_STATUS_CODE', 1))
|
||||
|
||||
@property
|
||||
def stdout(self):
|
||||
logs.warn('`stdout` is deprecated, please use `output` instead')
|
||||
@ -52,8 +56,8 @@ class Command(object):
|
||||
return False
|
||||
|
||||
def __repr__(self):
|
||||
return u'Command(script={}, output={})'.format(
|
||||
self.script, self.output)
|
||||
return u'Command(script={}, output={}, status_code={})'.format(
|
||||
self.script, self.output, self.status_code)
|
||||
|
||||
def update(self, **kwargs):
|
||||
"""Returns new command with replaced fields.
|
||||
|
Loading…
x
Reference in New Issue
Block a user