Git获取Commit修改文件列表

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zxc024000/article/details/85160104

Git获取Commit修改文件列表

  • 获得Git本次Commit修改的文件
# 命令格式
# 会列出compare2与compare1的不同。
# git diff --name-only <commit compare1> <compare2>
changeFiles=$(git diff --name-only HEAD~ HEAD)
  • 例:配合cpplint,对Git本次提交修改的文件,进行codecheck。
# 需要检查的文件
checkFiles=$(git diff --name-only HEAD~ HEAD)

# cpplint检查文件类型
CPPLINT_EXTENS=cc,cpp,h
# cpplint filter :  -xxx,就是去掉该项检查。+xxx,就是添加该项检查。
CPPLINT_FITER=-whitespace/line_length,-build/include_what_you_use,-readability/todo,-build/include,-build/header_guard
# cpplint.py为google的代码风格检查脚本,可百度自行获取
python cpplint.py --extensions=$CPPLINT_EXTENS --filter=$CPPLINT_FITER $checkFiles 2>&1 | tee cpplint-result.xml

猜你喜欢

转载自blog.csdn.net/zxc024000/article/details/85160104