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

Rule for branch dash 0 #942

Merged
merged 8 commits into from
Jul 1, 2021
Merged

Conversation

ProfessorTom
Copy link
Contributor

fixes fat-fingering git branch -0 instead of git branch -v

...deleting branch `0v` and running `git branch -v` as the user intended
@nvbn
Copy link
Owner

nvbn commented Aug 19, 2019

Nice idea, maybe it will be a good thing to make that more generic? To just replace any argument that starts with 0 if it appears in stderr.

@ProfessorTom
Copy link
Contributor Author

@nvbn When I quickly read your comment on my phone, I thought making this fix more generic sounded like a good idea, but upon reflection, I'm not so sure.

In the specific case I coded up, the argument needs to turn into a flag. Would making that assumption more generic (i.e. convert all arguments starting with 0 to -) make sense?

For that matter, what would the "undo" action look like, or would there even need to be an "undo" action? (In the specific example here, I need to delete a branch that was just accidentally created...what should the proper response be if git branch 0v wasn't the command?

@nvbn
Copy link
Owner

nvbn commented Aug 21, 2019

@ProfessorTom you're right, initially I thought that git branch 0v prints something, but it just creates a branch.

I guess the only way to generalize this rule is to also support cases like git branch 0l, git branch 0a and etc, so just check that the argument after branch starts with 0.

@ProfessorTom
Copy link
Contributor Author

Do you still want me to generalize this feature turning the 0 into a - and deleting the branch just created in all cases?

Is there a case where this would cause more harm than good?

@ProfessorTom
Copy link
Contributor Author

bumping to get a review and hopefully a merge.

Copy link
Collaborator

@scorphus scorphus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for contributing! Please mind my change requests including the correct naming of the test file test_get_branch_0v_to_dash_v.py into test_git_branch_0v_to_dash_v.py.

tests/rules/test_get_branch_0v_to_dash_v.py Outdated Show resolved Hide resolved
thefuck/rules/git_branch_0v_to_dash_v.py Outdated Show resolved Hide resolved
tests/rules/test_get_branch_0v_to_dash_v.py Outdated Show resolved Hide resolved
@ProfessorTom
Copy link
Contributor Author

@scorphus @nvbn Can I get a review on my latest changes?

@ProfessorTom
Copy link
Contributor Author

What will it take to get this new approach reviewed and merged? cc @nvbn @scorphus @jamtur01

@scorphus scorphus merged commit 24576b3 into nvbn:master Jul 1, 2021
@scorphus
Copy link
Collaborator

scorphus commented Jul 1, 2021

Thank you for contributing, @ProfessorTom 👍

Please check a new PR, which is probably going to be #1212.

@ProfessorTom
Copy link
Contributor Author

Thank you for merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants