diff options
-rwxr-xr-x | morphlib/exts/rawdisk.write | 2 | ||||
-rwxr-xr-x | morphlib/exts/ssh-rsync.write | 4 | ||||
-rw-r--r-- | morphlib/git.py | 2 | ||||
-rw-r--r-- | morphlib/gitdir.py | 7 | ||||
-rw-r--r-- | morphlib/gitdir_tests.py | 7 |
5 files changed, 18 insertions, 4 deletions
diff --git a/morphlib/exts/rawdisk.write b/morphlib/exts/rawdisk.write index 1c2c5a84..12db4398 100755 --- a/morphlib/exts/rawdisk.write +++ b/morphlib/exts/rawdisk.write @@ -68,7 +68,7 @@ class RawDiskWriteExtension(morphlib.writeexts.WriteExtension): version_root = os.path.join(mp, 'systems', version_label) os.mkdir(version_root) - old_orig = os.path.join(mp, 'systems', 'factory', 'orig') + old_orig = os.path.join(mp, 'systems', 'default', 'orig') new_orig = os.path.join(version_root, 'orig') cliapp.runcmd( ['btrfs', 'subvolume', 'snapshot', old_orig, new_orig]) diff --git a/morphlib/exts/ssh-rsync.write b/morphlib/exts/ssh-rsync.write index 0ce89c7f..2d7258ba 100755 --- a/morphlib/exts/ssh-rsync.write +++ b/morphlib/exts/ssh-rsync.write @@ -92,8 +92,8 @@ class SshRsyncWriteExtension(morphlib.writeexts.WriteExtension): def get_old_orig(self, location, remote_mnt): '''Identify which subvolume to snapshot from''' - # rawdisk upgrades use 'factory' - return os.path.join(remote_mnt, 'systems', 'factory', 'orig') + # rawdisk upgrades use 'default' + return os.path.join(remote_mnt, 'systems', 'default', 'orig') @contextlib.contextmanager def _created_orig_subvolume(self, location, remote_mnt, version_root): diff --git a/morphlib/git.py b/morphlib/git.py index 70222acb..6a5a9a47 100644 --- a/morphlib/git.py +++ b/morphlib/git.py @@ -107,7 +107,7 @@ class Submodules(object): # list objects in the parent repo tree to find the commit # object that corresponds to the submodule commit = gitcmd(self.app.runcmd, 'ls-tree', self.ref, - submodule.name, cwd=self.repo) + submodule.path, cwd=self.repo) # read the commit hash from the output fields = commit.split() diff --git a/morphlib/gitdir.py b/morphlib/gitdir.py index 94cc5cb9..a0f35eef 100644 --- a/morphlib/gitdir.py +++ b/morphlib/gitdir.py @@ -552,6 +552,13 @@ class GitDirectory(object): def resolve_ref_to_tree(self, ref): return self._rev_parse('%s^{tree}' % ref) + def ref_exists(self, ref): + try: + self._rev_parse('%s^{commit}' % ref) + return True + except InvalidRefError: + return False + def _list_files_in_work_tree(self): for dirpath, subdirs, filenames in os.walk(self.dirname): if dirpath == self.dirname and '.git' in subdirs: diff --git a/morphlib/gitdir_tests.py b/morphlib/gitdir_tests.py index 42118fe2..55b3caa5 100644 --- a/morphlib/gitdir_tests.py +++ b/morphlib/gitdir_tests.py @@ -172,6 +172,13 @@ class GitDirectoryContentsTests(unittest.TestCase): self.assertEqual(len(tree), 40) self.assertNotEqual(commit, tree) + def test_ref_exists(self): + gd = morphlib.gitdir.GitDirectory(self.dirname) + self.assertFalse(gd.ref_exists('non-existant-ref')) + self.assertTrue(gd.ref_exists('master')) + self.assertFalse( + gd.ref_exists('0000000000000000000000000000000000000000')) + def test_store_blob_with_string(self): gd = morphlib.gitdir.GitDirectory(self.dirname) sha1 = gd.store_blob('test string') |