Skip to content

feat(digest): flag forks diverged from upstream - #5

Merged
dnplkndll merged 1 commit into
mainfrom
feat/fork-sync-divergence-check
May 22, 2026
Merged

feat(digest): flag forks diverged from upstream#5
dnplkndll merged 1 commit into
mainfrom
feat/fork-sync-divergence-check

Conversation

@dnplkndll

Copy link
Copy Markdown
Contributor

Why

merge-upstream (the API behind GitHub's green "Sync fork" button) returns success whether it fast-forwards or produces a merge commit. So a series-named fork branch that someone accidentally pushed local commits to silently accumulates drift across daily syncs, and the digest reports "Synced" same as a healthy run.

Concrete case from today: ledoent/social:18.0 had grown 30 commits ahead of OCA/social:18.0 before anyone noticed — caused by four Merge branch '18.0-social-media-*' of … into 18.0 commits in April 2026 that broke the fast-forward invariant. Every nightly sync since then quietly produced another Merge branch 'OCA:18.0' into 18.0 merge commit on top, all flagged success by the workflow.

What changes

  • fork_sync_digest.sync_branch() now takes an optional upstream_org and, on a successful merge-upstream, calls /repos/{upstream}/{repo}/compare/{upstream}:{branch}...{fork}:{branch} to capture ahead_by / behind_by. Sets diverged = ahead_by > 0.
  • Non-OCA forks (no upstream_org in forks.yml) skip the compare — one network call per fork, not per branch, only when meaningful.
  • render_digest.render() adds a sync_diverged bucket: own warning section (⚠️ Diverged from upstream, amber not red), separate subject tag (⚠️ N diverged), exit_marker unchanged so divergence stays informational and doesn't conflate with "scripts broke".
  • A compare-call failure doesn't mask a successful sync — ahead_by stays None and the branch is treated as not-known-diverged rather than falsely clean.

Tests

6 new tests (25 total, all pass):

  • test_diverged_branch_is_flagged_when_upstream_org_provided — the 30-ahead social case
  • test_clean_fast_forward_is_not_diverged
  • test_no_upstream_org_skips_divergence_check — verifies only one gh call happens
  • test_compare_failure_does_not_mask_successful_sync
  • test_failed_sync_skips_compare
  • test_diverged_branch_warning_in_subject_and_body — render side

Out of scope

Auto-resetting diverged branches. The email surfaces the drift; manual git refs PATCH … force=true (after backup) stays the recovery path, since reset-to-upstream is destructive and the workflow's PAT shouldn't have force-push authority on a series-named branch.

merge-upstream returns success whether it fast-forwards or produces a
merge commit, so a series-named fork branch that someone accidentally
pushed local commits to (e.g. merging a feature branch into 18.0)
silently accumulates drift across daily syncs. ledoent/social:18.0 in
May 2026 had grown 30 commits ahead before anyone noticed; today's run
"succeeded" same as every prior one.

Add a post-sync compare call per branch (when upstream_org is set in
forks.yml) and surface ahead_by > 0 as a "Diverged from upstream"
warning in the email — own section, separate subject tag, exit_marker
unchanged so it stays informational and doesn't fail the workflow.

Tests: divergence flagged with merge_type=merge + ahead_by>0, clean
fast-forward not flagged, missing upstream_org skips the compare,
compare-call failure doesn't mask a successful sync.
@dnplkndll
dnplkndll merged commit 857c9cf into main May 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant