When phpcs-changed is used in CI (eg.: Travis), there is no good way to determine the unified diff, since the working directory is clean.
In order to accommodate the situation when a branch or PR is being checked, a support for inter branch diff is helpful.
This PR adds a new param git-branch: which instructs the phpcs-changed to run a diff of the current working directory against specified branch (eg.: master).
A usage in Travis would be, for instance, as follows:
script:
- if [[ "$SNIFF" == "1" ]] && [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then /tmp/phpcs-changed/bin/phpcs-changed --git --git-branch "$TRAVIS_BRANCH" --standard="WordPress-VIP-Go" .; fi
For the needs of checking whether a file is a new one, the UnixShell::executeCommand method had to be changed to use exec rather than shell_exec, as exec also provides support for reading the exit code. In order to make the UnixShell::executeCommand backward compatible, I'm joining the $output with PHP_EOL + appending one to the very end.
When phpcs-changed is used in CI (eg.: Travis), there is no good way to determine the unified diff, since the working directory is clean.
In order to accommodate the situation when a branch or PR is being checked, a support for inter branch diff is helpful.
This PR adds a new param
git-branch:
which instructs the phpcs-changed to run a diff of the current working directory against specified branch (eg.:master
).A usage in Travis would be, for instance, as follows:
For the needs of checking whether a file is a new one, the
UnixShell::executeCommand
method had to be changed to useexec
rather thanshell_exec
, asexec
also provides support for reading the exit code. In order to make theUnixShell::executeCommand
backward compatible, I'm joining the$output
withPHP_EOL
+ appending one to the very end.See #25