Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PointCloud
VTK
提交
f8badc3d
V
VTK
项目概览
PointCloud
/
VTK
9 个月 前同步成功
通知
8
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VTK
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f8badc3d
编写于
3月 08, 2022
作者:
B
Brad King
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pre-commit: add support for the ghostflow hooks-max-size attribute
上级
d033ed35
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
14 deletion
+35
-14
pre-commit
pre-commit
+35
-14
未找到文件。
pre-commit
浏览文件 @
f8badc3d
...
...
@@ -163,6 +163,8 @@ check_mode() {
size_max_KiB
=
$(
git config hooks.MaxObjectKiB
)
test
-n
"
$size_max_KiB
"
||
size_max_KiB
=
1024
size_max_bytes
=
$(
git config hooks.max-size
)
test
-n
"
$size_max_bytes
"
||
size_max_bytes
=
$((
"
${
size_max_KiB
}
"
*
1024
))
size_too_large_once
=
""
size_too_large_once
()
{
test
-z
"
$size_too_large_once
"
||
return
;
size_too_large_once
=
done
...
...
@@ -170,42 +172,61 @@ size_too_large_once() {
We prefer to keep large files out of the main source tree, especially
binary files that do not compress well. This hook disallows large files
by default but can be configured. A limit for specific files or patterns
may be set in ".gitattributes" with the "hooks
.MaxObjectKiB
" attribute.
may be set in ".gitattributes" with the "hooks
-max-size
" attribute.
For example, the line
*.c hooks
.MaxObjectKiB=2048
*.c hooks
-max-size=1500000
sets a limit of
2048 KiB
for C source files. See "git help attributes"
sets a limit of
1500000 bytes
for C source files. See "git help attributes"
for details on the .gitattributes format. If no attribute has been set
for a given file then its size is limited by the local default. Run
git config hooks.
MaxObjectKiB $KiB
git config hooks.
max-size $bytes
to set the local default limit (0 to disable).
'
}
size_too_large
()
{
size_too_large_once
echo
"The path '
$file
' has size
$file_
KiB
KiB, greater than allowed
$max_KiB
KiB
."
echo
"The path '
$file
' has size
$file_
bytes
bytes, greater than allowed
$max_bytes
bytes
."
}
size_validate_max_KiB
()
{
test
"
$max_KiB
"
-ge
"0"
2>/dev/null
&&
return
0
echo
"The path '
$file
' has invalid attribute
\"
hooks-MaxObjectKiB=
$max_KiB
\"
."
echo
"The path '
$file
' has invalid attribute
\"
hooks.MaxObjectKiB=
$max_KiB
\"
."
return
1
}
size_validate_max_bytes
()
{
test
"
$max_bytes
"
-ge
"0"
2>/dev/null
&&
return
0
echo
"The path '
$file
' has invalid attribute
\"
hooks-max-size=
$max_bytes
\"
."
return
1
}
check_size
()
{
test
"
$dst_obj
"
!=
"
$zero
"
||
return
max_KiB
=
$(
git check-attr hooks.MaxObjectKiB
--
"
$file
"
|
sed
's/^[^:]*: hooks.MaxObjectKiB: //'
)
max_KiB
=
$(
git check-attr hooks.MaxObjectKiB
--
"
$file
"
|
sed
's/^[^:]*: hooks.MaxObjectKiB: //'
)
case
"
$max_KiB
"
in
'unset'
)
return
;;
# No maximum for this object.
'set'
)
max_KiB
=
"
$size_max_KiB
"
;;
# Use local default.
'unspecified'
)
max_KiB
=
"
$size_max_KiB
"
;;
# Use local default.
'unset'
)
;;
'set'
)
;;
'unspecified'
)
;;
*
)
size_validate_max_KiB
||
return
;;
esac
if
test
"
$max_KiB
"
-gt
"0"
;
then
file_KiB
=
$(
expr
'('
$(
git cat-file
-s
"
$dst_obj
"
)
+ 1023
')'
/ 1024
)
test
"
$file_KiB
"
-le
"
$max_KiB
"
||
size_too_large
max_bytes
=
$(
git check-attr hooks-max-size
--
"
$file
"
|
sed
's/^[^:]*: hooks-max-size: //'
)
case
"
$max_bytes
"
in
'unset'
)
return
;;
# No maximum for this object.
'set'
)
max_bytes
=
"
$size_max_bytes
"
;;
# Use local default.
'unspecified'
)
# Fall back to max KiB setting.
case
"
$max_KiB
"
in
'unset'
)
return
;;
# No maximum for this object.
'set'
)
max_bytes
=
$((
"
${
size_max_KiB
}
"
*
1024
))
;;
# Use local default.
'unspecified'
)
max_bytes
=
"
$size_max_bytes
"
;;
# Use local default.
*
)
max_bytes
=
$((
"
${
max_KiB
}
"
*
1024
))
;;
esac
;;
*
)
size_validate_max_bytes
||
return
;;
esac
if
test
"
$max_bytes
"
-gt
"0"
;
then
file_bytes
=
$(
git cat-file
-s
"
$dst_obj
"
)
test
"
$file_bytes
"
-le
"
$max_bytes
"
||
size_too_large
fi
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录