From: Shane Jaroch Date: Thu, 8 Jan 2026 20:39:20 +0000 (-0500) Subject: simplify X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=b05b97bcc67d2a471dfda8127584a805e82ed52e;p=gamesguru%2Fgit-remote-gcrypt.git simplify --- diff --git a/git-remote-gcrypt b/git-remote-gcrypt index ff7c1cc..c55925c 100755 --- a/git-remote-gcrypt +++ b/git-remote-gcrypt @@ -92,21 +92,16 @@ case "$1" in # URL resolution logic if [ -z "$URL" ]; then - # Auto-detect all gcrypt remotes + # List all gcrypt remotes and exit remotes=$(git remote -v | grep 'gcrypt::' | awk '{print $1}' | sort -u || :) - if [ -z "$remotes" ]; then - echo "Usage: git-remote-gcrypt clean [URL|REMOTE] [-f]" >&2 - echo "Error: No gcrypt remotes found and no URL/remote specified." >&2 - exit 1 - fi - num_remotes=$(printf "%s\n" "$remotes" | grep -v '^$' | wc -l | tr -d ' ') - if [ "$num_remotes" -eq 1 ]; then - URL=$(git config --get "remote.$remotes.url") - elif [ "$num_remotes" -gt 1 ]; then - echo "Error: Multiple gcrypt remotes found. Please specify one:" >&2 + echo "Usage: git-remote-gcrypt clean [URL|REMOTE] [-f]" >&2 + if [ -n "$remotes" ]; then + echo "Error: No URL or remote specified. Available gcrypt remotes:" >&2 echo "$remotes" | sed 's/^/ /' >&2 - exit 1 + else + echo "Error: No gcrypt remotes found and no URL/remote specified." >&2 fi + exit 1 elif ! echo "$URL" | grep -q -E '://|::'; then # Not a URL, check if it's a remote name potential_url=$(git config --get "remote.$URL.url" || :) diff --git a/tests/test-clean-command.sh b/tests/test-clean-command.sh index 67e7726..837308f 100755 --- a/tests/test-clean-command.sh +++ b/tests/test-clean-command.sh @@ -95,15 +95,15 @@ else exit 1 fi -# Test 4: clean (no args) automatic discovery -print_info "Test 4: Automatic discovery..." -# Add a gcrypt:: remote to enable discovery +# Test 4: clean (no args) lists available remotes but doesn't proceed +print_info "Test 4: Remote listing..." +# Add a gcrypt:: remote to enable listing $GIT remote add gcrypt-origin "gcrypt::$tempdir/remote.git" -output=$("$SCRIPT_DIR/git-remote-gcrypt" clean 2>&1) -if echo "$output" | grep -q "Checking remote: gcrypt::$tempdir/remote.git"; then - print_success "clean discovered gcrypt remotes automatically" +output=$("$SCRIPT_DIR/git-remote-gcrypt" clean 2>&1 || :) +if echo "$output" | grep -q "Available gcrypt remotes:" && echo "$output" | grep -q "gcrypt-origin"; then + print_success "clean lists available remotes when no URL/remote specified" else - print_err "clean failed automatic discovery" + print_err "clean failed to list available remotes" echo "$output" exit 1 fi