Skip to content

feat(sync): add sync.backfill to fetch closed items with no local file - #72

Open
vkislichenko wants to merge 1 commit into
antfu:mainfrom
vkislichenko:feat/sync-backfill-closed
Open

vkislichenko wants to merge 1 commit into
antfu:mainfrom
vkislichenko:feat/sync-backfill-closed

Conversation

@vkislichenko

Copy link
Copy Markdown

I use ghfs to mirror a few repos and noticed a lot of closed PRs were just missing, even with closed: true.

Turns out closed: true only keeps closed items that were already mirrored while they were open. If something opens and closes between two syncs (pretty common for small PRs that get merged in a few minutes), it never gets a local file, so it's dropped instead of fetched. Running --full doesn't bring it back either.

Looks like this came from 81ebd50, where closed went from 'existing' | 'all' | false to a boolean. The JSDoc says true syncs all closed items, but the check was switched from === 'existing' to === true, so it kept the old "existing" behavior.

I went with a separate opt-in sync.backfill rather than changing what closed: true does, because turning it on fetches the whole closed history on the next full sync (around 7 requests per closed PR), which could be a surprise on bigger repos. Happy to change it so closed: true just does this if you'd prefer.

The drop check was duplicated in prepareIssueCandidateSync and handleClosedIssueByPolicy, so I moved it into one helper used by both.

Tested on a repo with 5 closed PRs that were never mirrored: before, 0 of them came through; with backfill: true, all 5 plus their patches. A follow-up incremental sync made 2 requests and changed nothing.

With `closed: true`, a closed issue or PR is only kept if it was already
mirrored while it was open. Anything that opened and closed between two
syncs has no local file, so it gets dropped instead of fetched, and a
`--full` sync doesn't bring it back. On my mirrors that was most of the
closed PRs, mostly short-lived ones that merged before the next poll.

This adds an opt-in `sync.backfill`. When it's on, those items are
fetched like any other. It's off by default because backfilling a long
history costs roughly 7 requests per closed PR.

The drop check existed twice (prepareIssueCandidateSync and
handleClosedIssueByPolicy), so it now lives in one helper,
shouldDropUntrackedClosedItem, used by both.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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