PRE_ and POST_CREATE triggers get an extra argument...

...when invoked by single-repo operations like auto-creating a wild
repo, or running perms or fork.
This commit is contained in:
Sitaram Chamarty 2012-06-14 13:17:34 +05:30
parent 57f82ee044
commit fbd745958e
5 changed files with 13 additions and 9 deletions

View file

@ -138,6 +138,10 @@ description of when the trigger runs:
repo is created by user action. Extra arguments: repo is created by user action. Extra arguments:
* repo * repo
* user * user
* invoking operation
* 'R' for fetch/clone/ls-remote, 'W' for push
* can also be anything set by the external command running the
trigger (e.g., see the perms and fork commands).
They are also run when a *normal* repo is created (say by adding a "repo 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: foo" line to the conf file). This case has only one extra argument:

View file

@ -59,4 +59,4 @@ ln -sf `gitolite query-rc GL_ADMIN_BASE`/hooks/common/* hooks
echo "$from" > gl-forked-from echo "$from" > gl-forked-from
# trigger post_create # trigger post_create
gitolite trigger POST_CREATE $to $GL_USER gitolite trigger POST_CREATE $to $GL_USER fork

View file

@ -55,14 +55,14 @@ if ( $ARGV[0] eq '-c' ) {
require Gitolite::Conf::Store; require Gitolite::Conf::Store;
Gitolite::Conf::Store->import; Gitolite::Conf::Store->import;
new_wild_repo( $repo, $ENV{GL_USER} ); new_wild_repo( $repo, $ENV{GL_USER}, 'perms-c' );
gl_log( 'create', $repo, $ENV{GL_USER} ); gl_log( 'create', $repo, $ENV{GL_USER}, 'perms-c' );
} }
} }
my $repo = shift; my $repo = shift;
setperms(@ARGV); setperms(@ARGV);
_system( "gitolite", "trigger", "POST_CREATE", $repo, $ENV{GL_USER} ); _system( "gitolite", "trigger", "POST_CREATE", $repo, $ENV{GL_USER}, 'perms' );
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------

View file

@ -107,8 +107,8 @@ sub main {
if ( repo_missing($repo) and access( $repo, $user, '^C', 'any' ) !~ /DENIED/ ) { if ( repo_missing($repo) and access( $repo, $user, '^C', 'any' ) !~ /DENIED/ ) {
require Gitolite::Conf::Store; require Gitolite::Conf::Store;
Gitolite::Conf::Store->import; Gitolite::Conf::Store->import;
new_wild_repo( $repo, $user ); new_wild_repo( $repo, $user, $aa );
gl_log( 'create', $repo, $user ); gl_log( 'create', $repo, $user, $aa );
} }
# a ref of 'any' signifies that this is a pre-git check, where we don't # a ref of 'any' signifies that this is a pre-git check, where we don't

View file

@ -184,14 +184,14 @@ sub new_repo {
} }
sub new_wild_repo { sub new_wild_repo {
my ( $repo, $user ) = @_; my ( $repo, $user, $aa ) = @_;
_chdir( $rc{GL_REPO_BASE} ); _chdir( $rc{GL_REPO_BASE} );
trigger( 'PRE_CREATE', $repo, $user ); trigger( 'PRE_CREATE', $repo, $user, $aa );
new_repo($repo); new_repo($repo);
_print( "$repo.git/gl-creator", $user ); _print( "$repo.git/gl-creator", $user );
_print( "$repo.git/gl-perms", "$rc{DEFAULT_ROLE_PERMS}\n" ) if $rc{DEFAULT_ROLE_PERMS}; _print( "$repo.git/gl-perms", "$rc{DEFAULT_ROLE_PERMS}\n" ) if $rc{DEFAULT_ROLE_PERMS};
trigger( 'POST_CREATE', $repo, $user ); trigger( 'POST_CREATE', $repo, $user, $aa );
_chdir( $rc{GL_ADMIN_BASE} ); _chdir( $rc{GL_ADMIN_BASE} );
} }