licenses fix tentative
This commit is contained in:
1 parent
42e5e3321a
commit
04ba4437f0
3 files changed
+20
-9
No files matched your search
@@ -35,6 +35,7 @@ countdown. Press any key (or Ctrl-C) to quit.")
|
|||||||
console-eio
|
console-eio
|
||||||
digestif
|
digestif
|
||||||
(bos :build)
|
(bos :build)
|
||||||
|
(ocamlfind :build)
|
||||||
(ocaml-lsp-server :with-dev-setup)
|
(ocaml-lsp-server :with-dev-setup)
|
||||||
(merlin :with-dev-setup)
|
(merlin :with-dev-setup)
|
||||||
(ocamlformat :with-dev-setup)
|
(ocamlformat :with-dev-setup)
|
||||||
|
|||||||
+18
-9
@@ -29,6 +29,10 @@ let line cmd =
|
|||||||
| x :: _ -> Ok x
|
| x :: _ -> Ok x
|
||||||
| [] -> msg "no output from: %s" (Cmd.to_string cmd)
|
| [] -> msg "no output from: %s" (Cmd.to_string cmd)
|
||||||
|
|
||||||
|
(* Windows writes paths with backslashes, and drive letters in either case. *)
|
||||||
|
let normalize s =
|
||||||
|
String.lowercase_ascii (String.map (function '\\' -> '/' | c -> c) s)
|
||||||
|
|
||||||
let starts_with ~prefix s =
|
let starts_with ~prefix s =
|
||||||
String.length s >= String.length prefix
|
String.length s >= String.length prefix
|
||||||
&& String.sub s 0 (String.length prefix) = prefix
|
&& String.sub s 0 (String.length prefix) = prefix
|
||||||
@@ -64,19 +68,23 @@ let load_changes switch =
|
|||||||
|> List.filter (Fpath.has_ext ".changes")
|
|> List.filter (Fpath.has_ext ".changes")
|
||||||
|> map_result (fun f ->
|
|> map_result (fun f ->
|
||||||
let* content = OS.File.read f in
|
let* content = OS.File.read f in
|
||||||
Ok (Fpath.(basename (rem_ext f)), content))
|
Ok (Fpath.(basename (rem_ext f)), normalize content))
|
||||||
|
|
||||||
let owner ~stdlib ~changes lib =
|
let owner ~stdlib ~changes lib =
|
||||||
let* dir = line (ocamlfind [ "query"; "-format"; "%d"; lib ]) in
|
let* dir = line (ocamlfind [ "query"; "-format"; "%d"; lib ]) in
|
||||||
if starts_with ~prefix:stdlib dir then Ok (Some "ocaml")
|
if starts_with ~prefix:(normalize stdlib) (normalize dir) then Ok "ocaml"
|
||||||
else
|
else
|
||||||
let top = List.hd (String.split_on_char '.' lib) in
|
let top = List.hd (String.split_on_char '.' lib) in
|
||||||
let meta = Re.compile (Re.str (Printf.sprintf "lib/%s/META" top)) in
|
let meta =
|
||||||
Ok
|
Re.compile (Re.str (normalize (Printf.sprintf "lib/%s/META" top)))
|
||||||
(List.find_map
|
in
|
||||||
(fun (pkg, content) ->
|
match
|
||||||
if Re.execp meta content then Some pkg else None)
|
List.find_map
|
||||||
changes)
|
(fun (pkg, content) -> if Re.execp meta content then Some pkg else None)
|
||||||
|
changes
|
||||||
|
with
|
||||||
|
| Some pkg -> Ok pkg
|
||||||
|
| None -> msg "no opam package found for the library %s" lib
|
||||||
|
|
||||||
let license_re = Re.Perl.compile_pat ~opts:[ `Multiline ] "^license:[ \t]*(.*)$"
|
let license_re = Re.Perl.compile_pat ~opts:[ `Multiline ] "^license:[ \t]*(.*)$"
|
||||||
|
|
||||||
@@ -125,7 +133,8 @@ let run file =
|
|||||||
let* owners =
|
let* owners =
|
||||||
map_result (owner ~stdlib ~changes) (List.sort_uniq compare libs)
|
map_result (owner ~stdlib ~changes) (List.sort_uniq compare libs)
|
||||||
in
|
in
|
||||||
let packages = List.sort_uniq compare (List.filter_map Fun.id owners) in
|
let packages = List.sort_uniq compare owners in
|
||||||
|
if packages = [] then msg "no library found in %s" file else
|
||||||
let* infos =
|
let* infos =
|
||||||
map_result
|
map_result
|
||||||
(fun p ->
|
(fun p ->
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ depends: [
|
|||||||
"console-eio"
|
"console-eio"
|
||||||
"digestif"
|
"digestif"
|
||||||
"bos" {build}
|
"bos" {build}
|
||||||
|
"ocamlfind" {build}
|
||||||
"ocaml-lsp-server" {with-dev-setup}
|
"ocaml-lsp-server" {with-dev-setup}
|
||||||
"merlin" {with-dev-setup}
|
"merlin" {with-dev-setup}
|
||||||
"ocamlformat" {with-dev-setup}
|
"ocamlformat" {with-dev-setup}
|
||||||
|
|||||||
Reference in new issue
Block a user