summaryrefslogtreecommitdiffstats
path: root/apps/patchwork/models.py
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2009-02-12 22:01:09 +1100
committerJeremy Kerr <jk@ozlabs.org>2009-02-12 22:03:55 +1100
commit8de3e85466899d83adca7bafe9057a821458c5b4 (patch)
treed6f59f264ec7612e0fa24c480069db58aebdb3d9 /apps/patchwork/models.py
parent17e39712c3f9398f4aa6aae9f368f642af615eab (diff)
downloadpatchwork-8de3e85466899d83adca7bafe9057a821458c5b4.tar.bz2
patchwork-8de3e85466899d83adca7bafe9057a821458c5b4.tar.xz
[mbox] Put ACKs before '---' updates
Update the Patch's mbox() function to split into '--- update' sections, allowing us to add Acks and Signoffs in the right place Add tests too. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/models.py')
-rw-r--r--apps/patchwork/models.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py
index a672f9a..cfc875f 100644
--- a/apps/patchwork/models.py
+++ b/apps/patchwork/models.py
@@ -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,6 +255,9 @@ class Patch(models.Model):
if body:
body += '\n'
+ if postscript:
+ body += '---\n' + postscript.strip() + '\n'
+
body += self.content
mail = PatchMbox(body)