Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ocaml-version to a fixed version by default to avoid reproducibility issues and surprising behaviours #2064

Merged
merged 4 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Doc-comments code blocks with a language other than 'ocaml' (set in metadata) are not parsed as OCaml (#2037, @gpetiot)
- More comprehensible error message in case of version mismatch (#2042, @gpetiot)
- The global configuration file (`$XDG_CONFIG_HOME` or `$HOME/.config`) is only applied when no project is detected, `--enable-outside-detected-project` is set, and no applicable `.ocamlformat` file has been found. Global and local configurations are no longer used at the same time. (#2039, @gpetiot)
- Set `ocaml-version` to a fixed version (4.04.0) by default to avoid reproducibility issues and surprising behaviours (#2064, @kit-ty-kate)

### New features

Expand Down
7 changes: 3 additions & 4 deletions lib/Conf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1189,10 +1189,9 @@ module Operational = struct
let ocaml_version =
let docv = "V" in
let doc = "Version of OCaml syntax of the output." in
let default = Ocaml_version.sys_version in
let default_doc = "the version of OCaml used to build OCamlFormat" in
C.any ocaml_version_conv ~names:["ocaml-version"] ~default ~default_doc
~doc ~docv ~kind
let default = Ocaml_version.Releases.v4_04_0 in
C.any ocaml_version_conv ~names:["ocaml-version"] ~default ~doc ~docv
~kind
(fun conf x -> update conf ~f:(fun f -> {f with ocaml_version= x}))
(fun conf -> conf.opr_opts.ocaml_version)

Expand Down
14 changes: 4 additions & 10 deletions lib/Config_option.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,8 @@ module Make (C : CONFIG) = struct
(in_attributes allow_inline kind)
status_doc status

let generated_doc ?default_doc conv ~allow_inline ~doc ~kind ~default
~status =
let default_doc =
match default_doc with
| Some x -> x
| None -> Format.asprintf "%a" (Arg.conv_printer conv) default
in
let generated_doc conv ~allow_inline ~doc ~kind ~default ~status =
let default_doc = Format.asprintf "%a" (Arg.conv_printer conv) default in
let default =
if String.is_empty default_doc then "none" else default_doc
in
Expand Down Expand Up @@ -183,13 +178,12 @@ module Make (C : CONFIG) = struct
store := Pack opt :: !store ;
opt

let any ?default_doc converter ~default ~docv ~names ~doc ~kind
let any converter ~default ~docv ~names ~doc ~kind
?(allow_inline = Poly.(kind = Formatting)) ?(status = `Valid) update
get_value =
let open Cmdliner in
let doc =
generated_doc converter ?default_doc ~allow_inline ~doc ~kind ~default
~status
generated_doc converter ~allow_inline ~doc ~kind ~default ~status
in
let docs = section_name kind status in
let term =
Expand Down
6 changes: 1 addition & 5 deletions lib/Config_option.mli
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ module Make (C : CONFIG) : sig
val flag : default:bool -> bool option_decl

val any :
?default_doc:string
-> 'a Cmdliner.Arg.conv
-> default:'a
-> docv:string
-> 'a option_decl
'a Cmdliner.Arg.conv -> default:'a -> docv:string -> 'a option_decl

val removed_option :
names:string list -> since:Version.t -> msg:string -> unit
Expand Down
4 changes: 2 additions & 2 deletions ocamlformat-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,8 @@ OPTIONS
omitted.

--ocaml-version=V
Version of OCaml syntax of the output. The default value is the
version of OCaml used to build OCamlFormat.
Version of OCaml syntax of the output. The default value is
4.04.0.

--ocp-indent-config
Read .ocp-indent configuration files. base is an alias for
Expand Down
2 changes: 1 addition & 1 deletion ocamlformat-rpc-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NAME
code.

SYNOPSIS
ocamlformat-rpc [OPTION]…
ocamlformat-rpc [OPTION]…

DESCRIPTION
ocamlformat-rpc listens to RPC requests, provided on the standard
Expand Down