OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 the V8 project authors. All rights reserved. | 2 # Copyright 2013 the V8 project authors. All rights reserved. |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 self.Persist("date", date) | 105 self.Persist("date", date) |
106 output = "%s: Version %s.%s.%s\n\n" % (date, | 106 output = "%s: Version %s.%s.%s\n\n" % (date, |
107 self._state["major"], | 107 self._state["major"], |
108 self._state["minor"], | 108 self._state["minor"], |
109 self._state["build"]) | 109 self._state["build"]) |
110 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) | 110 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) |
111 | 111 |
112 args = "log %s..HEAD --format=%%H" % self._state["last_push"] | 112 args = "log %s..HEAD --format=%%H" % self._state["last_push"] |
113 commits = self.Git(args).strip() | 113 commits = self.Git(args).strip() |
114 | 114 |
115 def GetCommitMessages(): | 115 # Cache raw commit messages. |
116 for commit in commits.splitlines(): | 116 commit_messages = [ |
117 yield [ | 117 [ |
118 self.Git("log -1 %s --format=\"%%w(80,8,8)%%s\"" % commit), | 118 self.Git("log -1 %s --format=\"%%w(80,8,8)%%s\"" % commit), |
119 self.Git("log -1 %s --format=\"%%B\"" % commit), | 119 self.Git("log -1 %s --format=\"%%B\"" % commit), |
120 self.Git("log -1 %s --format=\"%%w(80,8,8)(%%an)\"" % commit), | 120 self.Git("log -1 %s --format=\"%%w(80,8,8)(%%an)\"" % commit), |
121 ] | 121 ] for commit in commits.splitlines() |
122 ] | |
122 | 123 |
123 body = MakeChangeLogBody(GetCommitMessages) | 124 # Auto-format commit messages. |
125 body = MakeChangeLogBody(commit_messages, auto_format=True) | |
124 AppendToFile(body, self.Config(CHANGELOG_ENTRY_FILE)) | 126 AppendToFile(body, self.Config(CHANGELOG_ENTRY_FILE)) |
125 | 127 |
126 msg = " Performance and stability improvements on all platforms.\n" | 128 msg = (" Performance and stability improvements on all platforms." |
129 "\n#\n# The change log above is auto-generated. Please review if " | |
130 "all relevant\n# commit messages from the list below are included." | |
131 "\n# All lines starting with # will be stripped.\n#\n") | |
127 AppendToFile(msg, self.Config(CHANGELOG_ENTRY_FILE)) | 132 AppendToFile(msg, self.Config(CHANGELOG_ENTRY_FILE)) |
128 | 133 |
134 # Include unformatted commit messages as a reference in a comment. | |
135 comment_body = MakeComment(MakeChangeLogBody(commit_messages)) | |
136 AppendToFile(comment_body, self.Config(CHANGELOG_ENTRY_FILE)) | |
137 | |
129 | 138 |
130 class EditChangeLog(Step): | 139 class EditChangeLog(Step): |
131 def __init__(self): | 140 def __init__(self): |
132 Step.__init__(self, "Edit ChangeLog entry.") | 141 Step.__init__(self, "Edit ChangeLog entry.") |
133 | 142 |
134 def RunStep(self): | 143 def RunStep(self): |
135 print ("Please press <Return> to have your EDITOR open the ChangeLog " | 144 print ("Please press <Return> to have your EDITOR open the ChangeLog " |
136 "entry, then edit its contents to your liking. When you're done, " | 145 "entry, then edit its contents to your liking. When you're done, " |
137 "save the file and exit your EDITOR. ") | 146 "save the file and exit your EDITOR. ") |
138 self.ReadLine(default="") | 147 self.ReadLine(default="") |
139 | 148 |
140 # TODO(machenbach): Don't use EDITOR in forced mode as soon as script is | 149 # TODO(machenbach): Don't use EDITOR in forced mode as soon as script is |
141 # well tested. | 150 # well tested. |
142 self.Editor(self.Config(CHANGELOG_ENTRY_FILE)) | 151 self.Editor(self.Config(CHANGELOG_ENTRY_FILE)) |
143 handle, new_changelog = tempfile.mkstemp() | 152 handle, new_changelog = tempfile.mkstemp() |
144 os.close(handle) | 153 os.close(handle) |
145 | 154 |
146 # (1) Eliminate tabs, (2) fix too little and (3) too much indentation, and | 155 # (1) Strip comments, (2) eliminate tabs, (3) fix too little and (4) too |
Jakob Kummerow
2013/11/21 09:17:05
This section is a candidate for Pythonification. I
| |
147 # (4) eliminate trailing whitespace. | 156 # much indentation, and (5) eliminate trailing whitespace. |
148 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip() | 157 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip() |
158 changelog_entry = StripComments(changelog_entry) | |
149 changelog_entry = MSub(r"\t", r" ", changelog_entry) | 159 changelog_entry = MSub(r"\t", r" ", changelog_entry) |
150 changelog_entry = MSub(r"^ {1,7}([^ ])", r" \1", changelog_entry) | 160 changelog_entry = MSub(r"^ {1,7}([^ ])", r" \1", changelog_entry) |
151 changelog_entry = MSub(r"^ {9,80}([^ ])", r" \1", changelog_entry) | 161 changelog_entry = MSub(r"^ {9,80}([^ ])", r" \1", changelog_entry) |
152 changelog_entry = MSub(r" +$", r"", changelog_entry) | 162 changelog_entry = MSub(r" +$", r"", changelog_entry) |
153 | 163 |
154 if changelog_entry == "": | 164 if changelog_entry == "": |
155 self.Die("Empty ChangeLog entry.") | 165 self.Die("Empty ChangeLog entry.") |
156 | 166 |
157 with open(new_changelog, "w") as f: | 167 with open(new_changelog, "w") as f: |
158 f.write(changelog_entry) | 168 f.write(changelog_entry) |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 def Main(): | 571 def Main(): |
562 parser = BuildOptions() | 572 parser = BuildOptions() |
563 (options, args) = parser.parse_args() | 573 (options, args) = parser.parse_args() |
564 if not ProcessOptions(options): | 574 if not ProcessOptions(options): |
565 parser.print_help() | 575 parser.print_help() |
566 return 1 | 576 return 1 |
567 RunPushToTrunk(CONFIG, options) | 577 RunPushToTrunk(CONFIG, options) |
568 | 578 |
569 if __name__ == "__main__": | 579 if __name__ == "__main__": |
570 sys.exit(Main()) | 580 sys.exit(Main()) |
OLD | NEW |