diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2014-08-12 18:09:13 +0100 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2014-08-12 18:09:13 +0100 |
commit | b2786c73c0f4d4b76f824e309598ce57065e30ab (patch) | |
tree | 1e18a61d37da2da8ba19ef39eae1265185a13e75 /morphlib/sysbranchdir.py | |
parent | 6241d4466599406e3ad0a176c70fcbecdfdd1b64 (diff) | |
parent | 0f9c9e2ff3c9afe00735fa986200ac5fdcc8f79e (diff) | |
download | morph-b2786c73c0f4d4b76f824e309598ce57065e30ab.tar.gz |
Merge branch 'baserock/richardmaw/misc-fixups'baserock/richardmaw/tmp
Reviewed-by: Daniel Silverstone
Reviewed-by: Pedro Alvarez
Diffstat (limited to 'morphlib/sysbranchdir.py')
-rw-r--r-- | morphlib/sysbranchdir.py | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/morphlib/sysbranchdir.py b/morphlib/sysbranchdir.py index b8953c2f..19fba695 100644 --- a/morphlib/sysbranchdir.py +++ b/morphlib/sysbranchdir.py @@ -68,19 +68,13 @@ class SystemBranchDirectory(object): value = cliapp.runcmd(['git', 'config', '-f', self._config_path, key]) return value.strip() - def get_git_directory_name(self, repo_url): - '''Return directory pathname for a given git repository. - - If the URL is a real one (not aliased), the schema and leading // - are removed from it, as is a .git suffix. - - Any colons in the URL path or network location are replaced - with slashes, so that directory paths do not contain colons. - This avoids problems with PYTHONPATH, PATH, and other things - that use colon as a separator. - - ''' + def _find_git_directory(self, repo_url): + for gd in self.list_git_directories(): + if gd.get_config('morph.repository') == repo_url: + return gd.dirname + return None + def _fabricate_git_directory_name(self, repo_url): # Parse the URL. If the path component is absolute, we assume # it's a real URL; otherwise, an aliased URL. parts = urlparse.urlparse(repo_url) @@ -107,6 +101,26 @@ class SystemBranchDirectory(object): return os.path.join(self.root_directory, relative) + def get_git_directory_name(self, repo_url): + '''Return directory pathname for a given git repository. + + If the repository has already been cloned, then it returns the + path to that, if not it will fabricate a path based on the url. + + If the URL is a real one (not aliased), the schema and leading // + are removed from it, as is a .git suffix. + + Any colons in the URL path or network location are replaced + with slashes, so that directory paths do not contain colons. + This avoids problems with PYTHONPATH, PATH, and other things + that use colon as a separator. + + ''' + found_repo = self._find_git_directory(repo_url) + if not found_repo: + return self._fabricate_git_directory_name(repo_url) + return found_repo + def get_filename(self, repo_url, relative): '''Return full pathname to a file in a checked out repository. |