@@ -12,8 +12,46 @@ def main():
1212 required = True , help = "The version string to update" )
1313 argument_parser .add_argument ("--type" , metavar = "<string containing PATCH, MINOR, or MAJOR>" ,
1414 required = True , help = "Which version number to bump" )
15+ argument_parser .add_argument ("--parse_latest_version" , metavar = "<true>" ,
16+ help = "Takes '$(git tag)' and returns the highest version in the list" , default = "false" )
1517 parsed_commands = argument_parser .parse_args ()
1618
19+ if (parsed_commands .parse_latest_version == "true" ):
20+ version_list = parsed_commands .version .split ("\n " )
21+ highest = [0 , 0 , 0 ]
22+
23+ for i in range (0 , len (version_list )):
24+ i_version = version_list [i ]
25+ i_version = i_version .replace ("v" , "" )
26+
27+ i_version_tuple = i_version .split ("." )
28+ if (len (i_version_tuple ) != 3 ):
29+ continue
30+
31+ i_version_tuple [0 ] = int (i_version_tuple [0 ])
32+ i_version_tuple [1 ] = int (i_version_tuple [1 ])
33+ i_version_tuple [2 ] = int (i_version_tuple [2 ])
34+
35+ if (highest == None ):
36+ highest = i_version_tuple
37+ continue
38+ else :
39+ if (i_version_tuple [0 ] > highest [0 ]):
40+ highest = i_version_tuple
41+ continue
42+ if (i_version_tuple [0 ] >= highest [0 ] and i_version_tuple [1 ] > highest [1 ]):
43+ highest = i_version_tuple
44+ continue
45+ if (i_version_tuple [0 ] >= highest [0 ] and i_version_tuple [1 ] >= highest [1 ] and i_version_tuple [2 ] >= highest [2 ]):
46+ highest = i_version_tuple
47+ continue
48+
49+ if (highest [0 ] != 0 and highest [1 ] != 0 and highest [2 ] != 0 ):
50+ print (f"v{ highest [0 ]} .{ highest [1 ]} .{ highest [2 ]} " )
51+ sys .exit (0 )
52+ else :
53+ sys .exit (- 1 )
54+
1755 version_tuple = parsed_commands .version .split ("." )
1856 if len (version_tuple ) != 3 :
1957 print ("0.0.0" ) # Error
0 commit comments