diff options
-rw-r--r-- | git/objects/submodule/base.py | 4 | ||||
-rw-r--r-- | git/objects/submodule/root.py | 34 |
2 files changed, 12 insertions, 26 deletions
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index ca408338..76769cad 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -1015,7 +1015,7 @@ class Submodule(IndexObject, TraversableIterableObj): # If check is False, we might see a parent-commit that doesn't even contain the submodule anymore. # in that case, mark our sha as being NULL try: - self.binsha = pctree[self.path].binsha # type: ignore # str()? + self.binsha = pctree[str(self.path)].binsha except KeyError: self.binsha = self.NULL_BIN_SHA # end @@ -1080,7 +1080,7 @@ class Submodule(IndexObject, TraversableIterableObj): destination_module_abspath = self._module_abspath(self.repo, self.path, new_name) source_dir = mod.git_dir # Let's be sure the submodule name is not so obviously tied to a directory - if destination_module_abspath.startswith(str(mod.git_dir)): # type: ignore # str()? + if str(destination_module_abspath).startswith(str(mod.git_dir)): tmp_dir = self._module_abspath(self.repo, self.path, str(uuid.uuid4())) os.renames(source_dir, tmp_dir) source_dir = tmp_dir diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py index bcac5419..0af48710 100644 --- a/git/objects/submodule/root.py +++ b/git/objects/submodule/root.py @@ -10,18 +10,6 @@ import git import logging -# typing ------------------------------------------------------------------- - -from typing import TYPE_CHECKING, Union - -from git.types import Commit_ish - -if TYPE_CHECKING: - from git.repo import Repo - from git.util import IterableList - -# ---------------------------------------------------------------------------- - __all__ = ["RootModule", "RootUpdateProgress"] log = logging.getLogger('git.objects.submodule.root') @@ -54,7 +42,7 @@ class RootModule(Submodule): k_root_name = '__ROOT__' - def __init__(self, repo: 'Repo'): + def __init__(self, repo): # repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None) super(RootModule, self).__init__( repo, @@ -67,17 +55,15 @@ class RootModule(Submodule): branch_path=git.Head.to_full_path(self.k_head_default) ) - def _clear_cache(self) -> None: + def _clear_cache(self): """May not do anything""" pass #{ Interface - def update(self, previous_commit: Union[Commit_ish, None] = None, # type: ignore[override] - recursive: bool = True, force_remove: bool = False, init: bool = True, - to_latest_revision: bool = False, progress: Union[None, 'RootUpdateProgress'] = None, - dry_run: bool = False, force_reset: bool = False, keep_going: bool = False - ) -> 'RootModule': + def update(self, previous_commit=None, recursive=True, force_remove=False, init=True, + to_latest_revision=False, progress=None, dry_run=False, force_reset=False, + keep_going=False): """Update the submodules of this repository to the current HEAD commit. This method behaves smartly by determining changes of the path of a submodules repository, next to changes to the to-be-checked-out commit or the branch to be @@ -142,8 +128,8 @@ class RootModule(Submodule): previous_commit = repo.commit(previous_commit) # obtain commit object # END handle previous commit - psms: 'IterableList[Submodule]' = self.list_items(repo, parent_commit=previous_commit) - sms: 'IterableList[Submodule]' = self.list_items(repo) + psms = self.list_items(repo, parent_commit=previous_commit) + sms = self.list_items(repo) spsms = set(psms) ssms = set(sms) @@ -176,8 +162,8 @@ class RootModule(Submodule): csms = (spsms & ssms) len_csms = len(csms) for i, csm in enumerate(csms): - psm: 'Submodule' = psms[csm.name] - sm: 'Submodule' = sms[csm.name] + psm = psms[csm.name] + sm = sms[csm.name] # PATH CHANGES ############## @@ -357,7 +343,7 @@ class RootModule(Submodule): return self - def module(self) -> 'Repo': + def module(self): """:return: the actual repository containing the submodules""" return self.repo #} END interface |