Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: tools/autoroller/roll_chromium_revision.py

Issue 1173523003: Auto-roll script: Add dirty tree check and git pull (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added treecheck and made pull not run in dry-run mode Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 # Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 # 3 #
4 # Use of this source code is governed by a BSD-style license 4 # Use of this source code is governed by a BSD-style license
5 # that can be found in the LICENSE file in the root of the source 5 # that can be found in the LICENSE file in the root of the source
6 # tree. An additional intellectual property rights grant can be found 6 # tree. An additional intellectual property rights grant can be found
7 # in the file PATENTS. All contributing project authors may 7 # in the file PATENTS. All contributing project authors may
8 # be found in the AUTHORS file in the root of the source tree. 8 # be found in the AUTHORS file in the root of the source tree.
9 9
10 """Script to roll chromium_revision in the WebRTC DEPS file.""" 10 """Script to roll chromium_revision in the WebRTC DEPS file."""
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 283
284 def UpdateDeps(deps_filename, old_cr_revision, new_cr_revision): 284 def UpdateDeps(deps_filename, old_cr_revision, new_cr_revision):
285 """Update the DEPS file with the new revision.""" 285 """Update the DEPS file with the new revision."""
286 with open(deps_filename, 'rb') as deps_file: 286 with open(deps_filename, 'rb') as deps_file:
287 deps_content = deps_file.read() 287 deps_content = deps_file.read()
288 deps_content = deps_content.replace(old_cr_revision, new_cr_revision) 288 deps_content = deps_content.replace(old_cr_revision, new_cr_revision)
289 with open(deps_filename, 'wb') as deps_file: 289 with open(deps_filename, 'wb') as deps_file:
290 deps_file.write(deps_content) 290 deps_file.write(deps_content)
291 291
292 def _IsTreeClean():
293 stdout, _ = _RunCommand(['git', 'status', '--porcelain'])
294 if len(stdout) == 0:
295 return True
296
297 logging.error('Dirty/unversioned files:\n%s', stdout)
298 return False
292 299
293 def _CreateRollBranch(dry_run): 300 def _CreateRollBranch(dry_run):
294 current_branch = _RunCommand( 301 current_branch = _RunCommand(
295 ['git', 'rev-parse', '--abbrev-ref', 'HEAD'])[0].splitlines()[0] 302 ['git', 'rev-parse', '--abbrev-ref', 'HEAD'])[0].splitlines()[0]
296 if current_branch != 'master': 303 if current_branch != 'master':
297 logging.error('Please checkout the master branch and re-run this script.') 304 logging.error('Please checkout the master branch and re-run this script.')
298 if not dry_run: 305 if not dry_run:
299 sys.exit(-1) 306 sys.exit(-1)
300 307
308 logging.info('Updating master branch...')
309 if not dry_run:
310 _RunCommand(['git', 'pull'])
301 logging.info('Creating roll branch: %s', ROLL_BRANCH_NAME) 311 logging.info('Creating roll branch: %s', ROLL_BRANCH_NAME)
302 if not dry_run: 312 if not dry_run:
303 _RunCommand(['git', 'checkout', '-b', ROLL_BRANCH_NAME]) 313 _RunCommand(['git', 'checkout', '-b', ROLL_BRANCH_NAME])
304 314
305 315
306 def _RemovePreviousRollBranch(dry_run): 316 def _RemovePreviousRollBranch(dry_run):
307 active_branch, branches = _GetBranches() 317 active_branch, branches = _GetBranches()
308 if active_branch == ROLL_BRANCH_NAME: 318 if active_branch == ROLL_BRANCH_NAME:
309 active_branch = 'master' 319 active_branch = 'master'
310 if ROLL_BRANCH_NAME in branches: 320 if ROLL_BRANCH_NAME in branches:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 'tryjobs.')) 356 'tryjobs.'))
347 p.add_argument('-v', '--verbose', action='store_true', default=False, 357 p.add_argument('-v', '--verbose', action='store_true', default=False,
348 help='Be extra verbose in printing of log messages.') 358 help='Be extra verbose in printing of log messages.')
349 opts = p.parse_args() 359 opts = p.parse_args()
350 360
351 if opts.verbose: 361 if opts.verbose:
352 logging.basicConfig(level=logging.DEBUG) 362 logging.basicConfig(level=logging.DEBUG)
353 else: 363 else:
354 logging.basicConfig(level=logging.INFO) 364 logging.basicConfig(level=logging.INFO)
355 365
366 if not _IsTreeClean():
367 logging.error('Please clean your local checkout first.')
368 return 1
369
356 if opts.clean: 370 if opts.clean:
357 _RemovePreviousRollBranch(opts.dry_run) 371 _RemovePreviousRollBranch(opts.dry_run)
358 372
359 if not opts.revision: 373 if not opts.revision:
360 lkgr_contents = ReadUrlContent(CHROMIUM_LKGR_URL) 374 lkgr_contents = ReadUrlContent(CHROMIUM_LKGR_URL)
361 logging.info('No revision specified. Using LKGR: %s', lkgr_contents[0]) 375 logging.info('No revision specified. Using LKGR: %s', lkgr_contents[0])
362 opts.revision = lkgr_contents[0] 376 opts.revision = lkgr_contents[0]
363 377
364 deps_filename = os.path.join(CHECKOUT_ROOT_DIR, 'DEPS') 378 deps_filename = os.path.join(CHECKOUT_ROOT_DIR, 'DEPS')
365 local_deps = ParseLocalDepsFile(deps_filename) 379 local_deps = ParseLocalDepsFile(deps_filename)
(...skipping 16 matching lines...) Expand all
382 _CreateRollBranch(opts.dry_run) 396 _CreateRollBranch(opts.dry_run)
383 UpdateDeps(deps_filename, current_cr_rev, opts.revision) 397 UpdateDeps(deps_filename, current_cr_rev, opts.revision)
384 _LocalCommit(commit_msg, opts.dry_run) 398 _LocalCommit(commit_msg, opts.dry_run)
385 _UploadCL(opts.dry_run) 399 _UploadCL(opts.dry_run)
386 _LaunchTrybots(opts.dry_run) 400 _LaunchTrybots(opts.dry_run)
387 return 0 401 return 0
388 402
389 403
390 if __name__ == '__main__': 404 if __name__ == '__main__':
391 sys.exit(main()) 405 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698