fix(#2916): use fork-point detection for non-default-base warning
Replace the "ahead-of" heuristic with a structural check that compares the HEAD↔origin/$DEFAULT_BRANCH merge-base to origin/$DEFAULT_BRANCH itself. The previous count-based warning fired on legitimate WIP that was simply ahead of the default branch — the correct signal is that the branch did not fork from the default branch in the first place. Addresses CodeRabbit review on PR #2921. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -241,9 +241,9 @@ else
|
||||
git checkout -b "$BRANCH_NAME" "origin/$DEFAULT_BRANCH" # pinned base (#2916)
|
||||
fi
|
||||
|
||||
INHERITED=$(git rev-list --count "origin/${DEFAULT_BRANCH}..HEAD" 2>/dev/null || echo "?")
|
||||
if [ "$INHERITED" != "0" ] && [ "$INHERITED" != "?" ]; then
|
||||
echo "WARNING: Phase branch '$BRANCH_NAME' contains $INHERITED commit(s) inherited from a non-default base. Verify this is intentional."
|
||||
# Warn only when HEAD did NOT fork from origin/$DEFAULT_BRANCH (merge-base ≠ tip) — #2916.
|
||||
if MB=$(git merge-base HEAD "origin/${DEFAULT_BRANCH}" 2>/dev/null) && DT=$(git rev-parse --verify --quiet "refs/remotes/origin/${DEFAULT_BRANCH}" 2>/dev/null) && [ "$MB" != "$DT" ]; then
|
||||
echo "WARNING: Phase branch '$BRANCH_NAME' does not fork from origin/${DEFAULT_BRANCH}; verify the base is intentional."
|
||||
fi
|
||||
```
|
||||
|
||||
|
||||
@@ -222,9 +222,9 @@ else
|
||||
git checkout -b "$branch_name" "origin/$DEFAULT_BRANCH"
|
||||
fi
|
||||
|
||||
INHERITED=$(git rev-list --count "origin/${DEFAULT_BRANCH}..HEAD" 2>/dev/null || echo "?")
|
||||
if [ "$INHERITED" != "0" ] && [ "$INHERITED" != "?" ]; then
|
||||
echo "WARNING: Quick-task branch '$branch_name' contains $INHERITED commit(s) inherited from a non-default base. Verify this is intentional before continuing."
|
||||
# Warn only when HEAD did NOT fork from origin/$DEFAULT_BRANCH (merge-base ≠ tip) — #2916.
|
||||
if MB=$(git merge-base HEAD "origin/${DEFAULT_BRANCH}" 2>/dev/null) && DT=$(git rev-parse --verify --quiet "refs/remotes/origin/${DEFAULT_BRANCH}" 2>/dev/null) && [ "$MB" != "$DT" ]; then
|
||||
echo "WARNING: Quick-task branch '$branch_name' does not fork from origin/${DEFAULT_BRANCH}; verify the base is intentional before continuing."
|
||||
fi
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user