Conversation
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.
unknwon
approved these changes
Feb 27, 2020
ryan-blunden
approved these changes
Feb 27, 2020
57 tasks
scjohns
pushed a commit
that referenced
this pull request
Apr 24, 2023
* Use git diff in temp repository instead of diff over directories 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. * Remove mention of `zip` and `diff` from README * Check that git is available in src actions exec * Add note about git requirement to README
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #137.
Before this change
src actions execproduced patches by doing thefollowing:
diff A BThe 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:
git init && git add --all --force & git commit -am "init"in directorygit add --all && git diff --cachedin directory AThat 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 aton of different versions installed.