pydoit / doit

task management & automation tool

Home Page:http://pydoit.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pre-commit hook

real-yfprojects opened this issue · comments

I would like to use doit as a pre-commit hook. I have a couple of 'build' tasks that generate source files. These source files should be present and also up-to-date in each commit. Not only doesn't doit provide its own .pre-commit-hooks.yaml file, but i can't define my own hook using doit since doit will always return code 0. I would like to have an option which makes doit fail if one of the tasks run modified a file. Also I would like doit to provide a pre-configured pre-commit hook.

Fund with Polar

doit does NOT always return 0. If a task fails it returns non-zero.

It seems you want a non-zero return code if any task is actually executed (not up-to-date). is that it? currently not possible but should not be hard to achieve this somehow...

Regarding pre-commit package. I am not familiar with the project implementation.
doit was designed to be executed many times during development cycle, not once on commit.
But I get it would be trivial to just invoke doit in a pre-commit hook.

It seems you want a non-zero return code if any task is actually executed (not up-to-date). is that it? currently not possible but should not be hard to achieve this somehow...

Yes, exactly. There would be two possible modes for such a hook. A mode that only checks that everything is up-to-date and doesn't modify any files. And a mode that actually runs the tasks.
I would prefer to use the second option. However the first option would work too since I could run doit manually if the pre-commit check fails. This would therefore be the more versatile option.

Regarding pre-commit package. I am not familiar with the project implementation.

You define how to run your hook in a small .pre-commit-hooks.yaml file. I could write such a file if above functionality is in place.

doit was designed to be executed many times during development cycle, not once on commit.

That isn't a problem since the hook can be used additionally to running doit manually.