phpro / grumphp

A PHP code-quality tool
MIT License
4.11k stars 429 forks source link

Allow to also ignore untracked files #1075

Closed yguedidi closed 1 year ago

yguedidi commented 1 year ago
Q A
Version 1.15.0
Bug? yes/no
New feature? no
Question? no
Documentation? no
Related tickets N/A

I faced an issue for which ignoring unstaged changes was not sufficient: running a unit test suite as precommit with an untracked unit test file. it wasn't expected to commit that file at that moment, but it existed already. And so being on the file system it was taken into account by PHPUnit.

I was about to quickly contribute a new ignore_untracked_files option, but I realized that it may not be good to have it as a separate configuration, as it would mean that it could be used alone, without ignore_unstaged_changes.

Another solution is to simply add --ignore-untracked to the stach command, but maybe this is a BC break?

So I'm questioning what would be the best way to solve the issue I faced.

Note: issue faced when doing lot of code changes then trying to do clean atomic commits 🙂

veewee commented 1 year ago

Hello,

It seems that this default behaviour of git stash changed in a specific git version. I'dd say adding --include-untracked (not --ignore ;) )to the stash command would result in the expacted behaviour? In that scenario, GrumPHP wants to have only the committed files available.

Care to create a PR for this?

yguedidi commented 1 year ago

Good! thank, I'm on it