Moved logic to own function
Allows importing from another file
This commit is contained in:
parent
8659de71cd
commit
c3e3b0800a
1 changed files with 12 additions and 10 deletions
|
@ -20,13 +20,7 @@
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
def sorted_tags():
|
||||||
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"
|
|
||||||
|
|
||||||
# Retrieve all tags in the repo (that are fetched...)
|
# Retrieve all tags in the repo (that are fetched...)
|
||||||
tags = subprocess.run(["git", "tag"], stdout=subprocess.PIPE)
|
tags = subprocess.run(["git", "tag"], stdout=subprocess.PIPE)
|
||||||
allowedTags = {}
|
allowedTags = {}
|
||||||
|
@ -39,12 +33,20 @@ def main():
|
||||||
# Strip away the encloding quotes as well as some whitespace
|
# Strip away the encloding quotes as well as some whitespace
|
||||||
allowedTags[tag] = date.stdout.decode('utf-8').strip(" \n'")
|
allowedTags[tag] = date.stdout.decode('utf-8').strip(" \n'")
|
||||||
# Sort by keys, which are the retrieved timestampes
|
# 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
|
# Printing out
|
||||||
for k,v in allowedTags:
|
for k,_ in tags:
|
||||||
print(k)
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|
Reference in a new issue