【发布时间】:2026-01-18 23:45:01
【问题描述】:
我的本地项目中有一个yml 文件,存储在config/locales/en.yml。
我想创建 rake 任务将此文件推送到 GitHub,覆盖现有文件。
我怎样才能做到这一点?
【问题讨论】:
我的本地项目中有一个yml 文件,存储在config/locales/en.yml。
我想创建 rake 任务将此文件推送到 GitHub,覆盖现有文件。
我怎样才能做到这一点?
【问题讨论】:
也许你想要这样的东西?
# in lib/tasks/github.rake
namespace :github do
desc "Push locale stored in `config/locales/en.yml` to github"
task :push_locale do |t|
sh "git add config/locales/en.yml"
sh "git commit -m 'Update locale.'"
sh "git push"
end
end
然后用rake github:push_locale调用任务
【讨论】: