Skip to content

Commit

Permalink
Merge pull request #397 from shonfeder/dont-crash-on-new-dirs
Browse files Browse the repository at this point in the history
Don't fail analysis on new directories in the root
  • Loading branch information
shonfeder authored Nov 29, 2024
2 parents d9b58b7 + 04c1b89 commit 619aac5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/analyse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ module Analysis = struct
| Error _ as err -> Lwt.return err
| Ok pkgs ->
match String.split_on_char '/' path with
| [_] | ".github"::_ ->
Lwt_result.return pkgs
| "packages" :: name :: package :: "files" :: _ ->
Lwt_result.return (add_pkg ~path ~name ~package SignificantlyChanged pkgs)
| ["packages"; name; package; "opam"] ->
Expand All @@ -211,8 +209,11 @@ module Analysis = struct
get_opam ~cwd:dir path
>>= add_changed_pkg ~path ~name ~package ~old_content pkgs
end
| "packages" :: _ ->
Fmt.failwith "Unexpected path %S in packages directory (expecting 'packages/name/name.l.m.n/{opam,files/*}')" path
| _ ->
Fmt.failwith "Unexpected path %S in output (expecting 'packages/name/pkg/...')" path
(* Changes to any other path should be reviewed manually, since it's a change into repository meta data *)
Lwt_result.return pkgs
) (Ok OpamPackage.Map.empty)

let has_tests opam =
Expand Down
13 changes: 11 additions & 2 deletions test/analyse.t
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ See https://github.com/ocurrent/opam-repo-ci/issues/291
$ opam-repo-ci-local --repo="." --branch=analyze-invalid-opam-file --analyse-only --no-web-server
Error ""packages/a-1/a-1.0.0.1/opam" failed to be parsed: '.' is not a valid token"

Clean up the build cache
$ rm -rf var

$ rm -rf ./var
Test that a new root directory can be created.
See https://github.com/ocurrent/opam-repo-ci/pull/397

$ git checkout -q -b add-a-new-dir initial-state
$ mkdir a-new-directory
$ touch a-new-directory/foo
$ git add a-new-directory/foo
$ git commit -q -m "Add a new directory"
$ opam-repo-ci-local --repo="." --branch=add-a-new-dir --analyse-only --no-web-server
{ "packages": [] }

0 comments on commit 619aac5

Please sign in to comment.