Skip to main content

find_merged_pr

Function find_merged_pr 

Source
pub fn find_merged_pr(branch: &str) -> Result<Option<MergedPr>>
Expand description

Look up the merged PR for branch, if any, using the gh CLI.

Runs gh pr list --head <branch> --state merged --json number,mergedAt,headRefOid --limit 1. Matching is by branch name only, so a same-named branch from a fork is a false match; callers that care about this should already have ruled out forks another way.

Returns Ok(None) if the branch never had a PR merged under that name, or if the merged PR’s headRefOid is missing or unparseable (callers can’t compare against the branch tip without it, so this degrades the same as “no merged PR”). Does not call check_gh_available itself — callers that intend to silently degrade when gh is unavailable should check once up front rather than pay for it on every branch.