aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2009-09-16 22:32:54 -0700
committerTommi Virtanen <tv@eagain.net>2009-09-16 22:32:59 -0700
commitdedb3dc63f413ed6eeba8082b7e93ad136b16d0d (patch)
tree464007fd2ac16f3261546e71060d7eba3e290252
parentFix unit test failure with git >=1.6.0 (diff)
downloadgitosis-gentoo-master.tar.gz
gitosis-gentoo-master.tar.bz2
gitosis-gentoo-master.zip
Let even readonly operations init a repo if needed.HEADmaster
Git >=1.6.2 support cloning empty repositories; this is a good way to bootstrap development on a new repository.
-rw-r--r--gitosis/serve.py3
-rw-r--r--gitosis/test/test_serve.py24
2 files changed, 25 insertions, 2 deletions
diff --git a/gitosis/serve.py b/gitosis/serve.py
index 867249e..d83b1d8 100644
--- a/gitosis/serve.py
+++ b/gitosis/serve.py
@@ -130,8 +130,7 @@ def serve(
'git extension should have been stripped: %r' % relpath
repopath = '%s.git' % relpath
fullpath = os.path.join(topdir, repopath)
- if (not os.path.exists(fullpath)
- and verb in COMMANDS_WRITE):
+ if not os.path.exists(fullpath):
# it doesn't exist on the filesystem, but the configuration
# refers to it, we're serving a write request, and the user is
# authorized to do that: create the repository on the fly
diff --git a/gitosis/test/test_serve.py b/gitosis/test/test_serve.py
index f1c1930..9884694 100644
--- a/gitosis/test/test_serve.py
+++ b/gitosis/test/test_serve.py
@@ -215,6 +215,30 @@ def test_simple_read_space():
)
eq(got, "git upload-pack '%s/foo.git'" % tmp)
+def test_read_inits_if_needed():
+ # a clone of a non-existent repository (but where config
+ # authorizes you to do that) will create the repository on the fly
+ tmp = util.maketemp()
+ cfg = RawConfigParser()
+ cfg.add_section('gitosis')
+ repositories = os.path.join(tmp, 'repositories')
+ os.mkdir(repositories)
+ cfg.set('gitosis', 'repositories', repositories)
+ generated = os.path.join(tmp, 'generated')
+ os.mkdir(generated)
+ cfg.set('gitosis', 'generate-files-in', generated)
+ cfg.add_section('group foo')
+ cfg.set('group foo', 'members', 'jdoe')
+ cfg.set('group foo', 'readonly', 'foo')
+ got = serve.serve(
+ cfg=cfg,
+ user='jdoe',
+ command="git-upload-pack 'foo'",
+ )
+ eq(got, "git-upload-pack '%s/foo.git'" % repositories)
+ eq(os.listdir(repositories), ['foo.git'])
+ assert os.path.isfile(os.path.join(repositories, 'foo.git', 'HEAD'))
+
def test_simple_write_dash():
tmp = util.maketemp()
repository.init(os.path.join(tmp, 'foo.git'))