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

Commite2d5e0e

Browse files
authored
Update head.py
1 parentb833eeb commite2d5e0e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

‎git/refs/head.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fromgit.configimportSectionConstraint
1+
fromgit.configimportGitConfigParser,SectionConstraint
22
fromgit.utilimportjoin_path
33
fromgit.excimportGitCommandError
44

@@ -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.
@@ -203,7 +203,7 @@ def rename(self, new_path: PathLike, force: bool = False) -> 'Head':
203203
self.path="%s/%s"% (self._common_path_default,new_path)
204204
returnself
205205

206-
defcheckout(self,force:bool=False,**kwargs:Any):
206+
defcheckout(self,force:bool=False,**kwargs:Any)->Union['HEAD','Head']:
207207
"""Checkout this head by setting the HEAD to this reference, by updating the index
208208
to reflect the tree we point to and by updating the working tree to reflect
209209
the latest index.
@@ -235,10 +235,11 @@ def checkout(self, force: bool = False, **kwargs: Any):
235235
self.repo.git.checkout(self,**kwargs)
236236
ifself.repo.head.is_detached:
237237
returnself.repo.head
238-
returnself.repo.active_branch
238+
else:
239+
returnself.repo.active_branch
239240

240241
#{ Configuration
241-
def_config_parser(self,read_only:bool)->SectionConstraint:
242+
def_config_parser(self,read_only:bool)->SectionConstraint[GitConfigParser]:
242243
ifread_only:
243244
parser=self.repo.config_reader()
244245
else:
@@ -247,13 +248,13 @@ def _config_parser(self, read_only: bool) -> SectionConstraint:
247248

248249
returnSectionConstraint(parser,'branch "%s"'%self.name)
249250

250-
defconfig_reader(self)->SectionConstraint:
251+
defconfig_reader(self)->SectionConstraint[GitConfigParser]:
251252
"""
252253
:return: A configuration parser instance constrained to only read
253254
this instance's values"""
254255
returnself._config_parser(read_only=True)
255256

256-
defconfig_writer(self)->SectionConstraint:
257+
defconfig_writer(self)->SectionConstraint[GitConfigParser]:
257258
"""
258259
:return: A configuration writer instance with read-and write access
259260
to options of this head"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp