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

Appearance settings

correctly handle uname-cmd that doesn't point to an executable file #2026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
Loading
from
Open
1 change: 1 addition & 0 deletions 1 AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ Contributors are:
-Eliah Kagan <eliah.kagan _at_ gmail.com>
-Ethan Lin <et.repositories _at_ gmail.com>
-Jonas Scharpf <jonas.scharpf _at_ checkmk.com>
-Gordon Marx

Portions derived from other open source works and are clearly marked.
9 changes: 8 additions & 1 deletion 9 git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ def _is_cygwin_git(git_executable: str) -> bool:

# Just a name given, not a real path.
uname_cmd = osp.join(git_dir, "uname")

if not (pathlib.Path(uname_cmd).is_file() and os.access(uname_cmd, os.X_OK)):
Byron marked this conversation as resolved.
Show resolved Hide resolved
_logger.debug(f"Failed checking if running in CYGWIN: {uname_cmd} is not an executable")
_is_cygwin_cache[git_executable] = is_cygwin
return is_cygwin

process = subprocess.Popen([uname_cmd], stdout=subprocess.PIPE, universal_newlines=True)
uname_out, _ = process.communicate()
# retcode = process.poll()
Expand All @@ -484,7 +490,8 @@ def is_cygwin_git(git_executable: PathLike) -> bool: ...


def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool:
if sys.platform == "win32": # TODO: See if we can use `sys.platform != "cygwin"`.
_logger.debug(f"sys.platform = {sys.platform}, git_executable = {git_executable}")
if sys.platform != "cygwin":
return False
elif git_executable is None:
return False
Expand Down
18 changes: 18 additions & 0 deletions 18 test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
LockFile,
cygpath,
decygpath,
is_cygwin_git,
get_user_id,
remove_password_if_present,
rmtree,
Expand Down Expand Up @@ -349,6 +350,23 @@ def test_decygpath(self, wpath, cpath):
assert wcpath == wpath.replace("/", "\\"), cpath


class TestIsCygwinGit:
"""Tests for :func:`is_cygwin_git`"""

def test_on_path_executable(self):
if sys.platform == "cygwin":
assert is_cygwin_git("git")
else:
assert not is_cygwin_git("git")

def test_none_executable(self):
assert not is_cygwin_git(None)

def test_with_missing_uname(self):
"""Test for handling when `uname` isn't in the same directory as `git`"""
assert not is_cygwin_git("/bogus_path/git")


class _Member:
"""A member of an IterableList."""

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.