Skip to content

Ability to add/remove git hooks #9

Open

Description

@michaeldejong

Users should be able to add or remove git hooks for every repository (excluding gitolite-admin). This will probably require Java-Gitolite-Manager to be run on the git server (preferably on the git user).

Activity

  1. michaeldejong commented on Sep 9, 2013

    @michaeldejong
    MemberAuthor

    I've been trying to figure out how to write a post-update hook so I'll be able to notify a HTTP server.

    #!/usr/bin/perl -w
    
    use strict;
    use warnings;
    
    use lib $ENV{GL_LIBDIR};
    use Gitolite::Hooks::Update
    
    # gitolite update hook
    #---------------------------------------------------------------
    
    my $path = `pwd`;
    $path =~ s/\/home\/git\/repositories\///;
    `curl -s http://<host>/?repo=$path`;
    
    update();
    exit 1;
  2. alexnederlof commented on Sep 9, 2013

    @alexnederlof

    Why PERL? All variables are passed in a hook.

    It takes a variable number of parameters, each of which is the name of ref that was actually updated.

    https://www.kernel.org/pub/software/scm/git/docs/githooks.html

    You can use CURL to do form a POST body in Json and deliver that to a webserver.

    REVISION=$2  # or whatever it is
    curl -X POST -H "Content-Type: application/json" -d '{"revision":"$REVISION","repo":"xyz"}' http://the.url.com/hook
    
  3. michaeldejong commented on Sep 9, 2013

    @michaeldejong
    MemberAuthor

    Perl because, that's what Gitolite is using in the already existing post-update hook of my testing repo. I can easily switch to bash, but for now it's just to find out how these hooks work and test them. Also, my current aim is just to be able to notify a web server that a certain repository has received a push. It's up to that web server to determine if it's interested in fetching stuff like logs/diffs/branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions