diff options
Diffstat (limited to 'git_config.py')
-rw-r--r-- | git_config.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/git_config.py b/git_config.py index b6288219..4a42c047 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -461,8 +461,30 @@ class Remote(object): | |||
461 | self._Get('fetch', all=True)) | 461 | self._Get('fetch', all=True)) |
462 | self._review_protocol = None | 462 | self._review_protocol = None |
463 | 463 | ||
464 | def _InsteadOf(self): | ||
465 | globCfg = GitConfig.ForUser() | ||
466 | urlList = globCfg.GetSubSections('url') | ||
467 | longest = "" | ||
468 | longestUrl = "" | ||
469 | |||
470 | for url in urlList: | ||
471 | key = "url." + url + ".insteadOf" | ||
472 | insteadOfList = globCfg.GetString(key, all=True) | ||
473 | |||
474 | for insteadOf in insteadOfList: | ||
475 | if self.url.startswith(insteadOf) \ | ||
476 | and len(insteadOf) > len(longest): | ||
477 | longest = insteadOf | ||
478 | longestUrl = url | ||
479 | |||
480 | if len(longest) == 0: | ||
481 | return self.url | ||
482 | |||
483 | return self.url.replace(longest, longestUrl, 1) | ||
484 | |||
464 | def PreConnectFetch(self): | 485 | def PreConnectFetch(self): |
465 | return _preconnect(self.url) | 486 | connectionUrl = self._InsteadOf() |
487 | return _preconnect(connectionUrl) | ||
466 | 488 | ||
467 | @property | 489 | @property |
468 | def ReviewProtocol(self): | 490 | def ReviewProtocol(self): |