|
@@ -671,6 +671,52 @@ class GetUnstagedChangesTests(TestCase):
|
|
|
|
|
|
self.assertEqual(list(changes), [b'foo1'])
|
|
|
|
|
|
+ def test_get_unstaged_changes_removed_replaced_by_directory(self):
|
|
|
+ """Unit test for get_unstaged_changes."""
|
|
|
+
|
|
|
+ repo_dir = tempfile.mkdtemp()
|
|
|
+ self.addCleanup(shutil.rmtree, repo_dir)
|
|
|
+ with Repo.init(repo_dir) as repo:
|
|
|
+
|
|
|
+
|
|
|
+ foo1_fullpath = os.path.join(repo_dir, 'foo1')
|
|
|
+ with open(foo1_fullpath, 'wb') as f:
|
|
|
+ f.write(b'origstuff')
|
|
|
+
|
|
|
+ repo.stage(['foo1'])
|
|
|
+ repo.do_commit(b'test status', author=b'author <email>',
|
|
|
+ committer=b'committer <email>')
|
|
|
+
|
|
|
+ os.remove(foo1_fullpath)
|
|
|
+ os.mkdir(foo1_fullpath)
|
|
|
+
|
|
|
+ changes = get_unstaged_changes(repo.open_index(), repo_dir)
|
|
|
+
|
|
|
+ self.assertEqual(list(changes), [b'foo1'])
|
|
|
+
|
|
|
+ def test_get_unstaged_changes_removed_replaced_by_link(self):
|
|
|
+ """Unit test for get_unstaged_changes."""
|
|
|
+
|
|
|
+ repo_dir = tempfile.mkdtemp()
|
|
|
+ self.addCleanup(shutil.rmtree, repo_dir)
|
|
|
+ with Repo.init(repo_dir) as repo:
|
|
|
+
|
|
|
+
|
|
|
+ foo1_fullpath = os.path.join(repo_dir, 'foo1')
|
|
|
+ with open(foo1_fullpath, 'wb') as f:
|
|
|
+ f.write(b'origstuff')
|
|
|
+
|
|
|
+ repo.stage(['foo1'])
|
|
|
+ repo.do_commit(b'test status', author=b'author <email>',
|
|
|
+ committer=b'committer <email>')
|
|
|
+
|
|
|
+ os.remove(foo1_fullpath)
|
|
|
+ os.symlink(os.path.dirname(foo1_fullpath), foo1_fullpath)
|
|
|
+
|
|
|
+ changes = get_unstaged_changes(repo.open_index(), repo_dir)
|
|
|
+
|
|
|
+ self.assertEqual(list(changes), [b'foo1'])
|
|
|
+
|
|
|
|
|
|
class TestValidatePathElement(TestCase):
|
|
|
|