Skip to content

Commit

Permalink
Merge pull request docker#3457 from dnephin/fix_versions_script
Browse files Browse the repository at this point in the history
Skip invalid git tags in versions.py
  • Loading branch information
shin- committed May 12, 2016
2 parents 72f6a5c + 4bf5271 commit c9fe892
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion script/test/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import argparse
import itertools
import operator
import sys
from collections import namedtuple

import requests
Expand Down Expand Up @@ -103,6 +104,14 @@ def get_default(versions):
return version


def get_versions(tags):
for tag in tags:
try:
yield Version.parse(tag['name'])
except ValueError:
print("Skipping invalid tag: {name}".format(**tag), file=sys.stderr)


def get_github_releases(project):
"""Query the Github API for a list of version tags and return them in
sorted order.
Expand All @@ -112,7 +121,7 @@ def get_github_releases(project):
url = '{}/{}/tags'.format(GITHUB_API, project)
response = requests.get(url)
response.raise_for_status()
versions = [Version.parse(tag['name']) for tag in response.json()]
versions = get_versions(response.json())
return sorted(versions, reverse=True, key=operator.attrgetter('order'))


Expand Down

0 comments on commit c9fe892

Please sign in to comment.