运行 pre-commit.com 如果检测到匹配的文件则挂钩一次(不是针对每个文件)
Run pre-commit.com hook once (not for every file) if a matched file is detected
我有一个从源文件生成文档文件的挂钩,使用 pre-commit.com framework. The function that is invoked in that hook does not have a file argument, so it simply creates documentation for all source files in the directory. The hook is a system
hook, i.e. just a bash script where I call that function to create the documentation. However, in the pre-commit.com framework, files are passed to the hook and the logic is to execute a hook on every file, which makes sense in most cases (e.g. to lint every file separately). So my question is: How can I ensure that the documentation hook is run once if there is any source file changed, as opposed to it being run in multiple times (in parallel or sequentially), on the individual files? In concrete terms, my hook is generating R docuementation with roxygen2::roxygenize()
and can be found here.
预提交框架支持 pass_filenames: false
这里的文档也许可以改进,但这是他们不得不说的
pass_filenames
- (optional: default true
) if true
this hook must take filenames as positional arguments. new in 0.14.0.
嗯是的也许不是最好的描述——但是如果 false
pre-commit
将只调用你的命令一次并且不会传递任何文件名
我有一个从源文件生成文档文件的挂钩,使用 pre-commit.com framework. The function that is invoked in that hook does not have a file argument, so it simply creates documentation for all source files in the directory. The hook is a system
hook, i.e. just a bash script where I call that function to create the documentation. However, in the pre-commit.com framework, files are passed to the hook and the logic is to execute a hook on every file, which makes sense in most cases (e.g. to lint every file separately). So my question is: How can I ensure that the documentation hook is run once if there is any source file changed, as opposed to it being run in multiple times (in parallel or sequentially), on the individual files? In concrete terms, my hook is generating R docuementation with roxygen2::roxygenize()
and can be found here.
预提交框架支持 pass_filenames: false
这里的文档也许可以改进,但这是他们不得不说的
pass_filenames
- (optional: defaulttrue
) iftrue
this hook must take filenames as positional arguments. new in 0.14.0.
嗯是的也许不是最好的描述——但是如果 false
pre-commit
将只调用你的命令一次并且不会传递任何文件名