@@ -73,6 +73,32 @@ def _latest_git_version_tag_on_branches(
7373MAX_COMMIT_DISTANCE = 999
7474
7575
76+ def _latest_git_version_tag_new (
77+ repo : git .Repo , assume_if_none : bool = False , base_commit : git .Commit = None ,
78+ commit_distance : int = 0 , skip_commits : t .Set [git .Commit ] = None ) -> t .Tuple [
79+ git .Commit , t .Optional [git .TagReference ], Version , int ]:
80+ version_tags = _git_version_tags (repo )
81+ version_tag_commits = set ()
82+ divergence_points = []
83+ if skip_commits is None :
84+ skip_commits = set ()
85+ while True :
86+ commit = None
87+ for commit in repo .iter_commits (rev = base_commit ):
88+ if commit in skip_commits :
89+ return None , None , None , - 1
90+ _LOG .log (logging .NOTSET , 'iterating over commit %s' , commit )
91+ current_version_tags = {tag : version for tag , version in version_tags .items ()
92+ if tag .commit == commit }
93+ commit_distance += 1
94+ skip_commits .add (commit )
95+ if len (commit .parents ) > 1 :
96+ divergence_points .append (commit )
97+ break
98+ base_commit = divergence_points .pop ()
99+ return commit , tag , version , commit_distance
100+
101+
76102def _latest_git_version_tag (
77103 repo : git .Repo , assume_if_none : bool = False ,
78104 base_commit : t .Optional [git .objects .Commit ] = None , commit_distance : int = 0 ,
@@ -122,6 +148,9 @@ def _latest_git_version_tag(
122148 return commit , tag , version , commit_distance
123149
124150
151+ _latest_git_version_tag = _latest_git_version_tag_new
152+
153+
125154def _upcoming_git_version_tag (repo : git .Repo , ignore_untracked_files : bool = True ) -> t .Tuple [
126155 t .Optional [git .objects .Commit ], t .Optional [git .TagReference ], t .Optional [Version ], int ,
127156 bool ]:
0 commit comments