|
33 | 33 |
|
34 | 34 |
|
35 | 35 | @contextlib.contextmanager |
36 | | -def _allow_file_protocol(): |
37 | | - """Temporarily set protocol.file.allow to always, using environment variables.""" |
| 36 | +def _patch_git_config(name, value): |
| 37 | + """Temporarily add a git config name-value pair, using environment variables.""" |
38 | 38 | pair_index = int(os.getenv("GIT_CONFIG_COUNT", "0")) |
39 | 39 |
|
40 | 40 | # This is recomputed each time the context is entered, for compatibility with |
41 | 41 | # existing GIT_CONFIG_* environment variables, even if changed in this process. |
42 | 42 | patcher = mock.patch.dict(os.environ, { |
43 | 43 | "GIT_CONFIG_COUNT": str(pair_index + 1), |
44 | | - f"GIT_CONFIG_KEY_{pair_index}": "protocol.file.allow", |
45 | | - f"GIT_CONFIG_VALUE_{pair_index}": "always", |
| 44 | + f"GIT_CONFIG_KEY_{pair_index}": name, |
| 45 | + f"GIT_CONFIG_VALUE_{pair_index}": value, |
46 | 46 | }) |
47 | 47 |
|
48 | 48 | with patcher: |
@@ -727,7 +727,7 @@ def test_add_empty_repo(self, rwdir): |
727 | 727 | # end for each checkout mode |
728 | 728 |
|
729 | 729 | @with_rw_directory |
730 | | - @_allow_file_protocol() |
| 730 | + @_patch_git_config("protocol.file.allow", "always") |
731 | 731 | def test_list_only_valid_submodules(self, rwdir): |
732 | 732 | repo_path = osp.join(rwdir, "parent") |
733 | 733 | repo = git.Repo.init(repo_path) |
@@ -756,7 +756,7 @@ def test_list_only_valid_submodules(self, rwdir): |
756 | 756 | """, |
757 | 757 | ) |
758 | 758 | @with_rw_directory |
759 | | - @_allow_file_protocol() |
| 759 | + @_patch_git_config("protocol.file.allow", "always") |
760 | 760 | def test_git_submodules_and_add_sm_with_new_commit(self, rwdir): |
761 | 761 | parent = git.Repo.init(osp.join(rwdir, "parent")) |
762 | 762 | parent.git.submodule("add", self._small_repo_url(), "module") |
|
0 commit comments