1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-11-01 07:32:09 +00:00

Compare commits

...

19 Commits
3.16 ... 3.19

Author SHA1 Message Date
Vladimir Iakovlev
2bbba9a0c8 Bump to 3.19 2017-08-03 11:34:01 +02:00
Vladimir Iakovlev
b978c3793e Merge pull request #669 from tomoshi0809/master
#630 Catching the escaped space in filenames
2017-07-22 20:11:03 +02:00
KEI
8a83b30e73 Corrected the part for splitting a command 2017-07-19 00:09:21 +09:00
Vladimir Iakovlev
fd20a3f832 Merge pull request #657 from josephfrazier/git_not_command-wording
Update stderr wording of git_not_command
2017-06-19 23:12:46 +02:00
Joseph Frazier
b6ed499103 Make git_not_command stderr detection backward-compatible 2017-06-06 13:56:13 -04:00
Joseph Frazier
76600cf40a Update stderr wording of git_not_command
This changed in git v2.13.1, see
6c48686263 (diff-081cf476dd9ac3b05c183570de47cb23)
2017-06-05 17:29:42 -04:00
Vladimir Iakovlev
e62666181a #650: #651: #646: Recommend to install thefuck globally 2017-05-29 10:11:15 +02:00
Vladimir Iakovlev
c88b0792b8 Bump to 3.18 2017-05-10 16:51:19 +02:00
Vladimir Iakovlev
06a89427e2 #N/A: Fix bash alias on ci 2017-05-10 16:40:57 +02:00
Vladimir Iakovlev
3a134f250d Bump to 3.17 2017-05-10 15:34:06 +02:00
Vladimir Iakovlev
b54cdf7c49 #637: Suggest yarn add on yarn require 2017-05-10 15:32:11 +02:00
Vladimir Iakovlev
1b05a497e8 #635: Show "Nothing found" instead of 'No fucks given' when different alias are used 2017-05-10 15:22:26 +02:00
Vladimir Iakovlev
79602383ec #549: Fix aliases with bash 2017-05-10 15:14:01 +02:00
Vladimir Iakovlev
84c42168df #N/A: Add new line after version 2017-05-10 15:06:29 +02:00
Vladimir Iakovlev
f53d772ac3 Merge pull request #640 from bam241/add_macport_to_sudo
fix sudo.py for macport
2017-05-03 12:08:53 +04:00
Mouginot B
93d4a4fc3a fix sudo.py for macport 2017-05-02 17:36:35 -05:00
Vladimir Iakovlev
2cb23b1805 #N/A: Fix docstring 2017-05-01 17:49:13 +02:00
Vladimir Iakovlev
33f28cf76d #633: Show ci badges for master 2017-04-20 21:34:47 +02:00
Vladimir Iakovlev
6322dbd9ed #N/A: Fix flake8 warnings 2017-04-10 23:23:23 +02:00
17 changed files with 56 additions and 33 deletions

View File

@@ -106,13 +106,13 @@ On Ubuntu you can install `The Fuck` with:
```bash
sudo apt update
sudo apt install python3-dev python3-pip
pip3 install --user thefuck
sudo pip3 install thefuck
```
On other systems you can install `The Fuck` with `pip`:
```bash
pip install --user thefuck
pip install thefuck
```
[Or using an OS package manager (OS X, Ubuntu, Arch).](https://github.com/nvbn/thefuck/wiki/Installation)
@@ -139,7 +139,7 @@ alias fuck-it='export THEFUCK_REQUIRE_CONFIRMATION=False; fuck; export THEFUCK_R
## Update
```bash
pip install --user thefuck --upgrade
pip install thefuck --upgrade
```
**Aliases changed in 1.34.**
@@ -429,9 +429,9 @@ Project License can be found [here](LICENSE.md).
[version-badge]: https://img.shields.io/pypi/v/thefuck.svg?label=version
[version-link]: https://pypi.python.org/pypi/thefuck/
[travis-badge]: https://img.shields.io/travis/nvbn/thefuck.svg
[travis-badge]: https://travis-ci.org/nvbn/thefuck.svg?branch=master
[travis-link]: https://travis-ci.org/nvbn/thefuck
[appveyor-badge]: https://img.shields.io/appveyor/ci/nvbn/thefuck.svg?label=windows%20build
[appveyor-badge]: https://ci.appveyor.com/api/projects/status/1sskj4imj02um0gu/branch/master?svg=true
[appveyor-link]: https://ci.appveyor.com/project/nvbn/thefuck
[coverage-badge]: https://img.shields.io/coveralls/nvbn/thefuck.svg
[coverage-link]: https://coveralls.io/github/nvbn/thefuck

View File

@@ -29,7 +29,7 @@ elif (3, 0) < version < (3, 3):
' ({}.{} detected).'.format(*version))
sys.exit(-1)
VERSION = '3.16'
VERSION = '3.19'
install_requires = ['psutil', 'colorama', 'six', 'decorator']
extras_require = {':python_version<"3.4"': ['pathlib2'],

View File

@@ -7,7 +7,7 @@ shells.shell = shells.Generic()
def pytest_addoption(parser):
"""Adds `--run-without-docker` argument."""
"""Adds `--enable-functional` argument."""
group = parser.getgroup("thefuck")
group.addoption('--enable-functional', action="store_true", default=False,
help="Enable functional tests")

View File

@@ -39,7 +39,6 @@ parametrize_extensions = pytest.mark.parametrize('ext', tar_extensions)
# (filename as typed by the user, unquoted filename, quoted filename as per shells.quote)
parametrize_filename = pytest.mark.parametrize('filename, unquoted, quoted', [
('foo{}', 'foo{}', 'foo{}'),
('foo\ bar{}', 'foo bar{}', "'foo bar{}'"),
('"foo bar{}"', 'foo bar{}', "'foo bar{}'")])
parametrize_script = pytest.mark.parametrize('script, fixed', [

View File

@@ -64,7 +64,6 @@ def test_side_effect(zip_error, script, filename):
@pytest.mark.parametrize('script,fixed,filename', [
(u'unzip café', u"unzip café -d 'café'", u'café.zip'),
(u'unzip foo', u'unzip foo -d foo', u'foo.zip'),
(u"unzip foo\\ bar.zip", u"unzip foo\\ bar.zip -d 'foo bar'", u'foo.zip'),
(u"unzip 'foo bar.zip'", u"unzip 'foo bar.zip' -d 'foo bar'", u'foo.zip'),
(u'unzip foo.zip', u'unzip foo.zip -d foo', u'foo.zip')])
def test_get_new_command(zip_error, script, fixed, filename):

View File

@@ -7,7 +7,7 @@ from tests.utils import Command
def git_not_command():
return """git: 'brnch' is not a git command. See 'git --help'.
Did you mean this?
The most similar command is
branch
"""
@@ -16,7 +16,7 @@ branch
def git_not_command_one_of_this():
return """git: 'st' is not a git command. See 'git --help'.
Did you mean one of these?
The most similar commands are
status
reset
stage
@@ -29,7 +29,7 @@ stats
def git_not_command_closest():
return '''git: 'tags' is not a git command. See 'git --help'.
Did you mean one of these?
The most similar commands are
\tstage
\ttag
'''

View File

@@ -17,7 +17,7 @@ def test_match(script):
assert match(Command(script))
@pytest.mark.parametrize('script', ['git branch' 'vimfile'])
@pytest.mark.parametrize('script', ['git branch', 'vimfile'])
def test_not_match(script):
assert not match(Command(script))

View File

@@ -106,6 +106,13 @@ def test_not_match(command):
@pytest.mark.parametrize('command, result', [
(Command('yarn whyy webpack', stderr=stderr('whyy')), 'yarn why webpack')])
(Command('yarn whyy webpack', stderr=stderr('whyy')),
'yarn why webpack'),
(Command('yarn require lodash', stderr=stderr('require')),
'yarn add lodash')])
def test_get_new_command(command, result):
assert get_new_command(command)[0] == result
fixed_command = get_new_command(command)
if isinstance(fixed_command, list):
fixed_command = fixed_command[0]
assert fixed_command == result

View File

@@ -125,5 +125,5 @@ def configured_successfully(configuration_details):
def version(thefuck_version, python_version):
sys.stderr.write(
u'The Fuck {} using Python {}'.format(thefuck_version,
python_version))
u'The Fuck {} using Python {}\n'.format(thefuck_version,
python_version))

View File

@@ -6,12 +6,13 @@ from thefuck.specific.git import git_support
@git_support
def match(command):
return (" is not a git command. See 'git --help'." in command.stderr
and 'Did you mean' in command.stderr)
and ('The most similar command' in command.stderr
or 'Did you mean' in command.stderr))
@git_support
def get_new_command(command):
broken_cmd = re.findall(r"git: '([^']*)' is not a git command",
command.stderr)[0]
matched = get_all_matched_commands(command.stderr)
matched = get_all_matched_commands(command.stderr, ['The most similar command', 'Did you mean'])
return replace_command(command, broken_cmd, matched)

View File

@@ -1,4 +1,4 @@
from thefuck.utils import get_all_executables, memoize, which
from thefuck.utils import get_all_executables, memoize
@memoize

View File

@@ -21,7 +21,8 @@ patterns = ['permission denied',
'edspermissionerror',
'you don\'t have write permissions',
'use `sudo`',
'SudoRequiredError']
'SudoRequiredError',
'error: insufficient privileges']
def match(command):

View File

@@ -1,6 +1,6 @@
import re
from subprocess import Popen, PIPE
from thefuck.utils import for_app, eager, replace_command
from thefuck.utils import for_app, eager, replace_command, replace_argument
regex = re.compile(r'error Command "(.*)" not found.')
@@ -10,6 +10,9 @@ def match(command):
return regex.findall(command.stderr)
npm_commands = {'require': 'add'}
@eager
def _get_all_tasks():
proc = Popen(['yarn', '--help'], stdout=PIPE)
@@ -27,5 +30,9 @@ def _get_all_tasks():
def get_new_command(command):
misspelled_task = regex.findall(command.stderr)[0]
tasks = _get_all_tasks()
return replace_command(command, misspelled_task, tasks)
if misspelled_task in npm_commands:
yarn_command = npm_commands[misspelled_task]
return replace_argument(command.script, misspelled_task, yarn_command)
else:
tasks = _get_all_tasks()
return replace_command(command, misspelled_task, tasks)

View File

@@ -11,12 +11,14 @@ class Bash(Generic):
return '''
function {name} () {{
TF_PREVIOUS=$(fc -ln -1);
TF_PYTHONIOENCODING=$PYTHONIOENCODING;
export TF_ALIAS={name};
export TF_SHELL_ALIASES=$(alias);
export PYTHONIOENCODING=utf-8;
TF_CMD=$(
TF_ALIAS={name}
TF_SHELL_ALIASES=$(alias)
PYTHONIOENCODING=utf-8
thefuck $TF_PREVIOUS {argument_placeholder} $@
) && eval $TF_CMD;
export PYTHONIOENCODING=$TF_PYTHONIOENCODING;
{alter_history}
}}
'''.format(

View File

@@ -77,7 +77,7 @@ class Generic(object):
encoded = self.encode_utf8(command)
try:
splitted = shlex.split(encoded)
splitted = [s.replace("??", "\ ") for s in shlex.split(encoded.replace('\ ', '??'))]
except ValueError:
splitted = encoded.split(' ')

View File

@@ -4,6 +4,7 @@ import sys
from .conf import settings
from .exceptions import NoRuleMatched
from .system import get_key
from .utils import get_alias
from . import logs, const
@@ -69,7 +70,8 @@ def select_command(corrected_commands):
try:
selector = CommandSelector(corrected_commands)
except NoRuleMatched:
logs.failed('No fucks given')
logs.failed('No fucks given' if get_alias() == 'fuck'
else 'Nothing found')
return
if not settings.require_confirmation:

View File

@@ -141,12 +141,17 @@ def eager(fn, *args, **kwargs):
@eager
def get_all_matched_commands(stderr, separator='Did you mean'):
if not isinstance(separator, list):
separator = [separator]
should_yield = False
for line in stderr.split('\n'):
if separator in line:
should_yield = True
elif should_yield and line:
yield line.strip()
for sep in separator:
if sep in line:
should_yield = True
break
else:
if should_yield and line:
yield line.strip()
def replace_command(command, broken, matched):