Skip to content

kew sync

Backfill PR outcomes (merged/closed state, review cycles, diff stats) for past runs.

Usage: kew sync

kew sync walks every run whose PR outcome isn't yet final — those with no persisted outcome and those still marked open — and fetches the current state of each PR from GitHub (so a merge or close that landed since the last sync is picked up here). Runs already in a terminal state (merged/closed) are skipped. Results are written to the local SQLite store so that kew report can read them without making live GitHub calls.

When to use

  • After connectivity gaps — if kew was offline while PRs were merging, run kew sync to catch up before generating a report.
  • Scheduled sweep — add kew sync to cron to keep outcome data fresh without waiting for the next kew report run.
  • CI/CD integration — call kew sync in a post-merge workflow to record merge state close to the event.

Behaviour

  • Fail-soft: individual fetch failures (missing PR, rate limit, network error) are silently skipped. The count returned reflects how many runs were successfully updated. Partial results are always persisted.
  • Cron-friendly: exits 0 even when no runs need updating (count = 0).
  • Deduplication: multiple runs that share a branch (e.g. retries on the same issue) count as one GitHub call.
  • Repo resolution: uses [project] repo when set, otherwise auto-detects it via gh repo view (the same detection kew report and dispatch use). If no repo can be determined, kew sync warns and skips rather than silently reporting synced 0 run(s).

Note: kew report also syncs outcomes automatically before building the report, so you only need to run kew sync explicitly when you want to update the store without generating a report.

Examples

# Pull the latest PR outcomes for all un-synced runs
kew sync

# Schedule a daily sync (crontab example)
0 6 * * * cd /path/to/repo && kew sync