| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 1 | #!/usr/bin/perl |
| 2 | eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' |
| 3 | if $running_under_some_shell; |
| 4 | #!/usr/bin/perl |
| 5 | |
| 6 | use strict; |
| Christian Lohmaier | 249b6a5 | 2017-04-29 19:15:26 +0200 | [diff] [blame] | 7 | use warnings; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 8 | use LWP::UserAgent; |
| Ivan Timofeev | 521ae23 | 2012-05-21 16:54:25 +0200 | [diff] [blame] | 9 | use utf8; |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 10 | use File::Temp; |
| Christian Lohmaier | 9c83796 | 2017-04-29 18:26:20 +0200 | [diff] [blame] | 11 | use Encode; |
| 12 | use open ':encoding(utf8)'; |
| 13 | use open ':std' => ':encoding(utf8)'; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 14 | |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 15 | my %module_dirname = ( |
| 16 | "core" => "", |
| 17 | "dictionaries" => "dictionaries", |
| 18 | "help" => "helpcontent2", |
| 19 | "translations" => "translations" |
| 20 | ); |
| 21 | |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 22 | |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 23 | my %bugzillas = ( |
| Dennis Roczek | b990cdf | 2015-06-09 06:01:37 +0200 | [diff] [blame] | 24 | fdo => "https://bugs.documentfoundation.org/show_bug.cgi?id=", |
| 25 | tdf => "https://bugs.documentfoundation.org/show_bug.cgi?id=", |
| Thorsten Behrens | 724b4ea | 2012-07-12 01:32:55 +0200 | [diff] [blame] | 26 | bnc => "https://bugzilla.novell.com/show_bug.cgi?id=", |
| 27 | rhbz => "https://bugzilla.redhat.com/show_bug.cgi?id=", |
| Adolfo Jayme Barrientos | d02c159 | 2015-05-19 19:48:11 -0500 | [diff] [blame] | 28 | i => "https://bz.apache.org/ooo/show_bug.cgi?id=", |
| Thorsten Behrens | 724b4ea | 2012-07-12 01:32:55 +0200 | [diff] [blame] | 29 | fate => "https://features.opensuse.org/", |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 30 | ); |
| 31 | |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 32 | sub search_bugs($$$$) |
| 33 | { |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 34 | my ($pdata, $module, $commit_id, $line) = @_; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 35 | |
| 36 | my $bug = ""; |
| 37 | my $bug_orig; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 38 | while (defined $bug) { |
| Petr Mladek | 5c42f5d | 2011-03-01 21:16:48 +0100 | [diff] [blame] | 39 | |
| Thorsten Behrens | 9852f01 | 2012-06-12 03:34:33 +0200 | [diff] [blame] | 40 | # match fdo#123, rhz#123, i#123, #123 |
| Korrawit Pruegsanusak | 6858c3e | 2012-06-01 00:24:16 +0700 | [diff] [blame] | 41 | # but match only bug number with >= 4 digits |
| Thorsten Behrens | 9852f01 | 2012-06-12 03:34:33 +0200 | [diff] [blame] | 42 | if ( $line =~ m/(\w+\#+\d{4,})/ ) { |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 43 | $bug_orig = $1; |
| 44 | $bug = $1; |
| Thorsten Behrens | 9852f01 | 2012-06-12 03:34:33 +0200 | [diff] [blame] | 45 | # default to issuezilla for the #123 variant |
| 46 | # but match only bug number with >= 4 digits |
| 47 | } elsif ( $line =~ m/(\#)(\d{4,})/ ) { |
| 48 | $bug_orig = $1 . $2; |
| 49 | $bug = "i#$2"; |
| Petr Mladek | 9a34f07 | 2011-02-02 17:46:51 +0100 | [diff] [blame] | 50 | # match #i123# |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 51 | } elsif ( $line =~ m/(\#i)(\d+)(\#)/ ) { |
| 52 | $bug_orig = $1 . $2 . $3; |
| Petr Mladek | b9e2283 | 2011-02-09 12:37:47 +0100 | [diff] [blame] | 53 | $bug = "i#$2"; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 54 | } else { |
| 55 | $bug = undef; |
| 56 | next; |
| 57 | } |
| Petr Mladek | 5c42f5d | 2011-03-01 21:16:48 +0100 | [diff] [blame] | 58 | |
| Petr Mladek | b9e2283 | 2011-02-09 12:37:47 +0100 | [diff] [blame] | 59 | # print " found $bug\n"; |
| Petr Mladek | 5c42f5d | 2011-03-01 21:16:48 +0100 | [diff] [blame] | 60 | # remove bug number from the comment; it will be added later a standardized way |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 61 | $bug_orig =~ s/\#/\\#/; |
| Dennis Roczek | 880e3af | 2015-07-12 04:35:28 +0200 | [diff] [blame] | 62 | $line =~ s/(,\s)*[Rr](elated|esolve[ds]):?\s*$bug_orig\s?:?\s*//; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 63 | $line =~ s/\s*-\s*$bug_orig\s*//; |
| Korrawit Pruegsanusak | efecdec | 2012-06-01 00:24:22 +0700 | [diff] [blame] | 64 | $line =~ s/\(?$bug_orig\)?\s*[:,-]?\s*//; |
| Petr Mladek | 5c42f5d | 2011-03-01 21:16:48 +0100 | [diff] [blame] | 65 | |
| Andras Timar | 382eea6 | 2011-04-19 18:42:53 +0200 | [diff] [blame] | 66 | # bnc# is preferred over n# for novell bugs |
| Petr Mladek | 5c42f5d | 2011-03-01 21:16:48 +0100 | [diff] [blame] | 67 | $bug =~ s/^n\#/bnc#/; |
| Thorsten Behrens | 9852f01 | 2012-06-12 03:34:33 +0200 | [diff] [blame] | 68 | # deb# is preferred over debian# for debian bugs |
| 69 | $bug =~ s/^debian\#/deb#/; |
| 70 | # easyhack# is sometimes used for fdo# - based easy hacks |
| 71 | $bug =~ s/^easyhack\#/fdo#/; |
| 72 | # someone mistyped fdo as fd0 |
| 73 | $bug =~ s/^fd0\#/fdo#/; |
| Petr Mladek | 5c42f5d | 2011-03-01 21:16:48 +0100 | [diff] [blame] | 74 | # save the bug number |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 75 | $pdata->{$module}{$commit_id}{'bugs'}{$bug} = 1; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | return $line; |
| 79 | } |
| 80 | |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 81 | sub standardize_summary($) |
| 82 | { |
| 83 | my $line = shift; |
| 84 | |
| 85 | $line =~ s/^\s*//; |
| 86 | $line =~ s/\s*$//; |
| 87 | |
| Korrawit Pruegsanusak | f439d76 | 2012-06-01 00:24:18 +0700 | [diff] [blame] | 88 | # lower first letter if the word contains only lowercase letter |
| 89 | if ( $line =~ m/(^.[a-z]+\b)/ ) { |
| 90 | $line =~ m/(^.)/; |
| 91 | my $first_char = lc($1); |
| 92 | $line =~ s/^./$first_char/; |
| 93 | } |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 94 | |
| 95 | # FIXME: remove do at the end of line |
| 96 | # remove bug numbers |
| 97 | return $line; |
| 98 | } |
| 99 | |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 100 | sub generate_git_cherry_ids_log($$$$$) |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 101 | { |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 102 | my ($pdata, $repo_dir, $module, $branch_name, $git_args) = @_; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 103 | |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 104 | my $commit_ids_log; |
| 105 | my $commit_ids_log_fh; |
| 106 | $commit_ids_log_fh = File::Temp->new(TEMPLATE => 'lo-commit-stat-ids-XXXXXX', |
| 107 | DIR => '/tmp', |
| 108 | UNLINK => 0); |
| 109 | $commit_ids_log = $commit_ids_log_fh->filename; |
| 110 | |
| 111 | print STDERR "Filtering cherry-picked commits in the git repo: $module...\n"; |
| 112 | |
| 113 | my $cmd = "cd $repo_dir; git cherry $git_args"; |
| 114 | open (GIT, "$cmd 2>&1|") || die "Can't run $cmd: $!"; |
| 115 | |
| 116 | while (my $line = <GIT>) { |
| 117 | |
| 118 | # skip cherry-picked commits |
| 119 | next if ( $line =~ m/^\-/ ); |
| 120 | |
| 121 | if ( $line =~ m/^\+ / ) { |
| 122 | $line =~ s/^\+ //; |
| 123 | print $commit_ids_log_fh $line; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | close GIT; |
| 128 | close $commit_ids_log_fh; |
| 129 | |
| 130 | return $commit_ids_log; |
| 131 | } |
| 132 | |
| 133 | sub load_git_log($$$$$$$) |
| 134 | { |
| 135 | my ($pdata, $repo_dir, $module, $branch_name, $git_command, $git_cherry, $git_args) = @_; |
| 136 | |
| 137 | my $cmd = "cd $repo_dir;"; |
| 138 | my $commit_ids_log; |
| 139 | |
| 140 | if ($git_cherry) { |
| 141 | $commit_ids_log = generate_git_cherry_ids_log($pdata, $repo_dir, $module, $branch_name, $git_args); |
| 142 | $cmd .= " cat $commit_ids_log | xargs -n 1 $git_command -1"; |
| 143 | } else { |
| 144 | $cmd .= " $git_command $git_args"; |
| 145 | } |
| 146 | |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 147 | my $commit_id; |
| 148 | my $summary; |
| 149 | |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 150 | print STDERR "Analyzing log from the git repo: $module...\n"; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 151 | |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 152 | # FIXME: ./g pull move submodules in unnamed branches |
| 153 | # my $repo_branch_name = get_branch_name($repo_dir); |
| 154 | # if ( $branch_name ne $repo_branch_name ) { |
| 155 | # die "Error: mismatch of branches:\n" . |
| 156 | # " main repo is on the branch: $branch_name\n" . |
| 157 | # " $module repo is on the branch: $repo_branch_name\n"; |
| 158 | # } |
| Petr Mladek | 33a8400 | 2011-04-26 20:03:01 +0200 | [diff] [blame] | 159 | |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 160 | open (GIT, "$cmd 2>&1|") || die "Can't run $cmd: $!"; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 161 | |
| 162 | while (my $line = <GIT>) { |
| 163 | chomp $line; |
| 164 | |
| Petr Mladek | 9a34f07 | 2011-02-02 17:46:51 +0100 | [diff] [blame] | 165 | if ( $line =~ m/^commit ([0-9a-z]{20})/ ) { |
| Christian Lohmaier | 249b6a5 | 2017-04-29 19:15:26 +0200 | [diff] [blame] | 166 | $commit_id = $1; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 167 | $summary=undef; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 168 | next; |
| 169 | } |
| 170 | |
| Petr Mladek | 9a34f07 | 2011-02-02 17:46:51 +0100 | [diff] [blame] | 171 | if ( $line =~ /^Author:\s*([^\<]*)\<([^\>]*)>/ ) { |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 172 | # get rid of extra empty spaces; |
| Christian Lohmaier | 249b6a5 | 2017-04-29 19:15:26 +0200 | [diff] [blame] | 173 | my $name = $1; |
| 174 | my $email = $2; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 175 | $name =~ s/\s+$//; |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 176 | die "Error: Author already defined for the commit {$commit_id}\n" if defined ($pdata->{$module}{$commit_id}{'author'}); |
| Christian Lohmaier | 249b6a5 | 2017-04-29 19:15:26 +0200 | [diff] [blame] | 177 | $pdata->{$module}{$commit_id}{'author'}{'name'} = $name; |
| 178 | $pdata->{$module}{$commit_id}{'author'}{'email'} = $email; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 179 | next; |
| 180 | } |
| Petr Mladek | 9a34f07 | 2011-02-02 17:46:51 +0100 | [diff] [blame] | 181 | |
| 182 | if ( $line =~ /^Date:\s+/ ) { |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 183 | # ignore date line |
| 184 | next; |
| 185 | } |
| Petr Mladek | 9a34f07 | 2011-02-02 17:46:51 +0100 | [diff] [blame] | 186 | |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 187 | if ( $line =~ /^\s*$/ ) { |
| 188 | # ignore empty line |
| 189 | next; |
| 190 | } |
| 191 | |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 192 | $line = search_bugs($pdata, $module, $commit_id, $line); |
| Andras Timar | 382eea6 | 2011-04-19 18:42:53 +0200 | [diff] [blame] | 193 | # FIXME: need to be implemented |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 194 | # search_keywords($pdata, $line); |
| 195 | |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 196 | unless (defined $pdata->{$module}{$commit_id}{'summary'}) { |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 197 | $summary = standardize_summary($line); |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 198 | $pdata->{$module}{$commit_id}{'summary'} = $summary; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 199 | } |
| 200 | } |
| 201 | |
| 202 | close GIT; |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 203 | unlink $commit_ids_log if ($git_cherry); |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | sub get_repo_name($) |
| 207 | { |
| 208 | my $repo_dir = shift; |
| 209 | |
| 210 | open (GIT_CONFIG, "$repo_dir/.git/config") || |
| 211 | die "can't open \"$$repo_dir/.git/config\" for reading: $!\n"; |
| 212 | |
| 213 | while (my $line = <GIT_CONFIG>) { |
| 214 | chomp $line; |
| 215 | |
| 216 | if ( $line =~ /^\s*url\s*=\s*(\S+)$/ ) { |
| 217 | my $repo_name = "$1"; |
| 218 | $repo_name = s/.*\///g; |
| 219 | return "$repo_name"; |
| 220 | } |
| 221 | } |
| 222 | die "Error: can't find repo name in \"$$repo_dir/.git/config\"\n"; |
| 223 | } |
| 224 | |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 225 | sub load_data($$$$$$$) |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 226 | { |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 227 | my ($pdata, $top_dir, $p_module_dirname, $branch_name, $git_command, $git_cherry, $git_args) = @_; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 228 | |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 229 | foreach my $module (sort { $a cmp $b } keys %{$p_module_dirname}) { |
| 230 | load_git_log($pdata, "$top_dir/$p_module_dirname->{$module}", $module, $branch_name, $git_command, $git_cherry, $git_args); |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 234 | sub get_branch_name($) |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 235 | { |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 236 | my ($top_dir) = @_; |
| 237 | |
| 238 | my $branch; |
| 239 | my $cmd = "cd $top_dir && git branch"; |
| 240 | |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 241 | open (GIT, "$cmd 2>&1|") || die "Can't run $cmd: $!"; |
| 242 | |
| 243 | while (my $line = <GIT>) { |
| 244 | chomp $line; |
| 245 | |
| 246 | if ( $line =~ m/^\*\s*(\S+)/ ) { |
| 247 | $branch = "$1"; |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | close GIT; |
| Petr Mladek | 33a8400 | 2011-04-26 20:03:01 +0200 | [diff] [blame] | 252 | |
| 253 | die "Error: did not detect git branch name in $top_dir\n" unless defined ($branch); |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 254 | |
| 255 | return $branch; |
| 256 | } |
| 257 | |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 258 | sub get_bug_list($$$) |
| 259 | { |
| 260 | my ($pdata, $pbugs, $check_bugzilla) = @_; |
| 261 | |
| 262 | # associate bugs with their summaries and fixers |
| 263 | foreach my $module ( keys %{$pdata}) { |
| 264 | foreach my $id ( keys %{$pdata->{$module}}) { |
| 265 | foreach my $bug (keys %{$pdata->{$module}{$id}{'bugs'}}) { |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 266 | my $author = $pdata->{$module}{$id}{'author'}{'name'}; |
| 267 | my $summary = $pdata->{$module}{$id}{'summary'}; |
| 268 | $pbugs->{$bug}{'summary'} = $summary; |
| 269 | $pbugs->{$bug}{'author'}{$author} = 1; |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | # try to replace summaries with bug names from bugzilla |
| 275 | if ($check_bugzilla) { |
| 276 | print "Getting bug titles:\n"; |
| 277 | foreach my $bug ( sort { $a cmp $b } keys %{$pbugs}) { |
| 278 | $pbugs->{$bug}{'summary'} = get_bug_name($bug, $pbugs->{$bug}{'summary'}); |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 283 | sub open_log_file($$$$$$) |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 284 | { |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 285 | my ($log_dir, $log_prefix, $log_suffix, $top_dir, $branch_name, $wiki) = @_; |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 286 | |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 287 | my $logfilename = "$log_prefix-$branch_name-$log_suffix"; |
| Petr Mladek | a07a230 | 2011-05-30 17:08:26 +0200 | [diff] [blame] | 288 | $logfilename = "$log_dir/$logfilename" if (defined $log_dir); |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 289 | if ($wiki) { |
| 290 | $logfilename .= ".wiki"; |
| 291 | } else { |
| 292 | $logfilename .= ".log"; |
| 293 | } |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 294 | |
| 295 | if (-f $logfilename) { |
| 296 | print "WARNING: The log file already exists: $logfilename\n"; |
| Andras Timar | 382eea6 | 2011-04-19 18:42:53 +0200 | [diff] [blame] | 297 | print "Do you want to overwrite it? (Y/n)?\n"; |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 298 | my $answer = <STDIN>; |
| 299 | chomp $answer; |
| 300 | $answer = "y" unless ($answer); |
| 301 | die "Please, rename the file or choose another log suffix\n" if ( lc($answer) ne "y" ); |
| 302 | } |
| 303 | |
| 304 | my $log; |
| 305 | open($log, '>', $logfilename) || die "Can't open \"$logfilename\" for writing: $!\n"; |
| 306 | |
| 307 | return $log; |
| 308 | } |
| 309 | |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 310 | sub print_commit_summary($$$$$$) |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 311 | { |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 312 | my ($summary, $pmodule_title, $pbugs, $pauthors, $prefix, $log) = @_; |
| Petr Mladek | 9a34f07 | 2011-02-02 17:46:51 +0100 | [diff] [blame] | 313 | |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 314 | return if ( $summary eq "" ); |
| Petr Mladek | 331006b | 2011-04-28 20:08:11 +0200 | [diff] [blame] | 315 | |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 316 | # print module title if not done yet |
| 317 | if ( defined ${$pmodule_title} ) { |
| 318 | print $log "${$pmodule_title}\n"; |
| 319 | ${$pmodule_title} = undef; |
| Petr Mladek | 8d8a189 | 2011-02-14 15:26:38 +0100 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | # finally print the summary line |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 323 | my $bugs = ""; |
| 324 | if ( %{$pbugs} ) { |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 325 | $bugs = " (" . join (", ", keys %{$pbugs}) . ")"; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | my $authors = ""; |
| 329 | if ( %{$pauthors} ) { |
| 330 | $authors = " [" . join (", ", keys %{$pauthors}) . "]"; |
| 331 | } |
| 332 | |
| Thorsten Behrens | d5e3a6a | 2012-06-13 11:20:47 +0200 | [diff] [blame] | 333 | print $log $prefix, $summary, $bugs, $authors, "\n"; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 334 | } |
| 335 | |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 336 | sub print_commits($$$) |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 337 | { |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 338 | my ($pdata, $log, $wiki) = @_; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 339 | |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 340 | foreach my $module ( sort { $a cmp $b } keys %{$pdata}) { |
| 341 | # check if this module has any entries at all |
| 342 | my $module_title = "+ $module"; |
| 343 | if ( %{$pdata->{$module}} ) { |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 344 | my $old_summary=""; |
| 345 | my %authors = (); |
| 346 | my %bugs = (); |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 347 | foreach my $id ( sort { lc $pdata->{$module}{$a}{'summary'} cmp lc $pdata->{$module}{$b}{'summary'} } keys %{$pdata->{$module}}) { |
| 348 | my $summary = $pdata->{$module}{$id}{'summary'}; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 349 | if ($summary ne $old_summary) { |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 350 | print_commit_summary($old_summary, \$module_title, \%bugs, \%authors, " + ", $log); |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 351 | $old_summary = $summary; |
| 352 | %authors = (); |
| 353 | %bugs = (); |
| 354 | } |
| Petr Mladek | 8d8a189 | 2011-02-14 15:26:38 +0100 | [diff] [blame] | 355 | # collect bug numbers |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 356 | if (defined $pdata->{$module}{$id}{'bugs'}) { |
| 357 | foreach my $bug (keys %{$pdata->{$module}{$id}{'bugs'}}) { |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 358 | $bugs{$bug} = 1; |
| 359 | } |
| 360 | } |
| Petr Mladek | 8d8a189 | 2011-02-14 15:26:38 +0100 | [diff] [blame] | 361 | # collect author names |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 362 | my $author = $pdata->{$module}{$id}{'author'}{'name'}; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 363 | $authors{$author} = 1; |
| 364 | } |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 365 | print_commit_summary($old_summary, \$module_title, \%bugs, \%authors, " + ", $log); |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 366 | } |
| 367 | } |
| 368 | } |
| 369 | |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 370 | sub get_bug_name($$) |
| 371 | { |
| 372 | my ($bug, $summary) = @_; |
| Petr Mladek | dd15b51d | 2012-05-18 18:02:37 +0200 | [diff] [blame] | 373 | print "$bug: "; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 374 | |
| 375 | $bug =~ m/(?:(\w*)\#+(\d+))/; # fdo#12345 |
| 376 | my $bugzilla = $1; # fdo |
| 377 | my $bug_number = $2; # 12345 |
| 378 | |
| 379 | if ( $bugzillas{$bugzilla} ) { |
| Thorsten Behrens | 724b4ea | 2012-07-12 01:32:55 +0200 | [diff] [blame] | 380 | my $url = $bugzillas{$bugzilla} . $bug_number; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 381 | my $ua = LWP::UserAgent->new; |
| 382 | $ua->timeout(10); |
| 383 | $ua->env_proxy; |
| 384 | my $response = $ua->get($url); |
| 385 | if ($response->is_success) { |
| Christian Lohmaier | 9c83796 | 2017-04-29 18:26:20 +0200 | [diff] [blame] | 386 | my $title = decode('utf8', $response->title); |
| 387 | if ( $title =~ s/^(?:Bug $bug_number \S+|$bug_number –) // ) { |
| Petr Mladek | dd15b51d | 2012-05-18 18:02:37 +0200 | [diff] [blame] | 388 | print "$title\n"; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 389 | return $title; |
| Petr Mladek | dd15b51d | 2012-05-18 18:02:37 +0200 | [diff] [blame] | 390 | } else { |
| Christian Lohmaier | 9c83796 | 2017-04-29 18:26:20 +0200 | [diff] [blame] | 391 | print "warning: not found; using commit message (only got $title)"; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 392 | } |
| 393 | } |
| 394 | } |
| Christian Lohmaier | 9c83796 | 2017-04-29 18:26:20 +0200 | [diff] [blame] | 395 | print "\n"; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 396 | |
| 397 | return $summary; |
| 398 | } |
| 399 | |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 400 | sub print_bugs($$$$) |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 401 | { |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 402 | my ($pbugs, $log, $wiki) = @_; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 403 | |
| Andrea Gelmini | 64a3124 | 2017-08-17 16:41:20 +0200 | [diff] [blame] | 404 | # sort alphabetically by bugzilla-type, but within that numerically |
| Christian Lohmaier | 0b8cccd | 2017-04-29 18:54:16 +0200 | [diff] [blame] | 405 | foreach my $bug ( sort { ($a =~ /(\D+)/)[0] cmp ($b =~ /(\D+)/)[0] || |
| 406 | ($a =~ /(\d+)/)[0] <=> ($b =~ /(\d+)/)[0] } keys %{$pbugs}) { |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 407 | my $summary = $pbugs->{$bug}{'summary'}; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 408 | |
| 409 | my $authors = ""; |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 410 | if ( %{$pbugs->{$bug}{'author'}} ) { |
| 411 | $authors = " [" . join (", ", keys %{$pbugs->{$bug}{'author'}}) . "]"; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 412 | } |
| 413 | |
| Thorsten Behrens | 001adf6 | 2013-06-27 19:37:53 +0200 | [diff] [blame] | 414 | $bug =~ s/(.*)\#(.*)/# {{$1|$2}}/ if ($wiki); |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 415 | print $log $bug, " ", $summary, $authors, "\n"; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 416 | } |
| 417 | } |
| 418 | |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 419 | sub print_bugs_changelog($$$$) |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 420 | { |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 421 | my ($pbugs, $log, $wiki) = @_; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 422 | |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 423 | foreach my $bug ( sort { $a cmp $b } keys %{$pbugs}) { |
| 424 | my $summary = $pbugs->{$bug}{'summary'}; |
| 425 | |
| 426 | my $authors = ""; |
| 427 | if ( %{$pbugs->{$bug}{'author'}} ) { |
| 428 | $authors = " [" . join (", ", keys %{$pbugs->{$bug}{'author'}}) . "]"; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 429 | } |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 430 | |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 431 | print $log " + $summary ($bug)$authors\n"; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | sub print_bugnumbers($$$$) |
| 436 | { |
| 437 | my ($pbugs, $log, $wiki) = @_; |
| 438 | |
| 439 | print $log join ("\n", sort { $a cmp $b } keys %{$pbugs}), "\n"; |
| Ivan Timofeev | a8b77a5 | 2012-05-17 18:38:09 +0400 | [diff] [blame] | 440 | } |
| 441 | |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 442 | sub generate_log($$$$$$$$) |
| 443 | { |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 444 | my ($pused_data, $print_func, $log_dir, $log_prefix, $log_suffix, $top_dir, $branch_name, $wiki) = @_; |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 445 | |
| 446 | my $log = open_log_file($log_dir, $log_prefix, $log_suffix, $top_dir, $branch_name, $wiki); |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 447 | & {$print_func} ($pused_data, $log, $wiki); |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 448 | close $log; |
| 449 | } |
| 450 | |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 451 | ######################################################################## |
| 452 | # help |
| 453 | |
| 454 | sub usage() |
| 455 | { |
| 456 | print "This script generates LO git commit summary\n\n" . |
| 457 | |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 458 | "Usage: lo-commit-stat [--help] [--no-submodules] [--module=<module>] --log-dir=<dir> --log-suffix=<string> topdir [git_arg...]\n\n" . |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 459 | |
| 460 | "Options:\n" . |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 461 | " --help print this help\n" . |
| 462 | " --no-submodule read changes just from the main repository, ignore submodules\n" . |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 463 | " --module=<module> summarize just changes from the given module, use \"core\"\n" . |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 464 | " for the main module\n" . |
| 465 | " --log-dir=<dir> directory where to put the generated log\n" . |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 466 | " --log-suffix=<string> suffix of the log file name; the result will be\n" . |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 467 | " commit-log-<branch>-<log-name-suffix>.log; the branch name\n" . |
| 468 | " is detected automatically\n" . |
| 469 | " --commits generete log with all commits (default)\n" . |
| 470 | " --bugs generate log with bugzilla entries\n" . |
| 471 | " --bugs-changelog generate log with bugzilla entries, use changelog style\n" . |
| 472 | " --bugs-wiki generate log with bugzilla entries, use wiki markup\n" . |
| 473 | " --bugs-numbers generate log with bugzilla numbers\n" . |
| 474 | " --rev-list use \"git rev-list\" instead of \"git log\"; useful to check\n" . |
| 475 | " differences between branches\n" . |
| 476 | " --cherry use \"git cherry\" instead of \"git log\"; detects cherry-picked\n" . |
| 477 | " commits between branches\n" . |
| 478 | " topdir directory with the libreoffice/core clone\n" . |
| 479 | " git_arg extra parameters passed to the git command to define\n" . |
| 480 | " the area of interest; The default command is \"git log\" and\n" . |
| 481 | " parameters might be, for example, --after=\"2010-09-27\" or\n" . |
| 482 | " TAG..HEAD; with the option --rev-list, useful might be, for\n" . |
| 483 | " example origin/master ^origin/libreoffice-3-3; with the option\n" . |
| 484 | " --rev-list, useful might be, for example libreoffice-3.6.3.2\n" . |
| 485 | " libreoffice-3.6.4.1\n"; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | |
| 489 | ####################################################################### |
| 490 | ####################################################################### |
| 491 | # MAIN |
| 492 | ####################################################################### |
| 493 | ####################################################################### |
| 494 | |
| 495 | |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 496 | my $module; |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 497 | my %generate_log = (); |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 498 | my $top_dir; |
| Petr Mladek | a07a230 | 2011-05-30 17:08:26 +0200 | [diff] [blame] | 499 | my $log_dir; |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 500 | my $log_suffix; |
| 501 | my $log; |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 502 | my $list_bugs = 0; |
| 503 | my $check_bugzilla = 0; |
| Petr Mladek | 33a8400 | 2011-04-26 20:03:01 +0200 | [diff] [blame] | 504 | my $branch_name; |
| Petr Mladek | 6ad7cdc | 2011-04-13 16:10:45 +0200 | [diff] [blame] | 505 | my $git_command = "git log"; |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 506 | my $git_cherry; |
| 507 | my $git_args = ""; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 508 | my %data; |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 509 | my %bugs = (); |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 510 | |
| 511 | |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 512 | foreach my $arg (@ARGV) { |
| 513 | if ($arg eq '--help') { |
| 514 | usage(); |
| 515 | exit; |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 516 | } elsif ($arg eq '--no-submodule') { |
| 517 | $module = "core"; |
| 518 | } elsif ($arg =~ m/--module=(.*)/) { |
| 519 | $module = $1; |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 520 | } elsif ($arg =~ m/--log-suffix=(.*)/) { |
| 521 | $log_suffix = "$1"; |
| Petr Mladek | a07a230 | 2011-05-30 17:08:26 +0200 | [diff] [blame] | 522 | } elsif ($arg =~ m/--log-dir=(.*)/) { |
| 523 | $log_dir = "$1"; |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 524 | } elsif ($arg eq '--commits') { |
| 525 | $generate_log{"commits"} = 1; |
| Petr Mladek | 8d8a189 | 2011-02-14 15:26:38 +0100 | [diff] [blame] | 526 | } elsif ($arg eq '--bugs') { |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 527 | $generate_log{"bugs"} = 1; |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 528 | $check_bugzilla = 1; |
| 529 | $list_bugs = 1; |
| 530 | } elsif ($arg eq '--bugs-changelog') { |
| 531 | $generate_log{"bugs-changelog"} = 1; |
| 532 | $check_bugzilla = 1; |
| 533 | $list_bugs = 1; |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 534 | } elsif ($arg eq '--bugs-wiki' || $arg eq '--wikibugs') { |
| 535 | $generate_log{"bugs-wiki"} = 1; |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 536 | $check_bugzilla = 1; |
| 537 | $list_bugs = 1; |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 538 | } elsif ($arg eq '--bugs-numbers' || $arg eq '--bug-numbers') { |
| 539 | $generate_log{"bugs-numbers"} = 1; |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 540 | $list_bugs = 1; |
| Petr Mladek | 6ad7cdc | 2011-04-13 16:10:45 +0200 | [diff] [blame] | 541 | } elsif ($arg eq '--rev-list') { |
| 542 | $git_command = "git rev-list --pretty=medium" |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 543 | } elsif ($arg eq '--cherry') { |
| 544 | $git_command = "git log"; |
| 545 | $git_cherry = 1; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 546 | } else { |
| 547 | if (! defined $top_dir) { |
| 548 | $top_dir=$arg; |
| 549 | } else { |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 550 | $git_args .= " $arg"; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 551 | } |
| 552 | } |
| 553 | } |
| 554 | |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 555 | # default log |
| Christian Lohmaier | 249b6a5 | 2017-04-29 19:15:26 +0200 | [diff] [blame] | 556 | unless (%generate_log) { |
| Petr Mladek | 93d021a | 2012-11-20 16:10:58 +0100 | [diff] [blame] | 557 | $generate_log{"commits"} = 1; |
| 558 | } |
| 559 | |
| 560 | # we want only one module |
| Petr Mladek | 0746c95 | 2012-11-19 17:50:42 +0100 | [diff] [blame] | 561 | if ($module) { |
| 562 | my $name = $module_dirname{$module}; |
| 563 | %module_dirname = (); |
| 564 | $module_dirname{$module} = $name; |
| 565 | } |
| 566 | |
| Andras Timar | 382eea6 | 2011-04-19 18:42:53 +0200 | [diff] [blame] | 567 | (defined $top_dir) || die "Error: top directory is not defined\n"; |
| Petr Mladek | 3a0ec75 | 2011-01-31 19:43:03 +0100 | [diff] [blame] | 568 | (-d "$top_dir") || die "Error: not a directory: $top_dir\n"; |
| 569 | (-f "$top_dir/.git/config") || die "Error: can't find $top_dir/.git/config\n"; |
| 570 | |
| Petr Mladek | a07a230 | 2011-05-30 17:08:26 +0200 | [diff] [blame] | 571 | (!defined $log_dir) || (-d $log_dir) || die "Error: directory does no exist: $log_dir\n"; |
| 572 | |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 573 | (defined $log_suffix) || die "Error: define log suffix using --log-suffix=<string>\n"; |
| 574 | |
| Petr Mladek | 33a8400 | 2011-04-26 20:03:01 +0200 | [diff] [blame] | 575 | $branch_name = get_branch_name($top_dir); |
| Petr Mladek | fa4a061 | 2011-03-28 15:51:47 +0200 | [diff] [blame] | 576 | |
| Petr Mladek | 3e0e88f | 2012-11-29 11:14:13 +0100 | [diff] [blame] | 577 | load_data(\%data, $top_dir, \%module_dirname, $branch_name, $git_command, $git_cherry, $git_args); |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 578 | get_bug_list(\%data, \%bugs, $check_bugzilla) if ($list_bugs); |
| Petr Mladek | 33a8400 | 2011-04-26 20:03:01 +0200 | [diff] [blame] | 579 | |
| Petr Mladek | 7cc7e40 | 2013-03-06 15:15:01 +0100 | [diff] [blame] | 580 | generate_log(\%data, \&print_commits, $log_dir, "commits", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"commits"}); |
| 581 | generate_log(\%bugs, \&print_bugs, $log_dir, "bugs", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"bugs"}); |
| 582 | generate_log(\%bugs, \&print_bugs, $log_dir, "bugs", $log_suffix, $top_dir, $branch_name, 1) if (defined $generate_log{"bugs-wiki"}); |
| 583 | generate_log(\%bugs, \&print_bugs_changelog, $log_dir, "bugs-changelog", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"bugs-changelog"}); |
| 584 | generate_log(\%bugs, \&print_bugnumbers, $log_dir, "bug-numbers", $log_suffix, $top_dir, $branch_name, 0) if (defined $generate_log{"bugs-numbers"}); |