File tree 3 files changed +26
-2
lines changed
3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,11 @@ class RepositoryError(BuildEnvironmentError):
38
38
'Private repositories are not supported.' ,
39
39
)
40
40
41
- INVALID_SUBMODULES = _ ('One or more submodule URLs are not valid: {}.' ,)
41
+ INVALID_SUBMODULES = _ ('One or more submodule URLs are not valid: {}.' )
42
+ INVALID_SUBMODULES_PATH = _ (
43
+ 'One or more submodule paths are not valid. '
44
+ 'Check that all your submodules in .gitmodules are used.'
45
+ )
42
46
43
47
DUPLICATED_RESERVED_VERSIONS = _ (
44
48
'You can not have two versions with the name latest or stable.' ,
Original file line number Diff line number Diff line change @@ -189,6 +189,21 @@ def test_check_invalid_submodule_urls(self):
189
189
RepositoryError .INVALID_SUBMODULES .format (['invalid' ]),
190
190
)
191
191
192
+ def test_invalid_submodule_path (self ):
193
+ repo_path = self .project .repo
194
+ gitmodules_path = os .path .join (repo_path , '.gitmodules' )
195
+
196
+ with open (gitmodules_path , 'w+' ) as f :
197
+ content = textwrap .dedent ("""
198
+ [submodule "not-valid-path"]
199
+ path = not-valid-path
200
+ url = https://github.com/readthedocs/readthedocs.org
201
+ """ )
202
+ f .write (content )
203
+
204
+ with self .assertRaises (RepositoryError , msg = RepositoryError .INVALID_SUBMODULES_PATH ):
205
+ repo .update_submodules (self .dummy_conf )
206
+
192
207
@patch ('readthedocs.projects.models.Project.checkout_path' )
193
208
def test_fetch_clean_tags_and_branches (self , checkout_path ):
194
209
upstream_repo = self .project .repo
Original file line number Diff line number Diff line change @@ -105,7 +105,12 @@ def validate_submodules(self, config):
105
105
Returns the list of invalid submodules.
106
106
"""
107
107
repo = git .Repo (self .working_dir )
108
- submodules = {sub .path : sub for sub in repo .submodules }
108
+ try :
109
+ submodules = {sub .path : sub for sub in repo .submodules }
110
+ except InvalidGitRepositoryError :
111
+ raise RepositoryError (
112
+ RepositoryError .INVALID_SUBMODULES_PATH ,
113
+ )
109
114
110
115
for sub_path in config .submodules .exclude :
111
116
path = sub_path .rstrip ('/' )
You can’t perform that action at this time.
0 commit comments