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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 | 69 |
70 def GetLastChangeLogEntries(change_log_file): | 70 def GetLastChangeLogEntries(change_log_file): |
71 result = [] | 71 result = [] |
72 for line in LinesInFile(change_log_file): | 72 for line in LinesInFile(change_log_file): |
73 if re.search(r"^\d{4}-\d{2}-\d{2}:", line) and result: break | 73 if re.search(r"^\d{4}-\d{2}-\d{2}:", line) and result: break |
74 result.append(line) | 74 result.append(line) |
75 return "".join(result) | 75 return "".join(result) |
76 | 76 |
77 | 77 |
| 78 def MakeChangeLogBody(commit_generator): |
| 79 result = "" |
| 80 for (title, body, author) in commit_generator(): |
| 81 # Add the commit's title line. |
| 82 result += "%s\n" % title.rstrip() |
| 83 |
| 84 # Grep for "BUG=xxxx" lines in the commit message and convert them to |
| 85 # "(issue xxxx)". |
| 86 out = body.splitlines() |
| 87 out = filter(lambda x: re.search(r"^BUG=", x), out) |
| 88 out = filter(lambda x: not re.search(r"BUG=$", x), out) |
| 89 out = filter(lambda x: not re.search(r"BUG=none$", x), out) |
| 90 |
| 91 # TODO(machenbach): Handle multiple entries (e.g. BUG=123, 234). |
| 92 def FormatIssue(text): |
| 93 text = re.sub(r"BUG=v8:(.*)$", r"(issue \1)", text) |
| 94 text = re.sub(r"BUG=chromium:(.*)$", r"(Chromium issue \1)", text) |
| 95 text = re.sub(r"BUG=(.*)$", r"(Chromium issue \1)", text) |
| 96 return " %s\n" % text |
| 97 |
| 98 for line in map(FormatIssue, out): |
| 99 result += line |
| 100 |
| 101 # Append the commit's author for reference. |
| 102 result += "%s\n\n" % author.rstrip() |
| 103 return result |
| 104 |
| 105 |
78 # Some commands don't like the pipe, e.g. calling vi from within the script or | 106 # Some commands don't like the pipe, e.g. calling vi from within the script or |
79 # from subscripts like git cl upload. | 107 # from subscripts like git cl upload. |
80 def Command(cmd, args="", prefix="", pipe=True): | 108 def Command(cmd, args="", prefix="", pipe=True): |
81 cmd_line = "%s %s %s" % (prefix, cmd, args) | 109 cmd_line = "%s %s %s" % (prefix, cmd, args) |
82 print "Command: %s" % cmd_line | 110 print "Command: %s" % cmd_line |
83 try: | 111 try: |
84 if pipe: | 112 if pipe: |
85 return subprocess.check_output(cmd_line, shell=True) | 113 return subprocess.check_output(cmd_line, shell=True) |
86 else: | 114 else: |
87 return subprocess.check_call(cmd_line, shell=True) | 115 return subprocess.check_call(cmd_line, shell=True) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 class UploadStep(Step): | 316 class UploadStep(Step): |
289 def __init__(self): | 317 def __init__(self): |
290 Step.__init__(self, "Upload for code review.") | 318 Step.__init__(self, "Upload for code review.") |
291 | 319 |
292 def RunStep(self): | 320 def RunStep(self): |
293 print "Please enter the email address of a V8 reviewer for your patch: ", | 321 print "Please enter the email address of a V8 reviewer for your patch: ", |
294 reviewer = self.ReadLine() | 322 reviewer = self.ReadLine() |
295 args = "cl upload -r \"%s\" --send-mail" % reviewer | 323 args = "cl upload -r \"%s\" --send-mail" % reviewer |
296 if self.Git(args,pipe=False) is None: | 324 if self.Git(args,pipe=False) is None: |
297 self.Die("'git cl upload' failed, please try again.") | 325 self.Die("'git cl upload' failed, please try again.") |
OLD | NEW |