When autocreating repositories on push, set git-daemon-export-ok etc.

Without this, it would need a separate push to gitosis-admin.git,
after the repository is autocreated, to get it to show up and be
anonymously usable.
This commit is contained in:
Tommi Virtanen 2007-11-18 17:50:02 +02:00
parent af0081a197
commit bda6572c92
3 changed files with 83 additions and 3 deletions

View file

@ -6,9 +6,6 @@
- gitosis-lint: check that the user account (e.g. ``git``) looks valid
- create git-daemon-export-ok, description, projects.list etc when
autocreating repositorites?
- guard against *.pub files named -foo.pub or foo;bar.pub
- gitweb doesn't understand mappings, just visible/no,

View file

@ -10,6 +10,8 @@ import sys, os, re
from gitosis import access
from gitosis import repository
from gitosis import gitweb
from gitosis import gitdaemon
from gitosis import app
from gitosis import util
@ -112,6 +114,21 @@ def serve(
util.mkdir(p, 0750)
repository.init(path=fullpath)
gitweb.set_descriptions(
config=cfg,
)
gitosis_repo = os.path.join(topdir, 'gitosis-admin.git')
if os.path.isdir(gitosis_repo):
gitweb.generate_project_list(
config=cfg,
path=os.path.join(
gitosis_repo,
'projects.list',
),
)
gitdaemon.set_export_ok(
config=cfg,
)
# put the verb back together with the new path
newcmd = "%(verb)s '%(path)s'" % dict(

View file

@ -258,3 +258,69 @@ def test_push_inits_no_stdout_spam():
eq(got, '')
eq(os.listdir(tmp), ['foo.git'])
assert os.path.isfile(os.path.join(tmp, 'foo.git', 'HEAD'))
def test_push_inits_sets_description():
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')
cfg.add_section('repo foo')
cfg.set('repo foo', 'description', 'foodesc')
serve.serve(
cfg=cfg,
user='jdoe',
command="git-receive-pack 'foo'",
)
eq(os.listdir(tmp), ['foo.git'])
path = os.path.join(tmp, 'foo.git', 'description')
assert os.path.exists(path)
got = util.readFile(path)
eq(got, 'foodesc\n')
def test_push_inits_updates_projects_list():
tmp = util.maketemp()
os.mkdir(os.path.join(tmp, 'gitosis-admin.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')
cfg.add_section('repo foo')
cfg.set('repo foo', 'gitweb', 'yes')
serve.serve(
cfg=cfg,
user='jdoe',
command="git-receive-pack 'foo'",
)
eq(
sorted(os.listdir(tmp)),
sorted(['foo.git', 'gitosis-admin.git']),
)
path = os.path.join(tmp, 'gitosis-admin.git', 'projects.list')
assert os.path.exists(path)
got = util.readFile(path)
eq(got, 'foo.git\n')
def test_push_inits_sets_export_ok():
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')
cfg.add_section('repo foo')
cfg.set('repo foo', 'daemon', 'yes')
serve.serve(
cfg=cfg,
user='jdoe',
command="git-receive-pack 'foo'",
)
eq(os.listdir(tmp), ['foo.git'])
path = os.path.join(tmp, 'foo.git', 'git-daemon-export-ok')
assert os.path.exists(path)