US01-01: Inventory and Characterize Donor Code

This commit is contained in:
2026-07-13 16:42:51 +02:00
parent 43ffde71da
commit a0e1752ff1
11 changed files with 646 additions and 13 deletions

View File

@@ -10,6 +10,7 @@ workflow:
require_ci: false
required_tests:
- work_item/scripts/python -m unittest discover -s work_item/tests -v
- work_item/scripts/python -m unittest discover -s tests/characterization -v
safety:
max_file_bytes: 5000000

View File

@@ -317,7 +317,13 @@ class GitRepo:
return branch
def changed_paths(self) -> list[Path]:
output = self.git("status", "--porcelain=v1", "--untracked-files=all", "-z")
# Porcelain's leading status column is significant (an unstaged modification
# starts with a space). ``git()`` strips surrounding whitespace for ordinary
# scalar commands, so read this machine format directly and preserve it.
output = self.runner.run(
("git", "status", "--porcelain=v1", "--untracked-files=all", "-z"),
cwd=self.root,
).stdout
if not output:
return []
entries = output.split("\0")

View File

@@ -354,6 +354,12 @@ class GitSafetyTests(RepositoryFixture):
run("git", "mv", "README.md", "RENAMED.md", cwd=self.repo)
self.assertEqual(git.changed_paths(), [Path("RENAMED.md")])
def test_changed_paths_preserves_modified_and_untracked_filenames(self) -> None:
git = GitRepo(self.repo, self.config, Runner())
(self.repo / "README.md").write_text("changed\n", encoding="utf-8")
(self.repo / "Another file.md").write_text("new\n", encoding="utf-8")
self.assertEqual(set(git.changed_paths()), {Path("README.md"), Path("Another file.md")})
def test_diff_check_rejects_whitespace_errors(self) -> None:
git = GitRepo(self.repo, self.config, Runner())
(self.repo / "README.md").write_text("seed\ntrailing whitespace \n", encoding="utf-8")