From: W. Trevor King Date: Mon, 20 Jul 2009 18:30:40 +0000 (-0400) Subject: Added psuedo-header handling to be-handle-mail. X-Git-Tag: 1.0.0~62^2~46^2~14 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a408bd6c1d631ef4c1271b8d9574e4171ae85d2b;p=be.git Added psuedo-header handling to be-handle-mail. Many psuedo-headers had been ignored. Now they are all implemented. Getting this working exposed a few bugs in error message generation for Commands with IDs in their argument list. These bugs should now be fixed. --- diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail index a82f723..d1c9451 100755 --- a/interfaces/email/interactive/be-handle-mail +++ b/interfaces/email/interactive/be-handle-mail @@ -143,6 +143,8 @@ class ID (object): def __init__(self, command): self.command = command def extract_id(self): + if hasattr(self, "cached_id"): + return self.cached_id assert self.command.ret == 0, self.command.ret if self.command.command == u"new": regexp = re.compile(u"Created bug with ID (.*)") @@ -150,7 +152,12 @@ class ID (object): raise NotImplementedError, self.command.command match = regexp.match(self.command.stdout) assert len(match.groups()) == 1, str(match.groups()) - return match.group(1) + self.cached_id = match.group(1) + return self.cached_id + def __str__(self): + if self.command.ret != 0: + return "" % repr(self.command) + return "" % self.extract_id() class Command (object): """ @@ -178,7 +185,7 @@ class Command (object): self.stderr = None self.err = None def __str__(self): - return "" % (self.command, " ".join(self.args)) + return "" % (self.command, " ".join([str(s) for s in self.args])) def normalize_args(self): """ Expand any ID placeholders in self.args. @@ -409,15 +416,22 @@ class Message (object): args.append(summary) commands.append(Command(self, command, args)) comment_body = self._strip_footer(comment_body) + id = ID(commands[0]) if len(comment_body) > 0: command = u"comment" comment = u"Version: %s\n\n"%options[u"Version"] + comment_body args = [u"--author", self.author_addr(), u"--alt-id", self.message_id(), u"--content-type", mime_type] - args.append(ID(commands[0])) + args.append(id) args.append(u"-") commands.append(Command(self, u"comment", args, stdin=comment)) + for key,value in options.items(): + if key in [u"Version", u"Reporter"]: + continue # we've already handled this option + command = key.lower() + args = [id, value] + commands.append(Command(self, command, args)) elif tag_type == u"comment": command = u"comment" bug_id = value diff --git a/interfaces/email/interactive/examples/new b/interfaces/email/interactive/examples/new index b0bc3d7..c64db93 100644 --- a/interfaces/email/interactive/examples/new +++ b/interfaces/email/interactive/examples/new @@ -1,4 +1,4 @@ -From jdoe@example.com Fri Apr 18 11:18:58 2008 +From jdoe@example.com Fri Apr 18 12:00:00 2008 Message-ID: Date: Fri, 18 Apr 2008 12:00:00 +0000 From: John Doe @@ -7,6 +7,13 @@ Content-Transfer-Encoding: 8bit Subject: [be-bug:submit] Need tests for the email interface. Version: XYZ +Reporter: Jane Doe +Assign: Dick Tracy +Depend: 00f +Severity: critical +Status: assigned +Tag: topsecret +Target: Law&Order -- Goofy tagline not included, and no comment added.