@@ -67,7 +67,7 @@ def list_remote_tags(self, major_version: int) -> List[Tuple[str, str]]:
6767 console .print (f"[dim]Listing remote tags for v{ major_version } .*[/dim]" )
6868
6969 cmd = [
70- "git" , "ls-remote" , "--refs" , "-- tags" ,
70+ "git" , "ls-remote" , "--tags" ,
7171 self .remote , f"refs/tags/v{ major_version } .*"
7272 ]
7373
@@ -76,11 +76,28 @@ def list_remote_tags(self, major_version: int) -> List[Tuple[str, str]]:
7676 if not result .stdout .strip ():
7777 raise GitOperationError (f"No tags found for major version { major_version } " )
7878
79- tags = []
79+ tag_commits = {}
80+
81+ # always use peeled commits for annotated tags
82+ # for annotated tags git ls-remote prints tag object hash, then actual commit hash with ^{} suffix
83+ # https://stackoverflow.com/a/25996877
8084 for line in result .stdout .strip ().split ('\n ' ):
8185 if line :
8286 commit , ref = line .split ('\t ' , 1 )
83- tags .append ((commit , ref ))
87+ if ref .endswith ('^{}' ):
88+ # This is a peeled ref - extract the tag name
89+ # always rewrite tag commits with peeled ref commits
90+ tag_name = ref [:- 3 ] # Remove '^{}'
91+ tag_commits [tag_name ] = commit
92+ else :
93+ # This is a regular tag
94+ # rewrite only if not yet exists
95+ if ref not in tag_commits :
96+ tag_commits [ref ] = commit
97+
98+ tags = []
99+ for tag_ref , commit in tag_commits .items ():
100+ tags .append ((commit , tag_ref ))
84101
85102 console .print (f"[dim]Found { len (tags )} tags[/dim]" )
86103 return tags
0 commit comments