Use Case
For PR management automation, we need to detect when PR branches are behind their base branch to:
- Monitor branch sync status
- Alert authors when branches need rebasing
- Track how many commits behind/ahead a branch is
Current State
The package provides PullRequest::query(), ->head->ref, ->base->ref, but lacks branch comparison.
Proposed API
// Option 1: On PullRequest instance
= PullRequest::find('owner/repo', 123);
= ->compare(); // returns Comparison DTO
->aheadBy; // int - commits ahead of base
->behindBy; // int - commits behind base
->status; // 'ahead' | 'behind' | 'diverged' | 'identical'
// Option 2: Static method for arbitrary branches
= PullRequest::compareBranches('owner/repo', 'main', 'feature-branch');
GitHub API Endpoint
Uses: GET /repos/{owner}/{repo}/compare/{basehead}
Response includes:
ahead_by (int)
behind_by (int)
status (string)
commits (array)
files (array)
Additional Context
This would enable building sync-monitoring agents that can:
- Check all open PRs for branches behind base
- Alert/nudge authors to rebase
- Scheduled checks for branch hygiene
Happy to contribute a PR if this aligns with the package direction.
Use Case
For PR management automation, we need to detect when PR branches are behind their base branch to:
Current State
The package provides
PullRequest::query(),->head->ref,->base->ref, but lacks branch comparison.Proposed API
GitHub API Endpoint
Uses:
GET /repos/{owner}/{repo}/compare/{basehead}Response includes:
ahead_by(int)behind_by(int)status(string)commits(array)files(array)Additional Context
This would enable building sync-monitoring agents that can:
Happy to contribute a PR if this aligns with the package direction.