| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ jobs: | |||
| 12 | 12 | SHELLOPTS: igncr | |
| 13 | 13 | TMP: "/tmp" | |
| 14 | 14 | TEMP: "/tmp" | |
| 15 | - | ||
| 15 | + | ||
| 16 | 16 | steps: | |
| 17 | 17 | - name: Force LF line endings | |
| 18 | 18 | run: git config --global core.autocrlf input | |
@@ -24,9 +24,8 @@ jobs: | |||
| 24 | 24 | packages: python39 python39-pip python39-virtualenv git | |
| 25 | 25 | - name: Tell git to trust this repo | |
| 26 | 26 | shell: bash.exe -eo pipefail -o igncr "{0}" | |
| 27 | - run: | | ||
| 28 | - /usr/bin/git config --global --add safe.directory $(pwd) | ||
| 29 | - /usr/bin/git config --global protocol.file.allow always | ||
| 27 | + run: | | ||
| 28 | + /usr/bin/git config --global --add safe.directory "$(pwd)" | ||
| 30 | 29 | - name: Install dependencies and prepare tests | |
| 31 | 30 | shell: bash.exe -eo pipefail -o igncr "{0}" | |
| 32 | 31 | run: | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,11 +52,6 @@ jobs: | |||
| 52 | 52 | set -x | |
| 53 | 53 | mypy -p git | |
| 54 | 54 | ||
| 55 | - - name: Tell git to trust this repo | ||
| 56 | - run: | | ||
| 57 | - /usr/bin/git config --global --add safe.directory $(pwd) | ||
| 58 | - /usr/bin/git config --global protocol.file.allow always | ||
| 59 | - | ||
| 60 | 55 | - name: Test with pytest | |
| 61 | 56 | run: | | |
| 62 | 57 | set -x | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,13 @@ | |||
| 1 | 1 | # -*- coding: utf-8 -*- | |
| 2 | 2 | # This module is part of GitPython and is released under | |
| 3 | 3 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 4 | + import contextlib | ||
| 4 | 5 | import os | |
| 5 | 6 | import shutil | |
| 6 | 7 | import tempfile | |
| 7 | 8 | from pathlib import Path | |
| 8 | 9 | import sys | |
| 9 | - from unittest import skipIf | ||
| 10 | + from unittest import mock, skipIf | ||
| 10 | 11 | ||
| 11 | 12 | import pytest | |
| 12 | 13 | ||
@@ -31,6 +32,23 @@ | |||
| 31 | 32 | import os.path as osp | |
| 32 | 33 | ||
| 33 | 34 | ||
| 35 | + @contextlib.contextmanager | ||
| 36 | + def _patch_git_config(name, value): | ||
| 37 | + """Temporarily add a git config name-value pair, using environment variables.""" | ||
| 38 | + pair_index = int(os.getenv("GIT_CONFIG_COUNT", "0")) | ||
| 39 | + | ||
| 40 | + # This is recomputed each time the context is entered, for compatibility with | ||
| 41 | + # existing GIT_CONFIG_* environment variables, even if changed in this process. | ||
| 42 | + patcher = mock.patch.dict(os.environ, { | ||
| 43 | + "GIT_CONFIG_COUNT": str(pair_index + 1), | ||
| 44 | + f"GIT_CONFIG_KEY_{pair_index}": name, | ||
| 45 | + f"GIT_CONFIG_VALUE_{pair_index}": value, | ||
| 46 | + }) | ||
| 47 | + | ||
| 48 | + with patcher: | ||
| 49 | + yield | ||
| 50 | + | ||
| 51 | + | ||
| 34 | 52 | class TestRootProgress(RootUpdateProgress): | |
| 35 | 53 | """Just prints messages, for now without checking the correctness of the states""" | |
| 36 | 54 | ||
@@ -709,6 +727,7 @@ def test_add_empty_repo(self, rwdir): | |||
| 709 | 727 | # end for each checkout mode | |
| 710 | 728 | ||
| 711 | 729 | @with_rw_directory | |
| 730 | + @_patch_git_config("protocol.file.allow", "always") | ||
| 712 | 731 | def test_list_only_valid_submodules(self, rwdir): | |
| 713 | 732 | repo_path = osp.join(rwdir, "parent") | |
| 714 | 733 | repo = git.Repo.init(repo_path) | |
@@ -737,6 +756,7 @@ def test_list_only_valid_submodules(self, rwdir): | |||
| 737 | 756 | """, | |
| 738 | 757 | ) | |
| 739 | 758 | @with_rw_directory | |
| 759 | + @_patch_git_config("protocol.file.allow", "always") | ||
| 740 | 760 | def test_git_submodules_and_add_sm_with_new_commit(self, rwdir): | |
| 741 | 761 | parent = git.Repo.init(osp.join(rwdir, "parent")) | |
| 742 | 762 | parent.git.submodule("add", self._small_repo_url(), "module") | |
| Back | FazBrowse Home | New Git URL |
0 commit comments