feat(digest): flag forks diverged from upstream - #5
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.0had grown 30 commits ahead ofOCA/social:18.0before anyone noticed — caused by fourMerge branch '18.0-social-media-*' of … into 18.0commits in April 2026 that broke the fast-forward invariant. Every nightly sync since then quietly produced anotherMerge branch 'OCA:18.0' into 18.0merge commit on top, all flaggedsuccessby the workflow.What changes
fork_sync_digest.sync_branch()now takes an optionalupstream_organd, on a successful merge-upstream, calls/repos/{upstream}/{repo}/compare/{upstream}:{branch}...{fork}:{branch}to captureahead_by/behind_by. Setsdiverged = ahead_by > 0.upstream_orginforks.yml) skip the compare — one network call per fork, not per branch, only when meaningful.render_digest.render()adds async_divergedbucket: own warning section (⚠️ Diverged from upstream, amber not red), separate subject tag (⚠️ N diverged),exit_markerunchanged so divergence stays informational and doesn't conflate with "scripts broke".ahead_bystaysNoneand 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 casetest_clean_fast_forward_is_not_divergedtest_no_upstream_org_skips_divergence_check— verifies only oneghcall happenstest_compare_failure_does_not_mask_successful_synctest_failed_sync_skips_comparetest_diverged_branch_warning_in_subject_and_body— render sideOut 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.