Browse Source

Support plain strings as refspec arguments to dulwich.porcelain.push.

Jelmer Vernooij 6 years ago
parent
commit
d55d4a248e
3 changed files with 9 additions and 1 deletions
  1. 3 0
      NEWS
  2. 1 1
      dulwich/objectspec.py
  3. 5 0
      dulwich/tests/test_objectspec.py

+ 3 - 0
NEWS

@@ -12,6 +12,9 @@
    applicable. Required for 3.8 compatibility.
    applicable. Required for 3.8 compatibility.
    (Jelmer Vernooij)
    (Jelmer Vernooij)
 
 
+ * Support plain strings as refspec arguments to
+   ``dulwich.porcelain.push``. (Jelmer Vernooij)
+
  BUG FIXES
  BUG FIXES
 
 
  *  Handle invalid ref that pretends to be a sub-folder under a valid ref.
  *  Handle invalid ref that pretends to be a sub-folder under a valid ref.

+ 1 - 1
dulwich/objectspec.py

@@ -87,12 +87,12 @@ def parse_reftuple(lh_container, rh_container, refspec):
     :return: A tuple with left and right ref
     :return: A tuple with left and right ref
     :raise KeyError: If one of the refs can not be found
     :raise KeyError: If one of the refs can not be found
     """
     """
+    refspec = to_bytes(refspec)
     if refspec.startswith(b"+"):
     if refspec.startswith(b"+"):
         force = True
         force = True
         refspec = refspec[1:]
         refspec = refspec[1:]
     else:
     else:
         force = False
         force = False
-    refspec = to_bytes(refspec)
     if b":" in refspec:
     if b":" in refspec:
         (lh, rh) = refspec.split(b":")
         (lh, rh) = refspec.split(b":")
     else:
     else:

+ 5 - 0
dulwich/tests/test_objectspec.py

@@ -174,6 +174,11 @@ class ParseReftupleTests(TestCase):
         self.assertEqual((b"refs/heads/foo", None, False),
         self.assertEqual((b"refs/heads/foo", None, False),
                          parse_reftuple(r, r, b"refs/heads/foo:"))
                          parse_reftuple(r, r, b"refs/heads/foo:"))
 
 
+    def test_default_with_string(self):
+        r = {b"refs/heads/foo": "bla"}
+        self.assertEqual((b"refs/heads/foo", b"refs/heads/foo", False),
+                         parse_reftuple(r, r, "foo"))
+
 
 
 class ParseReftuplesTests(TestCase):
 class ParseReftuplesTests(TestCase):