fix(install): resolve git hooks dir via git plumbing, fix stale plugin manifests #72
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"agents": "agents/",
|
|
||||||
"author": {
|
"author": {
|
||||||
"email": "defame1297@rkdr.net",
|
"email": "defame1297@rkdr.net",
|
||||||
"name": "Defame1297"
|
"name": "Defame1297"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"agents": "agents/",
|
|
||||||
"author": {
|
"author": {
|
||||||
"email": "defame1297@rkdr.net",
|
"email": "defame1297@rkdr.net",
|
||||||
"name": "Defame1297"
|
"name": "Defame1297"
|
||||||
@@ -16,8 +15,5 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"mcpServers": ".mcp.json",
|
"mcpServers": ".mcp.json",
|
||||||
"name": "core",
|
"name": "core",
|
||||||
"skills": [
|
|
||||||
"skills/"
|
|
||||||
],
|
|
||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"agents": "agents/",
|
|
||||||
"author": {
|
"author": {
|
||||||
"email": "defame1297@rkdr.net",
|
"email": "defame1297@rkdr.net",
|
||||||
"name": "Defame1297"
|
"name": "Defame1297"
|
||||||
@@ -16,8 +15,5 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"mcpServers": ".mcp.json",
|
"mcpServers": ".mcp.json",
|
||||||
"name": "gitea",
|
"name": "gitea",
|
||||||
"skills": [
|
|
||||||
"skills/"
|
|
||||||
],
|
|
||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,16 @@ done
|
|||||||
# Install git hooks into the current repo checkout
|
# Install git hooks into the current repo checkout
|
||||||
HOOKS_SRC="$REPO_ROOT/scripts/git-hooks"
|
HOOKS_SRC="$REPO_ROOT/scripts/git-hooks"
|
||||||
if [[ -d "$HOOKS_SRC" ]]; then
|
if [[ -d "$HOOKS_SRC" ]]; then
|
||||||
|
# Unset inherited GIT_DIR/GIT_WORK_TREE — set by git when this script runs as
|
||||||
|
# a hook (e.g. pre-push), they override -C's directory-based discovery and
|
||||||
|
# would resolve against the invoking repo instead of $REPO_ROOT.
|
||||||
|
GIT_HOOKS_DIR="$(env -u GIT_DIR -u GIT_WORK_TREE git -C "$REPO_ROOT" rev-parse --git-path hooks)"
|
||||||
|
[[ "$GIT_HOOKS_DIR" = /* ]] || GIT_HOOKS_DIR="$REPO_ROOT/$GIT_HOOKS_DIR"
|
||||||
|
mkdir -p "$GIT_HOOKS_DIR"
|
||||||
for hook_file in "$HOOKS_SRC"/*; do
|
for hook_file in "$HOOKS_SRC"/*; do
|
||||||
[[ -f "$hook_file" ]] || continue
|
[[ -f "$hook_file" ]] || continue
|
||||||
hook_name="$(basename "$hook_file")"
|
hook_name="$(basename "$hook_file")"
|
||||||
dest_hook="$REPO_ROOT/.git/hooks/$hook_name"
|
dest_hook="$GIT_HOOKS_DIR/$hook_name"
|
||||||
cp "$hook_file" "$dest_hook"
|
cp "$hook_file" "$dest_hook"
|
||||||
chmod +x "$dest_hook"
|
chmod +x "$dest_hook"
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
# Runs install.sh from a temp repo to avoid touching the real .git/hooks/.
|
# Runs install.sh from a temp repo to avoid touching the real .git/hooks/.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# This script may itself run inside a git hook (e.g. pre-push), which sets
|
||||||
|
# GIT_DIR/GIT_EXEC_PATH/etc. in the environment. `git init`/`git -C` below
|
||||||
|
# would silently re-target the inherited GIT_DIR instead of creating an
|
||||||
|
# isolated repo in $TEMP_REPO, so start from a clean slate.
|
||||||
|
for var in $(compgen -v | grep '^GIT_'); do unset "$var"; done
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
PASS=0
|
PASS=0
|
||||||
FAIL=0
|
FAIL=0
|
||||||
@@ -22,7 +28,7 @@ TEMP_HOME="$(mktemp -d)"
|
|||||||
trap 'rm -rf "$TEMP_REPO" "$TEMP_HOME"' EXIT
|
trap 'rm -rf "$TEMP_REPO" "$TEMP_HOME"' EXIT
|
||||||
|
|
||||||
mkdir -p "$TEMP_REPO/scripts"
|
mkdir -p "$TEMP_REPO/scripts"
|
||||||
mkdir -p "$TEMP_REPO/.git/hooks"
|
git -C "$TEMP_REPO" init -q
|
||||||
|
|
||||||
# Minimal deploy-manifest.sh — empty deploy lists so install.sh reaches the
|
# Minimal deploy-manifest.sh — empty deploy lists so install.sh reaches the
|
||||||
# hook-copy block without attempting to copy files that don't exist in the
|
# hook-copy block without attempting to copy files that don't exist in the
|
||||||
@@ -90,6 +96,28 @@ else
|
|||||||
fi
|
fi
|
||||||
rmdir "$HOOKS_SRC/not-a-hook"
|
rmdir "$HOOKS_SRC/not-a-hook"
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "--- hook install: resolves correctly when GIT_DIR is inherited (hook context) ---"
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Git sets GIT_DIR/GIT_WORK_TREE for child processes when this script itself
|
||||||
|
# runs as a hook (e.g. pre-push). Simulate that and confirm install.sh still
|
||||||
|
# resolves hooks against $TEMP_REPO, not the inherited GIT_DIR.
|
||||||
|
OTHER_REPO="$(mktemp -d)"
|
||||||
|
git -C "$OTHER_REPO" init -q
|
||||||
|
if HOME="$TEMP_HOME" GIT_DIR="$OTHER_REPO/.git" GIT_WORK_TREE="$OTHER_REPO" \
|
||||||
|
bash "$TEMP_REPO/scripts/install.sh" > /dev/null 2>&1; then
|
||||||
|
if [[ -f "$TEMP_REPO/.git/hooks/post-push" ]]; then
|
||||||
|
pass "resolves \$TEMP_REPO/.git/hooks/ even with inherited GIT_DIR"
|
||||||
|
else
|
||||||
|
fail "installed into inherited GIT_DIR instead of \$TEMP_REPO"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
fail "install.sh failed when GIT_DIR/GIT_WORK_TREE were inherited"
|
||||||
|
fi
|
||||||
|
rm -rf "$OTHER_REPO"
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- hook install: idempotent ---"
|
echo "--- hook install: idempotent ---"
|
||||||
|
|||||||
Reference in New Issue
Block a user