Problem with submodule in project template
Hello, I’m using gitlab.com and I have the following group/repository structure:
org
+ projects
+ project-1
- project-1-repo-a
- project-1-repo-b
+ templates
- project-repo-template
+ template-submodules
- project-repo-lib
I’m using GitLab CI, templates and submodules. So in the .gitmodules
file in project-repo-template
I put a relative URL for a submodule (as suggested by gitlab docs):
[submodule "lib"]
path = lib
url = ../template-submodules/project-repo-lib.git
The problem is that when I use the template to create a new repository (e.g., project-1-repo-c
), the relative URL is incorrect and should be ../../../templates/template-submodules/project-repo-lib.git
.
Maybe one solution could be changing group structure to have same level between templates and projects. E.g. adding another group under templates (org/templates/templates/...
) to match the projects 3 levels. This does not seem to scale to other templates for projects organized in different groups structure and just feels unnatural.
What is the best way to organize this structure so that the relative URLs work correctly and the CI/CD pipelines can be run on all repositories?