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

Added git lock rule #883

wants to merge 3 commits into from

Conversation

tobibechtold
Copy link

No description provided.

@tobibechtold tobibechtold changed the title Added git lock rule WIP: Added git lock rule Feb 6, 2019
@tobibechtold tobibechtold changed the title WIP: Added git lock rule Added git lock rule Feb 6, 2019
@tobibechtold
Copy link
Author

My colleague and i just ran into a funny situation while pair programming and trying to bring an out of date branch up to date with the master. We weren't quite sure what actually has changed and he said "just type git log". And so i typed "git lock". He said no... log with a "g". So i said: " no problem, i got this" and typed "fuck". But instead of "log" fuck was suggesting "lsck". So this is the intent of this PR.

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.

That's a nice story! There's always some good outcome of pair programming. If only Git would list log as one of the most similar commands then your friend would be amazed 😄

As you probably know, there's already a git_not_command rule. I'd recommend changing it instead, in a way to include the most common typos. Something like having a dict like this:

COMMON_TYPOS = {
    'copy': ['branch'],
    'list': ['branch'],
    'lock': ['log'],
    'switch': ['checkout'],
    'update': ['fetch', 'fetch --all', 'fetch --all --tags', 'remote update'],
}

And then in get_new_command:

    # ...
    matched = [replace_argument(command.script, broken_cmd, common_typo)
               for common_typo in COMMON_TYPOS.get(broken_cmd, [])]
    # ...
    matched.extend(...)  # add Git's similar commands to the end of the list
    # ...

What do you think?

@tobibechtold
Copy link
Author

Hey that sounds like an even better idea. I will try to tackle this next week. Thank you :)

@scorphus
Copy link
Collaborator

scorphus commented Aug 8, 2021

Hey, @tobibechtold! Hopefully you're willing to have anoother look at this PR!

@scorphus scorphus added this to the 3.33 milestone Aug 8, 2021
@scorphus scorphus added this to To do in Release Pipeline Aug 8, 2021
@preetham1239
Copy link

Hello @scorphus

I'm new to open source and I am interested in contributing to thefuck. Can I work on this issue?

@scorphus
Copy link
Collaborator

Go for it, @preetham1239 😊

@preetham1239
Copy link

preetham1239 commented Jan 16, 2024

Hello @scorphus, I made a pull request #1429, please let me know if I need to make any changes as this is my first one.

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

Successfully merging this pull request may close these issues.

None yet

3 participants