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

Add completions for git fork #2291

Merged
merged 5 commits into from Oct 4, 2019

Conversation

@sinisterstuf
Copy link
Contributor

commented Oct 3, 2019

Based on the manual page for git fork, this pull request adds --remote-name and --org completions, waiting for user-provided free-text as arguments to both. It also considers the --remote-name and --no-remote flags to be mutually exclusive. See commit messages for details.

Fixes #2108.

sinisterstuf added 5 commits Oct 3, 2019
Instead of adding more if statements I swapped the remote=yes variable
for a list of available flags which we drop elements from on each
completion.  This is based on the logic in git create above.

Fixes #2108.
Because this is an array of flags now, adding new flags is as simple as
adding more elements to the array and to the case statement.
The --remote-name and --org parameters to git fork expect arguments
which can be considered free text because the user has to suggest a
name, so we can't provide suggestions there.

If one of those two was the previous word then we clear completion
suggestions until a free-text word has been entered, allowing the user
to add their own input there.
Because it wouldn't make sense to set a name for a remote when you ask
it not to add a remote (or vice versa) these two flags are mutually
exclusive.

For lack of an idea for a more elegant solution, I've made it so that
whenever either of them matches, the other will also be dropped from the
available flags list.  This works perfectly for now but will probably
need to be revisited if any other such parameters are added in future.
Now that there are 3 different flags all starting with the same two
dashes, the previous test case (that pressing Tab will expand to
--no-remote) will fail.

The previous test case has been replaced with one that expects a list of
completion options matching those provided for git fork.
@sinisterstuf sinisterstuf marked this pull request as ready for review Oct 3, 2019
@sinisterstuf

This comment has been minimized.

Copy link
Contributor Author

commented Oct 3, 2019

Shell completion tests don't seem to run in the Travis builds, but I updated the bash completion feature file to match the code changes in this pull request.

@mislav mislav merged commit 51a2565 into github:master Oct 4, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@mislav

This comment has been minimized.

Copy link
Member

commented Oct 4, 2019

Sweet! Thank you 🎉

Shell completion tests don't seem to run in the Travis builds

Yeah, unfortunately I had to disable them because Travis made a change to their infrastructure that somehow disabled running an interactive shell inside tmux during builds. 😞

@sinisterstuf sinisterstuf deleted the sinisterstuf:fork-completions branch Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.