X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=releases%2Fscripts%2Frepos.py;h=91c4e9300a3fb0c7c2234846a958e0b6e6d40ee1;hb=c0c6f23c2c494cefa01398f6c18e95af4c801d1a;hp=47ce42d887329642b85a84218e9065eeffa58a94;hpb=0ee36b71b34afa6f54415a8ed7bcd25222591a4e;p=releng.git diff --git a/releases/scripts/repos.py b/releases/scripts/repos.py index 47ce42d88..91c4e9300 100644 --- a/releases/scripts/repos.py +++ b/releases/scripts/repos.py @@ -63,20 +63,28 @@ def main(): type=str, help="Only print" "SHAs for the specified release") + parser.add_argument('--branches', '-b', + action='store_true', + default=False, + help="Print Branch info") + args = parser.parse_args() project = yaml.safe_load(args.file) - list_repos(project, args) + if args.branches: + list_branches(project, args) + else: + list_repos(project, args) def list_repos(project, args): """List repositories in the project file""" lookup = project.get('releases', []) + if 'releases' not in project: exit(0) - repos = set() for item in lookup: repo, ref = next(iter(item['location'].items())) @@ -90,5 +98,24 @@ def list_repos(project, args): print(repo) +def list_branches(project, args): + """List branches in the project file""" + + lookup = project.get('branches', []) + + if 'branches' not in project: + exit(0) + repos = set() + for item in lookup: + repo, ref = next(iter(item['location'].items())) + if args.names: + repos.add(Repo(repo)) + elif args.release and item['name'] == args.release: + repos.add(Repo(repo, ref)) + elif not args.release: + repos.add(Repo(repo, item['name'], ref)) + for repo in repos: + print(repo) + if __name__ == "__main__": main()