mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-07-31 03:05:21 +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 1bc4d9bf 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
1bc4d9bf7d
commit
06ee924fd4
1 changed files with 4 additions and 11 deletions
|
|
@ -40,23 +40,16 @@ import subprocess
|
|||
import sys
|
||||
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:
|
||||
"""Return the absolute path of the git working tree containing ``cwd``.
|
||||
|
||||
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
|
||||
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"]
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue