Closed papandreou closed 11 years ago
Ok, I think I figured out how this should work and implemented the following on the fsPlusGit
branch:
1) When determining the set of files to lint, look for files that have staged changes. Ignore files not under version control and files that are identical to the version in HEAD.
2) When reading files and reporting file names to linters, use what's staged in the index, but fall back to what's in the working copy. This ensures that auto-generated files are present in case eg. the less linter needs to @import
them. It uses the virtual .git/gitFakeFs/indexOrWorkingCopy
dir in fsPlusGit to support this feature.
Let me know if you think this is in a state to land on master.
There's a minor thing missing, but I don't think it should be a blocker: https://github.com/papandreou/node-gitfakefs/issues/1
Landed on master.
I finally assembled the tech to accomplish this:
https://github.com/papandreou/node-cachedfs https://github.com/papandreou/node-fsplusgit https://github.com/papandreou/node-gitfakefs
What's still missing is finding a good way to expose it. As a starting point, I wired things up and added a
--git
switch that figures out where the.git
folder for your project is, then resolves your paths relative to the virtual directory that exposes the contents of the index. I put it on thefsPlusGit
branch: https://github.com/msiebuhr/slint/commit/03e9e3052803ed36b2c25d7faab963c06db266b2It seems to work:
As for the mode that only lints the actually changed files, that is supported by those helper modules I built (
/path/to/repo.git/gitFakeFs/changesInIndex/...
). We need to think a bit about how to use that, though, as you usually won't have changed yourslint.json
file, which will make it absent. Also, theless
linter will have trouble resolving@import
s pointing at files that haven't changed. Clearly some things still need to be fetched from/path/to/repo.git/gitFakeFs/index/...
.