summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-03-06 15:53:05 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-03-06 19:25:00 +0000
commitb3a92a22969b5131aacd7294a3105507125cc3ab (patch)
treee977fcb8d65d34e3f32d610f5644182d4bb427be
parenta0fe3ebf760839ac6b95ff888ed79e0b88dd5f0e (diff)
downloadmorph-b3a92a22969b5131aacd7294a3105507125cc3ab.tar.gz
Fix system branch dirname generation to avoid colons
-rw-r--r--morphlib/sysbranchdir.py10
-rw-r--r--morphlib/sysbranchdir_tests.py6
2 files changed, 12 insertions, 4 deletions
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'