From 00934e20fd2ea177ff629b2a4e6c9c9d8e6ce6e1 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Sat, 24 Oct 2026 09:32:08 -0700 Subject: [PATCH] fix(make): skip deleted files in the diff-scoped format check --- Makefile | 5 +++-- tests/unit/test_default_branch.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dec853515b9..4234d299025 100644 --- a/Makefile +++ b/Makefile @@ -147,14 +147,15 @@ lint-install: $(UV_RUN) python scripts/prisma_generate_if_needed.py # Diff-scoped format check, mirroring test-linting.yml's "Check ruff format" step: -# only the litellm Python files changed vs the base are checked, so a pre-existing +# only the litellm Python files changed vs the base and still on disk are checked, so a pre-existing # format issue elsewhere doesn't block an unrelated commit. Git pathspecs match # recursively, so 'litellm/*.py' covers top-level files and nested modules alike, # the same set CI's ':(glob)litellm/**/*.py' selects. lint-format-check-changed: $(LINT_DEP_INSTALL) $(LINT_DEP_BASE) @base_ref=$$($(RESOLVE_BASE)) && \ changed=$$(git diff --name-only --diff-filter=ACMR "$$base_ref...HEAD" -- 'litellm/*.py') && \ - files=$$(printf '%s\n' "$$changed" | grep -v '^litellm/enterprise/' || true) || exit $$?; \ + files=$$(printf '%s\n' "$$changed" | grep -v '^litellm/enterprise/' | \ + while IFS= read -r f; do if [ -f "$$f" ]; then printf '%s\n' "$$f"; fi; done) || exit $$?; \ if [ -z "$$files" ]; then \ echo "No changed litellm Python files to format-check."; \ else \ diff --git a/tests/unit/test_default_branch.py b/tests/unit/test_default_branch.py index bb04ea2a0fa..9759a263cb7 100644 --- a/tests/unit/test_default_branch.py +++ b/tests/unit/test_default_branch.py @@ -119,6 +119,18 @@ def test_explicit_base_works_without_remote_access( assert "No changed litellm Python files" in checked.stdout +def test_format_check_skips_branch_files_deleted_from_the_working_tree(remote_and_clone: tuple[Path, Path]) -> None: + _, repo = remote_and_clone + (repo / "litellm" / "kept.py").write_text("value = 2\n") + (repo / "litellm" / "dropped.py").write_text("value = 3\n") + _commit(repo, "add two modules") + _git(repo, "rm", "-q", "litellm/dropped.py") + checked: Final = _make(repo, "lint-format-check-changed", "BASE_REF=origin/release_branch", "UV_RUN=echo") + assert checked.returncode == 0, checked.stderr + assert "litellm/kept.py" in checked.stdout + assert "litellm/dropped.py" not in checked.stdout + + def _freshness(repo: Path, *args: str) -> subprocess.CompletedProcess[str]: return subprocess.run( [