-
Notifications
You must be signed in to change notification settings - Fork 232
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
custom-completions: git: Include remote branches #407
Conversation
I'm a little worried about this because the regexes are so radically different. Will this get remote branches too? I wonder since the |
Thanks for asking again @fdncred 🙂 - turns out there was a subtle difference in the output which I found while writing an explanation. Actually, I think we need different completions for
Here are some differences:
I added the completion command now separately instead of replacing the "switchable branches" and updated the argument completions accordingly. Does it make sense like this? |
fb24a45
to
fcc8e38
Compare
| parse "{value}" | ||
| insert description Branch | ||
| append (nu-complete git commits) | ||
} | ||
|
||
# Check out git branches and files | ||
export extern "git checkout" [ | ||
...targets: string@"nu-complete git switchable branches" # name of the branch or files to checkout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we do here? Add yet another completion command or concatenate the output of two and make it unique?
The below commands are all valid
git checkout local-branch
git checkout remote-branch-without-prefix
git checkout upstream/remote-branch-without-prefix
git checkout 234commit456hash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm wrong here, but I'm thinking we'd concatenate and unique the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK that would work 👍 One further question: Should the completion suggestions be a flat list (as in the current version of git switch
) or a table with value
/description
pairs? The flat list makes better use of limited terminal space, but especially commit suggestions may be useless without any description alongside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you maybe use a parameter to allow one to choose --verbose to show the value/description version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm but how exactly would that work? A parameter to using the completion, or a parameter in the git
command? 🤔
Thanks for the thorough explanation @sgasse. |
fcc8e38
to
514b55c
Compare
The different commands such as `git checkout`, `git switch`, `git cherry-pick` and `git rebase` all accept slightly differing refspecs. This commit separates the extraction of refspecs and combines them in individual completion commands for the different external commands. All git commands complete with a table of `value | description` now. Addresses nushell#406
514b55c
to
6b289e2
Compare
Hi, sorry for the wait - I was busy with some stuff. Took another stab at it and I think it makes sense to separate the individual completion parts into different functions. Here are five different parts:
Here is who accepts what:
I personally would never need 5 (all commits) in I also saw that there were some changes and rebased on them updating namings where needed. Could you take another look at how you like it @fdncred ? Below are screenshots of how it looks on the current version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the changes.
This commit adds remote branches (e.g. origin/main, github/feature-a etc.) to the output of the helper command
nu-complete git switchable branches
.Addresses #406