summaryrefslogtreecommitdiff
path: root/git/remote.py
diff options
context:
space:
mode:
authorOdegard, Ken <ken.odegard@gmail.com>2017-07-09 19:53:38 +0200
committerOdegard, Ken <ken.odegard@gmail.com>2017-07-09 19:53:38 +0200
commitfeed81ea1a332dc415ea9010c8b5204473a51bdf (patch)
tree9d1ea2b94980bad734a360c8e476e0e871032d42 /git/remote.py
parenta962464c1504d716d4acee7770d8831cd3a84b48 (diff)
downloadgitpython-feed81ea1a332dc415ea9010c8b5204473a51bdf.tar.gz
Moved setup function into top level __init__
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.
Diffstat (limited to 'git/remote.py')
-rw-r--r--git/remote.py40
1 files changed, 30 insertions, 10 deletions
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):
"""