From 96fae83e36c67f90d6c3da64a936a06a0966e981 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 10 Jun 2022 17:52:42 -0400 Subject: [PATCH 01/17] BUG: Fix is_cygwin_git to return True on Cygwin. --- git/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git/util.py b/git/util.py index 11139156c..e55f15d30 100644 --- a/git/util.py +++ b/git/util.py @@ -377,7 +377,9 @@ def is_cygwin_git(git_executable: PathLike) -> bool: def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: - if not is_win: + if is_win: + # is_win seems to be true only for Windows-native pythons + # cygwin has os.name = posix, I think return False if git_executable is None: From a67862c6d9e6835382ebbb255ad3a121c4cdc6a7 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 10 Jun 2022 18:07:08 -0400 Subject: [PATCH 02/17] CI: Add a CI job with Cygwin tests I think this got deleted because the tests were failing, so let's see what happens! --- .github/workflows/cygwin-test.yml | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/cygwin-test.yml diff --git a/.github/workflows/cygwin-test.yml b/.github/workflows/cygwin-test.yml new file mode 100644 index 000000000..f38f2bd6b --- /dev/null +++ b/.github/workflows/cygwin-test.yml @@ -0,0 +1,53 @@ +name: test-cygwin + +on: + push: + branches: + main + pull_request: + branches: + main + +jobs: + build: + runs-on: windows-latest + env: + CHERE_INVOKING: 1 + SHELLOPTS: igncr + + steps: + - name: Force LF line endings + run: git config --global core.autocrlf input + - uses: actions/checkout@v3 + with: + fetch-depth: 9999 + - uses: cygwin/cygwin-install-action@v2 + with: + packages: python39 python39-pip git + - name: Install dependencies and prepare tests + shell: bash.exe -eo pipefail -o igncr "{0}" + run: | + set -x + python -m pip install --upgrade pip setuptools wheel + python --version; git --version + git submodule update --init --recursive + git fetch --tags + pip install -r requirements.txt + pip install -r test-requirements.txt + TRAVIS=yes ./init-tests-after-clone.sh + git config --global user.email "travis@ci.com" + git config --global user.name "Travis Runner" + # If we rewrite the user's config by accident, we will mess it up + # and cause subsequent tests to fail + cat test/fixtures/.gitconfig >> ~/.gitconfig + - name: Lint with flake8 + shell: bash.exe -eo pipefail -o igncr "{0}" + run: | + set -x + flake8 + - name: Test with pytest + shell: bash.exe -eo pipefail -o igncr "{0}" + run: | + set -x + pytest + continue-on-error: false From 3fc07acfc9a9824307cf1c41c5bfa4ed7f760f50 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 10 Jun 2022 18:13:06 -0400 Subject: [PATCH 03/17] ENH: Update cygpath recodes to work with all installs People can change the `/cygdrive` prefix for mounting Windows drives; `/` and `/mnt` are both popular. `/proc/cygdrive` is always going to have the drive letters under it. --- git/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git/util.py b/git/util.py index e55f15d30..6a4a65579 100644 --- a/git/util.py +++ b/git/util.py @@ -310,7 +310,7 @@ def _cygexpath(drive: Optional[str], path: str) -> str: else: p = cygpath(p) elif drive: - p = "/cygdrive/%s/%s" % (drive.lower(), p) + p = "/proc/cygdrive/%s/%s" % (drive.lower(), p) p_str = str(p) # ensure it is a str and not AnyPath return p_str.replace("\\", "/") @@ -334,7 +334,7 @@ def cygpath(path: str) -> str: """Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment.""" path = str(path) # ensure is str and not AnyPath. # Fix to use Paths when 3.5 dropped. or to be just str if only for urls? - if not path.startswith(("/cygdrive", "//")): + if not path.startswith(("/cygdrive", "//", "/proc/cygdrive")): for regex, parser, recurse in _cygpath_parsers: match = regex.match(path) if match: @@ -348,7 +348,7 @@ def cygpath(path: str) -> str: return path -_decygpath_regex = re.compile(r"/cygdrive/(\w)(/.*)?") +_decygpath_regex = re.compile(r"(?:/proc)?/cygdrive/(\w)(/.*)?") def decygpath(path: PathLike) -> str: From d8ad56fdef864d8db73fb35f9547fa8a9dc00774 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 10 Jun 2022 18:16:29 -0400 Subject: [PATCH 04/17] CI: Mark GHA repo safe for Git to use --- .github/workflows/cygwin-test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cygwin-test.yml b/.github/workflows/cygwin-test.yml index f38f2bd6b..1ec5391a8 100644 --- a/.github/workflows/cygwin-test.yml +++ b/.github/workflows/cygwin-test.yml @@ -24,6 +24,9 @@ jobs: - uses: cygwin/cygwin-install-action@v2 with: packages: python39 python39-pip git + - name: Tell git to trust this repo + shell: bash.exe -eo pipefail -o igncr "{0}" + run: git config --global --add safe.directory $(pwd) - name: Install dependencies and prepare tests shell: bash.exe -eo pipefail -o igncr "{0}" run: | From f96cea165425fd569e8a185237669a66f62c49f2 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 10 Jun 2022 19:13:56 -0400 Subject: [PATCH 05/17] CI: Specify full path to python executables. --- .github/workflows/cygwin-test.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cygwin-test.yml b/.github/workflows/cygwin-test.yml index 1ec5391a8..19b19edd4 100644 --- a/.github/workflows/cygwin-test.yml +++ b/.github/workflows/cygwin-test.yml @@ -26,20 +26,20 @@ jobs: packages: python39 python39-pip git - name: Tell git to trust this repo shell: bash.exe -eo pipefail -o igncr "{0}" - run: git config --global --add safe.directory $(pwd) + run: /usr/bin/git config --global --add safe.directory $(pwd) - name: Install dependencies and prepare tests shell: bash.exe -eo pipefail -o igncr "{0}" run: | set -x - python -m pip install --upgrade pip setuptools wheel - python --version; git --version - git submodule update --init --recursive - git fetch --tags - pip install -r requirements.txt - pip install -r test-requirements.txt + /usr/bin/python -m pip install --upgrade pip setuptools wheel + /usr/bin/python --version; /usr/bin/git --version + /usr/bin/git submodule update --init --recursive + /usr/bin/git fetch --tags + /usr/bin/python -m pip install -r requirements.txt + /usr/bin/python -m pip install -r test-requirements.txt TRAVIS=yes ./init-tests-after-clone.sh - git config --global user.email "travis@ci.com" - git config --global user.name "Travis Runner" + /usr/bin/git config --global user.email "travis@ci.com" + /usr/bin/git config --global user.name "Travis Runner" # If we rewrite the user's config by accident, we will mess it up # and cause subsequent tests to fail cat test/fixtures/.gitconfig >> ~/.gitconfig @@ -47,10 +47,10 @@ jobs: shell: bash.exe -eo pipefail -o igncr "{0}" run: | set -x - flake8 + /usr/bin/python flake8 - name: Test with pytest shell: bash.exe -eo pipefail -o igncr "{0}" run: | set -x - pytest + /usr/bin/python -m pytest continue-on-error: false From d57a513791cd3a673b5bd7621809dd29bfc54321 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 10 Jun 2022 21:14:53 -0400 Subject: [PATCH 06/17] FIX: Fix flake8 command line Got this wrong the first time through --- .github/workflows/cygwin-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cygwin-test.yml b/.github/workflows/cygwin-test.yml index 19b19edd4..ee5867fc2 100644 --- a/.github/workflows/cygwin-test.yml +++ b/.github/workflows/cygwin-test.yml @@ -47,7 +47,7 @@ jobs: shell: bash.exe -eo pipefail -o igncr "{0}" run: | set -x - /usr/bin/python flake8 + /usr/bin/python -m flake8 - name: Test with pytest shell: bash.exe -eo pipefail -o igncr "{0}" run: | From 5d874ddc5a6cab35812e1ef395c18216f9399425 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 10 Jun 2022 21:35:40 -0400 Subject: [PATCH 07/17] BUG: Convert to native path before checking if absolute --- git/repo/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/git/repo/base.py b/git/repo/base.py index 111a350e9..440cfaef2 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -29,6 +29,7 @@ from git.util import ( Actor, finalize_process, + cygpath, decygpath, hex_to_bin, expand_path, @@ -175,7 +176,10 @@ def __init__( if not epath: epath = os.getcwd() if Git.is_cygwin(): - epath = decygpath(epath) + # Given how the tests are written, this seems more likely to catch + # Cygwin git used from Windows than Windows git used from Cygwin. + # Therefore changing to Cygwin-style paths is the relevant operation. + epath = cygpath(epath) epath = epath or path or os.getcwd() if not isinstance(epath, str): From 21113a81560dfea6f2eea5f50ceb5e87e9097c82 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sat, 11 Jun 2022 10:01:53 -0400 Subject: [PATCH 08/17] STY: Remove import of now-unused function --- git/repo/base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/git/repo/base.py b/git/repo/base.py index 440cfaef2..5a85cc4e2 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -30,7 +30,6 @@ Actor, finalize_process, cygpath, - decygpath, hex_to_bin, expand_path, remove_password_if_present, From 863c67882ce6fd25f6c8d3681ccf6331418806d3 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sat, 11 Jun 2022 10:18:57 -0400 Subject: [PATCH 09/17] CI: Set temporary directory for tests. Hopefully this avoids the mismatched directories with saving into a user temporary directory with one user name and reading from a user temporary directory with a different user name. --- .github/workflows/cygwin-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cygwin-test.yml b/.github/workflows/cygwin-test.yml index ee5867fc2..c30781537 100644 --- a/.github/workflows/cygwin-test.yml +++ b/.github/workflows/cygwin-test.yml @@ -14,6 +14,8 @@ jobs: env: CHERE_INVOKING: 1 SHELLOPTS: igncr + TMP: "/tmp" + TEMP: "/tmp" steps: - name: Force LF line endings From f99085263d959ef39830901734f232fa774dd5e0 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sat, 11 Jun 2022 10:39:36 -0400 Subject: [PATCH 10/17] CI: Install virtualenv for Cygwin CI. --- .github/workflows/cygwin-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cygwin-test.yml b/.github/workflows/cygwin-test.yml index c30781537..fff21e67e 100644 --- a/.github/workflows/cygwin-test.yml +++ b/.github/workflows/cygwin-test.yml @@ -25,7 +25,7 @@ jobs: fetch-depth: 9999 - uses: cygwin/cygwin-install-action@v2 with: - packages: python39 python39-pip git + packages: python39 python39-pip python39-virtualenv git - name: Tell git to trust this repo shell: bash.exe -eo pipefail -o igncr "{0}" run: /usr/bin/git config --global --add safe.directory $(pwd) From 9be148c65e9e6c7ed6706c12adc785187918da88 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sat, 11 Jun 2022 11:21:54 -0400 Subject: [PATCH 11/17] BUG: Use Cygwin paths for Cygwin git --- git/repo/fun.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git/repo/fun.py b/git/repo/fun.py index 8a07c2abd..2ca2e3d6f 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -7,7 +7,7 @@ from git.exc import WorkTreeRepositoryUnsupported from git.objects import Object from git.refs import SymbolicReference -from git.util import hex_to_bin, bin_to_hex, decygpath +from git.util import hex_to_bin, bin_to_hex, cygpath from gitdb.exc import ( BadObject, BadName, @@ -109,7 +109,9 @@ def find_submodule_git_dir(d: "PathLike") -> Optional["PathLike"]: if Git.is_cygwin(): ## Cygwin creates submodules prefixed with `/cygdrive/...` suffixes. - path = decygpath(path) + # Cygwin git understands Cygwin paths much better than Windows ones + # Also the Cygwin tests are assuming Cygwin paths. + path = cygpath(path) if not osp.isabs(path): path = osp.normpath(osp.join(osp.dirname(d), path)) return find_submodule_git_dir(path) From aafb92ab934dcf58fe432f95c8dfcef8f32a91c7 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sat, 11 Jun 2022 11:34:22 -0400 Subject: [PATCH 12/17] CI: Turn of command echo for tests Echoing the commands in shell scripts in tests causes problems with the tests. --- .github/workflows/cygwin-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cygwin-test.yml b/.github/workflows/cygwin-test.yml index fff21e67e..6fe501249 100644 --- a/.github/workflows/cygwin-test.yml +++ b/.github/workflows/cygwin-test.yml @@ -53,6 +53,5 @@ jobs: - name: Test with pytest shell: bash.exe -eo pipefail -o igncr "{0}" run: | - set -x /usr/bin/python -m pytest continue-on-error: false From 54bae76a88acfc4ddb60f32938ccc8febd0c5a7d Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Mon, 20 Jun 2022 20:39:09 -0400 Subject: [PATCH 13/17] TST: Mark test_docs.Tutorials.test_submodules as xfail on Cygwin --- test/test_docs.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_docs.py b/test/test_docs.py index bea34a0b8..75fd2ba59 100644 --- a/test/test_docs.py +++ b/test/test_docs.py @@ -5,6 +5,7 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php import os +import sys from test.lib import TestBase from test.lib.helper import with_rw_directory @@ -475,6 +476,11 @@ def test_references_and_objects(self, rw_dir): repo.git.clear_cache() + @pytest.mark.xfail( + sys.platform == "cygwin", + reason="Cygwin GitPython can't find SHA for submodule", + raises=ValueError + ) def test_submodules(self): # [1-test_submodules] repo = self.rorepo From 0eda0a54b3093681ed5431c003ec4994aecfe273 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Mon, 20 Jun 2022 20:41:36 -0400 Subject: [PATCH 14/17] TST: Mark test_repo.TestRepo.test_submodules as xfail on Cygwin --- test/test_repo.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_repo.py b/test/test_repo.py index 30db13920..75b590fe7 100644 --- a/test/test_repo.py +++ b/test/test_repo.py @@ -11,9 +11,12 @@ import os import pathlib import pickle +import sys import tempfile from unittest import mock, skipIf, SkipTest +import pytest + from git import ( InvalidGitRepositoryError, Repo, @@ -903,6 +906,11 @@ def test_repo_odbtype(self): target_type = GitCmdObjectDB self.assertIsInstance(self.rorepo.odb, target_type) + @pytest.mark.xfail( + sys.platform == "cygwin", + reason="Cygwin GitPython can't find submodule SHA", + raises=ValueError + ) def test_submodules(self): self.assertEqual(len(self.rorepo.submodules), 1) # non-recursive self.assertGreaterEqual(len(list(self.rorepo.iter_submodules())), 2) From 7f3689d1f9ffb3ae9122a284129b61e64ac30d2d Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Mon, 20 Jun 2022 20:43:31 -0400 Subject: [PATCH 15/17] TST: Mark test_submodule.TestSubmodule.test_root_module as xfail on Cygwin --- test/test_submodule.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_submodule.py b/test/test_submodule.py index 2930ce032..98cc55439 100644 --- a/test/test_submodule.py +++ b/test/test_submodule.py @@ -3,8 +3,11 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php import os import shutil +import sys from unittest import skipIf +import pytest + import git from git.cmd import Git from git.compat import is_win @@ -433,6 +436,11 @@ def _do_base_tests(self, rwrepo): def test_base_rw(self, rwrepo): self._do_base_tests(rwrepo) + @pytest.mark.xfail( + sys.platform == "cygwin", + reason="Cygwin GitPython can't find submodule SHA", + raises=ValueError + ) @with_rw_repo(k_subm_current, bare=True) def test_base_bare(self, rwrepo): self._do_base_tests(rwrepo) From c3fd6c1a7c93d28597b45ca424efa1a6fdd8b2c8 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Mon, 20 Jun 2022 20:44:20 -0400 Subject: [PATCH 16/17] FIX: Import pytest in tests.test_docs --- test/test_docs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_docs.py b/test/test_docs.py index 75fd2ba59..20027c191 100644 --- a/test/test_docs.py +++ b/test/test_docs.py @@ -7,6 +7,8 @@ import os import sys +import pytest + from test.lib import TestBase from test.lib.helper import with_rw_directory From 2996f402f11565c3ad93aedfe070f4f5f571e72e Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Mon, 20 Jun 2022 21:02:18 -0400 Subject: [PATCH 17/17] FIX: Mark the correct test_submodule test as xfail on Cygwin Got the wrong one the first time. --- test/test_submodule.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_submodule.py b/test/test_submodule.py index 98cc55439..d72fe5d3a 100644 --- a/test/test_submodule.py +++ b/test/test_submodule.py @@ -436,15 +436,15 @@ def _do_base_tests(self, rwrepo): def test_base_rw(self, rwrepo): self._do_base_tests(rwrepo) + @with_rw_repo(k_subm_current, bare=True) + def test_base_bare(self, rwrepo): + self._do_base_tests(rwrepo) + @pytest.mark.xfail( sys.platform == "cygwin", reason="Cygwin GitPython can't find submodule SHA", raises=ValueError ) - @with_rw_repo(k_subm_current, bare=True) - def test_base_bare(self, rwrepo): - self._do_base_tests(rwrepo) - @skipIf( HIDE_WINDOWS_KNOWN_ERRORS, """ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy