|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
| 5 | +import logging |
5 | 6 | import pathlib |
6 | 7 | import re |
7 | 8 | import subprocess |
@@ -809,6 +810,41 @@ def _fake_save(path: pathlib.Path, data: dict[str, t.Any]) -> None: |
809 | 810 | assert "Successfully updated" in caplog.text |
810 | 811 |
|
811 | 812 |
|
| 813 | +def test_discover_logs_redact_scan_and_repo_paths( |
| 814 | + user_path: pathlib.Path, |
| 815 | + caplog: pytest.LogCaptureFixture, |
| 816 | + monkeypatch: MonkeyPatch, |
| 817 | +) -> None: |
| 818 | + """Warnings and info logs should display PrivatePath-collapsed values.""" |
| 819 | + scan_dir = user_path / "projects" |
| 820 | + repo_dir = scan_dir / "demo" |
| 821 | + (repo_dir / ".git").mkdir(parents=True, exist_ok=True) |
| 822 | + |
| 823 | + caplog.set_level(logging.INFO, logger="vcspull.cli.discover") |
| 824 | + |
| 825 | + monkeypatch.setattr( |
| 826 | + "vcspull.cli.discover.get_git_origin_url", |
| 827 | + lambda _path: None, |
| 828 | + ) |
| 829 | + |
| 830 | + config_file = user_path / ".vcspull.yaml" |
| 831 | + config_file.write_text("{}\n", encoding="utf-8") |
| 832 | + |
| 833 | + discover_repos( |
| 834 | + scan_dir_str=str(scan_dir), |
| 835 | + config_file_path_str=str(config_file), |
| 836 | + recursive=False, |
| 837 | + workspace_root_override=None, |
| 838 | + yes=True, |
| 839 | + dry_run=True, |
| 840 | + ) |
| 841 | + |
| 842 | + repo_display = str(PrivatePath(repo_dir)) |
| 843 | + scan_display = str(PrivatePath(scan_dir)) |
| 844 | + assert repo_display in caplog.text |
| 845 | + assert scan_display in caplog.text |
| 846 | + |
| 847 | + |
812 | 848 | def test_discover_user_config_prefers_absolute_workspace_label( |
813 | 849 | tmp_path: pathlib.Path, |
814 | 850 | monkeypatch: MonkeyPatch, |
|
0 commit comments