Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcc63210

Browse files
committed
Add types to refs/tag.py
1 parent2fa9fb1 commitcc63210

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

‎git/refs/tag.py‎

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
__all__= ["TagReference","Tag"]
44

5+
# typing ------------------------------------------------------------------
6+
7+
fromtypingimportAny,Union,TYPE_CHECKING
8+
fromgit.typesimportCommit_ish,PathLike
9+
10+
ifTYPE_CHECKING:
11+
fromgit.repoimportRepo
12+
fromgit.objectsimportCommit
13+
fromgit.objectsimportTagObject
14+
15+
16+
# ------------------------------------------------------------------------------
17+
518

619
classTagReference(Reference):
720

@@ -22,9 +35,9 @@ class TagReference(Reference):
2235
_common_path_default=Reference._common_path_default+"/"+_common_default
2336

2437
@property
25-
defcommit(self):
38+
defcommit(self)->'Commit':# type: ignore[override] # LazyMixin has unrelated
2639
""":return: Commit object the tag ref points to
27-
40+
2841
:raise ValueError: if the tag points to a tree or blob"""
2942
obj=self.object
3043
whileobj.type!='commit':
@@ -37,7 +50,7 @@ def commit(self):
3750
returnobj
3851

3952
@property
40-
deftag(self):
53+
deftag(self)->Union['TagObject',None]:
4154
"""
4255
:return: Tag object this tag ref points to or None in case
4356
we are a light weight tag"""
@@ -48,10 +61,16 @@ def tag(self):
4861

4962
# make object read-only
5063
# It should be reasonably hard to adjust an existing tag
51-
object=property(Reference._get_object)
64+
65+
# object = property(Reference._get_object)
66+
@property
67+
defobject(self)->Commit_ish:# type: ignore[override]
68+
returnReference._get_object(self)
5269

5370
@classmethod
54-
defcreate(cls,repo,path,ref='HEAD',message=None,force=False,**kwargs):
71+
defcreate(cls,repo:'Repo',path:PathLike,reference:Union[Commit_ish,str]='HEAD',
72+
logmsg:Union[str,None]=None,
73+
force:bool=False,**kwargs:Any)->'TagReference':
5574
"""Create a new tag reference.
5675
5776
:param path:
@@ -62,30 +81,37 @@ def create(cls, repo, path, ref='HEAD', message=None, force=False, **kwargs):
6281
A reference to the object you want to tag. It can be a commit, tree or
6382
blob.
6483
65-
:parammessage:
84+
:paramlogmsg:
6685
If not None, the message will be used in your tag object. This will also
6786
create an additional tag object that allows to obtain that information, i.e.::
6887
6988
tagref.tag.message
7089
90+
:param message:
91+
Synonym for :param logmsg:
92+
Included for backwards compatability. :param logmsg is used in preference if both given.
93+
7194
:param force:
7295
If True, to force creation of a tag even though that tag already exists.
7396
7497
:param kwargs:
7598
Additional keyword arguments to be passed to git-tag
7699
77100
:return: A new TagReference"""
78-
args= (path,ref)
79-
ifmessage:
80-
kwargs['m']=message
101+
args= (path,reference)
102+
iflogmsg:
103+
kwargs['m']=logmsg
104+
elif'message'inkwargsandkwargs['message']:
105+
kwargs['m']=kwargs['message']
106+
81107
ifforce:
82108
kwargs['f']=True
83109

84110
repo.git.tag(*args,**kwargs)
85111
returnTagReference(repo,"%s/%s"% (cls._common_path_default,path))
86112

87113
@classmethod
88-
defdelete(cls,repo,*tags):
114+
defdelete(cls,repo:'Repo',*tags:'TagReference')->None:
89115
"""Delete the given existing tag or tags"""
90116
repo.git.tag("-d",*tags)
91117

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp