php - 仅对修改后的行使用 PHP_CodeSniffer

标签 php svn pre-commit-hook codesniffer

我正在尝试在 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/

相关文章:

c# - 使用源代码管理时,实际上应该提交哪些文件?

git - 如何传播我的 git 配置/ Hook ?

git - 使用预提交搜索文件

php - Android 上传多张带有文本数据的图像

php - MySQL如何显示两个表的数据

php - 使用 MySQL 为帖子投票/点赞系统

svn - Subversion 和 MKS 的区别

php - 在 1 个查询中选择/求和具有不同条件的列

c# - SharpSvn GetInfo LastChangeRevision 错误

svn - 颠覆 : how to remove property on commit