Sort tags by version

This commit is contained in:
Zach Borboa
2022-09-23 13:46:46 -07:00
parent ff424b2a69
commit 4072e32185
+6 -2
View File
@@ -33,9 +33,13 @@ def main():
for remote in local_repo.remotes:
remote.fetch()
tags = sorted(local_repo.tags, key=lambda tag: tag.commit.committed_datetime)
most_recent_tag = tags[-1]
# Sort the tags by version.
# git tag --list | sort --reverse --version-sort
tags = sorted(
local_repo.tags,
key=lambda tag: list(map(int, tag.name.split('.'))), reverse=True)
most_recent_tag = tags[0]
print('most_recent_tag: {}'.format(most_recent_tag))
most_recent_tag_datetime = most_recent_tag.commit.committed_datetime
print('most_recent_tag_datetime: {}'.format(most_recent_tag_datetime))