2
0
Эх сурвалжийг харах

Unit test for loading a git submodule

Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Nick Ward 13 жил өмнө
parent
commit
ae8ba7aee4

+ 1 - 0
dulwich/tests/data/repos/submodule/dotgit

@@ -0,0 +1 @@
+gitdir: ./a.git

+ 10 - 0
dulwich/tests/test_repository.py

@@ -323,6 +323,16 @@ class RepositoryTests(TestCase):
         r = self._repo = open_repo('ooo_merge.git')
         self.assertIsInstance(r.get_config_stack(), Config)
 
+    def test_submodule(self):
+        temp_dir = tempfile.mkdtemp()
+        repo_dir = os.path.join(os.path.dirname(__file__), 'data', 'repos')
+        shutil.copytree(os.path.join(repo_dir, 'a.git'),
+                        os.path.join(temp_dir, 'a.git'), symlinks=True)
+        rel = os.path.relpath(os.path.join(repo_dir, 'submodule'), temp_dir)
+        os.symlink(os.path.join(rel, 'dotgit'), os.path.join(temp_dir, '.git'))
+        r = Repo(temp_dir)
+        self.assertEqual(r.head(), 'a90fa2d900a17e99b433217e988c4eb4a2e9a097')
+
     def test_common_revisions(self):
         """
         This test demonstrates that ``find_common_revisions()`` actually returns