Fix Repository.__setitem__.
authorJelmer Vernooij <jelmer@samba.org>
Tue, 9 Mar 2010 13:15:31 +0000 (14:15 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 9 Mar 2010 13:15:31 +0000 (14:15 +0100)
dulwich/repo.py
dulwich/tests/test_repository.py

index 520fe575cceaf732f2d875f9f550b619d608e0e2..ef3e9ffe422d56e4afdfe000d9a0086ff4dd8541 100644 (file)
@@ -792,7 +792,8 @@ class BaseRepo(object):
                 self.refs[name] = value
             else:
                 raise TypeError(value)
-        raise ValueError(name)
+        else:
+            raise ValueError(name)
 
     def __delitem__(self, name):
         if name.startswith("refs") or name == "HEAD":
index 2634407c7aab5d83ce9cec1213ad27827a175ed8..14871c79e8596b2dbd5bb6c60d41aeee8fcc544e 100644 (file)
@@ -72,6 +72,12 @@ class RepositoryTests(unittest.TestCase):
         r = self._repo = open_repo('a.git')
         self.assertEqual(r.ref('refs/heads/master'),
                          'a90fa2d900a17e99b433217e988c4eb4a2e9a097')
+
+    def test_setitem(self):
+        r = self._repo = open_repo('a.git')
+        r["refs/tags/foo"] = 'a90fa2d900a17e99b433217e988c4eb4a2e9a097'
+        self.assertEquals('a90fa2d900a17e99b433217e988c4eb4a2e9a097',
+                          r["refs/tags/foo"].id)
   
     def test_get_refs(self):
         r = self._repo = open_repo('a.git')
@@ -235,6 +241,7 @@ THREES = "3" * 40
 FOURS = "4" * 40
 
 class PackedRefsFileTests(unittest.TestCase):
+
     def test_split_ref_line_errors(self):
         self.assertRaises(errors.PackedRefsException, _split_ref_line,
                           'singlefield')
@@ -283,6 +290,7 @@ class PackedRefsFileTests(unittest.TestCase):
 
 
 class RefsContainerTests(unittest.TestCase):
+
     def setUp(self):
         self._repo = open_repo('refs.git')
         self._refs = self._repo.refs