sirbrillig / phpcs-changed

🐘 Run phpcs on files and only report new warnings/errors compared to the previous version.
MIT License
31 stars 11 forks source link

Fetch correct old file versions #43

Closed anomiex closed 3 years ago

anomiex commented 3 years ago

When --git-base is used, we use git diff $BASE... to fetch the diff, which will diff against the merge-base of $BASE and HEAD rather than against $BASE itself.

When we run phpcs for the old file versions, we run it against the version from $BASE itself rather than the merge-base version.

Since the diff does not match the versions of the files used to produce the phpcs output, the line number correction may fail and unchanged issues may be incorrectly reported.

This PR adds an initial step that replaces the passed --git-base with the merge-base commit hash so later steps use the correct file versions.

Fixes #42

sirbrillig commented 3 years ago

This looks great! Thank you for discovering this, and more importantly for fixing it. I'm not sure my git-fu would have been sufficient.