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

Commit8576534

Browse files
authored
Merge pull request#2026 from gcmarx/main
correctly handle `uname-cmd` that doesn't point to an executable file
2 parentsbf51609 +f3ab5d3 commit8576534

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

‎.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ __pycache__/
1010
# Transient editor files
1111
*.swp
1212
*~
13+
\#*#
14+
.#*#
1315

1416
# Editor configuration
1517
nbproject

‎AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ Contributors are:
5555
-Eliah Kagan <eliah.kagan _at_ gmail.com>
5656
-Ethan Lin <et.repositories _at_ gmail.com>
5757
-Jonas Scharpf <jonas.scharpf _at_ checkmk.com>
58+
-Gordon Marx
5859

5960
Portions derived from other open source works and are clearly marked.

‎git/util.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,12 @@ def _is_cygwin_git(git_executable: str) -> bool:
464464

465465
# Just a name given, not a real path.
466466
uname_cmd=osp.join(git_dir,"uname")
467+
468+
ifnot (pathlib.Path(uname_cmd).is_file()andos.access(uname_cmd,os.X_OK)):
469+
_logger.debug(f"Failed checking if running in CYGWIN:{uname_cmd} is not an executable")
470+
_is_cygwin_cache[git_executable]=is_cygwin
471+
returnis_cygwin
472+
467473
process=subprocess.Popen([uname_cmd],stdout=subprocess.PIPE,universal_newlines=True)
468474
uname_out,_=process.communicate()
469475
# retcode = process.poll()
@@ -484,7 +490,9 @@ def is_cygwin_git(git_executable: PathLike) -> bool: ...
484490

485491

486492
defis_cygwin_git(git_executable:Union[None,PathLike])->bool:
487-
ifsys.platform=="win32":# TODO: See if we can use `sys.platform != "cygwin"`.
493+
# TODO: when py3.7 support is dropped, use the new interpolation f"{variable=}"
494+
_logger.debug(f"sys.platform={sys.platform!r}, git_executable={git_executable!r}")
495+
ifsys.platform!="cygwin":
488496
returnFalse
489497
elifgit_executableisNone:
490498
returnFalse

‎test/test_util.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
LockFile,
3535
cygpath,
3636
decygpath,
37+
is_cygwin_git,
3738
get_user_id,
3839
remove_password_if_present,
3940
rmtree,
@@ -349,6 +350,24 @@ def test_decygpath(self, wpath, cpath):
349350
assertwcpath==wpath.replace("/","\\"),cpath
350351

351352

353+
classTestIsCygwinGit:
354+
"""Tests for :func:`is_cygwin_git`"""
355+
356+
deftest_on_path_executable(self):
357+
# Currently we assume tests run on Cygwin use Cygwin git. See #533 and #1455 for background.
358+
ifsys.platform=="cygwin":
359+
assertis_cygwin_git("git")
360+
else:
361+
assertnotis_cygwin_git("git")
362+
363+
deftest_none_executable(self):
364+
assertnotis_cygwin_git(None)
365+
366+
deftest_with_missing_uname(self):
367+
"""Test for handling when `uname` isn't in the same directory as `git`"""
368+
assertnotis_cygwin_git("/bogus_path/git")
369+
370+
352371
class_Member:
353372
"""A member of an IterableList."""
354373

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp