From 0dc22b3155d359fc54d141e3355382ff044ba8e1 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Mon, 4 Jun 2007 14:22:56 +0300 Subject: [PATCH] Allow ``gitosis-serve`` incoming path names to always have ``.git`` suffix. Strip it before processing further. --- gitosis/access.py | 10 ++++++++++ gitosis/test/test_access.py | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/gitosis/access.py b/gitosis/access.py index 77be0c8..1e64072 100644 --- a/gitosis/access.py +++ b/gitosis/access.py @@ -23,6 +23,16 @@ def haveAccess(config, user, mode, path): path=path, )) + basename, ext = os.path.splitext(path) + if ext == '.git': + log.debug( + 'Stripping .git suffix from %(path)r, new value %(basename)r' + % dict( + path=path, + basename=basename, + )) + path = basename + for groupname in group.getMembership(config=config, user=user): try: repos = config.get('group %s' % groupname, mode) diff --git a/gitosis/test/test_access.py b/gitosis/test/test_access.py index 6e41a99..b9f2073 100644 --- a/gitosis/test/test_access.py +++ b/gitosis/test/test_access.py @@ -120,3 +120,12 @@ def test_base_local(): eq(access.haveAccess( config=cfg, user='jdoe', mode='writable', path='foo/bar'), 'some/relative/path/baz/quux/thud') + +def test_dotgit(): + # a .git extension is always allowed to be added + cfg = RawConfigParser() + cfg.add_section('group fooers') + 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')