您使用什么工具来避免意外地将私人信息推送到 Rails 项目上的 github 存储库?

发布于 2024-10-18 01:33:01 字数 82 浏览 3 评论 0原文

在将项目推送到公共 github 存储库之前,是否有任何工具可以用来清理项目。在将源代码推送到公共存储库的同时,如何维护您的私有设置?最佳实践是什么?

Are there any tools you use to scrub your project before pushing to a public github repo. How do you maintain your private settings, while pushing your source code to a public repo? What is the best practice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

纵山崖 2024-10-25 01:33:01

.gitignore 文件是你的朋友。

.gitignore file is your friend.

つ低調成傷 2024-10-25 01:33:01

我没有将database.yml 保存在git 中。我把它写在上限设置任务中。对于电子邮件地址和其他内容,我在应用程序初始化时从文件系统中的文件中读取它们。同样,不在源代码管理下并在 cap 设置期间写入共享目录。

这是一个示例:

namespace :deploy do
  task :start do ; end
  task :stop do ; end

  task :setup do
    run <<-CMD
      mkdir -p -m 775 #{release_path} #{shared_path}/system #{shared_path}/media &&
      mkdir -p -m 777 #{shared_path}/log &&
      mkdir -p -m 777 #{shared_path}/pids &&
      mkdir -p #{deploy_to}/#{shared_dir}/config
    CMD

  end

  require 'erb'

  after deploy:setup do
    db_config = ERB.new <<-EOF
production:
  adapter: mysql2
  database: my_fine_database
  host: 127.0.0.1
  username: database_user
  password: database_password
EOF

    email_config = ERB.new <<-EOF
--- 
:user_name: [email protected]
:password: verysecret
:port: 25
:address: mydomain.com
:domain: mydomain.com
:authentication: :login
EOF

    put db_config.result, "#{shared_path}/config/database.yml"
    put email_config.result, "#{shared_path}/config/creds.yml"
  end

在我的 environment.rb 中,我输入:

credentials = File.join(Rails.root, 'config/creds.yml')

ActionMailer::Base.smtp_settings = YAML.load(File.open(credentials)) if File.exists?(credentials)

您还可能存储哪些其他敏感信息?

I don't keep database.yml in git. I write it in a cap setup task. For email addresses and other things, I read them at app initialize from a file in the file-system. Again, not under source code management and written to the shared directory during cap setup.

Here's a sample:

namespace :deploy do
  task :start do ; end
  task :stop do ; end

  task :setup do
    run <<-CMD
      mkdir -p -m 775 #{release_path} #{shared_path}/system #{shared_path}/media &&
      mkdir -p -m 777 #{shared_path}/log &&
      mkdir -p -m 777 #{shared_path}/pids &&
      mkdir -p #{deploy_to}/#{shared_dir}/config
    CMD

  end

  require 'erb'

  after deploy:setup do
    db_config = ERB.new <<-EOF
production:
  adapter: mysql2
  database: my_fine_database
  host: 127.0.0.1
  username: database_user
  password: database_password
EOF

    email_config = ERB.new <<-EOF
--- 
:user_name: [email protected]
:password: verysecret
:port: 25
:address: mydomain.com
:domain: mydomain.com
:authentication: :login
EOF

    put db_config.result, "#{shared_path}/config/database.yml"
    put email_config.result, "#{shared_path}/config/creds.yml"
  end

and in my environment.rb, I put:

credentials = File.join(Rails.root, 'config/creds.yml')

ActionMailer::Base.smtp_settings = YAML.load(File.open(credentials)) if File.exists?(credentials)

What other sensitive information might you be storing?

邮友 2024-10-25 01:33:01

有时您不想 gitignore 整个文件 - 也许您更愿意只删除一两行敏感数据。我专门为此目的编写了 lucido

lucido(发音为 loo-CHEE-dough)是一个简单的脚本,旨在...轻松剥离和恢复敏感数据。在 git 存储库中,lucido 会阻止您提交敏感数据,并在任何合并后自动为您恢复它。

Sometimes you don't want to gitignore an entire file - maybe you'd prefer to just scrub out a line or two of sensitive data. I've written lucido specifically for this purpose.

lucido (pronounced loo-CHEE-dough) is a simple script designed to ... strip and restore sensitive data with ease. Within a git repository, lucido prevents you from committing your sensitive data, and automatically restores it for you after any merges.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文