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

[RFC] contrib: Add bash completions #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dcbaker
Copy link

@dcbaker dcbaker commented Sep 29, 2016

I'm definitely not a bash completions wizard, but it was annoying me
enough to scratch my own itch. These completions are fairly completely
(req isn't implemented, but git doesn't have completions for
pull-request either).

This is based on git bash completions included in git (and in fact rely on
them) making them a derivative work, and therefore GPLv2. I chose to leverage
the existing git completions because they made it rather easy to implement.

Fixes #20

I'm definitely not a bash completions wizard, but it was annoying me
enough to scratch my own itch. These completions are fairly completely
(req isn't implemented, but git doesn't have completions for
pull-request either).

This is based on git bash completions included in git (and in fact rely
on them) making them a derivative work, and therefore GPLv2.

Fixes git-series#20
@joshtriplett
Copy link
Member

Thanks, I really appreciate this!

I'd like to avoid duplication between the bash completions and the code as much as I can, so I'd hoped to make use of the clap argument parser's automatic bash completions. However, clap doesn't currently support extending those completions with things like git refs or series names.

Given that, I'm inclined to merge something like this for now, and potentially update it in the future to use generated completions once clap supports extending them.

A few bits of feedback:

  • This uses __gitcomp and similar, but doesn't ensure that the git completions are installed. At completion load time, this needs to make sure that __gitcomp exists.
  • The completion for git series add and similar shouldn't hard-code series, base, and cover. Ideally, it should look at the set of outstanding changes to determine what to complete (like the completion for git add does)
  • Completions for possible series to check out needs to include not just series under refs/heads/git-series/*, but also series under refs/git-series-internals/{working,staged}/*. A series that doesn't have any commits yet will have working and staged refs but no git-series ref yet.
  • For any completion that requires running non-trivial code (such as multiple different git commands), please feel free to add a hidden option to git-series and invoke that, if that's easier.
  • The completion for git series format should include --subject-prefix.

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.

2 participants