v2.18.3 (#861)
Co-authored-by: Clément Drouin <clement.drouin@mistral.ai> Co-authored-by: Laure Hugo <201583486+laure0303@users.noreply.github.com> Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@users.noreply.github.com> Co-authored-by: Peter Evers <peter.evers@mistral.ai> Co-authored-by: Jules YZERD <newtonlormont@gmail.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
d50704e694
commit
4e495f658d
130 changed files with 1042 additions and 552 deletions
|
|
@ -665,14 +665,17 @@ async def test_apply_patch_end_to_end_routes_default_writes_to_project_layer(
|
|||
reason="update runtime defaults",
|
||||
)
|
||||
|
||||
failure = assert_single_failure(result, NotImplementedError)
|
||||
assert str(failure) == "ProjectConfigLayer patch persistence is not implemented yet"
|
||||
assert result == []
|
||||
with project_config_path.open("rb") as file:
|
||||
assert tomllib.load(file) == {"default_agent": "plan"}
|
||||
assert tomllib.load(file) == {
|
||||
"default_agent": "auto-approve",
|
||||
"active_model": "persisted-in-project-file",
|
||||
}
|
||||
with user_config_path.open("rb") as file:
|
||||
assert tomllib.load(file) == {"default_agent": "accept-edits"}
|
||||
# active_model stays env-model: the environment layer outranks the project file.
|
||||
assert orch.config.active_model == "env-model"
|
||||
assert orch.config.default_agent == "plan"
|
||||
assert orch.config.default_agent == "auto-approve"
|
||||
assert orch.config.enabled_tools == ["read"]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import tomllib
|
||||
|
||||
import pytest
|
||||
|
||||
from vibe.core.config.fingerprint import create_file_fingerprint
|
||||
from vibe.core.config.layer import UntrustedLayerError
|
||||
from vibe.core.config.layers.project import ProjectConfigLayer
|
||||
from vibe.core.config.patch import AddOperationPatch, ConfigPatch, ReplaceOperationPatch
|
||||
from vibe.core.config.types import MISSING_BACKING_STORE_DATA_FINGERPRINT
|
||||
from vibe.core.paths._vibe_home import GlobalPath
|
||||
from vibe.core.trusted_folders import trusted_folders_manager
|
||||
|
|
@ -300,3 +303,53 @@ async def test_walk_stops_at_vibe_home_parent(
|
|||
layer = ProjectConfigLayer(path=subdir)
|
||||
data = await layer.load()
|
||||
assert data.model_extra == {}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_apply_persists_to_discovered_file(tmp_working_directory: Path) -> None:
|
||||
trusted_folders_manager.add_trusted(tmp_working_directory)
|
||||
config_path = tmp_working_directory / ".vibe" / "config.toml"
|
||||
config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
config_path.write_text('active_model = "old"\n')
|
||||
|
||||
layer = ProjectConfigLayer(path=tmp_working_directory)
|
||||
await layer.load()
|
||||
fingerprint = layer.fingerprint
|
||||
assert isinstance(fingerprint, str)
|
||||
|
||||
await layer.apply(
|
||||
ConfigPatch(
|
||||
ReplaceOperationPatch(path="/active_model", value="new"),
|
||||
AddOperationPatch(path="/default_agent", value="plan"),
|
||||
fingerprint=fingerprint,
|
||||
)
|
||||
)
|
||||
|
||||
with config_path.open("rb") as file:
|
||||
assert tomllib.load(file) == {"active_model": "new", "default_agent": "plan"}
|
||||
assert layer.fingerprint == create_file_fingerprint(file)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_apply_creates_file_when_none_discovered(
|
||||
tmp_working_directory: Path,
|
||||
) -> None:
|
||||
# No .vibe/config.toml exists; the layer is still trusted (nothing to distrust).
|
||||
layer = ProjectConfigLayer(path=tmp_working_directory)
|
||||
await layer.load()
|
||||
assert layer.fingerprint == MISSING_BACKING_STORE_DATA_FINGERPRINT
|
||||
|
||||
await layer.apply(
|
||||
ConfigPatch(
|
||||
AddOperationPatch(path="/active_model", value="created"),
|
||||
fingerprint=MISSING_BACKING_STORE_DATA_FINGERPRINT,
|
||||
)
|
||||
)
|
||||
|
||||
created_path = tmp_working_directory / ".vibe" / "config.toml"
|
||||
with created_path.open("rb") as file:
|
||||
assert tomllib.load(file) == {"active_model": "created"}
|
||||
assert layer.fingerprint == create_file_fingerprint(file)
|
||||
|
||||
assert layer.is_file_discovered
|
||||
assert layer.config_file_path == created_path
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
from git import Repo
|
||||
import pytest
|
||||
|
||||
from vibe.core.teleport.errors import (
|
||||
|
|
@ -37,10 +38,21 @@ def make_mock_repo(
|
|||
mock.git.branch.return_value = ""
|
||||
mock.git.rev_list.return_value = "0"
|
||||
mock.git.rev_parse.return_value = "abc123"
|
||||
mock.index.path = str(Path("/tmp/mock-index"))
|
||||
mock.remote.return_value = make_mock_remote(urls[0] if urls else "")
|
||||
return mock
|
||||
|
||||
|
||||
def make_real_repo(workdir: Path) -> Repo:
|
||||
repo = Repo.init(workdir, initial_branch="main")
|
||||
repo.config_writer().set_value("user", "name", "Tester").release()
|
||||
repo.config_writer().set_value("user", "email", "t@example.com").release()
|
||||
(workdir / "tracked.txt").write_text("base\n")
|
||||
repo.index.add(["tracked.txt"])
|
||||
repo.index.commit("initial")
|
||||
return repo
|
||||
|
||||
|
||||
class TestGitRepositoryParseGithubUrl:
|
||||
def test_parse_ssh_url(self) -> None:
|
||||
result = GitRepository._parse_github_url("git@github.com:owner/repo.git")
|
||||
|
|
@ -192,6 +204,22 @@ class TestGitRepositoryGetInfo:
|
|||
assert info.branch is None
|
||||
|
||||
|
||||
class TestGitRepositoryGetDiff:
|
||||
@pytest.mark.asyncio
|
||||
async def test_includes_untracked_files_without_mutating_index(
|
||||
self, tmp_path: Path
|
||||
) -> None:
|
||||
source_repo = make_real_repo(tmp_path)
|
||||
(tmp_path / "new.txt").write_text("hello\n")
|
||||
status_before = source_repo.git.status("--short")
|
||||
|
||||
async with GitRepository(tmp_path) as git_repo:
|
||||
diff = await git_repo._get_diff(source_repo)
|
||||
|
||||
assert "diff --git a/new.txt b/new.txt" in diff
|
||||
assert source_repo.git.status("--short") == status_before
|
||||
|
||||
|
||||
class TestGitRepositoryIsCommitPushed:
|
||||
@pytest.fixture
|
||||
def repo(self, tmp_path: Path) -> GitRepository:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue