Skip to content

Conversation

@MixiMaxiMouse
Copy link

This PR introduces a new subcommand dune promotion show that lets users
view the corrected contents of files ready for promotion without modifying
them.

It also adds a blackbox test verifying key behaviors:

  • Displays corrected contents for failed diff rules
  • Handles multiple and missing files gracefully
  • Ensures source files remain unchanged
  • Produces appropriate warnings for non-promotable files

Fixes #3883

@rgrinberg
Copy link
Member

@ElectreAAS do you want to try reviewing this one?

Copy link
Collaborator

@ElectreAAS ElectreAAS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!
My only question was: didn't we already have this? isn't this supposed to be what dune promotion diff does?
well apparently not
thanks :)

@Alizter Alizter requested a review from rgrinberg November 12, 2025 12:22
@rgrinberg
Copy link
Member

I'll let @ElectreAAS review or merge this one.

@rgrinberg rgrinberg removed their request for review November 12, 2025 13:45
@ElectreAAS ElectreAAS force-pushed the feat/add-promotion-show-command branch from 218c6ea to 17be9be Compare November 17, 2025 18:28
Maxence Maury added 3 commits November 17, 2025 19:40
Implements a new command to display corrected file contents
without applying the promotion. Users can now view what the
promoted file would look like before deciding to promote.

- Added 'show' subcommand to bin/promotion.ml
- Exposed correction_file function in src/promote/diff_promotion.mli

Tests still need to be added.

Fixes ocaml#3883

Signed-off-by: Maxence Maury <[email protected]>
Add a new blackbox test to verify the behavior of the
'dune promotion show' command. The test covers common
use cases and edge cases to make sure the command works
as intended and doesn’t modify source files.

It checks that:
- corrected files are displayed after failed diffs
- multiple files and missing promotions are handled properly
- warnings appear for non-promotable or missing files
- source files stay untouched after showing their content

Signed-off-by: Maxence Maury <[email protected]>
@ElectreAAS
Copy link
Collaborator

I just rebased on main and apparently fucked up something with Github, don't worry I'm on it ;)

let show_corrected_contents files_to_promote =
let open Fiber.O in
let files = Diff_promotion.load_db () |> Diff_promotion.filter_db files_to_promote in
Fiber.parallel_iter files ~f:(fun file ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to above fuck-up: this parallel_iter means that files will be iterated over in a non-deterministic order. I don't think performance is a concern here, we can just List.iter.
If you want parallelism, do what Diff_promotion.display does, and sort after creating what you want to print, then print in an orderly manner

Signed-off-by: Ambre Austen Suhamy <[email protected]>
@ElectreAAS ElectreAAS force-pushed the feat/add-promotion-show-command branch from 17be9be to a9b7a5c Compare November 17, 2025 18:53
@ElectreAAS
Copy link
Collaborator

Also as this is user-facing, a changes entry would be nice

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.

Add dune command to get the contents of a "corrected" file

4 participants