diff options
author | Andy Doan <andy.doan@linaro.org> | 2016-10-13 16:50:01 -0500 |
---|---|---|
committer | Andy Doan <andy.doan@linaro.org> | 2016-10-13 16:50:01 -0500 |
commit | ca90ae8897da2d31bc9e653823b270e46c058898 (patch) | |
tree | bc05cc9086c57bf6eaf26d7acae3384ac9dcd4d9 /linaro_metrics | |
parent | 18e348be75813c9318ea1cb67dd0ca5999e855ef (diff) |
linaro-metrics: accept patches from linaro submitters
We have users who'd like to track patches they've submitted on behalf of
other users who may not be Linaro. In this case we need to make sure we
don't apply TeamCredits to the submitter since it wasn't authored by
Linaro.
Change-Id: I747093b2a25ac4dd326f887597e487f04052f570
Diffstat (limited to 'linaro_metrics')
-rw-r--r-- | linaro_metrics/parsemail.py | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/linaro_metrics/parsemail.py b/linaro_metrics/parsemail.py index 1fce21f..bfc481e 100644 --- a/linaro_metrics/parsemail.py +++ b/linaro_metrics/parsemail.py @@ -85,15 +85,16 @@ def comment_lines(mail): return commentbuf.split('\n') -def find_author(mail): +def find_author_submitter(mail): _, auth = email.utils.parseaddr(mail.get('From')) + submitter = auth for i, line in enumerate(comment_lines(mail)): # only look in first 3 lines for author if i > 2: break if line.startswith('From:'): _, auth = email.utils.parseaddr(line[5:]) - return auth + return auth, submitter def get_linaro_person(crowd, email): @@ -111,25 +112,34 @@ def get_linaro_person(crowd, email): def linaro_parse_mail(crowd, real_parse_mail, mail): - '''Only track patches *authored* by "linaro" people. We determine this by - first finding the author's email. Most of the time this is the simply - the "from" address. Occasionally the "from" winds up being the submitter - and the author is actually listed in the email's content. Once we - have the author email address we check the following logic: - - * is this a valid crowd email? + '''Only track patches authored or submitted by "linaro" people. We + determine this by first finding the author's email. Most of the time + this is the simply the "from" address. Occasionally the "from" winds up + being the submitter and the author is actually listed in the email's + content. Once we have the author email address we check the following + logic: + + * is this author or submitter a valid crowd email? * is there a Person in patchwork by this email address? - if so, is its User part of Linaro? (ie allow tracking of non-linaro emails ''' - author = find_author(mail) + author, submitter = find_author_submitter(mail) person = get_linaro_person(crowd, author) - if person: + if person: # we have a linaro authored patch try: Patch.linaro_author = person return real_parse_mail(mail) finally: delattr(Patch, 'linaro_author') + else: + # see if its a linaro submitter, we'll add the patch but not give + # out team credits + submitter = get_linaro_person(crowd, submitter) + if submitter: + Patch.linaro_author = person + return real_parse_mail(mail) + return 0 |