Browse Source

add tests for find_unique_abbrev.

Jelmer Vernooij 3 years ago
parent
commit
1562c4e3fc
1 changed files with 12 additions and 0 deletions
  1. 12 0
      dulwich/tests/test_porcelain.py

+ 12 - 0
dulwich/tests/test_porcelain.py

@@ -2813,3 +2813,15 @@ class WriteTreeTests(PorcelainTestCase):
 class ActiveBranchTests(PorcelainTestCase):
     def test_simple(self):
         self.assertEqual(b"master", porcelain.active_branch(self.repo))
+
+
+class FindUniqueAbbrevTests(PorcelainTestCase):
+
+    def test_simple(self):
+        c1, c2, c3 = build_commit_graph(
+            self.repo.object_store, [[1], [2, 1], [3, 1, 2]]
+        )
+        self.repo.refs[b"HEAD"] = c3.id
+        self.assertEqual(
+            c1.id.decode('ascii')[:7],
+            porcelain.find_unique_abbrev(self.repo.object_store, c1.id))