aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2007-11-18 17:50:02 +0200
committerTommi Virtanen <tv@eagain.net>2007-11-18 17:50:02 +0200
commitbda6572c92a9717c54b5a371a764e7536392715f (patch)
tree9c0f64c036e8ff2978c54d4125b18f6d17c191d0 /gitosis
parentUpdate TODO list. (diff)
downloadgitosis-gentoo-bda6572c92a9717c54b5a371a764e7536392715f.tar.gz
gitosis-gentoo-bda6572c92a9717c54b5a371a764e7536392715f.tar.bz2
gitosis-gentoo-bda6572c92a9717c54b5a371a764e7536392715f.zip
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.
Diffstat (limited to 'gitosis')
-rw-r--r--gitosis/serve.py17
-rw-r--r--gitosis/test/test_serve.py66
2 files changed, 83 insertions, 0 deletions
diff --git a/gitosis/serve.py b/gitosis/serve.py
index e781dea..0b8f775 100644
--- a/gitosis/serve.py
+++ b/gitosis/serve.py
@@ -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(
diff --git a/gitosis/test/test_serve.py b/gitosis/test/test_serve.py
index 2372429..b842bdf 100644
--- a/gitosis/test/test_serve.py
+++ b/gitosis/test/test_serve.py
@@ -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)
+