Tag repo with date
This commit is contained in:
commit
c92864febe
|
@ -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
|
Loading…
Reference in New Issue