Skip to content
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

When using templates, submodules do not get "inherited" #10316

Closed
1 of 3 tasks
HanEmile opened this issue Feb 17, 2020 · 19 comments · Fixed by #16237
Closed
1 of 3 tasks

When using templates, submodules do not get "inherited" #10316

HanEmile opened this issue Feb 17, 2020 · 19 comments · Fixed by #16237
Labels
type/enhancement An improvement of existing functionality

Comments

@HanEmile
Copy link

  • Gitea version (or commit ref): 1.11.1
  • Git version: 2.23.1
  • Operating system: NixOS
  • Database: shouldn't matter, if so, please write
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (POC can be found here)
    • No
    • Not relevant

Description

So I tried out the new template feature and found out, that when using templates, submodules do not get "inherited".

Reproduction

  1. Create a repo A that should be used as a template
  2. Mark the repo A as a template in the repos settings
  3. Create a repo B using the repo A as a submodule: git submodule add <repo A>
  4. Create a repo C using B as a template. My result is that C does not contains the submodule A.
@davidsvantesson
Copy link
Contributor

davidsvantesson commented Feb 17, 2020

Seems it has to be restored from .gitmodules. For example like this:
https://gist.github.com/aroemen/5027030

@stale
Copy link

stale bot commented Apr 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale stale bot added the issue/stale label Apr 17, 2020
@davidsvantesson
Copy link
Contributor

I think this is something that can be fixed. GitHub doesn't handle it so should maybe be an option.

@stale stale bot removed the issue/stale label Apr 22, 2020
@davidsvantesson
Copy link
Contributor

Something to notice is that the ".gitmodules" file does not contain information about which commit is currently checked out, only the repo path and url. So if re-initalizing submodules from the ".gitmodules" file, every submodule will be added with "HEAD" checked out in the parent repo.
This is probably not what you want. If the new repo should look same as the latest commit of the template repo, you need to checkout each submodule repo to the same commit.

So somthing like this would be needed:

  • Run git submodule status in the template repo to get all submodules (paths) and their checked out commit.
  • Clone template repo without submodules and remove .git folder (as today)
    Then for each submodule:
  • To get submodule url run: git config -f .gitmodules --get "submodule.<submodule path>.url"
  • Remove submodule folder: rmdir <submodule path>
  • Run git submodule add <submodule url> <submodule path>
  • Got to submodule: cd <submodule path>
  • and change checked out commit: git checkout <submodule commit>
  • All submodules with correct commit will be added when running git add --all

@lunny lunny added the type/enhancement An improvement of existing functionality label Jul 7, 2020
@lunny
Copy link
Member

lunny commented Jul 7, 2020

related with #9126

@stale
Copy link

stale bot commented Sep 5, 2020

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale stale bot added the issue/stale label Sep 5, 2020
@stale
Copy link

stale bot commented Sep 20, 2020

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale stale bot closed this as completed Sep 20, 2020
@6543 6543 reopened this Sep 20, 2020
@stale stale bot removed the issue/stale label Sep 20, 2020
@6543
Copy link
Member

6543 commented Sep 20, 2020

status?

@davidsvantesson
Copy link
Contributor

I know more what's needs to be done now, but I think it is some work to do it. I have been and will be quite busy so I might not have time to look at it the nearest months.

@CakePost
Copy link

Still running into this issue on the latest release. Was there a reason that #16237 was closed and not merged? Looks like it was supposed to fix this problem.

@luna215
Copy link

luna215 commented Aug 4, 2023

After I create a repo using a template repo that contains modules, running this commands helps me pull them:

git submodule update --init submodule/location

@Nigh
Copy link

Nigh commented Mar 6, 2024

Version 1.21.7, Still troubled by this issue.
Since this problem resolved on GitHub as early as Oct 8 2020.

https://github.com/orgs/community/discussions/22244

@didim99
Copy link

didim99 commented Jul 11, 2024

This issue still actual, maybe someone of maintainers consider to look at related PR #16237, please!

@StarP0ny

This comment was marked as duplicate.

@Baragalio
Copy link

This issue still actual, fix please.

@lunny
Copy link
Member

lunny commented Oct 11, 2024

We need to check whether all submodules are also template repositories and do recursive replacements. That means if a template repository includes a template repository submodule which includes a template submodule or maybe the 3 submodule can become a circle.

@geerligs
Copy link

geerligs commented Dec 3, 2024

I just ran into this issue.

My fix for now is to fork a repo instead of using the template mechanism. But I'd like to use the template feature.
One important advantage of using a a template is that not entire history is copied, but commit on branch is mentioned as "Initial commit"

@traffel
Copy link

traffel commented Dec 4, 2024

Hi,

We have encountered this issue and hope it will be resolved soon. Unfortunately, using forks is not a suitable workaround for us.

Thank you for your attention to this matter.

@Nigh
Copy link

Nigh commented Dec 5, 2024

We need to check whether all submodules are also template repositories and do recursive replacements. That means if a template repository includes a template repository submodule which includes a template submodule or maybe the 3 submodule can become a circle.

Since this problem resolved on GitHub as early as Oct 8 2020. Therefore, this case should not be an unsolvable problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.