MCPcopy
hub / github.com/harness/harness / Find

Method Find

app/api/controller/pullreq/pr_find.go:28–59  ·  view source on GitHub ↗

Find returns a pull request from the provided repository.

(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	options types.PullReqMetadataOptions,
)

Source from the content-addressed store, hash-verified

26
27// Find returns a pull request from the provided repository.
28func (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.
62func (c *Controller) FindByBranches(

Callers

nothing calls this directly

Calls 6

getRepoCheckAccessMethod · 0.95
BadRequestFunction · 0.92
BackfillMethod · 0.80
FindByNumberMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected