Make repository autocreate add .git extension.

This commit is contained in:
Tommi Virtanen 2007-09-02 13:42:55 -07:00
parent 3dd96139a1
commit 70dbe1dfca
2 changed files with 24 additions and 3 deletions

View file

@ -112,7 +112,10 @@ def serve(
# it doesn't exist on the filesystem, but the configuration # it doesn't exist on the filesystem, but the configuration
# refers to it, we're serving a write request, and the user is # refers to it, we're serving a write request, and the user is
# authorized to do that: create the repository on the fly # 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 # put the verb back together with the new path
newcmd = "%(verb)s '%(newpath)s'" % dict( newcmd = "%(verb)s '%(newpath)s'" % dict(

View file

@ -136,5 +136,23 @@ def test_push_inits_if_needed():
user='jdoe', user='jdoe',
command="git-receive-pack 'foo'", command="git-receive-pack 'foo'",
) )
eq(os.listdir(tmp), ['foo']) eq(os.listdir(tmp), ['foo.git'])
assert os.path.isfile(os.path.join(tmp, 'foo', 'HEAD')) 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'))