@@ -377,7 +377,6 @@ def build(self, repo):
377377 except errors .UnrecognizedBranchPattern :
378378 continue
379379 self ._add_branch (branch )
380-
381380 self .finalize ()
382381
383382 @property
@@ -858,7 +857,6 @@ def build(self, repo, dst_branch=None):
858857 self ._cascade = OrderedDict (
859858 sorted (self ._cascade .items (), key = cmp_to_key (compare_branches ))
860859 )
861-
862860 self ._update_major_versions ()
863861 if dst_branch :
864862 self .finalize (dst_branch )
@@ -979,6 +977,7 @@ def update_versions(self, tag):
979977 if dev_branch :
980978 # Only update if tag matches X.Y
981979 # And is not a three-digit dev branch
980+
982981 if dev_branch .major == major and dev_branch .minor == minor :
983982 # Exclude tags whose micro is already
984983 # A three-digit dev branch for this X.Y
@@ -989,7 +988,6 @@ def update_versions(self, tag):
989988
990989 three_digit_micros = set (k [2 ] for k in three_digit_keys )
991990 next_micro = micro + 1
992-
993991 while next_micro in three_digit_micros :
994992 next_micro += 1
995993 if (not hasattr (dev_branch , '_next_micro' ) or
@@ -1042,21 +1040,37 @@ def _update_major_versions(self):
10421040 """
10431041 for version_tuple , branch_set in self ._cascade .items ():
10441042 # Only process major-only branches (tuples where minor is None)
1045- if len (version_tuple ) < 2 or version_tuple [ 1 ] is not None :
1043+ if len (version_tuple ) < 2 :
10461044 continue
1047- major_branch : DevelopmentBranch = branch_set [DevelopmentBranch ]
1048- major = version_tuple [0 ]
1049-
1050- # Find all minor versions for this major
1051- minors = [
1052- version_tuple [1 ] for version_tuple in self ._cascade .keys ()
1053- if (len (version_tuple ) >= 2 and
1054- version_tuple [0 ] == major and
1055- version_tuple [1 ] is not None )
1056- ]
1057- minors .append (major_branch .latest_minor )
1058-
1059- major_branch .latest_minor = max (minors )
1045+ if len (version_tuple ) == 2 and version_tuple [1 ] is None :
1046+ major_branch : DevelopmentBranch = branch_set [DevelopmentBranch ]
1047+ major = version_tuple [0 ]
1048+
1049+ # Find all minor versions for this major
1050+ minors = [
1051+ version_tuple [1 ] for version_tuple in self ._cascade .keys ()
1052+ if (len (version_tuple ) >= 2 and
1053+ version_tuple [0 ] == major and
1054+ version_tuple [1 ] is not None )
1055+ ]
1056+ minors .append (major_branch .latest_minor )
1057+
1058+ major_branch .latest_minor = max (minors )
1059+ elif len (version_tuple ) == 2 and version_tuple [1 ] is not None :
1060+ minor_branch : DevelopmentBranch = branch_set [DevelopmentBranch ]
1061+ minor = version_tuple [1 ]
1062+ major = version_tuple [0 ]
1063+
1064+ # Find all micros versions for this minor
1065+ micros = [
1066+ version_tuple [2 ] for version_tuple in self ._cascade .keys ()
1067+ if (len (version_tuple ) >= 3 and
1068+ version_tuple [0 ] == major and
1069+ version_tuple [1 ] == minor and
1070+ version_tuple [2 ] is not None )
1071+ ]
1072+ if micros :
1073+ minor_branch .latest_micro = max (micros )
10601074
10611075 def _set_target_versions (self , dst_branch ):
10621076 """Compute list of expected Jira FixVersion/s.
@@ -1091,7 +1105,10 @@ def _set_target_versions(self, dst_branch):
10911105 self .target_versions .append (version_current )
10921106 next_micro = dev_branch .micro
10931107 else :
1094- next_micro = 0
1108+ if hasattr (dev_branch , 'latest_micro' ):
1109+ next_micro = dev_branch .latest_micro + 1
1110+ else :
1111+ next_micro = 0
10951112 version_str = '%d.%d.%d' % (
10961113 dev_branch .major , dev_branch .minor , next_micro
10971114 )
0 commit comments