git の特定のコミットの影響を受けるファイルのリストが必要です。コマンドラインを使用して、次のように実行できます。
git show --pretty="format:" --name-only (sha)
しかし、Ruby の Grit を使用してこれを行うにはどうすればよいでしょうか?
インスタンスyour_commit.diffs
の配列を返すwhichを使用できます。とプロパティがあります。Grit::Diff
Grit::Diff
a_path
b_path
いくつかの(テストされていない)サンプルコード:
paths = [];
@commit.diffs.each do |diff|
paths += [diff.a_path, diff.b_path]
end
paths.uniq!
Grit の git モジュールは shell out に method_missing を採用しているので、以下を試すこともできます:
grit.git.show({ :pretty => :format, :name_only => true}, sha)