diff options
author | 2018-06-06 15:24:36 +0200 | |
---|---|---|
committer | 2018-06-13 13:11:29 -0700 | |
commit | b6e3c8d163e20de08e612c300097523ba2fb36b6 (patch) | |
tree | 7b81ee1e802295143d90b1049fe03143cc490a35 | |
parent | eb7e71885b912b5b81b11eeb5b1097310c349b90 (diff) |
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 <tbramwell@linuxfoundation.org>
-rwxr-xr-x[-rw-r--r--] | releases/scripts/release-status.sh | 4 | ||||
-rw-r--r-- | releases/scripts/repos.py | 42 |
2 files changed, 40 insertions, 6 deletions
diff --git a/releases/scripts/release-status.sh b/releases/scripts/release-status.sh index da66bc936..6790100a7 100644..100755 --- 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__": |