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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 | 75 |
76 def GetLastChangeLogEntries(change_log_file): | 76 def GetLastChangeLogEntries(change_log_file): |
77 result = [] | 77 result = [] |
78 for line in LinesInFile(change_log_file): | 78 for line in LinesInFile(change_log_file): |
79 if re.search(r"^\d{4}-\d{2}-\d{2}:", line) and result: break | 79 if re.search(r"^\d{4}-\d{2}-\d{2}:", line) and result: break |
80 result.append(line) | 80 result.append(line) |
81 return "".join(result) | 81 return "".join(result) |
82 | 82 |
83 | 83 |
84 def MakeChangeLogBody(commit_generator): | 84 def MakeComment(text): |
| 85 return MSub(r"^( ?)", "#", text) |
| 86 |
| 87 |
| 88 def StripComments(text): |
| 89 # Use split not splitlines to keep terminal newlines. |
| 90 return "\n".join(filter(lambda x: not x.startswith("#"), text.split("\n"))) |
| 91 |
| 92 |
| 93 def MakeChangeLogBody(commit_messages, auto_format=False): |
85 result = "" | 94 result = "" |
86 for (title, body, author) in commit_generator(): | 95 added_titles = set() |
| 96 for (title, body, author) in commit_messages: |
| 97 # TODO(machenbach): Reload the commit description from rietveld in order to |
| 98 # catch late changes. |
| 99 title = title.rstrip() |
| 100 if auto_format: |
| 101 # Only add commits that set the LOG flag correctly. |
| 102 log_exp = r"^[ \t]*LOG[ \t]*=[ \t]*(?:Y(?:ES)?)|TRUE" |
| 103 if not re.search(log_exp, body, flags=re.I | re.M): |
| 104 continue |
| 105 # Never include reverts. |
| 106 if title.startswith("Revert "): |
| 107 continue |
| 108 # Don't include duplicates. |
| 109 if title in added_titles: |
| 110 continue |
| 111 |
| 112 # TODO(machenbach): Let python do all formatting. Get raw git title, attach |
| 113 # issue and add/move dot to the end - all in one line. Make formatting and |
| 114 # indentation afterwards. |
| 115 |
87 # Add the commit's title line. | 116 # Add the commit's title line. |
88 result += "%s\n" % title.rstrip() | 117 result += "%s\n" % title |
| 118 added_titles.add(title) |
89 | 119 |
90 # Add bug references. | 120 # Add bug references. |
91 result += MakeChangeLogBugReference(body) | 121 result += MakeChangeLogBugReference(body) |
92 | 122 |
93 # Append the commit's author for reference. | 123 # Append the commit's author for reference if not in auto-format mode. |
94 result += "%s\n\n" % author.rstrip() | 124 if not auto_format: |
| 125 result += "%s\n" % author.rstrip() |
| 126 |
| 127 result += "\n" |
95 return result | 128 return result |
96 | 129 |
97 | 130 |
98 def MakeChangeLogBugReference(body): | 131 def MakeChangeLogBugReference(body): |
99 """Grep for "BUG=xxxx" lines in the commit message and convert them to | 132 """Grep for "BUG=xxxx" lines in the commit message and convert them to |
100 "(issue xxxx)". | 133 "(issue xxxx)". |
101 """ | 134 """ |
102 crbugs = [] | 135 crbugs = [] |
103 v8bugs = [] | 136 v8bugs = [] |
104 | 137 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 step.SetNumber(number) | 432 step.SetNumber(number) |
400 step.SetConfig(config) | 433 step.SetConfig(config) |
401 step.SetOptions(options) | 434 step.SetOptions(options) |
402 step.SetState(state) | 435 step.SetState(state) |
403 step.SetSideEffectHandler(side_effect_handler) | 436 step.SetSideEffectHandler(side_effect_handler) |
404 steps.append(step) | 437 steps.append(step) |
405 number += 1 | 438 number += 1 |
406 | 439 |
407 for step in steps[options.s:]: | 440 for step in steps[options.s:]: |
408 step.Run() | 441 step.Run() |
OLD | NEW |