gitolite_admin hooks and mirroring

后端 未结 3 718
攒了一身酷
攒了一身酷 2020-12-11 07:23

I\'m wondering is there a simple way to install hooks for certain repo using gitolite_admin.

Let\'s imagine i want to have post-update hook

3条回答
  •  旧时难觅i
    2020-12-11 08:09

    In addition to sitaram's answer, the recent (August 29th, 2013) commit 62fb31755a formerly introduce repo specific hooks:

    it's basically just creating a symlink in /hooks pointing to some file inside $rc{LOCAL_CODE}/hooks/repo-specific (except the gitolite-admin repo)

    You cannot specific a hook for gitolite-admin though.
    And you hook is only one of the three following authorized hooks:

    • pre-receive
    • post-receive
    • post-update

    That means you can:

    • store your repo specific hooks in your gitolite-admin/hooks/repo-specific/xx
    • declare those your in the gitolite-admin local options on the server.

    First enable those hooks:

    ENABLE => [
    
                 # allow repo-specific hooks to be added
                 # 'repo-specific-hooks', 
    

    Then declare the hooks on the server gitolite-admin repo:

    gitolite git-config gitolite-options.hook=reponame hookname scriptname
    

    (with a tab or \t between reponame hookname scriptname)


    Original answer:

    As mention in the gitolite man page on hooks

    if you want to install a hook in only a few specific repositories, do it directly on the server.

    (otherwise, you would be managing hooks for all git repos through gitolite-admin/common/hooks)

    That being said, you could take advantage of VREF in gitolite V3.x, which are update hooks: those can be set for some repos and for some user, like any other rule.
    You could then:

    • make your VREF script leave a 'flag' (a file) in the appropriate bare git repo being updated
    • make a common 'deploy' post-update hook, which would first look for that flag, and if found, deploy the repo (and remove the flag).

    Again:

    • a post-update hook managed through gitolite-admin can only be common to all git repos (not what you want)
    • only VREFs can be associated to repos and users through gitolite.conf

    The solution above tries to take those two facts into account to achieve what you are looking for: a deploy script running only for certain repos and managed through the gitolite.conf config file of the gitolite-admin repo.

提交回复
热议问题