File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -995,6 +995,28 @@ def __getattribute__(self, name: str) -> Any:
995995 _warn_use_shell (extra_danger = False )
996996 return super ().__getattribute__ (name )
997997
998+ def latest_remote_tag (self , repository : PathLike ) -> Optional [str ]:
999+ output = self .ls_remote ("--tags" , "--sort=-version:refname" , repository )
1000+ if not output :
1001+ return None
1002+
1003+ for line in output .splitlines ():
1004+ if not line :
1005+ continue
1006+ try :
1007+ _ , ref = line .split ("\t " , 1 )
1008+ except ValueError :
1009+ continue
1010+ if not ref .startswith ("refs/tags/" ):
1011+ continue
1012+ tag = ref [len ("refs/tags/" ) :]
1013+ if tag .endswith ("^{}" ):
1014+ tag = tag [:- 3 ]
1015+ if tag :
1016+ return tag
1017+
1018+ return None
1019+
9981020 def __getattr__ (self , name : str ) -> Any :
9991021 """A convenience method as it allows to call the command as if it was an object.
10001022
You can’t perform that action at this time.
0 commit comments