-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit_log_report.sh
More file actions
executable file
·87 lines (74 loc) · 2.2 KB
/
git_log_report.sh
File metadata and controls
executable file
·87 lines (74 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/perl
sub cond_add_to_list {
my $line = shift;
my $regex = shift;
my $list = shift;
my $num_elements = @$list;
if ($line =~ $regex) {
@$list[$num_elements] = $line;
}
}
sub print_list {
my $headline = $_[0];
my @unsorted_list = @{$_[1]};
my @list = sort {lc($a) cmp lc($b)} @unsorted_list;
printf("%s\n", $headline);
if (@list > 0) {
for (my $i = 0; $i < @list; $i++) {
printf("%s\n", $list[$i]);
}
} else {
printf("* N/A\n");
}
}
if (@ARGV != 2) {
printf("Invalid number of arguments!\n");
printf("Syntax: git_log_diff.sh <old commit ID> <new commit ID>\n");
exit -1;
}
$old_commit_id = shift @ARGV;
chomp($old_commit_id = `git rev-parse --short $old_commit_id`);
$new_commit_id = shift @ARGV;
chomp($new_commit_id = `git rev-parse --short $new_commit_id`);
$new = 0;
open(my $fh, '-|', "git log $old_commit_id...$new_commit_id") or die $!;
while (<$fh>) {
chomp;
if ($_ =~ "^commit ([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])[0-9a-f]*") {
$new=1;
$commit_id=$1;
} elsif ($_ =~ "^Author:") {
} elsif ($_ =~ "^Date:") {
} elsif ($_ =~ "Change-Id:") {
} elsif ($_ =~ "Signed-off-by") {
} elsif ($_ =~ "^[ \t]*\$") {
} else {
if ($new) {
$line = sprintf("*%s (%s)", $_, $commit_id);
} else {
$line = sprintf("**%s", $_);
}
$line =~ s/^\*\s\s*/* /g;
$line =~ s/^\*\*\s\s*/** /g;
$line =~ s/^\*\* \*\s/** /g;
#printf("%s\n", $line);
if ($new) {
cond_add_to_list($line, "Bug Fix]", \@bug_fixes);
cond_add_to_list($line, "Optimization]", \@optimizations);
cond_add_to_list($line, "API Change]", \@api_changes);
cond_add_to_list($line, "New Feature]", \@new_features);
cond_add_to_list($line, "New Architecture Support]", \@new_features);
cond_add_to_list($line, "Refactoring]", \@refactorings);
}
$new = 0;
}
}
close($fh);
printf("==HAL Log Report==\n");
printf("* Branch: %s", `git rev-parse --abbrev-ref HEAD`);
printf("* Commit ID range: %s...%s\n\n", $old_commit_id, $new_commit_id);
print_list("===Bug Fixes===", \@bug_fixes);
print_list("===Optimizations===", \@optimizations);
print_list("===API Changes===", \@api_changes);
print_list("===New Features===", \@new_features);
print_list("===Refactorings===", \@refactorings);