commit c92864febe90b4466908093061797c2667b6edfa Author: Peter J. Holzer Date: Mon Mar 21 12:00:00 2022 +0100 Tag repo with date diff --git a/tagger b/tagger new file mode 100755 index 0000000..22122a1 --- /dev/null +++ b/tagger @@ -0,0 +1,33 @@ +#!/usr/bin/python3 + +import datetime +import re +import subprocess + +subprocess.run(["git", "pull"]) +result = subprocess.run(["git", "log", "--pretty=format:%H %D", "--date-order"], stdout=subprocess.PIPE, universal_newlines=True) +found_tags = set() +need_tag = False +for ln in result.stdout.split("\n"): + + m = re.match(r"[0-9a-f]+ .*\btag: ([-a-z0-9._]+)", ln) + if m: + found_tags.add(m.group(1)) + + if not found_tags: + need_tag = True + +print(need_tag, found_tags) +if need_tag: + today = datetime.date.today() + tag = today.strftime("r%y.%m.%d") + if tag in found_tags: + inc = 1 + while f"{tag}.{inc}" in found_tags: + inc += 1 + tag = f"{tag}.{inc}" + print(tag) + subprocess.run(["git", "tag", "-a", tag, "-m", "auto-tagged"]) + subprocess.run(["git", "push", "--tags"]) + +# vim: expandtab sw=4