modulesync
modulesync copied to clipboard
Allow pre-commit script to exist outside of modulesync Gem
The pre-commit script shouldn't need to be inside of modulesync itself (instead of forcing it to be in contrib).
At the simplest, if given an absolute path it should run that.
The primary use case here is that we have modulesync creating shell scripts and need to be able to chmod them prior to commit.
see also #148
Could someone describe a real-life example where its useful to use a pre commit hook in msync
context?
This way, we can write a behavior test and fix this issue accordingly.
Thanks
One use case is coding style checkers. For example, you can run rubocop
with -a
to automatically fix style errors. puppet-lint
has a similar operation.
Then there are 2 ways of dealing with that. First of all, it could be part of the "modulesync x.y.z" commit. However, I personally think a separate "autofix" commit makes more sense and makes reviewing easier. That would give a need for a post-commit hook.
Another could be to run a rake task, like validate. For example, I can imagine you want to verify you generated valid Ruby code in a template. bundle update
must succeed comes to mind.
Regarding our discussion about lightweight of the msync
, is this pre hook commit is not an overkill feature if we have an exec
and push
atomic command?
If pre commit hook stays interesting, what about rely on git
hooks?
ATM, it seems almost no one use this feature as there is only one available script, "hardcoded" is repo.
My first though is to drop this feature... just waiting to be convinced it make sense to (really) integrate it in msync
code base.
Thinking about this, I purpose a solution that looks better to me:
What about allowing user to specify hooks in configuration files?
Details: I think we could implement a way to install hooks, globally or per-module defined, and rely on git
hooks features to run the user specified hooks.
Example:
---
puppet-hello:
hooks:
pre_commit: '/usr/bin/true'
pre_push: 'bundle update'