Skip to content

Commit dd2782f

Browse files
committed
Add flag to validate change log
1 parent 84429a4 commit dd2782f

File tree

6 files changed

+25
-6
lines changed

6 files changed

+25
-6
lines changed

CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
### Added
44

5+
- Add flag to `dune-release check` that attempts to discover and parse the
6+
change log. (#458, @gridbugs)
7+
58
### Changed
69

710
### Deprecated

bin/check.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let clone_and_checkout_tag repo ~dir ~tag =
1515
let check (`Package_names pkg_names) (`Package_version version) (`Dist_tag tag)
1616
(`Keep_v keep_v) (`Build_dir build_dir) (`Skip_lint skip_lint)
1717
(`Skip_build skip_build) (`Skip_tests skip_tests)
18-
(`Working_tree on_working_tree) =
18+
(`Check_change_log check_change_log) (`Working_tree on_working_tree) =
1919
(let dir, clean_up =
2020
if on_working_tree then (OS.Dir.current (), fun _ -> ())
2121
else
@@ -46,7 +46,7 @@ let check (`Package_names pkg_names) (`Package_version version) (`Dist_tag tag)
4646
Config.keep_v ~keep_v >>= fun keep_v ->
4747
let check_result =
4848
Check.check_project ~pkg_names ?tag ?version ~keep_v ?build_dir ~skip_lint
49-
~skip_build ~skip_tests ~dir ()
49+
~skip_build ~skip_tests ~check_change_log ~dir ()
5050
in
5151
let () = clean_up dir in
5252
check_result)
@@ -80,7 +80,7 @@ let term =
8080
Term.(
8181
const check $ Cli.pkg_names $ Cli.pkg_version $ Cli.dist_tag $ Cli.keep_v
8282
$ Cli.build_dir $ Cli.skip_lint $ Cli.skip_build $ Cli.skip_tests
83-
$ working_tree)
83+
$ Cli.check_change_log $ working_tree)
8484

8585
let info = Cmd.info "check" ~doc ~man
8686
let cmd = Cmd.v info term

bin/cli.ml

+6
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ let skip_tests =
256256
in
257257
named (fun x -> `Skip_tests x) Arg.(value & flag & info [ "skip-tests" ] ~doc)
258258

259+
let check_change_log =
260+
let doc = "Check that the change log can be parsed" in
261+
named
262+
(fun x -> `Check_change_log x)
263+
Arg.(value & flag & info [ "check-change-log" ] ~doc)
264+
259265
let keep_build_dir =
260266
let doc =
261267
"Keep the distribution build directory after successful archival."

bin/cli.mli

+3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ val skip_build : [> `Skip_build of bool ] Term.t
105105
val skip_tests : [> `Skip_tests of bool ] Term.t
106106
(** a [--skip-test] option to skip checking the tests *)
107107

108+
val check_change_log : [> `Check_change_log of bool ] Term.t
109+
(** a [--check-change-log] option to force validation of change-log *)
110+
108111
val keep_build_dir : [> `Keep_build_dir of bool ] Term.t
109112
(** a [--keep-build-dir] flag to keep the build directory used for the archive
110113
check. *)

lib/check.ml

+9-3
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ let dune_project_check dir =
8888
in
8989
R.join @@ Sos.with_dir ~dry_run:false dir check ()
9090

91-
let check_project ~pkg_names ~skip_lint ~skip_build ~skip_tests ?tag ?version
92-
~keep_v ?build_dir ~dir () =
91+
let change_log_check pkg =
92+
Pkg.change_log pkg >>= Text.change_log_file_last_entry >>| Fun.const 0
93+
94+
let check_project ~pkg_names ~skip_lint ~skip_build ~skip_tests
95+
~check_change_log ?tag ?version ~keep_v ?build_dir ~dir () =
9396
match pkg_creation_check ?tag ?version ~keep_v ?build_dir dir with
9497
| Error (`Msg err) ->
9598
App_log.report_status `Fail (fun m -> m "%s" err);
@@ -102,5 +105,8 @@ let check_project ~pkg_names ~skip_lint ~skip_build ~skip_tests ?tag ?version
102105
>>= fun dune_exit ->
103106
(if skip_lint then Ok 0
104107
else Lint.lint_packages ~dry_run:false ~dir ~todo:Lint.all pkg pkg_names)
105-
>>| fun lint_exit ->
108+
>>= fun lint_exit ->
109+
(if check_change_log then change_log_check pkg else Ok 0)
110+
>>| fun change_log_exit ->
106111
opam_file_exit + dune_project_exit + dune_exit + lint_exit
112+
+ change_log_exit

lib/check.mli

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ val check_project :
1616
skip_lint:bool ->
1717
skip_build:bool ->
1818
skip_tests:bool ->
19+
check_change_log:bool ->
1920
?tag:Vcs.Tag.t ->
2021
?version:Version.t ->
2122
keep_v:bool ->

0 commit comments

Comments
 (0)