ci(upstream-merge): handle no merge-base case in context prep (skip reintroduced detection when unrelated histories)

This commit is contained in:
James Peter
2025-09-07 20:47:47 +10:00
parent dd0dc88f02
commit e410f2ab6e
+13 -9
View File
@@ -281,16 +281,20 @@ jobs:
git diff --stat "origin/${DEFAULT_BRANCH}..upstream/${UPSTREAM_BRANCH}" > .github/auto/DIFFSTAT.txt || true
# Detect reintroduced paths: present in merge-base, absent on default, present on upstream
MB=$(git merge-base "origin/${DEFAULT_BRANCH}" "upstream/${UPSTREAM_BRANCH}")
MB=$(git merge-base "origin/${DEFAULT_BRANCH}" "upstream/${UPSTREAM_BRANCH}" 2>/dev/null || true)
: > .github/auto/REINTRODUCED_PATHS.txt
while read -r status path; do
[ "${status}" = "A" ] || continue
if git ls-tree -r --name-only "$MB" -- "$path" >/dev/null 2>&1 && \
git ls-tree -r --name-only "$MB" -- "$path" | grep -q . && \
! git ls-tree -r --name-only "origin/${DEFAULT_BRANCH}" -- "$path" | grep -q .; then
echo "$path" >> .github/auto/REINTRODUCED_PATHS.txt
fi
done < <(git diff --name-status "origin/${DEFAULT_BRANCH}..upstream/${UPSTREAM_BRANCH}" || true)
if [ -n "${MB:-}" ]; then
while read -r status path; do
[ "${status}" = "A" ] || continue
if git ls-tree -r --name-only "$MB" -- "$path" >/dev/null 2>&1 && \
git ls-tree -r --name-only "$MB" -- "$path" | grep -q . && \
! git ls-tree -r --name-only "origin/${DEFAULT_BRANCH}" -- "$path" | grep -q .; then
echo "$path" >> .github/auto/REINTRODUCED_PATHS.txt
fi
done < <(git diff --name-status "origin/${DEFAULT_BRANCH}..upstream/${UPSTREAM_BRANCH}" || true)
else
echo "No merge-base between origin/${DEFAULT_BRANCH} and upstream/${UPSTREAM_BRANCH}; skipping reintroduced path detection." >> .github/auto/CHANGE_HISTOGRAM.txt
fi
- name: Run Code agent to perform upstream merge
id: agent