Moved logic to own function

Allows importing from another file
This commit is contained in:
Marcel Kapfer 2021-05-26 21:13:28 +02:00
parent 8659de71cd
commit c3e3b0800a
Signed by: mmk2410
GPG Key ID: CADE6F0C09F21B09
1 changed files with 12 additions and 10 deletions

View File

@ -20,13 +20,7 @@
import subprocess
def main():
# # TODO: Add user defined keywords to the list.
# ignored_keywords = ["pre", "rc", "beta", "alpha", "dev"]
# # TODO: Add a ability for the user to customize this.
# default_branch = "main"
def sorted_tags():
# Retrieve all tags in the repo (that are fetched...)
tags = subprocess.run(["git", "tag"], stdout=subprocess.PIPE)
allowedTags = {}
@ -39,12 +33,20 @@ def main():
# Strip away the encloding quotes as well as some whitespace
allowedTags[tag] = date.stdout.decode('utf-8').strip(" \n'")
# Sort by keys, which are the retrieved timestampes
allowedTags = sorted(allowedTags.items(), key=lambda item: item[1])
return sorted(allowedTags.items(), key=lambda item: item[1])
def main():
# # TODO: Add user defined keywords to the list.
# ignored_keywords = ["pre", "rc", "beta", "alpha", "dev"]
# # TODO: Add a ability for the user to customize this.
# default_branch = "main"
tags = sorted_tags()
# Printing out
for k,v in allowedTags:
for k,_ in tags:
print(k)
print("Latest tag: {}\nSecond latest tag: {}".format(allowedTags[-1][0],allowedTags[-2][0]))
print("Latest tag: {}\nSecond latest tag: {}".format(tags[-1][0],tags[-2][0]))
if __name__ == "__main__":