Commit f7831235 authored by aroben@apple.com's avatar aroben@apple.com

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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@90564 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4b7b4872
2011-07-07 Adam Roben <aroben@apple.com>
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.
2011-07-07 Adam Roben <aroben@apple.com>
Add a --print-log option to commit-log-editor
......
......@@ -120,16 +120,8 @@ class Checkout(object):
raise ScriptError(message="Found no modified ChangeLogs, cannot create a commit message.\n"
"All changes require a ChangeLog. See:\n %s" % urls.contribution_guidelines)
changelog_messages = []
for changelog_path in changelog_paths:
log("Parsing ChangeLog: %s" % changelog_path)
changelog_entry = ChangeLog(changelog_path).latest_entry()
if not changelog_entry:
raise ScriptError(message="Failed to parse ChangeLog: %s" % os.path.abspath(changelog_path))
changelog_messages.append(changelog_entry.contents())
# FIXME: We should sort and label the ChangeLog messages like commit-log-editor does.
return CommitMessage("".join(changelog_messages).splitlines())
message_text = Executive().run_command([self._scm.script_path('commit-log-editor'), '--print-log'] + changelog_paths, return_stderr=False)
return CommitMessage(message_text.splitlines())
def recent_commit_infos_for_files(self, paths):
revisions = set(sum(map(self._scm.revisions_changing_file, paths), []))
......
......@@ -37,7 +37,6 @@ import unittest
from .checkout import Checkout
from .changelog import ChangeLogEntry
from .scm import detect_scm_system, CommitMessage
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.common.system.executive import ScriptError
from webkitpy.thirdparty.mock import Mock
......@@ -83,29 +82,35 @@ _changelog2 = u"""2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org>
"""
class CommitMessageForThisCommitTest(unittest.TestCase):
expected_commit_message = u"""2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org>
expected_commit_message = u"""Unreviewed build fix to un-break webkit-patch land.
Unreviewed build fix to un-break webkit-patch land.
Tools:
Move commit_message_for_this_commit from scm to checkout
https://bugs.webkit.org/show_bug.cgi?id=36629
Move commit_message_for_this_commit from scm to checkout
https://bugs.webkit.org/show_bug.cgi?id=36629
* Scripts/webkitpy/common/checkout/api.py: import scm.CommitMessage
2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org>
* Scripts/webkitpy/common/checkout/api.py: import scm.CommitMessage
Unreviewed build fix to un-break webkit-patch land.
LayoutTests:
Second part of this complicated change.
Second part of this complicated change.
* Path/To/Complicated/File: Added.
* Path/To/Complicated/File: Added.
"""
def setUp(self):
self.temp_dir = tempfile.mkdtemp(suffix="changelogs")
self.old_cwd = os.getcwd()
os.chdir(self.temp_dir)
write_into_file_at_path("ChangeLog1", _changelog1)
write_into_file_at_path("ChangeLog2", _changelog2)
# Trick commit-log-editor into thinking we're in a Subversion working copy so it won't
# complain about not being able to figure out what SCM is in use.
os.mkdir(".svn")
self.changelogs = map(os.path.abspath, (os.path.join("Tools", "ChangeLog"), os.path.join("LayoutTests", "ChangeLog")))
for path, contents in zip(self.changelogs, (_changelog1, _changelog2)):
os.makedirs(os.path.dirname(path))
write_into_file_at_path(path, contents)
def tearDown(self):
shutil.rmtree(self.temp_dir, ignore_errors=True)
......@@ -114,12 +119,16 @@ class CommitMessageForThisCommitTest(unittest.TestCase):
# FIXME: This should not need to touch the file system, however
# ChangeLog is difficult to mock at current.
def test_commit_message_for_this_commit(self):
checkout = Checkout(None)
checkout.modified_changelogs = lambda git_commit, changed_files=None: ["ChangeLog1", "ChangeLog2"]
output = OutputCapture()
expected_stderr = "Parsing ChangeLog: ChangeLog1\nParsing ChangeLog: ChangeLog2\n"
commit_message = output.assert_outputs(self, checkout.commit_message_for_this_commit,
kwargs={"git_commit": None}, expected_stderr=expected_stderr)
scm = Mock()
def mock_script_path(script):
return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', script))
scm.script_path = mock_script_path
checkout = Checkout(scm)
checkout.modified_changelogs = lambda git_commit, changed_files=None: self.changelogs
commit_message = checkout.commit_message_for_this_commit(git_commit=None)
self.assertEqual(commit_message.message(), self.expected_commit_message)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment