@@ -20,20 +20,21 @@ import (
2020)
2121
2222type Email struct {
23- BugIDs []string
24- MessageID string
25- InReplyTo string
26- Date time.Time
27- Link string
28- Subject string
29- MailingList string
30- Author string
31- OwnEmail bool
32- Cc []string
33- RawCc []string // unstripped emails
34- Body string // text/plain part
35- Patch string // attached patch, if any
36- Commands []* SingleCommand
23+ BugIDs []string
24+ MessageID string
25+ InReplyTo string
26+ Date time.Time
27+ Link string
28+ Subject string
29+ MailingList string
30+ Author string
31+ OwnEmail bool
32+ Cc []string
33+ RawCc []string // unstripped emails
34+ Body string // text/plain part
35+ Patch string // attached patch, if any
36+ BaseCommitHint string // Hash of base-commit, if provided.
37+ Commands []* SingleCommand
3738}
3839
3940type SingleCommand struct {
@@ -179,20 +180,21 @@ func Parse(r io.Reader, ownEmails, goodLists, domains []string) (*Email, error)
179180 }
180181 date , _ := mail .ParseDate (msg .Header .Get ("Date" ))
181182 email := & Email {
182- BugIDs : unique (bugIDs ),
183- MessageID : msg .Header .Get ("Message-ID" ),
184- InReplyTo : extractInReplyTo (msg .Header ),
185- Date : date ,
186- Link : link ,
187- Author : author ,
188- OwnEmail : fromMe ,
189- MailingList : mailingList ,
190- Subject : subject ,
191- Cc : ccList ,
192- RawCc : mergeRawAddresses (from , originalFroms , to , cc ),
193- Body : bodyStr ,
194- Patch : patch ,
195- Commands : cmds ,
183+ BugIDs : unique (bugIDs ),
184+ MessageID : msg .Header .Get ("Message-ID" ),
185+ InReplyTo : extractInReplyTo (msg .Header ),
186+ Date : date ,
187+ Link : link ,
188+ Author : author ,
189+ OwnEmail : fromMe ,
190+ MailingList : mailingList ,
191+ Subject : subject ,
192+ Cc : ccList ,
193+ RawCc : mergeRawAddresses (from , originalFroms , to , cc ),
194+ Body : bodyStr ,
195+ Patch : patch ,
196+ Commands : cmds ,
197+ BaseCommitHint : extractBaseCommitHint (bodyStr ),
196198 }
197199 return email , nil
198200}
@@ -575,3 +577,13 @@ func decodeSubject(rawSubject string) string {
575577 }
576578 return decodedSubject
577579}
580+
581+ var baseCommitRegex = regexp .MustCompile (`(?m)^base-commit:\s*([0-9a-fA-F]{40})\r?$` )
582+
583+ func extractBaseCommitHint (email string ) string {
584+ matches := baseCommitRegex .FindStringSubmatch (email )
585+ if matches != nil {
586+ return matches [1 ]
587+ }
588+ return ""
589+ }
0 commit comments