feat: refresh shared Git config mounts live
- Use profile-scoped canonical Git clone sources with locked refreshes - Mount shared Git configuration read-only and isolate profile content - Add API and desktop/mobile actions for live Git mount refresh Quality gates: frontend build and backend py_compile passed. Skipped: backend pytest/Ruff unavailable; Docker/manual checks not approved.
This commit is contained in:
@@ -80,12 +80,7 @@ class TestCloneGitRepo:
|
||||
branch = None
|
||||
clone_parent = str(tmp_path)
|
||||
url_hash = hashlib.md5(f"{remote_url}:default".encode()).hexdigest()[:12]
|
||||
repo_path = (
|
||||
tmp_path
|
||||
/ "git-mounts"
|
||||
/ f"dotfiles-{url_hash}"
|
||||
/ "repo-clone"
|
||||
)
|
||||
repo_path = tmp_path / "git-mounts" / f"dotfiles-{url_hash}" / "repo-clone"
|
||||
(repo_path / ".git").mkdir(parents=True)
|
||||
|
||||
clone = MagicMock(side_effect=AssertionError("existing clone must be reused"))
|
||||
@@ -99,7 +94,9 @@ class TestCloneGitRepo:
|
||||
clone.assert_not_called()
|
||||
pull.assert_called_once_with(str(repo_path), remote_url)
|
||||
|
||||
def test_replaces_incomplete_clone_before_retry(self, monkeypatch, tmp_path) -> None:
|
||||
def test_replaces_incomplete_clone_before_retry(
|
||||
self, monkeypatch, tmp_path
|
||||
) -> None:
|
||||
from src.services.tool import instance_service
|
||||
|
||||
remote_url = "https://gitlab.com/example/dotfiles"
|
||||
@@ -128,10 +125,10 @@ class TestCloneGitRepo:
|
||||
class TestStackProfileMountsWithGitMounts:
|
||||
"""Tests for _stack_profile_mounts_with_git_mounts."""
|
||||
|
||||
def test_exact_overlap_merges_profile_files_into_git_source(self, tmp_path) -> None:
|
||||
"""When a profile mount targets the same directory as a git mount,
|
||||
the profile files should be copied into the git-mount source so the
|
||||
container sees both sets of files through one bind mount."""
|
||||
def test_exact_overlap_keeps_profile_files_out_of_git_source(
|
||||
self, tmp_path
|
||||
) -> None:
|
||||
"""Overlaps must not dirty the shared Git checkout."""
|
||||
git_source = tmp_path / "git" / "repo-clone"
|
||||
git_source.mkdir(parents=True)
|
||||
(git_source / "existing.txt").write_text("from git")
|
||||
@@ -156,13 +153,12 @@ class TestStackProfileMountsWithGitMounts:
|
||||
profile_mounts, git_mount_volumes
|
||||
)
|
||||
|
||||
assert result == []
|
||||
assert result == profile_mounts
|
||||
assert (git_source / "existing.txt").read_text() == "from git"
|
||||
assert (git_source / "settings.json").read_text() == "{}"
|
||||
assert not (git_source / "settings.json").exists()
|
||||
|
||||
def test_descendant_overlap_copies_into_subdirectory(self, tmp_path) -> None:
|
||||
"""Profile mounts targeting a child directory are copied into the
|
||||
corresponding subdirectory of the git-mount source."""
|
||||
def test_descendant_overlap_keeps_sources_isolated(self, tmp_path) -> None:
|
||||
"""A child profile mount must not mutate the shared Git checkout."""
|
||||
git_source = tmp_path / "git"
|
||||
git_source.mkdir()
|
||||
(git_source / "README").write_text("repo")
|
||||
@@ -186,8 +182,8 @@ class TestStackProfileMountsWithGitMounts:
|
||||
profile_mounts, git_mount_volumes
|
||||
)
|
||||
|
||||
assert result == []
|
||||
assert (git_source / "agent" / "settings.json").read_text() == "x"
|
||||
assert result == profile_mounts
|
||||
assert not (git_source / "agent").exists()
|
||||
assert (git_source / "README").read_text() == "repo"
|
||||
|
||||
def test_non_overlapping_mounts_left_untouched(self, tmp_path) -> None:
|
||||
@@ -247,9 +243,8 @@ class TestStackProfileMountsWithGitMounts:
|
||||
|
||||
assert result == profile_mounts
|
||||
|
||||
def test_profile_source_file_copied_into_git_source(self, tmp_path) -> None:
|
||||
"""A profile mount that supplies a single file is copied into the
|
||||
git-mount source directory."""
|
||||
def test_profile_source_file_does_not_mutate_git_source(self, tmp_path) -> None:
|
||||
"""A profile file must not be copied into a shared Git checkout."""
|
||||
git_source = tmp_path / "git"
|
||||
git_source.mkdir()
|
||||
|
||||
@@ -271,8 +266,8 @@ class TestStackProfileMountsWithGitMounts:
|
||||
profile_mounts, git_mount_volumes
|
||||
)
|
||||
|
||||
assert result == []
|
||||
assert (git_source / "settings.json").read_text() == "{}"
|
||||
assert result == profile_mounts
|
||||
assert not (git_source / "settings.json").exists()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
|
||||
Reference in New Issue
Block a user