Changeset 171954 in webkit
- Timestamp:
- Aug 1, 2014 4:10:50 PM (10 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r171947 r171954 1 2014-08-01 Dan Bernstein <mitz@apple.com> 2 3 commit-log-editor uses a non-standard message format when git index contains no ChangeLog changes 4 https://bugs.webkit.org/show_bug.cgi?id=135527 5 6 Reviewed by Tim Horton. 7 8 * Scripts/commit-log-editor: 9 In the case of a git repository when there are no changed ChangeLog files, changed to pass 10 the --delimiters option to prepare-ChangeLog, then process each entry in the output using 11 commitMessageFromChangeLogEntry. 12 (commitMessageFromChangeLogEntry): Factored out from createCommitMessage. 13 (sortKey): Factored out from createCommitMessage. 14 (createCommitMessage): Changed to use new sortKey and commitMessageFromChangeLogEntry 15 subroutines. 16 17 * Scripts/prepare-ChangeLog: 18 (main): Parse new --delimiters option. 19 (generateNewChangeLogs): When --no-write and --delimiters are both specified, always print 20 the label before each change log entry, and a "~" delimiter on a new line after each entry. 21 1 22 2014-08-01 Bear Travis <betravis@adobe.com> 2 23 -
trunk/Tools/Scripts/commit-log-editor
r167751 r171954 39 39 use webkitdirs; 40 40 41 sub commitMessageFromChangeLogEntry($); 42 sub sortKey($); 41 43 sub createCommitMessage(@); 42 44 sub loadTermReadKey(); … … 177 179 } 178 180 if ($webkitGenerateCommitMessage ne "false") { 179 open CHANGELOG_ENTRIES, "-|", "$FindBin::Bin/prepare-ChangeLog --git-index --no-write --no-style" or die "prepare-ChangeLog failed: $!.\n"; 180 while (<CHANGELOG_ENTRIES>) { 181 print NEWLOG normalizeLineEndings($_, $endl); 182 } 183 close CHANGELOG_ENTRIES; 181 my %changeLogSort; 182 my %changeLogContents; 183 open my $changeLogEntries, "-|", "$FindBin::Bin/prepare-ChangeLog --git-index --no-write --no-style --delimiters" or die "prepare-ChangeLog failed: $!.\n"; 184 185 while (!eof($changeLogEntries)) { 186 my $label = <$changeLogEntries>; 187 chomp $label; 188 $label =~ s/:$//; 189 ($changeLogContents{$label}) = commitMessageFromChangeLogEntry($changeLogEntries); 190 $changeLogSort{sortKey($label)} = $label; 191 } 192 close $changeLogEntries; 193 194 my $commonPrefix = removeLongestCommonPrefixEndingInNewline(%changeLogContents); 195 196 my @result; 197 push @result, normalizeLineEndings($commonPrefix, $endl); 198 for my $sortKey (sort keys %changeLogSort) { 199 my $label = $changeLogSort{$sortKey}; 200 next if ($changeLogContents{$label} eq "\n"); 201 if (keys %changeLogSort > 1) { 202 push @result, normalizeLineEndings("\n", $endl); 203 push @result, normalizeLineEndings("$label: ", $endl); 204 } 205 push @result, normalizeLineEndings($changeLogContents{$label}, $endl); 206 } 207 208 print NEWLOG join '', @result; 184 209 } 185 210 } else { … … 210 235 unlink "$log.edit"; 211 236 237 sub commitMessageFromChangeLogEntry($) 238 { 239 my ($changeLog) = @_; 240 241 my $commitMessage = ""; 242 my $blankLines = ""; 243 my $lineCount = 0; 244 my $date = ""; 245 my $author = ""; 246 my $email = ""; 247 my $hasAuthorInfoToWrite = 0; 248 249 while (<$changeLog>) { 250 if (/^\S/) { 251 last if $commitMessage; 252 } 253 if (/\S/) { 254 $commitMessage .= $blankLines if $commitMessage; 255 $blankLines = ""; 256 257 my $line = $_; 258 # Remove indentation spaces 259 $line =~ s/^ {8}//; 260 261 # Grab the author and the date line 262 if ($line =~ m/^([0-9]{4}-[0-9]{2}-[0-9]{2})\s+(.*[^\s])\s+<(.*)>/ && $lineCount == 0) { 263 $date = $1; 264 $author = $2; 265 $email = $3; 266 $hasAuthorInfoToWrite = 1; 267 next; 268 } 269 270 if ($hasAuthorInfoToWrite) { 271 my $isReviewedByLine = $line =~ m/^(?:Reviewed|Rubber[ \-]?stamped) by/; 272 my $isModifiedFileLine = $line =~ m/^\* .*:/; 273 274 # Insert the authorship line if needed just above the "Reviewed by" line or the 275 # first modified file (whichever comes first). 276 if ($isReviewedByLine || $isModifiedFileLine) { 277 $hasAuthorInfoToWrite = 0; 278 my $authorshipString = patchAuthorshipString($author, $email, $date); 279 if ($authorshipString) { 280 $commitMessage .= "$authorshipString\n"; 281 $commitMessage .= "\n" if $isModifiedFileLine; 282 } 283 } 284 } 285 286 287 $lineCount++; 288 $commitMessage .= $line; 289 } else { 290 $blankLines .= $_; 291 } 292 } 293 return ($commitMessage, $hasAuthorInfoToWrite, $date, $author, $email); 294 } 295 296 sub sortKey($) 297 { 298 my ($label) = @_; 299 my $sortKey = lc $label; 300 if ($label eq "top level") { 301 $sortKey = ""; 302 } elsif ($label eq "LayoutTests") { 303 $sortKey = lc "~, LayoutTests last"; 304 } 305 return $sortKey; 306 } 307 212 308 sub createCommitMessage(@) 213 309 { … … 219 315 my %changeLogContents; 220 316 for my $changeLog (@changeLogs) { 221 open CHANGELOG, $changeLog or die "Can't open $changeLog"; 222 my $contents = ""; 223 my $blankLines = ""; 224 my $lineCount = 0; 225 my $date = ""; 226 my $author = ""; 227 my $email = ""; 228 my $hasAuthorInfoToWrite = 0; 229 while (<CHANGELOG>) { 230 if (/^\S/) { 231 last if $contents; 232 } 233 if (/\S/) { 234 $contents .= $blankLines if $contents; 235 $blankLines = ""; 236 237 my $line = $_; 238 239 # Remove indentation spaces 240 $line =~ s/^ {8}//; 241 242 # Grab the author and the date line 243 if ($line =~ m/^([0-9]{4}-[0-9]{2}-[0-9]{2})\s+(.*[^\s])\s+<(.*)>/ && $lineCount == 0) { 244 $date = $1; 245 $author = $2; 246 $email = $3; 247 $hasAuthorInfoToWrite = 1; 248 next; 249 } 250 251 if ($hasAuthorInfoToWrite) { 252 my $isReviewedByLine = $line =~ m/^(?:Reviewed|Rubber[ \-]?stamped) by/; 253 my $isModifiedFileLine = $line =~ m/^\* .*:/; 254 255 # Insert the authorship line if needed just above the "Reviewed by" line or the 256 # first modified file (whichever comes first). 257 if ($isReviewedByLine || $isModifiedFileLine) { 258 $hasAuthorInfoToWrite = 0; 259 my $authorshipString = patchAuthorshipString($author, $email, $date); 260 if ($authorshipString) { 261 $contents .= "$authorshipString\n"; 262 $contents .= "\n" if $isModifiedFileLine; 263 } 264 } 265 } 266 267 268 $lineCount++; 269 $contents .= $line; 270 } else { 271 $blankLines .= $_; 272 } 273 } 317 open my $changeLogFile, $changeLog or die "Can't open $changeLog"; 318 319 my ($contents, $hasAuthorInfoToWrite, $date, $author, $email) = commitMessageFromChangeLogEntry($changeLogFile); 274 320 if ($hasAuthorInfoToWrite) { 275 321 # We didn't find anywhere to put the authorship info, so just put it at the end. … … 279 325 } 280 326 281 close CHANGELOG;327 close $changeLogFile; 282 328 283 329 $changeLog = File::Spec->abs2rel(File::Spec->rel2abs($changeLog), $topLevel); … … 286 332 $label = "top level" unless length $label; 287 333 288 my $sortKey = lc $label; 289 if ($label eq "top level") { 290 $sortKey = ""; 291 } elsif ($label eq "LayoutTests") { 292 $sortKey = lc "~, LayoutTests last"; 293 } 294 295 $changeLogSort{$sortKey} = $label; 334 $changeLogSort{sortKey($label)} = $label; 296 335 $changeLogContents{$label} = $contents; 297 336 } -
trunk/Tools/Scripts/prepare-ChangeLog
r170521 r171954 81 81 sub generateFunctionLists($$$$$); 82 82 sub generateFunctionListsByRanges($$$$); 83 sub generateNewChangeLogs($$$$$$$$$$$ );83 sub generateNewChangeLogs($$$$$$$$$$$$); 84 84 sub getLatestChangeLogs($); 85 85 sub get_function_line_ranges($$); … … 132 132 my $openChangeLogs = 0; 133 133 my $writeChangeLogs = 1; 134 my $delimiters = 0; 134 135 my $showHelp = 0; 135 136 my $spewDiff = $ENV{"PREPARE_CHANGELOG_DIFF"}; … … 138 139 GetOptions("diff|d!" => \$spewDiff, 139 140 "bug|b:i" => \$bugNumber, 141 "delimiters" => \$delimiters, 140 142 "description:s" => \$bugDescription, 141 143 "name:s" => \$name, … … 165 167 print STDERR " --[no-]update Update ChangeLogs from svn before adding entry (default: update)\n"; 166 168 print STDERR " --[no-]write Write ChangeLogs to disk (otherwise send new entries to stdout) (default: write)\n"; 169 print STDERR " --delimiters When writing to stdout, label and print a \"~\" after each entry\n"; 167 170 print STDERR " --email= Specify the email address to be used in the patch\n"; 168 171 return 1; … … 223 226 } 224 227 225 generateNewChangeLogs($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs );228 generateNewChangeLogs($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters); 226 229 227 230 if ($writeChangeLogs) { … … 523 526 } 524 527 525 sub generateNewChangeLogs($$$$$$$$$$$ )526 { 527 my ($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs ) = @_;528 sub generateNewChangeLogs($$$$$$$$$$$$) 529 { 530 my ($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters) = @_; 528 531 529 532 # Generate new ChangeLog entries and (optionally) write out new ChangeLog files. … … 548 551 } else { 549 552 open CHANGE_LOG, ">-" or die "Could not write to STDOUT\n."; 550 print substr($prefix, 0, length($prefix) - 1) . ":\n\n" unless (scalar @$prefixes) == 1 ;553 print substr($prefix, 0, length($prefix) - 1) . ":\n\n" unless (scalar @$prefixes) == 1 && !$delimiters; 551 554 } 552 555 … … 583 586 } else { 584 587 print CHANGE_LOG "\n"; 588 print "~\n" if $delimiters; 585 589 } 586 590
Note: See TracChangeset
for help on using the changeset viewer.