aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2007-09-02 13:42:55 -0700
committerTommi Virtanen <tv@eagain.net>2007-09-02 13:42:55 -0700
commit70dbe1dfca34f678bc227c73bef480baf6d9c23c (patch)
treedea0d8f8139048138c27d586352c39f75e7a0e59
parentMake gitosis-serve create repositories on demand when pushing. (diff)
downloadgitosis-dakkar-70dbe1dfca34f678bc227c73bef480baf6d9c23c.tar.gz
gitosis-dakkar-70dbe1dfca34f678bc227c73bef480baf6d9c23c.tar.bz2
gitosis-dakkar-70dbe1dfca34f678bc227c73bef480baf6d9c23c.zip
Make repository autocreate add .git extension.
-rw-r--r--gitosis/serve.py5
-rw-r--r--gitosis/test/test_serve.py22
2 files changed, 24 insertions, 3 deletions
diff --git a/gitosis/serve.py b/gitosis/serve.py
index 82976c8..df2d963 100644
--- a/gitosis/serve.py
+++ b/gitosis/serve.py
@@ -112,7 +112,10 @@ def serve(
# 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
- repository.init(path=newpath)
+ assert not newpath.endswith('.git'), \
+ 'git extension should have been stripped: %r' % newpath
+ repopath = '%s.git' % newpath
+ repository.init(path=repopath)
# put the verb back together with the new path
newcmd = "%(verb)s '%(newpath)s'" % dict(
diff --git a/gitosis/test/test_serve.py b/gitosis/test/test_serve.py
index bbffe16..846d720 100644
--- a/gitosis/test/test_serve.py
+++ b/gitosis/test/test_serve.py
@@ -136,5 +136,23 @@ def test_push_inits_if_needed():
user='jdoe',
command="git-receive-pack 'foo'",
)
- eq(os.listdir(tmp), ['foo'])
- assert os.path.isfile(os.path.join(tmp, 'foo', 'HEAD'))
+ eq(os.listdir(tmp), ['foo.git'])
+ assert os.path.isfile(os.path.join(tmp, 'foo.git', 'HEAD'))
+
+def test_push_inits_if_needed_haveExtension():
+ # a push to 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')
+ cfg.set('gitosis', 'repositories', tmp)
+ cfg.add_section('group foo')
+ cfg.set('group foo', 'members', 'jdoe')
+ cfg.set('group foo', 'writable', 'foo')
+ got = serve.serve(
+ cfg=cfg,
+ user='jdoe',
+ command="git-receive-pack 'foo.git'",
+ )
+ eq(os.listdir(tmp), ['foo.git'])
+ assert os.path.isfile(os.path.join(tmp, 'foo.git', 'HEAD'))