mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-08-06 10:25:45 +00:00
chore: remove now-unused REPO_ROOT from require_math_evidence
Sourcery-bot housekeeping note on PR #11: REPO_ROOT was only mentioned
in comments after the cwd-resolution fix in 61005655 and was no longer
used by any logic in this module (other math-first scripts have their
own REPO_ROOT constants). Removed it. Folded the rationale that
previously lived in the comment above the constant into the
_git_toplevel docstring so future readers still see why we don't
hardcode the cwd.
Co-Authored-By: Allaun Silverfox <bigdataiscoming+9i37y6j2@protonmail.com>
This commit is contained in:
parent
6100565578
commit
8ffc4e2fda
1 changed files with 4 additions and 11 deletions
|
|
@ -40,23 +40,16 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Only used for logging/help -- *not* as the subprocess ``cwd`` for the git
|
|
||||||
# calls below. Hardcoding the subprocess cwd to this path caused the
|
|
||||||
# regression test in ``test_require_math_evidence.py`` to pass vacuously
|
|
||||||
# because the test stages files in a *temp* repo and expects ``git diff
|
|
||||||
# --cached`` to query that temp repo, not the real one. Pre-commit and CI
|
|
||||||
# both happen to invoke the script from inside the repo root, so letting
|
|
||||||
# the git subprocess inherit cwd is correct in every real-world case.
|
|
||||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
|
||||||
|
|
||||||
|
|
||||||
def _git_toplevel(cwd: Path | None = None) -> Path:
|
def _git_toplevel(cwd: Path | None = None) -> Path:
|
||||||
"""Return the absolute path of the git working tree containing ``cwd``.
|
"""Return the absolute path of the git working tree containing ``cwd``.
|
||||||
|
|
||||||
Defaults to the current working directory. The script never assumes the
|
Defaults to the current working directory. The script never assumes the
|
||||||
git repo lives at ``REPO_ROOT`` because that would be wrong when the
|
git repo lives at a hardcoded path because that would be wrong when the
|
||||||
script is run from a different working tree -- notably, the temp repo
|
script is run from a different working tree -- notably, the temp repo
|
||||||
set up by ``test_require_math_evidence.py``.
|
set up by ``test_require_math_evidence.py``. Pre-commit and CI both
|
||||||
|
happen to invoke the script from inside the repo root, so letting the
|
||||||
|
git subprocess inherit cwd is correct in every real-world case.
|
||||||
"""
|
"""
|
||||||
cmd = ["git", "rev-parse", "--show-toplevel"]
|
cmd = ["git", "rev-parse", "--show-toplevel"]
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue