sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.11k stars 1.29k forks source link

Extend `replace` command to output file diffs #39185

Open courier-new opened 2 years ago

courier-new commented 2 years ago

Currently, the compute replace command only outputs the changed file contents.

For search-and-replace batch changes, we would like to implement support for an alternative output of the file diff when a new command, replace.diff(...), is used. This will enable us to leverage this command for the UI previews and ChangesetSpec. We should ensure we're not creating 2 requests to gitserver for the same file this way.

There are currently 3 types of Compute result: Text, TextExtra, and MatchContext. replace.diff(...) should output a 4th type of result like ReplaceDiff that also contains all the necessary context about where the diff was generated:

This issue has as a prerequisite that we are able to generate patches in Go without calling out to git diff (https://github.com/sourcegraph/sourcegraph/issues/39194).

courier-new commented 2 years ago

P0 or P1, depending on how bad https://github.com/sourcegraph/sourcegraph/issues/39194 is? Estimating this is a bit hard since compute will be new to all of us (we at least can look at replace itself to get started) so let's be flexible here: 2d to 6d??

malomarrec commented 2 years ago

I vote P0 for the overall tracking issue, let's discuss what's the best ordering :)

courier-new commented 2 years ago

Updating the estimate on this given Bolaji has a working solution for generating the diffs and just needs to figure out where it should live. 🎉