From feed81ea1a332dc415ea9010c8b5204473a51bdf Mon Sep 17 00:00:00 2001 From: "Odegard, Ken" Date: Sun, 9 Jul 2017 19:53:38 +0200 Subject: Moved setup function into top level __init__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Discovered that the remote module also relies on the git executable as such it also needs to be “refreshed” anytime the git executable is updated or changed. This was best solved by moving the setup function into the top level __init__ where the setup simply calls git.cmd.Git.refresh and git.remote.FetchInfo.refresh. --- git/remote.py | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index fd76e592..b6ac66cb 100644 --- a/git/remote.py +++ b/git/remote.py @@ -210,17 +210,37 @@ class FetchInfo(object): re_fetch_result = re.compile(r'^\s*(.) (\[?[\w\s\.$@]+\]?)\s+(.+) -> ([^\s]+)( \(.*\)?$)?') - _flag_map = {'!': ERROR, - '+': FORCED_UPDATE, - '*': 0, - '=': HEAD_UPTODATE, - ' ': FAST_FORWARD} + _flag_map = { + '!': ERROR, + '+': FORCED_UPDATE, + '*': 0, + '=': HEAD_UPTODATE, + ' ': FAST_FORWARD, + '-': TAG_UPDATE, + } - v = Git().version_info[:2] - if v >= (2, 10): - _flag_map['t'] = TAG_UPDATE - else: - _flag_map['-'] = TAG_UPDATE + @classmethod + def refresh(cls): + """This gets called by the setup function (see the top level __init__). + """ + # clear the old values in _flag_map + try: + del cls._flag_map["t"] + except KeyError: + pass + + try: + del cls._flag_map["-"] + except KeyError: + pass + + # set the value given the git version + if Git().version_info[:2] >= (2, 10): + cls._flag_map["t"] = cls.TAG_UPDATE + else: + cls._flag_map["-"] = cls.TAG_UPDATE + + return True def __init__(self, ref, flags, note='', old_commit=None, remote_ref_path=None): """ -- cgit v1.2.1