blob: 00fac4ab1365eca33b3f5160f0ba5f7772e537bf [file] [log] [blame]
Josip Sokcevic4de5dea2022-03-23 21:15:14 +00001#!/usr/bin/env python3
maruel@chromium.org96550942015-05-22 18:46:51 +00002# Copyright 2015 The Chromium Authors. All rights reserved.
szager@chromium.org03fd85b2014-06-09 23:43:33 +00003# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
maruel@chromium.org96550942015-05-22 18:46:51 +00006"""Rolls DEPS controlled dependency.
szager@chromium.org03fd85b2014-06-09 23:43:33 +00007
Josip Sokcevicc1a06c12022-01-12 00:44:14 +00008Works only with git checkout and git dependencies. Currently this script will
9always roll to the tip of to origin/main.
szager@chromium.org03fd85b2014-06-09 23:43:33 +000010"""
11
Raul Tambre80ee78e2019-05-06 22:41:05 +000012from __future__ import print_function
13
sbc@chromium.org30e5b232015-06-01 18:06:59 +000014import argparse
Thiago Perrottaa0892812022-09-03 11:22:46 +000015import itertools
szager@chromium.org03fd85b2014-06-09 23:43:33 +000016import os
17import re
Corentin Wallez5157fbf2020-11-12 22:31:35 +000018import subprocess2
szager@chromium.org03fd85b2014-06-09 23:43:33 +000019import sys
Bruce Dawson03af44a2022-12-27 19:37:58 +000020import tempfile
szager@chromium.org03fd85b2014-06-09 23:43:33 +000021
scottmg@chromium.orgc20f4702015-05-23 00:44:46 +000022NEED_SHELL = sys.platform.startswith('win')
Edward Lemurfaae42e2018-11-26 18:34:30 +000023GCLIENT_PATH = os.path.join(
24 os.path.dirname(os.path.abspath(__file__)), 'gclient.py')
scottmg@chromium.orgc20f4702015-05-23 00:44:46 +000025
26
Marc-Antoine Ruel1e2cb152019-04-17 17:32:52 +000027# Commit subject that will be considered a roll. In the format generated by the
28# git log used, so it's "<year>-<month>-<day> <author> <subject>"
29_ROLL_SUBJECT = re.compile(
30 # Date
31 r'^\d\d\d\d-\d\d-\d\d '
32 # Author
33 r'[^ ]+ '
34 # Subject
35 r'('
36 # Generated by
Josip Sokcevic9c0dc302020-11-20 18:41:25 +000037 # https://skia.googlesource.com/buildbot/+/HEAdA/autoroll/go/repo_manager/deps_repo_manager.go
Marc-Antoine Ruel1e2cb152019-04-17 17:32:52 +000038 r'Roll [^ ]+ [a-f0-9]+\.\.[a-f0-9]+ \(\d+ commits\)'
39 r'|'
40 # Generated by
Josip Sokcevic9c0dc302020-11-20 18:41:25 +000041 # https://chromium.googlesource.com/infra/infra/+/HEAD/recipes/recipe_modules/recipe_autoroller/api.py
Marc-Antoine Ruel1e2cb152019-04-17 17:32:52 +000042 r'Roll recipe dependencies \(trivial\)\.'
43 r')$')
44
45
sbc@chromium.orge5d984b2015-05-29 22:09:39 +000046class Error(Exception):
47 pass
48
49
smut7036c4f2016-06-09 14:28:48 -070050class AlreadyRolledError(Error):
51 pass
52
53
scottmg@chromium.orgc20f4702015-05-23 00:44:46 +000054def check_output(*args, **kwargs):
Corentin Wallez8732c0e2020-12-09 17:43:46 +000055 """subprocess2.check_output() passing shell=True on Windows for git."""
scottmg@chromium.orgc20f4702015-05-23 00:44:46 +000056 kwargs.setdefault('shell', NEED_SHELL)
Corentin Wallez5157fbf2020-11-12 22:31:35 +000057 return subprocess2.check_output(*args, **kwargs).decode('utf-8')
scottmg@chromium.orgc20f4702015-05-23 00:44:46 +000058
59
60def check_call(*args, **kwargs):
Corentin Wallez8732c0e2020-12-09 17:43:46 +000061 """subprocess2.check_call() passing shell=True on Windows for git."""
scottmg@chromium.orgc20f4702015-05-23 00:44:46 +000062 kwargs.setdefault('shell', NEED_SHELL)
Corentin Wallez5157fbf2020-11-12 22:31:35 +000063 subprocess2.check_call(*args, **kwargs)
scottmg@chromium.orgc20f4702015-05-23 00:44:46 +000064
65
Corentin Wallez5157fbf2020-11-12 22:31:35 +000066def return_code(*args, **kwargs):
Corentin Wallez8732c0e2020-12-09 17:43:46 +000067 """subprocess2.call() passing shell=True on Windows for git and
Edward Lesmescf06cad2020-12-14 22:03:23 +000068 subprocess2.DEVNULL for stdout and stderr."""
Corentin Wallez5157fbf2020-11-12 22:31:35 +000069 kwargs.setdefault('shell', NEED_SHELL)
Edward Lesmescf06cad2020-12-14 22:03:23 +000070 kwargs.setdefault('stdout', subprocess2.DEVNULL)
71 kwargs.setdefault('stderr', subprocess2.DEVNULL)
Corentin Wallez5157fbf2020-11-12 22:31:35 +000072 return subprocess2.call(*args, **kwargs)
73
74
75def is_pristine(root):
maruel@chromium.org96550942015-05-22 18:46:51 +000076 """Returns True if a git checkout is pristine."""
Josip Sokcevicc1a06c12022-01-12 00:44:14 +000077 # `git rev-parse --verify` has a non-zero return code if the revision
78 # doesn't exist.
79 diff_cmd = ['git', 'diff', '--ignore-submodules', 'origin/main']
80 return (not check_output(diff_cmd, cwd=root).strip() and
81 not check_output(diff_cmd + ['--cached'], cwd=root).strip())
Corentin Wallez5157fbf2020-11-12 22:31:35 +000082
83
szager@chromium.org03fd85b2014-06-09 23:43:33 +000084
Josip Sokcevic9c0dc302020-11-20 18:41:25 +000085def get_log_url(upstream_url, head, tot):
maruel@chromium.org398ed342015-09-29 12:27:25 +000086 """Returns an URL to read logs via a Web UI if applicable."""
87 if re.match(r'https://[^/]*\.googlesource\.com/', upstream_url):
88 # gitiles
Josip Sokcevic9c0dc302020-11-20 18:41:25 +000089 return '%s/+log/%s..%s' % (upstream_url, head[:12], tot[:12])
maruel@chromium.org398ed342015-09-29 12:27:25 +000090 if upstream_url.startswith('https://github.com/'):
91 upstream_url = upstream_url.rstrip('/')
92 if upstream_url.endswith('.git'):
93 upstream_url = upstream_url[:-len('.git')]
Josip Sokcevic9c0dc302020-11-20 18:41:25 +000094 return '%s/compare/%s...%s' % (upstream_url, head[:12], tot[:12])
maruel@chromium.org398ed342015-09-29 12:27:25 +000095 return None
96
97
98def should_show_log(upstream_url):
99 """Returns True if a short log should be included in the tree."""
100 # Skip logs for very active projects.
Eric Boren07efc5a2017-08-28 09:13:20 -0400101 if upstream_url.endswith('/v8/v8.git'):
maruel@chromium.org398ed342015-09-29 12:27:25 +0000102 return False
103 if 'webrtc' in upstream_url:
104 return False
105 return True
106
107
Edward Lemurfaae42e2018-11-26 18:34:30 +0000108def gclient(args):
109 """Executes gclient with the given args and returns the stdout."""
110 return check_output([sys.executable, GCLIENT_PATH] + args).strip()
sbc@chromium.org98201122015-04-22 20:21:34 +0000111
maruel@chromium.org96550942015-05-22 18:46:51 +0000112
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500113def generate_commit_message(
114 full_dir, dependency, head, roll_to, no_log, log_limit):
115 """Creates the commit message for this specific roll."""
Sylvain Defresneae2b9622020-01-31 09:46:06 +0000116 commit_range = '%s..%s' % (head, roll_to)
117 commit_range_for_header = '%s..%s' % (head[:9], roll_to[:9])
maruel@chromium.org398ed342015-09-29 12:27:25 +0000118 upstream_url = check_output(
119 ['git', 'config', 'remote.origin.url'], cwd=full_dir).strip()
120 log_url = get_log_url(upstream_url, head, roll_to)
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500121 cmd = ['git', 'log', commit_range, '--date=short', '--no-merges']
maruel@chromium.orgc6e39fe2015-09-23 13:45:52 +0000122 logs = check_output(
Sylvain Defresneae2b9622020-01-31 09:46:06 +0000123 # Args with '=' are automatically quoted.
124 cmd + ['--format=%ad %ae %s', '--'],
Marc-Antoine Ruel51104fe2017-03-01 17:57:41 -0500125 cwd=full_dir).rstrip()
maruel@chromium.orgc6e39fe2015-09-23 13:45:52 +0000126 logs = re.sub(r'(?m)^(\d\d\d\d-\d\d-\d\d [^@]+)@[^ ]+( .*)$', r'\1\2', logs)
Marc-Antoine Ruel51104fe2017-03-01 17:57:41 -0500127 lines = logs.splitlines()
Marc-Antoine Ruel1e2cb152019-04-17 17:32:52 +0000128 cleaned_lines = [l for l in lines if not _ROLL_SUBJECT.match(l)]
Marc-Antoine Ruel51104fe2017-03-01 17:57:41 -0500129 logs = '\n'.join(cleaned_lines) + '\n'
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500130
Marc-Antoine Ruel51104fe2017-03-01 17:57:41 -0500131 nb_commits = len(lines)
132 rolls = nb_commits - len(cleaned_lines)
Marc-Antoine Ruel51104fe2017-03-01 17:57:41 -0500133 header = 'Roll %s/ %s (%d commit%s%s)\n\n' % (
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500134 dependency,
Sylvain Defresneae2b9622020-01-31 09:46:06 +0000135 commit_range_for_header,
maruel@chromium.org398ed342015-09-29 12:27:25 +0000136 nb_commits,
Marc-Antoine Ruel51104fe2017-03-01 17:57:41 -0500137 's' if nb_commits > 1 else '',
138 ('; %s trivial rolls' % rolls) if rolls else '')
maruel@chromium.org398ed342015-09-29 12:27:25 +0000139 log_section = ''
140 if log_url:
141 log_section = log_url + '\n\n'
johannkoenig@google.com64f2fc32015-10-07 19:11:17 +0000142 log_section += '$ %s ' % ' '.join(cmd)
143 log_section += '--format=\'%ad %ae %s\'\n'
Sylvain Defresne4ada8ab2020-01-31 17:22:56 +0000144 log_section = log_section.replace(commit_range, commit_range_for_header)
Eric Boren3be96a82017-09-29 10:07:46 -0400145 # It is important that --no-log continues to work, as it is used by
146 # internal -> external rollers. Please do not remove or break it.
maruel@chromium.org398ed342015-09-29 12:27:25 +0000147 if not no_log and should_show_log(upstream_url):
Marc-Antoine Ruel51104fe2017-03-01 17:57:41 -0500148 if len(cleaned_lines) > log_limit:
Marc-Antoine Ruel6ce18222019-01-16 21:36:36 +0000149 # Keep the first N/2 log entries and last N/2 entries.
150 lines = logs.splitlines(True)
Edward Lesmes994bed52020-04-01 16:21:40 +0000151 lines = lines[:log_limit//2] + ['(...)\n'] + lines[-log_limit//2:]
Marc-Antoine Ruel6ce18222019-01-16 21:36:36 +0000152 logs = ''.join(lines)
maruel@chromium.org398ed342015-09-29 12:27:25 +0000153 log_section += logs
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500154 return header + log_section
maruel@chromium.org398ed342015-09-29 12:27:25 +0000155
maruel@chromium.org96550942015-05-22 18:46:51 +0000156
Aravind Vasudevan474e28e2023-01-18 20:29:51 +0000157def is_submoduled():
158 """Returns true if gclient root has submodules"""
159 return os.path.isfile(os.path.join(gclient(['root']), ".gitmodules"))
160
161
162def get_submodule_rev(submodule):
163 """Returns revision of the given submodule path"""
164 rev_output = check_output(['git', 'submodule', 'status', submodule],
165 cwd=gclient(['root'])).strip()
166
167 # git submodule status <path> returns all submodules with its rev in the
168 # pattern: `(+|-| )(<revision>) (submodule.path)`
169 revision = rev_output.split(' ')[0]
170 return revision[1:] if revision[0] in ('+', '-') else revision
171
172
Edward Lemurfaae42e2018-11-26 18:34:30 +0000173def calculate_roll(full_dir, dependency, roll_to):
Edward Lesmesc772cf72018-04-03 14:47:30 -0400174 """Calculates the roll for a dependency by processing gclient_dict, and
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500175 fetching the dependency via git.
176 """
Aravind Vasudevan474e28e2023-01-18 20:29:51 +0000177 # if the super-project uses submodules, get rev directly using git.
178 if is_submoduled():
179 head = get_submodule_rev(dependency)
180 else:
181 head = gclient(['getdep', '-r', dependency])
Edward Lesmesc772cf72018-04-03 14:47:30 -0400182 if not head:
183 raise Error('%s is unpinned.' % dependency)
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500184 check_call(['git', 'fetch', 'origin', '--quiet'], cwd=full_dir)
Josip Sokcevic69902d02021-02-02 21:57:55 +0000185 if roll_to == 'origin/HEAD':
186 check_output(['git', 'remote', 'set-head', 'origin', '-a'], cwd=full_dir)
187
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500188 roll_to = check_output(['git', 'rev-parse', roll_to], cwd=full_dir).strip()
189 return head, roll_to
190
191
Josip Sokcevic69902d02021-02-02 21:57:55 +0000192
Robert Iannuccic1e65942018-10-18 17:59:45 +0000193def gen_commit_msg(logs, cmdline, reviewers, bug):
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500194 """Returns the final commit message."""
195 commit_msg = ''
196 if len(logs) > 1:
197 commit_msg = 'Rolling %d dependencies\n\n' % len(logs)
198 commit_msg += '\n\n'.join(logs)
Kenneth Russellebe839b2017-12-22 14:55:39 -0800199 commit_msg += '\nCreated with:\n ' + cmdline + '\n'
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500200 commit_msg += 'R=%s\n' % ','.join(reviewers) if reviewers else ''
Robert Iannuccic1e65942018-10-18 17:59:45 +0000201 commit_msg += '\nBug: %s\n' % bug if bug else ''
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500202 return commit_msg
203
204
Edward Lemurfaae42e2018-11-26 18:34:30 +0000205def finalize(commit_msg, current_dir, rolls):
206 """Commits changes to the DEPS file, then uploads a CL."""
maruel@chromium.org96550942015-05-22 18:46:51 +0000207 print('Commit message:')
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500208 print('\n'.join(' ' + i for i in commit_msg.splitlines()))
209
Aravind Vasudevan474e28e2023-01-18 20:29:51 +0000210 # Pull the dependency to the right revision. This is surprising to users
211 # otherwise. The revision update is done before commiting to update
212 # submodule revision if present.
213 for _head, roll_to, full_dir in sorted(rolls.values()):
214 check_call(['git', 'checkout', '--quiet', roll_to], cwd=full_dir)
215
216 # This adds the submodule revision update to the commit.
217 if is_submoduled():
218 check_call(['git', 'add', full_dir])
219
Edward Lesmes3f277fc2018-04-06 15:32:51 -0400220 check_call(['git', 'add', 'DEPS'], cwd=current_dir)
Bruce Dawson03af44a2022-12-27 19:37:58 +0000221 # We have to set delete=False and then let the object go out of scope so
222 # that the file can be opened by name on Windows.
223 with tempfile.NamedTemporaryFile('w+', newline='', delete=False) as f:
224 commit_filename = f.name
225 f.write(commit_msg)
226 check_call(['git', 'commit', '--quiet', '--file', commit_filename],
227 cwd=current_dir)
228 os.remove(commit_filename)
maruel@chromium.org398ed342015-09-29 12:27:25 +0000229
szager@chromium.org03fd85b2014-06-09 23:43:33 +0000230
maruel@chromium.org96550942015-05-22 18:46:51 +0000231def main():
sbc@chromium.org30e5b232015-06-01 18:06:59 +0000232 parser = argparse.ArgumentParser(description=__doc__)
maruel@chromium.org398ed342015-09-29 12:27:25 +0000233 parser.add_argument(
smut@google.com02d20872015-11-14 00:46:41 +0000234 '--ignore-dirty-tree', action='store_true',
235 help='Roll anyways, even if there is a diff.')
236 parser.add_argument(
Thiago Perrottaa0892812022-09-03 11:22:46 +0000237 '-r',
238 '--reviewer',
239 action='append',
240 help=
241 'To specify multiple reviewers, either use a comma separated list, e.g. '
242 '-r joe,jane,john or provide the flag multiple times, e.g. '
243 '-r joe -r jane. Defaults to @chromium.org')
maruel@chromium.org398ed342015-09-29 12:27:25 +0000244 parser.add_argument('-b', '--bug', help='Associate a bug number to the roll')
Eric Boren3be96a82017-09-29 10:07:46 -0400245 # It is important that --no-log continues to work, as it is used by
246 # internal -> external rollers. Please do not remove or break it.
maruel@chromium.org398ed342015-09-29 12:27:25 +0000247 parser.add_argument(
248 '--no-log', action='store_true',
249 help='Do not include the short log in the commit message')
250 parser.add_argument(
251 '--log-limit', type=int, default=100,
252 help='Trim log after N commits (default: %(default)s)')
253 parser.add_argument(
Josip Sokcevic69902d02021-02-02 21:57:55 +0000254 '--roll-to', default='origin/HEAD',
maruel@chromium.org398ed342015-09-29 12:27:25 +0000255 help='Specify the new commit to roll to (default: %(default)s)')
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500256 parser.add_argument(
257 '--key', action='append', default=[],
258 help='Regex(es) for dependency in DEPS file')
259 parser.add_argument('dep_path', nargs='+', help='Path(s) to dependency')
sbc@chromium.org30e5b232015-06-01 18:06:59 +0000260 args = parser.parse_args()
maruel@chromium.org96550942015-05-22 18:46:51 +0000261
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500262 if len(args.dep_path) > 1:
Josip Sokcevic69902d02021-02-02 21:57:55 +0000263 if args.roll_to != 'origin/HEAD':
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500264 parser.error(
265 'Can\'t use multiple paths to roll simultaneously and --roll-to')
266 if args.key:
267 parser.error(
268 'Can\'t use multiple paths to roll simultaneously and --key')
maruel@chromium.org96550942015-05-22 18:46:51 +0000269 reviewers = None
sbc@chromium.org30e5b232015-06-01 18:06:59 +0000270 if args.reviewer:
Thiago Perrottaa0892812022-09-03 11:22:46 +0000271 reviewers = list(itertools.chain(*[r.split(',') for r in args.reviewer]))
maruel@chromium.org96550942015-05-22 18:46:51 +0000272 for i, r in enumerate(reviewers):
273 if not '@' in r:
274 reviewers[i] = r + '@chromium.org'
275
Edward Lemurfaae42e2018-11-26 18:34:30 +0000276 gclient_root = gclient(['root'])
Edward Lesmes3f277fc2018-04-06 15:32:51 -0400277 current_dir = os.getcwd()
Bruce Dawson37b62e52020-06-23 18:06:00 +0000278 dependencies = sorted(d.replace('\\', '/').rstrip('/') for d in args.dep_path)
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500279 cmdline = 'roll-dep ' + ' '.join(dependencies) + ''.join(
280 ' --key ' + k for k in args.key)
sbc@chromium.orge5d984b2015-05-29 22:09:39 +0000281 try:
Edward Lesmes3f277fc2018-04-06 15:32:51 -0400282 if not args.ignore_dirty_tree and not is_pristine(current_dir):
283 raise Error(
284 'Ensure %s is clean first (no non-merged commits).' % current_dir)
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500285 # First gather all the information without modifying anything, except for a
286 # git fetch.
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500287 rolls = {}
288 for dependency in dependencies:
Edward Lemurfaae42e2018-11-26 18:34:30 +0000289 full_dir = os.path.normpath(os.path.join(gclient_root, dependency))
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500290 if not os.path.isdir(full_dir):
Edward Lemurfaae42e2018-11-26 18:34:30 +0000291 print('Dependency %s not found at %s' % (dependency, full_dir))
292 full_dir = os.path.normpath(os.path.join(current_dir, dependency))
293 print('Will look for relative dependency at %s' % full_dir)
294 if not os.path.isdir(full_dir):
295 raise Error('Directory not found: %s (%s)' % (dependency, full_dir))
296
297 head, roll_to = calculate_roll(full_dir, dependency, args.roll_to)
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500298 if roll_to == head:
299 if len(dependencies) == 1:
300 raise AlreadyRolledError('No revision to roll!')
301 print('%s: Already at latest commit %s' % (dependency, roll_to))
302 else:
303 print(
304 '%s: Rolling from %s to %s' % (dependency, head[:10], roll_to[:10]))
Edward Lemurfaae42e2018-11-26 18:34:30 +0000305 rolls[dependency] = (head, roll_to, full_dir)
sbc@chromium.orge5d984b2015-05-29 22:09:39 +0000306
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500307 logs = []
Edward Lemurfaae42e2018-11-26 18:34:30 +0000308 setdep_args = []
Marc-Antoine Ruel8e57b4b2019-10-11 01:01:36 +0000309 for dependency, (head, roll_to, full_dir) in sorted(rolls.items()):
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500310 log = generate_commit_message(
311 full_dir, dependency, head, roll_to, args.no_log, args.log_limit)
312 logs.append(log)
Edward Lemurfaae42e2018-11-26 18:34:30 +0000313 setdep_args.extend(['-r', '{}@{}'.format(dependency, roll_to)])
Edward Lesmesc772cf72018-04-03 14:47:30 -0400314
Aravind Vasudevan474e28e2023-01-18 20:29:51 +0000315 # DEPS is updated even if the repository uses submodules.
Edward Lemurfaae42e2018-11-26 18:34:30 +0000316 gclient(['setdep'] + setdep_args)
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500317
Robert Iannuccic1e65942018-10-18 17:59:45 +0000318 commit_msg = gen_commit_msg(logs, cmdline, reviewers, args.bug)
Edward Lemurfaae42e2018-11-26 18:34:30 +0000319 finalize(commit_msg, current_dir, rolls)
sbc@chromium.orge5d984b2015-05-29 22:09:39 +0000320 except Error as e:
321 sys.stderr.write('error: %s\n' % e)
smut7036c4f2016-06-09 14:28:48 -0700322 return 2 if isinstance(e, AlreadyRolledError) else 1
Corentin Wallez8732c0e2020-12-09 17:43:46 +0000323 except subprocess2.CalledProcessError:
Edward Lemur3c117942020-03-12 17:21:12 +0000324 return 1
sbc@chromium.orge5d984b2015-05-29 22:09:39 +0000325
Marc-Antoine Ruel85a8c102017-12-12 15:42:25 -0500326 print('')
327 if not reviewers:
328 print('You forgot to pass -r, make sure to insert a R=foo@example.com line')
329 print('to the commit description before emailing.')
330 print('')
331 print('Run:')
332 print(' git cl upload --send-mail')
sbc@chromium.orge5d984b2015-05-29 22:09:39 +0000333 return 0
szager@chromium.org03fd85b2014-06-09 23:43:33 +0000334
sbc@chromium.org98201122015-04-22 20:21:34 +0000335
szager@chromium.org03fd85b2014-06-09 23:43:33 +0000336if __name__ == '__main__':
maruel@chromium.org96550942015-05-22 18:46:51 +0000337 sys.exit(main())