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

correctly handleuname-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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
EliahKagan merged 16 commits intogitpython-developers:mainfromgcmarx:main
May 28, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
ec00872
add tests for is_cygwin_git
gcmarxMay 21, 2025
de5e57c
check for the existence/execute bit on the uname command before tryin…
gcmarxMay 21, 2025
428be1a
adding self to authors
gcmarxMay 21, 2025
58ff723
Revert "check for the existence/execute bit on the uname command befo…
gcmarxMay 22, 2025
7187984
use pathlib.Path instead of os.path.isfile
gcmarxMay 22, 2025
3f5a942
don't keep checking if sys.platform isn't 'cygwin'
gcmarxMay 22, 2025
226f4ff
check that uname_cmd points to a file; if uname_cmd were a directory,…
gcmarxMay 22, 2025
22d6284
don't use match-case, since it's a 3.10 feature
gcmarxMay 22, 2025
b1289ee
it's is_file(), not isfile()
gcmarxMay 22, 2025
cffa264
turns out f-strings before 3.8 don't support {variable=} notation, ta…
gcmarxMay 22, 2025
36a893b
add self to AUTHORS, add Emacs tempfiles to .gitignore
gcmarxMay 23, 2025
c441316
use `strings` instead of `uname` to detect cygwin
gcmarxMay 27, 2025
0df0818
debug printing
gcmarxMay 27, 2025
58f7710
Revert "debug printing"
gcmarxMay 28, 2025
1731c1e
Revert "use `strings` instead of `uname` to detect cygwin"
gcmarxMay 28, 2025
f3ab5d3
incorporate review feedback from @EliahKagan
gcmarxMay 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,8 @@ __pycache__/
# Transient editor files
*.swp
*~
\#*#
.#*#

# Editor configuration
nbproject
Expand Down
1 change: 1 addition & 0 deletionsAUTHORS
View file
Open in desktop
Original file line numberDiff line numberDiff 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.
10 changes: 9 additions & 1 deletiongit/util.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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)):
_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,9 @@ 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"`.
# TODO: when py3.7 support is dropped, use the new interpolation f"{variable=}"
_logger.debug(f"sys.platform={sys.platform!r}, git_executable={git_executable!r}")
if sys.platform != "cygwin":
return False
elif git_executable is None:
return False
Expand Down
19 changes: 19 additions & 0 deletionstest/test_util.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,6 +34,7 @@
LockFile,
cygpath,
decygpath,
is_cygwin_git,
get_user_id,
remove_password_if_present,
rmtree,
Expand DownExpand Up@@ -349,6 +350,24 @@ 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):
# Currently we assume tests run on Cygwin use Cygwin git. See #533 and #1455 for background.
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

[8]ページ先頭

©2009-2025 Movatter.jp