| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,5 +20,6 @@ Contributors are: | |||
| 20 | 20 | -Konstantin Popov <konstantin.popov.89 _at_ yandex.ru> | |
| 21 | 21 | -Peter Jones <pjones _at_ redhat.com> | |
| 22 | 22 | -Ken Odegard <ken.odegard _at_ gmail.com> | |
| 23 | + -Alexis Horgix Chotard | ||
| 23 | 24 | ||
| 24 | 25 | Portions derived from other open source works and are clearly marked. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,5 +14,5 @@ release: clean | |||
| 14 | 14 | ||
| 15 | 15 | force_release: clean | |
| 16 | 16 | git push --tags | |
| 17 | - python setup.py sdist bdist_wheel | ||
| 17 | + python3 setup.py sdist bdist_wheel | ||
| 18 | 18 | twine upload -s -i byronimo@gmail.com dist/* | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1 +1 @@ | |||
| 1 | - 2.1.5 | ||
| 1 | + 2.1.6 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,23 +35,26 @@ def _init_externals(): | |||
| 35 | 35 | ||
| 36 | 36 | #{ Imports | |
| 37 | 37 | ||
| 38 | - from git.config import GitConfigParser # @NoMove @IgnorePep8 | ||
| 39 | - from git.objects import * # @NoMove @IgnorePep8 | ||
| 40 | - from git.refs import * # @NoMove @IgnorePep8 | ||
| 41 | - from git.diff import * # @NoMove @IgnorePep8 | ||
| 42 | - from git.exc import * # @NoMove @IgnorePep8 | ||
| 43 | - from git.db import * # @NoMove @IgnorePep8 | ||
| 44 | - from git.cmd import Git # @NoMove @IgnorePep8 | ||
| 45 | - from git.repo import Repo # @NoMove @IgnorePep8 | ||
| 46 | - from git.remote import * # @NoMove @IgnorePep8 | ||
| 47 | - from git.index import * # @NoMove @IgnorePep8 | ||
| 48 | - from git.util import ( # @NoMove @IgnorePep8 | ||
| 49 | - LockFile, | ||
| 50 | - BlockingLockFile, | ||
| 51 | - Stats, | ||
| 52 | - Actor, | ||
| 53 | - rmtree, | ||
| 54 | - ) | ||
| 38 | + from git.exc import * # @NoMove @IgnorePep8 | ||
| 39 | + try: | ||
| 40 | + from git.config import GitConfigParser # @NoMove @IgnorePep8 | ||
| 41 | + from git.objects import * # @NoMove @IgnorePep8 | ||
| 42 | + from git.refs import * # @NoMove @IgnorePep8 | ||
| 43 | + from git.diff import * # @NoMove @IgnorePep8 | ||
| 44 | + from git.db import * # @NoMove @IgnorePep8 | ||
| 45 | + from git.cmd import Git # @NoMove @IgnorePep8 | ||
| 46 | + from git.repo import Repo # @NoMove @IgnorePep8 | ||
| 47 | + from git.remote import * # @NoMove @IgnorePep8 | ||
| 48 | + from git.index import * # @NoMove @IgnorePep8 | ||
| 49 | + from git.util import ( # @NoMove @IgnorePep8 | ||
| 50 | + LockFile, | ||
| 51 | + BlockingLockFile, | ||
| 52 | + Stats, | ||
| 53 | + Actor, | ||
| 54 | + rmtree, | ||
| 55 | + ) | ||
| 56 | + except GitError as exc: | ||
| 57 | + raise ImportError('%s: %s' % (exc.__class__.__name__, exc)) | ||
| 55 | 58 | ||
| 56 | 59 | #} END imports | |
| 57 | 60 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,7 @@ | |||
| 32 | 32 | ) | |
| 33 | 33 | from git.exc import CommandError | |
| 34 | 34 | from git.odict import OrderedDict | |
| 35 | - from git.util import is_cygwin_git, cygpath | ||
| 35 | + from git.util import is_cygwin_git, cygpath, expand_path | ||
| 36 | 36 | ||
| 37 | 37 | from .exc import ( | |
| 38 | 38 | GitCommandError, | |
@@ -531,7 +531,7 @@ def __init__(self, working_dir=None): | |||
| 531 | 531 | It is meant to be the working tree directory if available, or the | |
| 532 | 532 | .git directory in case of bare repositories.""" | |
| 533 | 533 | super(Git, self).__init__() | |
| 534 | - self._working_dir = working_dir | ||
| 534 | + self._working_dir = expand_path(working_dir) | ||
| 535 | 535 | self._git_options = () | |
| 536 | 536 | self._persistent_git_options = [] | |
| 537 | 537 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -123,12 +123,12 @@ def _set_cache_(self, attr): | |||
| 123 | 123 | reader = self.config_reader() | |
| 124 | 124 | # default submodule values | |
| 125 | 125 | try: | |
| 126 | - self.path = reader.get_value('path') | ||
| 126 | + self.path = reader.get('path') | ||
| 127 | 127 | except cp.NoSectionError: | |
| 128 | 128 | raise ValueError("This submodule instance does not exist anymore in '%s' file" | |
| 129 | 129 | % osp.join(self.repo.working_tree_dir, '.gitmodules')) | |
| 130 | 130 | # end | |
| 131 | - self._url = reader.get_value('url') | ||
| 131 | + self._url = reader.get('url') | ||
| 132 | 132 | # git-python extension values - optional | |
| 133 | 133 | self._branch_path = reader.get_value(self.k_head_option, git.Head.to_full_path(self.k_head_default)) | |
| 134 | 134 | elif attr == '_name': | |
@@ -1168,11 +1168,11 @@ def iter_items(cls, repo, parent_commit='HEAD'): | |||
| 1168 | 1168 | ||
| 1169 | 1169 | for sms in parser.sections(): | |
| 1170 | 1170 | n = sm_name(sms) | |
| 1171 | - p = parser.get_value(sms, 'path') | ||
| 1172 | - u = parser.get_value(sms, 'url') | ||
| 1171 | + p = parser.get(sms, 'path') | ||
| 1172 | + u = parser.get(sms, 'url') | ||
| 1173 | 1173 | b = cls.k_head_default | |
| 1174 | 1174 | if parser.has_option(sms, cls.k_head_option): | |
| 1175 | - b = str(parser.get_value(sms, cls.k_head_option)) | ||
| 1175 | + b = str(parser.get(sms, cls.k_head_option)) | ||
| 1176 | 1176 | # END handle optional information | |
| 1177 | 1177 | ||
| 1178 | 1178 | # get the binsha | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,6 +36,10 @@ def delete(cls, repo, *refs, **kwargs): | |||
| 36 | 36 | # are generally ignored in the refs/ folder. We don't though | |
| 37 | 37 | # and delete remainders manually | |
| 38 | 38 | for ref in refs: | |
| 39 | + try: | ||
| 40 | + os.remove(osp.join(repo.common_dir, ref.path)) | ||
| 41 | + except OSError: | ||
| 42 | + pass | ||
| 39 | 43 | try: | |
| 40 | 44 | os.remove(osp.join(repo.git_dir, ref.path)) | |
| 41 | 45 | except OSError: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,14 @@ | |||
| 26 | 26 | __all__ = ["SymbolicReference"] | |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | + def _git_dir(repo, path): | ||
| 30 | + """ Find the git dir that's appropriate for the path""" | ||
| 31 | + name = "%s" % (path,) | ||
| 32 | + if name in ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'index', 'logs']: | ||
| 33 | + return repo.git_dir | ||
| 34 | + return repo.common_dir | ||
| 35 | + | ||
| 36 | + | ||
| 29 | 37 | class SymbolicReference(object): | |
| 30 | 38 | ||
| 31 | 39 | """Represents a special case of a reference such that this reference is symbolic. | |
@@ -71,16 +79,11 @@ def name(self): | |||
| 71 | 79 | ||
| 72 | 80 | @property | |
| 73 | 81 | def abspath(self): | |
| 74 | - return join_path_native(self.repo.git_dir, self.path) | ||
| 82 | + return join_path_native(_git_dir(self.repo, self.path), self.path) | ||
| 75 | 83 | ||
| 76 | 84 | @classmethod | |
| 77 | 85 | def _get_packed_refs_path(cls, repo): | |
| 78 | - try: | ||
| 79 | - commondir = open(osp.join(repo.git_dir, 'commondir'), 'rt').readlines()[0].strip() | ||
| 80 | - except (OSError, IOError): | ||
| 81 | - commondir = '.' | ||
| 82 | - repodir = osp.join(repo.git_dir, commondir) | ||
| 83 | - return osp.join(repodir, 'packed-refs') | ||
| 86 | + return osp.join(repo.common_dir, 'packed-refs') | ||
| 84 | 87 | ||
| 85 | 88 | @classmethod | |
| 86 | 89 | def _iter_packed_refs(cls, repo): | |
@@ -127,11 +130,12 @@ def dereference_recursive(cls, repo, ref_path): | |||
| 127 | 130 | # END recursive dereferencing | |
| 128 | 131 | ||
| 129 | 132 | @classmethod | |
| 130 | - def _get_ref_info_helper(cls, repo, repodir, ref_path): | ||
| 133 | + def _get_ref_info_helper(cls, repo, ref_path): | ||
| 131 | 134 | """Return: (str(sha), str(target_ref_path)) if available, the sha the file at | |
| 132 | 135 | rela_path points to, or None. target_ref_path is the reference we | |
| 133 | 136 | point to, or None""" | |
| 134 | 137 | tokens = None | |
| 138 | + repodir = _git_dir(repo, ref_path) | ||
| 135 | 139 | try: | |
| 136 | 140 | with open(osp.join(repodir, ref_path), 'rt') as fp: | |
| 137 | 141 | value = fp.read().rstrip() | |
@@ -169,16 +173,7 @@ def _get_ref_info(cls, repo, ref_path): | |||
| 169 | 173 | """Return: (str(sha), str(target_ref_path)) if available, the sha the file at | |
| 170 | 174 | rela_path points to, or None. target_ref_path is the reference we | |
| 171 | 175 | point to, or None""" | |
| 172 | - try: | ||
| 173 | - return cls._get_ref_info_helper(repo, repo.git_dir, ref_path) | ||
| 174 | - except ValueError: | ||
| 175 | - try: | ||
| 176 | - commondir = open(osp.join(repo.git_dir, 'commondir'), 'rt').readlines()[0].strip() | ||
| 177 | - except (OSError, IOError): | ||
| 178 | - commondir = '.' | ||
| 179 | - | ||
| 180 | - repodir = osp.join(repo.git_dir, commondir) | ||
| 181 | - return cls._get_ref_info_helper(repo, repodir, ref_path) | ||
| 176 | + return cls._get_ref_info_helper(repo, ref_path) | ||
| 182 | 177 | ||
| 183 | 178 | def _get_object(self): | |
| 184 | 179 | """ | |
@@ -433,7 +428,7 @@ def delete(cls, repo, path): | |||
| 433 | 428 | or just "myreference", hence 'refs/' is implied. | |
| 434 | 429 | Alternatively the symbolic reference to be deleted""" | |
| 435 | 430 | full_ref_path = cls.to_full_path(path) | |
| 436 | - abs_path = osp.join(repo.git_dir, full_ref_path) | ||
| 431 | + abs_path = osp.join(repo.common_dir, full_ref_path) | ||
| 437 | 432 | if osp.exists(abs_path): | |
| 438 | 433 | os.remove(abs_path) | |
| 439 | 434 | else: | |
@@ -484,8 +479,9 @@ def _create(cls, repo, path, resolve, reference, force, logmsg=None): | |||
| 484 | 479 | a proper symbolic reference. Otherwise it will be resolved to the | |
| 485 | 480 | corresponding object and a detached symbolic reference will be created | |
| 486 | 481 | instead""" | |
| 482 | + git_dir = _git_dir(repo, path) | ||
| 487 | 483 | full_ref_path = cls.to_full_path(path) | |
| 488 | - abs_ref_path = osp.join(repo.git_dir, full_ref_path) | ||
| 484 | + abs_ref_path = osp.join(git_dir, full_ref_path) | ||
| 489 | 485 | ||
| 490 | 486 | # figure out target data | |
| 491 | 487 | target = reference | |
@@ -559,8 +555,8 @@ def rename(self, new_path, force=False): | |||
| 559 | 555 | if self.path == new_path: | |
| 560 | 556 | return self | |
| 561 | 557 | ||
| 562 | - new_abs_path = osp.join(self.repo.git_dir, new_path) | ||
| 563 | - cur_abs_path = osp.join(self.repo.git_dir, self.path) | ||
| 558 | + new_abs_path = osp.join(_git_dir(self.repo, new_path), new_path) | ||
| 559 | + cur_abs_path = osp.join(_git_dir(self.repo, self.path), self.path) | ||
| 564 | 560 | if osp.isfile(new_abs_path): | |
| 565 | 561 | if not force: | |
| 566 | 562 | # if they point to the same file, its not an error | |
@@ -594,7 +590,7 @@ def _iter_items(cls, repo, common_path=None): | |||
| 594 | 590 | ||
| 595 | 591 | # walk loose refs | |
| 596 | 592 | # Currently we do not follow links | |
| 597 | - for root, dirs, files in os.walk(join_path_native(repo.git_dir, common_path)): | ||
| 593 | + for root, dirs, files in os.walk(join_path_native(repo.common_dir, common_path)): | ||
| 598 | 594 | if 'refs' not in root.split(os.sep): # skip non-refs subfolders | |
| 599 | 595 | refs_id = [d for d in dirs if d == 'refs'] | |
| 600 | 596 | if refs_id: | |
@@ -605,7 +601,7 @@ def _iter_items(cls, repo, common_path=None): | |||
| 605 | 601 | if f == 'packed-refs': | |
| 606 | 602 | continue | |
| 607 | 603 | abs_path = to_native_path_linux(join_path(root, f)) | |
| 608 | - rela_paths.add(abs_path.replace(to_native_path_linux(repo.git_dir) + '/', "")) | ||
| 604 | + rela_paths.add(abs_path.replace(to_native_path_linux(repo.common_dir) + '/', "")) | ||
| 609 | 605 | # END for each file in root directory | |
| 610 | 606 | # END for each directory to walk | |
| 611 | 607 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,6 +38,7 @@ | |||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | 40 | log = logging.getLogger('git.remote') | |
| 41 | + log.addHandler(logging.NullHandler()) | ||
| 41 | 42 | ||
| 42 | 43 | ||
| 43 | 44 | __all__ = ('RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote') | |
@@ -208,7 +209,7 @@ class FetchInfo(object): | |||
| 208 | 209 | NEW_TAG, NEW_HEAD, HEAD_UPTODATE, TAG_UPDATE, REJECTED, FORCED_UPDATE, \ | |
| 209 | 210 | FAST_FORWARD, ERROR = [1 << x for x in range(8)] | |
| 210 | 211 | ||
| 211 | - re_fetch_result = re.compile(r'^\s*(.) (\[?[\w\s\.$@]+\]?)\s+(.+) -> ([^\s]+)( \(.*\)?$)?') | ||
| 212 | + _re_fetch_result = re.compile(r'^\s*(.) (\[?[\w\s\.$@]+\]?)\s+(.+) -> ([^\s]+)( \(.*\)?$)?') | ||
| 212 | 213 | ||
| 213 | 214 | _flag_map = { | |
| 214 | 215 | '!': ERROR, | |
@@ -284,7 +285,7 @@ def _from_line(cls, repo, line, fetch_line): | |||
| 284 | 285 | ||
| 285 | 286 | fetch line is the corresponding line from FETCH_HEAD, like | |
| 286 | 287 | acb0fa8b94ef421ad60c8507b634759a472cd56c not-for-merge branch '0.1.7RC' of /tmp/tmpya0vairemote_repo""" | |
| 287 | - match = cls.re_fetch_result.match(line) | ||
| 288 | + match = cls._re_fetch_result.match(line) | ||
| 288 | 289 | if match is None: | |
| 289 | 290 | raise ValueError("Failed to parse line: %r" % line) | |
| 290 | 291 | ||
@@ -673,7 +674,7 @@ def _get_fetch_info_from_stderr(self, proc, progress): | |||
| 673 | 674 | continue | |
| 674 | 675 | ||
| 675 | 676 | # read head information | |
| 676 | - with open(osp.join(self.repo.git_dir, 'FETCH_HEAD'), 'rb') as fp: | ||
| 677 | + with open(osp.join(self.repo.common_dir, 'FETCH_HEAD'), 'rb') as fp: | ||
| 677 | 678 | fetch_head_info = [l.decode(defenc) for l in fp.readlines()] | |
| 678 | 679 | ||
| 679 | 680 | l_fil = len(fetch_info_lines) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments