summaryrefslogtreecommitdiff
path: root/git/remote.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-08 09:45:50 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-08 09:45:50 +0100
commitf7b7eb6245e7d7c4535975268a9be936e2c59dc8 (patch)
treebdc6c5aa710632cc60e2c31ab08882c1e8b0d958 /git/remote.py
parentc7887c66483ffa9a839ecf1a53c5ef718dcd1d2d (diff)
downloadgitpython-f7b7eb6245e7d7c4535975268a9be936e2c59dc8.tar.gz
Added Remote.exists() method, and test. Fixes #229
Diffstat (limited to 'git/remote.py')
-rw-r--r--git/remote.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/git/remote.py b/git/remote.py
index 4d249004..deddd1f4 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -397,6 +397,19 @@ class Remote(LazyMixin, Iterable):
def __hash__(self):
return hash(self.name)
+ def exists(self):
+ """:return: True if this is a valid, existing remote.
+ Valid remotes have an entry in the repository's configuration"""
+ try:
+ self.config_reader.get('url')
+ return True
+ except cp.NoOptionError:
+ # we have the section at least ...
+ return True
+ except cp.NoSectionError:
+ return False
+ # end
+
@classmethod
def iter_items(cls, repo):
""":return: Iterator yielding Remote objects of the given repository"""