Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: tools/push-to-trunk/push_to_trunk.py

Issue 101763002: Make squash commits step more pythony in push-to-trunk script. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 58e2cb924d74f7b83d8a0541b891b5ffe9c83146..545cc7579dd89f621c867af06750e50122da97c9 100755
--- a/tools/push-to-trunk/push_to_trunk.py
+++ b/tools/push-to-trunk/push_to_trunk.py
@@ -257,31 +257,19 @@ class SquashCommits(Step):
args = "diff svn/trunk %s" % self._state["prepare_commit_hash"]
TextToFile(self.Git(args), self.Config(PATCH_FILE))
- # Convert the ChangeLog entry to commit message format:
- # - remove date
- # - remove indentation
- # - merge paragraphs into single long lines, keeping empty lines between
- # them.
+ # Convert the ChangeLog entry to commit message format.
self.RestoreIfUnset("date")
- changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE))
-
- # TODO(machenbach): This could create a problem if the changelog contained
- # any quotation marks.
- text = Command("echo \"%s\" \
- | sed -e \"s/^%s: //\" \
- | sed -e 's/^ *//' \
- | awk '{ \
- if (need_space == 1) {\
- printf(\" \");\
- };\
- printf(\"%%s\", $0);\
- if ($0 ~ /^$/) {\
- printf(\"\\n\\n\");\
- need_space = 0;\
- } else {\
- need_space = 1;\
- }\
- }'" % (changelog_entry, self._state["date"]))
+ text = FileToText(self.Config(CHANGELOG_ENTRY_FILE))
+
+ # Remove date and trailing white space.
+ text = re.sub(r"^%s: " % self._state["date"], "", text.rstrip())
+
+ # Remove indentation and merge paragraphs into single long lines, keeping
+ # empty lines between them.
+ def SplitMapJoin(split_text, fun, join_text):
+ return lambda text: join_text.join(map(fun, text.split(split_text)))
+ strip = lambda line: line.strip()
+ text = SplitMapJoin("\n\n", SplitMapJoin("\n", strip, " "), "\n\n")(text)
if not text:
self.Die("Commit message editing failed.")
« no previous file with comments | « no previous file | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698