phpro / grumphp

A PHP code-quality tool
MIT License
4.14k stars 430 forks source link

Handling Unstaged Changes #858

Closed dshafik closed 3 years ago

dshafik commented 3 years ago
Q A
Version GrumPHP 1.3.0
Bug? no
New feature? yes
Question? no
Documentation? no
Related tickets none

There is currently no warning when the ignore_unstaged_changes: true parameter causes changes to be stashed. It would be very helpful to know that has happened as it may cause other tasks (e.g. phpunit) to fail, and the reasoning be unclear.

Additionally, the ability to fail when there are unstaged changes would be useful to some I'm sure.

veewee commented 3 years ago

Thanks for reporting. It should be giving you a notice, so I assume this is a bug.

https://github.com/phpro/grumphp/blob/11ff4779ad4dcead36e97f812c896d7e53b4ee67/src/Event/Subscriber/StashUnstagedChangesSubscriber.php#L105-L113

dshafik commented 3 years ago

I just tried this again, and it deleted everything in my repo that wasn't staged. Thankfully that caused my tasks to fail and I was able to undo it.

The addition of ignore_unstaged_changes: true is the only change I made between working as expected (except not ignoring unstaged files) and deleting everything.

veewee commented 3 years ago

As seen in the added movie in #859, GrumPHP Does mention that changes are being stashed. Closing this one for now.