← Back to team overview

dulwich-users team mailing list archive

[PATCH 05/33] object_store: Fix return type of MemoryObjectStore.get_raw.

 

From: Dave Borowitz <dborowitz@xxxxxxxxxx>

Change-Id: I00481699ef71559b44976a17b564b5cba1f6c3e1
---
 NEWS                               |    2 ++
 dulwich/object_store.py            |    3 ++-
 dulwich/tests/test_object_store.py |    5 +++++
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 90b8291..a990242 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@
 
   * Prevent raising ValueError for correct refs in RefContainer.__delitem__.
 
+  * Correctly return a tuple from MemoryObjectStore.get_raw. (Dave Borowitz)
+
  API CHANGES
 
   * write_pack no longer takes the num_objects argument and requires an object
diff --git a/dulwich/object_store.py b/dulwich/object_store.py
index e61df1a..9309e50 100644
--- a/dulwich/object_store.py
+++ b/dulwich/object_store.py
@@ -540,7 +540,8 @@ class MemoryObjectStore(BaseObjectStore):
         :param name: sha for the object.
         :return: tuple with numeric type and object contents.
         """
-        return self[name].as_raw_string()
+        obj = self[name]
+        return obj.type_num, obj.as_raw_string()
 
     def __getitem__(self, name):
         return self._data[name]
diff --git a/dulwich/tests/test_object_store.py b/dulwich/tests/test_object_store.py
index 32b405c..314ef3f 100644
--- a/dulwich/tests/test_object_store.py
+++ b/dulwich/tests/test_object_store.py
@@ -178,6 +178,11 @@ class ObjectStoreTests(object):
         for obj in [testobject, tag1, tag2, tag3]:
             self.assertEqual(testobject, self.store.peel_sha(obj.id))
 
+    def test_get_raw(self):
+        self.store.add_object(testobject)
+        self.assertEqual((Blob.type_num, 'yummy data'),
+                         self.store.get_raw(testobject.id))
+
 
 class MemoryObjectStoreTests(ObjectStoreTests, TestCase):
 
-- 
1.7.3.1



References