Skip to content

feat: Print formatted file names in mix format --verbose#15119

Merged
josevalim merged 2 commits intoelixir-lang:mainfrom
georgeguimaraes:mix-format-verbose
Feb 28, 2026
Merged

feat: Print formatted file names in mix format --verbose#15119
josevalim merged 2 commits intoelixir-lang:mainfrom
georgeguimaraes:mix-format-verbose

Conversation

@georgeguimaraes
Copy link
Member

@georgeguimaraes georgeguimaraes commented Feb 27, 2026

mix format is completely silent on success right now, so you have no idea which files it actually changed. This is also useful for LLMs reading the output of mix format to know what was touched. This adds a --verbose flag that prints files as they're formatted, using the same * verb path convention as the rest of mix:

$ mix format --verbose
* formatting lib/my_app/router.ex
* formatting lib/my_app/server.ex

Already-formatted files produce no output. Default behavior (silent) is unchanged.

Copilot AI review requested due to automatic review settings February 27, 2026 14:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds informative output to mix format that displays which files were actually formatted, addressing the current silent behavior that provides no feedback about what changed. The feature follows Mix's established convention of using * verb path format for action messages.

Changes:

  • Adds formatted file output using * formatting path format with ANSI coloring
  • Introduces --quiet flag to restore previous silent behavior
  • Refactors internal tracking to distinguish between formatted and unchanged files

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/mix/lib/mix/tasks/format.ex Core implementation: adds --quiet flag, refactors write_or_print to return formatting status, updates collect_status and check! to track and print formatted files
lib/mix/test/mix/tasks/format_test.exs Adds three tests verifying formatted file output, --quiet flag suppression, and --dry-run suppression

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

refute_received {:mix_shell, :info, ["* formatting a.ex"]}
end)
end

Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

Missing test coverage for --check-formatted flag interaction with the new formatting output feature. While the implementation correctly doesn't print formatting messages when --check-formatted is used (since it doesn't actually format files), this behavior should be explicitly tested to prevent regressions. Consider adding a test similar to the --dry-run and --quiet tests that verifies no formatting messages are printed when using --check-formatted.

Suggested change
test "does not print formatted file names with --check-formatted", context do
in_tmp(context.test, fn ->
File.write!("a.ex", """
foo bar
""")
Mix.Tasks.Format.run(["a.ex, "--check-formatted"])
refute_received {:mix_shell, :info, ["* formatting a.ex"]}
end)
end

Copilot uses AI. Check for mistakes.
@josevalim
Copy link
Member

This behaviour needs to be opt-in. We can have a --verbose mode.

@georgeguimaraes
Copy link
Member Author

This behaviour needs to be opt-in. We can have a --verbose mode.

:( ok

@georgeguimaraes
Copy link
Member Author

@josevalim updated

@georgeguimaraes georgeguimaraes changed the title feat: Print formatted file names in mix format feat: Print formatted file names in mix format --verbose Feb 27, 2026
@josevalim josevalim merged commit 8cda8e1 into elixir-lang:main Feb 28, 2026
15 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@georgeguimaraes
Copy link
Member Author

😘

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants