开发者

Keeping custom build configuration files in a git repository

I've got a project in a git repository that uses some custom (and so far unversioned) setup scripts for the build environment etc. I'd like to put these under version control (hopefully git) but keep them versioned separate from the project itself, while still living in the base directory of the project - I've considered options like local branches but these seem to have the problem that switch back to master (or any other "real" branch) will throw away the working copies of the setup scripts.

I'm on Windows using msysg开发者_StackOverflow社区it so I've got a few tools to play with; does anyone have a recommendation or solution?


If you really need them separate from your main git repo while still living directly within it, you could try:

  • creating a new repo with those script within it

and:

  • adding that new repo as a submodule to your repo. Except:
    • a/ those scripts won't live directly in the base directory, but in a subfolder representing the submodule
    • b/ you need of course to not publish (push) that new repo, in order for other cloning your main repo to not get those setup files

or:

  • merging that new repo into your main repo (with the subtree project), but:
    • you need to split back your project to get rid of those files
    • for a project with a large history, and with frequent push, that step (the split) can be long and cumbersome.

I would consider a simpler solution, involving some evolution to your current setup files:

  • a private repo (as in "not pushed") with those setup files
  • environment variables with the path of your main git repo in order for your setup files (which would not be directly within the base directory of said main repo) to do their job in the right directory (like beginning for instance with a 'cd right_main_git_repo_dir').


I want to share an additional solution and some samples from which to start.

I've has a similar problem in attempting to build Mozilla Firefox with Buildbot -- I need to have some files in the root folder (namely the .mozconfig file and some helper scripts) and I wanted to version them separately.

My solution is as follow:

  1. checkout the Firefox code from the Mercurial repository;
  2. checkout an additional repository with the additional file I need;
  3. before starting the build, I copy these file to the folder with the Firefox code.

This approach is implemented in the following repositories:

  • buildconfig-mozilla-central: it contains the Buildbot configuration, which
    • pulls both repositories
    • copies the files from the scripts repository
    • and start the build;
  • buildscripts-mozilla-central: the repository with the build configuration and helper scripts.

Please note that the code might not be well factored (for example the paths) but it should be a good starting point.

This procedure is tailored for Firefox, but it can be applied to any repository.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜