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

Appearance settings

Commit 6aebb73

Browse filesBrowse files
committed
Rmv submodule types
1 parent 8ef1adb commit 6aebb73
Copy full SHA for 6aebb73

2 files changed

+20-22Lines changed: 20 additions & 22 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/objects/submodule/base.py‎

Copy file name to clipboardExpand all lines: git/objects/submodule/base.py
+13-6Lines 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
def add(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
if url is not None:
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
if sm.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
return sm
395397
except KeyError:
@@ -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
raise ValueError("depth should be an integer")
440+
if clone_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
return sm
470474

471475
def update(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
if not dry_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
except KeyError:
9981005
self.binsha = self.NULL_BIN_SHA
9991006
# end
Collapse file

‎git/objects/submodule/util.py‎

Copy file name to clipboardExpand all lines: git/objects/submodule/util.py
+7-16Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,35 @@
55
import weakref
66

77

8-
# typing -----------------------------------------------------------------------
9-
10-
from typing import Any, Sequence, TYPE_CHECKING, Union
11-
12-
from git.types import PathLike
8+
from typing import Any, TYPE_CHECKING, Union
139

1410
if TYPE_CHECKING:
1511
from .base import Submodule
1612
from weakref import ReferenceType
17-
from git.repo import Repo
18-
from git.refs import Head
19-
from git import Remote
20-
from git.refs import RemoteReference
21-
2213

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

2617
#{ Utilities
2718

2819

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

3324

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

3930

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

4435

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

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.