Don't git init when it's not needed.
Confusion between pathnames with extensions and without made gitosis-serve confused when it needs to create a repository and when not.
This commit is contained in:
parent
e37b1dac1b
commit
2e068602d0
|
@ -93,14 +93,14 @@ def serve(
|
|||
# didn't have write access and tried to write
|
||||
raise WriteAccessDenied()
|
||||
|
||||
if (not os.path.exists(newpath)
|
||||
assert not newpath.endswith('.git'), \
|
||||
'git extension should have been stripped: %r' % newpath
|
||||
repopath = '%s.git' % newpath
|
||||
if (not os.path.exists(repopath)
|
||||
and verb in COMMANDS_WRITE):
|
||||
# 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
|
||||
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
|
||||
|
|
|
@ -143,7 +143,7 @@ def test_push_inits_if_needed():
|
|||
cfg.add_section('group foo')
|
||||
cfg.set('group foo', 'members', 'jdoe')
|
||||
cfg.set('group foo', 'writable', 'foo')
|
||||
got = serve.serve(
|
||||
serve.serve(
|
||||
cfg=cfg,
|
||||
user='jdoe',
|
||||
command="git-receive-pack 'foo'",
|
||||
|
@ -161,10 +161,31 @@ def test_push_inits_if_needed_haveExtension():
|
|||
cfg.add_section('group foo')
|
||||
cfg.set('group foo', 'members', 'jdoe')
|
||||
cfg.set('group foo', 'writable', 'foo')
|
||||
got = serve.serve(
|
||||
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'))
|
||||
|
||||
def test_push_inits_if_needed_existsWithExtension():
|
||||
tmp = util.maketemp()
|
||||
os.mkdir(os.path.join(tmp, 'foo.git'))
|
||||
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')
|
||||
serve.serve(
|
||||
cfg=cfg,
|
||||
user='jdoe',
|
||||
command="git-receive-pack 'foo'",
|
||||
)
|
||||
eq(os.listdir(tmp), ['foo.git'])
|
||||
# it should *not* have HEAD here as we just mkdirred it and didn't
|
||||
# create it properly, and the mock repo didn't have anything in
|
||||
# it.. having HEAD implies serve ran git init, which is supposed
|
||||
# to be unnecessary here
|
||||
eq(os.listdir(os.path.join(tmp, 'foo.git')), [])
|
||||
|
|
Loading…
Reference in a new issue