@@ -12,8 +12,46 @@ def main():
12
12
required = True , help = "The version string to update" )
13
13
argument_parser .add_argument ("--type" , metavar = "<string containing PATCH, MINOR, or MAJOR>" ,
14
14
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" )
15
17
parsed_commands = argument_parser .parse_args ()
16
18
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
+
17
55
version_tuple = parsed_commands .version .split ("." )
18
56
if len (version_tuple ) != 3 :
19
57
print ("0.0.0" ) # Error
0 commit comments