Ensure "git init" doesn't write to stdout, and confuse a push.
The repository autocreation functionality ends up sending the stdout to the client side, and there a very confused git push can't make any sense of the protocol.
This commit is contained in:
parent
4d793f6fd4
commit
5df4b0c4f8
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from gitosis import util
|
||||
|
||||
|
@ -28,6 +29,7 @@ def init(
|
|||
returncode = subprocess.call(
|
||||
args=args,
|
||||
cwd=path,
|
||||
stdout=sys.stderr,
|
||||
close_fds=True,
|
||||
env=dict(GIT_DIR='.'),
|
||||
)
|
||||
|
|
|
@ -189,3 +189,32 @@ def test_push_inits_if_needed_existsWithExtension():
|
|||
# it.. having HEAD implies serve ran git init, which is supposed
|
||||
# to be unnecessary here
|
||||
eq(os.listdir(os.path.join(tmp, 'foo.git')), [])
|
||||
|
||||
def test_push_inits_no_stdout_spam():
|
||||
# git init has a tendency to spew to stdout, and that confuses
|
||||
# e.g. a git push
|
||||
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')
|
||||
old_stdout = os.dup(1)
|
||||
try:
|
||||
new_stdout = os.tmpfile()
|
||||
os.dup2(new_stdout.fileno(), 1)
|
||||
serve.serve(
|
||||
cfg=cfg,
|
||||
user='jdoe',
|
||||
command="git-receive-pack 'foo'",
|
||||
)
|
||||
finally:
|
||||
os.dup2(old_stdout, 1)
|
||||
os.close(old_stdout)
|
||||
new_stdout.seek(0)
|
||||
got = new_stdout.read()
|
||||
new_stdout.close()
|
||||
eq(got, '')
|
||||
eq(os.listdir(tmp), ['foo.git'])
|
||||
assert os.path.isfile(os.path.join(tmp, 'foo.git', 'HEAD'))
|
||||
|
|
Loading…
Reference in a new issue