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

usesys.platform == "cygwin" to figure out when we are using cygwin#2027

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

Open
gcmarx wants to merge2 commits intogitpython-developers:main
base:main
Choose a base branch
Loading
fromgcmarx:sys-platform-detect-cygwin

Conversation

gcmarx
Copy link
Contributor

The current logic for detecting cygwin is:

  • ifsys.platform == "win32", then it's not cygwin
  • if the passed-in git executable is None, then it's not cygwin git
  • finally, is there auname executable in the same folder as the git executable, and if so, does the output of that command include"CYGWIN"? if so, then it's cygwin

In thepython 3.7 docs for sys.platform, Cygwin systems havesys.platform == "cygwin". Since Python 3.7 is the oldest version still supported by GitPython, it stands to reason that we can rely on that being true for all supported Python versions.

The logic I propose is:

  • if the git executable you passed in is None, it's not cygwin git
  • ifsys.platform == 'cygwin', then it's cygwin git

This is simple enough for a single expression, so I replaced the body of theis_cygwin function with that expression and removedis_cygwin_git and friends completely.

I don't know if there's such a thing assys.platform == 'cygwin' and thegit not being cygwingit, but if there is, I don't think the existing code deals with that anyway, so this seems to return the same result and would fail in the same way.

@gcmarx
Copy link
ContributorAuthor

only this PR or#2026 should be merged

Copy link

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR simplifies the detection of Cygwin Git by replacing the former multi-step logic with a concise check that relies on sys.platform.

  • Removed deprecated functions and caching logic for Cygwin detection.
  • Updated the Git command interface to directly use sys.platform and the Git executable's existence.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

FileDescription
git/util.pyRemoved the py_where and _is_cygwin_git functions along with unused imports.
git/cmd.pyUpdated the is_cygwin method to use a simplified sys.platform check.

@@ -661,7 +660,7 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:

@classmethod
def is_cygwin(cls) -> bool:
returnis_cygwin_git(cls.GIT_PYTHON_GIT_EXECUTABLE)
return cls.GIT_PYTHON_GIT_EXECUTABLE is not None and sys.platform == "cygwin"
Copy link
Preview

CopilotAIMay 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Consider adding an inline comment explaining that sys.platform being 'cygwin' reliably indicates a Cygwin environment per Python 3.7+, to improve clarity for future maintainers.

Copilot uses AI. Check for mistakes.

@gcmarxgcmarx changed the titleuse 'sys.platform == "cygwin"' to figure out when we are using cygwinusesys.platform == "cygwin" to figure out when we are using cygwinMay 23, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@gcmarx

[8]ページ先頭

©2009-2025 Movatter.jp