From 8cf3add90b3eb28778e1d62cec77e72e16609414 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 7 Mar 2014 12:16:49 +0000 Subject: Raise correct error on `morph checkout|branch` of repo with no morphs --- morphlib/plugins/branch_and_merge_new_plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py index 94b2381c..8c8a98e9 100644 --- a/morphlib/plugins/branch_and_merge_new_plugin.py +++ b/morphlib/plugins/branch_and_merge_new_plugin.py @@ -191,7 +191,7 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin): ws, root_url, system_branch, cached_repo, base_ref) as (sb, gd): if not self._checkout_has_systems(gd): - raise BranchRootHasNoSystemsError(base_ref) + raise BranchRootHasNoSystemsError(root_url, base_ref) def branch(self, args): @@ -252,7 +252,7 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin): gd.checkout(system_branch) if not self._checkout_has_systems(gd): - raise BranchRootHasNoSystemsError(base_ref) + raise BranchRootHasNoSystemsError(root_url, base_ref) def _save_dirty_morphologies(self, loader, sb, morphs): logging.debug('Saving dirty morphologies: start') -- cgit v1.2.1 From fbce0142fb9ff9c9187cdcb67bc3a2981e78ff69 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 7 Mar 2014 12:29:19 +0000 Subject: Fix `morph petrify` in cases where root repo URL has a trailing / gitdir._list_work_tree_files() needs to use os.relpath() instead of direct string manipulation to avoid chopping off the first line of every filename in cases where the base gitdir path string includes the trailing /. Unit test updated to catch this. --- morphlib/gitdir.py | 3 ++- morphlib/gitdir_tests.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/morphlib/gitdir.py b/morphlib/gitdir.py index f5ef0061..15079231 100644 --- a/morphlib/gitdir.py +++ b/morphlib/gitdir.py @@ -478,7 +478,8 @@ class GitDirectory(object): if dirpath == self.dirname and '.git' in subdirs: subdirs.remove('.git') for filename in filenames: - yield os.path.join(dirpath, filename)[len(self.dirname)+1:] + filepath = os.path.join(dirpath, filename) + yield os.path.relpath(filepath, start=self.dirname) def _list_files_in_ref(self, ref): tree = self.resolve_ref_to_tree(ref) diff --git a/morphlib/gitdir_tests.py b/morphlib/gitdir_tests.py index 8c312c1b..14b2a57a 100644 --- a/morphlib/gitdir_tests.py +++ b/morphlib/gitdir_tests.py @@ -82,9 +82,13 @@ class GitDirectoryContentsTests(unittest.TestCase): shutil.rmtree(self.tempdir) def test_lists_files_in_work_tree(self): + expected = ['bar.morph', 'baz.morph', 'foo.morph', 'quux'] + gd = morphlib.gitdir.GitDirectory(self.dirname) - self.assertEqual(sorted(gd.list_files()), - ['bar.morph', 'baz.morph', 'foo.morph', 'quux']) + self.assertEqual(sorted(gd.list_files()), expected) + + gd = morphlib.gitdir.GitDirectory(self.dirname + '/') + self.assertEqual(sorted(gd.list_files()), expected) def test_read_file_in_work_tree(self): gd = morphlib.gitdir.GitDirectory(self.dirname) -- cgit v1.2.1