| # 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 for updating the code search super manifest project""" |
| |
| from recipe_engine.recipe_api import Property |
| |
| DEPS = [ |
| 'fuchsia/checkout', |
| 'fuchsia/git', |
| 'fuchsia/jiri', |
| 'recipe_engine/buildbucket', |
| 'recipe_engine/context', |
| 'recipe_engine/file', |
| 'recipe_engine/path', |
| 'recipe_engine/step', |
| ] |
| |
| PROPERTIES = { |
| 'manifest': |
| Property(kind=str, help='Jiri manifest to use.', default='flower'), |
| 'remote': |
| Property( |
| kind=str, |
| help='Remote manifest repository.', |
| default='https://fuchsia.googlesource.com/integration'), |
| 'super_manifest_project': |
| Property( |
| kind=str, |
| help='Super manifest project to update.', |
| default='https://fuchsia.googlesource.com/super') |
| } |
| |
| GENERATE_SCRIPT = 'setup.sh' |
| |
| |
| def RunSteps(api, manifest, remote, super_manifest_project): |
| api.checkout.fuchsia_with_options( |
| build=api.buildbucket.build, |
| manifest=manifest, |
| path=api.path['start_dir'], |
| remote=remote, |
| ) |
| |
| super_manifest_project_path = api.path['start_dir'].join('super') |
| api.file.ensure_directory('make dirs', super_manifest_project_path) |
| |
| api.git.checkout( |
| url=super_manifest_project, |
| path=super_manifest_project_path, |
| submodules=False) |
| |
| generate_script_path = super_manifest_project_path.join(GENERATE_SCRIPT) |
| with api.context(cwd=super_manifest_project_path): |
| # See https://fuchsia.googlesource.com/jiri/+/master/cmd/jiri/generate-gitmodules.go |
| # for details. |
| api.jiri('generate-gitmodules', '--redir-root', '--generate-script', |
| generate_script_path, '.gitmodules') |
| api.step('run %s' % GENERATE_SCRIPT, [generate_script_path]) |
| api.file.remove('remove %s' % GENERATE_SCRIPT, generate_script_path) |
| # Add & Push updated submodules. |
| api.git('add', '.gitmodules') |
| # Only commit and push if we have a diff, otherwise commit fails. |
| if api.git('diff', '--cached', '--exit-code', ok_ret='any').retcode: |
| api.git.commit(message='Update submodules based on jiri manifest') |
| api.git('push', 'origin', 'HEAD:master') |
| |
| |
| def GenTests(api): |
| yield api.test('no_diff') |
| yield api.test('yes_diff') + api.step_data('git diff', retcode=1) |