| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -335,7 +335,7 @@ def _write_git_file_and_module_config(cls, working_tree_dir, module_abspath): | |||
| 335 | 335 | ||
| 336 | 336 | @classmethod | |
| 337 | 337 | 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 | ||
| 339 | 339 | ) -> 'Submodule': | |
| 340 | 340 | """Add a new submodule to the given repository. This will alter the index | |
| 341 | 341 | 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 | |||
| 369 | 369 | and is defined in `os.environ`, value from `os.environ` will be used. | |
| 370 | 370 | If you want to unset some variable, consider providing empty string | |
| 371 | 371 | as its value. | |
| 372 | + :param clone_multi_options: A list of Clone options. Please see ``git.repo.base.Repo.clone`` | ||
| 373 | + for details. | ||
| 372 | 374 | :return: The newly created submodule instance | |
| 373 | 375 | :note: works atomically, such that no change will be done if the repository | |
| 374 | 376 | update fails for instance""" | |
@@ -381,15 +383,15 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No | |||
| 381 | 383 | # assure we never put backslashes into the url, as some operating systems | |
| 382 | 384 | # like it ... | |
| 383 | 385 | 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) | ||
| 385 | 387 | # END assure url correctness | |
| 386 | 388 | ||
| 387 | 389 | # INSTANTIATE INTERMEDIATE SM | |
| 388 | 390 | sm = cls(repo, cls.NULL_BIN_SHA, cls.k_default_mode, path, name, url='invalid-temporary') | |
| 389 | 391 | if sm.exists(): | |
| 390 | 392 | # reretrieve submodule from tree | |
| 391 | 393 | try: | |
| 392 | - sm = repo.head.commit.tree[path] # type: ignore | ||
| 394 | + sm = repo.head.commit.tree[path] | ||
| 393 | 395 | sm._name = name | |
| 394 | 396 | return sm | |
| 395 | 397 | except KeyError: | |
@@ -435,6 +437,8 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No | |||
| 435 | 437 | kwargs['depth'] = depth | |
| 436 | 438 | else: | |
| 437 | 439 | raise ValueError("depth should be an integer") | |
| 440 | + if clone_multi_options: | ||
| 441 | + kwargs['multi_options'] = clone_multi_options | ||
| 438 | 442 | ||
| 439 | 443 | # _clone_repo(cls, repo, url, path, name, **kwargs): | |
| 440 | 444 | 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 | |||
| 469 | 473 | return sm | |
| 470 | 474 | ||
| 471 | 475 | 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): | ||
| 473 | 477 | """Update the repository of this submodule to point to the checkout | |
| 474 | 478 | we point at with the binsha of this instance. | |
| 475 | 479 | ||
@@ -500,6 +504,8 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress= | |||
| 500 | 504 | and is defined in `os.environ`, value from `os.environ` will be used. | |
| 501 | 505 | If you want to unset some variable, consider providing empty string | |
| 502 | 506 | 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. | ||
| 503 | 509 | :note: does nothing in bare repositories | |
| 504 | 510 | :note: method is definitely not atomic if recurisve is True | |
| 505 | 511 | :return: self""" | |
@@ -566,7 +572,8 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress= | |||
| 566 | 572 | progress.update(BEGIN | CLONE, 0, 1, prefix + "Cloning url '%s' to '%s' in submodule %r" % | |
| 567 | 573 | (self.url, checkout_module_abspath, self.name)) | |
| 568 | 574 | 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) | ||
| 570 | 577 | # END handle dry-run | |
| 571 | 578 | progress.update(END | CLONE, 0, 1, prefix + "Done cloning to %s" % checkout_module_abspath) | |
| 572 | 579 | ||
@@ -993,7 +1000,7 @@ def set_parent_commit(self, commit: Union[Commit_ish, None], check=True): | |||
| 993 | 1000 | # If check is False, we might see a parent-commit that doesn't even contain the submodule anymore. | |
| 994 | 1001 | # in that case, mark our sha as being NULL | |
| 995 | 1002 | try: | |
| 996 | - self.binsha = pctree[self.path].binsha # type: ignore | ||
| 1003 | + self.binsha = pctree[str(self.path)].binsha | ||
| 997 | 1004 | except KeyError: | |
| 998 | 1005 | self.binsha = self.NULL_BIN_SHA | |
| 999 | 1006 | # end | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,44 +5,35 @@ | |||
| 5 | 5 | import weakref | |
| 6 | 6 | ||
| 7 | 7 | ||
| 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 | ||
| 13 | 9 | ||
| 14 | 10 | if TYPE_CHECKING: | |
| 15 | 11 | from .base import Submodule | |
| 16 | 12 | 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 | - | ||
| 22 | 13 | ||
| 23 | 14 | __all__ = ('sm_section', 'sm_name', 'mkhead', 'find_first_remote_branch', | |
| 24 | 15 | 'SubmoduleConfigParser') | |
| 25 | 16 | ||
| 26 | 17 | #{ Utilities | |
| 27 | 18 | ||
| 28 | 19 | ||
| 29 | - def sm_section(name: str) -> str: | ||
| 20 | + def sm_section(name): | ||
| 30 | 21 | """:return: section title used in .gitmodules configuration file""" | |
| 31 | - return f'submodule {name}' | ||
| 22 | + return 'submodule "%s"' % name | ||
| 32 | 23 | ||
| 33 | 24 | ||
| 34 | - def sm_name(section: str) -> str: | ||
| 25 | + def sm_name(section): | ||
| 35 | 26 | """:return: name of the submodule as parsed from the section name""" | |
| 36 | 27 | section = section.strip() | |
| 37 | 28 | return section[11:-1] | |
| 38 | 29 | ||
| 39 | 30 | ||
| 40 | - def mkhead(repo: 'Repo', path: PathLike) -> 'Head': | ||
| 31 | + def mkhead(repo, path): | ||
| 41 | 32 | """:return: New branch/head instance""" | |
| 42 | 33 | return git.Head(repo, git.Head.to_full_path(path)) | |
| 43 | 34 | ||
| 44 | 35 | ||
| 45 | - def find_first_remote_branch(remotes: Sequence['Remote'], branch_name: str) -> 'RemoteReference': | ||
| 36 | + def find_first_remote_branch(remotes, branch_name): | ||
| 46 | 37 | """Find the remote branch matching the name of the given branch or raise InvalidGitRepositoryError""" | |
| 47 | 38 | for remote in remotes: | |
| 48 | 39 | try: | |
@@ -101,7 +92,7 @@ def flush_to_index(self) -> None: | |||
| 101 | 92 | ||
| 102 | 93 | #{ Overridden Methods | |
| 103 | 94 | def write(self) -> None: | |
| 104 | - rval: None = super(SubmoduleConfigParser, self).write() | ||
| 95 | + rval = super(SubmoduleConfigParser, self).write() | ||
| 105 | 96 | self.flush_to_index() | |
| 106 | 97 | return rval | |
| 107 | 98 | # END overridden methods | |
| Back | FazBrowse Home | New Git URL |
0 commit comments