我正在尝试在 SVN 中构建预提交脚本,并且我想在修改的行(而不是整个文件)上运行 PHP_CodeSniffer。到目前为止,我有这个脚本:
#!/bin/sh
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
grep "[a-zA-Z0-9]" > /dev/null || exit 1
# Check for code validation before commiting the script using PHP_CodeSniffer
/tmp/pear/download/PHP_CodeSniffer-1.4.3/scripts/phpcs-svn-pre-commit "$REPOS" -t "$TXN" >&2 || exit 1
# All checks passed, so allow the commit.
exit 0
最佳答案
2017 年,自 CodeSniffer 3.0.0释放,有new --cache
option .
或者您可以使用 EasyCodingStandard ,默认执行此操作。
关于php - 仅对修改后的行使用 PHP_CodeSniffer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14114260/