Skip to content

Commit

Permalink
Fix mounting of reference clones in system tests
Browse files Browse the repository at this point in the history
caching iterators is evil: we get an empty list as soon as something consumes it

Change-Id: If47ace136a82de6fea7b166aeb7d8ce3f7af9fb2
  • Loading branch information
TimotheusBachinger committed Feb 27, 2025
1 parent 749e58a commit 368f135
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/testlib/common/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import re
import subprocess
import sys
from collections.abc import Callable, Iterator
from collections.abc import Callable
from contextlib import suppress
from functools import cache
from pathlib import Path
Expand Down Expand Up @@ -172,10 +172,11 @@ def git_commit_id(path: Path | str) -> str:


@cache
def git_essential_directories(checkout_dir: Path) -> Iterator[str]:
"""Yields paths to all directories needed to be accessible in order to run git operations
def git_essential_directories(checkout_dir: Path) -> list[str]:
"""Returns paths to all directories needed to be accessible in order to run git operations
Note that if a directory is a subdirectory of checkout_dir it will be skipped"""

essential_dirs = []
# path to the 'real git repository directory', i.e. the common dir when dealing with work trees
common_dir = (
(
Expand All @@ -189,7 +190,7 @@ def git_essential_directories(checkout_dir: Path) -> Iterator[str]:
)

if not common_dir.is_relative_to(checkout_dir):
yield common_dir.as_posix()
essential_dirs.append(common_dir.as_posix())

# In case of reference clones we also need to access them.
# Not sure if 'objects/info/alternates' can contain more than one line and if we really need
Expand All @@ -198,7 +199,9 @@ def git_essential_directories(checkout_dir: Path) -> Iterator[str]:
with (common_dir / "objects/info/alternates").open() as alternates:
for alternate in (Path(line).parent for line in alternates):
if not alternate.is_relative_to(checkout_dir):
yield alternate.as_posix()
essential_dirs.append(alternate.as_posix())

return essential_dirs


@cache
Expand Down

0 comments on commit 368f135

Please sign in to comment.