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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 def StripComments(text): | 93 def StripComments(text): |
94 # Use split not splitlines to keep terminal newlines. | 94 # Use split not splitlines to keep terminal newlines. |
95 return "\n".join(filter(lambda x: not x.startswith("#"), text.split("\n"))) | 95 return "\n".join(filter(lambda x: not x.startswith("#"), text.split("\n"))) |
96 | 96 |
97 | 97 |
98 def MakeChangeLogBody(commit_messages, auto_format=False): | 98 def MakeChangeLogBody(commit_messages, auto_format=False): |
99 result = "" | 99 result = "" |
100 added_titles = set() | 100 added_titles = set() |
101 for (title, body, author) in commit_messages: | 101 for (title, body, author) in commit_messages: |
102 # TODO(machenbach): Reload the commit description from rietveld in order to | 102 # TODO(machenbach): Better check for reverts. A revert should remove the |
103 # catch late changes. | 103 # original CL from the actual log entry. |
104 title = title.strip() | 104 title = title.strip() |
105 if auto_format: | 105 if auto_format: |
106 # Only add commits that set the LOG flag correctly. | 106 # Only add commits that set the LOG flag correctly. |
107 log_exp = r"^[ \t]*LOG[ \t]*=[ \t]*(?:Y(?:ES)?)|TRUE" | 107 log_exp = r"^[ \t]*LOG[ \t]*=[ \t]*(?:Y(?:ES)?)|TRUE" |
108 if not re.search(log_exp, body, flags=re.I | re.M): | 108 if not re.search(log_exp, body, flags=re.I | re.M): |
109 continue | 109 continue |
110 # Never include reverts. | 110 # Never include reverts. |
111 if title.startswith("Revert "): | 111 if title.startswith("Revert "): |
112 continue | 112 continue |
113 # Don't include duplicates. | 113 # Don't include duplicates. |
114 if title in added_titles: | 114 if title in added_titles: |
115 continue | 115 continue |
116 | 116 |
117 # TODO(machenbach): Let python do all formatting. Get raw git title, attach | 117 # Add and format the commit's title and bug reference. Move dot to the end. |
118 # issue and add/move dot to the end - all in one line. Make formatting and | |
119 # indentation afterwards. | |
120 | |
121 # Add the commit's title line. | |
122 result += "%s\n" % Fill80(title) | |
123 added_titles.add(title) | 118 added_titles.add(title) |
124 | 119 raw_title = re.sub(r"(\.|\?|!)$", "", title) |
125 # Add bug references. | 120 bug_reference = MakeChangeLogBugReference(body) |
126 result += MakeChangeLogBugReference(body) | 121 space = " " if bug_reference else "" |
| 122 result += "%s\n" % Fill80("%s%s%s." % (raw_title, space, bug_reference)) |
127 | 123 |
128 # Append the commit's author for reference if not in auto-format mode. | 124 # Append the commit's author for reference if not in auto-format mode. |
129 if not auto_format: | 125 if not auto_format: |
130 result += "%s\n" % Fill80("(%s)" % author.strip()) | 126 result += "%s\n" % Fill80("(%s)" % author.strip()) |
131 | 127 |
132 result += "\n" | 128 result += "\n" |
133 return result | 129 return result |
134 | 130 |
135 | 131 |
136 def MakeChangeLogBugReference(body): | 132 def MakeChangeLogBugReference(body): |
(...skipping 25 matching lines...) Expand all Loading... |
162 bug_groups = [] | 158 bug_groups = [] |
163 def FormatIssues(prefix, bugs): | 159 def FormatIssues(prefix, bugs): |
164 if len(bugs) > 0: | 160 if len(bugs) > 0: |
165 plural = "s" if len(bugs) > 1 else "" | 161 plural = "s" if len(bugs) > 1 else "" |
166 bug_groups.append("%sissue%s %s" % (prefix, plural, ", ".join(bugs))) | 162 bug_groups.append("%sissue%s %s" % (prefix, plural, ", ".join(bugs))) |
167 | 163 |
168 FormatIssues("", v8bugs) | 164 FormatIssues("", v8bugs) |
169 FormatIssues("Chromium ", crbugs) | 165 FormatIssues("Chromium ", crbugs) |
170 | 166 |
171 if len(bug_groups) > 0: | 167 if len(bug_groups) > 0: |
172 # Format with 8 characters indentation and max 80 character lines. | 168 return "(%s)" % ", ".join(bug_groups) |
173 return "%s\n" % Fill80("(%s)" % ", ".join(bug_groups)) | |
174 else: | 169 else: |
175 return "" | 170 return "" |
176 | 171 |
177 | 172 |
178 # Some commands don't like the pipe, e.g. calling vi from within the script or | 173 # Some commands don't like the pipe, e.g. calling vi from within the script or |
179 # from subscripts like git cl upload. | 174 # from subscripts like git cl upload. |
180 def Command(cmd, args="", prefix="", pipe=True): | 175 def Command(cmd, args="", prefix="", pipe=True): |
181 cmd_line = "%s %s %s" % (prefix, cmd, args) | 176 cmd_line = "%s %s %s" % (prefix, cmd, args) |
182 print "Command: %s" % cmd_line | 177 print "Command: %s" % cmd_line |
183 try: | 178 try: |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 options, | 440 options, |
446 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): | 441 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
447 state = {} | 442 state = {} |
448 steps = [] | 443 steps = [] |
449 for (number, step_class) in enumerate(step_classes): | 444 for (number, step_class) in enumerate(step_classes): |
450 steps.append(MakeStep(step_class, number, state, config, | 445 steps.append(MakeStep(step_class, number, state, config, |
451 options, side_effect_handler)) | 446 options, side_effect_handler)) |
452 | 447 |
453 for step in steps[options.s:]: | 448 for step in steps[options.s:]: |
454 step.Run() | 449 step.Run() |
OLD | NEW |