backport
Version:
A CLI tool that automates the process of backporting commits
8 lines • 461 B
JavaScript
export function getSourcePullRequest(sourceCommit) {
const edges = sourceCommit.associatedPullRequests?.edges ?? [];
// Pick the PR whose merge produced this commit. GitHub also returns PRs
// whose head branch happens to contain it (e.g. rebased open PRs).
const merger = edges.find((edge) => edge?.node?.mergeCommit?.sha === sourceCommit.sha)?.node;
return merger ?? edges.at(0)?.node;
}
//# sourceMappingURL=get-source-pull-request.js.map