You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Git submodules allow relative URLs which are based on the parent repo URL.
Right now this is not supported, ie. adding a submodule configuration in .gitmodules with a relative URL will fail when cloning in the add or updateSubmodule.
A sample stack trace when calling submodule.update(init=True):
GitCommandError
Cmd('git') failed due to: exit code(128)
cmdline: git clone -n --separate-git-dir=/opt/parent_project/.git/modules/submodule_project -v ../../my-company/submodule-project.git /opt/parent_project/submodule_project
stderr: 'fatal: repository '../../my-company/submodule-project.git' does not exist
'
git/cmd.py in wait at line 291
git/util.py in finalize_process at line 341
git/repo/base.py in _clone at line 880
git/repo/base.py in clone_from at line 925
git/objects/submodule/base.py in _clone_repo at line 261
git/objects/submodule/base.py in update at line 524
GitPython==2.1.1
Still present in the current revision 8f76463
File "C:\Program Files\Python36\lib\site-packages\git\repo\base.py", line 353, in submodule_update
return RootModule(self).update(*args, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\git\objects\submodule\root.py", line 339, in update
keep_going=keep_going)
File "C:\Program Files\Python36\lib\site-packages\git\objects\submodule\root.py", line 201, in update
smr.fetch(progress=progress)
File "C:\Program Files\Python36\lib\site-packages\git\remote.py", line 789, in fetch
res = self._get_fetch_info_from_stderr(proc, progress)
File "C:\Program Files\Python36\lib\site-packages\git\remote.py", line 675, in _get_fetch_info_from_stderr
proc.wait(stderr=stderr_text)
File "C:\Program Files\Python36\lib\site-packages\git\cmd.py", line 415, in wait
raise GitCommandError(self.args, status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git fetch --progress -v __new_origin__
stderr: 'fatal: '../HelperModule.git' does not appear to be a git repository
fatal: Could not read from remote repository.
We are on a Gitlab instance where relative submodule URLs are a must have:
If you are using GitLab 8.12+ and your submodule is on the same GitLab server, you must update your .gitmodules file to use relative URLs
I was able to workaround this issue by manually resolving the relative path in the .gitmodules file. If you care about the .gitmodules file retaining the relative path url, you could easily just set the original url back to the .gitmodules file after operating on the repo with gitpython.
forsminrepo.submodules:
# Calling git directly for own submodules since using relative path is not working in gitpython# see https://github.com/gitpython-developers/GitPython/issues/730ifsm.url[0:3] =='../':
repo.git.submodule('init', sm.name)
repo.git.submodule('update', sm.name)
# For external submodules we can use the update function of gitpythonelse:
sm.update()
Reacted by Sam Fuller, sp-ricard-valverde and PhilippSelenium
Activity
PhilLab commentedon Oct 8, 2018
Similar but slightly different message in our system, when calling
We are on a Gitlab instance where relative submodule URLs are a must have:
sfuller commentedon Dec 30, 2018
I was able to workaround this issue by manually resolving the relative path in the .gitmodules file. If you care about the .gitmodules file retaining the relative path url, you could easily just set the original url back to the .gitmodules file after operating on the repo with gitpython.
Bruceforce commentedon Dec 31, 2018
Another workaround I'm currently using is to use git directly as described in https://gitpython.readthedocs.io/en/stable/tutorial.html#using-git-directly
Towards handling of relative submodule paths
Relative URLs for submodules
fix updating submodules with relative urls
fix updating submodules with relative urls
fix updating submodules with relative urls