@@ -332,30 +332,29 @@ module Buildkite : Api.Buildkite = struct
332
332
333
333
let get_build ?(cache : [ `Use | `Refresh ] = `Use ) ~(ctx : Context.t ) build_url =
334
334
let * org, pipeline, build_nr = Lwt. return @@ Util.Build. get_org_pipeline_build' build_url in
335
- let build_url = sprintf " organizations/%s/pipelines/%s/builds/%s" org pipeline build_nr in
335
+ let path = sprintf " organizations/%s/pipelines/%s/builds/%s" org pipeline build_nr in
336
336
let build_key = cache_key org pipeline build_nr in
337
337
let * build =
338
338
let get () =
339
- request_token_auth ~name: (" get build details for #" ^ build_nr) ~ctx `GET build_url
339
+ request_token_auth ~name: (" get build details for #" ^ build_nr) ~ctx `GET path
340
340
Buildkite_j. get_build_res_of_string
341
341
in
342
342
match cache with
343
343
| `Refresh -> get ()
344
344
| `Use ->
345
345
match Builds_cache. get builds_cache build_key with
346
- | Some build -> Lwt. return_ok build
346
+ | Some build ->
347
+ log#info " Cache hit for build %s" build_key;
348
+ Lwt. return_ok build
347
349
| None -> get ()
348
350
in
349
351
Builds_cache. set builds_cache build_key build;
350
352
Lwt. return_ok build
351
353
352
354
let get_build_branch ~(ctx : Context.t ) (n : Github_t.status_notification ) =
353
355
let * org, pipeline, build_nr = Lwt. return @@ Util.Build. get_org_pipeline_build n in
354
- let build_url = sprintf " organizations/%s/pipelines/%s/builds/%s " org pipeline build_nr in
356
+ let * build_url = Lwt. return @@ Util.Build. get_build_url n in
355
357
let map_branch { Buildkite_t. branch; _ } : Github_t.branch = { name = branch } in
356
- match Builds_cache. get builds_cache (cache_key org pipeline build_nr) with
357
- | Some { Buildkite_t. branch; _ } -> Lwt. return_ok ({ name = branch } : Github_t.branch )
358
- | None ->
359
- log#info " Fetching branch details for build %s in pipeline %s" build_nr pipeline;
360
- get_build ~ctx build_url |> Lwt_result. map map_branch
358
+ log#info " Fetching branch details for %s" (cache_key org pipeline build_nr);
359
+ get_build ~cache: `Use ~ctx build_url |> Lwt_result. map map_branch
361
360
end
0 commit comments