From b6e3c8d163e20de08e612c300097523ba2fb36b6 Mon Sep 17 00:00:00 2001 From: Trevor Bramwell Date: Wed, 6 Jun 2018 15:24:36 +0200 Subject: Update the repo script to only list repos once When projects have multiple releases (ex 6.0, 6.1) the repos would be listed multiple times when only wanting repo names. This change still supports listing the repos when they have multiple versions. Change-Id: I7b0c96649b5486d91b177f95cf175bebcb53815b Signed-off-by: Trevor Bramwell --- releases/scripts/release-status.sh | 4 ++-- releases/scripts/repos.py | 42 ++++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) mode change 100644 => 100755 releases/scripts/release-status.sh diff --git a/releases/scripts/release-status.sh b/releases/scripts/release-status.sh old mode 100644 new mode 100755 index da66bc936..6790100a7 --- a/releases/scripts/release-status.sh +++ b/releases/scripts/release-status.sh @@ -12,6 +12,8 @@ set -o pipefail TAG="${TAG:-opnfv-6.0.0}" RELEASE="${RELEASE:-fraser}" +[ -a repos.txt ] && rm repos.txt + for project in releases/$RELEASE/*; do python releases/scripts/repos.py -n -f $project >> repos.txt done @@ -21,5 +23,3 @@ do tag="$(git ls-remote "https://gerrit.opnfv.org/gerrit/$repo.git" "refs/tags/$TAG")" echo "$repo $tag" done < repos.txt - -# rm repos.txt diff --git a/releases/scripts/repos.py b/releases/scripts/repos.py index 0ded0207b..58454c318 100644 --- a/releases/scripts/repos.py +++ b/releases/scripts/repos.py @@ -15,6 +15,38 @@ import argparse import yaml +class Repo(object): + """Object representing a repo listed in the release file. + + Includes eq, hash, and ne methods so set comparisons work + """ + + def __init__(self, repo=None, ref=None, version=None): + self.repo = repo + self.ref = ref + self.version = version + + def __repr__(self): + if self.version: + return "%s %s %s" % (self.repo, self.ref, self.version) + elif self.ref: + return "%s %s" % (self.repo, self.ref) + return "%s" % self.repo + + def __eq__(self, obj): + if isinstance(obj, Repo): + return ((self.repo == obj.repo) and + (self.ref == obj.ref) and + (self.version == obj.version)) + return False + + def __ne__(self, obj): + return (not self.__eq__(obj)) + + def __hash__(self): + return hash(self.__repr__()) + + def main(): """Given a release yamlfile list the repos it contains""" @@ -45,15 +77,17 @@ def list_repos(project, args): if 'releases' not in project: exit(0) + repos = set() for item in lookup: repo, ref = next(iter(item['location'].items())) if args.names: - print(repo) + repos.add(Repo(repo)) elif args.release and item['version'] == args.release: - print("%s %s" % (repo, ref)) + repos.add(Repo(repo, ref)) elif not args.release: - # Print all releases - print("%s %s %s" % (repo, item['version'], ref)) + repos.add(Repo(repo, ref, item['version'])) + for repo in repos: + print repo if __name__ == "__main__": -- cgit 1.2.3-korg