Gitolite Update Hook exclude a repository

2019-01-15 16:49发布

I'm adding a gitolite update hook as a VREF and was wondering if there was a way to apply it to all of the repositories except for the gitolite-admin one.

Having a simpler way rather than listing all of the repositories I want to apply the hook on would be great.

Currently I have:

repo @all
-    VREF/update    =   @all

I was thinking of adding an exception above that one for the gitolite-admin repository. Something like:

repo gitolite-admin
RW+  VREF/update    =   @all

repo @all
-    VREF/update    =   @all

Is there a way to get a rule like this to work? Thanks for the help! (I tried this way and it didn't seem to work)

标签: hook gitolite
1条回答
Fickle 薄情
2楼-- · 2019-01-15 17:16

Just for other readers less familiar with VREF (introduced with "g3" or Gitolite V3).

The idea behind VREF rules are:

  • For every refex starting with VREF/FOO/ in a rule that applies to this user, a call to a program called FOO is triggered. Note that the program isn't even called if the VREF rule doesn't apply to that user.

This is why one can define an 'update' hook even though the update hook is reserved by gitolite.
A normal update hook expects 3 arguments (ref, old SHA, new SHA).
Any VREF will get those three, followed by at least 4 more. Your 'update' VREF should just ignore the extra args.

  • fallthru is considering success (ie you won't be denied a git operation on a repo because none of the VREF applied)
    If fallthru were to be considered 'failure', you'd be forced to add a "success rule" like this for every vref you used in this repo, in each case listing every user who was not already mentioned in the context of that vref

Considering the update VREF program, you could add a parameter which would allow your update script to recognize it is called in the gitolite-admin context (and should do nothing):

repo gitolite-admin
-  VREF/update/donothing    =   @all

repo @all
-  VREF/update    =   @all
查看更多
登录 后发表回答