aboutsummaryrefslogtreecommitdiff
path: root/gitosis/access.py
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2007-06-04 14:22:54 +0300
committerTommi Virtanen <tv@eagain.net>2007-06-04 14:22:54 +0300
commit7b99ae75833314a85dc5a1a51183620d917c29d6 (patch)
treee5269336681568f02dfa1113e1b6cef628d61a76 /gitosis/access.py
parentgitosis/serve.py is not meant to be a script, remove #! (diff)
downloadgitosis-dakkar-7b99ae75833314a85dc5a1a51183620d917c29d6.tar.gz
gitosis-dakkar-7b99ae75833314a85dc5a1a51183620d917c29d6.tar.bz2
gitosis-dakkar-7b99ae75833314a85dc5a1a51183620d917c29d6.zip
Add config option ``repositories``, for giving a path prefix to repositories.
Both global and relative (to home directory) values work, can be given in global section ``[gitosis]`` or in the ``[group FOO]`` section for just that group.
Diffstat (limited to 'gitosis/access.py')
-rw-r--r--gitosis/access.py59
1 files changed, 43 insertions, 16 deletions
diff --git a/gitosis/access.py b/gitosis/access.py
index 1146c2d..77be0c8 100644
--- a/gitosis/access.py
+++ b/gitosis/access.py
@@ -1,4 +1,4 @@
-import logging
+import os, logging
from ConfigParser import NoSectionError, NoOptionError
from gitosis import group
@@ -31,6 +31,8 @@ def haveAccess(config, user, mode, path):
else:
repos = repos.split()
+ mapping = None
+
if path in repos:
log.debug(
'Access ok for %(user)r as %(mode)r on %(path)r'
@@ -39,20 +41,45 @@ def haveAccess(config, user, mode, path):
mode=mode,
path=path,
))
- return path
-
- try:
- mapping = config.get('group %s' % groupname,
- 'map %s %s' % (mode, path))
- except (NoSectionError, NoOptionError):
- pass
+ mapping = path
else:
- log.debug(
- 'Access ok for %(user)r as %(mode)r on %(path)r=%(mapping)r'
- % dict(
- user=user,
- mode=mode,
- path=path,
- mapping=mapping,
- ))
+ try:
+ mapping = config.get('group %s' % groupname,
+ 'map %s %s' % (mode, path))
+ except (NoSectionError, NoOptionError):
+ pass
+ else:
+ log.debug(
+ 'Access ok for %(user)r as %(mode)r on %(path)r=%(mapping)r'
+ % dict(
+ user=user,
+ mode=mode,
+ path=path,
+ mapping=mapping,
+ ))
+
+ if mapping is not None:
+ prefix = None
+ try:
+ prefix = config.get(
+ 'group %s' % groupname, 'repositories')
+ except (NoSectionError, NoOptionError):
+ try:
+ prefix = config.get('gitosis', 'repositories')
+ except (NoSectionError, NoOptionError):
+ pass
+
+ if prefix is not None:
+ log.debug(
+ 'Using prefix %(prefix)r for %(path)r'
+ % dict(
+ prefix=prefix,
+ path=mapping,
+ ))
+ mapping = os.path.join(prefix, mapping)
+ log.debug(
+ 'New path is %(path)r'
+ % dict(
+ path=mapping,
+ ))
return mapping