58 Star 462 Fork 112

GVPVNoteX/vnote

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pre-commit 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
tamlok 提交于 2025-10-27 23:07 +08:00 . introduce auto-formatting and init scripts (#2664)
#!/bin/sh
#
# Pre-commit hook to format C++ files with clang-format
# Excludes third-party library folders
# Folders to exclude (third-party sources)
EXCLUDE_DIRS="libs"
# Get list of staged C++ files
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cpp|h|c|cc|cxx|hpp)$')
if [ -z "$STAGED_FILES" ]; then
exit 0
fi
# Check if clang-format is available
if ! command -v clang-format >/dev/null 2>&1; then
echo "Warning: clang-format not found. Skipping formatting."
echo "Install clang-format to enable automatic formatting."
exit 0
fi
# Format each file that is not in excluded directories
for FILE in $STAGED_FILES; do
# Check if file is in excluded directory
EXCLUDED=0
for EXCLUDE_DIR in $EXCLUDE_DIRS; do
case "$FILE" in
$EXCLUDE_DIR/*)
EXCLUDED=1
break
;;
esac
done
if [ $EXCLUDED -eq 0 ]; then
echo "Formatting: $FILE"
clang-format -i "$FILE"
git add "$FILE"
else
echo "Skipping (third-party): $FILE"
fi
done
exit 0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/vnotex/vnote.git
git@gitee.com:vnotex/vnote.git
vnotex
vnote
vnote
master

搜索帮助