25 lines
527 B
Python
25 lines
527 B
Python
import logging
|
|
import os
|
|
import re
|
|
|
|
|
|
def get_tags_from_git(remote):
|
|
regex = re.compile("^refs/tags/v?(\d+\.\d+\.\d+)$")
|
|
def extract_tag(tag):
|
|
m = regex.search(tag)
|
|
if m:
|
|
return m.groups()[0]
|
|
return ""
|
|
|
|
raw_tags = os.popen(f"git ls-remote --tags {remote}").read().split()
|
|
tags = sorted(
|
|
list(
|
|
filter(''.__ne__,
|
|
map(extract_tag, raw_tags)
|
|
),
|
|
)
|
|
)
|
|
logging.debug(f"{remote}: {', '.join(tags)}")
|
|
|
|
return tags[-1]
|