Closed sirbrillig closed 3 years ago
I'm going to merge this as-is because I think it's the right behavior, but I won't cut a release until I'm sure that I can treat this as a non-breaking change.
Thanks for addressing the issue! The solution seems to be working fine for me. 🙇
When using the various git modes, the way to determine the contents of the "new" version of a file differs. Using
git-unstaged
, we cancat
the working copy of the file; usinggit-staged
, we must ask git for the staged version; usinggit-branch
, we must ask git for the committed version.An oversight in https://github.com/sirbrillig/phpcs-changed/pull/18 meant that the first two modes used the current working copy of the file. This PR fixes that bug by using the staged version for
git-staged
.The third mode is a little more complicated. https://github.com/sirbrillig/phpcs-changed/pull/28 added the
git-branch
mode, and based on the description, it was intended to also use the current working copy of the file. However, in https://github.com/sirbrillig/phpcs-changed/pull/31 and https://github.com/sirbrillig/phpcs-changed/pull/34 I added documentation for that mode and incorrectly specified that it used the currently committed version of the code to compare to the HEAD of another branch. This PR changes the mode's behavior to match the documentation, using the current HEAD forgit-branch
. While I think this should be safe (the use-case given in the original PR was running the changes through CI, which is probably always operating on the committed file), I want to double check with @david-binda to make sure.Fixes https://github.com/sirbrillig/phpcs-changed/issues/37