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).
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
============
- ``-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
=====
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
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
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'
'(- *)'{-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 "$@"
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
#!/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