I have a hook that generates documentation files from source files, built with the 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.
Run pre-commit.com hook once (not for every file) if a matched file is detected
Asked Answered
Looks similar to #2412950 –
Eudora
I am not sure. My question is very specific to the pre-commit.com framework. I updated the question to reflect that better. –
Canikin
This sounds like you are trying to bend a system designed for use case A to apply to completely-different use-case H. It might be better to look into a system that's not so tied to the one-file-at-a-time use-case. –
Newson
The pre-commit framework supports a pass_filenames: false
The docs could perhaps be improved here but this is what they have to say
pass_filenames
- (optional: defaulttrue
) iftrue
this hook must take filenames as positional arguments. new in 0.14.0.
hmmm yeah maybe not the best description -- but if false
pre-commit
will only invoke your command once and won't pass any filenames
© 2022 - 2024 — McMap. All rights reserved.