1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 06:38:32 +00:00

Merge 6ec28073ed18470ed47eb4fc2c086d770f742490 into 6975d30818792f1b37de702fc93c66023c4c50d5

This commit is contained in:
Tobias Bechtold 2020-04-07 05:32:49 +03:00 committed by GitHub
commit 00352ef833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 0 deletions

View File

@ -214,6 +214,7 @@ following rules are enabled by default:
* `git_fix_stash` – fixes `git stash` commands (misspelled subcommand and missing `save`);
* `git_flag_after_filename` – fixes `fatal: bad flag '...' after filename`
* `git_help_aliased` &ndash; fixes `git help <alias>` commands replacing <alias> with the aliased command;
* `git_log` &ndash; replaces `git lock` command with `git log`;
* `git_merge` &ndash; adds remote to branch names;
* `git_merge_unrelated` &ndash; adds `--allow-unrelated-histories` when required
* `git_not_command` &ndash; fixes wrong git commands like `git brnch`;

View File

@ -0,0 +1,25 @@
import pytest
from thefuck.rules.git_log import match, get_new_command
from thefuck.types import Command
@pytest.mark.parametrize('script, output', [
('git lock', 'git: \'lock\' is not a git command.'),
('git lock --help', 'git: \'lock\' is not a git command.')])
def test_match(output, script):
assert match(Command(script, output))
@pytest.mark.parametrize('script', [
'git branch foo',
'git checkout feature/test_commit',
'git push'])
def test_not_match(script):
assert not match(Command(script, ''))
@pytest.mark.parametrize('script, output', [
('git lock', 'git log'),
('git lock --help', 'git log --help')])
def test_get_new_command(script, output):
assert get_new_command(Command(script, '')) == output

11
thefuck/rules/git_log.py Normal file
View File

@ -0,0 +1,11 @@
from thefuck.specific.git import git_support
@git_support
def match(command):
return 'git: \'lock\' is not a git command.' in command.output
@git_support
def get_new_command(command):
return command.script.replace('lock', 'log', 1)