-
Notifications
You must be signed in to change notification settings - Fork 203
Open
Description
The problem:
When running diff-quality from a subfolder of the git repository, it incorrectly reports 0 violations even when the quality tool (e.g., mypy, flake8) finds issues. This happens because git diff reports paths relative to the repo root, whereas the quality tool reports paths relative to the working directory.
The issue becomes especially significant in a monorepo layout, where each subfolder is a separate project with its own pyproject.toml. In such layout, it becomes increasingly inconvenient to run the quality tools from the repo root.
Previous issue #179 touched on the subject specifically for SQLFluff, and ultimately didn't reach a conclusion.
Script to reproduce:
docker run --rm python bash -c '
pip -qq install mypy diff_cover
git init -b main repo && cd repo
mkdir subdir && touch subdir/file.py
git add . && git -c user.email="test" -c user.name="test" commit -m "init"
echo "def f() -> str: return 1" > subdir/file.py
diff-quality --violations=mypy --compare-branch main # Shows violation
cd subdir
diff-quality --violations=mypy --compare-branch main # Shows no violations - bug
'Output:
Initialized empty Git repository in /repo/.git/
[main (root-commit) e38a20b] init
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 subdir/file.py
-------------
Diff Quality
Quality Report: mypy
Diff: main...HEAD, staged and unstaged changes
-------------
subdir/file.py (0.0%):
subdir/file.py:1: error: Incompatible return value type (got "int", expected "str") [return-value]
-------------
Total: 1 line
Violations: 1 line
% Quality: 0%
-------------
-------------
Diff Quality
Quality Report: mypy
Diff: main...HEAD, staged and unstaged changes
-------------
subdir/file.py (100%)
-------------
Total: 1 line
Violations: 0 lines
% Quality: 100%
-------------
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels