Fix reconciliation parent order and add reverse sync tree check
- Swap parent order in reconcile_filter_change(): josh-filtered must be first parent so josh can follow first-parent traversal to map history back to the monorepo. Old subrepo history on parent 2. - Add tree comparison in reverse_sync() before commit detection: if subrepo tree matches josh-filtered tree, skip immediately. Prevents false positive PRs after reconciliation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
21
lib/sync.sh
21
lib/sync.sh
@@ -185,11 +185,13 @@ reconcile_filter_change() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 4. Create merge commit: subrepo HEAD + josh-proxy HEAD, with josh-proxy's tree
|
# 4. Create merge commit: josh-proxy HEAD (first parent) + subrepo HEAD, with josh-proxy's tree
|
||||||
|
# Josh follows first-parent traversal — josh-filtered MUST be first so josh can map
|
||||||
|
# the history back to the monorepo. Old subrepo history hangs off parent 2.
|
||||||
local merge_commit
|
local merge_commit
|
||||||
merge_commit=$(git commit-tree "$josh_tree" \
|
merge_commit=$(git commit-tree "$josh_tree" \
|
||||||
-p "$subrepo_head" \
|
|
||||||
-p "$josh_head" \
|
-p "$josh_head" \
|
||||||
|
-p "$subrepo_head" \
|
||||||
-m "Sync: filter configuration updated
|
-m "Sync: filter configuration updated
|
||||||
|
|
||||||
${BOT_TRAILER}: filter-change/${mono_branch}/$(date -u +%Y-%m-%dT%H:%M:%SZ)")
|
${BOT_TRAILER}: filter-change/${mono_branch}/$(date -u +%Y-%m-%dT%H:%M:%SZ)")
|
||||||
@@ -242,7 +244,20 @@ reverse_sync() {
|
|||||||
git remote add mono-filtered "$(josh_auth_url)"
|
git remote add mono-filtered "$(josh_auth_url)"
|
||||||
git fetch mono-filtered "$mono_branch" || die "Failed to fetch from josh-proxy"
|
git fetch mono-filtered "$mono_branch" || die "Failed to fetch from josh-proxy"
|
||||||
|
|
||||||
# 3. Find new human commits (excludes bot commits from forward sync)
|
# 3. Compare trees — skip if subrepo matches josh-filtered view
|
||||||
|
local subrepo_tree josh_tree
|
||||||
|
# shellcheck disable=SC1083 # {tree} is git syntax, not shell brace expansion
|
||||||
|
subrepo_tree=$(git rev-parse "HEAD^{tree}")
|
||||||
|
# shellcheck disable=SC1083
|
||||||
|
josh_tree=$(git rev-parse "mono-filtered/${mono_branch}^{tree}")
|
||||||
|
|
||||||
|
if [ "$subrepo_tree" = "$josh_tree" ]; then
|
||||||
|
log "INFO" "Subrepo tree matches josh-filtered view — nothing to sync"
|
||||||
|
echo "skip"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. Find new human commits (excludes bot commits from forward sync)
|
||||||
local human_commits
|
local human_commits
|
||||||
human_commits=$(git log --ancestry-path "mono-filtered/${mono_branch}..HEAD" \
|
human_commits=$(git log --ancestry-path "mono-filtered/${mono_branch}..HEAD" \
|
||||||
--oneline --invert-grep --grep="^${BOT_TRAILER}:" 2>/dev/null || echo "")
|
--oneline --invert-grep --grep="^${BOT_TRAILER}:" 2>/dev/null || echo "")
|
||||||
|
|||||||
Reference in New Issue
Block a user