- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 934
Submodule from relative URL #730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Similar but slightly different message in our system, when calling
We are on a Gitlab instance where relative submodule URLs are a must have:
|
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. for submodule in repo.submodules:
# Hack around gitpython bug: https://github.com/gitpython-developers/GitPython/issues/730
if submodule.url.startswith('..'):
submodule_repo_name = submodule.url[3:] # Strip off '../'
repo_parent_url, _ = os.path.split(origin.url)
actual_url = os.path.join(repo_parent_url, submodule_repo_name)
with submodule.config_writer() as writer:
writer.set('url', actual_url)
print(f'Processing submodule {submodule.name}')
submodule.update(init=True) |
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 for sm in repo.submodules:
# Calling git directly for own submodules since using relative path is not working in gitpython
# see https://github.com/gitpython-developers/GitPython/issues/730
if sm.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 gitpython
else:
sm.update() |
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 theadd
orupdate
Submodule
.A sample stack trace when calling
submodule.update(init=True)
:GitPython==2.1.1
Still present in the current revision 8f76463
The text was updated successfully, but these errors were encountered: