diff options
author | Shawn O. Pearce <sop@google.com> | 2011-09-19 11:00:31 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2011-09-19 14:52:57 -0700 |
commit | 13111b4e97d8cccdba5da974de0996994c64c7e5 (patch) | |
tree | 817de88a6a4cc406dca1dbb93cdea4ee34c7f903 /git_config.py | |
parent | bd0312a4841e9488cf43ae4afb3b58d44eebbbb1 (diff) | |
download | git-repo-13111b4e97d8cccdba5da974de0996994c64c7e5.tar.gz |
Add support for url.*.insteadof
Teach repo how to resolve URLs using the url.insteadof feature
that C Git natively uses during clone, fetch or push. This will
later allow repo to resolve a URL before accessing it directly.
We do not want to pre-resolve things and store the resolved URL
into individual projects, as this makes it impossible for the
user to undo the insteadof mapping at a later date.
Change-Id: I0f62e811197c53fbc8a8be424e3cabf4ed07b4cb
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'git_config.py')
-rw-r--r-- | git_config.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/git_config.py b/git_config.py index 19c19f19..e4f4a0ab 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -198,6 +198,15 @@ class GitConfig(object): | |||
198 | except KeyError: | 198 | except KeyError: |
199 | return False | 199 | return False |
200 | 200 | ||
201 | def UrlInsteadOf(self, url): | ||
202 | """Resolve any url.*.insteadof references. | ||
203 | """ | ||
204 | for new_url in self.GetSubSections('url'): | ||
205 | old_url = self.GetString('url.%s.insteadof' % new_url) | ||
206 | if old_url is not None and url.startswith(old_url): | ||
207 | return new_url + url[len(old_url):] | ||
208 | return url | ||
209 | |||
201 | @property | 210 | @property |
202 | def _sections(self): | 211 | def _sections(self): |
203 | d = self._section_dict | 212 | d = self._section_dict |