--diff <ref> — PR-scoped findings¶
On a codebase with non-trivial existing debt, a full doctor run
surfaces dozens of warnings that the current PR didn't introduce. Most of
them are legitimate but they drown the signal. --diff <ref> narrows the
report to files touched since a git reference.
Usage¶
What it does, in order:
- Asks git for every file that differs from
<ref>: committed changes (git diff --name-only <ref>...HEAD), unstaged modifications (git diff --name-only), and new files (git ls-files --others --exclude-standard). - Filters findings: keep a finding if its
locationreferences one of those files. - Findings with no resolvable file path (e.g.
views.unguardedonusers:login) are kept — we'd rather over-report than silently drop them.
CI recipe — PR-only gate¶
# .github/workflows/doctor.yml — fails the PR on new findings only
- name: django-doctor (PR-scoped)
run: |
./manage.py doctor \
--diff origin/${{ github.base_ref }} \
--ci \
--html doctor-report.html
Combined with --ci, the exit code reflects the filtered findings, so
existing debt doesn't block merges — only regressions do.
Combining with --section¶
--diff filters after checks run, so it composes with --section:
is the quickest way to audit a PR that touches templates and views.