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