Display tags before and after fetch

This commit is contained in:
Zach Borboa
2022-09-23 13:54:29 -07:00
parent 4072e32185
commit ba74b5534c
+10
View File
@@ -28,17 +28,27 @@ def main():
# git for-each-ref --format="%(refname:short) | %(creatordate)" "refs/tags/*"
local_repo = git.Repo(ROOT)
print('before:')
print(local_repo.git.tag('--list'))
# Fetch tags since `git fetch' is run with --no-tags during actions/checkout.
# git fetch --tags
for remote in local_repo.remotes:
remote.fetch()
print('after:')
print(local_repo.git.tag('--list'))
# 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)
print('sorted tags:')
for tag in tags:
print(tag.name)
most_recent_tag = tags[0]
print('most_recent_tag: {}'.format(most_recent_tag))
most_recent_tag_datetime = most_recent_tag.commit.committed_datetime