forked from mirrors/nixpkgs
gitlab: update.py: properly sort version numbers, ignore invalid versions
This commit is contained in:
parent
c53b8aa77b
commit
847eb76cf8
|
@ -9,6 +9,7 @@ import logging
|
|||
import subprocess
|
||||
import json
|
||||
import pathlib
|
||||
from distutils.version import LooseVersion
|
||||
from typing import Iterable
|
||||
|
||||
import requests
|
||||
|
@ -18,6 +19,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class GitLabRepo:
|
||||
version_regex = re.compile(r"^v\d+\.\d+\.\d+(\-rc\d+)?(\-ee)?")
|
||||
def __init__(self, owner: str, repo: str):
|
||||
self.owner = owner
|
||||
self.repo = repo
|
||||
|
@ -31,8 +33,13 @@ class GitLabRepo:
|
|||
r = requests.get(self.url + "/tags?format=atom", stream=True)
|
||||
|
||||
tree = ElementTree.fromstring(r.content)
|
||||
return sorted((e.text for e in tree.findall(
|
||||
'{http://www.w3.org/2005/Atom}entry/{http://www.w3.org/2005/Atom}title')), reverse=True)
|
||||
versions = [e.text for e in tree.findall('{http://www.w3.org/2005/Atom}entry/{http://www.w3.org/2005/Atom}title')]
|
||||
# filter out versions not matching version_regex
|
||||
versions = filter(self.version_regex.match, versions)
|
||||
|
||||
# sort, but ignore v and -ee for sorting comparisons
|
||||
versions.sort(key=lambda x: LooseVersion(x.replace("v", "").replace("-ee", "")), reverse=True)
|
||||
return versions
|
||||
|
||||
def get_git_hash(self, rev: str):
|
||||
out = subprocess.check_output(['nix-prefetch-git', self.url, rev])
|
||||
|
@ -202,7 +209,6 @@ def update_gitaly():
|
|||
click.echo(f"Please update gitaly/default.nix to version {gitaly_server_version} and hash {gitaly_hash}")
|
||||
|
||||
|
||||
|
||||
@cli.command('update-gitlab-shell')
|
||||
def update_gitlab_shell():
|
||||
"""Update gitlab-shell"""
|
||||
|
|
Loading…
Reference in a new issue