diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2019-05-08 16:28:17 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-05-08 16:29:04 +0200 |
| commit | b12c1ab14cf7312fefd126d40968bb8cc322a960 (patch) | |
| tree | d6da340b65c09958288e1c12d55c68583c06b7d7 /pkg/email/parser.go | |
| parent | a7383bfac17332db9afdad436b6c06c48bfe4815 (diff) | |
dashboard/app: restore printing of email commands
After commit 9ad9ef29caa52714dd5faff167e4b61643e40a7e
we started saying "your command '3' is accepted"
because we use numbers now. Keep string representation
of the command when parsing and use it in reply emails.
Diffstat (limited to 'pkg/email/parser.go')
| -rw-r--r-- | pkg/email/parser.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pkg/email/parser.go b/pkg/email/parser.go index 2566ae1d5..0f4e1d40c 100644 --- a/pkg/email/parser.go +++ b/pkg/email/parser.go @@ -28,6 +28,7 @@ type Email struct { Body string // text/plain part Patch string // attached patch, if any Command Command // command to bot + CommandStr string // string representation of the command CommandArgs string // arguments for the command } @@ -104,7 +105,7 @@ func Parse(r io.Reader, ownEmails []string) (*Email, error) { } bodyStr := string(body) cmd := CmdNone - patch, cmdArgs := "", "" + patch, cmdStr, cmdArgs := "", "", "" if !fromMe { for _, a := range attachments { _, patch, _ = ParsePatch(string(a)) @@ -115,7 +116,7 @@ func Parse(r io.Reader, ownEmails []string) (*Email, error) { if patch == "" { _, patch, _ = ParsePatch(bodyStr) } - cmd, cmdArgs = extractCommand(body) + cmd, cmdStr, cmdArgs = extractCommand(body) } link := "" if match := groupsLinkRe.FindStringSubmatchIndex(bodyStr); match != nil { @@ -131,6 +132,7 @@ func Parse(r io.Reader, ownEmails []string) (*Email, error) { Body: string(body), Patch: patch, Command: cmd, + CommandStr: cmdStr, CommandArgs: cmdArgs, } return email, nil @@ -193,7 +195,7 @@ func CanonicalEmail(email string) string { // extractCommand extracts command to syzbot from email body. // Commands are of the following form: // ^#syz cmd args... -func extractCommand(body []byte) (cmd Command, args string) { +func extractCommand(body []byte) (cmd Command, str, args string) { cmdPos := bytes.Index(append([]byte{'\n'}, body...), []byte("\n"+commandPrefix)) if cmdPos == -1 { cmd = CmdNone @@ -213,7 +215,8 @@ func extractCommand(body []byte) (cmd Command, args string) { if cmdEnd1 := bytes.IndexByte(body[cmdPos:], ' '); cmdEnd1 != -1 && cmdEnd1 < cmdEnd { cmdEnd = cmdEnd1 } - switch string(body[cmdPos : cmdPos+cmdEnd]) { + str = string(body[cmdPos : cmdPos+cmdEnd]) + switch str { default: cmd = CmdUnknown case "": @@ -246,8 +249,6 @@ func extractCommand(body []byte) (cmd Command, args string) { args = extractArgsTokens(body[cmdPos+cmdEnd:], 5) case CmdFix, CmdDup: args = extractArgsLine(body[cmdPos+cmdEnd:]) - case CmdUnknown: - args = extractArgsLine(body[cmdPos:]) } return } |
