aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Virtanen <tv@inoi.fi>2007-08-11 16:05:26 -0700
committerTommi Virtanen <tv@eagain.net>2007-08-11 17:28:52 -0700
commitc1b15d3e481cba65be193e37c04e70b03c7d68ca (patch)
treed8b9f7daec94c65ddcff101999c7300c48a3b69d
parentAdd .git to gitweb projects list if only that version of path exists. (diff)
downloadgitosis-dakkar-c1b15d3e481cba65be193e37c04e70b03c7d68ca.tar.gz
gitosis-dakkar-c1b15d3e481cba65be193e37c04e70b03c7d68ca.tar.bz2
gitosis-dakkar-c1b15d3e481cba65be193e37c04e70b03c7d68ca.zip
Add a default repository prefix.
Used to fail is gitosis.repositories is not set.
-rw-r--r--gitosis/access.py27
-rw-r--r--gitosis/test/test_access.py20
2 files changed, 28 insertions, 19 deletions
diff --git a/gitosis/access.py b/gitosis/access.py
index 1e64072..21724e0 100644
--- a/gitosis/access.py
+++ b/gitosis/access.py
@@ -77,19 +77,18 @@ def haveAccess(config, user, mode, path):
try:
prefix = config.get('gitosis', 'repositories')
except (NoSectionError, NoOptionError):
- pass
+ prefix = 'repositories'
- 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,
- ))
+ 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
diff --git a/gitosis/test/test_access.py b/gitosis/test/test_access.py
index b9f2073..66e799c 100644
--- a/gitosis/test/test_access.py
+++ b/gitosis/test/test_access.py
@@ -15,7 +15,7 @@ def test_write_yes_simple():
cfg.set('group fooers', 'members', 'jdoe')
cfg.set('group fooers', 'writable', 'foo/bar')
eq(access.haveAccess(config=cfg, user='jdoe', mode='writable', path='foo/bar'),
- 'foo/bar')
+ 'repositories/foo/bar')
def test_write_no_simple_wouldHaveReadonly():
cfg = RawConfigParser()
@@ -31,7 +31,7 @@ def test_write_yes_map():
cfg.set('group fooers', 'members', 'jdoe')
cfg.set('group fooers', 'map writable foo/bar', 'quux/thud')
eq(access.haveAccess(config=cfg, user='jdoe', mode='writable', path='foo/bar'),
- 'quux/thud')
+ 'repositories/quux/thud')
def test_write_no_map_wouldHaveReadonly():
cfg = RawConfigParser()
@@ -52,7 +52,7 @@ def test_read_yes_simple():
cfg.set('group fooers', 'members', 'jdoe')
cfg.set('group fooers', 'readonly', 'foo/bar')
eq(access.haveAccess(config=cfg, user='jdoe', mode='readonly', path='foo/bar'),
- 'foo/bar')
+ 'repositories/foo/bar')
def test_read_yes_simple_wouldHaveWritable():
cfg = RawConfigParser()
@@ -68,7 +68,7 @@ def test_read_yes_map():
cfg.set('group fooers', 'members', 'jdoe')
cfg.set('group fooers', 'map readonly foo/bar', 'quux/thud')
eq(access.haveAccess(config=cfg, user='jdoe', mode='readonly', path='foo/bar'),
- 'quux/thud')
+ 'repositories/quux/thud')
def test_read_yes_map_wouldHaveWritable():
cfg = RawConfigParser()
@@ -111,6 +111,16 @@ def test_base_global_relative_simple():
config=cfg, user='jdoe', mode='readonly', path='xyzzy'),
'some/relative/path/xyzzy')
+def test_base_global_unset():
+ cfg = RawConfigParser()
+ cfg.add_section('gitosis')
+ cfg.add_section('group fooers')
+ cfg.set('group fooers', 'members', 'jdoe')
+ cfg.set('group fooers', 'readonly', 'foo xyzzy bar')
+ eq(access.haveAccess(
+ config=cfg, user='jdoe', mode='readonly', path='xyzzy'),
+ 'repositories/xyzzy')
+
def test_base_local():
cfg = RawConfigParser()
cfg.add_section('group fooers')
@@ -128,4 +138,4 @@ def test_dotgit():
cfg.set('group fooers', 'members', 'jdoe')
cfg.set('group fooers', 'writable', 'foo/bar')
eq(access.haveAccess(config=cfg, user='jdoe', mode='writable', path='foo/bar.git'),
- 'foo/bar')
+ 'repositories/foo/bar')