Liviu Rau | 3f14624 | 2022-02-23 11:48:28 | [diff] [blame] | 1 | #!/usr/bin/env vpython3 |
Mathias Bynens | 8555df0 | 2020-04-27 14:19:06 | [diff] [blame] | 2 | # |
Yang Guo | fa871b6 | 2019-10-24 14:04:46 | [diff] [blame] | 3 | # 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 | """ |
| 7 | Update Chromium to ToT devtools-frontend. |
| 8 | """ |
| 9 | |
| 10 | import argparse |
Yang Guo | fa871b6 | 2019-10-24 14:04:46 | [diff] [blame] | 11 | import subprocess |
| 12 | import sys |
| 13 | |
| 14 | |
| 15 | def 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 | |
| 23 | def update(options): |
| 24 | # Update from upstream |
| 25 | subprocess.check_call(['git', 'fetch', 'origin'], |
| 26 | cwd=options.chromium_dir) |
Alex Rudenko | 7d12c02 | 2021-04-07 06:11:10 | [diff] [blame] | 27 | subprocess.check_call(['git', 'checkout', 'origin/main'], |
Yang Guo | fa871b6 | 2019-10-24 14:04:46 | [diff] [blame] | 28 | 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 | |
| 72 | if __name__ == '__main__': |
| 73 | OPTIONS = parse_options(sys.argv[1:]) |
| 74 | update(OPTIONS) |