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

Add function to add repos as submodules without clone the whole repo but only the default branch #6

Open
bicschneider opened this issue Aug 19, 2024 · 0 comments

Comments

@bicschneider
Copy link
Collaborator

bicschneider commented Aug 19, 2024

The idea is handle the clone pre to the git submodule add

submodule_path=<dir>
submodule_clone_url=<url>
submodule_relative_url=<rel_path>
git clone --depth 1 --separate-git-dir=./.git/modules/${submodule_path} ${submodule_remote_url} ${submodule_path}
git submodule add ${submodule_relative_url} ${submodule_path}

The diff looks like this afterwards

cschneider@CPHAPF22MBP6:~/airoha/sdk_airoha(master)$ git diff --cached
diff --git a/.gitmodules b/.gitmodules
index 9ff939daf..83fc68eb6 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -24,3 +24,6 @@
+[submodule "${submodule_path} "]
+       path = ${submodule_path} 
+       url = ${submodule_relative_url}
diff --git a/${submodule_path}  b/s${submodule_path} 
new file mode 160000
index 000000000..ce9bfc428
--- /dev/null
+++ b/${submodule_path} 
@@ -0,0 +1 @@
+Subproject commit ce9bfc4285653eb04188b30fb67c60eab84a3ed6

You can now go to the submodule and find the artifact to add ..
git artifact fetch-co-latest -r <pattern>

The actual commit/tag/artifact can then be added/downloaded and committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant