diff --git a/scripts/ci/binary-artifacts.sh b/scripts/ci/binary-artifacts.sh index 4d420eb9aa..4d63a71e2a 100755 --- a/scripts/ci/binary-artifacts.sh +++ b/scripts/ci/binary-artifacts.sh @@ -30,12 +30,12 @@ set -euo pipefail # - WebAssembly modules, compiled Java classes, .NET assemblies # # Runs in two contexts: -# pre-commit hook -- checks staged files (--check --staged) +# pre-commit hook -- checks filenames passed by pre-commit (--check files...) # CI workflow -- checks PR diff files (--check --ci) # # Exit codes: 0 = clean, 1 = binary artifacts found or error. -FILE_MODE="staged" +FILE_MODE="all" FILES=() while [[ $# -gt 0 ]]; do @@ -43,25 +43,16 @@ while [[ $# -gt 0 ]]; do --check) shift ;; - --staged) - FILE_MODE="staged" - shift - ;; --ci) FILE_MODE="ci" shift ;; - --all) - FILE_MODE="all" - shift - ;; --help|-h) - echo "Usage: $0 [--check] [--staged|--ci|--all] [files...]" + echo "Usage: $0 [--check] [--ci] [files...]" echo "" echo "File selection:" - echo " --staged Check staged files (default, for git hooks)" + echo " [none] Check all tracked files (default)" echo " --ci Check files changed in PR (for CI)" - echo " --all Check all tracked files" echo " [files] Check specific files" exit 0 ;; @@ -79,9 +70,6 @@ done get_files() { case "$FILE_MODE" in - staged) - git diff --cached --name-only --diff-filter=ACM - ;; ci) if [ -n "${GITHUB_BASE_REF:-}" ]; then git fetch --no-tags --depth=1 origin "${GITHUB_BASE_REF}:${GITHUB_BASE_REF}" 2>/dev/null || true @@ -89,7 +77,7 @@ get_files() { elif [ -n "${CI:-}" ]; then git diff --name-only --diff-filter=ACM HEAD~1 else - git diff --cached --name-only --diff-filter=ACM + git ls-files fi ;; all) diff --git a/scripts/ci/markdownlint.sh b/scripts/ci/markdownlint.sh index 0db7dfdb31..a937956e4e 100755 --- a/scripts/ci/markdownlint.sh +++ b/scripts/ci/markdownlint.sh @@ -19,11 +19,10 @@ set -euo pipefail MODE="check" -FILE_MODE="all" FILES=() -# Accept mode flags plus optional file paths. In pre-commit, matching staged -# markdown files are passed as positional arguments. +# Accept mode flags plus optional file paths. Pre-commit passes matching +# markdown files as positional arguments. while [[ $# -gt 0 ]]; do case "$1" in --check) @@ -34,20 +33,10 @@ while [[ $# -gt 0 ]]; do MODE="fix" shift ;; - --staged) - FILE_MODE="staged" - shift - ;; - --all) - FILE_MODE="all" - shift - ;; --help|-h) - echo "Usage: $0 [--check|--fix] [--staged|--all] [files...]" + echo "Usage: $0 [--check|--fix] [files...]" echo " --check Check markdown files for issues (default)" echo " --fix Automatically fix markdown issues" - echo " --staged Check staged markdown files" - echo " --all Check all markdown files (default)" exit 0 ;; -*) @@ -66,19 +55,6 @@ done # helm/charts/iggy/README.md is auto-generated by helm-docs IGNORE_ARGS=(--ignore "helm/charts/iggy/README.md") -# Keep --staged for manual runs; pre-commit normally passes matching staged -# files directly through pass_filenames. -if [ ${#FILES[@]} -eq 0 ] && [ "$FILE_MODE" = "staged" ]; then - while IFS= read -r file; do - [ -n "$file" ] && FILES+=("$file") - done < <(git diff --cached --name-only --diff-filter=ACM -- '*.md') - - if [ ${#FILES[@]} -eq 0 ]; then - echo "✅ No staged markdown files to check" - exit 0 - fi -fi - # Default to the full repository for CI/manual runs, but use the explicit file # list when pre-commit or a caller passes paths directly. if [ ${#FILES[@]} -gt 0 ]; then diff --git a/scripts/ci/shellcheck.sh b/scripts/ci/shellcheck.sh index 4f66fdbca0..1cc970c452 100755 --- a/scripts/ci/shellcheck.sh +++ b/scripts/ci/shellcheck.sh @@ -21,11 +21,10 @@ set -euo pipefail MODE="check" -FILE_MODE="all" FILES=() -# Accept mode flags plus optional file paths. In pre-commit, matching staged -# shell files are passed as positional arguments. +# Accept mode flags plus optional file paths. Pre-commit passes matching shell +# files as positional arguments. while [[ $# -gt 0 ]]; do case "$1" in --check) @@ -36,20 +35,10 @@ while [[ $# -gt 0 ]]; do MODE="fix" shift ;; - --staged) - FILE_MODE="staged" - shift - ;; - --all) - FILE_MODE="all" - shift - ;; --help|-h) - echo "Usage: $0 [--check|--fix] [--staged|--all] [files...]" + echo "Usage: $0 [--check|--fix] [files...]" echo " --check Check shell scripts for issues (default)" echo " --fix Show detailed suggestions for fixes" - echo " --staged Check staged shell scripts" - echo " --all Check all shell scripts (default)" exit 0 ;; -*) @@ -88,26 +77,6 @@ for path in "${EXCLUDE_PATHS[@]}"; do FIND_EXCLUDE_ARGS+=("-not" "-path" "$path") done -# Keep --staged for manual runs; pre-commit normally passes matching staged -# files directly through pass_filenames. -if [ ${#FILES[@]} -eq 0 ] && [ "$FILE_MODE" = "staged" ]; then - while IFS= read -r script; do - if [ ! -f "$script" ]; then - continue - fi - - # Match normal .sh files and executable scripts with shell shebangs. - if [[ "$script" == *.sh ]] || head -n 1 "$script" | grep -qE '^#!.*[^[:alnum:]_](bash|dash|ksh|zsh|sh)([[:space:]]|$)'; then - FILES+=("$script") - fi - done < <(git diff --cached --name-only --diff-filter=ACM) - - if [ ${#FILES[@]} -eq 0 ]; then - echo "✅ No staged shell scripts to check" - exit 0 - fi -fi - # Check if shellcheck is installed if ! command -v shellcheck &> /dev/null; then echo "❌ shellcheck command not found" @@ -128,8 +97,8 @@ if [ "$MODE" = "fix" ]; then echo "" FAILED=0 - # Use staged or explicitly provided files when present; otherwise keep the - # historical full-repository behavior for CI/manual all-file checks. + # Use file arguments from pre-commit or the caller when present; otherwise + # keep the historical full-repository behavior for CI/manual checks. if [ ${#FILES[@]} -gt 0 ]; then for script in "${FILES[@]}"; do [ -f "$script" ] || continue @@ -159,8 +128,8 @@ if [ "$MODE" = "fix" ]; then else echo "🔍 Checking shell scripts..." - # Use staged or explicitly provided files when present; otherwise keep the - # historical full-repository behavior for CI/manual all-file checks. + # Use file arguments from pre-commit or the caller when present; otherwise + # keep the historical full-repository behavior for CI/manual checks. if [ ${#FILES[@]} -gt 0 ]; then if shellcheck -x "${FILES[@]}"; then echo "✅ All shell scripts passed shellcheck" diff --git a/scripts/ci/taplo.sh b/scripts/ci/taplo.sh index 7240368c2d..1568d17d93 100755 --- a/scripts/ci/taplo.sh +++ b/scripts/ci/taplo.sh @@ -20,7 +20,7 @@ set -euo pipefail # Default values MODE="check" -FILE_MODE="staged" +FILE_MODE="all" FILES=() # Parse arguments @@ -34,29 +34,20 @@ while [[ $# -gt 0 ]]; do MODE="fix" shift ;; - --staged) - FILE_MODE="staged" - shift - ;; --ci) FILE_MODE="ci" shift ;; - --all) - FILE_MODE="all" - shift - ;; --help|-h) - echo "Usage: $0 [--check|--fix] [--staged|--ci|--all] [files...]" + echo "Usage: $0 [--check|--fix] [--ci] [files...]" echo "" echo "Modes:" echo " --check Check TOML formatting (default)" echo " --fix Format TOML files" echo "" echo "File selection:" - echo " --staged Check staged files (default, for git hooks)" + echo " [none] Check all tracked TOML files (default)" echo " --ci Check files changed in PR (for CI)" - echo " --all Check all TOML files" echo " [files] Check specific files" exit 0 ;; @@ -87,10 +78,6 @@ fi # Get files to check based on mode get_files() { case "$FILE_MODE" in - staged) - # Get staged TOML files for git hooks - git diff --cached --name-only --diff-filter=ACM -- '*.toml' - ;; ci) # Get TOML files changed in PR for CI if [ -n "${GITHUB_BASE_REF:-}" ]; then @@ -101,18 +88,13 @@ get_files() { # Generic CI - compare with HEAD~1 git diff --name-only --diff-filter=ACM HEAD~1 -- '*.toml' else - # Fallback to staged files - git diff --cached --name-only --diff-filter=ACM -- '*.toml' + # Local fallback: check all tracked TOML files + git ls-files -- '*.toml' fi ;; all) # Get all TOML files (excluding common build directories) - find . -name '*.toml' \ - -not -path './target/*' \ - -not -path './node_modules/*' \ - -not -path './.git/*' \ - -not -path './venv/*' \ - -type f + git ls-files -- '*.toml' ;; esac } diff --git a/scripts/ci/trailing-newline.sh b/scripts/ci/trailing-newline.sh index bbab2e564c..107d51b61d 100755 --- a/scripts/ci/trailing-newline.sh +++ b/scripts/ci/trailing-newline.sh @@ -20,7 +20,7 @@ set -euo pipefail # Default values MODE="check" -FILE_MODE="staged" +FILE_MODE="all" FILES=() # Parse arguments @@ -34,29 +34,20 @@ while [[ $# -gt 0 ]]; do MODE="fix" shift ;; - --staged) - FILE_MODE="staged" - shift - ;; --ci) FILE_MODE="ci" shift ;; - --all) - FILE_MODE="all" - shift - ;; --help|-h) - echo "Usage: $0 [--check|--fix] [--staged|--ci|--all] [files...]" + echo "Usage: $0 [--check|--fix] [--ci] [files...]" echo "" echo "Modes:" echo " --check Check for missing trailing newlines (default)" echo " --fix Add trailing newlines to files" echo "" echo "File selection:" - echo " --staged Check staged files (default, for git hooks)" + echo " [none] Check all tracked files (default)" echo " --ci Check files changed in PR (for CI)" - echo " --all Check all tracked files" echo " [files] Check specific files" exit 0 ;; @@ -76,10 +67,6 @@ done # Get files to check based on mode get_files() { case "$FILE_MODE" in - staged) - # Get staged files for git hooks - git diff --cached --name-only --diff-filter=ACM - ;; ci) # Get files changed in PR for CI if [ -n "${GITHUB_BASE_REF:-}" ]; then @@ -90,8 +77,8 @@ get_files() { # Generic CI - compare with HEAD~1 git diff --name-only --diff-filter=ACM HEAD~1 else - # Fallback to staged files - git diff --cached --name-only --diff-filter=ACM + # Local fallback: check all tracked files + git ls-files fi ;; all) diff --git a/scripts/ci/trailing-whitespace.sh b/scripts/ci/trailing-whitespace.sh index 4e7f2410d3..34bc0f8776 100755 --- a/scripts/ci/trailing-whitespace.sh +++ b/scripts/ci/trailing-whitespace.sh @@ -20,7 +20,7 @@ set -euo pipefail # Default values MODE="check" -FILE_MODE="staged" +FILE_MODE="all" FILES=() # Parse arguments @@ -34,29 +34,20 @@ while [[ $# -gt 0 ]]; do MODE="fix" shift ;; - --staged) - FILE_MODE="staged" - shift - ;; --ci) FILE_MODE="ci" shift ;; - --all) - FILE_MODE="all" - shift - ;; --help|-h) - echo "Usage: $0 [--check|--fix] [--staged|--ci|--all] [files...]" + echo "Usage: $0 [--check|--fix] [--ci] [files...]" echo "" echo "Modes:" echo " --check Check for trailing whitespace (default)" echo " --fix Remove trailing whitespace" echo "" echo "File selection:" - echo " --staged Check staged files (default, for git hooks)" + echo " [none] Check all tracked files (default)" echo " --ci Check files changed in PR (for CI)" - echo " --all Check all tracked files" echo " [files] Check specific files" exit 0 ;; @@ -76,10 +67,6 @@ done # Get files to check based on mode get_files() { case "$FILE_MODE" in - staged) - # Get staged files for git hooks - git diff --cached --name-only --diff-filter=ACM - ;; ci) # Get files changed in PR for CI if [ -n "${GITHUB_BASE_REF:-}" ]; then @@ -90,8 +77,8 @@ get_files() { # Generic CI - compare with HEAD~1 git diff --name-only --diff-filter=ACM HEAD~1 else - # Fallback to staged files - git diff --cached --name-only --diff-filter=ACM + # Local fallback: check all tracked files + git ls-files fi ;; all)