Skip to content

Commit

Permalink
Gracefully handle deleted packages in analysis
Browse files Browse the repository at this point in the history
Previously, the analysis phase didn't expect any package deletions. So,
we'd fail with the error "impossible". But, with the new opam-repository
archival process, we allow for deletions, even though only in the
special case of a package being archived.
  • Loading branch information
punchagan committed Dec 17, 2024
1 parent fabac09 commit 9ff251b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/analyse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,12 @@ module Analysis = struct
Fpath.v "packages" // name // (name^"."^version) // "opam"

let add_package_data ~dir (pkg, kind) packages =
match packages with
| Error _ as err -> Lwt.return err
| Ok packages ->
match (packages, kind) with
| Error _ as err, _ ->
Lwt.return err
| Ok packages, Deleted ->
Lwt.return_ok ((pkg, {kind; has_tests = false}) :: packages)
| Ok packages, _ ->
let open Lwt_result.Syntax in
let path = Fpath.to_string (package_to_path pkg) in
let* content = get_opam ~cwd:dir path |> Lwt_result.map_error (fun _ -> `Msg "impossible") in
Expand Down
6 changes: 5 additions & 1 deletion test/analyse.t
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ Test deleting existing packages works
* a-1.0.0.1 removed (HEAD -> new-branch-2)
* a-1 (tag: initial-state, new-branch-1, master)
$ opam-repo-ci-local --repo="." --branch=new-branch-2 --analyse-only --no-web-server
Error "impossible"
{
"packages": [
[ "a-1.0.0.1", { "kind": [ "Deleted" ], "has_tests": false } ]
]
}

Clean up the build cache

Expand Down

0 comments on commit 9ff251b

Please sign in to comment.