-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Inherit submodules from template repository content #16237
Conversation
Signed-off-by: Steffen Schröter <steffen@vexar.de>
@sschroe If you dont force-push and not swash, it's simpler to review and see made changes ... ... wills will be squash-merged if accepted anyways |
Signed-off-by: Steffen Schröter <steffen@vexar.de>
Codecov Report
@@ Coverage Diff @@
## main #16237 +/- ##
=======================================
Coverage ? 47.42%
=======================================
Files ? 951
Lines ? 132431
Branches ? 0
=======================================
Hits ? 62801
Misses ? 62071
Partials ? 7559
Continue to review full report at Codecov.
|
@6543 all changes should be implemented so far. Just for the pipelines i need a little more info, is it enough to change the command to use |
Signed-off-by: Steffen Schröter <steffen@vexar.de>
Signed-off-by: Steffen Schröter <steffen@vexar.de>
Signed-off-by: Steffen Schröter <steffen@vexar.de>
Any other input or changes needed here to proceed? |
Maybe we could get it in Jan 1 2025 |
* giteaofficial/main: [skip ci] Updated translations via Crowdin unset XDG_HOME_CONFIG as gitea manages configuration locations (go-gitea#33067) Refactor repo-new.ts (go-gitea#33070) Refactor pull-request compare&create page (go-gitea#33071) feat: link to nuget dependencies (go-gitea#26554) Remove some unnecessary template helpers (go-gitea#33069) Inherit submodules from template repository content (go-gitea#16237) [skip ci] Updated translations via Crowdin feat(action): issue change title notifications (go-gitea#33050) Use project's redirect url instead of composing url (go-gitea#33058) Fix unittest and repo create bug (go-gitea#33061) Fix locale type (go-gitea#33059) Refactor maven package registry (go-gitea#33049) Optimize the installation page (go-gitea#32994) [Feature] Private README.md for organization (go-gitea#32872) Make issue suggestion work for new PR page (go-gitea#33035) Add IntelliJ Gateway's .uuid to gitignore (go-gitea#33052)
This PR addresses issue #10316 and makes submodules available in repositories created from templates.
Submodules are now inherited when creating a new repository from a template with "Git Content" checked,
Unlike the initial suggestion provided by @davidsvantesson in the original issue i decided not to use
git submodule status
initially because its output can look like this:Submodule names can contain all sorts of special characters and the
(heads/master)
part is not always present in the output which makes reliably parsing the name out of this quite a pain if not impossible. I replaced this step withgit config -f .gitmodules --list --name-only
which will give:This is far easier to parse and provides the necessary submodule name.
git submodule status lib (no%_()delay)1
is then used as second step to get the commit hash which is now easily parsed as well as there is only a single line of output.These steps happen in the
getSubmodules
function and are the largest part of the change. This function does not throw any errors but will just skip broken submodules so that a template with a malformed .gitmodules file can still be used.To re add the submodules i use
git update-index --add --cacheinfo 160000 0dff7e5493898954537202c0c975f7b1c55d0845 lib (no%_()delay)1
instead of the regulargit submodule add ...
. Updating the index directly skips cloning the submodule which is far faster and entirely avoids the problem of users adding excessively large submodules to possibly DoS attack the Gitea server. It also avoids the issue where a submodule repository might not be accessible by the Gitea server due to authentication/permissions or other reasons such as absolute local file paths being used.