docs(skills): make diff-base resolution robust

- Drop @{u} fallback that could resolve the current feature branch as its
  own diff base (empty diff -> falsely clean verification)
- Prefer origin/HEAD, then a common default branch that exists, else HEAD~1
- CI: resolve base branch without pipe-masking (parameter expansion + ref
  verification) so a failed lookup can't silently produce origin/
This commit is contained in:
Alex Schapiro 2026-07-28 04:48:44 +00:00
parent 56f08d52d1
commit a73b022f26
2 changed files with 19 additions and 4 deletions

View file

@ -76,9 +76,16 @@ Any pipeline works the same way — install, set the two env vars, run headless:
```bash
curl -sSL https://strix.ai/install | bash
# Resolve the PR's base branch (fall back to the remote default, then main).
DIFF_BASE="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-}"
DIFF_BASE="origin/${DIFF_BASE:-$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's#^origin/##' || echo main)}"
# Resolve the PR's base branch robustly (use your CI's base-branch variable if it
# has one, e.g. GitHub Actions: origin/${{ github.base_ref }}). Avoid piping the
# git lookup into another command — a failed lookup would otherwise be masked.
BASE_BRANCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-}" # GitLab MR target
if [ -z "$BASE_BRANCH" ]; then
BASE_BRANCH=$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null)
BASE_BRANCH="${BASE_BRANCH#origin/}"
fi
DIFF_BASE="origin/${BASE_BRANCH:-main}"
git rev-parse --verify --quiet "$DIFF_BASE" >/dev/null || DIFF_BASE="HEAD~1"
strix -n -t ./ --scan-mode quick --scope-mode diff --diff-base "$DIFF_BASE" --max-budget 10
```

View file

@ -41,7 +41,15 @@ After fixing, re-scan scoped to the fixed area and confirm the finding is gone.
```bash
# Re-test just the changed files (fast). Resolve the repo's real default
# branch instead of assuming origin/main (many repos use master/develop).
DIFF_BASE=$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null || git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null || echo HEAD~1)
# Avoid the current branch's own upstream as the base — its merge base with
# HEAD would be HEAD, giving an empty diff and a falsely clean result.
DIFF_BASE=$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null)
if [ -z "$DIFF_BASE" ]; then
for b in origin/main origin/master origin/develop; do
git rev-parse --verify --quiet "$b" >/dev/null && DIFF_BASE="$b" && break
done
fi
DIFF_BASE="${DIFF_BASE:-HEAD~1}"
strix -n -t ./ --scan-mode quick --scope-mode diff --diff-base "$DIFF_BASE" --max-budget 5
# Or re-test with the original finding as focus (no diff base needed)