最佳实践 - 混帐+构建自动化 - 保持CONFIGS分离 [英] Best practice - Git + Build automation - Keeping configs separate

查看:213
本文介绍了最佳实践 - 混帐+构建自动化 - 保持CONFIGS分离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

搜索,最好的办法,以保持我的配置文件分开,但没有引进新的开发人员额外的步骤,建立自己的环境。

Searching for the best approach to keep my config files separate, yet not introduce extra steps for new developers setting up their environments.

我猜一个子模块就足以完成这项工作,但后来我将如何切换无缝根据手头的任务CONFIGS,在DEV配置又名拉定期,拉构建过程中的配置回购PROD分支?

I am guessing a submodule would suffice to do the job, but then how would I switch configs seamlessly depending on the task at hand, aka pull in DEV config regularly, pull PROD branch of config repo during build?

必须是:


  • 容易和无痛的新的开发者。

  • PROD配置文件应该只访问选择用户打造+用户。

感谢您提前。

推荐答案

这就是所谓的 内容过滤驱动 ,它允许你声明,在 .gitattributes 文件(仅适用于您的配置文件类型)一个涂抹脚本哪些会的自动结账的:

That is called content filter driver, and it allows you to declare, in a .gitattributes file (and only for your config files type) a smudge script which will automatically on checkout:


  • 相结合的配置文件的模板的文件( config.tpl

  • 用正确的配置文件值( config.dev config.prod ,...)

  • 在以生产非版本配置文件(专用文件)

  • combine a config file template file (config.tpl)
  • with the right config file value (config.dev, config.prod, ...)
  • in order to produced a non-versioned config file (private file)

请参阅定制的Git - Git属性

echo '*.cfg.tpl config' >> .gitattributes
git config --global filter.config.smudge yourScript

通过这种方法,你不需要子模块,但你可以,你需要根据你的环境,比如像你的分支产生尽可能多的配置文件:结果
就像有点查找post-update挂钩的Git分支名称,你的涂抹脚本可以找出在哪个分支它目前正在与执行:

With that approach, you don't need submodules, but you can generate as many config file you need depending on your environment, like for instance your branch:
A bit like in "Find Git branch name in post-update hook", your smudge script can find out in which branch it is currently executing with:

#!/bin/sh
branch=$(git rev-parse --symbolic --abbrev-ref HEAD)

这篇关于最佳实践 - 混帐+构建自动化 - 保持CONFIGS分离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆