-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix gitblame to not use full path when chdir
#3809
Conversation
After we change into the files directory, invocation of git blame with full path will end in fatal error.
@datengraben Thanks for this PR. I've tested with both the PHPCS To properly evaluate this PR, I believe more information is needed to reproduce the issue this is trying to solve. What and how I tested thisTested with a git clone of this repo on Windows 10. Take note that I used the Scenario 1: PHPCS run from project rootFrom the root directory of the PHPCS repo, I ran the following command first with the phpcs -psl ./src --standard=PEAR --report=gitblame Scenario 2: PHPCS run from a subdirectory under the project rootI changed into the From the phpcs -psl . --standard=PEAR --report=gitblame In all four cases, the output is exactly the same for me (see details in the fold-out). Output
|
Ha! I ran into something similar the other day. I've just tested and even though this PR doesn't solve my issue, I can now see a case which it does solve. As far as I can see, the problem is the combination with the @datengraben Could you confirm you are using the In that case, the usecase for accepting this fix would be the following: Scenario 1: PHPCS run from project rootphpcs -psl ./src --standard=PEAR --report=gitblame --basepath=. Output when using the branch-off point (
Output when using the PR branch:
|
@datengraben Have you had a chance to check this ?
|
@jrfnl Yes I can confirm, we are using basepath="./" from the ruleset. |
@datengraben Thanks for confirming. In that case, I'll merge this now. |
FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release. As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo). |
Thanks for the great Tool!
When invoking with
--report=gitblame
most or all of the found sniffs do not show up with their author to blame. Instead the report table is empty.The problem is the following:
In #1249
chdir
was introduced before the call togit blame
, which was to change into a directory to resolve the.git
-root-dir more easily. For example when thephpcs
command is not started from a proper Git directory.I'm not sure what happened since #1249 that
--report=gitblame
won't work, but it seemed to work that time.But now
GitBlame.php
requests the full path file, but from within the directory of that file.I did not dig deeper why it seemed to work at that time. Anyway I'm sure it works now, tested it on my repos locally.
If you want I can attach a more detailed issue.