Skip to content

Use git diff in temp repository instead of diff over directories

Warren Gifford requested to merge git-diff into master

Created by: mrnugget

This fixes #137 (closed).

Before this change src actions exec produced patches by doing the following:

  1. Download ZIP archive of repository
  2. Unzip archive into directory A
  3. Run action in directory A
  4. Unzip archive into directory B
  5. Run diff A B
  6. Strip 'A' and 'B' prefixes from produced patches

The problem with this approach was that it didn't respect the .gitignore file in a repository.

And since we run diff outside the folder it's non-trivial to make it respect the .gitignore, which contains pattern with the assumption that the root directory is the repository.

This change here uses the following approach:

  1. Download ZIP archive of repository
  2. Unzip archive into directory A
  3. Run git init && git add --all --force & git commit -am "init" in directory
  4. Run action in directory A
  5. Run git add --all && git diff --cached in directory A

That gives us a proper diff produced by git, respecting .gitignore.

There's a cost involved to making a commit with all the files (since the git objects have to be written), but from manual testing I can say that it's not noticably slower than unzipping the archive a second time, as we previously did.

It also gets us rid of the dependency on diff, of which users have a ton of different versions installed.

Merge request reports

Loading