Reviewers: Jakob,
Message:
PTAL
Description:
Pythonification of change log formatting for push-to-trunk.
Please review this at https://codereview.chromium.org/81193002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+37, -41 lines):
M tools/push-to-trunk/common_includes.py
M tools/push-to-trunk/push_to_trunk.py
M tools/push-to-trunk/test_scripts.py
Index: tools/push-to-trunk/common_includes.py
diff --git a/tools/push-to-trunk/common_includes.py
b/tools/push-to-trunk/common_includes.py
index
b6f976144d70c0054806a136b0ca93a039568a85..037b17a85abcb989cd43448400174addc913cc57
100644
--- a/tools/push-to-trunk/common_includes.py
+++ b/tools/push-to-trunk/common_includes.py
@@ -69,6 +69,10 @@ def MSub(rexp, replacement, text):
def Fill80(line):
+ # Replace tabs and remove surrounding space.
+ line = re.sub(r"\t", r" ", line.strip())
+
+ # Format with 8 characters indentation and line width 80.
return textwrap.fill(line, width=80, initial_indent=" ",
subsequent_indent=" ")
@@ -96,7 +100,7 @@ def MakeChangeLogBody(commit_messages,
auto_format=False):
for (title, body, author) in commit_messages:
# TODO(machenbach): Reload the commit description from rietveld in
order to
# catch late changes.
- title = title.rstrip()
+ title = title.strip()
if auto_format:
# Only add commits that set the LOG flag correctly.
log_exp = r"^[ \t]*LOG[ \t]*=[ \t]*(?:Y(?:ES)?)|TRUE"
@@ -114,7 +118,7 @@ def MakeChangeLogBody(commit_messages,
auto_format=False):
# indentation afterwards.
# Add the commit's title line.
- result += "%s\n" % title
+ result += "%s\n" % Fill80(title)
added_titles.add(title)
# Add bug references.
@@ -122,7 +126,7 @@ def MakeChangeLogBody(commit_messages,
auto_format=False):
# Append the commit's author for reference if not in auto-format mode.
if not auto_format:
- result += "%s\n" % author.rstrip()
+ result += "%s\n" % Fill80("(%s)" % author.strip())
result += "\n"
return result
Index: tools/push-to-trunk/push_to_trunk.py
diff --git a/tools/push-to-trunk/push_to_trunk.py
b/tools/push-to-trunk/push_to_trunk.py
index
7278323e223b09379abef5402ba356be372f39ec..89c1259ab005687710ca816b786e2a2ea1ceda37
100755
--- a/tools/push-to-trunk/push_to_trunk.py
+++ b/tools/push-to-trunk/push_to_trunk.py
@@ -115,9 +115,9 @@ class PrepareChangeLog(Step):
# Cache raw commit messages.
commit_messages = [
[
- self.Git("log -1 %s --format=\"%%w(80,8,8)%%s\"" % commit),
+ self.Git("log -1 %s --format=\"%%s\"" % commit),
self.Git("log -1 %s --format=\"%%B\"" % commit),
- self.Git("log -1 %s --format=\"%%w(80,8,8)(%%an)\"" % commit),
+ self.Git("log -1 %s --format=\"%%an\"" % commit),
] for commit in commits.splitlines()
]
@@ -152,14 +152,10 @@ class EditChangeLog(Step):
handle, new_changelog = tempfile.mkstemp()
os.close(handle)
- # (1) Strip comments, (2) eliminate tabs, (3) fix too little and (4)
too
- # much indentation, and (5) eliminate trailing whitespace.
+ # Strip comments and reformat with correct indentation.
changelog_entry =
FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip()
changelog_entry = StripComments(changelog_entry)
- changelog_entry = MSub(r"\t", r" ", changelog_entry)
- changelog_entry = MSub(r"^ {1,7}([^ ])", r" \1",
changelog_entry)
- changelog_entry = MSub(r"^ {9,80}([^ ])", r" \1",
changelog_entry)
- changelog_entry = MSub(r" +$", r"", changelog_entry)
+ changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines()))
if changelog_entry == "":
self.Die("Empty ChangeLog entry.")
Index: tools/push-to-trunk/test_scripts.py
diff --git a/tools/push-to-trunk/test_scripts.py
b/tools/push-to-trunk/test_scripts.py
index
42b26cfb7a9ad01028308f39847cb321c44db8d1..dc7e1d0bb5445b7bce67a0954a09273040d65974
100644
--- a/tools/push-to-trunk/test_scripts.py
+++ b/tools/push-to-trunk/test_scripts.py
@@ -67,18 +67,18 @@ class ToplevelTest(unittest.TestCase):
def testMakeChangeLogBodySimple(self):
commits = [
- [" Title text 1",
+ ["Title text 1",
"Title text 1\n\nBUG=\n",
- " [email protected]"],
- [" Title text 2",
+ "[email protected]"],
+ ["Title text 2",
"Title text 2\n\nBUG=1234\n",
- " [email protected]"],
+ "[email protected]"],
]
self.assertEquals(" Title text 1\n"
- " [email protected]\n\n"
+ " ([email protected])\n\n"
" Title text 2\n"
" (Chromium issue 1234)\n"
- " [email protected]\n\n",
+ " ([email protected])\n\n",
MakeChangeLogBody(commits))
def testMakeChangeLogBodyEmpty(self):
@@ -86,18 +86,18 @@ class ToplevelTest(unittest.TestCase):
def testMakeChangeLogBodyAutoFormat(self):
commits = [
- [" Title text 1",
+ ["Title text 1",
"Title text 1\nLOG=y\nBUG=\n",
- " [email protected]"],
- [" Title text 2",
+ "[email protected]"],
+ ["Title text 2",
"Title text 2\n\nBUG=1234\n",
- " [email protected]"],
- [" Title text 3",
+ "[email protected]"],
+ ["Title text 3",
"Title text 3\n\nBUG=1234\nLOG = Yes\n",
- " [email protected]"],
- [" Title text 3",
+ "[email protected]"],
+ ["Title text 3",
"Title text 4\n\nBUG=1234\nLOG=\n",
- " [email protected]"],
+ "[email protected]"],
]
self.assertEquals(" Title text 1\n\n"
" Title text 3\n"
@@ -359,18 +359,15 @@ class ScriptTest(unittest.TestCase):
self._git_recipe = [
["log 1234..HEAD --format=%H", "rev1\nrev2\nrev3"],
- ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Title text 1"],
+ ["log -1 rev1 --format=\"%s\"", "Title text 1"],
["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\nLOG=y\n"],
- ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"",
- " [email protected]"],
- ["log -1 rev2 --format=\"%w(80,8,8)%s\"", " Title text 2"],
+ ["log -1 rev1 --format=\"%an\"", "[email protected]"],
+ ["log -1 rev2 --format=\"%s\"", "Title text 2"],
["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=123\nLOG= \n"],
- ["log -1 rev2 --format=\"%w(80,8,8)(%an)\"",
- " [email protected]"],
- ["log -1 rev3 --format=\"%w(80,8,8)%s\"", " Title text 3"],
+ ["log -1 rev2 --format=\"%an\"", "[email protected]"],
+ ["log -1 rev3 --format=\"%s\"", "Title text 3"],
["log -1 rev3 --format=\"%B\"", "Title\n\nBUG=321\nLOG=true\n"],
- ["log -1 rev3 --format=\"%w(80,8,8)(%an)\"",
- " [email protected]"],
+ ["log -1 rev3 --format=\"%an\"", "[email protected]"],
]
self.MakeStep().Persist("last_push", "1234")
@@ -394,15 +391,15 @@ class ScriptTest(unittest.TestCase):
# All lines starting with # will be stripped\\.
#
# Title text 1
-# author1@chromium\\.org
+# \\(author1@chromium\\.org\\)
#
# Title text 2
# \\(Chromium issue 123\\)
-# author2@chromium\\.org
+# \\(author2@chromium\\.org\\)
#
# Title text 3
# \\(Chromium issue 321\\)
-# author3@chromium\\.org
+# \\(author3@chromium\\.org\\)
#
#"""
@@ -505,7 +502,7 @@ class ScriptTest(unittest.TestCase):
self.assertTrue(re.search(r"Version 3.22.5", cl))
self.assertTrue(re.search(r" Log text 1", cl))
self.assertTrue(re.search(r" \(issue 321\)", cl))
- self.assertFalse(re.search(r" author1@chromium\.org", cl))
+ self.assertFalse(re.search(r" \(author1@chromium\.org\)", cl))
# Make sure all comments got stripped.
self.assertFalse(re.search(r"^#", cl, flags=re.M))
@@ -540,10 +537,9 @@ class ScriptTest(unittest.TestCase):
["log -1 --format=%H ChangeLog", "1234\n"],
["log -1 1234", "Last push ouput\n"],
["log 1234..HEAD --format=%H", "rev1\n"],
- ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Log text 1.\n"],
+ ["log -1 rev1 --format=\"%s\"", "Log text 1.\n"],
["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"],
- ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"",
- " [email protected]\n"],
+ ["log -1 rev1 --format=\"%an\"", "[email protected]\n"],
[("commit -a -m \"Prepare push to trunk. "
"Now working on version 3.22.6.\""),
" 2 files changed\n",
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.