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 completion script for dgit #615

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

Conversation

andrewshadura
Copy link

@andrewshadura andrewshadura commented Oct 4, 2021

This script autocompletes the most common subcommands, but only provides arguments autocompletion for only two of them, import-dsc and rpush, for practical reasons.

For dgit options, it provides two-level completion for the most popular options, excluding rarely used or dangerous ("use when you know what you’re doing") options. The two-levels work in a way to not overwhelm the user with options when they Tab twice, so only some but not all arguments to e.g. --quilt= are shown:

$ dgit --
--baredebian                                 --force-import-gitapply-no-absurd
--baredebian+git                             --force-reusing-version
--baredebian+tarball                         --force-unrepresentable
--build-products-dir=                        --force-unsupported-source-format
--clean                                      --force-uploading-binaries
--clean=dpkg-source                          --force-uploading-source-only
--clean=git                                  --gbp
--clean=git-ff                               --include-dirty
--damp-run                                   --new
--delayed=                                   --no-rm-on-error
--deliberately-fresh-repo                    --no-sign
--deliberately-include-questionable-history  --overwrite
--deliberately-not-fast-forward              --package
--dep14tag                                   --quilt
--distro=                                    --quilt=auto
--dpm                                        --quilt=linear
--dry-run                                    --rm-old-changes
--force-changes-origs-exactly                --save-dgit-view=
--force-dsc-changes-mismatch                 --split-view=
--force-import-dsc-with-dgit-field           --upstream-commitish=
--force-import-gitapply-absurd

However, when the user types --quilt=, the rest of them are shown:

$ dgit --quilt=
auto            baredebian+git      dpm      linear       nofix      unapplied
baredebian      baredebian+tarball  gbp      nocheck      smash

For --upstream-commitish= the script autocompletes some tags, starting with tags with the matching version, and the rest sorted by version:

$ dgit --upstream-commitish=upstream/1.
upstream/1.11.0  upstream/1.6.0

For options accepting both = and space (--quilt, --clean, --package) the completion is performed for both versions; the list of all options above shows the "spaced" (--clean) version and a couple of commonly used versions with = and an argument. For options only accepting =, the option ends with = to allow the user to start typing the argument directly after that.

The script was originally submitted upstream in December 2019, but they haven’t had time to integrate it yet.

This script autocompletes the most common subcommands, but only provides
arguments autocompletion for only two of them, import-dsc and rpush, for
practical reasons.

For dgit options, it provides two-level completion for the most popular
options, excluding rarely used or dangerous ("use when you know what
you’re doing") options.  The two-levels work in a way to not overwhelm
the user with options when they Tab twice, so only some but not all
arguments to e.g. --quilt= are shown:

$ dgit --
--baredebian                                 --force-import-gitapply-no-absurd
--baredebian+git                             --force-reusing-version
--baredebian+tarball                         --force-unrepresentable
--build-products-dir=                        --force-unsupported-source-format
--clean                                      --force-uploading-binaries
--clean=dpkg-source                          --force-uploading-source-only
--clean=git                                  --gbp
--clean=git-ff                               --include-dirty
--damp-run                                   --new
--delayed=                                   --no-rm-on-error
--deliberately-fresh-repo                    --no-sign
--deliberately-include-questionable-history  --overwrite
--deliberately-not-fast-forward              --package
--dep14tag                                   --quilt
--distro=                                    --quilt=auto
--dpm                                        --quilt=linear
--dry-run                                    --rm-old-changes
--force-changes-origs-exactly                --save-dgit-view=
--force-dsc-changes-mismatch                 --split-view=
--force-import-dsc-with-dgit-field           --upstream-commitish=
--force-import-gitapply-absurd

However, when the user types --quilt=, the rest of them are shown:

$ dgit --quilt=
auto            baredebian+git      dpm      linear       nofix      unapplied
baredebian      baredebian+tarball  gbp      nocheck      smash

For --upstream-commitish= the script autocompletes some tags, starting
with tags with the matching version, and the rest sorted by version:

$ dgit --upstream-commitish=upstream/1.
upstream/1.11.0  upstream/1.6.0

For options accepting both = and space (--quilt, --clean, --package)
the completion is performed for both versions; the list of all options
above shows the "spaced" (--clean) version and a couple of commonly
used versions with = and an argument. For options only accepting =,
the option ends with = to allow the user to start typing the argument
directly after that.

Signed-off-by: Andrej Shadura <[email protected]>
@akinomyoga
Copy link
Collaborator

This PR provides a completion script for dgit (git integration with the Debian-style archives):

The author of the PR @andrewshadura has already submitted the same completion script to Debian Bug Tracker System / debian-bugs-dist mailing list at Bug#928704 in Dec., 2019, but there seems to be no response in the thread. In earlier comments in the same thread, the maintainer of dgit seems to be positive about accepting completion scripts. Maybe the mail has just been overlooked by the maintainer?

I feel we should again try to contact the maintainer of dgit; @andrewshadura may again reply to the thread in Debian BTS, or may create a merge request in Debian Salsa as README says

Merge requests on Salsa are welcome; as are code contributions via the Debian Bug Tracking System. If you encounter a bug, please report it via the Debian BTS.


Note that there seem to be several other tools of the name dgit:

@akinomyoga
Copy link
Collaborator

akinomyoga commented Oct 5, 2021

Thanks for the update. If you add information after others have made comments, you can mention it in new replies instead of silently editing the original post so that the others don't miss the new information.

The script was originally submitted upstream in December 2019, but they haven’t had time to integrate it yet.

So the contribution is still under review, i.e., the maintainer recognizes the contribution yet hasn't rejected it? We should ask the maintainer about the current status of the review before proceeding. We need to respect the efforts of the maintainer if any.

I can guess why the review is delayed. Since the maintainer of dgit seems to mention that they don't use bash-completion by themselves, it is non-trivial for the maintainer how to properly set up the completion script you provided. You have just sent a fragment of the completion script in Debian BTS, but I guess it is not obvious how to use the code for those who don't use bash-completion. When you contribute to the upstream of dgit in such a case, it is useful to make a complete form of the patch for dgit instead of just providing a fragment of code. For example, you explicitly include the completion script as a file in the tree and also add the installation configuration that copies the file to /etc/bash_completion.d/dgit.sh /usr/share/bash-completion/completions/dgit. In this way, you can provide a complete version of the contribution ready to be reviewed.

[ Edit: I think maybe you can create a merge request (MR) at dgit / dgit · GitLab since it is more explicit on how the change should be applied. In creating the MR, please don't forget to mention the original threads, #928704 and #972904 ].

Also, I feel we need help from the developer of dgit since the set of the options that this PR supports is limited and there are still many unsupported options from dgit.

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

Successfully merging this pull request may close these issues.

2 participants