chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:49:17 +08:00
commit 7243d5823b
2201 changed files with 257291 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Pre-commit hook: regenerate the Docusaurus tool/resource reference when
# any tool/resource module is part of the commit. Installed by
# tools/install-hooks.sh; opt-in (devs without the hook see no behavior change).
# To bypass for a single commit: git commit --no-verify
set -e
REPO_ROOT="$(git rev-parse --show-toplevel)"
GENERATOR="${REPO_ROOT}/tools/generate_docs_reference.py"
if [[ ! -f "$GENERATOR" ]]; then
echo "pre-commit: $GENERATOR missing; skipping docs regeneration." >&2
exit 0
fi
relevant_paths='^Server/src/services/(tools|resources|registry)/'
# Look at the staged change set only — exclude pure deletions.
staged=$(git diff --cached --name-only --diff-filter=ACMR)
if ! grep -qE "$relevant_paths" <<<"$staged"; then
exit 0
fi
echo "pre-commit: tool/resource module changes detected — regenerating /website/docs/reference/"
# Prefer uv if available (matches how the Server's deps are pinned). Fall back
# to system python — the generator handles its own sys.path setup.
if command -v uv >/dev/null 2>&1 && [[ -f "${REPO_ROOT}/Server/pyproject.toml" ]]; then
(cd "${REPO_ROOT}/Server" && uv run python "$GENERATOR")
else
python3 "$GENERATOR"
fi
# Stage any reference files that changed so the commit captures them.
if ! git diff --quiet -- "website/docs/reference"; then
echo "pre-commit: staging regenerated reference pages."
git add website/docs/reference
fi
exit 0
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Pre-push hook: runs the local Unity-version parity check in compile-only mode.
# Installed by tools/install-hooks.sh; opt-in (devs without the hook see no behavior change).
# To bypass for a single push: git push --no-verify
set -e
REPO_ROOT="$(git rev-parse --show-toplevel)"
SCRIPT="${REPO_ROOT}/tools/check-unity-versions.sh"
if [[ ! -x "$SCRIPT" ]]; then
echo "pre-push: $SCRIPT missing or not executable; skipping Unity-version check." >&2
exit 0
fi
# Skip if the push touches nothing relevant. We approximate "relevant" with the same path filters
# the CI workflow uses, so the hook fires for the same scope of changes.
relevant_paths='^(MCPForUnity/(Editor|Runtime)/|TestProjects/UnityMCPTests/|tools/unity-versions\.json$|\.github/workflows/unity-tests\.yml$)'
# Git's empty-tree SHA — fallback that always exists. Used when we can't find a sensible merge
# base (shallow clone, fresh fork with no origin/beta or origin/main, etc.) so the hook still
# runs the check instead of silently skipping it.
EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
# stdin format from git: <local-ref> <local-sha> <remote-ref> <remote-sha> (one line per ref being pushed)
relevant=0
while read -r local_ref local_sha remote_ref remote_sha; do
[[ -z "$local_sha" || "$local_sha" == "0000000000000000000000000000000000000000" ]] && continue
if [[ "$remote_sha" == "0000000000000000000000000000000000000000" ]]; then
# New branch on remote — diff against the default branch, or the empty tree as a guaranteed-valid fallback.
base=$(git merge-base "$local_sha" origin/beta 2>/dev/null \
|| git merge-base "$local_sha" origin/main 2>/dev/null \
|| echo "$EMPTY_TREE")
else
base="$remote_sha"
fi
if git diff --name-only "$base..$local_sha" 2>/dev/null | grep -qE "$relevant_paths"; then
relevant=1
break
fi
done
if [[ $relevant -eq 0 ]]; then
echo "pre-push: no Unity-relevant changes detected; skipping check."
exit 0
fi
exec "$SCRIPT" --pre-push