gl-auth now checks for and run a hook called 'gl-pre-git'

see sample code for motivation; other uses at your discretion
This commit is contained in:
Sitaram Chamarty 2011-03-04 06:44:06 +05:30
parent aab5ec9e6a
commit 396bfaa3b9
3 changed files with 41 additions and 0 deletions

View file

@ -159,6 +159,16 @@ die "$aa access for $repo DENIED to $user
# check if repo is write-enabled
check_repo_write_enabled($repo) if $aa eq 'W';
# run the pre-git hook if present (do this last, just before actually handing
# off to git). Force its output to go to STDERR so the git client does not
# get confused, in case the code in the pre-git hook forgot. To make it
# simple for the script, send in $aa (which will be 'R' or 'W') so now they
# have all three: GL_USER and GL_REPO in the env, and $aa as arg-1.
if (-x "$ENV{GL_REPO_BASE_ABS}/$repo.git/hooks/gl-pre-git") {
system("cd $ENV{GL_REPO_BASE_ABS}/$repo.git; hooks/gl-pre-git $aa >&2");
die "gl-pre-git hook failed ($?)\n" if $?;
}
# ----------------------------------------------------------------------------
# over to git now
# ----------------------------------------------------------------------------