util/release: Update gerrit_stats script for release

- Change delimiter characters to safe characters to keep the output
from getting mangled when imported into a spreadsheet.
- Change hyphens for statistics to asterisks for easier use in the
release notes.

Signed-off-by: Martin Roth <gaumless@gmail.com>
Change-Id: I94f581d697f58cb29a662ac70ef9fd1d8c1e98ef
Reviewed-on: https://review.coreboot.org/c/coreboot/+/77332
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
This commit is contained in:
Martin Roth 2023-08-20 19:25:53 -06:00 committed by Felix Singer
parent cbc792c8c3
commit 647252ba84
1 changed files with 18 additions and 9 deletions

View File

@ -205,6 +205,8 @@ sub Main {
if ( $owner && exists( $aliases{$owner} ) ) { if ( $owner && exists( $aliases{$owner} ) ) {
$owner = $aliases{$owner}; $owner = $aliases{$owner};
} }
$owner =~ s/"/'/g;
$owner =~ s/,/./g;
$author = $commit_info->{'currentPatchSet'}{'author'}{'name'}; $author = $commit_info->{'currentPatchSet'}{'author'}{'name'};
if ( $author && exists( $aliases{$author} ) ) { if ( $author && exists( $aliases{$author} ) ) {
@ -213,10 +215,13 @@ sub Main {
if ( !$author ) { if ( !$author ) {
$author = $commit_info->{'currentPatchSet'}{'author'}{'username'}; $author = $commit_info->{'currentPatchSet'}{'author'}{'username'};
} }
$author =~ s/"/'/g;
$author =~ s/,/./g;
$author_email = $commit_info->{'currentPatchSet'}{'author'}{'email'}; $author_email = $commit_info->{'currentPatchSet'}{'author'}{'email'};
$inserted_lines = $commit_info->{'currentPatchSet'}{'sizeInsertions'}; $inserted_lines = $commit_info->{'currentPatchSet'}{'sizeInsertions'};
$deleted_lines = $commit_info->{'currentPatchSet'}{'sizeDeletions'}; $deleted_lines = $commit_info->{'currentPatchSet'}{'sizeDeletions'};
$subject = $commit_info->{'subject'}; $subject = $commit_info->{'subject'};
$subject =~ s/"/'/g;
#get the patch's submitter #get the patch's submitter
my $approvals = $commit_info->{'currentPatchSet'}{'approvals'}; my $approvals = $commit_info->{'currentPatchSet'}{'approvals'};
@ -275,6 +280,8 @@ sub Main {
$commenter = $aliases{$commenter}; $commenter = $aliases{$commenter};
} }
} }
$commenter =~ s/"/'/g;
$commenter =~ s/,/./g;
if ( $commenter && $author && $commenter eq $author ) { if ( $commenter && $author && $commenter eq $author ) {
next; next;
} }
@ -307,6 +314,8 @@ sub Main {
$submitter = $aliases{$submitter}; $submitter = $aliases{$submitter};
} }
} }
$submitter =~ s/"/'/g;
$submitter =~ s/,/./g;
if ( $approval->{'type'} eq "Code-Review" ) { if ( $approval->{'type'} eq "Code-Review" ) {
my $patch_reviewer = $approval->{'by'}{'name'}; my $patch_reviewer = $approval->{'by'}{'name'};
@ -483,16 +492,16 @@ sub Main {
$Days += 1; $Days += 1;
} }
print "\n- Total Commits: $number_of_commits\n"; print "\n* Total Commits: $number_of_commits\n";
printf "- Average Commits per day: %.2f\n", $number_of_commits / $Days; printf "* Average Commits per day: %.2f\n", $number_of_commits / $Days;
print "- Total lines added: $total_added\n"; print "* Total lines added: $total_added\n";
printf "- Average lines added per commit: %.2f\n", $total_added / $number_of_commits; printf "* Average lines added per commit: %.2f\n", $total_added / $number_of_commits;
print "- Number of patches adding more than 100 lines: $patches_over_100_lines\n"; print "* Number of patches adding more than 100 lines: $patches_over_100_lines\n";
printf "- Average lines added per small commit: %.2f\n", ( $total_added - $total_lines_large_patches ) / ( $number_of_commits - $patches_over_100_lines ); printf "* Average lines added per small commit: %.2f\n", ( $total_added - $total_lines_large_patches ) / ( $number_of_commits - $patches_over_100_lines );
print "- Total lines removed: $total_removed\n"; print "* Total lines removed: $total_removed\n";
printf "- Average lines removed per commit: %.2f\n", $total_removed / $number_of_commits; printf "* Average lines removed per commit: %.2f\n", $total_removed / $number_of_commits;
print "- Total difference between added and removed: " . ( $total_added - $total_removed ) . "\n\n"; print "* Total difference between added and removed: " . ( $total_added - $total_removed ) . "\n\n";
print "=== Authors - Number of commits ===\n"; print "=== Authors - Number of commits ===\n";
printf "%-30s ,%5s ,%5s ,%6s ,%6s , %-52s ,%6s, %-19s , %s\n", "Author", "Ptchs", "Revws", "Cmnts", "Sbmts", "Email", "Prcnt", "Last commit", "Earliest_commit"; printf "%-30s ,%5s ,%5s ,%6s ,%6s , %-52s ,%6s, %-19s , %s\n", "Author", "Ptchs", "Revws", "Cmnts", "Sbmts", "Email", "Prcnt", "Last commit", "Earliest_commit";