diff options
author | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-10-11 19:12:33 +0200 |
---|---|---|
committer | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-10-11 19:18:15 +0200 |
commit | 4b84602026c1cc7b9d83ab618efb6b48503e97af (patch) | |
tree | fccd7abe41a4d20d2829355b086820ee2091fdb0 /git | |
parent | a596e1284c8a13784fd51b2832815fc2515b8d6a (diff) | |
download | gitpython-4b84602026c1cc7b9d83ab618efb6b48503e97af.tar.gz |
remote, #528: fix prev cmt, Git<2.7 miss `get-url`
Diffstat (limited to 'git')
-rw-r--r-- | git/remote.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/git/remote.py b/git/remote.py index c28f7efb..663e29b1 100644 --- a/git/remote.py +++ b/git/remote.py @@ -33,6 +33,7 @@ from git.cmd import handle_process_output from gitdb.util import join from git.compat import (defenc, force_text, is_win) import logging +from git.exc import GitCommandError log = logging.getLogger('git.remote') @@ -494,11 +495,22 @@ class Remote(LazyMixin, Iterable): @property def urls(self): - """:return: Iterator yielding all configured URL targets on a remote - as strings""" - remote_details = self.repo.git.remote("get-url", "--all", self.name) - for line in remote_details.split('\n'): - yield line + """:return: Iterator yielding all configured URL targets on a remote as strings""" + try: + remote_details = self.repo.git.remote("get-url", "--all", self.name) + for line in remote_details.split('\n'): + yield line + except GitCommandError as ex: + ## We are on git < 2.7 (i.e TravisCI as of Oct-2016), + # so `get-utl` command does not exist yet! + # see: https://github.com/gitpython-developers/GitPython/pull/528#issuecomment-252976319 + # and: http://stackoverflow.com/a/32991784/548792 + # + if 'Unknown subcommand: get-url' in str(ex): + remote_details = self.repo.git.remote("show", self.name) + for line in remote_details.split('\n'): + if ' Push URL:' in line: + yield line.split(': ')[-1] @property def refs(self): |