Changeset 90564 in webkit


Ignore:
Timestamp:
Jul 7, 2011 9:36:32 AM (13 years ago)
Author:
Adam Roben
Message:

Teach webkitpy's Checkout class to use commit-log-editor to create commit messages

Fixes <http://webkit.org/b/26755> webkit-patch's commit messages are less readable than
commit-log-editor's

Reviewed by David Kilzer.

  • Scripts/webkitpy/common/checkout/checkout.py:

(Checkout.commit_message_for_this_commit): Run commit-log-editor, passing it the paths of
the modified ChangeLogs, to generate the commit message, rather than trying to generate one
ourselves.

  • Scripts/webkitpy/common/checkout/checkout_unittest.py: Updated the expected commit message

to match commit-log-editor's format.
(CommitMessageForThisCommitTest.setUp): Write the ChangeLogs into Tools and LayoutTests
directories so we can see how the various entries get labeled in the commit message.
(CommitMessageForThisCommitTest.test_commit_message_for_this_commit): Create a mock SCM
instance that knows how to find commit-log-editor and pass it to our Checkout instance.
Don't bother capturing output, since there shouldn't be any.

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r90563 r90564  
     12011-07-07  Adam Roben  <aroben@apple.com>
     2
     3        Teach webkitpy's Checkout class to use commit-log-editor to create commit messages
     4
     5        Fixes <http://webkit.org/b/26755> webkit-patch's commit messages are less readable than
     6        commit-log-editor's
     7
     8        Reviewed by David Kilzer.
     9
     10        * Scripts/webkitpy/common/checkout/checkout.py:
     11        (Checkout.commit_message_for_this_commit): Run commit-log-editor, passing it the paths of
     12        the modified ChangeLogs, to generate the commit message, rather than trying to generate one
     13        ourselves.
     14
     15        * Scripts/webkitpy/common/checkout/checkout_unittest.py: Updated the expected commit message
     16        to match commit-log-editor's format.
     17        (CommitMessageForThisCommitTest.setUp): Write the ChangeLogs into Tools and LayoutTests
     18        directories so we can see how the various entries get labeled in the commit message.
     19        (CommitMessageForThisCommitTest.test_commit_message_for_this_commit): Create a mock SCM
     20        instance that knows how to find commit-log-editor and pass it to our Checkout instance.
     21        Don't bother capturing output, since there shouldn't be any.
     22
    1232011-07-07  Adam Roben  <aroben@apple.com>
    224
  • trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py

    r85727 r90564  
    121121                              "All changes require a ChangeLog.  See:\n %s" % urls.contribution_guidelines)
    122122
    123         changelog_messages = []
    124         for changelog_path in changelog_paths:
    125             log("Parsing ChangeLog: %s" % changelog_path)
    126             changelog_entry = ChangeLog(changelog_path).latest_entry()
    127             if not changelog_entry:
    128                 raise ScriptError(message="Failed to parse ChangeLog: %s" % os.path.abspath(changelog_path))
    129             changelog_messages.append(changelog_entry.contents())
    130 
    131         # FIXME: We should sort and label the ChangeLog messages like commit-log-editor does.
    132         return CommitMessage("".join(changelog_messages).splitlines())
     123        message_text = Executive().run_command([self._scm.script_path('commit-log-editor'), '--print-log'] + changelog_paths, return_stderr=False)
     124        return CommitMessage(message_text.splitlines())
    133125
    134126    def recent_commit_infos_for_files(self, paths):
  • trunk/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py

    r85452 r90564  
    3838from .changelog import ChangeLogEntry
    3939from .scm import detect_scm_system, CommitMessage
    40 from webkitpy.common.system.outputcapture import OutputCapture
    4140from webkitpy.common.system.executive import ScriptError
    4241from webkitpy.thirdparty.mock import Mock
     
    8483
    8584class CommitMessageForThisCommitTest(unittest.TestCase):
    86     expected_commit_message = u"""2010-03-25  Tor Arne Vestb\u00f8  <vestbo@webkit.org>
    87 
    88         Unreviewed build fix to un-break webkit-patch land.
    89 
    90         Move commit_message_for_this_commit from scm to checkout
    91         https://bugs.webkit.org/show_bug.cgi?id=36629
    92 
    93         * Scripts/webkitpy/common/checkout/api.py: import scm.CommitMessage
    94 2010-03-25  Tor Arne Vestb\u00f8  <vestbo@webkit.org>
    95 
    96         Unreviewed build fix to un-break webkit-patch land.
    97 
    98         Second part of this complicated change.
    99 
    100         * Path/To/Complicated/File: Added.
     85    expected_commit_message = u"""Unreviewed build fix to un-break webkit-patch land.
     86
     87Tools:
     88
     89Move commit_message_for_this_commit from scm to checkout
     90https://bugs.webkit.org/show_bug.cgi?id=36629
     91
     92* Scripts/webkitpy/common/checkout/api.py: import scm.CommitMessage
     93
     94LayoutTests:
     95
     96Second part of this complicated change.
     97
     98* Path/To/Complicated/File: Added.
    10199"""
    102100
     
    105103        self.old_cwd = os.getcwd()
    106104        os.chdir(self.temp_dir)
    107         write_into_file_at_path("ChangeLog1", _changelog1)
    108         write_into_file_at_path("ChangeLog2", _changelog2)
     105
     106        # Trick commit-log-editor into thinking we're in a Subversion working copy so it won't
     107        # complain about not being able to figure out what SCM is in use.
     108        os.mkdir(".svn")
     109
     110        self.changelogs = map(os.path.abspath, (os.path.join("Tools", "ChangeLog"), os.path.join("LayoutTests", "ChangeLog")))
     111        for path, contents in zip(self.changelogs, (_changelog1, _changelog2)):
     112            os.makedirs(os.path.dirname(path))
     113            write_into_file_at_path(path, contents)
    109114
    110115    def tearDown(self):
     
    115120    # ChangeLog is difficult to mock at current.
    116121    def test_commit_message_for_this_commit(self):
    117         checkout = Checkout(None)
    118         checkout.modified_changelogs = lambda git_commit, changed_files=None: ["ChangeLog1", "ChangeLog2"]
    119         output = OutputCapture()
    120         expected_stderr = "Parsing ChangeLog: ChangeLog1\nParsing ChangeLog: ChangeLog2\n"
    121         commit_message = output.assert_outputs(self, checkout.commit_message_for_this_commit,
    122             kwargs={"git_commit": None}, expected_stderr=expected_stderr)
     122        scm = Mock()
     123
     124        def mock_script_path(script):
     125            return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', script))
     126
     127        scm.script_path = mock_script_path
     128
     129        checkout = Checkout(scm)
     130        checkout.modified_changelogs = lambda git_commit, changed_files=None: self.changelogs
     131        commit_message = checkout.commit_message_for_this_commit(git_commit=None)
    123132        self.assertEqual(commit_message.message(), self.expected_commit_message)
    124133
Note: See TracChangeset for help on using the changeset viewer.