#!/bin/bash# Installation:# cp pre-commit .git/hooks# chmod +x .git/hooks/pre-commitOPTIONS="--convert-tabs --indent=spaces=2 --indent-switches --indent-col1-comments --break-blocks --delete-empty-lines --align-pointer=name --keep-one-line-blocks --keep-one-line-statements --lineend=linux"RETURN=0ASTYLE=$(which astyle)if [ $? -ne 0 ]; thenecho "[!] astyle not installed. Unable to check source file format policy." >&2exit 1fiFILES=`git diff --cached --name-only --diff-filter=ACMR | grep -E "\.(c|cpp|h)$"`for FILE in $FILES; do$ASTYLE $OPTIONS < $FILE | cmp -s $FILE -if [ $? -ne 0 ]; thenecho "[!] $FILE does not respect the agreed coding style." >&2RETURN=1fidoneif [ $RETURN -eq 1 ]; thenecho "" >&2echo "Make sure you have run astyle with the following options:" >&2echo $OPTIONS >&2fiexit $RETURN
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。