开发者

Open sourcing code without including specific set-up values in source [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 7 years ago.

开发者_运维技巧 Improve this question

I am creating a few small experiments / examples which I am open sourcing on git hub.

How have people dealt with user specific config/set-up vars in the past?

I would ideally like to commit the exact same code that I myself am using, but without including my URL's or app id / secrets etc.

I have thought that perhaps I could do it in one of the following ways, but is there a standard or recommended way of doing this?

baseURL = include myConfig.txt;

or

baseURL = "Enter Your URL Here";


You could have the very simplest config options as environment variables.

You could have a small config object, which holds dummy values.

You could add a config.ini.sample file.


For this kind of configuration (file with "secret private" content, private as "visible only within my working tree, but never versioned in the Git repo), I always recommend a custom filter driver (See also Pro Git book for the principle):

Open sourcing code without including specific set-up values in source [closed]

  • a template of your setting file (settings.template, with baseURL),
  • a script able to generate a proper setting file settings based on local values found in your working tree (like an encrypted file with the secret value ready to be decoded and put in the setting file by the smudge script)


Me personally I would use a special commit to my own GIT tree which includes my own specialities. So they are separated from the rest of the history. Whenever I push my changes to the public tree, that commit would be omitted.

I don't know however how to ensure not to accidentally push the commit. But there ought to be some way.


You can read configuration values from a file, for example config.txt, and commit config.txt.example with helpful comments, default values where applicable and dummy values in other places, so users can just copy that to config.txt and change the needed values.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜