summaryrefslogtreecommitdiff
path: root/git/remote.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-21 18:34:58 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-21 18:34:58 +0100
commite4d3809161fc54d6913c0c2c7f6a7b51eebe223f (patch)
tree1eebc9f43a1302c537da84e9a7219918da131f45 /git/remote.py
parente48e52001d5abad7b28a4ecadde63c78c3946339 (diff)
downloadgitpython-e4d3809161fc54d6913c0c2c7f6a7b51eebe223f.tar.gz
Added advance usage examples to tutorial and made minor fixes.
GIT_PYTHON_TRACE would actually fail (now) if we debugged archive operations. Related to #239
Diffstat (limited to 'git/remote.py')
-rw-r--r--git/remote.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/git/remote.py b/git/remote.py
index dbb82796..fcec5228 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -378,6 +378,8 @@ class Remote(LazyMixin, Iterable):
def _set_cache_(self, attr):
if attr == "_config_reader":
+ # NOTE: This is cached as __getattr__ is overridden to return remote config values implicitly, such as
+ # in print(r.pushurl)
self._config_reader = SectionConstraint(self.repo.config_reader(), self._config_section_name())
else:
super(Remote, self)._set_cache_(attr)
@@ -475,8 +477,13 @@ class Remote(LazyMixin, Iterable):
@classmethod
def remove(cls, repo, name):
- """Remove the remote with the given name"""
+ """Remove the remote with the given name
+ :return: the passed remote name to remove
+ """
repo.git.remote("rm", name)
+ if isinstance(name, cls):
+ name._clear_cache()
+ return name
# alias
rm = remove
@@ -489,11 +496,8 @@ class Remote(LazyMixin, Iterable):
self.repo.git.remote("rename", self.name, new_name)
self.name = new_name
- try:
- del(self._config_reader) # it contains cached values, section names are different now
- except AttributeError:
- pass
- # END handle exception
+ self._clear_cache()
+
return self
def update(self, **kwargs):
@@ -662,6 +666,13 @@ class Remote(LazyMixin, Iterable):
Hence you may simple type config.get("pushurl") to obtain the information"""
return self._config_reader
+ def _clear_cache(self):
+ try:
+ del(self._config_reader)
+ except AttributeError:
+ pass
+ # END handle exception
+
@property
def config_writer(self):
"""
@@ -676,9 +687,5 @@ class Remote(LazyMixin, Iterable):
writer = self.repo.config_writer()
# clear our cache to assure we re-read the possibly changed configuration
- try:
- del(self._config_reader)
- except AttributeError:
- pass
- # END handle exception
+ self._clear_cache()
return SectionConstraint(writer, self._config_section_name())