mateodelnorte / meta

tool for turning many repos into a meta repo. why choose many repos or a monolithic repo, when you can have both with a meta repo?
MIT License
2.05k stars 99 forks source link

Add subdirectory of remote repo #275

Closed lukaskrieger closed 3 years ago

lukaskrieger commented 3 years ago

🚀 Feature Proposal

Instead of building up a meta repository of a set of complete sets of other git repositories it would be great to be able to only select subfolders/parts of the other repos to be assembled in the meta repository.

As far as I understand this is not really possible with subtrees but maybe it could be solved by partial clones or sparse checkouts. https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository/52269934#52269934

Just close the proposal if this is not possible or if this is not the direction in which meta should be developed. If this is something you'd like to consider I am happy to contribute.

Example

Meta repository ├── file1 ├── externalSubfolders │   ├── programA <- subfolder of program repository │   ├── programC <- subfolder of program repository

Program repository ├── programA ├── programB ├── programC

Right now, to do something like this I would need a separate repository for each program (programA, programB). And with a large amount of programs that would grow hard to manage quite soon.

patrickleet commented 3 years ago

sounds interesting, though I don't have a use case for it myself at the moment.

meta works based on plugins, and ships with a few standard ones - meta-project and meta-git for example. You don't need to use these plugins though - you could make an alternative to those that allow for the project structure you imagine.

mateodelnorte commented 3 years ago

This does not fit the intention of meta. Meta exists as a tool to stitch together git repos in a way that is easier to deal with than alternatives. There would be a large amount of work turning meta into something that itself manages state outside of a git repo.

You could potentially do this now with symlinks, but it would be particular to your solution.

lukaskrieger commented 3 years ago

Just to document a working solution. The initial meta git clone <repo> is not possible and the repository needs to be set up with the commands below. After the setup, meta commands can be executed as usual.


#Here is a list of all the repositories from which subfolders are to be added to the meta repository
git clone --filter=blob:none --sparse <repo> <folder>

#Enter the respective repositories and only checkout the needed subfolders
cd <folder>
git sparse-checkout init --cone
git sparse-checkout add <subfolder>
cd -

#Add the repositories to the meta file
meta project import <folder> <repo>

#Update the entire meta project
meta git update