4
4
5
5
# typing ------------------------------------------------------------------
6
6
7
- from typing import Any ,Union ,TYPE_CHECKING
7
+ from typing import Any ,Type , Union ,TYPE_CHECKING
8
8
from git .types import Commit_ish ,PathLike
9
9
10
10
if TYPE_CHECKING :
11
11
from git .repo import Repo
12
12
from git .objects import Commit
13
13
from git .objects import TagObject
14
+ from git .refs import SymbolicReference
14
15
15
16
16
17
# ------------------------------------------------------------------------------
@@ -68,7 +69,8 @@ def object(self) -> Commit_ish: # type: ignore[override]
68
69
return Reference ._get_object (self )
69
70
70
71
@classmethod
71
- def create (cls ,repo :'Repo' ,path :PathLike ,reference :Union [Commit_ish ,str ]= 'HEAD' ,
72
+ def create (cls :Type ['TagReference' ],repo :'Repo' ,path :PathLike ,
73
+ reference :Union [str ,'SymbolicReference' ]= 'HEAD' ,
72
74
logmsg :Union [str ,None ]= None ,
73
75
force :bool = False ,** kwargs :Any )-> 'TagReference' :
74
76
"""Create a new tag reference.
@@ -78,7 +80,7 @@ def create(cls, repo: 'Repo', path: PathLike, reference: Union[Commit_ish, str]
78
80
The prefix refs/tags is implied
79
81
80
82
:param ref:
81
- A reference to theobject you want to tag.It can be a commit, tree or
83
+ A reference to theObject you want to tag.The Object can be a commit, tree or
82
84
blob.
83
85
84
86
:param logmsg:
@@ -98,7 +100,9 @@ def create(cls, repo: 'Repo', path: PathLike, reference: Union[Commit_ish, str]
98
100
Additional keyword arguments to be passed to git-tag
99
101
100
102
:return: A new TagReference"""
101
- args = (path ,reference )
103
+ if 'ref' in kwargs and kwargs ['ref' ]:
104
+ reference = kwargs ['ref' ]
105
+
102
106
if logmsg :
103
107
kwargs ['m' ]= logmsg
104
108
elif 'message' in kwargs and kwargs ['message' ]:
@@ -107,11 +111,13 @@ def create(cls, repo: 'Repo', path: PathLike, reference: Union[Commit_ish, str]
107
111
if force :
108
112
kwargs ['f' ]= True
109
113
114
+ args = (path ,reference )
115
+
110
116
repo .git .tag (* args ,** kwargs )
111
117
return TagReference (repo ,"%s/%s" % (cls ._common_path_default ,path ))
112
118
113
119
@classmethod
114
- def delete (cls ,repo :'Repo' ,* tags :'TagReference' )-> None :
120
+ def delete (cls ,repo :'Repo' ,* tags :'TagReference' )-> None :# type: ignore[override]
115
121
"""Delete the given existing tag or tags"""
116
122
repo .git .tag ("-d" ,* tags )
117
123