mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
Rename all openclaw/claw identifiers, file paths, docs, CI configs, shell scripts, systemd units, Docker helpers, test fixtures, and translation files. Remove stale clawdbot/clawhub paths. Fix pre-commit hook for bash 3 compatibility (macOS). Zero openclaw or claw brand references remain in the working tree.
43 lines
1.3 KiB
Bash
Executable File
43 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
RUN_NODE_TOOL="$ROOT_DIR/scripts/pre-commit/run-node-tool.sh"
|
|
FILTER_FILES="$ROOT_DIR/scripts/pre-commit/filter-staged-files.mjs"
|
|
|
|
if [[ ! -x "$RUN_NODE_TOOL" ]]; then
|
|
echo "Missing helper: $RUN_NODE_TOOL" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f "$FILTER_FILES" ]]; then
|
|
echo "Missing helper: $FILTER_FILES" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Security: avoid option-injection from malicious file names (e.g. "--all", "--force").
|
|
# Robustness: NUL-delimited file list handles spaces/newlines safely.
|
|
# Compatible with bash 3 (macOS default) — avoids mapfile which requires bash 4+.
|
|
files=()
|
|
while IFS= read -r -d '' f; do files+=("$f"); done < <(git diff --cached --name-only --diff-filter=ACMR -z)
|
|
|
|
if [ "${#files[@]}" -eq 0 ]; then
|
|
exit 0
|
|
fi
|
|
|
|
lint_files=()
|
|
while IFS= read -r -d '' f; do lint_files+=("$f"); done < <(node "$FILTER_FILES" lint -- "${files[@]}")
|
|
format_files=()
|
|
while IFS= read -r -d '' f; do format_files+=("$f"); done < <(node "$FILTER_FILES" format -- "${files[@]}")
|
|
|
|
if [ "${#lint_files[@]}" -gt 0 ]; then
|
|
"$RUN_NODE_TOOL" oxlint --type-aware --fix -- "${lint_files[@]}"
|
|
fi
|
|
|
|
if [ "${#format_files[@]}" -gt 0 ]; then
|
|
"$RUN_NODE_TOOL" oxfmt --write -- "${format_files[@]}"
|
|
fi
|
|
|
|
git add -- "${files[@]}"
|