Port the fedmsg git hooks to newer pygit2
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
parent
130eb14630
commit
45375683fa
2 changed files with 29 additions and 8 deletions
|
@ -49,10 +49,21 @@ def build_stats(commit):
|
|||
|
||||
for diff in diffs:
|
||||
for patch in diff:
|
||||
path = patch.new_file_path
|
||||
files[path]['additions'] += patch.additions
|
||||
files[path]['deletions'] += patch.deletions
|
||||
files[path]['lines'] += patch.additions + patch.deletions
|
||||
if hasattr(patch, 'new_file_path'):
|
||||
path = patch.new_file_path
|
||||
else:
|
||||
path = patch.old_file_path
|
||||
|
||||
if hasattr(patch, 'additions'):
|
||||
files[path]['additions'] += patch.additions
|
||||
files[path]['deletions'] += patch.deletions
|
||||
files[path]['lines'] += patch.additions + patch.deletions
|
||||
else:
|
||||
files[path]['additions'] += patch.line_stats[1]
|
||||
files[path]['deletions'] += patch.line_stats[2]
|
||||
files[path]['lines'] += patch.line_stats[1] \
|
||||
+ patch.line_stats[2]
|
||||
|
||||
|
||||
total = defaultdict(int)
|
||||
for name, stats in files.items():
|
||||
|
|
|
@ -53,10 +53,20 @@ def build_stats(commit):
|
|||
|
||||
for diff in diffs:
|
||||
for patch in diff:
|
||||
path = patch.new_file_path
|
||||
files[path]['additions'] += patch.additions
|
||||
files[path]['deletions'] += patch.deletions
|
||||
files[path]['lines'] += patch.additions + patch.deletions
|
||||
if hasattr(patch, 'new_file_path'):
|
||||
path = patch.new_file_path
|
||||
else:
|
||||
path = patch.old_file_path
|
||||
|
||||
if hasattr(patch, 'additions'):
|
||||
files[path]['additions'] += patch.additions
|
||||
files[path]['deletions'] += patch.deletions
|
||||
files[path]['lines'] += patch.additions + patch.deletions
|
||||
else:
|
||||
files[path]['additions'] += patch.line_stats[1]
|
||||
files[path]['deletions'] += patch.line_stats[2]
|
||||
files[path]['lines'] += patch.line_stats[1] \
|
||||
+ patch.line_stats[2]
|
||||
|
||||
total = defaultdict(int)
|
||||
for name, stats in files.items():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue