From 0f3a09ce60e157c552d165f874102139feee678f Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Fri, 25 May 2012 12:26:52 +0530 Subject: [PATCH] PRE_ and POST_CREATE should work for normal repos also --- doc/triggers.mkd | 14 +++++++++----- src/lib/Gitolite/Conf.pm | 4 ++++ src/lib/Gitolite/Conf/Store.pm | 6 +++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/doc/triggers.mkd b/doc/triggers.mkd index 5ae8609..660ccd7 100644 --- a/doc/triggers.mkd +++ b/doc/triggers.mkd @@ -61,7 +61,7 @@ Triggers receive the following arguments: Here are the **rest of** the arguments for each trigger, plus a brief description of when the trigger runs: - * `ACCESS_1` runs after the first access check. Arguments: + * `ACCESS_1` runs after the first access check. Extra arguments: * repo * user * 'R' or 'W' @@ -71,7 +71,7 @@ description of when the trigger runs: result contains the refex that caused the access to succeed. * `ACCESS_2` runs after the second access check, in the update hook. - Arguments: + Extra arguments: * repo * user * any of W, +, C, D, WM, +M, CM, DM @@ -79,7 +79,7 @@ description of when the trigger runs: * result (see above) * `PRE_GIT` and `POST_GIT` run just before and after the git command. - Arguments: + Extra arguments: * repo * user * 'R' or 'W' @@ -88,12 +88,16 @@ description of when the trigger runs: 'git-upload-archive') being invoked. * `PRE_CREATE` and `POST_CREATE` run just before and after a new "[wild][]" - repo is created by user action. Arguments: + repo is created by user action. Extra arguments: * repo * user + They are also run when a *normal* repo is created (say by adding a "repo + foo" line to the conf file). This case has only one extra argument: + * repo + * `POST_COMPILE` runs after an admin push has successfully "compiled" the config file. By default, the next thing is to update the ssh authkeys file, then all the 'git-config's, gitweb access, and daemon access. - No arguments. + No extra arguments. diff --git a/src/lib/Gitolite/Conf.pm b/src/lib/Gitolite/Conf.pm index 8d8c82f..e7ca028 100644 --- a/src/lib/Gitolite/Conf.pm +++ b/src/lib/Gitolite/Conf.pm @@ -34,6 +34,10 @@ sub compile { # place to put the individual gl-conf files new_repos(); store(); + + for my $repo ( @{ $rc{NEW_REPOS_CREATED} } ) { + trigger( 'POST_CREATE', $repo ); + } } sub parse { diff --git a/src/lib/Gitolite/Conf/Store.pm b/src/lib/Gitolite/Conf/Store.pm index 4eb3c67..f4f4cf2 100644 --- a/src/lib/Gitolite/Conf/Store.pm +++ b/src/lib/Gitolite/Conf/Store.pm @@ -164,7 +164,11 @@ sub new_repos { # use gl-conf as a sentinel hook_1($repo) if -d "$repo.git" and not -f "$repo.git/gl-conf"; - new_repo($repo) if not -d "$repo.git"; + if (not -d "$repo.git") { + push @{ $rc{NEW_REPOS_CREATED} }, $repo; + trigger( 'PRE_CREATE', $repo ); + new_repo($repo); + } } }