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 From 79a36a54b8891839b455c2f39c5d7bc4331a4e03 Mon Sep 17 00:00:00 2001 From: "Odegard, Ken" Date: Tue, 25 Jul 2017 10:09:52 -0500 Subject: Minor additional cleanup Added additional information in the import warning/error that tells the user how to silence the warning/error. Also added a GIT_OK variable that allows for a quick check whether the refresh has succeeded instead of needing to test an actual git command. --- git/remote.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index b6ac66cb..39b72249 100644 --- a/git/remote.py +++ b/git/remote.py @@ -221,7 +221,8 @@ class FetchInfo(object): @classmethod def refresh(cls): - """This gets called by the setup function (see the top level __init__). + """This gets called by the refresh function (see the top level + __init__). """ # clear the old values in _flag_map try: -- cgit v1.2.1