]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/models.py
Add nacked-by tag
[patchwork] / apps / patchwork / models.py
index a672f9ad41ebe5f16879db45a655a42b2c5643c8..fa213dc03e8dfa9a068e11f780d581a358acdb4d 100644 (file)
@@ -227,6 +227,8 @@ class Patch(models.Model):
         return str.strip('-') + '.patch'
 
     def mbox(self):
+        postscript_re = re.compile('\n-{2,3} ?\n')
+
         comment = None
         try:
             comment = Comment.objects.get(patch = self, msgid = self.msgid)
@@ -237,6 +239,14 @@ class Patch(models.Model):
         if comment:
             body = comment.content.strip() + "\n"
 
+        parts = postscript_re.split(body, 1)
+        if len(parts) == 2:
+            (body, postscript) = parts
+            body = body.strip() + "\n"
+            postscript = postscript.strip() + "\n"
+        else:
+            postscript = ''
+
         responses = False
         for comment in Comment.objects.filter(patch = self) \
                 .exclude(msgid = self.msgid):
@@ -245,7 +255,10 @@ class Patch(models.Model):
         if body:
             body += '\n'
 
-        body += self.content
+        if postscript:
+            body += '---\n' + postscript.strip() + '\n'
+
+        body += '\n' + self.content
 
         mail = PatchMbox(body)
         mail['Subject'] = self.name
@@ -275,7 +288,7 @@ class Comment(models.Model):
     headers = models.TextField(blank = True)
     content = models.TextField()
 
-    response_re = re.compile('^(Acked|Signed-off|Nacked)-by: .*$', re.M)
+    response_re = re.compile('^(Tested|Reviewed|Acked|Signed-off|Nacked)-by: .*$', re.M | re.I)
 
     def patch_responses(self):
         return ''.join([ match.group(0) + '\n' for match in \
@@ -332,7 +345,7 @@ class Bundle(models.Model):
 
     def mbox(self):
         return '\n'.join([p.mbox().as_string(True) \
-                        for p in self.patches.all()])
+                        for p in self.ordered_patches()])
 
 class BundlePatch(models.Model):
     patch = models.ForeignKey(Patch)