Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple fixes for bugs around --show-email and --since=<date> #32

Merged
merged 8 commits into from Jun 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion gitfame/_gitfame.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
# NB: does not support escaping of escaped character
RE_CSPILT = re.compile(r'(?<!\\),')
RE_NCOM_AUTH_EM = re.compile(r'^\s*(\d+)\s+(.*?)\s+<(.*)>\s*$', flags=re.M)
# finds "boundary" line-porcelain messages
RE_BLAME_BOUNDS = re.compile(
r'^\w+\s+\d+\s+\d+(\s+\d+)?\s*$[^\t]*?^boundary\s*$[^\t]*?^\t.*?$\r?\n',
flags=re.M | re.DOTALL)


def hours(dates, maxCommitDiffInSec=120 * 60, firstCommitAdditionInMinutes=120):
Expand Down Expand Up @@ -220,6 +224,10 @@ def _get_auth_stats(
getattr(log, "warn" if warn_binary else "debug")(fname + ':' + str(e))
continue
log.log(logging.NOTSET, blame_out)

# Strip boundary messages,
# preventing user with nearest commit to boundary owning the LOC
blame_out = RE_BLAME_BOUNDS.sub('', blame_out)
loc_auth_times = RE_AUTHS.findall(blame_out)

for loc, auth, tstamp in loc_auth_times: # for each chunk
Expand Down Expand Up @@ -265,7 +273,14 @@ def _get_auth_stats(
old = auth_stats
auth_stats = {}
for auth, stats in getattr(old, 'iteritems', old.items)():
auth_stats[auth2em[auth]] = stats
i = auth_stats.setdefault(auth2em[auth], {"loc": 0,
"files": set([]),
"commits": 0,
"ctimes": []})
i["loc"] += stats["loc"]
i["files"].update(stats["files"])
i["commits"] += stats["commits"]
i["ctimes"] += stats["ctimes"]
del old

return auth_stats
Expand Down