From 2a028347872bce363f911aa2053514488730d510 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 10 2015 11:03:40 +0000 Subject: Be more careful on how we get the number of line added/removed --- diff --git a/pagure/hooks/files/fedmsg_hook.py b/pagure/hooks/files/fedmsg_hook.py index f837fa4..264387f 100755 --- a/pagure/hooks/files/fedmsg_hook.py +++ b/pagure/hooks/files/fedmsg_hook.py @@ -36,11 +36,23 @@ def build_stats(commit): total = {} for line in output[1:]: additions, deletions, path = line.split('\t') + additions, deletions = additions.strip(), deletions.strip() + + try: + additions = int(additions) + except ValueError: + additions = 0 + + try: + deletions = int(deletions) + except ValueError: + deletions = 0 + path = path.strip() files[path] = { - 'additions': int(additions.strip()), - 'deletions': int(deletions.strip()), - 'lines': int(additions.strip()) + int(deletions.strip()), + 'additions': additions, + 'deletions': deletions, + 'lines': additions + deletions, } total = defaultdict(int)