2 from __future__
import print_function
6 from subprocess
import check_output
10 assert s.startswith(
"v")
11 return tuple(
int(c)
for c
in s[1:].
split(
".", 3))
14 tags_raw = check_output([
"git",
"tag",
"-l"]).decode(
"utf8").strip().
split(
"\n")
17 desc = check_output([
"git",
"describe",
"--exact-match",
"HEAD"]).strip()
18 on_tagged_commit =
True
19 except Exception
as e:
20 on_tagged_commit =
False
22 sys.stderr.write(
"On tagged commit? %s\n" % on_tagged_commit)
27 assert t.startswith(
"v")
29 sys.stderr.write(
"%s -> %s\n" % (t, version))
32 tags = list(sorted(tags))
35 if not on_tagged_commit:
36 sys.stderr.write(
"Not on tagged commit, testing against highest tag\n")
40 sys.stderr.write(
"Currently on %s\n" % str(current_tag))
41 idx = tags.index(current_tag)
42 assert idx != 0,
"This doesn't work on the first ever tag"
43 prev_tag = tags[idx - 1]
45 sys.stderr.write(
"Testing previous tag: v%s\n" %
".".join(map(str, prev_tag)))
48 sys.stdout.write(
"v%d.%02d.%02d" % prev_tag)