diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-11-11 17:44:57 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2013-11-22 13:49:25 +0000 |
commit | 65fc7474c12b7b0fccd57810ba4f06d2fbca895a (patch) | |
tree | f8b5791cce76424175ec7e5333ab42659db388dc /morphlib/gitindex_tests.py | |
parent | 0b4e147009bffa7b720ee767633e3acf3bb68c3a (diff) | |
download | morph-65fc7474c12b7b0fccd57810ba4f06d2fbca895a.tar.gz |
gitindex: Add GitIndex.set_to_tree(treeish) method
This is used to set the state of the index to that of a previously known
commit. This is needed for the build without commit logic, so that
commits generated are that of the last commit in the repository and
anything uncommitted.
Diffstat (limited to 'morphlib/gitindex_tests.py')
-rw-r--r-- | morphlib/gitindex_tests.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/morphlib/gitindex_tests.py b/morphlib/gitindex_tests.py index db1e0e9b..2dcb5003 100644 --- a/morphlib/gitindex_tests.py +++ b/morphlib/gitindex_tests.py @@ -54,3 +54,12 @@ class GitIndexTests(unittest.TestCase): self.assertEqual(sorted(idx.get_uncommitted_changes()), [('D ', 'foo', None)]) # 'D ' means not in the index, but in the working tree + + def test_set_to_tree_alt_index(self): + gd = morphlib.gitdir.GitDirectory(self.dirname) + idx = gd.get_index(os.path.join(self.tempdir, 'index')) + # Read the HEAD commit into the index, which is the same as the + # working tree, so there are no uncommitted changes reported + # by status + idx.set_to_tree(gd.HEAD) + self.assertEqual(list(idx.get_uncommitted_changes()),[]) |