| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,5 +19,6 @@ Contributors are: | |||
| 19 | 19 | -Timothy B. Hartman <tbhartman _at_ gmail.com> | |
| 20 | 20 | -Konstantin Popov <konstantin.popov.89 _at_ yandex.ru> | |
| 21 | 21 | -Peter Jones <pjones _at_ redhat.com> | |
| 22 | + -Alexis Horgix Chotard | ||
| 22 | 23 | ||
| 23 | 24 | Portions derived from other open source works and are clearly marked. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ | |||
| 31 | 31 | ) | |
| 32 | 32 | from git.exc import CommandError | |
| 33 | 33 | from git.odict import OrderedDict | |
| 34 | - from git.util import is_cygwin_git, cygpath | ||
| 34 | + from git.util import is_cygwin_git, cygpath, expand_path | ||
| 35 | 35 | ||
| 36 | 36 | from .exc import ( | |
| 37 | 37 | GitCommandError, | |
@@ -405,7 +405,7 @@ def __init__(self, working_dir=None): | |||
| 405 | 405 | It is meant to be the working tree directory if available, or the | |
| 406 | 406 | .git directory in case of bare repositories.""" | |
| 407 | 407 | super(Git, self).__init__() | |
| 408 | - self._working_dir = working_dir | ||
| 408 | + self._working_dir = expand_path(working_dir) | ||
| 409 | 409 | self._git_options = () | |
| 410 | 410 | self._persistent_git_options = [] | |
| 411 | 411 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ | |||
| 29 | 29 | from git.objects import Submodule, RootModule, Commit | |
| 30 | 30 | from git.refs import HEAD, Head, Reference, TagReference | |
| 31 | 31 | from git.remote import Remote, add_progress, to_progress_instance | |
| 32 | - from git.util import Actor, finalize_process, decygpath, hex_to_bin | ||
| 32 | + from git.util import Actor, finalize_process, decygpath, hex_to_bin, expand_path | ||
| 33 | 33 | import os.path as osp | |
| 34 | 34 | ||
| 35 | 35 | from .fun import rev_parse, is_git_dir, find_submodule_git_dir, touch, find_worktree_git_dir | |
@@ -50,10 +50,6 @@ | |||
| 50 | 50 | __all__ = ('Repo',) | |
| 51 | 51 | ||
| 52 | 52 | ||
| 53 | - def _expand_path(p): | ||
| 54 | - return osp.normpath(osp.abspath(osp.expandvars(osp.expanduser(p)))) | ||
| 55 | - | ||
| 56 | - | ||
| 57 | 53 | class Repo(object): | |
| 58 | 54 | """Represents a git repository and allows you to query references, | |
| 59 | 55 | 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 | |||
| 121 | 117 | epath = os.getcwd() | |
| 122 | 118 | if Git.is_cygwin(): | |
| 123 | 119 | epath = decygpath(epath) | |
| 124 | - epath = _expand_path(epath or path or os.getcwd()) | ||
| 120 | + epath = expand_path(epath or path or os.getcwd()) | ||
| 125 | 121 | if not os.path.exists(epath): | |
| 126 | 122 | raise NoSuchPathError(epath) | |
| 127 | 123 | ||
@@ -148,7 +144,7 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals | |||
| 148 | 144 | sm_gitpath = find_worktree_git_dir(dotgit) | |
| 149 | 145 | ||
| 150 | 146 | if sm_gitpath is not None: | |
| 151 | - self.git_dir = _expand_path(sm_gitpath) | ||
| 147 | + self.git_dir = expand_path(sm_gitpath) | ||
| 152 | 148 | self._working_tree_dir = curpath | |
| 153 | 149 | break | |
| 154 | 150 | ||
@@ -867,7 +863,7 @@ def init(cls, path=None, mkdir=True, odbt=DefaultDBType, **kwargs): | |||
| 867 | 863 | ||
| 868 | 864 | :return: ``git.Repo`` (the newly created repo)""" | |
| 869 | 865 | if path: | |
| 870 | - path = _expand_path(path) | ||
| 866 | + path = expand_path(path) | ||
| 871 | 867 | if mkdir and path and not osp.exists(path): | |
| 872 | 868 | os.makedirs(path, 0o755) | |
| 873 | 869 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -340,6 +340,13 @@ def finalize_process(proc, **kwargs): | |||
| 340 | 340 | ## TODO: No close proc-streams?? | |
| 341 | 341 | proc.wait(**kwargs) | |
| 342 | 342 | ||
| 343 | + | ||
| 344 | + def expand_path(p): | ||
| 345 | + try: | ||
| 346 | + return osp.normpath(osp.abspath(osp.expandvars(osp.expanduser(p)))) | ||
| 347 | + except: | ||
| 348 | + return None | ||
| 349 | + | ||
| 343 | 350 | #} END utilities | |
| 344 | 351 | ||
| 345 | 352 | #{ Classes | |
| Back | FazBrowse Home | New Git URL |
0 commit comments