bahmutov / pre-git

Automatically install pre-commit / pre-push hooks in your git repo
168 stars 22 forks source link

Add a way to disable default behaviors #96

Closed bratanon closed 8 years ago

bratanon commented 8 years ago

This module make assumptions that everyone that installs it want the predefined behaviors in pre-commit.js and pre-push.js.

I would find it very good if these predefined behaviors was optional and could be enabled/disabled from the package.js config.

bahmutov commented 8 years ago

hmm, I see your point, a flag like this would be useful to disable the hooks

{
"config": {
  "pre-git": {
     "enabled": false
  }
}
bahmutov commented 8 years ago

Should be under version 3.11.0 Thanks for the suggestion

bratanon commented 8 years ago

This new thing does not make sense as it will disabled the whole module as I understand it. What I ment is the default behaviours in each of the mentioned hooks.

For example bin/pre-commit.js is by default first calling haveChangesToCommi()t. That is the default behaviour I'm talking about.

The same goes for bin/pre-push.js, it is calling haveCommitsToPush() the first thing.

A solution could be that those files have a condition whether or not to use the predefined behaviour or not.

{
"config": {
  "pre-git": {
     "pre-push-use-defaults": false
     "pre-push": []
  }
}

Then something like

const preGit = require('pre-git');
const config = preGit.getConfig();
...

...
if (config[pre-push-use-defaults])  {
  runTask((err) => {})
    .then(...
    ...
} else {
  haveCommitsToPush()
    .then(runTask, (err) => {
    ...
}
bahmutov commented 8 years ago

Well, in this case the initial issue was unclear, but your code contributions would be welcome!

Sent from my iPhone

On Nov 17, 2016, at 09:41, Emil Stjerneman notifications@github.com wrote:

This new thing does not make sense as it will disabled the whole module as I understand it. What I ment is the default behaviours in each of the mentioned hooks.

For example bin/pre-commit.js is by default first calling haveChangesToCommi()t. That is the default behaviour I'm talking about.

The same goes for bin/pre-push.js, it is calling haveCommitsToPush() the first thing.

A solution could be that those files have a condition whether or not to use the predefined behaviour or not.

{ "config": { "pre-git": { "pre-push-use-defaults": false "pre-push": [] } } Then something like

const preGit = require('pre-git'); const config = preGit.getConfig(); ...

... if (config[pre-push-use-defaults]) { runTask((err) => {}) .then(... ... } else { haveCommitsToPush() .then(runTask, (err) => { ... } — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

bahmutov commented 8 years ago

Hmm, yeah, this could be skipped per hook basis using command line options, plus you can always edit the tasks themselves to skip them?

bratanon commented 8 years ago

this could be skipped per hook basis using command line options

How?

you can always edit the tasks themselves to skip them

If I'm the only one using them, correct. But when there are more the one contributor that will not work as then every contributor must edit them.