diff options
| -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 e1e20463..45a2d257 100644 --- a/git_config.py +++ b/git_config.py | |||
| @@ -442,8 +442,30 @@ class Remote(object): | |||
| 442 | self._Get('fetch', all=True)) | 442 | self._Get('fetch', all=True)) |
| 443 | self._review_protocol = None | 443 | self._review_protocol = None |
| 444 | 444 | ||
| 445 | def _InsteadOf(self): | ||
| 446 | globCfg = GitConfig.ForUser() | ||
| 447 | urlList = globCfg.GetSubSections('url') | ||
| 448 | longest = "" | ||
| 449 | longestUrl = "" | ||
| 450 | |||
| 451 | for url in urlList: | ||
| 452 | key = "url." + url + ".insteadOf" | ||
| 453 | insteadOfList = globCfg.GetString(key, all=True) | ||
| 454 | |||
| 455 | for insteadOf in insteadOfList: | ||
| 456 | if self.url.startswith(insteadOf) \ | ||
| 457 | and len(insteadOf) > len(longest): | ||
| 458 | longest = insteadOf | ||
| 459 | longestUrl = url | ||
| 460 | |||
| 461 | if len(longest) == 0: | ||
| 462 | return self.url | ||
| 463 | |||
| 464 | return self.url.replace(longest, longestUrl, 1) | ||
| 465 | |||
| 445 | def PreConnectFetch(self): | 466 | def PreConnectFetch(self): |
| 446 | return _preconnect(self.url) | 467 | connectionUrl = self._InsteadOf() |
| 468 | return _preconnect(connectionUrl) | ||
| 447 | 469 | ||
| 448 | @property | 470 | @property |
| 449 | def ReviewProtocol(self): | 471 | def ReviewProtocol(self): |
