Skip to content
Draft
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 bin/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ module Builder = struct
let default_root_is_cwd t = t.default_root_is_cwd
let set_default_root_is_cwd t x = { t with default_root_is_cwd = x }
let disable_log_file t = { t with trace_file = None }
let promote t = t.promote
let set_promote t v = { t with promote = Some v }
let default_target t = t.default_target

Expand Down
1 change: 1 addition & 0 deletions bin/common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module Builder : sig
val default_root_is_cwd : t -> bool
val set_default_root_is_cwd : t -> bool -> t
val disable_log_file : t -> t
val promote : t -> Dune_engine.Clflags.Promote.t option
val set_promote : t -> Dune_engine.Clflags.Promote.t -> t
val default_target : t -> Arg.Dep.t
val term : t Cmdliner.Term.t
Expand Down
10 changes: 10 additions & 0 deletions bin/fmt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ let command =
them. This takes precedence over auto-promote as that flag is assumed \
for this command."))
in
let () =
match Common.Builder.promote builder with
| Some Never ->
User_error.raise
[ Pp.text
"The --disable-promotion flag is not applicable to `dune fmt`. Use \
--preview to display formatting changes without applying them."
]
| _ -> ()
in
let builder =
Common.Builder.set_promote builder (if preview then Never else Automatically)
in
Expand Down
9 changes: 9 additions & 0 deletions bin/promotion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ module Apply = struct
(* CR-someday Alizter: document this option *)
Arg.(value & pos_all Arg.path [] & info [] ~docv:"FILE" ~doc:None)
in
let () =
match Common.Builder.promote builder with
| Some Dune_engine.Clflags.Promote.Never ->
User_error.raise
[ Pp.text
"The --disable-promotion flag is not applicable to `dune promotion apply`."
]
| _ -> ()
in
run ~builder ~exact ~files
;;

Expand Down
12 changes: 12 additions & 0 deletions test/blackbox-tests/test-cases/promote/disable-promotion.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ now we build without the option and see that they are present:
foo.exe exists
$ test -f foo.install && echo "foo.install exists"
foo.install exists

dune fmt rejects --disable-promotion:
$ dune fmt --disable-promotion
Error: The --disable-promotion flag is not applicable to `dune fmt`. Use
--preview to display formatting changes without applying them.
[1]

dune promotion apply rejects --disable-promotion:
$ dune promotion apply --disable-promotion
Error: The --disable-promotion flag is not applicable to `dune promotion
apply`.
[1]
Loading