Skip to content

jleo-py/pr_sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PR Sync

Keep your GitHub PRs updated with their target branch and CI passing.

What It Does

  1. Finds all your open PRs in the configured organization
  2. Updates branches that are behind their target (merge commits, not rebase)
  3. Waits for CI to complete
  4. Retries failed CI once (handles flaky tests)
  5. Reports conflicts and persistent failures for manual attention

Safety

This tool can ONLY:

  • Update PR branches with their base branch
  • Re-run failed CI jobs

It CANNOT merge, close, or make other changes to your PRs.

Prerequisites

  • Node.js 18+
  • GitHub CLI (gh) installed and authenticated
    gh auth status  # Verify authentication

Installation

# Clone the repository
git clone https://github.com/jleo-py/pr_sync.git
cd pr_sync

# Install dependencies
pnpm install

# Build
pnpm build

Configuration

Copy the example config and customize:

cp config.example.json config.json

Edit config.json:

{
  "org": "YourOrg",
  "maxConcurrency": 3,
  "staggerDelayMs": 30000,
  "ciRetryCount": 1,
  "ciPollIntervalMs": 30000,
  "ciTimeoutMs": 1800000,
  "excludeRepos": [],
  "includeRepos": null
}
Option Default Description
org "PerformYard" GitHub organization to search
maxConcurrency 3 Number of PRs to process in parallel
staggerDelayMs 30000 Delay between starting concurrent PRs (ms)
ciRetryCount 1 Times to retry failed CI (0 = no retries)
ciPollIntervalMs 30000 How often to check CI status (ms)
ciTimeoutMs 1800000 Max time to wait for CI (30 min)
excludeRepos [] Repos to skip (e.g., ["legacy-app"])
includeRepos null Only process these repos (null = all)

Usage

# Run with config file
pnpm start

# Or with CLI options
pnpm start --org MyOrg --max-concurrency 2

# See all options
pnpm start --help

Output

PR Sync - Keep your PRs up to date
──────────────────────────────────────────────────

🔍 Searching for open PRs by jleo in PerformYard...

🔍 Found 4 open PRs

  (sorted by dependency chain - base branches first)

  ├─ PerformYard#1234: Add user authentication...
  ✅ PerformYard#1234 - already up to date
    PerformYard#1234: ✅ CI passing
  ├─ PerformYard#1235: Fix pagination bug...
  🚀 PerformYard#1235 - updated
    PerformYard#1235: ⏳ Waiting for CI...
    PerformYard#1235: ✅ CI passing
  ├─ Logan#456: Update analytics...
  🔴 Logan#456 - merge conflict
  ├─ 🔄 PerformYard#1237: refreshing status...
  ├─ PerformYard#1237: Improve search filters...
  🚀 PerformYard#1237 - updated
    PerformYard#1237: ⚠️ CI failing (2 failed runs)
    PerformYard#1237: 🔄 Re-running 2 failed jobs...
    PerformYard#1237: ✅ CI passing after retry

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SUMMARY

  ✅ Passing: 3
     PerformYard#1234
     PerformYard#1235
     PerformYard#1237

  🔴 Merge Conflicts: 1 (needs manual resolution)
     https://github.com/PerformYard/Logan/pull/456

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Development

# Run tests
pnpm test

# Run tests in watch mode
pnpm test:watch

# Build
pnpm build

# Run without building (dev mode)
pnpm dev

Architecture

src/
├── index.ts      # CLI entry point
├── config.ts     # Configuration loading
├── github.ts     # GitHub operations (safety-scoped)
├── ci.ts         # CI status and retries
├── runner.ts     # Orchestration logic
├── output.ts     # Terminal formatting
└── types.ts      # TypeScript types

tests/
├── github.test.ts
├── runner.test.ts
└── mocks/
    └── gh.ts     # Mock gh CLI for testing

Sharing with Teammates

  1. Share this directory or create a git repo
  2. Each user copies config.example.json to config.json
  3. Users customize org if working with different organizations
  4. The tool auto-detects the current GitHub user via gh api user

Troubleshooting

"No PRs found"

  • Verify you're authenticated: gh auth status
  • Check the organization name in config
  • Ensure you have open PRs: gh pr list --author @me

"Command failed" errors

  • Check GitHub CLI is up to date: gh --version
  • Re-authenticate if needed: gh auth login

Rate limits

  • Reduce maxConcurrency in config
  • Increase staggerDelayMs to space out API calls

About

Keep your PRs up to date

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published