| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dafafff commit 738e940
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -729,6 +729,7 @@ def update( | |||
| 729 | 729 | clone_multi_options: Union[Sequence[TBD], None] = None, | |
| 730 | 730 | allow_unsafe_options: bool = False, | |
| 731 | 731 | allow_unsafe_protocols: bool = False, | |
| 732 | + no_fetch: bool = False, | ||
| 732 | 733 | ) -> "Submodule": | |
| 733 | 734 | """Update the repository of this submodule to point to the checkout we point at | |
| 734 | 735 | with the binsha of this instance. | |
@@ -791,6 +792,10 @@ def update( | |||
| 791 | 792 | :param allow_unsafe_options: | |
| 792 | 793 | Allow unsafe options to be used, like ``--upload-pack``. | |
| 793 | 794 | ||
| 795 | + :param no_fetch: | ||
| 796 | + If ``True``, submodule updating will be attempted without fetching | ||
| 797 | + new changes from remotes. | ||
| 798 | + | ||
| 794 | 799 | :note: | |
| 795 | 800 | Does nothing in bare repositories. | |
| 796 | 801 | ||
@@ -853,7 +858,8 @@ def fetch_remotes(module_repo: "Repo") -> None: | |||
| 853 | 858 | ####################################### | |
| 854 | 859 | try: | |
| 855 | 860 | mrepo = self.module() | |
| 856 | - fetch_remotes(mrepo) | ||
| 861 | + if not no_fetch: | ||
| 862 | + fetch_remotes(mrepo) | ||
| 857 | 863 | except InvalidGitRepositoryError: | |
| 858 | 864 | mrepo = None | |
| 859 | 865 | if not init: | |
@@ -880,6 +886,10 @@ def fetch_remotes(module_repo: "Repo") -> None: | |||
| 880 | 886 | raise OSError( | |
| 881 | 887 | "Module directory at %r does already exist and is non-empty" % checkout_module_abspath | |
| 882 | 888 | ) | |
| 889 | + elif no_fetch: | ||
| 890 | + raise ValueError( | ||
| 891 | + "Module directory at %r is empty but fetching is disabled" % checkout_module_abspath | ||
| 892 | + ) | ||
| 883 | 893 | os.makedirs(checkout_module_abspath, exist_ok=True) | |
| 884 | 894 | self._write_git_file_and_module_config(checkout_module_abspath, module_abspath) | |
| 885 | 895 | mrepo = git.Repo(checkout_module_abspath) | |
@@ -909,6 +919,8 @@ def fetch_remotes(module_repo: "Repo") -> None: | |||
| 909 | 919 | + "Cloning url '%s' to '%s' in submodule %r" % (self.url, checkout_module_abspath, self.name), | |
| 910 | 920 | ) | |
| 911 | 921 | if not dry_run: | |
| 922 | + if no_fetch: | ||
| 923 | + raise ValueError("Missing module at %r but fetching is disabled" % self.path) from None | ||
| 912 | 924 | if self.url.startswith("."): | |
| 913 | 925 | url = urllib.parse.urljoin(self.repo.remotes.origin.url + "/", self.url) | |
| 914 | 926 | else: | |
@@ -1057,6 +1069,7 @@ def fetch_remotes(module_repo: "Repo") -> None: | |||
| 1057 | 1069 | dry_run=dry_run, | |
| 1058 | 1070 | force=force, | |
| 1059 | 1071 | keep_going=keep_going, | |
| 1072 | + no_fetch=no_fetch, | ||
| 1060 | 1073 | ) | |
| 1061 | 1074 | # END handle recursive update | |
| 1062 | 1075 | # END handle dry run | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,6 +87,7 @@ def update( # type: ignore[override] | |||
| 87 | 87 | dry_run: bool = False, | |
| 88 | 88 | force_reset: bool = False, | |
| 89 | 89 | keep_going: bool = False, | |
| 90 | + no_fetch: bool = False, | ||
| 90 | 91 | ) -> "RootModule": | |
| 91 | 92 | """Update the submodules of this repository to the current HEAD commit. | |
| 92 | 93 | ||
@@ -146,6 +147,10 @@ def update( # type: ignore[override] | |||
| 146 | 147 | In conjunction with `dry_run`, this can be useful to anticipate all errors | |
| 147 | 148 | when updating submodules. | |
| 148 | 149 | ||
| 150 | + :param no_fetch: | ||
| 151 | + If ``True``, submodule updating will be attempted without fetching | ||
| 152 | + new changes from remotes. | ||
| 153 | + | ||
| 149 | 154 | :return: | |
| 150 | 155 | self | |
| 151 | 156 | """ | |
@@ -274,7 +279,8 @@ def update( # type: ignore[override] | |||
| 274 | 279 | if not dry_run: | |
| 275 | 280 | assert nn not in [r.name for r in rmts] | |
| 276 | 281 | smr = smm.create_remote(nn, sm.url) | |
| 277 | - smr.fetch(progress=progress) | ||
| 282 | + if not no_fetch: | ||
| 283 | + smr.fetch(progress=progress) | ||
| 278 | 284 | ||
| 279 | 285 | # If we have a tracking branch, it should be available | |
| 280 | 286 | # in the new remote as well. | |
@@ -433,6 +439,7 @@ def update( # type: ignore[override] | |||
| 433 | 439 | dry_run=dry_run, | |
| 434 | 440 | force=force_reset, | |
| 435 | 441 | keep_going=keep_going, | |
| 442 | + no_fetch=no_fetch, | ||
| 436 | 443 | ) | |
| 437 | 444 | ||
| 438 | 445 | # Update recursively depth first - question is which inconsistent state will | |
| Back | FazBrowse Home | New Git URL |
0 commit comments