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

Commit6aebb73

Browse files
committed
Rmv submodule types
1 parent8ef1adb commit6aebb73

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

‎git/objects/submodule/base.py‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def _write_git_file_and_module_config(cls, working_tree_dir, module_abspath):
335335

336336
@classmethod
337337
defadd(cls,repo:'Repo',name:str,path:PathLike,url:Union[str,None]=None,
338-
branch=None,no_checkout:bool=False,depth=None,env=None
338+
branch=None,no_checkout:bool=False,depth=None,env=None,clone_multi_options=None
339339
)->'Submodule':
340340
"""Add a new submodule to the given repository. This will alter the index
341341
as well as the .gitmodules file, but will not create a new commit.
@@ -369,6 +369,8 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No
369369
and is defined in `os.environ`, value from `os.environ` will be used.
370370
If you want to unset some variable, consider providing empty string
371371
as its value.
372+
:param clone_multi_options: A list of Clone options. Please see ``git.repo.base.Repo.clone``
373+
for details.
372374
:return: The newly created submodule instance
373375
:note: works atomically, such that no change will be done if the repository
374376
update fails for instance"""
@@ -381,15 +383,15 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No
381383
# assure we never put backslashes into the url, as some operating systems
382384
# like it ...
383385
ifurlisnotNone:
384-
url=to_native_path_linux(url)# to_native_path_linux does nothing??
386+
url=to_native_path_linux(url)
385387
# END assure url correctness
386388

387389
# INSTANTIATE INTERMEDIATE SM
388390
sm=cls(repo,cls.NULL_BIN_SHA,cls.k_default_mode,path,name,url='invalid-temporary')
389391
ifsm.exists():
390392
# reretrieve submodule from tree
391393
try:
392-
sm=repo.head.commit.tree[path]# type: ignore
394+
sm=repo.head.commit.tree[path]
393395
sm._name=name
394396
returnsm
395397
exceptKeyError:
@@ -435,6 +437,8 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No
435437
kwargs['depth']=depth
436438
else:
437439
raiseValueError("depth should be an integer")
440+
ifclone_multi_options:
441+
kwargs['multi_options']=clone_multi_options
438442

439443
# _clone_repo(cls, repo, url, path, name, **kwargs):
440444
mrepo=cls._clone_repo(repo,url,path,name,env=env,**kwargs)
@@ -469,7 +473,7 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No
469473
returnsm
470474

471475
defupdate(self,recursive=False,init=True,to_latest_revision=False,progress=None,dry_run=False,
472-
force=False,keep_going=False,env=None):
476+
force=False,keep_going=False,env=None,clone_multi_options=None):
473477
"""Update the repository of this submodule to point to the checkout
474478
we point at with the binsha of this instance.
475479
@@ -500,6 +504,8 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
500504
and is defined in `os.environ`, value from `os.environ` will be used.
501505
If you want to unset some variable, consider providing empty string
502506
as its value.
507+
:param clone_multi_options: list of Clone options. Please see ``git.repo.base.Repo.clone``
508+
for details. Only take effect with `init` option.
503509
:note: does nothing in bare repositories
504510
:note: method is definitely not atomic if recurisve is True
505511
:return: self"""
@@ -566,7 +572,8 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
566572
progress.update(BEGIN|CLONE,0,1,prefix+"Cloning url '%s' to '%s' in submodule %r"%
567573
(self.url,checkout_module_abspath,self.name))
568574
ifnotdry_run:
569-
mrepo=self._clone_repo(self.repo,self.url,self.path,self.name,n=True,env=env)
575+
mrepo=self._clone_repo(self.repo,self.url,self.path,self.name,n=True,env=env,
576+
multi_options=clone_multi_options)
570577
# END handle dry-run
571578
progress.update(END|CLONE,0,1,prefix+"Done cloning to %s"%checkout_module_abspath)
572579

@@ -993,7 +1000,7 @@ def set_parent_commit(self, commit: Union[Commit_ish, None], check=True):
9931000
# If check is False, we might see a parent-commit that doesn't even contain the submodule anymore.
9941001
# in that case, mark our sha as being NULL
9951002
try:
996-
self.binsha=pctree[self.path].binsha# type: ignore
1003+
self.binsha=pctree[str(self.path)].binsha
9971004
exceptKeyError:
9981005
self.binsha=self.NULL_BIN_SHA
9991006
# end

‎git/objects/submodule/util.py‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,35 @@
55
importweakref
66

77

8-
# typing -----------------------------------------------------------------------
9-
10-
fromtypingimportAny,Sequence,TYPE_CHECKING,Union
11-
12-
fromgit.typesimportPathLike
8+
fromtypingimportAny,TYPE_CHECKING,Union
139

1410
ifTYPE_CHECKING:
1511
from .baseimportSubmodule
1612
fromweakrefimportReferenceType
17-
fromgit.repoimportRepo
18-
fromgit.refsimportHead
19-
fromgitimportRemote
20-
fromgit.refsimportRemoteReference
21-
2213

2314
__all__= ('sm_section','sm_name','mkhead','find_first_remote_branch',
2415
'SubmoduleConfigParser')
2516

2617
#{ Utilities
2718

2819

29-
defsm_section(name:str)->str:
20+
defsm_section(name):
3021
""":return: section title used in .gitmodules configuration file"""
31-
returnf'submodule{name}'
22+
return'submodule"%s"'%name
3223

3324

34-
defsm_name(section:str)->str:
25+
defsm_name(section):
3526
""":return: name of the submodule as parsed from the section name"""
3627
section=section.strip()
3728
returnsection[11:-1]
3829

3930

40-
defmkhead(repo:'Repo',path:PathLike)->'Head':
31+
defmkhead(repo,path):
4132
""":return: New branch/head instance"""
4233
returngit.Head(repo,git.Head.to_full_path(path))
4334

4435

45-
deffind_first_remote_branch(remotes:Sequence['Remote'],branch_name:str)->'RemoteReference':
36+
deffind_first_remote_branch(remotes,branch_name):
4637
"""Find the remote branch matching the name of the given branch or raise InvalidGitRepositoryError"""
4738
forremoteinremotes:
4839
try:
@@ -101,7 +92,7 @@ def flush_to_index(self) -> None:
10192

10293
#{ Overridden Methods
10394
defwrite(self)->None:
104-
rval:None=super(SubmoduleConfigParser,self).write()
95+
rval=super(SubmoduleConfigParser,self).write()
10596
self.flush_to_index()
10697
returnrval
10798
# END overridden methods

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp