After we call "git init" for a new repository, we may want to
explicitly configure it for things like email notification and
mirroring. Add support for calling an external script to do exactly
that.
import logging
import sys, os, re
import logging
import sys, os, re
from gitosis import access
from gitosis import repository
from gitosis import access
from gitosis import repository
from gitosis import gitdaemon
from gitosis import app
from gitosis import util
from gitosis import gitdaemon
from gitosis import app
from gitosis import util
+from gitosis.repository import GitInitError
+
+from ConfigParser import NoSectionError, NoOptionError
log = logging.getLogger('gitosis.serve')
log = logging.getLogger('gitosis.serve')
+ try:
+ post_init_hook = cfg.get('hooks', 'post-init')
+ log.info ('Running post-init hook %s for new repository' % post_init_hook)
+ returncode = subprocess.call(
+ args=[ post_init_hook, repopath ],
+ stdout=sys.stderr
+ )
+ if returncode != 0:
+ raise GitInitError('exit status %d from post-init hook %s' % (returncode, post_init_hook))
+
+ except (NoSectionError, NoOptionError):
+ pass
+
# put the verb back together with the new path
newcmd = "%(verb)s '%(path)s'" % dict(
verb=verb,
# put the verb back together with the new path
newcmd = "%(verb)s '%(path)s'" % dict(
verb=verb,