@rm -rf $(COV_INSTALL)
@mkdir -p $(COV_INSTALL)
@export COV_DIR=$(COV_INSTALL); \
- kcov --bash-dont-parse-binary-dir \
- --include-pattern=install.sh \
- --exclude-path=$(PWD)/.git,$(PWD)/tests \
- $(COV_INSTALL) \
- ./tests/test-install-logic.sh 2>&1 | tee .tmp/kcov.log; \
+ for test_script in tests/installer-test*.sh; do \
+ kcov --bash-dont-parse-binary-dir \
+ --include-pattern=install.sh \
+ --exclude-path=$(PWD)/.git,$(PWD)/tests \
+ $(COV_INSTALL) \
+ "$$test_script" 2>&1 | tee -a .tmp/kcov.log; \
+ done; \
if grep -q 'kcov: error:' .tmp/kcov.log; then \
echo "FAIL: kcov errors detected (see above)"; exit 1; \
fi
return 0
fi
- if [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
+
+ if [ "$(git config --bool remote."$NAME".gcrypt-allow-unencrypted-remote)" = "true" ] || \
+ [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
return 0
fi
return 0
fi
- if [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
+
+ if [ "$(git config --bool remote."$NAME".gcrypt-allow-unencrypted-remote)" = "true" ] || \
+ [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
return 0
fi
if [ "$(line_count "$bad_files")" -gt 5 ]; then
echo_info " ... (and others)"
fi
-
+
# Check config to see if we should ignore
- if [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
+ if [ "$(git config --bool remote."$NAME".gcrypt-allow-unencrypted-remote)" = "true" ] || \
+ [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
echo_info "WARNING: Proceeding because gcrypt.allow-unencrypted-remote is set."
return 0
fi
if missed:
- missed.sort(key=int) # Sort for deterministic output
+ missed.sort(key=int)
+ # Group consecutive lines
+ ranges = []
+ if missed:
+ start = int(missed[0])
+ prev = start
+ for x in missed[1:]:
+ curr = int(x)
+ if curr == prev + 1:
+ prev = curr
+ else:
+ if start == prev:
+ ranges.append(str(start))
+ else:
+ ranges.append(f"{start}-{prev}")
+ start = curr
+ prev = curr
+ # Append the last range
+ if start == prev:
+ ranges.append(str(start))
+ else:
+ ranges.append(f"{start}-{prev}")
+
print(f"\033[31;1m{len(missed)} missing lines\033[0m in {patt}:")
print(
textwrap.fill(
- ", ".join(missed), width=72, initial_indent=" ", subsequent_indent=" "
+ ", ".join(ranges), width=72, initial_indent=" ", subsequent_indent=" "
)
)
+++ /dev/null
-#!/bin/bash
-# tests/test-clean-complex.sh
-# Verifies clean command on filenames with spaces and parentheses.
-
-TEST_DIR=$(dirname "$0")
-BIN="$TEST_DIR/../git-remote-gcrypt"
-git_remote_gcrypt() {
- bash "$BIN" "$@"
-}
-
-# Setup temp environment
-TMPDIR=$(mktemp -d)
-trap 'rm -rf "$TMPDIR"' EXIT
-
-# Create a "remote" bare repo to simulate git backend
-REMOTE_REPO="$TMPDIR/remote.git"
-git init --bare "$REMOTE_REPO" >/dev/null
-
-# Create a commit in the remote with "garbage" files
-# We need to simulate how git-remote-gcrypt stores files (in refs/gcrypt/...)
-# or just in master if it's a raw repo being cleaned?
-# If we run clean --init, we are cleaning a raw repo. So files are in HEAD (or master/main).
-
-# Helper to create commit
-(
- cd "$TMPDIR" || exit 1
- mkdir worktree
- cd worktree || exit 1
- git init >/dev/null
- git remote add origin "$REMOTE_REPO"
-
- # Create files with spaces and parens
- mkdir -p ".csv"
- touch ".csv/sheet-shanes-secondary-sheets-Univ Grades (OU).csv"
- touch "normal.txt"
-
- git add .
- git commit -m "Initial commit with garbage" >/dev/null
- git push origin master >/dev/null
-)
-
-URL="file://$REMOTE_REPO"
-
-echo "--- Status before clean ---"
-# We can use git ls-tree on remote to verify
-git --git-dir="$REMOTE_REPO" ls-tree -r master --name-only
-
-echo "--- Running clean --init --force ---"
-OUTPUT=$(git_remote_gcrypt clean --init --force "$URL" 2>&1)
-EXIT_CODE=$?
-echo "$OUTPUT"
-
-if [ $EXIT_CODE -ne 0 ]; then
- echo "FAIL: clean command failed."
- exit 1
-fi
-
-echo "--- Status after clean ---"
-FILES=$(git --git-dir="$REMOTE_REPO" ls-tree -r master --name-only)
-echo "$FILES"
-
-if [[ $FILES == *".csv"* ]]; then
- # We expect the file to be GONE.
- # Note: clean --init --force deletes ALL files (because map is not found)
- # So if there are ANY files left, it's a fail.
- # But clean command actually updates the refs (typically master or refs/gcrypt/...).
- # Wait, git-remote-gcrypt clean cleans "refs/heads/master" or "refs/heads/main" if mapped?
- # No, it checks what files are there.
- # If standard remote, it might be cleaning HEAD?
-
- # Let's check if the file persists.
- if echo "$FILES" | grep -q "Univ Grades"; then
- echo "FAIL: The complex filename was NOT removed."
- exit 1
- fi
-fi
-
-if [ -z "$FILES" ]; then
- echo "PASS: All files removed."
-else
- # It might leave an empty tree or commit?
- echo "FAIL: Files persist: $FILES"
- exit 1
-fi
# Isolate git config from user environment
export GIT_CONFIG_SYSTEM=/dev/null
export GIT_CONFIG_GLOBAL=/dev/null
+unset GIT_CONFIG_PARAMETERS
# Suppress git advice messages
# Note: git-remote-gcrypt reads actual config files, not just CLI -c options
echo "NESTED=123" >"$tempdir/subdir/nested.txt"
echo "SPACE=789" >"$tempdir/Has Space.txt"
+echo "PARENS=ABC" >"$tempdir/Has (Parens).txt"
BLOB1=$($GIT hash-object -w "$tempdir/secret1.txt")
BLOB2=$($GIT hash-object -w "$tempdir/secret2.txt")
BLOB3=$($GIT hash-object -w "$tempdir/subdir/nested.txt")
BLOB4=$($GIT hash-object -w "$tempdir/Has Space.txt")
+BLOB5=$($GIT hash-object -w "$tempdir/Has (Parens).txt")
# Create root tree using index
export GIT_INDEX_FILE=index.dirty
$GIT update-index --add --cacheinfo 100644 "$BLOB2" "secret2.txt"
$GIT update-index --add --cacheinfo 100644 "$BLOB3" "subdir/nested.txt"
$GIT update-index --add --cacheinfo 100644 "$BLOB4" "Has Space.txt"
+$GIT update-index --add --cacheinfo 100644 "$BLOB5" "Has (Parens).txt"
TREE=$($GIT write-tree)
rm index.dirty
# --------------------------------------------------
# Test 2: Safety Check (Abort on non-gcrypt)
# --------------------------------------------------
-print_info "Test 2: Safety Check (Abort on non-gcrypt)..."
+print_info "Test 2: Safety Check (Abort on non-gcrypt --force)..."
cd "$tempdir/remote.git"
-output=$("$SCRIPT_DIR/git-remote-gcrypt" clean "$tempdir/remote.git" 2>&1 || :)
-assert_grep "Error: No gcrypt manifest found" "$output" "clean aborts on non-gcrypt repo"
+output=$("$SCRIPT_DIR/git-remote-gcrypt" clean --force "$tempdir/remote.git" 2>&1 || :)
+assert_grep "Error: No gcrypt manifest found" "$output" "clean --force aborts on non-gcrypt repo"
if $GIT ls-tree HEAD | grep -q "secret1.txt"; then
print_success "Files preserved (Safety check passed)"
# Reuse the dirty remote from earlier ($tempdir/remote.git) which has secret1.txt and secret2.txt
-# 1. Standard clean should fail (as tested in Test 2)
+# 2. Standard clean should warn and list files (dry-run)
output=$("$SCRIPT_DIR/git-remote-gcrypt" clean "gcrypt::$tempdir/remote.git" 2>&1 || :)
-assert_grep "Error: No gcrypt manifest found" "$output" "standard clean fails on dirty remote"
+assert_grep "WARNING: No gcrypt manifest found" "$output" "clean warns on dirty remote"
+assert_grep "Listing all files as potential garbage" "$output" "clean lists files on dirty remote"
# 2. Clean with --init should succeed (scan only)
output=$("$SCRIPT_DIR/git-remote-gcrypt" clean --init "gcrypt::$tempdir/remote.git" 2>&1 || :)
assert_grep "secret1.txt" "$output" "--init found secret1.txt"
assert_grep "subdir/nested.txt" "$output" "--init found nested file in subdir"
assert_grep "Has Space.txt" "$output" "--init found file with spaces"
+assert_grep "Has (Parens).txt" "$output" "--init found file with parens"
# 3. Clean with --init --force should remove files
"$SCRIPT_DIR/git-remote-gcrypt" clean --init --force "gcrypt::$tempdir/remote.git" >/dev/null 2>&1
# Git config
export GIT_CONFIG_SYSTEM=/dev/null
export GIT_CONFIG_GLOBAL="${tempdir}/gitconfig"
+unset GIT_CONFIG_PARAMETERS
git config --global user.name "Test User"
git config --global user.email "test@example.com"
git config --global init.defaultBranch "master"