在ruby/grit中,如何获取特定提交中更改的文件的列表? [英] In ruby/grit, how do I get a list of files changed in a specific commit?
本文介绍了在ruby/grit中,如何获取特定提交中更改的文件的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要受git特定提交影响的文件列表.通过命令行,我可以执行以下操作:
I want a list of files affected by a certain commit in git. Through the command line, I can do this with:
git show --pretty =格式:" --name-only(sha)
git show --pretty="format:" --name-only (sha)
但是我该如何通过Ruby中的Grit做到这一点?
But how can I do this through Grit in Ruby?
推荐答案
您可以使用your_commit.diffs
返回一个Grit::Diff
实例的数组. Grit::Diff
具有a_path
和b_path
属性.
You can use your_commit.diffs
which returns an array of Grit::Diff
instances. Grit::Diff
has a_path
and b_path
properties.
一些(未经测试的)示例代码:
Some (untested) example code:
paths = [];
@commit.diffs.each do |diff|
paths += [diff.a_path, diff.b_path]
end
paths.uniq!
这篇关于在ruby/grit中,如何获取特定提交中更改的文件的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文