Extend `replace` command to output file diffs
Created by: courier-new
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:
- the repository ID
- the base ref
- the base revision
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).