Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check files in index/stage instead of working directory #67

Closed
alexgt9 opened this issue Nov 19, 2015 · 4 comments
Closed

Check files in index/stage instead of working directory #67

alexgt9 opened this issue Nov 19, 2015 · 4 comments

Comments

@alexgt9
Copy link

alexgt9 commented Nov 19, 2015

Now GrumPHP check the index/stage for files changed as desired, but then is check for the content of these files in the working directory, so, you can modify these files locally without adding them to the index (e.g. for commit them) and GrumPHP will pass.

I don't know if is easy or even possible to check for content of the files but in the git index.

@veewee
Copy link
Contributor

veewee commented Nov 19, 2015

Not sure if that is possible. We will need to do some extra investigation on this issue.

@alexgt9
Copy link
Author

alexgt9 commented Nov 19, 2015

I have been investigating and I think that is not possible, for example, we are calling to the php-cs-fixer and we need to pass to it the path to the file but we can only get the content of the files in the index using git show :file.path

I don't know if there is another approach...

@adam-paterson
Copy link
Contributor

I'm pretty sure this won't be possible. The git index itself doesn't contain the file changes. It is a binary file containing a sorted list of path names, each with permissions and the SHA1 of a blob object.

We will only ever be able to check the working directory files.

@veewee
Copy link
Contributor

veewee commented Dec 11, 2015

I've discussed the issue with @aderuwe. We also don't think it is possible.
As you mention, tools like php-cs-fixer require the file on the file-system, so it won't be able to run these tools on an in-memory version of the file.

The idea is:

  • Check the stage to know which files should be tested
  • Validate the file in the current working dir. (because that's the actual file at that moment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants