| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,57 @@ | |||
| 1 | + name: test-cygwin | ||
| 2 | + | ||
| 3 | + on: | ||
| 4 | + push: | ||
| 5 | + branches: | ||
| 6 | + main | ||
| 7 | + pull_request: | ||
| 8 | + branches: | ||
| 9 | + main | ||
| 10 | + | ||
| 11 | + jobs: | ||
| 12 | + build: | ||
| 13 | + runs-on: windows-latest | ||
| 14 | + env: | ||
| 15 | + CHERE_INVOKING: 1 | ||
| 16 | + SHELLOPTS: igncr | ||
| 17 | + TMP: "/tmp" | ||
| 18 | + TEMP: "/tmp" | ||
| 19 | + | ||
| 20 | + steps: | ||
| 21 | + - name: Force LF line endings | ||
| 22 | + run: git config --global core.autocrlf input | ||
| 23 | + - uses: actions/checkout@v3 | ||
| 24 | + with: | ||
| 25 | + fetch-depth: 9999 | ||
| 26 | + - uses: cygwin/cygwin-install-action@v2 | ||
| 27 | + with: | ||
| 28 | + packages: python39 python39-pip python39-virtualenv git | ||
| 29 | + - name: Tell git to trust this repo | ||
| 30 | + shell: bash.exe -eo pipefail -o igncr "{0}" | ||
| 31 | + run: /usr/bin/git config --global --add safe.directory $(pwd) | ||
| 32 | + - name: Install dependencies and prepare tests | ||
| 33 | + shell: bash.exe -eo pipefail -o igncr "{0}" | ||
| 34 | + run: | | ||
| 35 | + set -x | ||
| 36 | + /usr/bin/python -m pip install --upgrade pip setuptools wheel | ||
| 37 | + /usr/bin/python --version; /usr/bin/git --version | ||
| 38 | + /usr/bin/git submodule update --init --recursive | ||
| 39 | + /usr/bin/git fetch --tags | ||
| 40 | + /usr/bin/python -m pip install -r requirements.txt | ||
| 41 | + /usr/bin/python -m pip install -r test-requirements.txt | ||
| 42 | + TRAVIS=yes ./init-tests-after-clone.sh | ||
| 43 | + /usr/bin/git config --global user.email "travis@ci.com" | ||
| 44 | + /usr/bin/git config --global user.name "Travis Runner" | ||
| 45 | + # If we rewrite the user's config by accident, we will mess it up | ||
| 46 | + # and cause subsequent tests to fail | ||
| 47 | + cat test/fixtures/.gitconfig >> ~/.gitconfig | ||
| 48 | + - name: Lint with flake8 | ||
| 49 | + shell: bash.exe -eo pipefail -o igncr "{0}" | ||
| 50 | + run: | | ||
| 51 | + set -x | ||
| 52 | + /usr/bin/python -m flake8 | ||
| 53 | + - name: Test with pytest | ||
| 54 | + shell: bash.exe -eo pipefail -o igncr "{0}" | ||
| 55 | + run: | | ||
| 56 | + /usr/bin/python -m pytest | ||
| 57 | + continue-on-error: false | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ | |||
| 29 | 29 | from git.util import ( | |
| 30 | 30 | Actor, | |
| 31 | 31 | finalize_process, | |
| 32 | - decygpath, | ||
| 32 | + cygpath, | ||
| 33 | 33 | hex_to_bin, | |
| 34 | 34 | expand_path, | |
| 35 | 35 | remove_password_if_present, | |
@@ -175,7 +175,10 @@ def __init__( | |||
| 175 | 175 | if not epath: | |
| 176 | 176 | epath = os.getcwd() | |
| 177 | 177 | if Git.is_cygwin(): | |
| 178 | - epath = decygpath(epath) | ||
| 178 | + # Given how the tests are written, this seems more likely to catch | ||
| 179 | + # Cygwin git used from Windows than Windows git used from Cygwin. | ||
| 180 | + # Therefore changing to Cygwin-style paths is the relevant operation. | ||
| 181 | + epath = cygpath(epath) | ||
| 179 | 182 | ||
| 180 | 183 | epath = epath or path or os.getcwd() | |
| 181 | 184 | if not isinstance(epath, str): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ | |||
| 7 | 7 | from git.exc import WorkTreeRepositoryUnsupported | |
| 8 | 8 | from git.objects import Object | |
| 9 | 9 | from git.refs import SymbolicReference | |
| 10 | - from git.util import hex_to_bin, bin_to_hex, decygpath | ||
| 10 | + from git.util import hex_to_bin, bin_to_hex, cygpath | ||
| 11 | 11 | from gitdb.exc import ( | |
| 12 | 12 | BadObject, | |
| 13 | 13 | BadName, | |
@@ -109,7 +109,9 @@ def find_submodule_git_dir(d: "PathLike") -> Optional["PathLike"]: | |||
| 109 | 109 | ||
| 110 | 110 | if Git.is_cygwin(): | |
| 111 | 111 | ## Cygwin creates submodules prefixed with `/cygdrive/...` suffixes. | |
| 112 | - path = decygpath(path) | ||
| 112 | + # Cygwin git understands Cygwin paths much better than Windows ones | ||
| 113 | + # Also the Cygwin tests are assuming Cygwin paths. | ||
| 114 | + path = cygpath(path) | ||
| 113 | 115 | if not osp.isabs(path): | |
| 114 | 116 | path = osp.normpath(osp.join(osp.dirname(d), path)) | |
| 115 | 117 | return find_submodule_git_dir(path) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -310,7 +310,7 @@ def _cygexpath(drive: Optional[str], path: str) -> str: | |||
| 310 | 310 | else: | |
| 311 | 311 | p = cygpath(p) | |
| 312 | 312 | elif drive: | |
| 313 | - p = "/cygdrive/%s/%s" % (drive.lower(), p) | ||
| 313 | + p = "/proc/cygdrive/%s/%s" % (drive.lower(), p) | ||
| 314 | 314 | p_str = str(p) # ensure it is a str and not AnyPath | |
| 315 | 315 | return p_str.replace("\\", "/") | |
| 316 | 316 | ||
@@ -334,7 +334,7 @@ def cygpath(path: str) -> str: | |||
| 334 | 334 | """Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment.""" | |
| 335 | 335 | path = str(path) # ensure is str and not AnyPath. | |
| 336 | 336 | # Fix to use Paths when 3.5 dropped. or to be just str if only for urls? | |
| 337 | - if not path.startswith(("/cygdrive", "//")): | ||
| 337 | + if not path.startswith(("/cygdrive", "//", "/proc/cygdrive")): | ||
| 338 | 338 | for regex, parser, recurse in _cygpath_parsers: | |
| 339 | 339 | match = regex.match(path) | |
| 340 | 340 | if match: | |
@@ -348,7 +348,7 @@ def cygpath(path: str) -> str: | |||
| 348 | 348 | return path | |
| 349 | 349 | ||
| 350 | 350 | ||
| 351 | - _decygpath_regex = re.compile(r"/cygdrive/(\w)(/.*)?") | ||
| 351 | + _decygpath_regex = re.compile(r"(?:/proc)?/cygdrive/(\w)(/.*)?") | ||
| 352 | 352 | ||
| 353 | 353 | ||
| 354 | 354 | def decygpath(path: PathLike) -> str: | |
@@ -377,7 +377,9 @@ def is_cygwin_git(git_executable: PathLike) -> bool: | |||
| 377 | 377 | ||
| 378 | 378 | ||
| 379 | 379 | def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: | |
| 380 | - if not is_win: | ||
| 380 | + if is_win: | ||
| 381 | + # is_win seems to be true only for Windows-native pythons | ||
| 382 | + # cygwin has os.name = posix, I think | ||
| 381 | 383 | return False | |
| 382 | 384 | ||
| 383 | 385 | if git_executable is None: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,9 @@ | |||
| 5 | 5 | # This module is part of GitPython and is released under | |
| 6 | 6 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 7 | 7 | import os | |
| 8 | + import sys | ||
| 9 | + | ||
| 10 | + import pytest | ||
| 8 | 11 | ||
| 9 | 12 | from test.lib import TestBase | |
| 10 | 13 | from test.lib.helper import with_rw_directory | |
@@ -475,6 +478,11 @@ def test_references_and_objects(self, rw_dir): | |||
| 475 | 478 | ||
| 476 | 479 | repo.git.clear_cache() | |
| 477 | 480 | ||
| 481 | + @pytest.mark.xfail( | ||
| 482 | + sys.platform == "cygwin", | ||
| 483 | + reason="Cygwin GitPython can't find SHA for submodule", | ||
| 484 | + raises=ValueError | ||
| 485 | + ) | ||
| 478 | 486 | def test_submodules(self): | |
| 479 | 487 | # [1-test_submodules] | |
| 480 | 488 | repo = self.rorepo | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,9 +11,12 @@ | |||
| 11 | 11 | import os | |
| 12 | 12 | import pathlib | |
| 13 | 13 | import pickle | |
| 14 | + import sys | ||
| 14 | 15 | import tempfile | |
| 15 | 16 | from unittest import mock, skipIf, SkipTest | |
| 16 | 17 | ||
| 18 | + import pytest | ||
| 19 | + | ||
| 17 | 20 | from git import ( | |
| 18 | 21 | InvalidGitRepositoryError, | |
| 19 | 22 | Repo, | |
@@ -903,6 +906,11 @@ def test_repo_odbtype(self): | |||
| 903 | 906 | target_type = GitCmdObjectDB | |
| 904 | 907 | self.assertIsInstance(self.rorepo.odb, target_type) | |
| 905 | 908 | ||
| 909 | + @pytest.mark.xfail( | ||
| 910 | + sys.platform == "cygwin", | ||
| 911 | + reason="Cygwin GitPython can't find submodule SHA", | ||
| 912 | + raises=ValueError | ||
| 913 | + ) | ||
| 906 | 914 | def test_submodules(self): | |
| 907 | 915 | self.assertEqual(len(self.rorepo.submodules), 1) # non-recursive | |
| 908 | 916 | self.assertGreaterEqual(len(list(self.rorepo.iter_submodules())), 2) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,8 +3,11 @@ | |||
| 3 | 3 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 4 | 4 | import os | |
| 5 | 5 | import shutil | |
| 6 | + import sys | ||
| 6 | 7 | from unittest import skipIf | |
| 7 | 8 | ||
| 9 | + import pytest | ||
| 10 | + | ||
| 8 | 11 | import git | |
| 9 | 12 | from git.cmd import Git | |
| 10 | 13 | from git.compat import is_win | |
@@ -437,6 +440,11 @@ def test_base_rw(self, rwrepo): | |||
| 437 | 440 | def test_base_bare(self, rwrepo): | |
| 438 | 441 | self._do_base_tests(rwrepo) | |
| 439 | 442 | ||
| 443 | + @pytest.mark.xfail( | ||
| 444 | + sys.platform == "cygwin", | ||
| 445 | + reason="Cygwin GitPython can't find submodule SHA", | ||
| 446 | + raises=ValueError | ||
| 447 | + ) | ||
| 440 | 448 | @skipIf( | |
| 441 | 449 | HIDE_WINDOWS_KNOWN_ERRORS, | |
| 442 | 450 | """ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments