Skip to content

Reject --disable-promotion in dune fmt and dune promotion apply#14379

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/plan-example-implementation
Draft

Reject --disable-promotion in dune fmt and dune promotion apply#14379
Copilot wants to merge 1 commit into
mainfrom
copilot/plan-example-implementation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

dune fmt silently ignored --disable-promotion (overriding it internally with Automatically), and dune promotion apply accepted it without complaint — both are nonsensical combinations since these commands exist specifically to perform promotion.

Changes

  • bin/common.ml / bin/common.mli: Expose a promote accessor on Common.Builder so callers can inspect the parsed promotion flag before it is overridden.
  • bin/fmt.ml: Raise a User_error if --disable-promotion is passed, directing users to --preview instead.
  • bin/promotion.ml: Raise a User_error if --disable-promotion is passed to dune promotion apply.
  • test/…/promote/disable-promotion.t/run.t: Add cram test cases covering both rejection paths.
$ 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 --disable-promotion
Error: The --disable-promotion flag is not applicable to `dune promotion
apply`.
[1]

Note: the check also fires when --disable-promotion's backing env var DUNE_DISABLE_PROMOTION is set, since both map to the same Promote.Never value.

@Alizter
Copy link
Copy Markdown
Collaborator

Alizter commented Apr 30, 2026

@copilot Which issue does this fix? Please update the PR description.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 30, 2026

@copilot Which issue does this fix? Please update the PR description.

This fixes #5946.

Copilot AI requested a review from Alizter April 30, 2026 01:54
@Leonidas-from-XIV
Copy link
Copy Markdown
Collaborator

Seems like a sensible fix to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dune fmt ignores --disable-promotion flag

3 participants