Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitbbb3d00

Browse files
authored
Merge pull request#2062 from t-webber/relative_path_submodules
Allow relative path url in submodules for submodule_update
2 parents4d529b7 +1ee1e78 commitbbb3d00

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

‎git/objects/submodule/base.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
importstat
1212
importsys
1313
importuuid
14+
importurllib
1415

1516
importgit
1617
fromgit.cmdimportGit
@@ -799,9 +800,13 @@ def update(
799800
+"Cloning url '%s' to '%s' in submodule %r"% (self.url,checkout_module_abspath,self.name),
800801
)
801802
ifnotdry_run:
803+
ifself.url.startswith("."):
804+
url=urllib.parse.urljoin(self.repo.remotes.origin.url+"/",self.url)
805+
else:
806+
url=self.url
802807
mrepo=self._clone_repo(
803808
self.repo,
804-
self.url,
809+
url,
805810
self.path,
806811
self.name,
807812
n=True,

‎test/test_submodule.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,3 +1350,23 @@ def test_submodule_update_unsafe_options_allowed(self, rw_repo):
13501350
forunsafe_optioninunsafe_options:
13511351
withself.assertRaises(GitCommandError):
13521352
submodule.update(clone_multi_options=[unsafe_option],allow_unsafe_options=True)
1353+
1354+
@with_rw_directory
1355+
@_patch_git_config("protocol.file.allow","always")
1356+
deftest_submodule_update_relative_url(self,rwdir):
1357+
parent_path=osp.join(rwdir,"parent")
1358+
parent_repo=git.Repo.init(parent_path)
1359+
submodule_path=osp.join(rwdir,"module")
1360+
submodule_repo=git.Repo.init(submodule_path)
1361+
submodule_repo.git.commit(m="initial commit",allow_empty=True)
1362+
1363+
parent_repo.git.submodule("add","../module","module")
1364+
parent_repo.index.commit("add submodule with relative URL")
1365+
1366+
cloned_path=osp.join(rwdir,"cloned_repo")
1367+
cloned_repo=git.Repo.clone_from(parent_path,cloned_path)
1368+
1369+
cloned_repo.submodule_update(init=True,recursive=True)
1370+
1371+
has_module=any(sm.name=="module"forsmincloned_repo.submodules)
1372+
asserthas_module,"Relative submodule was not updated properly"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp