INNER CODE UNIT · Python
git
lissy93/portainer-templates · lib/changelog.py:33
def git(*args):
"""Run a git command in the repo root and return its stdout"""
result = subprocess.run(
['git', *args], capture_output=True, text=True, check=True, cwd=root_dir)
return result.stdout
def version(tag):
"""Numeric (major, minor, patch) tuple for a vX.Y.Z tag"""
return tuple(int(p) for p in tag[1:].split('.'))
def semver_tags():
"""All vMAJOR.MINOR.PATCH tags from FIRST_VERSION onwards, oldest first"""
tags = [t for t in git('tag').splitlines() if SEMVER_TAG.match(t)]
return sorted((t for t in tags if version(t) >= FIRST_VERSION), key=version)
def tag_dates():
"""Map of tag -> creation date (YYYY-MM-DD)"""
lines = git('for-each-ref', '--format=%(refname:short) %(creatordate:short)',