Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf0c6e11

Browse files
authored
Merge pull request#1455 from DWesl/patch-1
Re-enable Cygwin CI and get most tests passing
2 parents6660b84 +2996f40 commitf0c6e11

File tree

7 files changed

+96
-8
lines changed

7 files changed

+96
-8
lines changed

‎.github/workflows/cygwin-test.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff 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

‎git/repo/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
fromgit.utilimport (
3030
Actor,
3131
finalize_process,
32-
decygpath,
32+
cygpath,
3333
hex_to_bin,
3434
expand_path,
3535
remove_password_if_present,
@@ -175,7 +175,10 @@ def __init__(
175175
ifnotepath:
176176
epath=os.getcwd()
177177
ifGit.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)
179182

180183
epath=epathorpathoros.getcwd()
181184
ifnotisinstance(epath,str):

‎git/repo/fun.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
fromgit.excimportWorkTreeRepositoryUnsupported
88
fromgit.objectsimportObject
99
fromgit.refsimportSymbolicReference
10-
fromgit.utilimporthex_to_bin,bin_to_hex,decygpath
10+
fromgit.utilimporthex_to_bin,bin_to_hex,cygpath
1111
fromgitdb.excimport (
1212
BadObject,
1313
BadName,
@@ -109,7 +109,9 @@ def find_submodule_git_dir(d: "PathLike") -> Optional["PathLike"]:
109109

110110
ifGit.is_cygwin():
111111
## 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)
113115
ifnotosp.isabs(path):
114116
path=osp.normpath(osp.join(osp.dirname(d),path))
115117
returnfind_submodule_git_dir(path)

‎git/util.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def _cygexpath(drive: Optional[str], path: str) -> str:
310310
else:
311311
p=cygpath(p)
312312
elifdrive:
313-
p="/cygdrive/%s/%s"% (drive.lower(),p)
313+
p="/proc/cygdrive/%s/%s"% (drive.lower(),p)
314314
p_str=str(p)# ensure it is a str and not AnyPath
315315
returnp_str.replace("\\","/")
316316

@@ -334,7 +334,7 @@ def cygpath(path: str) -> str:
334334
"""Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment."""
335335
path=str(path)# ensure is str and not AnyPath.
336336
# Fix to use Paths when 3.5 dropped. or to be just str if only for urls?
337-
ifnotpath.startswith(("/cygdrive","//")):
337+
ifnotpath.startswith(("/cygdrive","//","/proc/cygdrive")):
338338
forregex,parser,recursein_cygpath_parsers:
339339
match=regex.match(path)
340340
ifmatch:
@@ -348,7 +348,7 @@ def cygpath(path: str) -> str:
348348
returnpath
349349

350350

351-
_decygpath_regex=re.compile(r"/cygdrive/(\w)(/.*)?")
351+
_decygpath_regex=re.compile(r"(?:/proc)?/cygdrive/(\w)(/.*)?")
352352

353353

354354
defdecygpath(path:PathLike)->str:
@@ -377,7 +377,9 @@ def is_cygwin_git(git_executable: PathLike) -> bool:
377377

378378

379379
defis_cygwin_git(git_executable:Union[None,PathLike])->bool:
380-
ifnotis_win:
380+
ifis_win:
381+
# is_win seems to be true only for Windows-native pythons
382+
# cygwin has os.name = posix, I think
381383
returnFalse
382384

383385
ifgit_executableisNone:

‎test/test_docs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# This module is part of GitPython and is released under
66
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
77
importos
8+
importsys
9+
10+
importpytest
811

912
fromtest.libimportTestBase
1013
fromtest.lib.helperimportwith_rw_directory
@@ -475,6 +478,11 @@ def test_references_and_objects(self, rw_dir):
475478

476479
repo.git.clear_cache()
477480

481+
@pytest.mark.xfail(
482+
sys.platform=="cygwin",
483+
reason="Cygwin GitPython can't find SHA for submodule",
484+
raises=ValueError
485+
)
478486
deftest_submodules(self):
479487
# [1-test_submodules]
480488
repo=self.rorepo

‎test/test_repo.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
importos
1212
importpathlib
1313
importpickle
14+
importsys
1415
importtempfile
1516
fromunittestimportmock,skipIf,SkipTest
1617

18+
importpytest
19+
1720
fromgitimport (
1821
InvalidGitRepositoryError,
1922
Repo,
@@ -903,6 +906,11 @@ def test_repo_odbtype(self):
903906
target_type=GitCmdObjectDB
904907
self.assertIsInstance(self.rorepo.odb,target_type)
905908

909+
@pytest.mark.xfail(
910+
sys.platform=="cygwin",
911+
reason="Cygwin GitPython can't find submodule SHA",
912+
raises=ValueError
913+
)
906914
deftest_submodules(self):
907915
self.assertEqual(len(self.rorepo.submodules),1)# non-recursive
908916
self.assertGreaterEqual(len(list(self.rorepo.iter_submodules())),2)

‎test/test_submodule.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
44
importos
55
importshutil
6+
importsys
67
fromunittestimportskipIf
78

9+
importpytest
10+
811
importgit
912
fromgit.cmdimportGit
1013
fromgit.compatimportis_win
@@ -437,6 +440,11 @@ def test_base_rw(self, rwrepo):
437440
deftest_base_bare(self,rwrepo):
438441
self._do_base_tests(rwrepo)
439442

443+
@pytest.mark.xfail(
444+
sys.platform=="cygwin",
445+
reason="Cygwin GitPython can't find submodule SHA",
446+
raises=ValueError
447+
)
440448
@skipIf(
441449
HIDE_WINDOWS_KNOWN_ERRORS,
442450
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp