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 cmd = [ | |
119 'git', 'log', commit_range, '--date=short', '--no-merges', | |
120 ] | |
118 logs = check_output( | 121 logs = check_output( |
119 ['git', 'log', commit_range, '--date=short', '--format=%ad %ae %s'], | 122 cmd + ['--format=%ad %ae %s'], # Args with '=' are automatically quoted. |
Johann
2015/10/07 18:20:11
so this is kind of messy because for --arg=<string
M-A Ruel
2015/10/07 18:43:11
IIRC, it works with "" but not ''. Please confirm.
| |
120 cwd=full_dir) | 123 cwd=full_dir) |
121 logs = re.sub(r'(?m)^(\d\d\d\d-\d\d-\d\d [^@]+)@[^ ]+( .*)$', r'\1\2', logs) | 124 logs = re.sub(r'(?m)^(\d\d\d\d-\d\d-\d\d [^@]+)@[^ ]+( .*)$', r'\1\2', logs) |
Johann
2015/10/07 18:20:11
a potential fix is to rework the regex to remove t
| |
122 nb_commits = logs.count('\n') | 125 nb_commits = logs.count('\n') |
123 | 126 |
124 header = 'Roll %s/ %s (%d commit%s).\n\n' % ( | 127 header = 'Roll %s/ %s (%d commit%s).\n\n' % ( |
125 deps_dir, | 128 deps_dir, |
126 commit_range, | 129 commit_range, |
127 nb_commits, | 130 nb_commits, |
128 's' if nb_commits > 1 else '') | 131 's' if nb_commits > 1 else '') |
129 | 132 |
130 log_section = '' | 133 log_section = '' |
131 if log_url: | 134 if log_url: |
132 log_section = log_url + '\n\n' | 135 log_section = log_url + '\n\n' |
133 log_section += '$ git log %s --date=short --format=\'%%ad %%ae %%s\'\n' % ( | 136 log_section += '$ %s ' % ' '.join(cmd) |
134 commit_range) | 137 log_section += '--format=\'%ad %ae %s\'\n' |
Johann
2015/10/07 18:20:11
without the quotes above, the command printed is $
| |
135 if not no_log and should_show_log(upstream_url): | 138 if not no_log and should_show_log(upstream_url): |
136 if logs.count('\n') > log_limit: | 139 if logs.count('\n') > log_limit: |
137 # Keep the first N log entries. | 140 # Keep the first N log entries. |
138 logs = ''.join(logs.splitlines(True)[:log_limit]) + '(...)\n' | 141 logs = ''.join(logs.splitlines(True)[:log_limit]) + '(...)\n' |
139 log_section += logs | 142 log_section += logs |
140 log_section += '\n' | 143 log_section += '\n' |
141 | 144 |
142 reviewer = 'R=%s\n' % ','.join(reviewers) if reviewers else '' | 145 reviewer = 'R=%s\n' % ','.join(reviewers) if reviewers else '' |
143 bug = 'BUG=%s\n' % bug if bug else '' | 146 bug = 'BUG=%s\n' % bug if bug else '' |
144 msg = header + log_section + reviewer + bug | 147 msg = header + log_section + reviewer + bug |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 | 208 |
206 except Error as e: | 209 except Error as e: |
207 sys.stderr.write('error: %s\n' % e) | 210 sys.stderr.write('error: %s\n' % e) |
208 return 1 | 211 return 1 |
209 | 212 |
210 return 0 | 213 return 0 |
211 | 214 |
212 | 215 |
213 if __name__ == '__main__': | 216 if __name__ == '__main__': |
214 sys.exit(main()) | 217 sys.exit(main()) |
OLD | NEW |