10

I have a rather big project with lots of dependencies. The project is stored in a git repository and the dependencies are stored in dedicated git repositories linked as submodules. The dependencies can have further dependencies (again, using git submodules).

This works well. However, if two dependencies required both a third dependency I run into trouble on updates.

A dependency graph looks like this:

[Main Repo]
  |
  |-- [ModuleA]
  |       |
  |       \-- [ModuleC]
  |
  \-- [ModuleB]
          |
          \-- [ModuleC]

Right now I update the submodule pointer in ModuleA and ModuleB. This way both modules remain self contained. However, this is a lot of work.

How is this problem usually solved in bigger projects? I am looking for best practices to approach this kind of problem.

Thanks!

Lars Schneider
  • 5,530
  • 4
  • 33
  • 58
  • I explicitly want to ensure ModuleC is always the same wherever it is used in my project (I know the submodules mechanism allows to checkout different versions). – Lars Schneider Nov 21 '13 at 11:09

2 Answers2

1

In bigger project, what you want is keep all your dependencies on one level.

That doesn't mean that ModuleA and ModuleB don't keep their own dependency to ModuleC.

That means your current main parent repo include a dependency on ModuleC, which acts as the referent version for C.
That also allows you to detect when a dependency has to be overridden as, in your case, for one of your two submodules: the dependency to ModuleC for ModuleA or ModuleB will have to be overridden by the one to ModuleC from your main Repo.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

We use Quack to pull specific module from other git repository. We need to pull code without whole code base of provided repository - we need very specific module / file from that huge repository and should be updated everytime we run update.

So we achieved in this way,

Create configuration

name: Project Name

modules:
  local/path:
    repository: https://github.com/<username>/<repo>.git
    path: repo/path
    branch: dev
  other/local/path/filename.txt:
    repository: https://github.com/<username>/<repo>.git
    hexsha: 9e3e9642cfea36f4ae216d27df100134920143b9
    path: repo/path/filename.txt

profiles:
  setup:
    tasks: ['modules']

With above configuration, it create 1 directory from provided github repository as specified in first module config, and the other one is to pull and create file from given repo.

Other developers just need to run

$ quack setup

And it pulls the code from above configurations.

Hope this fix your problem of reusing multiple modules.

Love Sharma
  • 1,981
  • 1
  • 18
  • 37