diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-08-08 15:09:57 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-08-14 16:26:53 +0000 |
commit | b6c7f1eb2c76ac3847d5b6da60b9c31a0a69d875 (patch) | |
tree | 59492ef096d0eeadff46e90513a5901315dda1a7 /morphlib | |
parent | b2e6814127f12fee3ce9bc5a9f40d20148353c2e (diff) | |
download | morph-b6c7f1eb2c76ac3847d5b6da60b9c31a0a69d875.tar.gz |
Add SystemBranchDirectory.get_filename method
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/sysbranchdir.py | 9 | ||||
-rw-r--r-- | morphlib/sysbranchdir_tests.py | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/morphlib/sysbranchdir.py b/morphlib/sysbranchdir.py index 7e278dce..827f150b 100644 --- a/morphlib/sysbranchdir.py +++ b/morphlib/sysbranchdir.py @@ -100,6 +100,15 @@ class SystemBranchDirectory(object): return os.path.join(self.root_directory, relative) + def get_filename(self, repo_url, relative): + '''Return full pathname to a file in a checked out repository. + + This is a convenience function. + + ''' + + return os.path.join(self.get_git_directory_name(repo_url), relative) + def clone_cached_repo(self, cached_repo, checkout_ref): '''Clone a cached git repository into the system branch directory. diff --git a/morphlib/sysbranchdir_tests.py b/morphlib/sysbranchdir_tests.py index e75122cc..7ee04c7d 100644 --- a/morphlib/sysbranchdir_tests.py +++ b/morphlib/sysbranchdir_tests.py @@ -162,6 +162,15 @@ class SystemBranchDirectoryTests(unittest.TestCase): sb.get_git_directory_name(url), os.path.join(self.root_directory, stripped)) + def test_reports_correct_path_for_file_in_repository(self): + sb = morphlib.sysbranchdir.create( + self.root_directory, + self.root_repository_url, + self.system_branch_name) + self.assertEqual( + sb.get_filename('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' url = 'file:///%s.git' % stripped |