◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
57 changes: 57 additions & 0 deletions .github/workflows/cygwin-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
7 changes: 5 additions & 2 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from git.util import (
Actor,
finalize_process,
decygpath,
hex_to_bin,
expand_path,
remove_password_if_present,
Expand Down Expand Up @@ -175,7 +175,10 @@ def __init__(
if not epath:
epath = os.getcwd()
if Git.is_cygwin():
epath = decygpath(epath)

epath = epath or path or os.getcwd()
if not isinstance(epath, str):
Expand Down
6 changes: 4 additions & 2 deletions git/repo/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 gitdb.exc import (
BadObject,
BadName,
Expand Down Expand Up @@ -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)
if not osp.isabs(path):
path = osp.normpath(osp.join(osp.dirname(d), path))
return find_submodule_git_dir(path)
Expand Down
10 changes: 6 additions & 4 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_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", "//")):
for regex, parser, recurse in _cygpath_parsers:
match = regex.match(path)
if match:
Expand All @@ -348,7 +348,7 @@ def cygpath(path: str) -> str:
return path


_decygpath_regex = re.compile(r"/cygdrive/(\w)(/.*)?")


def decygpath(path: PathLike) -> str:
Expand Down Expand Up @@ -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:
return False

if git_executable is None:
Expand Down
8 changes: 8 additions & 0 deletions test/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import os

from test.lib import TestBase
from test.lib.helper import with_rw_directory
Expand Down Expand Up @@ -475,6 +478,11 @@ def test_references_and_objects(self, rw_dir):

repo.git.clear_cache()

def test_submodules(self):
# [1-test_submodules]
repo = self.rorepo
Expand Down
8 changes: 8 additions & 0 deletions test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
import os
import pathlib
import pickle
import tempfile
from unittest import mock, skipIf, SkipTest

from git import (
InvalidGitRepositoryError,
Repo,
Expand Down Expand Up @@ -903,6 +906,11 @@ def test_repo_odbtype(self):
target_type = GitCmdObjectDB
self.assertIsInstance(self.rorepo.odb, target_type)

def test_submodules(self):
self.assertEqual(len(self.rorepo.submodules), 1) # non-recursive
self.assertGreaterEqual(len(list(self.rorepo.iter_submodules())), 2)
Expand Down
8 changes: 8 additions & 0 deletions test/test_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import os
import shutil
from unittest import skipIf

import git
from git.cmd import Git
from git.compat import is_win
Expand Down Expand Up @@ -437,6 +440,11 @@ def test_base_rw(self, rwrepo):
def test_base_bare(self, rwrepo):
self._do_base_tests(rwrepo)

@skipIf(
HIDE_WINDOWS_KNOWN_ERRORS,
"""
Expand Down
Toggle all file notes Toggle all file annotations