blob: 2c7fc610618941def35a791a4aeb66d23dc9c9ce [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
Recipe to take a jiri diff of two jiri project revisions.
"""
import json
from recipe_engine.recipe_api import Property
DEPS = [
'fuchsia/jiri',
'recipe_engine/context',
'recipe_engine/path',
'recipe_engine/properties',
'recipe_engine/step',
]
PROPERTIES = {
'revision_1':
Property(
kind=str,
help='Revision 1 as commit SHA1.',
),
'revision_2':
Property(
kind=str,
help='Revision 2 as commit SHA1.',
),
'project':
Property(
kind=str,
help='Jiri project to use.',
),
'manifest':
Property(
kind=str,
help='Jiri manifest to use.',
),
'remote':
Property(
kind=str,
help='Remote manifest repository SSO.',
),
'max_cls':
Property(
kind=int,
default=1000,
help='Max number of CLs to display per project.',
)
}
def RunSteps(api, revision_1, revision_2, project, manifest, remote, max_cls):
snapshot_file_1 = api.path.mkstemp()
snapshot_file_2 = api.path.mkstemp()
# Checkout at both revisions, taking a snapshot each time.
with api.context(cwd=api.path.mkdtemp()):
api.jiri.init()
for revision, snapshot_file in (
(revision_1, snapshot_file_1),
(revision_2, snapshot_file_2),
):
api.jiri.import_manifest(
manifest=manifest,
remote=remote,
name=project,
revision=revision,
overwrite=True,
)
api.jiri.update(
fetch_packages=False,
run_hooks=False,
)
api.jiri.snapshot(snapshot_file=snapshot_file)
diff = api.jiri.diff(
snapshot_file_1=snapshot_file_1,
snapshot_file_2=snapshot_file_2,
max_cls=max_cls,
)
# Display diff on build UI.
diff_logs = api.step.active_result.presentation.logs
diff_logs['diff'] = diff.split('\n')
def GenTests(api):
yield (api.test('basic') + api.properties(
revision_1='foo',
revision_2='bar',
project='project',
manifest='test/manifest/path',
remote='sso://fuchsia/project',
))