mirrored from https://chromium.googlesource.com/infra/luci/recipes-py
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmanual_roll.py
58 lines (40 loc) · 1.62 KB
/
manual_roll.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright 2018 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
"""Calculate the smallest possible recipes.cfg roll.
Prints changelist to stdout, extra info to stderr.
Exits 1 if no roll is found.
"""
import sys
from .autoroll.cmd import write_global_files_to_main_repo
from ..autoroll_impl.candidate_algorithm import get_roll_candidates
def add_arguments(parser):
parser.set_defaults(func=main, minimal_recipe_deps=True)
def main(args):
original_spec = args.recipe_deps.main_repo.recipes_cfg_pb2
# Fetch all remote changes locally, so we can compute metadata for them.
for repo in args.recipe_deps.repos.values():
if repo.name == args.recipe_deps.main_repo_id:
continue
repo.backend.fetch(original_spec.deps[repo.name].branch)
candidates, rejected, repos = get_roll_candidates(args.recipe_deps)
if not candidates:
print(
'No roll found. Rejected %d invalid roll candidates.' %
(len(rejected),), file=sys.stderr)
return 1
print(file=sys.stderr)
print('recipes.cfg has been rolled, use `recipes.py test train` to train '
'expectations.', file=sys.stderr)
print(file=sys.stderr)
print('Changelog:', file=sys.stderr)
candidate = candidates[0]
for pid, clist in candidate.changelist(repos).items():
print()
print(pid+':')
for commit in clist:
print(' https://crrev.com/%s %s (%s)' % (
commit.revision, commit.message_lines[0], commit.author_email
))
write_global_files_to_main_repo(args.recipe_deps, candidate.repo_spec)
return 0