11import atexit # For playing a sound when the program finishes
2+ import csv # For writing to a CSV file
23import os # For running a command in the terminal
34import platform # For getting the operating system name
4- import csv # For writing to a CSV file
5+ import re # For regular expressions
56import subprocess # For running git commands
67from colorama import Style # For coloring the terminal
78
@@ -57,6 +58,17 @@ def verify_git_installed():
5758 except Exception : # If an error occurs during the process
5859 return False # Git is not installed
5960
61+ def _tag_sort_key (t ):
62+ """
63+ Key function for sorting tags in a human-friendly way.
64+
65+ :param t: Tag name
66+ :return: List of strings and integers for sorting
67+ """
68+
69+ parts = re .split (r"(\d+)" , t ) # Split the tag into parts of digits and non-digits
70+ return [int (p ) if p .isdigit () else p .lower () for p in parts ] # Convert digit parts to integers for proper sorting
71+
6072def get_repository_tags (repo_url ):
6173 """
6274 Retrieves all tag names from a remote Git repository using native git commands.
@@ -65,6 +77,10 @@ def get_repository_tags(repo_url):
6577 :return: list of tag names
6678 """
6779
80+ if not verify_git_installed (): # Verify if git is installed
81+ print (f"{ BackgroundColors .RED } Git is not installed on this system. Please install Git to retrieve repository tags.{ Style .RESET_ALL } " )
82+ exit (1 ) # Exit the program
83+
6884 tags_list = [] # List to store the tag names
6985
7086 try : # Try to retrieve the tags using git ls-remote
@@ -102,6 +118,8 @@ def get_repository_tags(repo_url):
102118 except Exception as e : # If an error occurs during the process
103119 print (f"{ BackgroundColors .RED } Failed to retrieve tags: { BackgroundColors .CYAN } { e } { Style .RESET_ALL } " )
104120
121+ tags_list = sorted (tags_list , key = _tag_sort_key ) # Sort tags from lowest → highest
122+
105123 return tags_list # Return the list of tag names
106124
107125def create_directory (full_directory_name , relative_directory_name ):
0 commit comments