Provide a way to update the commit message with an updated list of changed files/functions
https://bugs.webkit.org/show_bug.cgi?id=230195

Patch by Hoa Dinh <dvh@apple.com> on 2021-09-14
Reviewed by Jonathan Bedard.

Add a new parameter --only-files to request generation of only the part of the changed files/functions.

* Scripts/prepare-ChangeLog:
(main):
(generateNewChangeLogs):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@282391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/Scripts/prepare-ChangeLog b/Tools/Scripts/prepare-ChangeLog
index b74c9ff..2cd6035 100755
--- a/Tools/Scripts/prepare-ChangeLog
+++ b/Tools/Scripts/prepare-ChangeLog
@@ -84,7 +84,7 @@
 sub findOriginalFileFromSvn($);
 sub generateFileList(\%$$$\%);
 sub generateFunctionLists($$$$$);
-sub generateNewChangeLogs($$$$$$$$$$$$$$);
+sub generateNewChangeLogs($$$$$$$$$$$$$$$);
 sub getLatestChangeLogs($);
 sub get_function_line_ranges($$);
 sub get_function_line_ranges_for_cpp($$);
@@ -145,6 +145,7 @@
     my $showHelp = 0;
     my $spewDiff = $ENV{"PREPARE_CHANGELOG_DIFF"};
     my $updateChangeLogs = 1;
+    my $onlyFiles = 0;
     my $parseOptionsResult =
         GetOptions("diff|d!" => \$spewDiff,
                    "bug|b:i" => \$bugNumber,
@@ -160,7 +161,8 @@
                    "style!" => \$checkWebKitStyle,
                    "open|o!" => \$openChangeLogs,
                    "write!" => \$writeChangeLogs,
-                   "update!" => \$updateChangeLogs);
+                   "update!" => \$updateChangeLogs,
+                   "only-files" => \$onlyFiles);
     if (!$parseOptionsResult || $showHelp) {
         print STDERR basename($0) . " [-b|--bug=<bugid>] [-d|--diff] [-h|--help] [-o|--open] [-g|--git-commit=<committish>] [--git-reviewer=<name>] [svndir1 [svndir2 ...]]\n";
         print STDERR "  -b|--bug        Fill in the ChangeLog bug information from the given bug.\n";
@@ -178,6 +180,7 @@
         print STDERR "  --[no-]write    Write ChangeLogs to disk (otherwise send new entries to stdout) (default: write)\n";
         print STDERR "  --delimiters    When writing to stdout, label and print a \"~\" after each entry\n";
         print STDERR "  --email=        Specify the email address to be used in the patch\n";
+        print STDERR "  --only-files    Exclude the standard changelog header and only include references to files.\n";
         return 1;
     }
 
@@ -237,7 +240,7 @@
         resolveConflictedChangeLogs($changeLogs);
     }
 
-    generateNewChangeLogs($prefixes, $filesInChangeLog, $addedRegressionTests, $requiresTests, $functionLists, $bugURL, $bugDescription, $bugRadarURL, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters);
+    generateNewChangeLogs($prefixes, $filesInChangeLog, $addedRegressionTests, $requiresTests, $functionLists, $bugURL, $bugDescription, $bugRadarURL, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters, $onlyFiles);
 
     if ($writeChangeLogs) {
         print STDERR "-- Please remember to include a detailed description in your ChangeLog entry. --\n-- See <http://webkit.org/coding/contributing.html> for more info --\n";
@@ -631,9 +634,9 @@
     close RESOLVE;
 }
 
-sub generateNewChangeLogs($$$$$$$$$$$$$$)
+sub generateNewChangeLogs($$$$$$$$$$$$$$$)
 {
-    my ($prefixes, $filesInChangeLog, $addedRegressionTests, $requiresTests, $functionLists, $bugURL, $bugDescription, $bugRadarURL, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters) = @_;
+    my ($prefixes, $filesInChangeLog, $addedRegressionTests, $requiresTests, $functionLists, $bugURL, $bugDescription, $bugRadarURL, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters, $onlyFiles) = @_;
 
     my $hasWebCoreChange = 0;
     foreach my $prefix (@$prefixes) {
@@ -667,8 +670,10 @@
             print substr($prefix, 0, length($prefix) - 1) . ":\n\n" unless (scalar @$prefixes) == 1 && !$delimiters;
         }
 
-        my $date = changeLogDate(ChangeLogTimeZone);
-        print CHANGE_LOG normalizeLineEndings("$date  $name  <$emailAddress>\n\n", $endl);
+        if (!$onlyFiles) {
+            my $date = changeLogDate(ChangeLogTimeZone);
+            print CHANGE_LOG normalizeLineEndings("$date  $name  <$emailAddress>\n\n", $endl);
+        }
 
         my ($reviewer, $description) = reviewerAndDescriptionForGitCommit($gitCommit, $gitReviewer) if $gitCommit;
         $reviewer = "NOBODY (OO" . "PS!)" if !$reviewer;
@@ -680,13 +685,15 @@
         $bugDescription = "Need a short description (OOPS!)." unless $bugDescription;
         $bugURL = "Need the bug URL (OOPS!)." unless $bugURL;
 
-        print CHANGE_LOG normalizeLineEndings("        $bugDescription\n", $endl) if $bugDescription;
-        print CHANGE_LOG normalizeLineEndings("        $bugURL\n", $endl) if $bugURL;
-        print CHANGE_LOG normalizeLineEndings("        $bugRadarURL\n", $endl) if $bugRadarURL;
-        print CHANGE_LOG normalizeLineEndings("\n", $endl);
+        if (!$onlyFiles) {
+            print CHANGE_LOG normalizeLineEndings("        $bugDescription\n", $endl) if $bugDescription;
+            print CHANGE_LOG normalizeLineEndings("        $bugURL\n", $endl) if $bugURL;
+            print CHANGE_LOG normalizeLineEndings("        $bugRadarURL\n", $endl) if $bugRadarURL;
+            print CHANGE_LOG normalizeLineEndings("\n", $endl);
 
-        print CHANGE_LOG normalizeLineEndings("        Reviewed by $reviewer.\n\n", $endl);
-        print CHANGE_LOG normalizeLineEndings($description . "\n", $endl) if $description;
+            print CHANGE_LOG normalizeLineEndings("        Reviewed by $reviewer.\n\n", $endl);
+            print CHANGE_LOG normalizeLineEndings($description . "\n", $endl) if $description;
+        }
 
         my $shouldMentionTests = @$requiresTests;
         $shouldMentionTests |= !$hasWebCoreChange && unixPath($prefix) =~ m|/WebKit/$|;