FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Handle invalid submodule names during recursive updates by Byron · Pull Request #2205 · gitpython-developers/GitPython · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .json  (1) .py  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 0 additions & 8 deletions .basedpyright/baseline.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,6 @@
"lineCount": 1
}
},
{
"code": "reportPossiblyUnboundVariable",
"range": {
"startColumn": 15,
"endColumn": 20,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
Expand Down
7 changes: 3 additions & 4 deletions git/objects/submodule/base.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ def _validated_name(cls, name: str) -> str:

@classmethod
def _module_abspath(cls, parent_repo: "Repo", path: PathLike, name: str) -> PathLike:
name = cls._validated_name(name)
if cls._need_gitfile_submodules(parent_repo.git):
return osp.join(parent_repo.git_dir, "modules", cls._validated_name(name))
return osp.join(parent_repo.git_dir, "modules", name)
if parent_repo.working_tree_dir:
return osp.join(parent_repo.working_tree_dir, path)
raise NotADirectoryError()
Expand Down Expand Up @@ -747,9 +748,7 @@ def update(
prefix = "DRY-RUN: "
# END handle prefix

# To keep things plausible in dry-run mode.
if dry_run:
mrepo = None
mrepo = None
# END init mrepo

def fetch_remotes(module_repo: "Repo") -> None:
Expand Down
6 changes: 6 additions & 0 deletions test/test_submodule.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,10 @@ def test_update_rejects_parent_component_in_name(self, rwdir):
with pytest.raises(ValueError, match="submodule name"):
Submodule._module_abspath(clone, "module", name)

with mock.patch.object(Submodule, "_need_gitfile_submodules", return_value=False):
with pytest.raises(ValueError, match="submodule name"):
Submodule._module_abspath(clone, "module", "../module")

@with_rw_directory
@_patch_git_config("protocol.file.allow", "always")
def test_root_update_keeps_going_after_invalid_submodule_name(self, rwdir):
Expand All @@ -994,6 +998,8 @@ def test_root_update_keeps_going_after_invalid_submodule_name(self, rwdir):
assert not clone.submodule("../invalid").module_exists()
assert clone.submodule("valid").module_exists()

clone.submodule("../invalid").update(recursive=True, keep_going=True)

@with_rw_directory
@_patch_git_config("protocol.file.allow", "always")
def test_list_only_valid_submodules(self, rwdir):
Expand Down
Loading

Back | FazBrowse Home | New Git URL