|
14 | 14 | import yaml |
15 | 15 |
|
16 | 16 | from vcspull.__about__ import __version__ |
| 17 | +from vcspull._internal.private_path import PrivatePath |
17 | 18 | from vcspull.cli import cli |
18 | 19 | from vcspull.cli._output import PlanAction, PlanEntry, PlanResult, PlanSummary |
19 | 20 | from vcspull.cli.sync import EXIT_ON_ERROR_MSG, NO_REPOS_FOR_TERM_MSG |
@@ -974,3 +975,75 @@ def test_sync_dry_run_plan_progress( |
974 | 975 | output = f"{captured.out}{captured.err}" |
975 | 976 | assert "Progress:" in output |
976 | 977 | assert "Plan:" in output |
| 978 | + |
| 979 | + |
| 980 | +def test_sync_human_output_redacts_repo_paths( |
| 981 | + capsys: pytest.CaptureFixture[str], |
| 982 | + monkeypatch: pytest.MonkeyPatch, |
| 983 | + user_path: pathlib.Path, |
| 984 | +) -> None: |
| 985 | + """Synced log lines should collapse repo paths via PrivatePath.""" |
| 986 | + repo_path = user_path / "repos" / "private" |
| 987 | + repo_path.mkdir(parents=True, exist_ok=True) |
| 988 | + |
| 989 | + repo_config = { |
| 990 | + "name": "private", |
| 991 | + "url": "git+https://example.com/private.git", |
| 992 | + "path": str(repo_path), |
| 993 | + "workspace_root": "~/repos/", |
| 994 | + } |
| 995 | + |
| 996 | + monkeypatch.setattr( |
| 997 | + sync_module, |
| 998 | + "load_configs", |
| 999 | + lambda _paths: [repo_config], |
| 1000 | + ) |
| 1001 | + monkeypatch.setattr( |
| 1002 | + sync_module, |
| 1003 | + "find_config_files", |
| 1004 | + lambda include_home=True: [], |
| 1005 | + ) |
| 1006 | + |
| 1007 | + def _fake_filter_repos( |
| 1008 | + _configs: list[dict[str, t.Any]], |
| 1009 | + *, |
| 1010 | + path: str | None = None, |
| 1011 | + vcs_url: str | None = None, |
| 1012 | + name: str | None = None, |
| 1013 | + ) -> list[dict[str, t.Any]]: |
| 1014 | + if name and name != repo_config["name"]: |
| 1015 | + return [] |
| 1016 | + if path and path != repo_config["path"]: |
| 1017 | + return [] |
| 1018 | + if vcs_url and vcs_url != repo_config["url"]: |
| 1019 | + return [] |
| 1020 | + return [repo_config] |
| 1021 | + |
| 1022 | + monkeypatch.setattr(sync_module, "filter_repos", _fake_filter_repos) |
| 1023 | + monkeypatch.setattr( |
| 1024 | + sync_module, |
| 1025 | + "update_repo", |
| 1026 | + lambda _repo, progress_callback=None: None, |
| 1027 | + ) |
| 1028 | + |
| 1029 | + sync_module.sync( |
| 1030 | + repo_patterns=[repo_config["name"]], |
| 1031 | + config=None, |
| 1032 | + workspace_root=None, |
| 1033 | + dry_run=False, |
| 1034 | + output_json=False, |
| 1035 | + output_ndjson=False, |
| 1036 | + color="never", |
| 1037 | + exit_on_error=False, |
| 1038 | + show_unchanged=False, |
| 1039 | + summary_only=False, |
| 1040 | + long_view=False, |
| 1041 | + relative_paths=False, |
| 1042 | + fetch=False, |
| 1043 | + offline=False, |
| 1044 | + verbosity=0, |
| 1045 | + ) |
| 1046 | + |
| 1047 | + captured = capsys.readouterr() |
| 1048 | + expected_path = str(PrivatePath(repo_path)) |
| 1049 | + assert expected_path in captured.out |
0 commit comments