Allow README.md being present anywhere

The one in root takes precedence, but opam-installer doesn't really
want to install things into %{prefix}%.
This commit is contained in:
Robur 2021-06-30 14:10:02 +00:00
parent 009fa49e9e
commit 1e3fcf984f
2 changed files with 19 additions and 6 deletions

View file

@ -71,9 +71,16 @@ let migrate datadir (module Db : Caqti_blocking.CONNECTION) =
Ok ((fpath, data) :: acc)) Ok ((fpath, data) :: acc))
(Ok []) (Ok [])
artifacts >>= fun files -> artifacts >>= fun files ->
(match List.find_opt (fun (p, _) -> Fpath.(equal (v "README.md") p)) files with let readme =
| None -> Ok () List.find_opt (fun (p, _) -> Fpath.(equal (v "README.md") p)) files
| Some (_, data) -> Db.exec insert_job_tag (readme_id, data, job))) in
let readme_anywhere =
List.find_opt (fun (p, _) -> String.equal "README.md" (Fpath.basename p)) files
in
(match readme, readme_anywhere with
| None, None -> Ok ()
| Some (_, data), _ | None, Some (_, data) ->
Db.exec insert_job_tag (readme_id, data, job)))
jobs >>= fun () -> jobs >>= fun () ->
Db.exec (Grej.set_version new_version) () Db.exec (Grej.set_version new_version) ()

View file

@ -294,9 +294,15 @@ let add_build
(match snd sec_syn with (match snd sec_syn with
| _, None -> Lwt_result.return () | _, None -> Lwt_result.return ()
| _, Some descr_v -> add_or_update descr_id descr_v) >>= fun () -> | _, Some descr_v -> add_or_update descr_id descr_v) >>= fun () ->
(match List.find_opt (fun (p, _) -> Fpath.(equal (v "README.md") p)) raw_artifacts with (let readme =
| None -> Lwt_result.return () List.find_opt (fun (p, _) -> Fpath.(equal (v "README.md") p)) raw_artifacts
| Some (_, data) -> add_or_update readme_id data) >>= fun () -> in
let readme_anywhere =
List.find_opt (fun (p, _) -> String.equal "README.md" (Fpath.basename p)) raw_artifacts
in
match readme, readme_anywhere with
| None, None -> Lwt_result.return ()
| Some (_, data), _ | None, Some (_, data) -> add_or_update readme_id data) >>= fun () ->
List.fold_left List.fold_left
(fun r file -> (fun r file ->
r >>= fun () -> r >>= fun () ->