HandleFind returns a http.HandlerFunc that finds a pull request.
(pullreqCtrl *pullreq.Controller)
| 24 | |
| 25 | // HandleFind returns a http.HandlerFunc that finds a pull request. |
| 26 | func HandleFind(pullreqCtrl *pullreq.Controller) http.HandlerFunc { |
| 27 | return func(w http.ResponseWriter, r *http.Request) { |
| 28 | ctx := r.Context() |
| 29 | session, _ := request.AuthSessionFrom(ctx) |
| 30 | |
| 31 | repoRef, err := request.GetRepoRefFromPath(r) |
| 32 | if err != nil { |
| 33 | render.TranslatedUserError(ctx, w, err) |
| 34 | return |
| 35 | } |
| 36 | |
| 37 | pullreqNumber, err := request.GetPullReqNumberFromPath(r) |
| 38 | if err != nil { |
| 39 | render.TranslatedUserError(ctx, w, err) |
| 40 | return |
| 41 | } |
| 42 | |
| 43 | options, err := request.ParsePullReqMetadataOptions(r) |
| 44 | if err != nil { |
| 45 | render.TranslatedUserError(ctx, w, err) |
| 46 | return |
| 47 | } |
| 48 | |
| 49 | options.IncludeGitStats = true // always backfill PR git stats when fetching one PR. |
| 50 | |
| 51 | pr, err := pullreqCtrl.Find(ctx, session, repoRef, pullreqNumber, options) |
| 52 | if err != nil { |
| 53 | render.TranslatedUserError(ctx, w, err) |
| 54 | return |
| 55 | } |
| 56 | |
| 57 | render.JSON(w, http.StatusOK, pr) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // HandleFindByBranches returns a http.HandlerFunc that finds a pull request from the provided branch pair. |
| 62 | func HandleFindByBranches(pullreqCtrl *pullreq.Controller) http.HandlerFunc { |
nothing calls this directly
no test coverage detected
searching dependent graphs…