Add --changes flag to buildbucket.py's put subcommand
This flag allows the user to specify a file which contains a JSON list of dicts to set for the "changes" property when scheduling the build.
BUG=493885
Review URL: https://codereview.chromium.org/1199963004
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295788 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/buildbucket.py b/buildbucket.py
index 97829d4..f00cc8f 100755
--- a/buildbucket.py
+++ b/buildbucket.py
@@ -52,6 +52,11 @@
required=True,
)
put_parser.add_argument(
+ '-c',
+ '--changes',
+ help='A flie to load a JSON list of changes dicts from.',
+ )
+ put_parser.add_argument(
'-n',
'--builder-name',
help='The builder to schedule the build on.',
@@ -66,6 +71,15 @@
# TODO(smut): When more commands are implemented, refactor this.
assert args.command == 'put'
+ changes = []
+ if args.changes:
+ try:
+ with open(args.changes) as fp:
+ changes.extend(json.load(fp))
+ except (TypeError, ValueError):
+ sys.stderr.write('%s contained invalid JSON list.\n' % args.changes)
+ raise
+
properties = {}
if args.properties:
try:
@@ -88,6 +102,7 @@
'bucket': args.bucket,
'parameters_json': json.dumps({
'builder_name': args.builder_name,
+ 'changes': changes,
'properties': properties,
}),
}),