Find returns a pull request from the provided repository.
( ctx context.Context, session *auth.Session, repoRef string, pullreqNum int64, options types.PullReqMetadataOptions, )
| 26 | |
| 27 | // Find returns a pull request from the provided repository. |
| 28 | func (c *Controller) Find( |
| 29 | ctx context.Context, |
| 30 | session *auth.Session, |
| 31 | repoRef string, |
| 32 | pullreqNum int64, |
| 33 | options types.PullReqMetadataOptions, |
| 34 | ) (*types.PullReq, error) { |
| 35 | if pullreqNum <= 0 { |
| 36 | return nil, usererror.BadRequest("A valid pull request number must be provided.") |
| 37 | } |
| 38 | |
| 39 | repo, err := c.getRepoCheckAccess(ctx, session, repoRef, enum.PermissionRepoView) |
| 40 | if err != nil { |
| 41 | return nil, fmt.Errorf("failed to acquire access to the repo: %w", err) |
| 42 | } |
| 43 | |
| 44 | pr, err := c.pullreqStore.FindByNumber(ctx, repo.ID, pullreqNum) |
| 45 | if err != nil { |
| 46 | return nil, err |
| 47 | } |
| 48 | |
| 49 | err = c.labelSvc.Backfill(ctx, pr) |
| 50 | if err != nil { |
| 51 | return nil, fmt.Errorf("failed to backfill labels assigned to pull request: %w", err) |
| 52 | } |
| 53 | |
| 54 | if err := c.pullreqListService.BackfillMetadataForPullReq(ctx, repo, pr, options); err != nil { |
| 55 | return nil, fmt.Errorf("failed to backfill pull request metadata: %w", err) |
| 56 | } |
| 57 | |
| 58 | return pr, nil |
| 59 | } |
| 60 | |
| 61 | // FindByBranches returns a pull request from the provided branch pair. |
| 62 | func (c *Controller) FindByBranches( |
nothing calls this directly
no test coverage detected