From b3a92a22969b5131aacd7294a3105507125cc3ab Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 6 Mar 2014 15:53:05 +0000 Subject: Fix system branch dirname generation to avoid colons --- morphlib/sysbranchdir.py | 10 +++++++++- morphlib/sysbranchdir_tests.py | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'morphlib') diff --git a/morphlib/sysbranchdir.py b/morphlib/sysbranchdir.py index 1a8b898a..9d96e974 100644 --- a/morphlib/sysbranchdir.py +++ b/morphlib/sysbranchdir.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013-2014 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -74,6 +74,11 @@ class SystemBranchDirectory(object): 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. + ''' # Parse the URL. If the path component is absolute, we assume @@ -93,6 +98,9 @@ class SystemBranchDirectory(object): else: relative = repo_url + # Replace colons with slashes. + relative = '/'.join(relative.split(':')) + # Remove anyleading slashes, or os.path.join below will only # use the relative part (since it's absolute, not relative). relative = relative.lstrip('/') diff --git a/morphlib/sysbranchdir_tests.py b/morphlib/sysbranchdir_tests.py index 7ec8ef5c..8b40f69c 100644 --- a/morphlib/sysbranchdir_tests.py +++ b/morphlib/sysbranchdir_tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013-2014 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -149,7 +149,7 @@ class SystemBranchDirectoryTests(unittest.TestCase): self.system_branch_name) self.assertEqual( sb.get_git_directory_name('baserock:baserock/morph'), - os.path.join(self.root_directory, 'baserock:baserock/morph')) + os.path.join(self.root_directory, 'baserock/baserock/morph')) def test_reports_correct_name_for_git_directory_from_real_url(self): stripped = 'git.baserock.org/baserock/baserock/morph' @@ -169,7 +169,7 @@ class SystemBranchDirectoryTests(unittest.TestCase): self.system_branch_name) self.assertEqual( sb.get_filename('test:chunk', 'foo'), - os.path.join(self.root_directory, 'test:chunk/foo')) + os.path.join(self.root_directory, 'test/chunk/foo')) def test_reports_correct_name_for_git_directory_from_file_url(self): stripped = 'foobar/morphs' -- cgit v1.2.1