Merge lp:~milo/linaro-patchmetrics/parsemail-fixes into lp:linaro-patchmetrics
Proposed by
Milo Casagrande
Status: | Merged |
---|---|
Merged at revision: | 401 |
Proposed branch: | lp:~milo/linaro-patchmetrics/parsemail-fixes |
Merge into: | lp:linaro-patchmetrics |
Diff against target: |
236 lines (+91/-38) 2 files modified
apps/patchwork/bin/parsemail.py (+64/-37) apps/patchwork/utils.py (+27/-1) |
To merge this branch: | bzr merge lp:~milo/linaro-patchmetrics/parsemail-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Paul Sokolovsky | Needs Fixing | ||
Review via email:
|
Description of the change
This is a fix for the script that parses the emails searching for patches. With the new changes, if the submitter of a patch nor the author of a patch are using Linaro email address, we do not consider the patch and we move on.
Another change made, is to when the saving action on a new Person (in this case a new author) happens. Previously, if a new author was found, it was saved immediately, now we save it only after making sure it is a valid Linaro engineer. In this way we do the exact same thing as it was done with the Submitter person, and we do not save authors that we do not want to track.
To post a comment you must log in.
Logic looks good. And I usually don't go at such details with stylistic changes, but for few quick looks at linaro-patchmetrics codebase, I felt confused and saw few less-than-ideal practices and hardcodings. So, let's try to do better.
1. Can "new_author" var be named "is_new_auhor"?
2.
8 - return None, None
9 + return None, None, None
From the rest of patch it's possible to figure out what 3rd return value is, and I'm not sure if that func had a docstring, but maybe it might?
3.
57 + # If submitter nor author of a patch are not Linaro, we move on.
58 + # TODO: may be worth to integrate with crowd.
59 + if "@linaro.org" not in submitter.email:
60 + if author is not None and "@linaro.org" not in author.email:
61 + return 0
62 + return 0
There're 2 issues here: one is that hardcoded "@linaro.org". We can do better ;-) (yeah, I know it takes much more patch lines to use config settings, and sometimes with my changes I wonder if I should bother either; friendly answer looking from outside - yes ;-) ). And we should anticipate need to support multiple patterns - either as array, or better just as a regexp.
Another is that there's superfluous/ erroneous logic - if first "if" fired, it's "return 0" regardless of second
"if". If code should look like that, there should be a comment (like, "one sweet day, we may want to handle these conditions separately"). Otherwise...