10
10
import shutil
11
11
import git
12
12
import os
13
+ import sys
13
14
14
15
class TestRootProgress (RootUpdateProgress ):
15
16
"""Just prints messages, for now without checking the correctness of the states"""
@@ -25,6 +26,10 @@ class TestSubmodule(TestObjectBase):
25
26
k_subm_changed = "394ed7006ee5dc8bddfd132b64001d5dfc0ffdd3"
26
27
k_no_subm_tag = "0.1.6"
27
28
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' ))
28
33
29
34
def _do_base_tests (self , rwrepo ):
30
35
"""Perform all tests in the given repository, it may be bare or nonbare"""
@@ -41,9 +46,9 @@ def _do_base_tests(self, rwrepo):
41
46
# at a different time, there is None
42
47
assert len (Submodule .list_items (rwrepo , self .k_no_subm_tag )) == 0
43
48
44
- assert sm .path == 'git/ext/git '
49
+ assert sm .path == 'git/ext/gitdb '
45
50
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'
47
52
assert sm .branch_path == 'refs/heads/master' # the default ...
48
53
assert sm .branch_name == 'master'
49
54
assert sm .parent_commit == rwrepo .head .commit
@@ -74,13 +79,21 @@ def _do_base_tests(self, rwrepo):
74
79
if rwrepo .bare :
75
80
self .failUnlessRaises (InvalidGitRepositoryError , sm .config_writer )
76
81
else :
77
- writer = sm .config_writer ()
78
82
# 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
+
84
97
# END handle bare repo
85
98
smold .config_reader ()
86
99
@@ -176,7 +189,8 @@ def _do_base_tests(self, rwrepo):
176
189
csm_repopath = csm .path
177
190
178
191
# 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 ()
180
194
csm .config_writer ().set_value ('url' , new_csmclone_path )
181
195
assert csm .url == new_csmclone_path
182
196
@@ -248,6 +262,10 @@ def _do_base_tests(self, rwrepo):
248
262
self .failUnlessRaises (InvalidGitRepositoryError , sm .remove , dry_run = True )
249
263
sm .module ().index .reset (working_tree = True )
250
264
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
+
251
269
# this would work
252
270
assert sm .remove (dry_run = True ) is sm
253
271
assert sm .module_exists ()
0 commit comments