diff options
| author | Insaf Latypov <saferif@google.com> | 2026-10-13 16:41:12 +0000 |
|---|---|---|
| committer | gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2026-10-14 07:49:21 -0700 |
| commit | a0bc2b14a30bef631b91a2ca37c5254d9af44718 (patch) | |
| tree | 0274ca559aabd04f723aee503fd098f91ef5fb4e /tests/test_git_config.py | |
| parent | 3448df395478c2375d880e33bfc705a9ed36272b (diff) | |
| download | git-repo-2.69.tar.gz | |
git_config: Fix bugs in processing RepoConfig.v2.69
- Automatically create all the parent directories for `git confing
--file ...`
- Prevent `RepoConfig` from inheriting caches from `GitConfig`. These
two are different files.
Bug: 569927750
Test: ./run_tests
Change-Id: I9c60cecff75c1fb62be3ff63425d9618c0f56b06
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/643263
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Insaf Latypov <saferif@google.com>
Commit-Queue: Insaf Latypov <saferif@google.com>
Diffstat (limited to 'tests/test_git_config.py')
| -rw-r--r-- | tests/test_git_config.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_git_config.py b/tests/test_git_config.py index 4b4e4cabb..33b0466fa 100644 --- a/tests/test_git_config.py +++ b/tests/test_git_config.py | |||
| @@ -268,3 +268,23 @@ def test_remote_save_with_push_url_without_projectname( | |||
| 268 | def test_is_id(rev: str, expected: bool) -> None: | 268 | def test_is_id(rev: str, expected: bool) -> None: |
| 269 | """Test IsId identifies both SHA-1 and SHA-256 hashes.""" | 269 | """Test IsId identifies both SHA-1 and SHA-256 hashes.""" |
| 270 | assert git_config.IsId(rev) == expected | 270 | assert git_config.IsId(rev) == expected |
| 271 | |||
| 272 | |||
| 273 | def test_repo_config_for_user_is_not_shared_with_git_config( | ||
| 274 | monkeypatch: pytest.MonkeyPatch, tmp_home_dir: Path | ||
| 275 | ) -> None: | ||
| 276 | """RepoConfig.ForUser() must not reuse GitConfig.ForUser()'s cache.""" | ||
| 277 | monkeypatch.setattr(git_config.GitConfig, "_ForUser", None) | ||
| 278 | monkeypatch.setattr(git_config.RepoConfig, "_ForUser", None) | ||
| 279 | monkeypatch.delenv("REPO_CONFIG_DIR", raising=False) | ||
| 280 | |||
| 281 | # Populate the GitConfig cache first, as manifest loading does. | ||
| 282 | git_cfg = git_config.GitConfig.ForUser() | ||
| 283 | repo_cfg = git_config.RepoConfig.ForUser() | ||
| 284 | |||
| 285 | assert repo_cfg is not git_cfg | ||
| 286 | assert git_cfg.file == str(tmp_home_dir / ".gitconfig") | ||
| 287 | assert repo_cfg.file == str(tmp_home_dir / ".repoconfig" / "config") | ||
| 288 | # And the RepoConfig instance is cached on its own class. | ||
| 289 | assert git_config.RepoConfig.ForUser() is repo_cfg | ||
| 290 | assert git_config.GitConfig.ForUser() is git_cfg | ||
