File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 31
31
from .enums import SubmoduleIgnore , SubmoduleStatus
32
32
from .errors import check_error
33
33
from .ffi import ffi , C
34
- from .utils import to_bytes
34
+ from .utils import to_bytes , maybe_string
35
35
36
36
# Need BaseRepository for type hints, but don't let it cause a circular dependency
37
37
if TYPE_CHECKING :
@@ -129,10 +129,10 @@ def path(self):
129
129
return ffi .string (path ).decode ('utf-8' )
130
130
131
131
@property
132
- def url (self ):
132
+ def url (self ) -> Union [ str , None ] :
133
133
"""URL of the submodule."""
134
134
url = C .git_submodule_url (self ._subm )
135
- return ffi . string (url ). decode ( 'utf-8' )
135
+ return maybe_string (url )
136
136
137
137
@property
138
138
def branch (self ):
Original file line number Diff line number Diff line change @@ -106,6 +106,15 @@ def test_url(repo):
106
106
assert SUBM_URL == s .url
107
107
108
108
109
+ def test_missing_url (repo ):
110
+ # Remove "url" from .gitmodules
111
+ with open (Path (repo .workdir , '.gitmodules' ), 'wt' ) as f :
112
+ f .write ('[submodule "TestGitRepository"]\n ' )
113
+ f .write ('\t path = TestGitRepository\n ' )
114
+ s = repo .submodules [SUBM_PATH ]
115
+ assert not s .url
116
+
117
+
109
118
@utils .requires_network
110
119
def test_init_and_update (repo ):
111
120
subrepo_file_path = Path (repo .workdir ) / SUBM_PATH / 'master.txt'
You can’t perform that action at this time.
0 commit comments