From 4e76065fb7752385a9a1212ff15d776498d5bedd Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Sat, 17 Nov 2007 17:40:34 +0200 Subject: Set description from config file for gitweb use. --- gitosis/gitweb.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'gitosis/gitweb.py') diff --git a/gitosis/gitweb.py b/gitosis/gitweb.py index fad4e84..b4b538b 100644 --- a/gitosis/gitweb.py +++ b/gitosis/gitweb.py @@ -47,7 +47,7 @@ def generate_project_list_fp(config, fp): :param fp: writable for ``projects.list`` :type fp: (file-like, anything with ``.write(data)``) """ - log = logging.getLogger('gitosis.gitweb') + log = logging.getLogger('gitosis.gitweb.generate_projects_list') repositories = util.getRepositoryDir(config) @@ -113,3 +113,53 @@ def generate_project_list(config, path): f.close() os.rename(tmp, path) + + +def set_descriptions(config): + """ + Set descriptions for gitweb use. + """ + log = logging.getLogger('gitosis.gitweb.set_descriptions') + + repositories = util.getRepositoryDir(config) + + for section in config.sections(): + l = section.split(None, 1) + type_ = l.pop(0) + if type_ != 'repo': + continue + if not l: + continue + + try: + description = config.get(section, 'description') + except (NoSectionError, NoOptionError): + continue + + if not description: + continue + + name, = l + + if not os.path.exists(os.path.join(repositories, name)): + namedotgit = '%s.git' % name + if os.path.exists(os.path.join(repositories, namedotgit)): + name = namedotgit + else: + log.warning( + 'Cannot find %(name)r in %(repositories)r' + % dict(name=name, repositories=repositories)) + continue + + path = os.path.join( + repositories, + name, + 'description', + ) + tmp = '%s.%d.tmp' % (path, os.getpid()) + f = file(tmp, 'w') + try: + print >>f, description + finally: + f.close() + os.rename(tmp, path) -- cgit v1.2.3