1 Star 0 Fork 77

loongtze/E-Books

forked from MMK/E-Books 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
pre-commit 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
hz 提交于 2017-07-04 09:37 . first commit
#!/bin/sh
MAX_SIZE=98*1000*1000
export TOP_PID=$$
trap 'exit 1' TERM
SolveBigFile(){
file_size=$(stat -c %s "${1}")
if [[ $file_size -gt $MAX_SIZE ]]; then
file_size=$(awk 'BEGIN{printf "%.2f\n",'$file_size'/'1000000'}')
echo "The file is too large."
echo " File Name: ${1}"
echo " File Size: ${file_size} MB"
echo "Solution: git reset HEAD <file> and rm <file>"
git reset "${1}"
rm "${1}"
return 1
else
return 0
fi
}
for file in ./*
do
if test -f "${file}"
then
SolveBigFile "${file}"
fi
if test -d "${file}"
then
ls "${file}" | while read sub_file
do
if test -d "${sub_file}"; then
echo "error: the directory has sub dir."
exit 1
fi
SolveBigFile "${file}/${sub_file}"
if [ 1 -eq $? ]; then
kill -s TERM $TOP_PID
fi
done
fi
done
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/loongtzer/E-Books.git
git@gitee.com:loongtzer/E-Books.git
loongtzer
E-Books
E-Books
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385