Backend: add argument to `fileDiffs` to filter diffs to a file or directory
Created by: camdencheek
This adds an argument to fileDiffs
so that we can filter the resulting diffs to a set of files or directories. This should be the extent of the backend changes required to implement a view of the changes for a single file as described here
Examples:
Get change in `dev/gqltest/search_test.go` over the last 50 commits
{
repository(name: "github.com/sourcegraph/sourcegraph") {
name
comparison(base:"HEAD~50", head:"HEAD") {
fileDiffs(paths:["dev/gqltest/search_test.go"]){
nodes{
hunks {
body
}
}
}
}
}
}
Get all commits that touch the directory `internal/search/job/jobutil` and the diff associated with them
{
repository(name:"github.com/sourcegraph/sourcegraph") {
commit(rev:"HEAD"){
ancestors(path:"internal/search/job/jobutil") {
nodes {
diff{
fileDiffs(paths:["internal/search/job/jobutil"]){
nodes{
hunks {
body
}
}
}
}
}
}
}
}
}
Test plan
Added unit test, tested manually to make sure git stuff works as expected.