phpstan / extension-installer

Composer plugin for automatic installation of PHPStan extensions.
MIT License
399 stars 27 forks source link

Document that the generated config is gitignored #11

Closed spaze closed 4 years ago

spaze commented 5 years ago

Fix #10

ondrejmirtes commented 4 years ago

Hi, sorry to let you wait for such a long time. I've had busy August :) I'd rather solve this properly than have an obscure description in the README :)

This package is heavily based on https://github.com/Ocramius/PackageVersions - it also has their generated file /src/PackageVersions/Versions.php in the .gitignore, but at the same time there's commited file in the repository: https://github.com/Ocramius/PackageVersions/blob/master/src/PackageVersions/Versions.php

Not sure how Git behaves in that scenario.

What would the consequences of removing our file from .gitignore be? I think the repo's Git repository isn't cloned to project vendor/ with stable release & --prefer-dist flag, right? So the additional file wouldn't show up anywhere in case the vendor/ isn't commited.

spaze commented 4 years ago

Hi, no problem, thanks to getting back at me. Hope you enjoyed your August (and I know you did 😊)

Agree this better be solved properly.

When there's a file in .gitignore, Git just refuses to start tracking the file (doc) but once tracked, Git "ignores" .gitignore. To put it simply, .gitignore lists paths that "shouldn't be added to repo" (as opposed to "shouldn't be in the repo"). Once added, Git will happily track those .gitgnore'd paths.

I think that Composer somehow works with .gitignore too but I don't know how exactly. I think that's also the reason why PackageVersions.php are both in the repo an in .gitignore - which in this case is used by Composer to not throw a warning (although I don't know which one right now, I'm just guessing by reading the message in the commit c36c32c66319affdf6b4a838cbfe3afc7e20dca3), not by Git (because the file is already tracked).

I can run some experiments and do some code reading to see if that's the case but don't hold your breath, I have a busy September (though in a different way than you :-))

Thx.

ondrejmirtes commented 4 years ago

So would the Ocramius way (force-add the generated file skeleton and add it to .gitignore) actually solve the problem for you? So it would pop up when you want to commit the vendor/ directory?

I'm willing to experiment it in the way that if we agree on something, I'll do it, release it and wait for feedback from users :)

spaze commented 4 years ago

Tightening the feedback loop, you really mean it :-)

I didn't know that PackageVersions.php is listed in .gitignore and the stub tracked in the repo until today (and I have it in the repo as an indirect dependency), so I guess it would solve it, yeah.

ondrejmirtes commented 4 years ago

Alright, let's hope this isn't catastrophic :) Just released as 1.0.2.

spaze commented 4 years ago

Thanks!