@@ -40,6 +40,17 @@ def _git_version_tags(repo: git.Repo) -> t.Mapping[git.Tag, Version]:
4040 return versions
4141
4242
43+ def _git_version_tag_commits (
44+ version_tags : t .Iterable [git .Tag ]) -> t .Mapping [git .objects .Commit , t .Set [git .Tag ]]:
45+ version_tag_commits : t .Dict [git .objects .Commit , t .Set [git .Tag ]] = {}
46+ for tag in version_tags :
47+ _commit = tag .commit
48+ if _commit not in version_tag_commits :
49+ version_tag_commits [_commit ] = set ()
50+ version_tag_commits [_commit ].add (tag )
51+ return version_tag_commits
52+
53+
4354def _latest_git_version_tag_on_branches (
4455 repo : git .Repo , assume_if_none : bool , commit : git .objects .Commit , commit_distance : int ,
4556 skip_commits : t .Set [git .objects .Commit ]) -> t .Union [int , t .Tuple [
@@ -80,12 +91,7 @@ def _latest_git_version_tag(
8091 t .Optional [git .objects .Commit ], t .Optional [git .TagReference ], t .Optional [Version ], int ]:
8192 """Return (commit, tag at that commit if any, latest version, distance from the version)."""
8293 version_tags = _git_version_tags (repo )
83- version_tag_commits : t .Dict [git .objects .Commit , set ] = {}
84- for tag , version in version_tags .items ():
85- _commit = tag .commit
86- if _commit not in version_tag_commits :
87- version_tag_commits [_commit ] = set ()
88- version_tag_commits [_commit ].add (tag )
94+ version_tag_commits = _git_version_tag_commits (version_tags .keys ())
8995 current_version_tags = {}
9096 commit = None
9197 if skip_commits is None :
0 commit comments