#!/bin/bash # ============================================================================ # Run only the tests related to files changed vs HEAD (staged, unstaged and # untracked). Quiet: failures plus a one-line summary. Falls back to the full # suite when a change cannot be mapped to tests. Generated by repo_contract. # ============================================================================ set -euo pipefail cd "$(git rev-parse --show-toplevel)" CHANGED=() while IFS= read -r f; do [[ -n "$f" && -e "$f" ]] && CHANGED+=("$f") done < <({ git diff --name-only HEAD 2>/dev/null || true; git ls-files --others --exclude-standard; } | sort -u) # Gradle test selection by class needs per-project knowledge: any source change runs the suite. if ! printf '%s\n' "${CHANGED[@]:-}" | grep -qE '\.(kt|java|kts|gradle|xml)$'; then echo "no jvm source changes: nothing to test"; exit 0 fi ./gradlew test --quiet