1010import shutil
1111import git
1212import os
13+ import sys
1314
1415class TestRootProgress (RootUpdateProgress ):
1516 """Just prints messages, for now without checking the correctness of the states"""
@@ -25,6 +26,10 @@ class TestSubmodule(TestObjectBase):
2526 k_subm_changed = "394ed7006ee5dc8bddfd132b64001d5dfc0ffdd3"
2627 k_no_subm_tag = "0.1.6"
2728
29+ env_gitdb_local_path = "GITPYTHON_TEST_GITDB_LOCAL_PATH"
30+
31+ def _generate_async_local_path (self ):
32+ return to_native_path_linux (join_path_native (self .rorepo .working_tree_dir , 'git/ext/async' ))
2833
2934 def _do_base_tests (self , rwrepo ):
3035 """Perform all tests in the given repository, it may be bare or nonbare"""
@@ -41,9 +46,9 @@ def _do_base_tests(self, rwrepo):
4146 # at a different time, there is None
4247 assert len (Submodule .list_items (rwrepo , self .k_no_subm_tag )) == 0
4348
44- assert sm .path == 'git/ext/git '
49+ assert sm .path == 'git/ext/gitdb '
4550 assert sm .path != sm .name # in our case, we have ids there, which don't equal the path
46- assert sm .url == 'git://github.com/gitpython-developers/git .git'
51+ assert sm .url == 'git://github.com/gitpython-developers/gitdb .git'
4752 assert sm .branch_path == 'refs/heads/master' # the default ...
4853 assert sm .branch_name == 'master'
4954 assert sm .parent_commit == rwrepo .head .commit
@@ -74,13 +79,21 @@ def _do_base_tests(self, rwrepo):
7479 if rwrepo .bare :
7580 self .failUnlessRaises (InvalidGitRepositoryError , sm .config_writer )
7681 else :
77- writer = sm .config_writer ()
7882 # for faster checkout, set the url to the local path
79- new_smclone_path = to_native_path_linux (join_path_native (self .rorepo .working_tree_dir , sm .path ))
80- writer .set_value ('url' , new_smclone_path )
81- del (writer )
82- assert sm .config_reader ().get_value ('url' ) == new_smclone_path
83- assert sm .url == new_smclone_path
83+ # Note: This is nice but doesn't work anymore with the latest git-python
84+ # version. This would also mean we need internet for this to work which
85+ # is why we allow an override using an environment variable
86+ new_smclone_path = os .environ .get (self .env_gitdb_local_path )
87+ if new_smclone_path is not None :
88+ writer = sm .config_writer ()
89+ writer .set_value ('url' , new_smclone_path )
90+ del (writer )
91+ assert sm .config_reader ().get_value ('url' ) == new_smclone_path
92+ assert sm .url == new_smclone_path
93+ else :
94+ sys .stderr .write ("Submodule tests need the gitdb repository. You can specify a local source setting the %s environment variable. Otherwise it will be downloaded from the internet" % self .env_gitdb_local_path )
95+ #END handle submodule path
96+
8497 # END handle bare repo
8598 smold .config_reader ()
8699
@@ -176,7 +189,8 @@ def _do_base_tests(self, rwrepo):
176189 csm_repopath = csm .path
177190
178191 # adjust the path of the submodules module to point to the local destination
179- new_csmclone_path = to_native_path_linux (join_path_native (self .rorepo .working_tree_dir , sm .path , csm .path ))
192+ # In the current gitpython version, async is used directly by gitpython
193+ new_csmclone_path = self ._generate_async_local_path ()
180194 csm .config_writer ().set_value ('url' , new_csmclone_path )
181195 assert csm .url == new_csmclone_path
182196
@@ -248,6 +262,10 @@ def _do_base_tests(self, rwrepo):
248262 self .failUnlessRaises (InvalidGitRepositoryError , sm .remove , dry_run = True )
249263 sm .module ().index .reset (working_tree = True )
250264
265+ # make sure sub-submodule is not modified by forcing it to update
266+ # to the revision it is supposed to point to.
267+ csm .update ()
268+
251269 # this would work
252270 assert sm .remove (dry_run = True ) is sm
253271 assert sm .module_exists ()
0 commit comments