23 lines
569 B
Python
23 lines
569 B
Python
import logging
|
|
import os
|
|
import re
|
|
|
|
|
|
def get_tag_from_git(remote):
|
|
if remote is None:
|
|
logging.warning("cannot retreive tags from None remote")
|
|
return None
|
|
|
|
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]
|