]> Nutra Git (v1) - gamesguru/git-remote-gcrypt.git/commitdiff
simplify
authorShane Jaroch <chown_tee@proton.me>
Thu, 8 Jan 2026 20:39:20 +0000 (15:39 -0500)
committerShane Jaroch <chown_tee@proton.me>
Thu, 8 Jan 2026 20:39:20 +0000 (15:39 -0500)
git-remote-gcrypt
tests/test-clean-command.sh

index ff7c1ccc5b090790122b47d2c47df689de089f58..c55925cf54dc27d4065b1887649421cc2bffe30d 100755 (executable)
@@ -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" || :)
index 67e7726844696f14de06eafaa775427fb9a9625a..837308f2f212b36702c3bd8310a452c3a56e062a 100755 (executable)
@@ -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