Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added git lock rule #883

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,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`;
Expand Down
25 changes: 25 additions & 0 deletions tests/rules/test_git_log.py
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions thefuck/rules/git_log.py
Original file line number Diff line number Diff line change
@@ -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)