Browse Source

Add test for subject parsing in git_am_patch_split.

Jelmer Vernooij 14 years ago
parent
commit
e6d4bf8b87
2 changed files with 4 additions and 1 deletions
  1. 2 1
      dulwich/patch.py
  2. 2 0
      dulwich/tests/test_patch.py

+ 2 - 1
dulwich/patch.py

@@ -155,7 +155,8 @@ def git_am_patch_split(f):
     c.author = msg["from"]
     c.committer = msg["from"]
     if msg["subject"].startswith("[PATCH"):
-        subject = msg["subject"].split("]", 1)[1][1:]
+        close = msg["subject"].index("] ")
+        subject = msg["subject"][close+2:]
     else:
         subject = msg["subject"]
     c.message = subject

+ 2 - 0
dulwich/tests/test_patch.py

@@ -82,6 +82,8 @@ Subject: [PATCH 1/2] Remove executable bit from prey.ico (triggers a lintian war
         c, diff, version = git_am_patch_split(StringIO(text))
         self.assertEquals("Jelmer Vernooij <jelmer@samba.org>", c.committer)
         self.assertEquals("Jelmer Vernooij <jelmer@samba.org>", c.author)
+        self.assertEquals("Remove executable bit from prey.ico "
+            "(triggers a lintian warning).", c.message)
         self.assertEquals(""" pixmaps/prey.ico |  Bin 9662 -> 9662 bytes
  1 files changed, 0 insertions(+), 0 deletions(-)
  mode change 100755 => 100644 pixmaps/prey.ico