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

Commit753e2da

Browse files
committed
completely remove 'is_cygwin_git' and use sys.platform instead
1 parentaa6b7e9 commit753e2da

File tree

2 files changed

+1
-86
lines changed

2 files changed

+1
-86
lines changed

‎git/cmd.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
fromgit.utilimport (
3333
cygpath,
3434
expand_path,
35-
is_cygwin_git,
3635
patch_env,
3736
remove_password_if_present,
3837
stream_copy,
@@ -661,7 +660,7 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
661660

662661
@classmethod
663662
defis_cygwin(cls)->bool:
664-
returnis_cygwin_git(cls.GIT_PYTHON_GIT_EXECUTABLE)
663+
returncls.GIT_PYTHON_GIT_EXECUTABLEisnotNoneandsys.platform=="cygwin"
665664

666665
@overload
667666
@classmethod

‎git/util.py

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
Files_TD,
9797
Has_id_attribute,
9898
HSH_TD,
99-
Literal,
10099
PathLike,
101100
Protocol,
102101
SupportsIndex,
@@ -344,44 +343,6 @@ def _get_exe_extensions() -> Sequence[str]:
344343
return ()
345344

346345

347-
defpy_where(program:str,path:Optional[PathLike]=None)->List[str]:
348-
"""Perform a path search to assist :func:`is_cygwin_git`.
349-
350-
This is not robust for general use. It is an implementation detail of
351-
:func:`is_cygwin_git`. When a search following all shell rules is needed,
352-
:func:`shutil.which` can be used instead.
353-
354-
:note:
355-
Neither this function nor :func:`shutil.which` will predict the effect of an
356-
executable search on a native Windows system due to a :class:`subprocess.Popen`
357-
call without ``shell=True``, because shell and non-shell executable search on
358-
Windows differ considerably.
359-
"""
360-
# From: http://stackoverflow.com/a/377028/548792
361-
winprog_exts=_get_exe_extensions()
362-
363-
defis_exec(fpath:str)->bool:
364-
return (
365-
osp.isfile(fpath)
366-
andos.access(fpath,os.X_OK)
367-
and (
368-
sys.platform!="win32"ornotwinprog_extsorany(fpath.upper().endswith(ext)forextinwinprog_exts)
369-
)
370-
)
371-
372-
progs= []
373-
ifnotpath:
374-
path=os.environ["PATH"]
375-
forfolderinstr(path).split(os.pathsep):
376-
folder=folder.strip('"')
377-
iffolder:
378-
exe_path=osp.join(folder,program)
379-
forfin [exe_path]+ ["%s%s"% (exe_path,e)foreinwinprog_exts]:
380-
ifis_exec(f):
381-
progs.append(f)
382-
returnprogs
383-
384-
385346
def_cygexpath(drive:Optional[str],path:str)->str:
386347
ifosp.isabs(path)andnotdrive:
387348
# Invoked from `cygpath()` directly with `D:Apps\123`?
@@ -447,51 +408,6 @@ def decygpath(path: PathLike) -> str:
447408
returnpath.replace("/","\\")
448409

449410

450-
#: Store boolean flags denoting if a specific Git executable
451-
#: is from a Cygwin installation (since `cache_lru()` unsupported on PY2).
452-
_is_cygwin_cache:Dict[str,Optional[bool]]= {}
453-
454-
455-
def_is_cygwin_git(git_executable:str)->bool:
456-
is_cygwin=_is_cygwin_cache.get(git_executable)# type: Optional[bool]
457-
ifis_cygwinisNone:
458-
is_cygwin=False
459-
try:
460-
git_dir=osp.dirname(git_executable)
461-
ifnotgit_dir:
462-
res=py_where(git_executable)
463-
git_dir=osp.dirname(res[0])ifreselse""
464-
465-
# Just a name given, not a real path.
466-
uname_cmd=osp.join(git_dir,"uname")
467-
process=subprocess.Popen([uname_cmd],stdout=subprocess.PIPE,universal_newlines=True)
468-
uname_out,_=process.communicate()
469-
# retcode = process.poll()
470-
is_cygwin="CYGWIN"inuname_out
471-
exceptExceptionasex:
472-
_logger.debug("Failed checking if running in CYGWIN due to: %r",ex)
473-
_is_cygwin_cache[git_executable]=is_cygwin
474-
475-
returnis_cygwin
476-
477-
478-
@overload
479-
defis_cygwin_git(git_executable:None)->Literal[False]: ...
480-
481-
482-
@overload
483-
defis_cygwin_git(git_executable:PathLike)->bool: ...
484-
485-
486-
defis_cygwin_git(git_executable:Union[None,PathLike])->bool:
487-
ifsys.platform=="win32":# TODO: See if we can use `sys.platform != "cygwin"`.
488-
returnFalse
489-
elifgit_executableisNone:
490-
returnFalse
491-
else:
492-
return_is_cygwin_git(str(git_executable))
493-
494-
495411
defget_user_id()->str:
496412
""":return: String identifying the currently active system user as ``name@node``"""
497413
return"%s@%s"% (getpass.getuser(),platform.node())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp