I have a PHP project that i am wanting to add CodeSniffer (phpcs) to via a pipeline. I currently have it running unit tests, so I am not worried about getting it working generally. I will have no issues being able to run the code sniffer over all files. However, there are will over 1000 files in the project, so it will take a while to run. I would love to be able to run the sniffer only over those files that were changed in the pull request. Is there a way to do that? I can't seem to locate any information on this.
I have these two git commands that should give me what I am looking for, but haven't determined which is more consistent:
git diff --name-only HEAD...master
and
git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master)
Any help on how to get that information inside a pipeline would be greatly appreciated. Thank you.
You might want to check this bitbucket API that should return you the files changed in the pullrequest
in PR triggered builds you get the pull request's ID as environment variable - BITBUCKET_PR_ID (https://confluence.atlassian.com/bitbucket/variables-in-pipelines-794502608.html)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.