From 97b133d4112456cbef6cfcf34cd29f568dd04683 Mon Sep 17 00:00:00 2001 From: Udita <83602637+ubatmongo@users.noreply.github.com> Date: Wed, 29 Oct 2025 15:18:07 -0400 Subject: [PATCH] SERVER-105911: interface for single files bazel format (#43059) GitOrigin-RevId: 1ffffc6f55bbf0a1006f66cd7f3da87bb05cffe3 --- bazel/format/rules_lint_format_wrapper.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bazel/format/rules_lint_format_wrapper.py b/bazel/format/rules_lint_format_wrapper.py index 2a81fca0e98..cd53ca49f9b 100644 --- a/bazel/format/rules_lint_format_wrapper.py +++ b/bazel/format/rules_lint_format_wrapper.py @@ -181,6 +181,11 @@ def main() -> int: help="The branch to use as the fork point for changed files", default="origin/master", ) + parser.add_argument( + "--file", + help="The file to format", + type=pathlib.Path, + ) args = parser.parse_args() prettier_path: pathlib.Path = args.prettier.resolve() @@ -188,7 +193,9 @@ def main() -> int: os.chdir(default_dir) files_to_format = "all" - if not args.all: + if args.file: + files_to_format = [str(args.file)] + elif not args.all: max_distance = 100 distance = _git_distance([f"{args.origin_branch}..HEAD"]) if distance > max_distance: