Calculate diff of the Web IDE file changes
Description
For #5276 (closed), the Web IDE needs to create and send a diff object to the terminal runner. This issue focuses on the creation of that diff object to satisfy the current iteration. In a later iteration, we'll resolve the bi-directional issue of applying diffs (generated by the terminal) in the Web IDE.
Engineering Notes
toDelete
and patch
Splitting up To save on bandwidth, the Web IDE diff has two properties:
-
patch : String
this is a git patch which contains file updates + file creations + 100% identical file renames. -
toDelete : [String]
this is simply an array of file paths which will be deleted by the runner.
To delete a file, git
requires including the entire file's content in the patch. This is not necessary since we're not interested in catching conflicts.
Original Description
(Below is the original description of this issue which focused on bi-directional generating and applying of diffs)
The information the mirroring service is going to send and receive are diffs. We still need to decide if they're going to be incremental or the whole diff (https://gitlab.com/gitlab-org/gitlab-ee/issues/10230).
We need a way to get the changes made to the files in the Web IDE, and calculate a valid diff file from there that we can send to the mirror service in the build. At the same time, ideally, we need a way to apply diff changes to the current files in the Web IDE but this may wait until we make the mirroring service workflow bidirectional.