aboutsummaryrefslogtreecommitdiff
path: root/gitosis/test/test_serve.py
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2007-11-15 20:56:15 +0200
committerTommi Virtanen <tv@eagain.net>2007-11-15 20:56:15 +0200
commita2e54704265b58abaa7a6edd0b64548974c69334 (patch)
treea78c9bc4e54cba195a12805917217ecce1ed3aca /gitosis/test/test_serve.py
parentFix copy-paste that made gitosis.gitweb use wrong logger. (diff)
downloadgitosis-dakkar-a2e54704265b58abaa7a6edd0b64548974c69334.tar.gz
gitosis-dakkar-a2e54704265b58abaa7a6edd0b64548974c69334.tar.bz2
gitosis-dakkar-a2e54704265b58abaa7a6edd0b64548974c69334.zip
Create leading directories when creating missing repos in gitosis-serve.
Creation is in gitosis.serve and not directly in repository.init(), because that's the location that can tell what part of the directory tree is allowed to be missing. Made the reconstructed git command include the extension as that was easier to do. haveAccess return value is now tuple, to preserve information on what parts of the path can be missing.
Diffstat (limited to 'gitosis/test/test_serve.py')
-rw-r--r--gitosis/test/test_serve.py44
1 files changed, 42 insertions, 2 deletions
diff --git a/gitosis/test/test_serve.py b/gitosis/test/test_serve.py
index 08a4e67..2372429 100644
--- a/gitosis/test/test_serve.py
+++ b/gitosis/test/test_serve.py
@@ -115,7 +115,7 @@ def test_simple_read():
user='jdoe',
command="git-upload-pack 'foo'",
)
- eq(got, "git-upload-pack '%s/foo'" % tmp)
+ eq(got, "git-upload-pack '%s/foo.git'" % tmp)
def test_simple_write():
tmp = util.maketemp()
@@ -131,7 +131,7 @@ def test_simple_write():
user='jdoe',
command="git-receive-pack 'foo'",
)
- eq(got, "git-receive-pack '%s/foo'" % tmp)
+ eq(got, "git-receive-pack '%s/foo.git'" % tmp)
def test_push_inits_if_needed():
# a push to a non-existent repository (but where config authorizes
@@ -169,6 +169,46 @@ def test_push_inits_if_needed_haveExtension():
eq(os.listdir(tmp), ['foo.git'])
assert os.path.isfile(os.path.join(tmp, 'foo.git', 'HEAD'))
+def test_push_inits_subdir_parent_missing():
+ tmp = util.maketemp()
+ cfg = RawConfigParser()
+ cfg.add_section('gitosis')
+ cfg.set('gitosis', 'repositories', tmp)
+ cfg.add_section('group foo')
+ cfg.set('group foo', 'members', 'jdoe')
+ cfg.set('group foo', 'writable', 'foo/bar')
+ serve.serve(
+ cfg=cfg,
+ user='jdoe',
+ command="git-receive-pack 'foo/bar.git'",
+ )
+ eq(os.listdir(tmp), ['foo'])
+ foo = os.path.join(tmp, 'foo')
+ util.check_mode(foo, 0750, is_dir=True)
+ eq(os.listdir(foo), ['bar.git'])
+ assert os.path.isfile(os.path.join(tmp, 'foo', 'bar.git', 'HEAD'))
+
+def test_push_inits_subdir_parent_exists():
+ tmp = util.maketemp()
+ foo = os.path.join(tmp, 'foo')
+ # silly mode on purpose; not to be touched
+ os.mkdir(foo, 0751)
+ cfg = RawConfigParser()
+ cfg.add_section('gitosis')
+ cfg.set('gitosis', 'repositories', tmp)
+ cfg.add_section('group foo')
+ cfg.set('group foo', 'members', 'jdoe')
+ cfg.set('group foo', 'writable', 'foo/bar')
+ serve.serve(
+ cfg=cfg,
+ user='jdoe',
+ command="git-receive-pack 'foo/bar.git'",
+ )
+ eq(os.listdir(tmp), ['foo'])
+ util.check_mode(foo, 0751, is_dir=True)
+ eq(os.listdir(foo), ['bar.git'])
+ assert os.path.isfile(os.path.join(tmp, 'foo', 'bar.git', 'HEAD'))
+
def test_push_inits_if_needed_existsWithExtension():
tmp = util.maketemp()
os.mkdir(os.path.join(tmp, 'foo.git'))