gnustavo / Git-Hooks

Framework for implementing Git (and Gerrit) hooks
http://search.cpan.org/dist/Git-Hooks/
41 stars 17 forks source link

Skip checks after a timeout #53

Closed gnustavo closed 5 years ago

gnustavo commented 6 years ago

Sometimes the checks take a long time, such as when too many files are affected in a commit and they all need to be checked. Git::Hooks should accept a configuration option such that it would skip further checks after a specified amount of time.

The timeout should be detected by a signal handler which would enable a flag in the Git::Repository object, which could be checked by a method called "check_timeout()", for example.

The run_hooks function should check this method before invoking each plugin function.

Moreover, plugins such as CheckFile, which can take a long list of files to check, should also check the method before invoking external checks for each file.

I think on a timeout the hooks shouldn't return error, but simply print a warning telling that some checks were skipped due to time constraints. Or perhaps this could be an option also...

gnustavo commented 5 years ago

I implemented a githooks.timeout option but not quite as I described above.

It's not released yet, but it will be part of the next release.