diff --git a/Makefile b/Makefile index 72d7c9f6251..d00d8b9f166 100644 --- a/Makefile +++ b/Makefile @@ -174,14 +174,11 @@ lint-ruff: $(LINT_DEP_INSTALL) # https://github.com/astral-sh/ruff/discussions/4049 lint-format-changed: install-dev @base_ref=$$($(RESOLVE_BASE)) && \ - diff=$$(git diff "$$base_ref" --unified=0 --no-color --no-renames --diff-filter=d -- '*.py') && \ + diff=$$(git diff "$$base_ref" --unified=0 --no-color --diff-filter=d -- '*.py') && \ printf '%s\n' "$$diff" | \ - perl -ne '\ - if (/^diff --git a\/(.*) b\//) { $$file = $$1; } \ - if (/^@@ .* \+(\d+)(?:,(\d+))? @@/) { \ - $$start = $$1; $$count = $$2 || 1; $$end = $$start + $$count - 1; \ - print "$$file:$$start:1-$$end:999\n"; \ - }' | \ + perl -ne 'if (/^\+\+\+ b\/(.*)/) { $$file = $$1; }' \ + -e 'if (/^@@ .* \+(\d+)(?:,(\d+))? @@/) { $$start = $$1; $$count = $$2 || 1; $$end = $$start + $$count - 1;' \ + -e 'print "$$file:$$start:1-$$end:999\n"; }' | \ while read range; do \ file="$${range%%:*}"; \ lines="$${range#*:}"; \ diff --git a/tests/unit/test_default_branch.py b/tests/unit/test_default_branch.py index b780e279482..81053b13e8c 100644 --- a/tests/unit/test_default_branch.py +++ b/tests/unit/test_default_branch.py @@ -130,13 +130,15 @@ def test_changed_file_targets_skip_paths_gone_from_the_working_tree( base: Final = _git(repo, "rev-parse", "HEAD") (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", "litellm/example.py") _git(repo, "mv", "litellm/renamed_away.py", "litellm/renamed_to.py") (repo / "litellm" / "renamed_to.py").write_text("a = 1\nb = 2\nc = 3\nd = 5\n") + _commit(repo, "add two modules and rename one") + _git(repo, "rm", "-q", "litellm/dropped.py", "litellm/example.py") checked: Final = _make(repo, target, "-o", "install-dev", f"BASE_REF={base}", "UV_RUN=echo") assert checked.returncode == 0, checked.stderr assert "litellm/kept.py" in checked.stdout + assert "litellm/renamed_to.py" in checked.stdout + assert "--range 0:" not in checked.stdout gone: Final = ("litellm/dropped.py", "litellm/example.py", "litellm/renamed_away.py") assert [path for path in gone if path in checked.stdout] == []