26
26
27
27
if TYPE_CHECKING :
28
28
from git .repo import Repo
29
+ from git .refs import Head , TagReference , Reference
29
30
30
31
T_References = TypeVar ('T_References' , bound = 'SymbolicReference' )
31
32
@@ -59,10 +60,10 @@ class SymbolicReference(object):
59
60
60
61
def __init__ (self , repo : 'Repo' , path : PathLike , check_path : bool = False ):
61
62
self .repo = repo
62
- self .path = str ( path )
63
+ self .path = path
63
64
64
65
def __str__ (self ) -> str :
65
- return self .path
66
+ return str ( self .path )
66
67
67
68
def __repr__ (self ):
68
69
return '<git.%s "%s">' % (self .__class__ .__name__ , self .path )
@@ -84,7 +85,7 @@ def name(self) -> str:
84
85
:return:
85
86
In case of symbolic references, the shortest assumable name
86
87
is the path itself."""
87
- return self .path
88
+ return str ( self .path )
88
89
89
90
@property
90
91
def abspath (self ) -> PathLike :
@@ -557,7 +558,7 @@ def create(cls, repo: 'Repo', path: PathLike, reference: Union[Commit_ish, str]
557
558
:note: This does not alter the current HEAD, index or Working Tree"""
558
559
return cls ._create (repo , path , cls ._resolve_ref_on_create , reference , force , logmsg )
559
560
560
- def rename (self , new_path , force = False ):
561
+ def rename (self , new_path : PathLike , force : bool = False ) -> 'SymbolicReference' :
561
562
"""Rename self to a new path
562
563
563
564
:param new_path:
@@ -577,7 +578,7 @@ def rename(self, new_path, force=False):
577
578
578
579
new_abs_path = os .path .join (_git_dir (self .repo , new_path ), new_path )
579
580
cur_abs_path = os .path .join (_git_dir (self .repo , self .path ), self .path )
580
- if os .path .path . isfile (new_abs_path ):
581
+ if os .path .isfile (new_abs_path ):
581
582
if not force :
582
583
# if they point to the same file, its not an error
583
584
with open (new_abs_path , 'rb' ) as fd1 :
@@ -663,7 +664,7 @@ def iter_items(cls: Type[T_References], repo: 'Repo', common_path: Union[PathLik
663
664
return (r for r in cls ._iter_items (repo , common_path ) if r .__class__ == SymbolicReference or not r .is_detached )
664
665
665
666
@classmethod
666
- def from_path (cls , repo , path ) :
667
+ def from_path (cls , repo : 'Repo' , path : PathLike ) -> Union [ 'Head' , 'TagReference' , 'Reference' ] :
667
668
"""
668
669
:param path: full .git-directory-relative path name to the Reference to instantiate
669
670
:note: use to_full_path() if you only have a partial path of a known Reference Type
0 commit comments