2

I intend to only accept the commits containning correct author information. like Author: Name<xxxx@xxx.org>

in gitolite, is there a way to implement it? BTW, I use V2. Thank you in advance.

Flyakite
  • 109
  • 8

1 Answers1

1

First, with Gitolite V3, it is called VREF, similar to an EMAIL_CHECK VREF.

You can also use in g2 (Gitolite V2) "virtual ref" (precursors of g3 VREF), including the check author email one: the script is "g2/contrib/VREF/gl-VREF-EMAIL_CHECK".
You would need to adapt that script to your own email control policy.

For a hook running for all repos on all users, a simpler version would be an update hook, but since that version uses the update hook already, you will need to chain your own update hook.
See "hook chaining".

To run your own 'update' hook, just put it in a file called update.secondary and install it as a hook.
Gitolite's update hook will automatically chain to it, taking care to pass it the same 3 arguments the original update hook received from git.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you VonC. Hook will run for all repos&usrs, VREF seems to be a good choice. For my own email control policy, do I need to write a perl script myself to implement the rules or is there an existing script in gitolite V2? If I write it myself, I have to put it in src/ and go with install process, right? – Flyakite Apr 11 '13 at 08:00
  • @Flyakite you would need to write your own script, put it in "`~/.gitolite/hooks/common`" and run "`gl-setup`" again: see http://gitolite.com/gitolite/g2/hooks.html – VonC Apr 11 '13 at 08:02
  • I put a echo "hello world" in `~/.gitolite/hooks/common/update.secondary`, then `chmod +x` and `gl-setup`. But when I run gl-setup, the code is gone. Do you have some ideas? Thank you:) – Flyakite Apr 17 '13 at 01:47
  • BTW, in gl-pre-git it works. And is it possible to run `git log --format="%ae" -1 $commit` in gl-pre-git or other hooks, what should I do? I tried `$ENV{GL_USER}` in gl-pre-git , but it is different with the info in git log. Many thanks. – Flyakite Apr 17 '13 at 03:14
  • @Flyakite it depends on the version of g2 your are using. [In older version](http://gitolite.googlecode.com/git/doc/2-admin.html?r=f023591183365980d11c1ba352461bea9863746f#_using_hooks), depending on the vay you installed it, you needed to run src/gl-easy-instal instead of `gl-setup`. But the recommended solution is to upgrade to g3. As [I mentioned before](http://stackoverflow.com/questions/16004729/regenerate-authorized-keys-file-in-gitolite/16008436#comment22836017_16008436)n this won't affect your existing repos. – VonC Apr 17 '13 at 05:26
  • thank you for the kind help, we are planning for the upgrade. And one more question... How can I get the commit hash that people want to push, from gitolite? I mean, if I use `git log --format="%ae" -1 `, it would be a top commit already in the repo. I intend to get the commit hash the people is going to push... – Flyakite Apr 17 '13 at 06:37
  • @Flyakite my script is another example: https://github.com/VonC/compileEverything/blob/master/gitolite/VREF/CHECKID.tpl, still based on a `git log $oldsha..$newsha`: it will list commits that are *being* pushed and will reject them if some policy is not properly followed. – VonC Apr 17 '13 at 06:41
  • cool, thank you very much:) What I did not know is the 3 argument mentioned in the document. It solved now, thank you. – Flyakite Apr 17 '13 at 07:48