Title: [121873] trunk/Tools
Revision
121873
Author
[email protected]
Date
2012-07-04 15:41:17 -0700 (Wed, 04 Jul 2012)

Log Message

webkit-patch should add reviewer if "Reviewed by NOBODY ..." is missing
https://bugs.webkit.org/show_bug.cgi?id=67935

Patch by Balazs Ankes <[email protected]> on 2012-07-04
Reviewed by Ryosuke Niwa.

* Scripts/webkitpy/common/checkout/changelog.py:
(ChangeLog.set_reviewer):
* Scripts/webkitpy/common/checkout/changelog_unittest.py:
(test_set_reviewer):
(test_set_short_description_and_bug_url):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (121872 => 121873)


--- trunk/Tools/ChangeLog	2012-07-04 22:06:39 UTC (rev 121872)
+++ trunk/Tools/ChangeLog	2012-07-04 22:41:17 UTC (rev 121873)
@@ -1,3 +1,16 @@
+2012-07-04  Balazs Ankes  <[email protected]>
+
+        webkit-patch should add reviewer if "Reviewed by NOBODY ..." is missing
+        https://bugs.webkit.org/show_bug.cgi?id=67935
+
+        Reviewed by Ryosuke Niwa.
+
+        * Scripts/webkitpy/common/checkout/changelog.py:
+        (ChangeLog.set_reviewer):
+        * Scripts/webkitpy/common/checkout/changelog_unittest.py:
+        (test_set_reviewer):
+        (test_set_short_description_and_bug_url):
+
 2012-07-04  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r121862.

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py (121872 => 121873)


--- trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py	2012-07-04 22:06:39 UTC (rev 121872)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py	2012-07-04 22:41:17 UTC (rev 121873)
@@ -345,11 +345,29 @@
                 print line,
 
     def set_reviewer(self, reviewer):
-        # inplace=1 creates a backup file and re-directs stdout to the file
-        for line in fileinput.FileInput(self.path, inplace=1):
-            # Trailing comma suppresses printing newline
-            print line.replace("NOBODY (OOPS!)", reviewer.encode("utf-8")),
+        latest_entry = self.latest_entry()
+        latest_entry_contents = latest_entry.contents()
+        reviewer_text = latest_entry.reviewer()
+        found_nobody = re.search("NOBODY\s*\(OOPS!\)", latest_entry_contents, re.MULTILINE)
 
+        if not found_nobody and not reviewer_text:
+            bug_url_number_of_items = len(re.findall(config_urls.bug_url_long, latest_entry_contents, re.MULTILINE))
+            bug_url_number_of_items += len(re.findall(config_urls.bug_url_short, latest_entry_contents, re.MULTILINE))
+            for line in fileinput.FileInput(self.path, inplace=1):
+                found_bug_url = re.search(config_urls.bug_url_long, line)
+                if not found_bug_url:
+                    found_bug_url = re.search(config_urls.bug_url_short, line)
+                print line,
+                if found_bug_url:
+                    if bug_url_number_of_items == 1:
+                        print "\n        Reviewed by %s." % (reviewer.encode("utf-8"))
+                    bug_url_number_of_items -= 1
+        else:
+            # inplace=1 creates a backup file and re-directs stdout to the file
+            for line in fileinput.FileInput(self.path, inplace=1):
+                # Trailing comma suppresses printing newline
+                print line.replace("NOBODY (OOPS!)", reviewer.encode("utf-8")),
+
     def set_short_description_and_bug_url(self, short_description, bug_url):
         message = "%s\n        %s" % (short_description, bug_url)
         for line in fileinput.FileInput(self.path, inplace=1):

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py (121872 => 121873)


--- trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py	2012-07-04 22:06:39 UTC (rev 121872)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py	2012-07-04 22:41:17 UTC (rev 121873)
@@ -496,8 +496,46 @@
         * Scripts/bugzilla-tool:
 '''
 
+    _new_entry_boilerplate_with_bugurl = '''2009-08-19  Eric Seidel  <[email protected]>
+
+        Need a short description and bug URL (OOPS!)
+        https://bugs.webkit.org/show_bug.cgi?id=12345
+
+        Reviewed by NOBODY (OOPS!).
+
+        * Scripts/bugzilla-tool:
+'''
+
+    _new_entry_boilerplate_with_multiple_bugurl = '''2009-08-19  Eric Seidel  <[email protected]>
+
+        Need a short description and bug URL (OOPS!)
+        https://bugs.webkit.org/show_bug.cgi?id=12345
+        http://webkit.org/b/12345
+
+        Reviewed by NOBODY (OOPS!).
+
+        * Scripts/bugzilla-tool:
+'''
+
+    _new_entry_boilerplate_without_reviewer_line = '''2009-08-19  Eric Seidel  <[email protected]>
+
+        Need a short description and bug URL (OOPS!)
+        https://bugs.webkit.org/show_bug.cgi?id=12345
+
+        * Scripts/bugzilla-tool:
+'''
+
+    _new_entry_boilerplate_without_reviewer_multiple_bugurl = '''2009-08-19  Eric Seidel  <[email protected]>
+
+        Need a short description and bug URL (OOPS!)
+        https://bugs.webkit.org/show_bug.cgi?id=12345
+        http://webkit.org/b/12345
+
+        * Scripts/bugzilla-tool:
+'''
+
     def test_set_reviewer(self):
-        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)
+        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_bugurl, self._example_changelog)
         changelog_path = self._write_tmp_file_with_contents(changelog_contents.encode("utf-8"))
         reviewer_name = 'Test Reviewer'
         ChangeLog(changelog_path).set_reviewer(reviewer_name)
@@ -506,8 +544,24 @@
         os.remove(changelog_path)
         self.assertEquals(actual_contents.splitlines(), expected_contents.splitlines())
 
+        changelog_contents_without_reviewer_line = u"%s\n%s" % (self._new_entry_boilerplate_without_reviewer_line, self._example_changelog)
+        changelog_path = self._write_tmp_file_with_contents(changelog_contents_without_reviewer_line.encode("utf-8"))
+        ChangeLog(changelog_path).set_reviewer(reviewer_name)
+        actual_contents = self._read_file_contents(changelog_path, "utf-8")
+        os.remove(changelog_path)
+        self.assertEquals(actual_contents.splitlines(), expected_contents.splitlines())
+
+        changelog_contents_without_reviewer_line = u"%s\n%s" % (self._new_entry_boilerplate_without_reviewer_multiple_bugurl, self._example_changelog)
+        changelog_path = self._write_tmp_file_with_contents(changelog_contents_without_reviewer_line.encode("utf-8"))
+        ChangeLog(changelog_path).set_reviewer(reviewer_name)
+        actual_contents = self._read_file_contents(changelog_path, "utf-8")
+        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_multiple_bugurl, self._example_changelog)
+        expected_contents = changelog_contents.replace('NOBODY (OOPS!)', reviewer_name)
+        os.remove(changelog_path)
+        self.assertEquals(actual_contents.splitlines(), expected_contents.splitlines())
+
     def test_set_short_description_and_bug_url(self):
-        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)
+        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_bugurl, self._example_changelog)
         changelog_path = self._write_tmp_file_with_contents(changelog_contents.encode("utf-8"))
         short_description = "A short description"
         bug_url = "http://example.com/b/2344"
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to