Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subrepo workflow issue in switch from Hg to Git

Tags:

git

mercurial

We're running into some workflow issues in the switch from hg to git (business requirement). In hg, we used to restrict outsource studios' access to proprietary code by creating subrepos with specific permissions settings. Our main hg repos would then have branches that pointed to the appropriate Source or DLL subrepos so they could easily be switched between.

The problem we're running into is that mimicking this setup in git seems impossible. Switching branches to one that does not contain a specific submodules does not delete the files of that submodule locally (intended git behavior). This creates a tedious manual deletion step that would likely cause problems if we rolled it out to the less technical people in the office. We need a system where people can checkout the tip from any other commit in the history and are guaranteed to have a working project, which can't happen if submodule content is not deleted in the current system.

Are there any alternatives in git to what we're trying to do?

like image 624
Konstantin Avatar asked Nov 03 '14 15:11

Konstantin


1 Answers

You could use a post-checkout client side hook. Basically, when you switch branches to one that uses another submodule, the post-checkout hook will be run. In this hook, you can simply add code to remove all submodules that are not used by the current branch.

As hooks are not synced between remotes and local repos, you can follow this suggestion for getting the hooks to the people who will clone your repository.

like image 61
houtanb Avatar answered Nov 09 '22 17:11

houtanb