Common dependency management with source control
Show older comments
I have two relatively large projects (A and B) that share a common dependency (C). A, B and C are all in their own separate git repositories. Now I want A to use code developed in B. There are multiple ways to handle this, none of which appear to be seamless.
If I use git submodules or subtrees, then adding A and B to the MATLAB path results in two copies of C being on the path. Due to function precedence the copies of functions of C in A are always called (A comes first alphabetically on the path). If the versions of C in A and B are out of sync, this can result in unexpected behavior in B.
I could solve this by putting C in private subfolders of A and B, so the expected version is called, but then many of the files in A and B must be in the top-level folder, which is not a very well organized solution. Additionally, my code depends on a number of FEX submissions, and it would be helpful to be able to organize those into their own "lib" folder to maintain a hard boundary between that code and my own code.
Alternatively, I could forego submodules, and manually add C separately. Then there is only one copy of C on the path. However, this results in a proliferation of repositories which must be independently cloned to access the functionality of a single project, especially with the number of FEX submissions.
Finally, I could just dump everything in a single repository, but then maintaining multiple copies of the dependencies, with respect to future projects, becomes nightmarish and violates DRY (don't repeat yourself).
Am I missing a more ideal and seamless way of handling this sort of dependency problem? I have googled a number of terms I thought might result in useful information, but haven't found anything aside the four options listed above.
2 Comments
per isakson
on 23 Jul 2019
Edited: per isakson
on 23 Jul 2019
I'm trying to get my head around how to best use Matlab's git support and I've spent a couple of days reading and testing. E.g.
- Developer Zone blogs: Best Practices – Adapt, then Adopt! and Packaging Pitfalls
- Browsed and read bits of Git tutorial and manual. (The git command line is scary - I'm used to TortoiseHg.)
- Googled "git subtree submodule" and read some blogs.
Comments so far
- The Developer Zone blogs don't discuss the problem of dependencies.
- There is no "ideal and seamless way of handling this sort of dependency problem", neither in Matlab nor elsewhere.
- More context is needed to choose an approach. Single developer or a group. ...
"A, B and C are all in their own separate git repositories." fine, but what is the meaning of "the versions of C in A and B"? Is C a subtree or submodule of A and B, respectively? Why?
When working on A, is it likely that you will modify code in B and C? In my case that is likely.
William Warriner
on 23 Jul 2019
Answers (0)
Categories
Find more on Source Control in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!