From abb0f6fe3233535f18427738161f6b3d5f83a779 Mon Sep 17 00:00:00 2001 From: Shane Jaroch Date: Thu, 8 Jan 2026 15:55:08 -0500 Subject: [PATCH] update completions --- README.rst | 22 +++++++++++++++++++++- completions/README.rst | 5 ++++- completions/bash/git-remote-gcrypt | 8 ++++++-- completions/fish/git-remote-gcrypt.fish | 17 ++++++++++++----- completions/zsh/_git-remote-gcrypt | 20 ++++++++++++++++++-- git-remote-gcrypt | 2 +- tests/test-clean-command.sh | 4 ++-- 7 files changed, 64 insertions(+), 14 deletions(-) diff --git a/README.rst b/README.rst index 2a566ee..dc3900a 100644 --- a/README.rst +++ b/README.rst @@ -256,7 +256,12 @@ Each item extends until newline, and matches one of the following: Detecting gcrypt repos ====================== -To detect if a git url is a gcrypt repo, use: ``git-remote-gcrypt --check url`` +To detect if a git url is a gcrypt repo, use:: + + git-remote-gcrypt check url + +(Legacy syntax ``--check`` is also supported). + Exit status is 0 if the repo exists and can be decrypted, 1 if the repo uses gcrypt but could not be decrypted, and 100 if the repo is not encrypted with gcrypt (or could not be accessed). @@ -264,6 +269,21 @@ encrypted with gcrypt (or could not be accessed). Note that this has to fetch the repo contents into the local git repository, the same as is done when using a gcrypt repo. +Cleaning gcrypt repos +===================== + +To scan for unencrypted files in a remote gcrypt repo, use:: + + git-remote-gcrypt clean [url|remote] + +If no URL or remote is specified, ``git-remote-gcrypt`` will list all +available ``gcrypt::`` remotes. + +By default, this command only performs a scan. To actually remove the +unencrypted files, you must use the ``--force`` (or ``-f``) flag:: + + git-remote-gcrypt clean url --force + Known issues ============ diff --git a/completions/README.rst b/completions/README.rst index d1e6f55..0c8b365 100644 --- a/completions/README.rst +++ b/completions/README.rst @@ -45,7 +45,10 @@ Supported Completions - ``-h``, ``--help`` - Show help message - ``-v``, ``--version`` - Show version information -- ``--check`` - Check if URL is a gcrypt repository +- ``check`` - Check if URL is a gcrypt repository +- ``clean`` - Scan/Clean unencrypted files from remote + - ``-f``, ``--force`` - Actually delete files during clean +- ``--check`` - (Legacy) Check if URL is a gcrypt repository Notes ===== diff --git a/completions/bash/git-remote-gcrypt b/completions/bash/git-remote-gcrypt index 18da214..b401311 100644 --- a/completions/bash/git-remote-gcrypt +++ b/completions/bash/git-remote-gcrypt @@ -7,7 +7,7 @@ _git_remote_gcrypt() { cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD - 1]}" opts="-h --help -v --version --check" - commands="capabilities list push fetch" + commands="capabilities list push fetch check clean" # If we're after a subcommand, only offer -h/--help if [[ " $commands " =~ " ${COMP_WORDS[1]:-} " ]]; then @@ -16,7 +16,11 @@ _git_remote_gcrypt() { fi case "$prev" in - --check) + clean) + COMPREPLY=($(compgen -W "-f --force" -- "$cur")) + return 0 + ;; + --check | check) # Complete with gcrypt:: URLs or file paths COMPREPLY=($(compgen -f -- "$cur")) return 0 diff --git a/completions/fish/git-remote-gcrypt.fish b/completions/fish/git-remote-gcrypt.fish index 9d089ce..2560ccb 100644 --- a/completions/fish/git-remote-gcrypt.fish +++ b/completions/fish/git-remote-gcrypt.fish @@ -3,10 +3,17 @@ complete -c git-remote-gcrypt -s h -l help -d 'Show help message' complete -c git-remote-gcrypt -s v -l version -d 'Show version information' -complete -c git-remote-gcrypt -l check -d 'Check if URL is a gcrypt repository' -r -F +complete -c git-remote-gcrypt -l check -d '(Legacy) Check if URL is a gcrypt repository' -r -F + +# Subcommands +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities list push fetch check clean" -a 'check' -d 'Check if URL is a gcrypt repository' +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities list push fetch check clean" -a 'clean' -d 'Scan/Clean unencrypted files from remote' + +# Clean flags +complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from clean" -s f -l force -d 'Actually delete files during clean' # Git protocol commands -complete -c git-remote-gcrypt -f -a 'capabilities' -d 'Show git remote helper capabilities' -complete -c git-remote-gcrypt -f -a 'list' -d 'List refs in remote repository' -complete -c git-remote-gcrypt -f -a 'push' -d 'Push refs to remote repository' -complete -c git-remote-gcrypt -f -a 'fetch' -d 'Fetch refs from remote repository' +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities list push fetch check clean" -a 'capabilities' -d 'Show git remote helper capabilities' +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities list push fetch check clean" -a 'list' -d 'List refs in remote repository' +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities list push fetch check clean" -a 'push' -d 'Push refs to remote repository' +complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities list push fetch check clean" -a 'fetch' -d 'Fetch refs from remote repository' diff --git a/completions/zsh/_git-remote-gcrypt b/completions/zsh/_git-remote-gcrypt index f3686d5..86c5d83 100644 --- a/completions/zsh/_git-remote-gcrypt +++ b/completions/zsh/_git-remote-gcrypt @@ -8,10 +8,26 @@ _git_remote_gcrypt() { '(- *)'{-h,--help}'[show help message]' '(- *)'{-v,--version}'[show version information]' '--check[check if URL is a gcrypt repository]:URL:_files' - '1:command:(capabilities list push fetch)' - '*:gcrypt URL:' + '1:command:(capabilities list push fetch check clean)' + '*::subcommand arguments:->args' ) _arguments -s -S $args + + case $words[1] in + clean) + _arguments \ + '(-f --force)'{-f,--force}'[actually delete files]' \ + '*:gcrypt URL:' + ;; + check) + _arguments \ + '1:gcrypt URL:_files' + ;; + *) + _arguments \ + '*:gcrypt URL:' + ;; + esac } _git_remote_gcrypt "$@" diff --git a/git-remote-gcrypt b/git-remote-gcrypt index 864ea6f..6e8767f 100755 --- a/git-remote-gcrypt +++ b/git-remote-gcrypt @@ -776,7 +776,7 @@ ensure_connected() echo_info "Found the following unexpected files:" echo_info "$early_bad_files" | head -n 5 | sed 's/^/ /' >&2 echo_info "" - echo_info "To fix: use 'git-remote-gcrypt --clean $URL' to remove these files," + echo_info "To fix: use 'git-remote-gcrypt clean --force $URL' to remove these files," echo_info "or set 'git config gcrypt.allow-unencrypted-remote true' to ignore." exit 1 fi diff --git a/tests/test-clean-command.sh b/tests/test-clean-command.sh index 4a10516..f39d511 100755 --- a/tests/test-clean-command.sh +++ b/tests/test-clean-command.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Test: --clean command removes unencrypted files -# This test verifies that git-remote-gcrypt --clean correctly identifies +# Test: clean command removes unencrypted files +# This test verifies that git-remote-gcrypt clean correctly identifies # and removes unencrypted files from a remote. set -e -- 2.52.0