Пример #1
0
def set_export_ok(config):
    global_enable = util.getConfigDefaultBoolean(config, 'defaults', 'daemon', False)
    log.debug(
        'Global default is %r',
        {True: 'allow', False: 'deny'}.get(global_enable),
        )

    enable_if_all = util.getConfigDefaultBoolean(config, 'defaults', 'daemon-if-all', False)
    if enable_if_all:
        access_table = access.getAccessTable(config)
    log.debug(
        'If accessible to @all: %r',
        {True: 'allow', False: 'unchanged'}.get(enable_if_all),
        )

    for (dirpath, repo, name) in walk_repos(config):
        try:
            enable = config.getboolean('repo %s' % name, 'daemon')
        except (NoSectionError, NoOptionError):
            enable = global_enable
            if not enable and enable_if_all:
                (users,groups,all_refs) = access.getAllAccess(config,access_table,name)
                enable = ('@all' in all_refs)

        if enable:
            log.debug('Allow %r', name)
            allow_export(os.path.join(dirpath, repo))
        else:
            log.debug('Deny %r', name)
            deny_export(os.path.join(dirpath, repo))
Пример #2
0
def gen_htaccess_if_enabled(config):
    do_htaccess = util.getConfigDefaultBoolean(config, 'gitosis', 'htaccess', False)

    if do_htaccess:
        gen_htaccess(config)

    return do_htaccess
Пример #3
0
def generate_project_list_fp(config, fp):
    """
    Generate projects list for ``gitweb``.

    :param config: configuration to read projects from
    :type config: RawConfigParser

    :param fp: writable for ``projects.list``
    :type fp: (file-like, anything with ``.write(data)``)
    """
    log = logging.getLogger('gitosis.gitweb.generate_projects_list')

    global_enable = util.getConfigDefaultBoolean(config, 'defaults', 'gitweb', False)

    for (section, name, topdir, subpath) in enum_cfg_repos(config):
        enable = util.getConfigDefaultBoolean(config, section, 'gitweb', global_enable)
        if not enable:
            continue

        if not os.path.exists(os.path.join(topdir,subpath)):
            log.warning(
                'Cannot find %(name)r in %(topdir)r'
                % dict(name=name,topdir=topdir))
            # preserve old behavior, using the original name for
            # completely nonexistant repos:
            subpath = name

        response = [subpath]

        owner = util.getConfigDefault(config, section, 'owner', None)
        if owner:
            username = util.getConfigDefault(config, 'user %s' % owner, 'name', None)
            if username:
                response.append(username)
            response.append(owner)

        line = ' '.join([urllib.quote_plus(s) for s in response])
        print >>fp, line
Пример #4
0
def autoinit_repos(config):
    do_init = util.getConfigDefaultBoolean(config, 'gitosis', 'init-on-config', False)
    if not do_init:
        return

    for (section, name, topdir, subpath) in gitweb.enum_cfg_repos(config):
        if os.path.exists(os.path.join(topdir,subpath)):
            continue

        try:
            serve.auto_init_repo(config,topdir,subpath)
        except GitInitError, e:
            log.warning('Auto-init failed: %r' % e)
        except GitError, e:
            log.warning('Git error in init: %r' % e)