Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -203,6 +203,7 @@ following rules are enabled by default:
* `git_branch_delete` – changes `git branch -d` to `git branch -D`;
* `git_branch_exists` – offers `git branch -d foo`, `git branch -D foo` or `git checkout foo` when creating a branch that already exists;
* `git_branch_list` – catches `git branch list` in place of `git branch` and removes created branch;
* `git_branch_0v_to_dash_v` – undoes `git branch 0v` and runs `git branch -v` in its place;
* `git_checkout` – fixes branch name or creates new branch;
* `git_commit_amend` – offers `git commit --amend` after previous commit;
* `git_commit_reset` – offers `git reset HEAD~` after previous commit;
Expand Down
19 changes: 19 additions & 0 deletions tests/rules/test_get_branch_0v_to_dash_v.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest
from thefuck.rules.git_branch_0v_to_dash_v import match, get_new_command
from thefuck.types import Command


@pytest.fixture
def output():
return ""


def test_match(output):
assert match(Command('git branch 0v', output))
assert not match(Command('git branch -v', ''))
assert not match(Command('ls', output))


def test_get_new_command(output):
assert get_new_command(Command('git branch 0v', output))\
== "git branch -D 0v && git branch -v"
13 changes: 13 additions & 0 deletions thefuck/rules/git_branch_0v_to_dash_v.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from thefuck.shells import shell
from thefuck.specific.git import git_support


@git_support
def match(command):
return (command.script_parts
and command.script_parts[1:] == 'branch 0v'.split())


@git_support
def get_new_command(command):
return shell.and_('git branch -D 0v', 'git branch -v')