2 # SPDX-License-Identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
19 """Given a release yamlfile list the repos it contains"""
21 parser = argparse.ArgumentParser()
22 parser.add_argument('--file', '-f',
23 type=argparse.FileType('r'),
25 parser.add_argument('--names', '-n',
28 help="Only print the names of repos, "
30 parser.add_argument('--release', '-r',
33 "SHAs for the specified release")
34 args = parser.parse_args()
36 project = yaml.safe_load(args.file)
38 list_repos(project, args)
41 def list_repos(project, args):
42 """List repositories in the project file"""
44 lookup = project.get('releases', [])
45 if 'releases' not in project:
49 repo, ref = next(iter(item['location'].items()))
52 elif args.release and item['version'] == args.release:
53 print("%s %s" % (repo, ref))
54 elif not args.release:
56 print("%s %s %s" % (repo, item['version'], ref))
59 if __name__ == "__main__":