hypertwist/scripts/run-hypertwist-gitnexus-analyze.sh
2026-06-22 23:24:30 +00:00

51 lines
1.5 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
local_gitnexus_cli="$repo_root/mirrors/GitNexus/gitnexus/dist/cli/index.js"
analysis_root="$repo_root/.gitnexus-source-only-root"
max_size_kb="${HYPERTWIST_GITNEXUS_MAX_FILE_SIZE_KB:-256}"
copy_targets=(
"UnrealHyperTwist/Source"
"Content/Browser/src"
"website/src"
"website/server/src"
"scripts"
)
rm -rf "$analysis_root"
mkdir -p "$analysis_root"
for target in "${copy_targets[@]}"; do
source_path="$repo_root/$target"
if [[ ! -e "$source_path" ]]; then
continue
fi
destination_path="$analysis_root/$target"
mkdir -p "$(dirname "$destination_path")"
cp -R "$source_path" "$destination_path"
done
find "$analysis_root" -type f -size +"${max_size_kb}"k -delete
# GitNexus status and registry behavior assume a repository root, so give the
# disposable source-only mirror its own lightweight git boundary.
git -C "$analysis_root" init -q
git -C "$analysis_root" config user.name "HyperTwist GitNexus Mirror"
git -C "$analysis_root" config user.email "hypertwist-gitnexus@local.invalid"
git -C "$analysis_root" add -A
git -C "$analysis_root" commit -q -m "source-only snapshot"
cd "$analysis_root"
if [[ -f "$local_gitnexus_cli" ]]; then
if node "$local_gitnexus_cli" analyze . --skip-agents-md "$@" 2>/dev/null; then
exit 0
fi
echo "Local retained GitNexus CLI was not runnable on this host. Falling back to npx gitnexus@latest." >&2
fi
exec npx -y gitnexus@latest analyze . --skip-agents-md "$@"