Use git diff in temp repository instead of diff over directories
Created by: mrnugget
This fixes #137 (closed).
Before this change src actions exec
produced patches by doing the
following:
- Download ZIP archive of repository
- Unzip archive into directory A
- Run action in directory A
- Unzip archive into directory B
- Run
diff A B
- 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:
- Download ZIP archive of repository
- Unzip archive into directory A
- Run
git init && git add --all --force & git commit -am "init"
in directory - Run action in directory A
- 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.