mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-05 07:37:50 +00:00
fix(make): skip deleted files in the diff-scoped format check
This commit is contained in:
parent
dc0237ccd7
commit
00934e20fd
2 changed files with 15 additions and 2 deletions
5
Makefile
5
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 \
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue