blob: 64a18017ceff95bd817c05775dfaf6a6db77b511 [file] [log] [blame]
Liviu Rau3f146242022-02-23 11:48:281#!/usr/bin/env vpython3
Mathias Bynens8555df02020-04-27 14:19:062#
Yang Guofa871b62019-10-24 14:04:463# Copyright 2019 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6"""
7Update Chromium to ToT devtools-frontend.
8"""
9
10import argparse
Yang Guofa871b62019-10-24 14:04:4611import subprocess
12import sys
13
14
15def parse_options(cli_args):
16 parser = argparse.ArgumentParser(
17 description='Roll dependencies from Chromium.')
18 parser.add_argument('chromium_dir', help='Chromium directory')
19 parser.add_argument('devtools_dir', help='DevTools directory')
20 parser.add_argument('reviewer', help='reviewer for the CL')
21 return parser.parse_args(cli_args)
22
23def update(options):
24 # Update from upstream
25 subprocess.check_call(['git', 'fetch', 'origin'],
26 cwd=options.chromium_dir)
Alex Rudenko7d12c022021-04-07 06:11:1027 subprocess.check_call(['git', 'checkout', 'origin/main'],
Yang Guofa871b62019-10-24 14:04:4628 cwd=options.chromium_dir)
29 subprocess.check_call(['git', 'fetch', 'origin'],
30 cwd=options.devtools_dir)
31 # Get commit hashes
32 new_rev = subprocess.check_output(['git', 'rev-parse', 'origin/master'],
33 cwd=options.devtools_dir).strip()
34 old_rev = subprocess.check_output(
35 ['gclient', 'getdep', '--var=devtools_frontend_revision'],
36 cwd=options.chromium_dir).strip()
37 rev_range = '%s..%s' % (old_rev[0:10], new_rev[0:10])
38 # Create commit message
39 message = 'Update third_party/devtools-frontend %s' % rev_range
40 message = message + '\n\n'
41 message = message + 'https://chromium.googlesource.com/devtools/devtools-frontend/+log/'
42 message = message + rev_range
43 # Display changes
44 subprocess.check_call(['git', 'log', '--oneline', rev_range],
45 cwd=options.devtools_dir)
46 # Set deps
47 subprocess.check_call(
48 ['gclient', 'setdep', '--var=devtools_frontend_revision=%s' % new_rev],
49 cwd=options.chromium_dir)
50 # Create commit
51 subprocess.check_call(['git', 'add', 'DEPS'], cwd=options.chromium_dir)
52 subprocess.check_call(
53 ['git',
54 'checkout',
55 '-b',
56 'devtools_frontend_%s_%s' % (old_rev[0:5], new_rev[0:5])],
57 cwd=options.chromium_dir)
58 subprocess.check_call(['git', 'commit', '-m', message],
59 cwd=options.chromium_dir)
60 # Upload CL
61 subprocess.check_call(
62 ['git',
63 'cl',
64 'upload',
65 '-m', message,
66 '--tbrs=%s' % options.reviewer,
67 '-c'],
68 cwd=options.chromium_dir)
69 subprocess.check_call(['git', 'cl', 'web'], cwd=options.chromium_dir)
70
71
72if __name__ == '__main__':
73 OPTIONS = parse_options(sys.argv[1:])
74 update(OPTIONS)