|  | 
| 33 | 33 | from gitdb.util import join | 
| 34 | 34 | from git.compat import (defenc, force_text, is_win) | 
| 35 | 35 | import logging | 
|  | 36 | +from git.exc import GitCommandError | 
| 36 | 37 | 
 | 
| 37 | 38 | log = logging.getLogger('git.remote') | 
| 38 | 39 | 
 | 
| @@ -494,11 +495,22 @@ def delete_url(self, url, **kwargs): | 
| 494 | 495 | 
 | 
| 495 | 496 |     @property | 
| 496 | 497 |     def urls(self): | 
| 497 |  | -        """:return: Iterator yielding all configured URL targets on a remote | 
| 498 |  | -        as strings""" | 
| 499 |  | -        remote_details = self.repo.git.remote("get-url", "--all", self.name) | 
| 500 |  | -        for line in remote_details.split('\n'): | 
| 501 |  | -            yield line | 
|  | 498 | +        """:return: Iterator yielding all configured URL targets on a remote as strings""" | 
|  | 499 | +        try: | 
|  | 500 | +            remote_details = self.repo.git.remote("get-url", "--all", self.name) | 
|  | 501 | +            for line in remote_details.split('\n'): | 
|  | 502 | +                yield line | 
|  | 503 | +        except GitCommandError as ex: | 
|  | 504 | +            ## We are on git < 2.7 (i.e TravisCI as of Oct-2016), | 
|  | 505 | +            #  so `get-utl` command does not exist yet! | 
|  | 506 | +            #    see: https://github.com/gitpython-developers/GitPython/pull/528#issuecomment-252976319 | 
|  | 507 | +            #    and: http://stackoverflow.com/a/32991784/548792 | 
|  | 508 | +            # | 
|  | 509 | +            if 'Unknown subcommand: get-url' in str(ex): | 
|  | 510 | +                remote_details = self.repo.git.remote("show", self.name) | 
|  | 511 | +                for line in remote_details.split('\n'): | 
|  | 512 | +                    if '  Push  URL:' in line: | 
|  | 513 | +                        yield line.split(': ')[-1] | 
| 502 | 514 | 
 | 
| 503 | 515 |     @property | 
| 504 | 516 |     def refs(self): | 
|  | 
0 commit comments