瀏覽代碼

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

Jelmer Vernooij 6 年之前
父節點
當前提交
d55d4a248e
共有 3 個文件被更改,包括 9 次插入1 次删除
  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.
    (Jelmer Vernooij)
 
+ * Support plain strings as refspec arguments to
+   ``dulwich.porcelain.push``. (Jelmer Vernooij)
+
  BUG FIXES
 
  *  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
     :raise KeyError: If one of the refs can not be found
     """
+    refspec = to_bytes(refspec)
     if refspec.startswith(b"+"):
         force = True
         refspec = refspec[1:]
     else:
         force = False
-    refspec = to_bytes(refspec)
     if b":" in refspec:
         (lh, rh) = refspec.split(b":")
     else:

+ 5 - 0
dulwich/tests/test_objectspec.py

@@ -174,6 +174,11 @@ class ParseReftupleTests(TestCase):
         self.assertEqual((b"refs/heads/foo", None, False),
                          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):