Skycoder42/dart_pre_commit

run specific tasks on staged files only

waleedf112 opened this issue · 3 comments

I would like to run the analyze and custom-lint tasks only on staged files, is there a way I could achieve that?
I have some changes on some files that I'm not trying to commit yet, therefore, I'm not able to commit one file that would actually pass the dart analyzer.

the tool should not prevent me from committing a file because other unstaged files have some issues with the analyze task.

thank you.

In theory, this could be archived by running the analyzer on every single file instead of the whole repository. I have not done this so far, as this would slow down the tool quite a bit. It would also mean that you will not see analysis results for the unstaged files.

Another option would be to scan all files and output all results, but only fail if a staged file is in the output. This a more complex solution, as the analyzer das not support machine readable output, but it is theoretically possible.

Would the first solution be enough for you, or would you prefer the second?

In theory, this could be archived by running the analyzer on every single file instead of the whole repository. I have not done this so far, as this would slow down the tool quite a bit. It would also mean that you will not see analysis results for the unstaged files.

Another option would be to scan all files and output all results, but only fail if a staged file is in the output. This a more complex solution, as the analyzer das not support machine readable output, but it is theoretically possible.

Would the first solution be enough for you, or would you prefer the second?

both works, the second is more "optimal", I will try to find a way to do it and open a pull request.