确定使用Ruby更改了哪些git文件?
我有一个Rails应用程序,其中包含我想从单独的blog.git repo更新的博客条目 我将我的工作流程设想为:确定使用Ruby更改了哪些git文件?,ruby,git,diff,Ruby,Git,Diff,我有一个Rails应用程序,其中包含我想从单独的blog.git repo更新的博客条目 我将我的工作流程设想为: 写新博客 推送到远程Git回购 Call cap deploy:update,它将调用一个Rake任务来使用任何更改或新条目更新数据库 这里的问题是查找哪些文件已更改。我想利用Git实现这一点,我知道我可以在Git diff上编写一些awk或Perl脚本 但是有更好的办法吗?我简单地看了一下Grit,但找不到一个好的解决方案 更新:事实证明,砂砾是解决这个问题的最佳方案,至少据我所
Git diff
上编写一些awk或Perl脚本
但是有更好的办法吗?我简单地看了一下Grit,但找不到一个好的解决方案
更新:事实证明,砂砾是解决这个问题的最佳方案,至少据我所知。以下是我用来解决这个问题的方法:
desc 'Posts all entries to database'
task :post_all do
Dir.chdir REPO do
Grit::Repo.new('.').tree.contents.each do |file|
# post_entry cleans up my blog entries and posts them via Post.create()
post_entry(file.data, :text) unless file.basename =~ /\.gitignore/
end
end
end
desc 'Posts all new or changed entries to database'
task :post_new do
Dir.chdir REPO do
Grit::Repo.new('.').head.commit.diffs.each do |diff|
post_entry diff.b_blob.data, :text
end
end
end
desc 'Deletes entries from database'
task :remove_all do
Post.destroy_all
end
desc 'Synchronizes the remote blog repo and the database'
task :sync => [ :remove_all, :post_all ]
数据库真的有必要吗?看看杰基尔宝石。数百(如果不是数千)个简单的博客使用它,包括我的两个 否则,砂砾是一个很好的解决方案。我用它做了一些事情,效果很好