diff options
author | Tommi Virtanen <tv@eagain.net> | 2007-06-05 14:06:33 +0300 |
---|---|---|
committer | Tommi Virtanen <tv@eagain.net> | 2007-06-05 14:06:33 +0300 |
commit | 4f6a8b8770e7aee232a3c88bf00c3ccce6378b62 (patch) | |
tree | 51c7dffde1d0c10d7b8ff1dc611bf2a8699d6c02 /gitosis/gitweb.py | |
parent | Extract test utility functions. (diff) | |
download | gitosis-dakkar-4f6a8b8770e7aee232a3c88bf00c3ccce6378b62.tar.gz gitosis-dakkar-4f6a8b8770e7aee232a3c88bf00c3ccce6378b62.tar.bz2 gitosis-dakkar-4f6a8b8770e7aee232a3c88bf00c3ccce6378b62.zip |
Add .git to gitweb projects list if only that version of path exists.
Diffstat (limited to 'gitosis/gitweb.py')
-rw-r--r-- | gitosis/gitweb.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/gitosis/gitweb.py b/gitosis/gitweb.py index 2ae682e..08f62f5 100644 --- a/gitosis/gitweb.py +++ b/gitosis/gitweb.py @@ -25,7 +25,7 @@ To plug this into ``gitweb``, you have two choices. isolates the changes a bit more nicely. Recommended. """ -import os, urllib +import os, urllib, logging from ConfigParser import RawConfigParser, NoSectionError, NoOptionError @@ -35,6 +35,16 @@ def _escape_filename(s): s = s.replace('"', '\\"') return s +def _getReposityDir(config): + repositories = os.path.expanduser('~') + try: + path = config.get('gitosis', 'repositories') + except (NoSectionError, NoOptionError): + pass + else: + repositories = os.path.join(repositories, path) + return repositories + def generate(config, fp): """ Generate a config file and projects list for ``gitweb``. @@ -45,6 +55,10 @@ def generate(config, fp): :param fp: writable for ``projects.list`` :type fp: (file-like, anything with ``.write(data)``) """ + log = logging.getLogger('gitosis.access.haveAccess') + + repositories = _getReposityDir(config) + try: global_enable = config.getboolean('gitosis', 'gitweb') except (NoSectionError, NoOptionError): @@ -67,6 +81,16 @@ def generate(config, fp): 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)) + response = [name] try: owner = config.get(section, 'owner') |