mirror of
https://github.com/obra/superpowers.git
synced 2026-08-30 18:39:23 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0be49879b1 |
@@ -22,15 +22,12 @@ head=$3
|
|||||||
git rev-parse --verify --quiet "$base" >/dev/null || { echo "bad BASE: $base" >&2; exit 2; }
|
git rev-parse --verify --quiet "$base" >/dev/null || { echo "bad BASE: $base" >&2; exit 2; }
|
||||||
git rev-parse --verify --quiet "$head" >/dev/null || { echo "bad HEAD: $head" >&2; exit 2; }
|
git rev-parse --verify --quiet "$head" >/dev/null || { echo "bad HEAD: $head" >&2; exit 2; }
|
||||||
|
|
||||||
# Range guards (exit 3): a wrong-branch HEAD yields a range that is empty or
|
|
||||||
# not rooted at BASE; either would silently produce a bogus review package.
|
|
||||||
git merge-base --is-ancestor "$base" "$head" || { echo "HEAD is not a descendant of BASE: ${base}..${head}" >&2; exit 3; }
|
|
||||||
[ "$(git rev-list --count "${base}..${head}")" -gt 0 ] || { echo "empty commit range: ${base}..${head}" >&2; exit 3; }
|
|
||||||
|
|
||||||
if [ $# -eq 4 ]; then
|
if [ $# -eq 4 ]; then
|
||||||
out=$4
|
out=$4
|
||||||
else
|
else
|
||||||
dir=$("$(cd "$(dirname "$0")" && pwd)/sdd-workspace" "$plan")
|
# Invoke via bash rather than direct exec: some extractors (Python zipfile)
|
||||||
|
# strip Unix exec bits when unpacking marketplace packages (#2040).
|
||||||
|
dir=$("${BASH:-bash}" "$(cd "$(dirname "$0")" && pwd)/sdd-workspace" "$plan")
|
||||||
out="$dir/review-$(git rev-parse --short "$base")..$(git rev-parse --short "$head").diff"
|
out="$dir/review-$(git rev-parse --short "$base")..$(git rev-parse --short "$head").diff"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ n=$2
|
|||||||
if [ $# -eq 3 ]; then
|
if [ $# -eq 3 ]; then
|
||||||
out=$3
|
out=$3
|
||||||
else
|
else
|
||||||
dir=$("$(cd "$(dirname "$0")" && pwd)/sdd-workspace" "$plan")
|
# Invoke via bash rather than direct exec: some extractors (Python zipfile)
|
||||||
|
# strip Unix exec bits when unpacking marketplace packages (#2040).
|
||||||
|
dir=$("${BASH:-bash}" "$(cd "$(dirname "$0")" && pwd)/sdd-workspace" "$plan")
|
||||||
out="$dir/task-${n}-brief.md"
|
out="$dir/task-${n}-brief.md"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -165,30 +165,6 @@ PLAN
|
|||||||
echo " got: $rp_explicit"
|
echo " got: $rp_explicit"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- range guards: BASE must be an ancestor of HEAD, range must be non-empty ---
|
|
||||||
local divergent
|
|
||||||
divergent="$(cd "$repo" && git "${git_id[@]}" commit-tree 'HEAD~1^{tree}' -p 'HEAD~1' -m divergent)"
|
|
||||||
rc=0
|
|
||||||
local guard_err
|
|
||||||
guard_err="$(cd "$repo" && "$SDD_SCRIPTS/review-package" plan-a.md "$divergent" HEAD 2>&1 >/dev/null)" || rc=$?
|
|
||||||
if [[ "$rc" -eq 3 && "$guard_err" == *"not a descendant"* ]]; then
|
|
||||||
pass "review-package rejects a BASE that is not an ancestor of HEAD with exit 3"
|
|
||||||
else
|
|
||||||
fail "review-package rejects a BASE that is not an ancestor of HEAD with exit 3"
|
|
||||||
echo " exit: $rc"
|
|
||||||
echo " stderr: $guard_err"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rc=0
|
|
||||||
guard_err="$(cd "$repo" && "$SDD_SCRIPTS/review-package" plan-a.md HEAD HEAD 2>&1 >/dev/null)" || rc=$?
|
|
||||||
if [[ "$rc" -eq 3 && "$guard_err" == *"empty commit range"* ]]; then
|
|
||||||
pass "review-package rejects an empty BASE..HEAD range with exit 3"
|
|
||||||
else
|
|
||||||
fail "review-package rejects an empty BASE..HEAD range with exit 3"
|
|
||||||
echo " exit: $rc"
|
|
||||||
echo " stderr: $guard_err"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- Worktree isolation: a linked worktree resolves its own workspace ---
|
# --- Worktree isolation: a linked worktree resolves its own workspace ---
|
||||||
local wt="$TEST_ROOT/wt"
|
local wt="$TEST_ROOT/wt"
|
||||||
( cd "$repo" && git worktree add -q "$wt" -b wt-feature )
|
( cd "$repo" && git worktree add -q "$wt" -b wt-feature )
|
||||||
@@ -213,6 +189,21 @@ PLAN
|
|||||||
echo " status: $wt_status"
|
echo " status: $wt_status"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# --- helpers survive a mode-stripping extractor dropping exec bits (#2040) ---
|
||||||
|
local stripped="$TEST_ROOT/stripped-scripts"
|
||||||
|
mkdir -p "$stripped"
|
||||||
|
cp "$SDD_SCRIPTS/sdd-workspace" "$SDD_SCRIPTS/task-brief" "$SDD_SCRIPTS/review-package" "$stripped/"
|
||||||
|
chmod -x "$stripped"/*
|
||||||
|
local noexec_out noexec_rc=0
|
||||||
|
noexec_out="$(cd "$repo" && bash "$stripped/task-brief" plan-b.md 1 2>&1)" || noexec_rc=$?
|
||||||
|
if [[ "$noexec_rc" -eq 0 && -f "$repo/.superpowers/sdd/plan-b/task-1-brief.md" ]]; then
|
||||||
|
pass "task-brief works with no exec bit on sdd-workspace"
|
||||||
|
else
|
||||||
|
fail "task-brief works with no exec bit on sdd-workspace"
|
||||||
|
echo " rc: $noexec_rc"
|
||||||
|
echo " output: $noexec_out"
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
if [[ "$FAILURES" -ne 0 ]]; then
|
if [[ "$FAILURES" -ne 0 ]]; then
|
||||||
echo "FAILED: $FAILURES assertion(s)."
|
echo "FAILED: $FAILURES assertion(s)."
|
||||||
|
|||||||
Reference in New Issue
Block a user