Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Rolls DEPS controlled dependency. | 6 """Rolls DEPS controlled dependency. |
| 7 | 7 |
| 8 Works only with git checkout and git dependencies. Currently this | 8 Works only with git checkout and git dependencies. Currently this |
| 9 script will always roll to the tip of to origin/master. | 9 script will always roll to the tip of to origin/master. |
| 10 """ | 10 """ |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 print('Found new revision %s' % roll_to) | 108 print('Found new revision %s' % roll_to) |
| 109 | 109 |
| 110 if roll_to == head: | 110 if roll_to == head: |
| 111 raise Error('No revision to roll!') | 111 raise Error('No revision to roll!') |
| 112 | 112 |
| 113 commit_range = '%s..%s' % (head[:9], roll_to[:9]) | 113 commit_range = '%s..%s' % (head[:9], roll_to[:9]) |
| 114 | 114 |
| 115 upstream_url = check_output( | 115 upstream_url = check_output( |
| 116 ['git', 'config', 'remote.origin.url'], cwd=full_dir).strip() | 116 ['git', 'config', 'remote.origin.url'], cwd=full_dir).strip() |
| 117 log_url = get_log_url(upstream_url, head, roll_to) | 117 log_url = get_log_url(upstream_url, head, roll_to) |
| 118 logs = check_output( | 118 logs = check_output( |
|
M-A Ruel
2015/10/07 17:13:03
Let's do instead:
cmd = [
'git', 'log', commit_r
| |
| 119 ['git', 'log', commit_range, '--date=short', '--format=%ad %ae %s'], | 119 ['git', 'log', commit_range, '--date=short', '--format=%ad %ae %s', |
| 120 '--no-merges'], | |
| 120 cwd=full_dir) | 121 cwd=full_dir) |
| 121 logs = re.sub(r'(?m)^(\d\d\d\d-\d\d-\d\d [^@]+)@[^ ]+( .*)$', r'\1\2', logs) | 122 logs = re.sub(r'(?m)^(\d\d\d\d-\d\d-\d\d [^@]+)@[^ ]+( .*)$', r'\1\2', logs) |
| 122 nb_commits = logs.count('\n') | 123 nb_commits = logs.count('\n') |
| 123 | 124 |
| 124 header = 'Roll %s/ %s (%d commit%s).\n\n' % ( | 125 header = 'Roll %s/ %s (%d commit%s).\n\n' % ( |
| 125 deps_dir, | 126 deps_dir, |
| 126 commit_range, | 127 commit_range, |
| 127 nb_commits, | 128 nb_commits, |
| 128 's' if nb_commits > 1 else '') | 129 's' if nb_commits > 1 else '') |
| 129 | 130 |
| 130 log_section = '' | 131 log_section = '' |
| 131 if log_url: | 132 if log_url: |
| 132 log_section = log_url + '\n\n' | 133 log_section = log_url + '\n\n' |
| 133 log_section += '$ git log %s --date=short --format=\'%%ad %%ae %%s\'\n' % ( | 134 log_section += '$ git log %s ' % (commit_range) |
| 134 commit_range) | 135 log_section += '--date=short --format=\'%ad %ae %s\' --no-merges\n' |
| 135 if not no_log and should_show_log(upstream_url): | 136 if not no_log and should_show_log(upstream_url): |
| 136 if logs.count('\n') > log_limit: | 137 if logs.count('\n') > log_limit: |
| 137 # Keep the first N log entries. | 138 # Keep the first N log entries. |
| 138 logs = ''.join(logs.splitlines(True)[:log_limit]) + '(...)\n' | 139 logs = ''.join(logs.splitlines(True)[:log_limit]) + '(...)\n' |
| 139 log_section += logs | 140 log_section += logs |
| 140 log_section += '\n' | 141 log_section += '\n' |
| 141 | 142 |
| 142 reviewer = 'R=%s\n' % ','.join(reviewers) if reviewers else '' | 143 reviewer = 'R=%s\n' % ','.join(reviewers) if reviewers else '' |
| 143 bug = 'BUG=%s\n' % bug if bug else '' | 144 bug = 'BUG=%s\n' % bug if bug else '' |
| 144 msg = header + log_section + reviewer + bug | 145 msg = header + log_section + reviewer + bug |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 | 206 |
| 206 except Error as e: | 207 except Error as e: |
| 207 sys.stderr.write('error: %s\n' % e) | 208 sys.stderr.write('error: %s\n' % e) |
| 208 return 1 | 209 return 1 |
| 209 | 210 |
| 210 return 0 | 211 return 0 |
| 211 | 212 |
| 212 | 213 |
| 213 if __name__ == '__main__': | 214 if __name__ == '__main__': |
| 214 sys.exit(main()) | 215 sys.exit(main()) |
| OLD | NEW |