Fix filter reconciliation for pre-v1.2 state and unrelated histories
Three bugs found during first CI run after enabling :exclude: - Derive old filter (:/subfolder) when state has no josh_filter stored (pre-v1.2 upgrade path) - Detect unrelated histories in forward_sync() and fall back to reconcile_filter_change() instead of creating a useless conflict PR - Skip state update on conflict result (prevents storing wrong filter and mono SHA that blocks retries) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -214,6 +214,18 @@ _sync_direction() {
|
||||
local prev_filter
|
||||
prev_filter=$(echo "$state" | jq -r '.last_forward.josh_filter // empty')
|
||||
|
||||
# If no filter stored (pre-v1.2 state) but a previous sync exists,
|
||||
# the old filter was the simple :/subfolder (before exclude was added)
|
||||
if [ -z "$prev_filter" ]; then
|
||||
local prev_mono_sha
|
||||
prev_mono_sha=$(echo "$state" | jq -r '.last_forward.mono_sha // empty')
|
||||
if [ -n "$prev_mono_sha" ]; then
|
||||
local subfolder
|
||||
subfolder=$(echo "$TARGET_JSON" | jq -r '.subfolder')
|
||||
prev_filter=":/${subfolder}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$prev_filter" ] && [ "$prev_filter" != "$JOSH_FILTER" ]; then
|
||||
log "WARN" "Josh filter changed — reconciling histories"
|
||||
log "INFO" "Old: ${prev_filter}"
|
||||
@@ -225,6 +237,13 @@ _sync_direction() {
|
||||
else
|
||||
result=$(reverse_sync)
|
||||
fi
|
||||
# If forward sync hit unrelated histories, fall back to reconciliation
|
||||
if [ "$result" = "unrelated" ]; then
|
||||
log "WARN" "Unrelated histories detected — falling back to filter reconciliation"
|
||||
result=$(reconcile_filter_change)
|
||||
log "INFO" "Reconciliation result: ${result}"
|
||||
fi
|
||||
|
||||
log "INFO" "Result: ${result}"
|
||||
|
||||
# Handle warnings
|
||||
@@ -234,6 +253,7 @@ _sync_direction() {
|
||||
fi
|
||||
if [ "$result" = "conflict" ]; then
|
||||
echo "::warning::Target ${target_name}, branch ${branch}: merge conflict — PR created on subrepo"
|
||||
continue
|
||||
fi
|
||||
if [ "$result" = "josh-rejected" ]; then
|
||||
echo "::error::Target ${target_name}, branch ${branch}: josh rejected push — check proxy logs"
|
||||
|
||||
Reference in New Issue
Block a user