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

Commit26fc586

Browse files
committed
Verified that it apparently is impossible to add empty submodules using git-python.
This is the case with `git submodule add` as well. This makes sense asan empty git repository doesn't have a commit, which needs to be specifiedas SHA in the parent repositories tree entry for the respective submodule.When manually adding the empty submodule to the .gitmodules file, git-pythonwill throw another error related to the inability to find the submodulein the index.Even if an iteration would be possible, git-python would now throwa BadName exception, which clearly indicates that the 'HEAD' revisionis invalid (as it doesn't point to any commit).Fixesgitpython-developers#152Fixesgitpython-developers#105
1 parent508807e commit26fc586

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

‎git/test/test_submodule.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# This module is part of GitPython and is released under
22
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
3+
importshutil
4+
importsys
5+
importos
6+
7+
importgit
38

49
fromgit.test.libimport (
510
TestBase,
611
with_rw_repo
712
)
13+
fromgitdb.test.libimportwith_rw_directory
814
fromgit.excimportInvalidGitRepositoryError
915
fromgit.objects.submodule.baseimportSubmodule
1016
fromgit.objects.submodule.rootimportRootModule,RootUpdateProgress
1117
fromgit.utilimportto_native_path_linux,join_path_native
1218
fromgit.compatimportstring_types
13-
importshutil
14-
importgit
15-
importsys
16-
importos
1719

1820
fromnoseimportSkipTest
1921

@@ -597,3 +599,17 @@ def test_first_submodule(self, rwrepo):
597599
self.failUnlessRaises(ValueError,rwrepo.create_submodule,'fail',os.path.expanduser('~'))
598600
self.failUnlessRaises(ValueError,rwrepo.create_submodule,'fail-too',
599601
rwrepo.working_tree_dir+os.path.sep)
602+
603+
@with_rw_directory
604+
deftest_add_empty_repo(self,rwdir):
605+
parent_dir=os.path.join(rwdir,'parent')
606+
os.mkdir(parent_dir)
607+
empty_repo_dir=os.path.join(rwdir,'empty-repo')
608+
609+
parent=git.Repo.init(parent_dir)
610+
git.Repo.init(empty_repo_dir)
611+
612+
forcheckout_modeinrange(2):
613+
self.failUnlessRaises(ValueError,parent.create_submodule,'empty','empty',
614+
url=empty_repo_dir,no_checkout=checkout_mode)
615+
# end for each checkout mode

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp