Split name blobs from `git shortlog -nse` into first/last/email.
(name)
| 60 | |
| 61 | |
| 62 | def parse_name(name): |
| 63 | """Split name blobs from `git shortlog -nse` into first/last/email.""" |
| 64 | # remove commit count |
| 65 | _, name_and_email = name.strip().split("\t") |
| 66 | name, email = name_and_email.split(" <") |
| 67 | email = email.strip(">") |
| 68 | email = "" if "noreply" in email else email # ignore "noreply" emails |
| 69 | name = " ".join(name.split(".")) # remove periods from initials |
| 70 | # handle compound surnames |
| 71 | for compound_surname in compound_surnames: |
| 72 | if name.endswith(compound_surname): |
| 73 | ix = name.index(compound_surname) |
| 74 | first = name[:ix].strip() |
| 75 | last = compound_surname |
| 76 | return (first, last, email) |
| 77 | # handle non-compound surnames |
| 78 | name_elements = name.split() |
| 79 | if len(name_elements) == 1: # mononyms / usernames |
| 80 | first = "" |
| 81 | last = name |
| 82 | else: |
| 83 | first = " ".join(name_elements[:-1]) |
| 84 | last = name_elements[-1] |
| 85 | return (first, last, email) |
| 86 | |
| 87 | |
| 88 | # MAKE SURE THE RELEASE STRING IS PROPERLY FORMATTED |
no test coverage detected