Read about our upcoming Code of Conduct on this issue

Commit 543ccb76 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

fetch-watch-tags: really alert for all specified series

and started to test this, with CI.

closes #1
parent e663b7cc47c0
Pipeline #19505 passed with stage
in 24 seconds
lint:
# same image as for py-heptapod. Quite overkill but should
# already be on all runners
image: octobus/ci-base
test:
# Image is quite overkill but should already be on all runners,
# as it is upstream of the ones used
# for testing of py-heptapod and HGitaly
image: registry.heptapod.net/heptapod/ci-images/fixed-pydeps
script:
......@@ -5,2 +6,3 @@
script:
- flake8 *.py
\ No newline at end of file
- flake8 *.py
- pytest --doctest-modules fetch-watch-tags.py
......@@ -4,6 +4,9 @@
*.\#*
*~
.pytest_cache/
__pycache__/
syntax: rootpath
# upstream Git repos
gitlab-ce
......
......@@ -20,6 +20,36 @@
return int(split[0]), int(split[1])
def filter_new_versions(new_versions, series=None):
"""Return only the highest version, optionally for each specified serie
Both version numbers and series are given as tuples of integers.
Examples::
>>> filter_new_versions([])
()
>>> filter_new_versions([(13, 7, 2), (13, 9, 3)])
[(13, 9, 3)]
>>> filter_new_versions([(13, 7, 2), (13, 7, 3), (13, 5, 4),
... (13, 9, 3), (13, 9, 4)],
... series=((13, 7), (13, 9)))
[(13, 7, 3), (13, 9, 4)]
>>> filter_new_versions([(13, 1, 4),
... (13, 9, 3), (13, 9, 5)],
... series=((13, 7), (13, 9)))
[(13, 9, 5)]
"""
if not new_versions:
return ()
if series is None:
return [max(v for v in new_versions)]
by_series = [[v for v in new_versions if v[:2] == ser]
for ser in series]
return sorted(max(versions) for versions in by_series if versions)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--simulate", action='store_true')
......@@ -78,11 +108,11 @@
if series:
print("Filtering according to specified version series: "
+ repr(series))
try:
new_versions = [max(v for v in new_versions if v[:2] in series)]
except ValueError: # max() on empty sequence
print("No release matches the given series")
return 0
new_versions = filter_new_versions(new_versions, series=series)
if not new_versions:
print("No new releases to consider")
return 0
if cl_args.create_issue:
for version in new_versions:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment