Reputation:
This is more of a best practice question, as we already have one solution in place, yet I am curious as to whether there are better ways of solving this.
Our projects are divided into 1 huge base project, that all other projects depend on and sub-projects. When building a sub project, I therefore also need to check out that one. In a TFSVC-build, this was possible on the "source" tab of the build definition, where you could specify exactly which projects you wanted the build agent to get for you.
In git (and VNEXT), this tab is gone, and instead there is only the option to specify a branch of your current repository. We solved this by adding a powershell-script to every project, that simply runs "git clone mainproject", granting the same effect as before.
Should our main project URL ever change, this would, however, mean we had to change this script in every customer project, which (while not impossible) would be tedious.
Has anyone got experience of something similar and has found a better way of doing this?
Upvotes: 3
Views: 434
Reputation: 1323115
You could add your main project as a submodule in each of your other projects
cd /path/to/otherproject
git submodule add -b master -- https://url/of/main/project
A git clone --recursive
of that other project would automatically clone your main project as well, as a subdirectory.
As described in "git submodule tracking latest", that main project submodule would track the latest of its upstream repo master branch at each git submodule update --remote
.
Since git-tfs doesn't support submodule yet, you would need to fall back to command-line for that.
Note: as Daniel Mann mentions in the comments:
TFS supports multiple repositories in one team project. There's no need to have each thing in its own team project.
That is actually counter to current project organization guidance
That means the idea of a submodule per project, while being a valid "git" solution, might not be the best one in a TFS environment.
Daniel mentions the blog post "Many Git Repositories, but one Team Project to rule them all" from Willy-P. Schaub
Upvotes: 2