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

Commit28fdd30

Browse files
committed
Fix SymbolicReference reference typing
1 parent77a7769 commit28fdd30

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

‎git/refs/head.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def delete(cls, repo: 'Repo', *heads: 'Head', **kwargs: Any):
142142
flag="-D"
143143
repo.git.branch(flag,*heads)
144144

145-
defset_tracking_branch(self,remote_reference:'RemoteReference')->'Head':
145+
defset_tracking_branch(self,remote_reference:Union['RemoteReference',None])->'Head':
146146
"""
147147
Configure this branch to track the given remote reference. This will alter
148148
this branch's configuration accordingly.

‎git/refs/symbolic.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
ifTYPE_CHECKING:
3030
fromgit.repoimportRepo
31+
fromgit.refsimportReference
3132

3233
T_References=TypeVar('T_References',bound='SymbolicReference')
3334

@@ -356,8 +357,9 @@ def set_reference(self, ref, logmsg=None):
356357
returnself
357358

358359
# aliased reference
359-
reference=property(_get_reference,set_reference,doc="Returns the Reference we point to")
360-
ref:Union[Commit_ish]=reference# type: ignore # Union[str, Commit_ish, SymbolicReference]
360+
reference:Union[Commit_ish,'Reference']=property(# type: ignore
361+
_get_reference,set_reference,doc="Returns the Reference we point to")
362+
ref=reference
361363

362364
defis_valid(self):
363365
"""

‎git/repo/base.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def _to_full_tag_path(path):
422422

423423
defcreate_head(self,path:PathLike,commit:str='HEAD',
424424
force:bool=False,logmsg:Optional[str]=None
425-
)->'SymbolicReference':
425+
)->'Head':
426426
"""Create a new head within the repository.
427427
For more documentation, please see the Head.create method.
428428
@@ -788,9 +788,8 @@ def ignored(self, *paths: PathLike) -> List[PathLike]:
788788
returnproc.replace("\\\\","\\").replace('"',"").split("\n")
789789

790790
@property
791-
defactive_branch(self)->'SymbolicReference':
791+
defactive_branch(self)->'HEAD':
792792
"""The name of the currently active branch.
793-
794793
:return: Head to the active branch"""
795794
returnself.head.reference
796795

‎test/test_refs.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

7+
fromgit.repo.baseimportRepo
78
fromitertoolsimportchain
89

910
fromgitimport (
@@ -125,11 +126,15 @@ def test_heads(self, rwrepo):
125126
gp_tracking_branch=rwrepo.create_head('gp_tracking#123')
126127
special_name_remote_ref=rwrepo.remotes[0].refs[special_name]# get correct type
127128
gp_tracking_branch.set_tracking_branch(special_name_remote_ref)
128-
assertgp_tracking_branch.tracking_branch().path==special_name_remote_ref.path
129+
TBranch=gp_tracking_branch.tracking_branch()
130+
ifTBranchisnotNone:
131+
assertTBranch.path==special_name_remote_ref.path
129132

130133
git_tracking_branch=rwrepo.create_head('git_tracking#123')
131134
rwrepo.git.branch('-u',special_name_remote_ref.name,git_tracking_branch.name)
132-
assertgit_tracking_branch.tracking_branch().name==special_name_remote_ref.name
135+
TBranch=gp_tracking_branch.tracking_branch()
136+
ifTBranchisnotNone:
137+
assertTBranch.name==special_name_remote_ref.name
133138
# END for each head
134139

135140
# verify REFLOG gets altered

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp