0

We are using Ubuntu. I want to execute pre-commit hooks in all developer machine so in all developer machine it needs to setup manually because there is no possible to commit hooks script. please give me any solution for avoiding individual setup.

Thanks,

1 Answers1

1

There is no method that "avoid[s] individual setup". You can, however, make setup as simple as possible. For instance, suppose that the setup script clones the repository and sets up the hook. Then the setup is simply to run:

$ clone-and-set-hook [optional arguments]

Of course, that leaves the problem of getting everyone the clone-and-set-hook script. So instead, it could be three commands:

$ git clone ...url... [optional additional arguments]
$ cd clone-we-just-made
$ ./auxiliary/set-hook

where auxiliary/set-hook is a script that is included in the repository itself. The script should then check that you are in the correct Git repository (that you issued the cd command above), and that there is no pre-commit hook yet, and if so, set up the pre-commit hook.

torek
  • 448,244
  • 59
  • 642
  • 775
  • Thanks Mr Torek, anyhow I have to tell all developers to execute script. there may be chance of missing. so is there any way to execute corresponding script instead of involving/mannually? – Saroj Kumar Moharana Dec 16 '16 at 06:15
  • @SarojKumarMoharana: no. Anything that runs automatically is a security risk. No one should ever make software that runs untrusted code automatically (though many people do anyway). You can automate as much as you like *provided* you start from something you *trust*, so you can make this as simple as: "obtain this script, which we promise you can trust, in some trusted manner, then run the trusted script to obtain and set up the clone". But first you must obtain the trusted script in some trusted manner—perhaps by cloning from a trusted site. – torek Dec 16 '16 at 14:09