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 3131from .enums import SubmoduleIgnore , SubmoduleStatus
3232from .errors import check_error
3333from .ffi import ffi , C
34- from .utils import to_bytes
34+ from .utils import to_bytes , maybe_string
3535
3636# Need BaseRepository for type hints, but don't let it cause a circular dependency
3737if TYPE_CHECKING :
@@ -129,10 +129,10 @@ def path(self):
129129 return ffi .string (path ).decode ('utf-8' )
130130
131131 @property
132- def url (self ):
132+ def url (self ) -> Union [ str , None ] :
133133 """URL of the submodule."""
134134 url = C .git_submodule_url (self ._subm )
135- return ffi . string (url ). decode ( 'utf-8' )
135+ return maybe_string (url )
136136
137137 @property
138138 def branch (self ):
Original file line number Diff line number Diff line change @@ -106,6 +106,15 @@ def test_url(repo):
106106 assert SUBM_URL == s .url
107107
108108
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+
109118@utils .requires_network
110119def test_init_and_update (repo ):
111120 subrepo_file_path = Path (repo .workdir ) / SUBM_PATH / 'master.txt'
You can’t perform that action at this time.
0 commit comments