From 4e0ed2cc8ddadf6d5504210e1210728e6f7cc9aa Mon Sep 17 00:00:00 2001 From: David Joerg Date: Sat, 11 Apr 2026 18:04:09 -0400 Subject: [PATCH] fix(ce-review): always fetch base branch to prevent stale merge-base (#544) Co-authored-by: David Joerg --- .../skills/ce-review/references/resolve-base.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/compound-engineering/skills/ce-review/references/resolve-base.sh b/plugins/compound-engineering/skills/ce-review/references/resolve-base.sh index 433d42b..9a87429 100644 --- a/plugins/compound-engineering/skills/ce-review/references/resolve-base.sh +++ b/plugins/compound-engineering/skills/ce-review/references/resolve-base.sh @@ -52,7 +52,9 @@ if [ -n "$REVIEW_BASE_BRANCH" ]; then if [ -n "$PR_BASE_REPO" ]; then PR_BASE_REMOTE=$(git remote -v | awk "index(\$2, \"github.com:$PR_BASE_REPO\") || index(\$2, \"github.com/$PR_BASE_REPO\") {print \$1; exit}") if [ -n "$PR_BASE_REMOTE" ]; then - git rev-parse --verify "$PR_BASE_REMOTE/$REVIEW_BASE_BRANCH" >/dev/null 2>&1 || git fetch --no-tags "$PR_BASE_REMOTE" "$REVIEW_BASE_BRANCH:refs/remotes/$PR_BASE_REMOTE/$REVIEW_BASE_BRANCH" 2>/dev/null || git fetch --no-tags "$PR_BASE_REMOTE" "$REVIEW_BASE_BRANCH" 2>/dev/null || true + # Always fetch — a locally cached ref may be stale, producing a + # merge-base that predates squash-merged work and inflating the diff. + git fetch --no-tags "$PR_BASE_REMOTE" "$REVIEW_BASE_BRANCH:refs/remotes/$PR_BASE_REMOTE/$REVIEW_BASE_BRANCH" 2>/dev/null || git fetch --no-tags "$PR_BASE_REMOTE" "$REVIEW_BASE_BRANCH" 2>/dev/null || true BASE_REF=$(git rev-parse --verify "$PR_BASE_REMOTE/$REVIEW_BASE_BRANCH" 2>/dev/null || true) fi fi @@ -60,7 +62,8 @@ if [ -n "$REVIEW_BASE_BRANCH" ]; then # Only try origin if it exists as a remote; otherwise skip to avoid # confusing errors in fork setups where origin points at the user's fork. if git remote get-url origin >/dev/null 2>&1; then - git rev-parse --verify "origin/$REVIEW_BASE_BRANCH" >/dev/null 2>&1 || git fetch --no-tags origin "$REVIEW_BASE_BRANCH:refs/remotes/origin/$REVIEW_BASE_BRANCH" 2>/dev/null || git fetch --no-tags origin "$REVIEW_BASE_BRANCH" 2>/dev/null || true + # Always fetch — same rationale as the fork-safe path above. + git fetch --no-tags origin "$REVIEW_BASE_BRANCH:refs/remotes/origin/$REVIEW_BASE_BRANCH" 2>/dev/null || git fetch --no-tags origin "$REVIEW_BASE_BRANCH" 2>/dev/null || true BASE_REF=$(git rev-parse --verify "origin/$REVIEW_BASE_BRANCH" 2>/dev/null || true) fi # Fall back to a bare local ref only if remote resolution failed