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

Commit3eb497b

Browse files
authored
Merge pull requestgitpython-developers#664 from Horgix/path_expansion
util: move expand_path from repo/base and use it in Git class init
2 parents2dca537 +a2d6787 commit3eb497b

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

‎AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ Contributors are:
1919
-Timothy B. Hartman <tbhartman _at_ gmail.com>
2020
-Konstantin Popov <konstantin.popov.89 _at_ yandex.ru>
2121
-Peter Jones <pjones _at_ redhat.com>
22+
-Alexis Horgix Chotard
2223

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

‎git/cmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
)
3232
fromgit.excimportCommandError
3333
fromgit.odictimportOrderedDict
34-
fromgit.utilimportis_cygwin_git,cygpath
34+
fromgit.utilimportis_cygwin_git,cygpath,expand_path
3535

3636
from .excimport (
3737
GitCommandError,
@@ -405,7 +405,7 @@ def __init__(self, working_dir=None):
405405
It is meant to be the working tree directory if available, or the
406406
.git directory in case of bare repositories."""
407407
super(Git,self).__init__()
408-
self._working_dir=working_dir
408+
self._working_dir=expand_path(working_dir)
409409
self._git_options= ()
410410
self._persistent_git_options= []
411411

‎git/repo/base.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
fromgit.objectsimportSubmodule,RootModule,Commit
3030
fromgit.refsimportHEAD,Head,Reference,TagReference
3131
fromgit.remoteimportRemote,add_progress,to_progress_instance
32-
fromgit.utilimportActor,finalize_process,decygpath,hex_to_bin
32+
fromgit.utilimportActor,finalize_process,decygpath,hex_to_bin,expand_path
3333
importos.pathasosp
3434

3535
from .funimportrev_parse,is_git_dir,find_submodule_git_dir,touch,find_worktree_git_dir
@@ -50,10 +50,6 @@
5050
__all__= ('Repo',)
5151

5252

53-
def_expand_path(p):
54-
returnosp.normpath(osp.abspath(osp.expandvars(osp.expanduser(p))))
55-
56-
5753
classRepo(object):
5854
"""Represents a git repository and allows you to query references,
5955
gather commit information, generate diffs, create and clone repositories query
@@ -121,7 +117,7 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
121117
epath=os.getcwd()
122118
ifGit.is_cygwin():
123119
epath=decygpath(epath)
124-
epath=_expand_path(epathorpathoros.getcwd())
120+
epath=expand_path(epathorpathoros.getcwd())
125121
ifnotos.path.exists(epath):
126122
raiseNoSuchPathError(epath)
127123

@@ -148,7 +144,7 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
148144
sm_gitpath=find_worktree_git_dir(dotgit)
149145

150146
ifsm_gitpathisnotNone:
151-
self.git_dir=_expand_path(sm_gitpath)
147+
self.git_dir=expand_path(sm_gitpath)
152148
self._working_tree_dir=curpath
153149
break
154150

@@ -867,7 +863,7 @@ def init(cls, path=None, mkdir=True, odbt=DefaultDBType, **kwargs):
867863
868864
:return: ``git.Repo`` (the newly created repo)"""
869865
ifpath:
870-
path=_expand_path(path)
866+
path=expand_path(path)
871867
ifmkdirandpathandnotosp.exists(path):
872868
os.makedirs(path,0o755)
873869

‎git/util.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,13 @@ def finalize_process(proc, **kwargs):
340340
## TODO: No close proc-streams??
341341
proc.wait(**kwargs)
342342

343+
344+
defexpand_path(p):
345+
try:
346+
returnosp.normpath(osp.abspath(osp.expandvars(osp.expanduser(p))))
347+
except:
348+
returnNone
349+
343350
#} END utilities
344351

345352
#{ Classes

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp