func FindPR()

in internal/github/find-pr.go [86:113]


func FindPR(ctx context.Context, c *Client, owner, repo, commit string) (FoundPRs, error) {
	prs, _, err := c.PullRequests.ListPullRequestsWithCommit(
		context.Background(), owner, repo, commit, nil)
	if err != nil {
		return FoundPRs{}, fmt.Errorf("failed listing prs with commit: %w", err)
	}

	respData := FoundPRs{
		Items: make([]PRForCommit, len(prs)),
	}

	backportStrategy := &BackportPRNumber{}
	prNumberStrategy := &PRNumber{}

	for i, pr := range prs {
		prID, err := TestStrategies(pr, backportStrategy, prNumberStrategy)
		if err != nil {
			return FoundPRs{}, fmt.Errorf("failed testing strategies: %w", err)
		}

		respData.Items[i] = PRForCommit{
			CommitHash:    commit,
			PullRequestID: prID,
		}
	}

	return respData, nil
}