Skip to content

Commit

Permalink
Remove ~repo_packages argument to lint_packages
Browse files Browse the repository at this point in the history
Also remove get_packages from the public API
  • Loading branch information
punchagan committed Dec 4, 2024
1 parent c0f728e commit eea68d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
5 changes: 1 addition & 4 deletions opam-ci-check/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ let lint (changed_pkgs, new_pkgs) local_repo_dir =
List.map (process_package ~newly_published:true) new_pkgs
@ List.map (process_package ~newly_published:false) changed_pkgs
in
let repo_packages = Lint.get_packages opam_repo_dir in
let errors =
Lint.lint_packages ~opam_repo_dir ~repo_packages all_lint_packages
in
let errors = Lint.lint_packages ~opam_repo_dir all_lint_packages in
match errors with
| [] ->
print_endline "No errors";
Expand Down
5 changes: 3 additions & 2 deletions opam-ci-check/lib/lint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,11 @@ type t = {
let v ~pkg ~newly_published ~pkg_src_dir opam =
{ pkg; newly_published; pkg_src_dir; opam }

let get_packages repo_dir =
let get_package_names repo_dir =
get_files (repo_dir // "packages") |> List.sort String.compare

let lint_packages ~opam_repo_dir ~repo_packages metas =
let lint_packages ~opam_repo_dir metas =
let repo_packages = get_package_names opam_repo_dir in
metas
|> List.map (fun { pkg; newly_published; pkg_src_dir; opam } ->
Checks.lint_package ~opam_repo_dir ~pkg ~pkg_src_dir ~repo_packages
Expand Down
26 changes: 5 additions & 21 deletions opam-ci-check/lib/lint.mli
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,20 @@ val v :
@param opam Parsed OPAM metadata for the package.
*)

val get_packages : string -> string list
(** [get_packages repo] is a list of all the packages in the opam repository
located at [repo].
Example:
{[
let all_packages = get_packages repo
]} *)

val lint_packages :
opam_repo_dir:string ->
repo_packages:string list ->
t list ->
(OpamPackage.t * error) list
(** [lint_packages ~opam_repo_dir ~repo_packages metas] is a list of all the
opam_repo_dir:string -> t list -> (OpamPackage.t * error) list
(** [lint_packages ~opam_repo_dir metas] is a list of all the
errors detected while linting the packages in the [metas] list in the
context of the opam repository located at [opam_repo_dir]. [repo_packages]
is the list of all the packages in the repository, used for some checks
like name clashes.
context of the opam repository located at [opam_repo_dir].
@param opam_repo_dir The path a local opam repository.
@param repo_packages List of names of all the packages in the opam repository.
Examples:
{[
let passes_all_checks = assert (lint_packages ~opam_repo_dir ~repo_packages metas |> List.length = 0)
let failed_some_checks = assert (lint_packages ~opam_repo_dir ~repo_packages metas |> List.length > 0)
let passes_all_checks = assert (lint_packages ~opam_repo_dir metas |> List.length = 0)
let failed_some_checks = assert (lint_packages ~opam_repo_dir metas |> List.length > 0)
let messages_for_all_failed_checks =
lint_packages ~opam_repo_dir ~repo_packages metas
|> List.map msg_of_error
Expand Down

0 comments on commit eea68d9

Please sign in to comment.