Title: [102481] trunk/Tools
Revision
102481
Author
hara...@chromium.org
Date
2011-12-09 15:26:42 -0800 (Fri, 09 Dec 2011)

Log Message

[Refactoring] In prepare-ChangeLog, move top-level code to fetch a bug description from URL into a method
https://bugs.webkit.org/show_bug.cgi?id=74173

Reviewed by Ryosuke Niwa.

The objective is to make prepare-ChangeLog a loadable Perl module for unit testing.
This requires to remove top-level code. This patch is one of the incremental refactorings
for that.

* Scripts/prepare-ChangeLog: Moved top-level code to fetch a bug description from URL into fetchBugDescriptionFromURL().
(fetchBugDescriptionFromURL):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (102480 => 102481)


--- trunk/Tools/ChangeLog	2011-12-09 23:26:38 UTC (rev 102480)
+++ trunk/Tools/ChangeLog	2011-12-09 23:26:42 UTC (rev 102481)
@@ -1,3 +1,17 @@
+2011-12-09  Kentaro Hara  <hara...@chromium.org>
+
+        [Refactoring] In prepare-ChangeLog, move top-level code to fetch a bug description from URL into a method
+        https://bugs.webkit.org/show_bug.cgi?id=74173
+
+        Reviewed by Ryosuke Niwa.
+
+        The objective is to make prepare-ChangeLog a loadable Perl module for unit testing.
+        This requires to remove top-level code. This patch is one of the incremental refactorings
+        for that.
+
+        * Scripts/prepare-ChangeLog: Moved top-level code to fetch a bug description from URL into fetchBugDescriptionFromURL().
+        (fetchBugDescriptionFromURL):
+
 2011-12-09  Tony Chang  <t...@chromium.org>
 
         Switch the chromium mac bots to using skia test results

Modified: trunk/Tools/Scripts/prepare-ChangeLog (102480 => 102481)


--- trunk/Tools/Scripts/prepare-ChangeLog	2011-12-09 23:26:38 UTC (rev 102480)
+++ trunk/Tools/Scripts/prepare-ChangeLog	2011-12-09 23:26:42 UTC (rev 102481)
@@ -67,6 +67,7 @@
 sub changeLogDate($);
 sub changeLogEmailAddressFromArgs($);
 sub changeLogNameFromArgs($);
+sub fetchBugDescriptionFromURL($);
 sub firstDirectoryOrCwd();
 sub diffFromToString();
 sub diffCommand(@);
@@ -256,37 +257,18 @@
 
 print STDERR "  Change author: $name <$emailAddress>.\n";
 
+# Remove trailing parenthesized notes from user name (bit of hack).
+$name =~ s/\(.*?\)\s*$//g;
+
 my $bugURL;
 if ($bugNumber) {
     $bugURL = "https://bugs.webkit.org/show_bug.cgi?id=$bugNumber";
 }
 
 if ($bugNumber && !$bugDescription) {
-    my $bugXMLURL = "$bugURL&ctype=xml";
-    # Perl has no built in XML processing, so we'll fetch and parse with curl and grep
-    # Pass --insecure because some cygwin installs have no certs we don't
-    # care about validating that bugs.webkit.org is who it says it is here.
-    my $descriptionLine = `curl --insecure --silent "$bugXMLURL" | grep short_desc`;
-    if ($descriptionLine !~ /<short_desc>(.*)<\/short_desc>/) {
-        # Maybe the reason the above did not work is because the curl that is installed doesn't
-        # support ssl at all.
-        if (`curl --version | grep ^Protocols` !~ /\bhttps\b/) {
-            print STDERR "  Could not get description for bug $bugNumber.\n";
-            print STDERR "  It looks like your version of curl does not support ssl.\n";
-            print STDERR "  If you are using macports, this can be fixed with sudo port install curl +ssl.\n";
-        } else {
-            print STDERR "  Bug $bugNumber has no bug description. Maybe you set wrong bug ID?\n";
-            print STDERR "  The bug URL: $bugXMLURL\n";
-        }
-        exit 1;
-    }
-    $bugDescription = decodeEntities($1);
-    print STDERR "  Description from bug $bugNumber:\n    \"$bugDescription\".\n";
+    $bugDescription = fetchBugDescriptionFromURL($bugURL);
 }
 
-# Remove trailing parenthesized notes from user name (bit of hack).
-$name =~ s/\(.*?\)\s*$//g;
-
 # Find the change logs.
 my %has_log;
 my %files;
@@ -488,6 +470,33 @@
     return $emailAddressFromArgs || changeLogEmailAddress();
 }
 
+sub fetchBugDescriptionFromURL($)
+{
+    my ($bugURL) = @_;
+
+    my $bugXMLURL = "$bugURL&ctype=xml";
+    # Perl has no built in XML processing, so we'll fetch and parse with curl and grep
+    # Pass --insecure because some cygwin installs have no certs we don't
+    # care about validating that bugs.webkit.org is who it says it is here.
+    my $descriptionLine = `curl --insecure --silent "$bugXMLURL" | grep short_desc`;
+    if ($descriptionLine !~ /<short_desc>(.*)<\/short_desc>/) {
+        # Maybe the reason the above did not work is because the curl that is installed doesn't
+        # support ssl at all.
+        if (`curl --version | grep ^Protocols` !~ /\bhttps\b/) {
+            print STDERR "  Could not get description for bug $bugNumber.\n";
+            print STDERR "  It looks like your version of curl does not support ssl.\n";
+            print STDERR "  If you are using macports, this can be fixed with sudo port install curl +ssl.\n";
+        } else {
+            print STDERR "  Bug $bugNumber has no bug description. Maybe you set wrong bug ID?\n";
+            print STDERR "  The bug URL: $bugXMLURL\n";
+        }
+        exit 1;
+    }
+    my $bugDescription = decodeEntities($1);
+    print STDERR "  Description from bug $bugNumber:\n    \"$bugDescription\".\n";
+    return $bugDescription;
+}
+
 sub get_function_line_ranges($$)
 {
     my ($file_handle, $file_name) = @_;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to