Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pre-commit script to exist outside of modulesync Gem #127

Open
btsibr opened this issue Aug 7, 2017 · 5 comments
Open

Allow pre-commit script to exist outside of modulesync Gem #127

btsibr opened this issue Aug 7, 2017 · 5 comments

Comments

@btsibr
Copy link

btsibr commented Aug 7, 2017

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.

@steinbrueckri
Copy link

see also #148

@neomilium
Copy link
Contributor

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

@ekohl
Copy link
Member

ekohl commented Apr 23, 2021

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.

@neomilium
Copy link
Contributor

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.

@neomilium
Copy link
Contributor

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants